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.
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.
{id} must be used in route definition and controller signature).@inject properties get inferred correctly from service signatures).addText() fields and corresponding validation rules (e.g., required fields missing NotNull rules).phpstan-strict-rules for layered strictness — nette/phpstan-rules covers Nette-specific semantics, while others handle general PHP best practices.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.extensions: in your config to add custom rules for domain-specific Nette services. See src/Type/ in the repo for concrete extension examples.How can I help you explore Laravel packages today?