How to say phpDoc, a string is a class name?

I often give objects to static methods and properties that do not require object initialization. For instance:

class SomeObject {
    public function __construct($object_id) {
        $this->loadProperties($object_id);
    }

    public static function getSomeStaticString() {
        return "some static string";
    }
}

Now we subclass these objects and have some kind of controller that returns an object class string under certain circumstances, when the object has not yet to be initialized. For instance:

class SomeObjectController {
    public function getSomeObjectWithTheseProperties(array $properties) {
        if($properties[0] === "somevalue") {
            if($properties[1] === "someothervalue") {
                return SomeSubclassObject::class;
            }

            return SomeObject::class;
        }

        return NULL;
    }
}

Sometimes I may need to call a static function SomeObject::getSomeStaticString()without actually initializing the object (because it involves retrieving an unnecessary database). For instance:

$controller = new SomeObjectController;
$properties = array("somevalue", "someothervalue");
$object_class = $controller->getSomeObjectWithTheseProperties($properties);

echo $object_class::getSomeStaticString();

Question: can I somehow tell PhpStorm, preferably through phpDoc, that $object_classthis is a subclass class string SomeObject?

IDE , , getSomeStaticString() . , IDE SomeObject, , , .

+4
1
/** @var SomeObject $object_class */
$object_class = $controller->getSomeObjectWithTheseProperties($properties);

enter image description here

, , SomeObject.

... IDE SomeObject, , , .

? .

0

All Articles