4 Replies Last post: Jul 7, 2013 9:25 AM by Danial RKH  
Danial RKH Newbie 49 posts since
Feb 14, 2013
Currently Being Moderated

Jun 30, 2013 12:08 PM

Auto complete for dynamic methods

hi every body

in my project there is a part that generate dynamic functions and method that phpstorm can not detect them

are there any way to define that functions or class or methods that phpstorm can show it when typing code ?


it's not important how it is hard for example in a file i define that functions or method then phpstorm appear them in drop-down menu for auto complete

Andriy Bazanov Master 3,641 posts since
May 28, 2010
Currently Being Moderated
Jul 4, 2013 4:10 PM in response to: Danial RKH
Re: Auto complete for dynamic methods

Hi there,

 

Please show an example -- just to be 100% clear on what exactly you have there.

 

In any case:

  • dynamically-created function (normal function, not a class method) -- easy -- just create it in some .php file (stub file -- just a declaration (name, parameters, PHPDoc) -- leave body empty) and place such file anywhere in the project  -- it will be used for IDE only. That's actually how all known to PhpStorm functions/classes are done anyway.
  • dynamically-created class -- the same idea as above (as long as class name is unique)
  • dynamically-created methods -- it depends. Usually it's done via @method PHPDoc tag in the class where they are declared. But if you cannot edit that class (e.g. 3rd party library) then no -- you cannot "attach" aditional members to already defined class ( http://youtrack.jetbrains.com/issue/WI-851 ).
Andriy Bazanov Master 3,641 posts since
May 28, 2010
Currently Being Moderated
Jul 5, 2013 9:11 PM in response to: Danial RKH
Re: Auto complete for dynamic methods

Sorry .. I'm still not 100% clear on the actual issue (I mean -- what files you can edit and what not).

 

But regarding your example -- this solves it:

 

class class2
{     /** @var class1 */     public $myClass;

More Like This

  • Retrieving data ...