Weave 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 Nette

Phpstan Nette Laravel Package

phpstan/phpstan-nette

PHPStan extension for the Nette Framework providing precise type inference for components, DI container getByType/createInstance, forms, dynamic Html methods, magic properties, and presenters, plus optional rules for regex validation and Nette\Object deprecation.

View on GitHub
Deep Wiki
Context7

Nette Framework class reflection extension for PHPStan & framework-specific rules

Frequently asked questions about Phpstan Nette
What does phpstan/phpstan-nette do for a Nette application?
It is a dev-only PHPStan extension that teaches static analysis how Nette's dynamic runtime behaves. It adds type inference for createComponent methods, DI Container getByType and createInstance, Nette Forms getValues, Html magic methods, SmartObject properties, and Strings regex handling. It also bundles optional Nette-specific rules that can be enabled separately.
Can I use phpstan/phpstan-nette in a Laravel application?
No, it is built for the Nette Framework and adds stubs and rules for Nette classes such as ComponentModel, DI Container, Forms, and Utils. Laravel applications should use Larastan and Laravel-specific PHPStan extensions instead. There is no benefit to installing this package in a Laravel-only codebase.
How do I install phpstan/phpstan-nette?
Install it as a dev dependency with composer require --dev phpstan/phpstan-nette. If you use phpstan/extension-installer, the extension is registered automatically; otherwise include vendor/phpstan/phpstan-nette/extension.neon in your phpstan.neon. Optionally include rules.neon to enable the framework-specific rules.
Do I need to enable rules.neon or is extension.neon enough?
extension.neon provides type inference only, which improves analysis accuracy without adding new failure conditions. rules.neon adds behavioral checks such as forbidding Nette\Object, requiring rethrowing of always-rethrown exceptions like AbortException, and validating regex patterns passed to Nette\Utils\Strings. Start with extension.neon and enable rules separately once the team agrees on the policy.
Which PHPStan and Nette versions are supported by phpstan/phpstan-nette?
The extension tracks PHPStan releases, including the 2.0 line, and follows Nette API changes such as getUnsafeValues to getUntrustedValues. Some features depend on PHPStan bleedingEdge behavior, so pin both PHPStan and the extension in composer.lock. Check the package composer.json and release notes for the exact supported ranges before upgrading.
Will installing phpstan/phpstan-nette cause many new PHPStan errors?
Yes, enabling the extension usually surfaces findings that were previously hidden behind mixed or untyped Nette magic. Run PHPStan before and after installation at the same level and diff the reports to size the triage backlog. Absorb the legitimate new findings into your baseline or fix them before enabling rules.neon.
Does phpstan/phpstan-nette work with PHPStan bleeding edge?
Some of its type inference relies on PHPStan bleedingEdge features, so analysis output can change when PHPStan is upgraded even if the extension version stays the same. If you enable bleedingEdge, pin PHPStan and the extension together and review changes in CI. Teams that need stable gates should avoid bleedingEdge or isolate it to a dedicated job.
Is phpstan/phpstan-nette maintained and safe for production CI?
It is a small, maintainer-driven package with limited third-party dependents, so assess bus factor and responsiveness before relying on it. Because it is a dev-only dependency, it has no production runtime footprint and cannot affect deployed code. Pin it in require-dev with a committed lock file and review upgrades like any other CI tool.
What are alternatives to phpstan/phpstan-nette for static analysis?
If you are not on Nette, use the PHPStan extensions for your framework, such as Larastan for Laravel or phpstan-symfony for Symfony. For Nette projects, this extension is the standard way to add framework-aware type inference to PHPStan. You can also write custom PHPStan stubs and rules, but that duplicates what this package provides.
How do I test that phpstan/phpstan-nette is working in my project?
Add a small fixture with a createComponent method or a DI getByType call and confirm PHPStan infers the concrete return type instead of mixed. Run PHPStan at your current level before and after enabling the extension and compare the error counts. You can also enable rules.neon in a separate run to see which framework-specific rule violations appear.
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.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels