Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpstan Strict Rules Laravel Package

thecodingmachine/phpstan-strict-rules

Extra-strict PHPStan ruleset that flags risky or inconsistent PHP patterns beyond the default checks. Helps enforce cleaner, safer code by catching edge cases and enforcing best practices, with easy opt-in configuration for existing PHPStan setups.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package via Composer to add strict PHPStan rules to your project:

composer require --dev thecodingmachine/phpstan-strict-rules

Then include the ruleset in your phpstan.neon:

includes:
    - vendor/thecodingmachine/phpstan-strict-rules/extension.neon

The primary use case is catching common anti-patterns early — e.g., strict equality checks (=== vs ==), enforcing @phpstan-template where generic types are used, or requiring type declarations in docblocks for arrays/iterables.

Implementation Patterns

  • Integrate with your CI pipeline (e.g., GitHub Actions, GitLab CI) to enforce rules on every pull request.
  • Gradually adopt rules by starting with level: 5 (recommended for most projects), then incrementally increase strictness (level: 6, level: 7) over time.
  • Combine with phpstan-exceptional-rules for enhanced error handling enforcement.
  • Use ignoreErrors selectively in phpstan.neon for legacy code where full compliance is infeasible — but track them via whitelist or ignore-by-regexp for future cleanup.

Gotchas and Tips

  • Rules are opinionated and may conflict with PSR-12 formatting in edge cases (e.g., strict comparison multiline expressions); use --clear-cache after config changes to avoid stale analysis.
  • Some rules require PHP 7.4+ (e.g., typed properties, variadic expansion enhancements) — ensure your PHP runtime and phpstan.phpStanVersion match.
  • The package is unmaintained (last release: 2021-11-10); consider migrating to phpstan/phpstan-strict-rules (the official fork), which supersedes this and is actively maintained.
  • To debug a specific rule failure, run vendor/bin/phpstan analyse -vvv and check the rule class name in the output (e.g., Thematic\StrictComparisonRule) for precise troubleshooting.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4