fix(colors): drop provably-dead saturation guard in calculate_avg_color
CR
19h ago
+3+3+0123456789-1-1-0123456789
Why
PHP Code Quality / PHPStan fails on main right now (PHPStan is floated as phpstan/phpstan:^2.2 in the workflow, and 2.3.x tightened && narrowing):
include/colors.php:393 Comparison operation "<" between float<0.25000000000000006, max> and 0.01 is always false. (smaller.alwaysFalse)
include/colors.php:393 Result of && is always false. (booleanAnd.alwaysFalse)
Both are correct. The guard chain opens with $hsl[1] > 0.25, so the next conjunct's $hsl[1] < 0.01 can never be true — that !(...) term is always true and never affected the branch.
This is why #314 (a Composer bump) and #315 (an Actions bump) both fail the same two checks even though neither touches PHP.
Change
Drop the dead term and leave a comment explaining why. No behaviour change.
Verification
phpstan analyze with PHPStan 2.3.7 on PHP 8.4: No errors (was 2).
Equivalence check of the old and new conditions over 200,000 random HSL triples plus an exhaustive grid of threshold-adjacent values: 0 mismatches.
Summary by Sourcery
Remove the unreachable saturation condition from average-color selection to resolve PHPStan false-positive failures while preserving existing behavior.
Bug Fixes:
Remove a provably unreachable saturation guard from average-color calculation without changing behavior.
Enhancements:
Keep the color-selection condition clear and compatible with stricter PHPStan analysis by documenting the redundant check.
Summary by cubic
Fixes the PHPStan pipeline failure by removing a provably-dead saturation check in calculate_avg_color.
The guard chain already requires $hsl[1] > 0.25, so the later $hsl[1] < 0.01 term can never be true and never affected the branch. The dead term is dropped with a comment; behavior is unchanged. Verified with PHPStan 2.3.7 (no errors) and an equivalence check over 200,000 random HSL triples plus a threshold grid (0 mismatches).
This change is
Confidence Score: 5/5
This PR appears safe to merge; color selection stays unchanged.
Summary
Removes a redundant condition from calculate_avg_color without changing which color it returns.
Average icon colors skip an impossible saturation check.