https://github.com/phpstan/phpstan-nette
Nette Framework class reflection extension for PHPStan & framework-specific rules
https://github.com/phpstan/phpstan-nette
nette-framework php php7 phpstan static-analysis static-analyzer static-code-analysis testing
Last synced: about 2 months ago
JSON representation
Nette Framework class reflection extension for PHPStan & framework-specific rules
- Host: GitHub
- URL: https://github.com/phpstan/phpstan-nette
- Owner: phpstan
- License: mit
- Created: 2016-01-04T19:08:52.000Z (over 9 years ago)
- Default Branch: 2.0.x
- Last Pushed: 2025-04-15T15:31:13.000Z (3 months ago)
- Last Synced: 2025-05-11T10:29:02.814Z (2 months ago)
- Topics: nette-framework, php, php7, phpstan, static-analysis, static-analyzer, static-code-analysis, testing
- Language: PHP
- Homepage:
- Size: 282 KB
- Stars: 102
- Watchers: 8
- Forks: 38
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nette Framework extension for PHPStan
[](https://github.com/phpstan/phpstan-nette/actions)
[](https://packagist.org/packages/phpstan/phpstan-nette)
[](https://packagist.org/packages/phpstan/phpstan-nette)* [PHPStan](https://phpstan.org/)
* [Nette Framework](https://nette.org/)This extension provides following features:
* `Nette\ComponentModel\Container::getComponent()` knows type of the component because it reads the return type on `createComponent*` (this works best in presenters and controls)
* `Nette\DI\Container::getByType` and `createInstance` return type based on first parameter (`Foo::class`).
* `Nette\Forms\Container::getValues` return type based on `$asArray` parameter.
* `Nette\ComponentModel\Component::lookup` return type based on `$throw` parameter.
* `Nette\Application\UI\Component::getPresenter` return type based on `$throw` parameter.
* Dynamic methods of [Nette\Utils\Html](https://doc.nette.org/en/2.4/html-elements)
* Magic [Nette\Object and Nette\SmartObject](https://doc.nette.org/en/2.4/php-language-enhancements) properties
* Event listeners through the `on*` properties
* Defines early terminating method calls for Presenter methods to prevent `Undefined variable` errors
* Understand the exact array shape coming from `Nette\Utils\Strings::match()` and `Nette\Utils\Strings::matchAll()` based on patternIt also contains these framework-specific rules (can be enabled separately):
* Do not extend Nette\Object, use Nette\SmartObject trait instead
* Rethrow exceptions that are always meant to be rethrown (like `AbortException`)## Installation
To use this extension, require it in [Composer](https://getcomposer.org/):
```
composer require --dev phpstan/phpstan-nette
```If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!
Manual installation
If you don't want to use `phpstan/extension-installer`, include extension.neon in your project's PHPStan config:
```
includes:
- vendor/phpstan/phpstan-nette/extension.neon
```To perform framework-specific checks, include also this file:
```
- vendor/phpstan/phpstan-nette/rules.neon
```