欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

Jump to function declaration in php

I have the following ide's for php

  1. Dreamweaver
  2. php-Eclipse
  3. Textpad

I wish to jump to a function's definition which is located in another file which is not yet open. How could I do that. I am studying a websites code and have the entire directory structure in my local root folder. I come across certain functions and I don't know in which file their definition is. Please suggest something.




 

In eclipse PDT IDE put mouse over class name, property, method or function name (must be in opened eclipse project) and press CTRL + clic.

It work with almost all declarations, even constants and class constants. In most case it will work, but it can have trouble with some dynamic property assignement like magic methods or certain injected dependency.

The file will be opened, and if target is in same file code view will scroll to the declaration

shareimprove this answer
 
   
No its not doing that ..ive pasted a screenshot link pls check – aeonsleo May 18 '10 at 12:29
   
Nope your screenshot show highlight on selection, but if in your example variables $today_milestone and $upcoming_milestone are typed in the file (with cast or new declaration), and the source file of their class is parsed in eclipse cache (ie included in project, and visible in project explorer if created outside), you can do the CTRL + click. It will open the class file and point cursor to method declaration. In addition to new object instanciation and casts I know eclipse PDT also use docblocs to guess variable types, so it will be easier if your code has well-formed docblocks – Benoit May 18 '10 at 12:40
   
Its highlighting all the instances within the same document but the classs files are in separate folder. I am used to 'oop' but new to php. I cant see any include files either and am not sure of other include methods you are talking. I have done similar stuff in visual studio with C# and it works in eclipse too but not really getting it. – aeonsleo May 18 '10 at 12:49
   
yes it's a bit obscure, I think eclipse can not guess the right objects type so their methods can not be linked with their declaration. Also I'm talking about Eclipse version I use at work (3.4.2) with PDT, i can work differently in other versions or php plugins – Benoit May 18 '10 at 13:11
 

Press F3 in eclipse and you will find the declaration.

shareimprove this answer
 

go to function definition

To jump to function definition for Dreamweaver just add this extension:http://code.google.com/p/dwoop/.

Also you can add Autocomplete feature to Dreamweaver by going to Site --> Site Specific code hints --> select a folder which you want to scan for autocomplete --> save it with any custom name you want.

This works with any type of project (wordpress, codeigniter...)

shareimprove this answer
 
   
can any one help.i can not see image on my answer although i uploaded it through image upload icon ! i can not see links also ! – ashraf mohammed Mar 8 '14 at 11:06
1 
You have four spaces before your text, this means the text is interpreted as code. Remove them and you should be fine. – Dan Lee Mar 8 '14 at 12:01
   
@DanLee thanks so much.i appreciate it. – ashraf mohammed Mar 8 '14 at 16:09

I wish to jump to a function's definition which is located in another file which is not yet open.

I can suggest you about dreamweaver, the one i use. Point the cursor at the file that is included via php's includerequire, etc or within link's href and src attribute and press Cntr+D and that file should open.

For functions, just right click anywhere on the document, in the context menu you should see the Functions link about all functions defined in the document.

shareimprove this answer
 
   
the function is not defined in the same php file. I need to open the file which has the definition. What i had to do is to search for that word and browse thru all the occurences to find that file but it is very tedious. – aeonsleo May 18 '10 at 12:11

phpDesigner can do that

shareimprove this answer
 
   
Too bad it's not free. – montrealist Aug 11 '11 at 15:24

In an opposite direction, and perhaps out of question's field, but if your code if OOP and you want to study it you can try automated tools to get UML view of its architecture , but these softwares are generally not free.

shareimprove this answer
 

I found a way of going to the function definition. Using help in dreamweaver and selecting the option of searching wihtin a folder type 'function function_name()' and unselect all the checkboxes below. if you press find it will start opening pages which containg the expression or find all will not open any pages but show the list of all the pages in the bottom panel.

shareimprove this answer
 

