phpstan-webmozart-assert
phpstan-webmozart-assert copied to clipboard
Add FQCN support in Assert::implementsInterface
The function implementsInterface($value, $interface, $message = '') from the docs
Check that a class implements an interface.
Here is the code:
<?php declare(strict_types=1);
namespace App;
use DateTimeInterface;
use Webmozart\Assert\Assert;
Assert::implementsInterface(\DateTime::class, DateTimeInterface::class);
Assert::implementsInterface(\DateTimeZone::class, DateTimeInterface::class);
Here is phpstan error:
Call to static method Webmozart\Assert\Assert::implementsInterface() with 'DateTime' and 'DateTimeInterface' will always evaluate to false.
Call to static method Webmozart\Assert\Assert::implementsInterface() with 'DateTimeZone' and 'DateTimeInterface' will always evaluate to false.
The error is not with the FQN, the problem is that the phpstan implementation is interpreting the first parameter as an object and checks if implements the interface and comes to the conclusion that the string "DateTime" never implements a DateTimeInterface. This should be fixed by #16 .
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.