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 Nette

Phpstan Nette Laravel Package

phpstan/phpstan-nette

PHPStan extension for Nette Framework. Improves type inference for components, DI container, forms, presenters/sessions, Html dynamic methods, SmartObject magic properties, events, and regex-based Strings utilities. Includes optional Nette-specific rules.

View on GitHub
Deep Wiki
Context7

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

Frequently asked questions about Phpstan Nette
Can I use phpstan/phpstan-nette in a Laravel project that also uses Nette Framework?
Yes, but only if your Laravel app integrates Nette Framework components. This extension is designed for Nette-specific static analysis and won’t affect Laravel’s core. Ensure your project uses PHPStan ≥2.0 and Nette 3.x/4.x for full compatibility.
How do I install this extension for PHPStan in a Laravel project?
Run `composer require --dev phpstan/phpstan-nette` in your project root. If using PHPStan’s extension-installer, it will auto-load the extension. Otherwise, manually include `extension.neon` in your PHPStan config.
Will this extension break my existing PHPStan rules or configurations?
No, it’s non-invasive. The extension adds Nette-specific type inference and rules but doesn’t override existing PHPStan configurations. Start with `--level=max` to test compatibility before enabling framework-specific rules.
Does this work with Nette 2.x or older PHPStan versions?
No, it requires PHPStan ≥2.0 (for GenericStaticType support) and actively supports Nette 3.x/4.x. Older versions may need manual stubs or won’t work at all. Check the [README](https://github.com/phpstan/phpstan-nette) for migration notes.
How does this extension improve type safety for Nette components?
It infers return types for `createComponent*`, `getComponent()`, and dynamic methods (e.g., `Html` elements). For example, `$presenter->getComponent('homepage')` will resolve to the correct component type instead of `?Component`.
Can I enable only specific Nette rules (e.g., regex validation) without others?
Yes, the extension includes optional framework-specific rules (e.g., `DoNotExtendNetteObjectRule`). Enable them selectively in `rules.neon` or via CLI flags like `--enable=regexPatternValidation`.
Will this slow down my CI/CD pipeline significantly?
Static analysis adds CPU/memory overhead, but the impact is minimal for most projects. Cache PHPStan results (`--generate-report`) and run it in parallel with other tests. Benchmark with `--memory-limit` to optimize.
Does this extension support IDE autocompletion (e.g., PHPStorm, VSCode)?
Yes, it works with any IDE that supports PHPStan (e.g., PHPStorm, VSCode with Intelephense). The type inference will improve autocompletion for Nette components, forms, and DI containers.
What if my project extends Nette’s core classes (e.g., custom Presenter)?
Custom extensions may require manual stubs or rule overrides. Document your overrides in `extension.neon` or use `@var` annotations for unsupported methods. Test thoroughly with `--level=max` to catch edge cases.
Are there alternatives to this extension for Nette + PHPStan?
No direct alternatives exist, but you could manually configure PHPStan with custom stubs for Nette classes. However, this extension is actively maintained and covers Nette’s unique patterns (e.g., `Strings::match()` array shapes) far more comprehensively.
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata