Fix the static analysis failures on main - #7
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CI on
mainis red under PHPStan. Two real defects, seven reported errors.A print returned what it did not promise. Five console functions were written
fn () => print(...), an arrow function whose body is an expression, so each returned theintthatprintevaluates to while declaringIO<void>. Their statement-bodied siblings in the same file,printTableandprintProgress, were always right. They now match, with an explicit: voidon the closure.An option with no name was accepted.
OptionDefinitionguarded on$short === null && $long === null, which can never be true: the name is a requiredstringand every branch assigns it to one or the other. Sooption('')returnedRightwith a definition nothing could ever pass on a command line, when it should have been aLeft. The guard now tests for emptiness, which is what it meant.Two tests cover it: one that
option('')is aLeft, one that naming an option only by its long form still works. The first fails before this change.Verified on 8.2.30, 8.3.16, 8.4.4 and 8.5.3: 75 tests, PHPStan 2.2.8 clean, cs-fixer clean.
Why this passed review and then failed CI
composer.lockis gitignored, so every CI run resolves dependencies afresh while a working copy keeps whatever it installed. Locally I had PHPStan 2.1.39; CI resolved^2.1to 2.2.8, whose stricter inference found all seven. No code had to change for CI to go red.That will happen again on the next minor of PHPStan, cs-fixer or PHPUnit. Worth deciding separately: pin narrower ranges, or commit a lock for CI to use.