KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
tl;dr What is the correct way to annotate (in PHPDoc) functions implemented via __callStatic ? More important: is there a way that will make NetBeans and PHPStorm understand that these are static methods? Motivation If you want the bigger picture, here's how I got to this question. Problem : In my current project we have a ton of classes that should really be singletons (DB proxies and the like). Needless to say, we have at least a few hundred require_once and $foo = new FooProxy(); lines. Solution : I created a Loader class to solve this, using the __callStatic magic method so we can just say $foo = Loader::FooProxy(); . It's perfect for our purposes, but: Problem : This way there's obviously no type hinting in either IDE used in the team. Solution : Every module defines a subclass of Loader , adding methods that just route to __callStatic . Problem : Adding actually interpreted code just for auto-completion's sake is not acceptable (this could be argued, but let's accept it for the time being). Solution : Let's not add any real methods, only declare the methods in PHPDoc like this: <?php /** * @method FooProxy FooProxy() */ class BarLoader extends Loader {} ?> Problem : FooProxy is not a static method. None of the following make it static either: <?php /** * @static * @method FooProxy FooProxy() */ /////////////// /** * @static @method A A() * @method static A A() * @method A static A() * @method A A() static */ Making the class abstract makes no difference. About an hour of Google'ing turned up no solutions. The primary goal is to make the IDEs aware of these functions; having correct PHPDo
Tags (comma-separated)
Save Edits
Cancel