Well, I'm currently working with Dreamweaver CC. If you want to jump to Function Definition from code, just select the desired function and then right click -> then select "Find Selection" option or you can use "Shift+F3", and you will be redirected to the code where the function is defined. enter image description here


In eclipse PDT IDE put mouse over class name, property, method or function name (must be in opened eclipse project) and press CTRL + clic.

It work with almost all declarations, even constants and class constants. In most case it will work, but it can have trouble with some dynamic property assignement like magic methods or certain injected dependency.

The file will be opened, and if target is in same file code view will scroll to the declaration

shareimprove this answer
 
   
No its not doing that ..ive pasted a screenshot link pls check – aeonsleo May 18 '10 at 12:29
   
Nope your screenshot show highlight on selection, but if in your example variables $today_milestone and $upcoming_milestone are typed in the file (with cast or new declaration), and the source file of their class is parsed in eclipse cache (ie included in project, and visible in project explorer if created outside), you can do the CTRL + click. It will open the class file and point cursor to method declaration. In addition to new object instanciation and casts I know eclipse PDT also use docblocs to guess variable types, so it will be easier if your code has well-formed docblocks – Benoit May 18 '10 at 12:40
   
Its highlighting all the instances within the same document but the classs files are in separate folder. I am used to 'oop' but new to php. I cant see any include files either and am not sure of other include methods you are talking. I have done similar stuff in visual studio with C# and it works in eclipse too but not really getting it. – aeonsleo May 18 '10 at 12:49
   
yes it's a bit obscure, I think eclipse can not guess the right objects type so their methods can not be linked with their declaration. Also I'm talking about Eclipse version I use at work (3.4.2) with PDT, i can work differently in other versions or php plugins – Benoit May 18 '10 at 13:11
 

Press F3 in eclipse and you will find the declaration.

shareimprove this answer
 

go to function definition

To jump to function definition for Dreamweaver just add this extension:http://code.google.com/p/dwoop/.

Also you can add Autocomplete feature to Dreamweaver by going to Site --> Site Specific code hints --> select a folder which you want to scan for autocomplete --> save it with any custom name you want.

This works with any type of project (wordpress, codeigniter...)

shareimprove this answer
 
   
can any one help.i can not see image on my answer although i uploaded it through image upload icon ! i can not see links also ! – ashraf mohammed Mar 8 '14 at 11:06
1 
You have four spaces before your text, this means the text is interpreted as code. Remove them and you should be fine. – Dan Lee Mar 8 '14 at 12:01
   
@DanLee thanks so much.i appreciate it. – ashraf mohammed Mar 8 '14 at 16:09

I wish to jump to a function's definition which is located in another file which is not yet open.

I can suggest you about dreamweaver, the one i use. Point the cursor at the file that is included via php's includerequire, etc or within link's href and src attribute and press Cntr+D and that file should open.

For functions, just right click anywhere on the document, in the context menu you should see the Functions link about all functions defined in the document.

shareimprove this answer
 
   
the function is not defined in the same php file. I need to open the file which has the definition. What i had to do is to search for that word and browse thru all the occurences to find that file but it is very tedious. – aeonsleo May 18 '10 at 12:11

phpDesigner can do that

shareimprove this answer
 
   
Too bad it's not free. – montrealist Aug 11 '11 at 15:24

In an opposite direction, and perhaps out of question's field, but if your code if OOP and you want to study it you can try automated tools to get UML view of its architecture , but these softwares are generally not free.

shareimprove this answer
 

I found a way of going to the function definition. Using help in dreamweaver and selecting the option of searching wihtin a folder type 'function function_name()' and unselect all the checkboxes below. if you press find it will start opening pages which containg the expression or find all will not open any pages but show the list of all the pages in the bottom panel.

shareimprove this answer
 

Well, I'm currently working with Dreamweaver CC. If you want to jump to Function Definition from code, just select the desired function and then right click -> then select "Find Selection" option or you can use "Shift+F3", and you will be redirected to the code where the function is defined. enter image description here

来自 http://stackoverflow.com/questions/2857009/jump-to-function-declaration-in-php
普通分类: