NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
'Find Declaration' won't find my function


Joined: 24 May 2008
Posts: 10
Reply with quote
Since there is no Bug forum I am going to post this here.

I had this function in file named reserv.php that was being called from 'includes/functions.php'
The function name was date_diff().
When I right clicked on it and selected 'Find Declaration' I was not sent to the functions.php in the includes folder.
I was sent to 'site/includes/functions.php' (a backup I have of the site inside the site)

So what is the 'Find declaration' doing? I think it's looking at every file in the project for the declaration of the date_diff function, which is completely wrong (as you can see in this scenario).
It should analyze the current file and look for require or include or something like that, something that would prevent it from giving me the wrong file.

This gave me quite a headache, because I then upload the file to the server and no changes took effect because I was editing the wrong file.

Hope this can be corrected!!!
View user's profileFind all posts by AntonioCSSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Quote:
It should analyze the current file and look for require or include or something like that, something that would prevent it from giving me the wrong file.

Seems you need to read php manual and check how it works in more details.
In short, it's not necessary to have any include/require statements in your file and get all the functions either from "site/include/functions.php" or "include/functions.php" to be accessible.
Just a trivial example:
fileA includes "site/include/functions.php" and also includes your file where you call date_diff().
In this case date_diff will be called in site/include/functions.php.
fileB includes "include/functions.php" and also includes your file where you call date_diff().
In this case date_diff will be called in include/functions.php.

I'd recommend you to remove backup (and all other possible duplications) from the project tree. You can do this by adding its directory name into the "Hide directories" in the project properties or placing the directory into another project or at least out of current project.


Last edited by dmitri on Fri Jan 30, 2009 7:17 am; edited 1 time in total

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 24 May 2008
Posts: 10
Reply with quote
Please do not think to teach me php.

I know very well functions are global, but if there is an include file in the current file phped should check if that file includes the function so I don't go back and forth for almost an hour checking why the code didn't update
View user's profileFind all posts by AntonioCSSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Quote:
I know very well functions are global, but if there is an include file in the current file phped should check if that file includes the function


IDE can not distiguish if include "include/functions.php" actually includes "site/include/functions.php" or "include/functions.php".
For example you might have "site" directory in your include_path setting in php.ini and therefore include would find "site/include/functions.php".

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website
'Find Declaration' won't find my function
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic