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 Rules Laravel Package

nette/phpstan-rules

Extra PHPStan rules from the Nette ecosystem to catch more issues in your PHP codebase. Adds stricter checks and best-practice validations on top of PHPStan, helping improve static analysis coverage and prevent bugs before runtime.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by installing the package via Composer:

composer require --dev nette/phpstan-rules

Then, include its configuration in your phpstan.neon:

includes:
    - vendor/nette/phpstan-rules/config/phpstan.neon

This enables built-in rules for Nette components like Container, Application, Form, and Router. Your first test: run PHPStan on a project using Nette — look for warnings around missing parameter types in factory methods or incorrect usage of IMessageSource or ITraversable.

Implementation Patterns

  • Strict routing checks: Rules validate that route parameters match route masks (e.g., {id} must be used in route definition and controller signature).
  • Factory type inference: Enhances PHPStan’s type inference for Nette’s factory patterns (e.g., @inject properties get inferred correctly from service signatures).
  • Form validation: Detects mismatches between addText() fields and corresponding validation rules (e.g., required fields missing NotNull rules).
  • Integration tip: Combine with phpstan-strict-rules for layered strictness — nette/phpstan-rules covers Nette-specific semantics, while others handle general PHP best practices.

Gotchas and Tips

  • Silent no-ops: If rules don’t trigger, ensure your PHPStan config includes the package’s config — not just the package being installed.
  • PHP version mismatch: Requires PHP 8.1+ and PHPStan 2.1+. Running on PHP 8.0 or older PHPStan will cause failures.
  • False positives in dynamic calls: Nette’s Container magic methods (e.g., $container->getService('foo')) may trigger false negatives if services aren’t explicitly tagged or documented. Mitigate by adding docblocks like @method FooService getFoo() on your container extensions.
  • Extensibility: Use extensions: in your config to add custom rules for domain-specific Nette services. See src/Type/ in the repo for concrete extension examples.
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
milesj/emojibase
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