You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
THRIFT-5957: Add phpstan static analysis with CI guardrail
Client: php
The PHP runtime library at lib/php/lib/ had no static-analysis tooling
in CI. Refactors and type-modernization PRs went in without an
automated safety net.
This change:
* Adds phpstan/phpstan ^1.12 as a require-dev dependency, plus a
"scripts.phpstan" composer alias for local use.
* Adds lib/php/phpstan.neon (level 1) targeting lib/php/lib/ with
test/bootstrap.php for autoload, and a generated baseline that
pins the 5 remaining issues (all "should return X but return
statement is missing" in TJSONProtocol/TSimpleJSONProtocol's
writeStructBegin/writeStructEnd and ThriftClassLoader::findFile —
left for a follow-up ticket).
* Adds a "Run phpstan" step alongside the existing per-language
steps (cppcheck, flake8, phpcs, rubocop) in the sca.yml workflow,
and wires its outcome into the aggregate "Fail if any SCA check
failed" gate. Runs with --error-format=github so findings show up
as inline annotations on PRs.
* Bumps the sca job's setup-php from 7.1 to 8.1 to match the new
project floor (THRIFT-5956) and to satisfy phpstan 1.x's PHP
>= 7.2 requirement.
Also fixes the trivial subset of phpstan findings already discovered
during baseline generation:
* TSocketPool::open: replace extract($this->servers_[$i]) with
explicit $host / $port assignments. Removes 10 "might not be
defined" findings and avoids extract()'s well-known footgun of
silently rebinding existing locals.
* TBufferedTransport::readAll: change the final "elseif" to "else"
so phpstan can prove $data is always assigned.
Level 1 catches undefined variables and obvious type mismatches
without requiring widespread code changes. Higher levels will be
raised in follow-up tickets as the runtime library gains native
types and PHPDoc cleanup.
Out of scope (separate tickets):
* PSR-12 migration / php-cs-fixer.
* declare(strict_types=1) and native types in lib.
* Static analysis of generated PHP under test/Resources/packages/.
* Fixing the remaining 5 missing-return findings.
* CHANGES.md is auto-generated on release; no manual entry here.
Generated-by: Claude Opus 4.7 (1M context)
0 commit comments