Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 28 days 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 (almost 9 years ago)
- Default Branch: 1.1.x
- Last Pushed: 2024-02-19T08:56:24.000Z (9 months ago)
- Last Synced: 2024-04-14T05:41:31.284Z (7 months ago)
- Topics: nette-framework, php, php7, phpstan, static-analysis, static-analyzer, static-code-analysis, testing
- Language: PHP
- Homepage:
- Size: 228 KB
- Stars: 99
- Watchers: 9
- Forks: 34
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nette Framework extension for PHPStan
[![Build](https://github.com/phpstan/phpstan-nette/workflows/Build/badge.svg)](https://github.com/phpstan/phpstan-nette/actions)
[![Latest Stable Version](https://poser.pugx.org/phpstan/phpstan-nette/v/stable)](https://packagist.org/packages/phpstan/phpstan-nette)
[![License](https://poser.pugx.org/phpstan/phpstan-nette/license)](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
```