Skip to content

Exempt the ICU tzdata check from PHPStan's stub, keep the guard - #35

Merged
imanimanyara merged 1 commit into
mainfrom
fix/icu-tzdata-stub-disagreement
Nov 13, 2026
Merged

imanimanyara merged 1 commit into
mainfrom
fix/icu-tzdata-stub-disagreement

Conversation

@imanimanyara

Copy link
Copy Markdown
Member

Summary

PHPStan fails main with one error:

src/Console/DoctorCommand.php:76
  Call to function is_string() with string will always evaluate to true.
  🪪 function.alreadyNarrowedType

This keeps the guard and exempts the line, rather than deleting the branch PHPStan believes is unreachable.

Why the guard stays

PHPStan reads IntlTimeZone::getTZDataVersion() as returning string. That is its stub's claim, not the extension's. Measured 2026-11-13 on PHP 8.5.12 with ICU 57.2:

declared return type: (none)
runtime value: string(5) "2019a"

ReflectionMethod reports no declared return type at all, and the manual has documented string|false since PHP 5. So the stub narrows further than the runtime promises, and is_string() is a real guard against a value the extension may still produce.

Line 74, immediately above, handles the same false for the same reason:

$this->components->twoColumnDetail('ICU tzdata', $icu === false ? 'unknown' : $icu);

Deleting the check to satisfy the stub would let a false reach $this->comparable($icu) and be interpolated into a warning message — a behaviour change on exactly the hosts the branch exists for, which ~/.claude/rules/preserve.md calls a removal in disguise.

The exemption carries its reason and its measurement

Inline @phpstan-ignore function.alreadyNarrowedType on that one line, with a comment naming the PHP and ICU versions it was measured against, so the entry is a ceiling rather than a licence. No ignoreErrors block is added to phpstan.neon, which still has none — a config-level entry would silently cover future occurrences elsewhere.

Scope

Unblocks #34, which is the security-scan rollout and touches no PHP. That PR's failure was pre-existing on main: line 76 is byte-identical there.

Copilot AI balanced review requested due to automatic review settings November 13, 2026 16:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@imanimanyara
imanimanyara merged commit 4987a18 into main Nov 13, 2026
7 checks passed
@imanimanyara
imanimanyara deleted the fix/icu-tzdata-stub-disagreement branch November 13, 2026 17:12
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.

2 participants