-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
@phpstan-assert tags are not correctly implicitly inherited #10037
Comments
@ondrejmirtes After the latest push in 1.11.x, PHPStan now reports different result with your code snippet: @@ @@
-PHP 8.1 – 8.3 (4 errors)
+PHP 8.2 – 8.3 (4 errors)
==========
+44: Dumped type: Identifier
+46: Dumped type: T of Identifier (class Fetcher, parameter)
+47: Parameter #1 $identifier of method PostFetcher::fetch() expects PostIdentifier, T of Identifier given.
+49: Parameter #1 $identifier of method PostFetcher::fetch() expects PostIdentifier, Identifier given.
+
+PHP 8.1 (5 errors)
+==========
+
+20: Readonly classes are supported only on PHP 8.2 and later.
44: Dumped type: Identifier
46: Dumped type: T of Identifier (class Fetcher, parameter)
47: Parameter #1 $identifier of method PostFetcher::fetch() expects PostIdentifier, T of Identifier given. Full reportPHP 8.2 – 8.3 (4 errors)
PHP 8.1 (5 errors)
PHP 7.2 – 8.0 (1 error)
|
Another similar issue https://phpstan.org/r/112d0f69-7672-4dbe-9621-fc9c45cae68b |
And another confirmed similar issue: #10520 How easy would an easy fix be :) Something I can help out with / any hint where to start? (searching for |
I guess it's a missing When fixing issues like this, it's worth it to go through all similar methods to see if the bug is also in a place that was not yet reported (while you have the right context in your head). |
Possible bugs in mergeThrowsTags, mergeSelfOutTypeTags. Needs to be verified first. |
Just quickly going over the code it indeed isn't called, I'll find out whether it's actually missing (or intended like this) when trying to fix it. Will check the others (throws, self-out as you mentioned, and possible others) as well in that case. I'll see what I can come up with during the weekend |
Closes phpstan/phpstan#10037 Closes phpstan/phpstan#9123
Fixed: phpstan/phpstan-src#2909 |
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. |
Bug report
See the example. It works only if the assert tag is repeated in PostFetcher.
Code snippet that reproduces the problem
https://phpstan.org/r/fb8735dc-026d-40ea-a724-c2e7eef04a9a
Expected output
Correct type in the truthy if branch.
Did PHPStan help you today? Did it make you happy in any way?
No response
The text was updated successfully, but these errors were encountered: