Skip to content

Analyse main with PHPStan at the max level with strict rules - #70

Merged
tattali merged 2 commits into
mainfrom
phpstan-max-level-strict-rules-main
Oct 18, 2026
Merged

tattali merged 2 commits into
mainfrom
phpstan-max-level-strict-rules-main

Conversation

@tattali

@tattali tattali commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Stacked on #69 (it needs that pull request's phpstan.neon.dist).

PHPStan ran at level 7 without the strict rules, so mixed values, loose comparisons and other unsafe code went unreported on main.

  • phpstan.neon.dist sets level: max and phpVersion: 80400 (the main floor, PHP 8.4), and keeps the src and tests paths.
  • phpstan/phpstan-strict-rules joins require-dev; phpstan-phpunit and phpstan-symfony were already there, and the extension installer loads all three.
  • No baseline file and no ignored errors.
  • No code change was needed: the fixes PHPStan asked for on 6.x and 7.x, with their tests, reached main with the 7.x merge-up.

Local checks on PHP 8.4 with Symfony 8.1: PHPStan 2.3.1 reports no errors with the three extensions loaded. CI runs PHPStan in the current job (PHP 8.4, Symfony 8.1).

CI on main only sampled versions (Symfony 8.0 lowest on PHP 8.4, then
the newest Symfony 8 on PHP 8.4 and 8.5), so a break on another PHP and
Symfony 8 minor pair could go unnoticed.

The matrix now runs Symfony 8.0 and 8.1 on PHP 8.4 and 8.5, plus the
lowest-dependencies job (PHP 8.4, Symfony 8.0) and the allowed-to-fail
nightly (PHP 8.6, Symfony next). The job that lints stays on PHP 8.4,
now pinned to Symfony 8.1. Symfony 8.0 no longer gets fixes and its
releases have open security advisories, so Composer refuses them: the
Symfony 8.0 jobs pass --no-blocking.

The PHPStan options move from the command line to phpstan.neon.dist
(same level 7, same paths) so CI and the Makefile read one
configuration. ci.yml is regenerated with the CI generator.
PHPStan ran at level 7 without the strict rules, so mixed values, loose
comparisons and other unsafe code went unreported on main.

phpstan.neon.dist now sets the max level, analyses for PHP 8.4 (the
main floor) and loads phpstan/phpstan-strict-rules, with no baseline and
no ignored errors. The code already passes: the fixes PHPStan asked for
on 6.x and 7.x reached main with the 7.x merge-up.
@sonarqubecloud

Copy link
Copy Markdown

@tattali
tattali changed the base branch from ci-every-php-and-symfony-8-x to main October 18, 2026 22:17
@tattali
tattali merged commit 2ef3286 into main Oct 18, 2026
8 checks passed
@tattali
tattali deleted the phpstan-max-level-strict-rules-main branch October 18, 2026 22:18
tattali added a commit that referenced this pull request Oct 18, 2026
Stacked on #70.

Passing tests say nothing about whether they would notice a wrong change
in the code. Infection mutates src and fails the run when the tests
catch fewer mutants than today.

- `infection/infection` (^0.35) joins require-dev, and its extension
installer is allowed as a Composer plugin.
- `infection.json5` runs the default mutators on src with `minMsi: 87`
and `minCoveredMsi: 87`.
- Measured on PHP 8.4 with Symfony 8.1 and Xdebug: 358 mutants, 313
killed, 45 escaped, 0 uncovered; MSI 87.43%, covered code MSI 87.43%,
mutation code coverage 100%. The thresholds are those scores rounded
down.
- The current CI job (PHP 8.4, Symfony 8.1) runs `vendor/bin/infection
--threads=max --no-progress --show-mutations` after PHPUnit; the other
jobs remove Infection before installing. `.github/workflows/ci.yml` is
generated with the CI generator.

Local checks: Infection passes with these thresholds (exit 0) and fails
with `--min-msi=88` (exit 1).

This branch was successfully deployed

1 active deployment
main — 8ade7887 Deployed Oct 18, 2026 by tattali via PHP 8.5 - Symfony 8.1.* #97
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