When I call something like:
$class_name = '\App\Models\User';
$class_name::create($attributes);
PhpStorm shows an inspection warning "Method 'create' not found in string".
I don't want to switch off this inspection, as it's very useful in other cases. Is there another way to avoid the warning, using annotations or something else?
@var
PHPDoc annotation above the variable usage. In this case, it will look like/** @var $class_name \App\Models\User */
class-string
type from Psalm? psalm.dev/docs/annotating_code/type_syntax/scalar_types/… You need to have that plugin enabled in PhpStorm (it is enabled by default). You do not need the actual Psalm tool.