-
Notifications
You must be signed in to change notification settings - Fork 504
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
Allow asserting array offset certainty #3503
Allow asserting array offset certainty #3503
Conversation
You've opened the pull request against the latest branch 2.0.x. PHPStan 2.0 is not going to be released for months. If your code is relevant on 1.12.x and you want it to be released sooner, please rebase your pull request and change its target to 1.12.x. |
76f24ad
to
d92c523
Compare
d92c523
to
47fbf55
Compare
nice one! |
f8ac7b6
to
af44d78
Compare
@ondrejmirtes I pushed another commit to add assertions on the errors. Is this what you had in mind? |
@ondrejmirtes Would be great to have this part of the next release 🙏. Does this need more testing? |
* @dataProvider dataFile | ||
*/ | ||
public function testFile(string $file): void | ||
public function testFile(string $file, array $expectedFailures = []): void |
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.
Don't change this signature. Don't change the many yield
lines. It doesn't make sense to expect failures outside of testing the actual implementation.
There's already TypeInferenceTestCaseTest. Test it there.
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.
It seems the last part of your comment was not stored...
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.
I meant to delete that :)
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.
@ondrejmirtes Done, I hope this is what you had in mind.
5a8c907
to
351ee4a
Compare
$this->assertSame('variable $context', $variableAssert[4]); | ||
$this->assertSame("offset 'email'", $offsetAssert[4]); |
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.
I did it this way, because the rest in this test did not actually ran the assertions, it only waited for thrown acceptors. See line 91 above.
So if you think we should actually call the asserts, please tell me how, and I'll make the change.
Then we can assert on the full error message.
@ondrejmirtes I think this one is now ready to go. The failing tests seem not related? |
351ee4a
to
a547291
Compare
Thank you! |
This makes it possible to do this: