Skip to content
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

Wrong type assumptions #5172

Closed
jrmajor opened this issue Jun 14, 2021 · 3 comments
Closed

Wrong type assumptions #5172

jrmajor opened this issue Jun 14, 2021 · 3 comments
Labels
Milestone

Comments

@jrmajor
Copy link

jrmajor commented Jun 14, 2021

Bug report

Code snippet that reproduces the problem

https://phpstan.org/r/c9afcc1a-1d8b-48d6-aaf8-8ae3dead2e03

Expected output

Dumped type in lines 21/22 is mixed~null, which is a wrong assumption (in case I pointed out in a comment).

Also, the message Using nullsafe property access on non-nullable type mixed. Use -> instead. makes no sense, because mixed is a nullable type.

Did PHPStan help you today? Did it make you happy in any way?

PHPStan makes me happier every day!

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Jun 15, 2021
@phpstan-bot
Copy link
Contributor

@jrmajor After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-12: Dumped type: mixed
-13: Dumped type: mixed
-21: Dumped type: mixed~null
-22: Dumped type: mixed~null
-24: Using nullsafe property access on non-nullable type mixed. Use -> instead.
+-1: Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40
+Run PHPStan with --debug option and post the stack trace to:
+https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md
Full report
Line Error
-1 Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40Run PHPStan with --debug option and post the stack trace to:https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src#2577

@github-actions
Copy link

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 Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants