-
Notifications
You must be signed in to change notification settings - Fork 508
More precise types after assignment when strict-types=0 #3965
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
base: 2.1.x
Are you sure you want to change the base?
Conversation
This pull request has been marked as ready for review. |
I don't get why this is needed and why the current logic from #3945 doesn't already work for that. Can you explain please? |
|
This pull request has been marked as ready for review. |
@@ -0,0 +1,145 @@ | |||
<?php declare(strict_types = 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copied the test 12393 and changed only the strict_types to 0
I just forcepushed here how the code makes sense to me. We just need to fix the failing tests 😂 |
thanks for the hints.. I will look into the errors after a lunch break |
do you mean adjusting test expectations or fixing the underlying bugs? |
Fix the bugs |
ready for another review. added loads of new tests |
I didn't mean you to start changing the toCoerced... method. It we do that, we need to do it right. What I meant right now is to slightly adjust what the "else" branch in NodeScopeResolver does after my force-push. It's up to you 😊 |
I don't see a way how a slight change can fullfill the tests
could you give me an idea whats "wrong" in the current PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks promising. But you haven't touched toCoercedArgumentType
in some types. For example in ArrayTypeTrait, HasOffset*Type, accessory array types, NullType, ObjectType (Stringable object can be passed to string imho), ObjectTypeTrait.
For example VoidType should do (new NullType)->toCoercedArgumentType($strictTypes)
.
Improve types on top of #3945 but for the non-strict-types case.
see https://phpstan.org/r/aa5d5753-eca2-4735-bebf-6479e1ab1f42
do you think we could remove nullability from the property-type in scope, as the method we call returns a native non-nullable type, even ifstrict-types=0
...?closes phpstan/phpstan#12946
closes phpstan/phpstan#12940
closes phpstan/phpstan#12950
closes phpstan/phpstan#12947