-
-
Notifications
You must be signed in to change notification settings - Fork 946
Description
Bug report
I am trying to type hint an abstract class in the code.
Code snippet that reproduces the problem
I am using PHPStan with --level=0 in my configuration. The part of code in question:
protected function instantiateRequestParameter(string $requestParameter): AbstractParameter
{
/**
* @var AbstractParameter $requestParameter
*/
$input = $this->wrapInput($requestParameter::getParameterName());
return new $requestParameter($input, $this->builder, $this->modelConfig);
}Input comes from doing a foreach loop on registered parameters from config file. Each of these is an exact class which extends abstract class AbstractParameter.
The error I'm getting is:
Instantiated class Asseco\JsonQueryBuilder\RequestParameters\AbstractParameter is abstract
Once I remove the type hint, it all goes well. Can this be somehow mitigated not to show while at the same time having a type hint? I tried replacing it with interface, however in that case I am getting:
Cannot instantiate interface Asseco\JsonQueryBuilder\RequestParameters\Parameter
So in both cases it is the same. Any ideas?
Expected output
I expect it not to fail as I am never forwarding an abstract class to the method.