Skip to content

Fix the static analysis failures on main - #7

Merged
MarcelloDuarte merged 2 commits into
mainfrom
fix-static-analysis
Aug 5, 2026
Merged

Fix the static analysis failures on main#7
MarcelloDuarte merged 2 commits into
mainfrom
fix-static-analysis

Conversation

@MarcelloDuarte

Copy link
Copy Markdown
Contributor

CI on main is 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 the int that print evaluates to while declaring IO<void>. Their statement-bodied siblings in the same file, printTable and printProgress, were always right. They now match, with an explicit : void on the closure.

An option with no name was accepted. OptionDefinition guarded on $short === null && $long === null, which can never be true: the name is a required string and every branch assigns it to one or the other. So option('') returned Right with a definition nothing could ever pass on a command line, when it should have been a Left. The guard now tests for emptiness, which is what it meant.

Two tests cover it: one that option('') is a Left, 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.lock is 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.1 to 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.

@MarcelloDuarte
MarcelloDuarte merged commit 1b3ed22 into main Aug 5, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant