-
Notifications
You must be signed in to change notification settings - Fork 534
fix baseline for access to uninitialized property from trait #2568
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
fix baseline for access to uninitialized property from trait #2568
Conversation
Both of your suggestions are fine :) I'd definitely like to see a failing test first, I don't yet understand the problem. |
6a45d62
to
eb0c8ca
Compare
@ondrejmirtes Done. I added it as a separate commit, so that you can see the failure as well: https://github.com/phpstan/phpstan-src/actions/runs/5901436629/job/16007616894?pr=2568 The issue basically happens due to the difference in these two lines (notice the difference in slashes):
|
Hi, when I check out your first commit, PHPStan generates this baseline:
When I try to run the analysis again with this baseline, it passes:
Then I noticed the behaviour you're describing happens only when you run PHPStan with I need to investigate that. |
Oh, there's also a diffence in |
@ondrejmirtes Thanks. I remember noticing that the error was not reported in some scenario, but I didn't look into it further. In any case, this discrepancy is probably an unrelated issue. I had the unignorable access to uninitialized property happen to me in our code-base, where we definitely run phpstan without |
Hi @schlndh, first and foremost, I need to say that I'm impressed with the level of your contributions and I'm looking forward to seeing more of them! I'm not saying this lightly, this definitely does not happen every day :) I made a few adjustments and brought this PR over the finish line. Turns out the Thank you. |
6baf1cf
to
c3e57a0
Compare
@ondrejmirtes Nice, thank you. |
This is a followup fix for #2531. That PR made the affected errors effectively unignorable, because it included the "in context of class ..." in path and consequently the
\
from the class namespace were converted to/
when the baseline was generated and so the path didn't match during analysis.I checked and other trait errors are saved with the parent classes' path. So this PR does the same for the uninitialized readonly property errors.
I'm not sure what's the best way to write a test for this issue. Should I add it to
e2e-tests.yml
, or should I create a PR inphpstan/phpstan
and add it toother-tests.yml
?Example
Foo.php:
HelloWorld.php
test.neon
Before the fix
Baseline:
The result of analysis with this baseline is:
After the fix
Here is the diff of the baseline:
And when I run analysis there are no errors reported (as it should be).