-
Notifications
You must be signed in to change notification settings - Fork 92
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
Form
is not subtype of native type FormInterface
#350
Comments
This is weird. Can you please create a small reproducing repository? |
I had the same issue. I ended up removing the phpdoc and surrounding some code with an if statement with |
We have the same issue currently (1.4.5 + PHPStan 1.11.6). Consider simplified code: services:
# Interface
Foo\ClientFactory: '@Foo\ApplicationClientFactory'
# Implementation
Foo\ApplicationClientFactory: ~ then, when we do something like: /** @var \Foo\ClientFactory $factory */
$factory = $container->get(\Foo\ClientFactory::class); we get an error:
which does not make sense. We fetch |
PHPStan doesn't want you to use a less specific type in the PHPDoc, because it already knows a more specific type. More often than not, you can simply delete this They're considered harmful anyway: https://phpstan.org/blog/phpstan-1-10-comes-with-lie-detector#validate-inline-phpdoc-%40var-tag-type |
But I don't want more specific type here, as the whole idea of interface is interchangeability. In the code, when I fetch I believe it's a bug and PHPStan should not narrow the type here. Similar here, I believe I should be allowed to restrict the contract to interface instead of relying on extended implementation.
I agree and I don't use |
@Wirone This is a completely different issue than the thing this was originally opened for so please create a separate one. |
Starting with version 1.3.0 of
phpstan/phpstan-symfony
, the following code is not valid anymore.Until version 1.2.25, no problems were reported here, but now I get the following error:
The text was updated successfully, but these errors were encountered: