Skip to content

Add FQCN support in Assert::implementsInterface #17

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

Closed
karser opened this issue Oct 21, 2019 · 2 comments · Fixed by #144
Closed

Add FQCN support in Assert::implementsInterface #17

karser opened this issue Oct 21, 2019 · 2 comments · Fixed by #144

Comments

@karser
Copy link

karser commented Oct 21, 2019

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.  
@mamazu
Copy link

mamazu commented Oct 31, 2019

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 .

@github-actions
Copy link

github-actions bot commented Nov 6, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants