Editor PHP Libraries and PHPStorm
Editor PHP Libraries and PHPStorm
dclar43
Posts: 47Questions: 13Answers: 2
I'm looking into using Editor on my current project with PHPStorm as my IDE. I've been unable to get PHPStorm to 'register' Editor's classes and methods as seen here:
Does anyone have a solution or idea of how to address this?
This discussion has been closed.
Answers
Rather than using
className::inst()
could you trynew className()
- e.g.:The
::inst
static factory method is for compatibility with PHP 5.3 - 5.4 introduced the ability to chain from the constructor and it looks like PHPStorm might not be resolving that.Thanks,
Allan
Thanks for the reply Allan. Your reply got me on the right track. Your solution didn't work unfortunately but the following did initially address the problem.
However it failed to resolve the issue when it occurred chaining more than once. In this case the following snippet of code would still throw the original warning for
getFormatter
andsetFormatter
.The above solution made me realize the (obvious) source is likely the PHPDoc block associated with Ext::inst(). Since Ext::inst uses reflection PHPStorm can't automatically determine the return type. The PHPDoc block for Ext::inst() originally read
The issue is this line:
* @return Instantiated class
phpDocumentor is usually considered to be the default standard for PHPDoc blocks and PHPStorm uses that standard. According to their documentation @return's first parameter is the return type and the second is the description.
The problem line seems to only have a description. I was able to address this in the following 3 ways:
Removing the line
Replacing the line with:
* @return mixed Instantiated class
Replacing the line with:
* @return \DataTables\Editor\Field|\DataTables\Editor\Join|\DataTables\Editor\Upload Instantiated class
Thanks very much for looking into this further. I had no idea PHPStorm actually used the doc comments. I'll sort that out for the next release!
Regards,
Allan
Not a problem. Is there a method for reporting this kind of thing? Lot's of warnings and a couple errors popping up in PHPStorm, all superficial, that I'd be interested in addressing if I do end up going with Editor.
Also I realized that the 3rd solution posted above didn't cover
->process()
in this example:updating the PHPDoc line to
* @return DataTables\Editor|\DataTables\Editor\Field|\DataTables\Editor\Join|\DataTables\Editor\Upload Instantiated class
addresses that.
Also, Github Markdown apparently doesn't allow escaping the mention(@) character properly so ```php * @return`;`` shows up as
So if some of the formatting in these code blocks looks weird, that's why.
Yes, here in the forum as you have done. I suspect there are a few doc comments errors. I'll see if I can find a linter for them.
Allan