Skip to content

chore(analysis): keep runtime fetch guards valid under PHPStan 2.3 - #35

Merged
Maatify merged 1 commit into
mainfrom
fix/phpstan-2-3-redundant-guards
Oct 14, 2026
Merged

Maatify merged 1 commit into
mainfrom
fix/phpstan-2-3-redundant-guards

Conversation

@megyptm

@megyptm megyptm commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Problem

CI Quality (PHP 8.2) fails on main content with PHPStan 2.3.1: phpstan/phpstan is ^2.1 and no lock file is tracked, so CI resolves the newest release. Reproduced on a clean checkout of main (fc1459b) with a fresh composer update; the last green main CI ran on 2026-09-18, before 2.3.x. Three errors (function.alreadyNarrowedType):

  • src/Pdo/Pagination/PdoPaginator.php:210 and :215
  • tests/Support/MySql/OrderingStateReader.php:80

Change

The is_array() / is_string() guards stay: PdoPaginatorFailureTest::testInvalidScalarFetch covers the scalar-fetch guard, and PDO can return integer keys for numeric column names. The fetch result is declared /** @var mixed */, matching what a driver or test double may return. No behavior change, no baseline, no ignore, no version pin.

Verification

Fresh resolve (phpstan 2.3.1), MySQL 8.4.11: validate, autoload, platform reqs, audit, PHPStan max (no errors), unit 260, regression 41, integration 94, consumer harness, php-cs-fixer, git diff --check.

Unblocks #34, which is unrelated to these errors.

🤖 Generated with Claude Code

PHPStan 2.3.1 (resolved by CI because phpstan/phpstan is ^2.1 and no lock
file is tracked) reports the defensive is_array()/is_string() checks on
PDOStatement::fetch() results as always true. The guards are exercised by
PdoPaginatorFailureTest::testInvalidScalarFetch, so they stay. The fetch
result is declared mixed instead, which matches what a driver or test
double may return. No behavior change; no baseline or ignore added.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Maatify
Maatify merged commit 1333ae6 into main Oct 14, 2026
24 of 30 checks passed
@Maatify
Maatify deleted the fix/phpstan-2-3-redundant-guards branch October 14, 2026 17:03
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