rollerscapes/standards
A standardized set of PHP code style and quality assurance rules from Rollerscapes, bundling the tooling and configuration used across all its projects, including Rollerworks, HuPKit, and Rollersearch, to keep coding standards consistent and enforce quality checks.
declare_strict_types to the fix rule set (issue #3) changes the package’s blast radius. standards:fix no longer only reformats whitespace and ordering — it now injects declare(strict_types=1); into every file it touches, which is a runtime behavior change. In Laravel terms this is the difference between a linting tool and a code-generation tool that alters type semantics.phpstan/phpstan-symfony suggests partial awareness of Laravel’s ecosystem, but no documentation confirms coverage of Laravel’s core components. This gap matters more now: strict types interact with Laravel’s string-typed request/input layer in ways Symfony-oriented defaults do not anticipate..php-cs-fixer.dist.php, phpstan.neon) allows for incremental adoption and customization. Existing Laravel projects using these tools individually would face minimal disruption, but conflicts may arise if overlapping configurations exist (e.g., custom PHPStan rules vs. Rollerscapes’ defaults).declare_strict_types is a risky fixer in PHP-CS-Fixer and only executes when the config sets setRiskyAllowed(true). Adoption teams must confirm whether the package’s shipped config enables risky rules globally — if it does, every other risky fixer becomes live at the same time, which is a much larger change surface than the release note implies.phpunit.xml and phpstan.neon can be merged without conflicts, but explicit guidance is lacking.jobs:
standards:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: composer require rollerscapes/standards --dev
- run: vendor/bin/php-cs-fixer fix --dry-run --diff
- run: vendor/bin/phpstan analyse --level=max --error-format=github
Key: The --diff flag for PHP-CS-Fixer and --error-format=github for PHPStan improve debuggability in CI. With v0.3.2, --diff output will now show +declare(strict_types=1); hunks on every file — treat that as an expected signal, not a formatting regression.standards:check, standards:fix, standards:analyze) provide a Laravel-native way to run checks, reducing friction for developers already familiar with Laravel’s CLI. However, standards:fix is now a mutating, semantics-changing command and should not be wired into auto-run hooks without a gate.declare(strict_types=1); disables scalar type coercion for calls made from within the declaring file. Typical Laravel hazards:
function setLimit(int $n) called with $request->input('limit') (string) → TypeError.env('X') returns string) passed to typed parameters.src/ new code first), never blanket-apply to app/Http, and require a full feature-suite run plus a staging smoke test on any commit that adds the declare.standards:fix run touches every PHP file (one-line insertion each), invalidating git blame, inflating PRs, and causing merge conflicts across long-lived branches. Mitigation: land it as one dedicated, isolated commit at a branch-quiet moment; add the hash to .git-blame-ignore-revs.phpstan-symfony covers Laravel’s core components (e.g., Illuminate\Contracts, Illuminate\Support\Facades).ignoreErrors or excludePaths).phpstan --generate-baseline to temporarily ignore known issues while fixing others.phpstan/phpstan-doctrine and phpstan/phpstan-symfony are necessary for the project.setRiskyAllowed(true), and if so which other risky fixers are now active that we have not evaluated?declare_strict_types be disabled or scoped per path without forking (e.g., via Finder exclusions in our merged config)? We need it off for app/Http, config/, database/migrations/.TypeError risk in existing controllers and jobs?@mixin, @inject)? If not, how will we customize PHPStan to avoid false positives?laravel/phpstan package? Should we merge configurations or replace one with the other?phpstan --generate-baseline or exclude specific paths?level=max in a large Laravel monolith? Can we cache results (e.g., via phpstan --generate-baseline) to reduce CI/CD noise?--parallel) for faster execution?phpunit.xml or phpstan.neon? Are there known conflicts with laravel/pint or laravel/phpstan?laravel/pint does not apply declare_strict_types by default, so running Pint alongside standards:fix may produce a fixer tug-of-war on the same file headers. Confirm rule-set precedence.composer require --dev rollerscapes/standards:0.3.2
Note: The --dev flag ensures the package is only installed in development, aligning with Laravel’s conventions. Given v0.3.2’s semantic change inside a patch release, pin the exact version rather than using a caret range, and let Renovate/Dependabot surface bumps for review.declare_strict_types rule is not cosmetic and must be treated as a separate workstream.laravel/phpstan with additional rules (Doctrine, Symfony). Critical: Verify if this duplicates or conflicts with existing Laravel PHPStan configs.phpunit.xml if not merged carefully.composer require rollerscapes/standards:0.3.2 --dev
vendor/bin/php-cs-fixer fix --dry-run --diff
vendor/bin/phpstan analyse --level=5 --error-format=github
--diff output for declare(strict_types=1) hunks to quantify how many files would be touched. That number is your strict-types scope estimate.declare_strict_types excluded via a project-level override:
// .php-cs-fixer.dist.php
$config = require __DIR__.'/vendor/rollerscapes/standards/config.php';
return $config->setRules(array_merge(
$config->getRules(),
['declare_strict_types' => false],
));
Example Husky config:
{
"hooks": {
"pre-commit": "vendor/bin/php-cs-fixer fix --dry-run"
}
}
5 → 7 → max) while fixing errors. Use phpstan --generate-baseline to temporarily ignore known issues.declare_strict_types for src//app/Services only, as one dedicated commit, with a full test-suite + staging verification. Extend directory coverage sprint over sprint.phpunit.xml overrides). Merge with Laravel’s default config:
<phpunit>
<extensions>
<extension class="Rollerscapes\Standards\PHPUnit\InternalTestExtension"/>
</extensions>
</phpunit>
.php-cs-fixer.dist.php. Prioritize project-specific rules over Rollerscapes’ defaults:
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules(array_merge(
Rollerscapes\Standards\Config::rules(),
['declare_strict_types' => false], // re-enable per path when ready
))
->setFinder($finder);
.neon/config consumers continue to load.declare_strict_types is not part of Pint’s default preset, so mixed tooling will diverge. Standardize on one fixer for header-level rules.excludePaths), so the change only affects first-party files.0.3.2 and run a dry-run diff audit (no writes).declare_strict_types => false; ship cosmetic linting into pre-commit and CI..git-blame-ignore-revs.standards:fix to run unscoped.composer require "rollerscapes/standards:0.3.2" --dev (exact) and require a human review of every bump, with the diff filtered for fix-rule and risky-rule changes.standards:check output before and after each bump in CI to make drift visible.TypeErrors surface at runtime, not at build time, so bugs land on developers and on-call rather than in CI. Pre-empt with a short internal note on the coercion rules and the $request->input() / env() string pitfall..php-cs-fixer.dist.php or phpstan.neon require that owner’s review.level=max across a large Laravel monolith is the dominant cost; enable --parallel, cache the result cache between runs, and keep a baseline file to avoid re-reporting known errors. Budget a measurable CI minute increase and validate against the current pipeline duration.TypeError after an unscoped standards:fix — highest likelihood, highest severity. Guard: staging smoke test + scoped directory enablement.fix --dry-run is clean.setRiskyAllowed(false) (or omitted), declare_strict_types never fires and teams wrongly believe they are compliant. Guard: add a fixture-file assertion in CI that a deliberately untyped file is flagged.phpstan.neon, dropping project-specific ignoreErrors. Guard: config files under CODEOWNERS review.How can I help you explore Laravel packages today?