Resolve edge cases cought by PHPStan level 7#672
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #672 +/- ##
============================================
+ Coverage 82.09% 82.46% +0.37%
- Complexity 3443 3460 +17
============================================
Files 154 154
Lines 9471 9491 +20
============================================
+ Hits 7775 7827 +52
+ Misses 1696 1664 -32
☔ View full report in Codecov by Sentry. |
|
@kylekatarnls thanks, lets merge it once you approve it |
src/main/php/PDepend/Source/Language/PHP/PHPParserVersion81.php
Outdated
Show resolved
Hide resolved
|
We have coverage decreasing since those edge-cases are not covered by tests. It would be nice to see if we can actually reproduce (if those are real edge-cases then we could have tests for them), or if they are only theoretical but cannot happen in practice, if so it would be better to handle with |
|
Yeah, I tried doing my best to deduce if they where possible or not and used assert() in that way. I currently do not have time to work on this, but I'm happy to review it if you have time to do so. |
AJenbo
left a comment
There was a problem hiding this comment.
Thanks for updating the pr 🙂
- getUnexpectedTokenException now expects a token - getUnexpectedNextTokenException checks next token
|
I hope I don't get carried too far away. I introduced some methods for repeated logic and split And now when we need the next token but no possible end-of-file expected, then we can use |
|
Oh and I forgot, I also replaced: $tokenType = $this->tokenizer->peek();
if (...) {
return ...
} elseif ($tokenType === Tokenizer::T_EOF) {
throw new TokenStreamEndException($this->tokenizer);
}
throw $this->getUnexpectedNextTokenException();With just: $tokenType = $this->tokenizer->peek();
if (...) {
return ...
}
throw $this->getUnexpectedNextTokenException();Because |
kylekatarnls
left a comment
There was a problem hiding this comment.
Coverage should be improved, but first we should run it with PHP 8.2, it's still on 7.4 which make some coverage missing just because tests are skipped.
So we'll handle in a next PR.
Type: bugfix / refactoring / documentation update
Breaking change: no
Resolve about half of the issues detected by PHPStan at level 7. This mostly involves handles a few edge cases and improve some PHPDoc. And a few
assert()to validate what is asserted by peek().