V
V
Vadim2011-12-08 15:46:55
phpstorm
Vadim, 2011-12-08 15:46:55

How to declare "magic" methods in PhpStorm?

Initial data - there is a project based on a third-party engine. And in this engine there is a mechanism for autoloading modules when calling their methods. The project is being done in PhpStorm . And I would like, without touching the source files of the engine, to create a file with an explicit description of calls to all possible methods.

For example, there is a class Foo (in the file Foo.class.php):

class Foo {
function A() {
$this->Bar_B(); // class Bar is automatically loaded here and its method B() is called
}
}

I would like not to touch the Foo.class.php file, but somewhere to describe it like:
/**
* @method int Bar_B() autoloaded method
*/

I don't want to write it directly in Foo.class.php because the engine is periodically updated, and touching its “native” files is somehow not ice. Nobody knows, in PhpStorm some other ways of solving this problem are possible?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Anatoly, 2011-12-08
@taliban

Dumb option of course, but still:


/** @var $tmp Bar; */
$tmp = $foo->A();
$tmp->//autocomplite for Bar goes here

A
Anton, 2011-12-08
@sHinE

In general, the description of methods in separate files can be set - make ctrl + click on some built-in function, but I don’t know how to connect my own such file.

V
Vladimir Chernyshev, 2011-12-08
@VolCh

Not really a direct answer to the question, more
like a workaround the engine is periodically updated, and touching its “native” files is somehow not ice.
Normal VCSs usually handle adding a couple of lines automatically. I'm currently working on a fork of an open source project. Project on SVN, I work in Mercurial (hg) - there were about 40 updates of the original in a month - manual intervention in the process of merging the original and mine edits was needed only once, and then for some trifle like I changed the default color to my own, and then they changed the default and hg did not figure out which one to leave.
If you use the original engine as a library, that is, you don’t touch it at all, but include its files in your own, then you can make a subrepository instead of a fork. And after you add comments, send them to the authors of the original engine, maybe they will add them and the problem will disappear :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question