Shared code style, static analysis and CI for 1994 and Porro PHP packages.
- Pint:
pint.json(Laravel preset). Repos extend it. - PHPStan:
phpstan/base.neon, plusphpstan/laravel.neonwith Larastan. - CI: reusable workflow
.github/workflows/php.yml. - Local checks: a
pre-pushhook that runs the samecomposer cias CI.
CI never runs vendor/bin/pint or phpstan directly. It runs the repo's own
scripts:
| Where | Command | What it runs |
|---|---|---|
| CI quality job (once) | composer ci:quality |
pint --test and phpstan analyse |
| CI test matrix (each leg) | composer ci:test |
the test suite |
| Local / pre-push | composer ci |
both of the above |
| Local, optional | composer ci:lowest |
tests on lowest deps, then restores |
Because both sides call the same scripts, what passes composer ci on your
machine passes the quality job and the test leg that matches your PHP
version. The other legs (older PHP, other framework versions) only run in
CI. To try one locally, use composer ci:lowest, or change PHP with Herd
and run composer ci again.
-
Install:
composer require --dev 1994/coding-standard
-
Replace
pint.jsonwith:{ "extend": "vendor/1994/coding-standard/pint.json" }Keep any repo-only
excludeornotPathentries next toextend. -
Replace
phpstan.neonwith:includes: - vendor/1994/coding-standard/phpstan/base.neon # or laravel.neon parameters: level: 6 # 8 for *-core paths: - src
If it fails, record the current errors and fix them later. Don't lower the level:
vendor/bin/phpstan analyse --generate-baseline
Then add
- phpstan-baseline.neontoincludes. Add.phpstan-cache/to.gitignore. -
Merge the scripts from
stubs/composer-scripts.jsonintocomposer.json. Changetestif the repo uses PHPUnit (phpunit) orphp artisan test. Thepost-install-cmdandpost-update-cmdentries install the pre-push hook. The installer does nothing in CI, and it leaves alone any pre-push hook it didn't write. -
Copy
stubs/ci.ymlto.github/workflows/ci.yml, edit the matrix, and delete the old workflow.
{"php": "8.4", "require": "laravel/framework:13.* orchestra/testbench:11.*"}
{"php": "8.2", "deps": "lowest"}
{"php": "8.2", "require": "laravel/framework:11.*", "insecure": true}insecure turns off Composer's advisory block for that leg. Use it for
end-of-life framework versions we still support, such as Laravel 11.
extensions replaces the workflow's extensions input for one leg, e.g.
{"php": "8.4", "extensions": ":sodium"} to test without sodium.
If tests need a service container or a scaffolded app (Craft with
Postgres, for example), the reusable workflow can't build it. Keep your own
workflow, but follow the same rule: one job runs composer ci:quality, and
the test job's last step runs composer ci:test.
- porro-wordpress-connector must keep running on PHP 5.6, and Pint would
rewrite it in newer syntax. Keep PHPCS with PHPCompatibilityWP there, and
set its
ci:qualityscript to run those instead. It can still use the shared workflow. - Porro app already runs
composer ci:check(Pint, Larastan, Vite+, vue-tsc and sharded tests). Switch it to the shared Pint and PHPStan base, but keep its own workflow for the sharding.
Tag v1.x.y and move the v1 tag. Callers pin @v1. A rule change that
could fail existing repos goes out as a new major version.