How to tell phpDoc a string is a class name?

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

enter image description here

Sorry, no other way as to tell that it's an instance of SomeObject.

... if I tell my IDE it's an instance of SomeObject, it thinks I can access regular non-static methods and properties, which I can't.

So? Just do not access non-static methods and properties.


UPDATE 2021-10-26: Since v2020.3 PhpStorm has Psalm Support and PHPStan Support plugins bundled. They support most of the syntax/types supported by those tools (you can check PhpStorm Issue Tracker here for all the tickets for those plugins (resolved and still pending)).

With those tools you can use class-string pseudo type:

  • https://psalm.dev/docs/annotating_code/type_syntax/scalar_types/#class-string-interface-string
  • https://phpstan.org/writing-php-code/phpdoc-types#class-string

PHPStan uses the class-string PHPDoc type for this. It has been supported by PHPStorm since 2020.3, but it seems to work properly (with all autocompletion available) as of 2021.2, when they added support for Generics.

In your case the return type annotation would be @return class-string<SomeObject>.