phpstan / phpstan-nette
Nette Framework class reflection extension for PHPStan
Installs: 6 609 902
Dependents: 636
Suggesters: 3
Security: 0
Stars: 100
Watchers: 9
Forks: 35
Open Issues: 17
Type:phpstan-extension
Requires
- php: ^7.4 || ^8.0
- phpstan/phpstan: ^2.0
Requires (Dev)
- nette/application: ^3.0
- nette/di: ^3.1.10
- nette/forms: ^3.0
- nette/utils: ^2.3.0 || ^3.0.0
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^9.6
Conflicts
- nette/application: <2.3.0
- nette/component-model: <2.3.0
- nette/di: <2.3.0
- nette/forms: <2.3.0
- nette/http: <2.3.0
- nette/utils: <2.3.0
- 2.0.x-dev
- 2.0.0
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.x-dev
- 1.1.0
- 1.0.0
- 0.12.21
- 0.12.20
- 0.12.19
- 0.12.18
- 0.12.17
- 0.12.16
- 0.12.15
- 0.12.14
- 0.12.13
- 0.12.12
- 0.12.11
- 0.12.10
- 0.12.9
- 0.12.8
- 0.12.7
- 0.12.6
- 0.12.5
- 0.12.4
- 0.12.3
- 0.12.2
- 0.12.1
- 0.12.0
- 0.11.1
- 0.11
- 0.10.1
- 0.10
- 0.9
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8
- 0.7
- 0.6.3
- 0.6.2
- 0.6.1
- 0.6
- 0.5.1
- 0.5
- 0.4
- 0.3
- 0.2
- 0.1
- dev-renovate/major-root-composer
- dev-renovate/major-github-actions
This package is auto-updated.
Last update: 2024-11-11 07:41:58 UTC
README
This extension provides following features:
Nette\ComponentModel\Container::getComponent()
knows type of the component because it reads the return type oncreateComponent*
(this works best in presenters and controls)Nette\DI\Container::getByType
andcreateInstance
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
- Magic Nette\Object and Nette\SmartObject 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()
andNette\Utils\Strings::matchAll()
based on pattern
It 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:
composer require --dev phpstan/phpstan-nette
If you also install 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