-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Assert::implementsInterface #15
Add Assert::implementsInterface #15
Conversation
Thank you! Will tag it promptly. |
Nice pull request however this doesn't work in the case where both arguments are strings which the assert function allows. |
Yes, AFAIK PHPStan does not understand |
Yeah I would also go with the return new \PhpParser\Node\Expr\FuncCall(
new \PhpParser\Node\Name('in_array'),
[
$class,
new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('class_implements'), [$expr]),
]
); |
I’m not sure there’s class_implements dynamic return type extension in PHPStan and that this would work... |
True. |
But the only thing that phpstan could optimize for are two cases:
But |
Hi, PHPStan is reporting errors where it should not when upgrading to this version. The following code is, imo, correct: class FilterDefinition
{
/* @var string */
private $filterClass;
/**
* @param string $filterClass FQCN of a filter class. The string must be a PHP class which implements the {@see FilterInterface}
*/
public function __construct(string $filterClass)
{
Assert::implementsInterface($filterClass, FilterInterface::class);
$this->filterClass = $filterClass;
}
} Instances of
Any suggested workaround, other than fixing the version to |
Yeah that's the same issue I also tried to fix in my merge request. But the quick fix would be to create an object of that class, which is probably not really a possible solution. |
I see. No, instantiating the class is not an option here, so I'll have to downgrade. Just wanted to add the comment here for visibility, that this issue affects someone else as well :) |
No description provided.