Feature request
Similarly to detecting the wrong type passed to a function parameter, it would be great if PHPStan could detect the type used with new to ensure it's always valid, so any problems can be caught before runtime.
Acceptable types for new appear to be:
string (preferably class-string)
static keyword
self keyword
parent keyword
For example, the following should raise an error:
function get_class_name() : int {
return 123;
}
$class = get_class_name();
new $class;
Feature request
Similarly to detecting the wrong type passed to a function parameter, it would be great if PHPStan could detect the type used with
newto ensure it's always valid, so any problems can be caught before runtime.Acceptable types for
newappear to be:string(preferablyclass-string)statickeywordselfkeywordparentkeywordFor example, the following should raise an error: