Answer the question
In order to leave comments, you need to log in
How to use phpDoc to describe two variants of a method at once, overloaded via __call and __callStatic?
The class has two magic methods, __call and callStatic , which overload the conditional read() method. If this method is accessed as a static method, the entity id is passed to it for reading. If it is accessed as a class instance method, nothing is passed to it, the id is taken from the instance property.
In both cases, the same either newly created or already existing instance of the class is returned. Before the class, I try to write both variants of the method like this, static and not:
/**
* Class Entity
*
* @package MyCompany\Contracts
*
* @property array $data
* @property int $id
* @property string $name
*
* @method Entity read()
* @method static Entity read( $id )
*/
Method with same name already defined in this class
Another definition with same name exists in this file
Answer the question
In order to leave comments, you need to log in
No, this behavior is not built into the IDE, and it cannot be prompted in any way.
If you try to declare 2 methods inside the class - with the same name, you will get exactly the same error. Method with same name already defined in this class . Actually, this is the expected behavior when you describe methods in phpDoc.
class Test {
public function test() {
}
public static function test() {
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question