PHPackages                             phpstan/phpstan-nette - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. phpstan/phpstan-nette

ActivePhpstan-extension[Testing &amp; Quality](/categories/testing)

phpstan/phpstan-nette
=====================

Nette Framework class reflection extension for PHPStan

2.0.9(3mo ago)1179.7M—0.4%45[6 issues](https://github.com/phpstan/phpstan-nette/issues)[10 PRs](https://github.com/phpstan/phpstan-nette/pulls)20MITPHPPHP ^7.4 || ^8.0CI passing

Since Jul 17Pushed 1mo ago6 watchersCompare

[ Source](https://github.com/phpstan/phpstan-nette)[ Packagist](https://packagist.org/packages/phpstan/phpstan-nette)[ RSS](/packages/phpstan-phpstan-nette/feed)WikiDiscussions 2.0.x Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (84)Used By (20)

Nette Framework extension for PHPStan
=====================================

[](#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://camo.githubusercontent.com/ac4e23e408810ffee50bb7929d961e47f922b2f4a0f528470794a37d0eba7385/68747470733a2f2f706f7365722e707567782e6f72672f7068707374616e2f7068707374616e2d6e657474652f762f737461626c65)](https://packagist.org/packages/phpstan/phpstan-nette)[![License](https://camo.githubusercontent.com/f9ae5ded59f770a8b8c4ac6a07ab4f0381261a43c45dea4f64b5e7d98974be98/68747470733a2f2f706f7365722e707567782e6f72672f7068707374616e2f7068707374616e2d6e657474652f6c6963656e7365)](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)
- Array access on components (`$component['name']`) resolves types via `createComponent*` methods
- `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\Forms\Container::getUntrustedValues` return type based on mapping class parameter.
- `Nette\Forms\Controls\BaseControl` fluent methods return `static` instead of `BaseControl`.
- `Nette\ComponentModel\Component::lookup` return type based on `$throw` parameter.
- `Nette\Application\UI\Component::getPresenter` return type based on `$throw` parameter.
- `Nette\Application\UI\Presenter::getSession` returns `Session` or `SessionSection` based on arguments.
- 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
- Presenter `@inject` properties are treated as initialized.
- 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 pattern
- `Nette\Utils\Strings::replace()` callback closure parameter type inferred from regex 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`)
- Validate regex patterns passed to `Nette\Utils\Strings` methods

Installation
------------

[](#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 installationIf 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

```

###  Health Score

73

—

ExcellentBetter than 100% of packages

Maintenance86

Actively maintained with recent releases

Popularity63

Solid adoption and visibility

Community51

Growing community involvement

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 61% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~47 days

Recently: every ~40 days

Total

75

Last Release

82d ago

Major Versions

0.12.21 → 1.0.02021-09-20

1.1.x-dev → 2.0.02024-10-26

PHP version history (5 changes)0.1PHP ~7.0

0.10PHP ~7.1

0.12.8PHP ^7.1 || ^8.0

1.1.0PHP ^7.2 || ^8.0

2.0.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/258cf2d2422f7e9ac5f7e1bb7a331f3fb717a11e51de7a3de2d6025507bd63cf?d=identicon)[ondrejmirtes](/maintainers/ondrejmirtes)

---

Top Contributors

[![ondrejmirtes](https://avatars.githubusercontent.com/u/104888?v=4)](https://github.com/ondrejmirtes "ondrejmirtes (177 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (20 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (14 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (10 commits)")[![adaamz](https://avatars.githubusercontent.com/u/4347332?v=4)](https://github.com/adaamz "adaamz (8 commits)")[![rattuscz](https://avatars.githubusercontent.com/u/688332?v=4)](https://github.com/rattuscz "rattuscz (7 commits)")[![xificurk](https://avatars.githubusercontent.com/u/117465?v=4)](https://github.com/xificurk "xificurk (6 commits)")[![ruudk](https://avatars.githubusercontent.com/u/104180?v=4)](https://github.com/ruudk "ruudk (5 commits)")[![lulco](https://avatars.githubusercontent.com/u/9377319?v=4)](https://github.com/lulco "lulco (5 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (4 commits)")[![spaze](https://avatars.githubusercontent.com/u/1966648?v=4)](https://github.com/spaze "spaze (4 commits)")[![janedbal](https://avatars.githubusercontent.com/u/1993453?v=4)](https://github.com/janedbal "janedbal (3 commits)")[![Kocal](https://avatars.githubusercontent.com/u/2103975?v=4)](https://github.com/Kocal "Kocal (3 commits)")[![lookyman](https://avatars.githubusercontent.com/u/3863468?v=4)](https://github.com/lookyman "lookyman (3 commits)")[![kamil-zacek](https://avatars.githubusercontent.com/u/17525718?v=4)](https://github.com/kamil-zacek "kamil-zacek (2 commits)")[![MartinMystikJonas](https://avatars.githubusercontent.com/u/2094752?v=4)](https://github.com/MartinMystikJonas "MartinMystikJonas (2 commits)")[![vhenzl](https://avatars.githubusercontent.com/u/243381?v=4)](https://github.com/vhenzl "vhenzl (2 commits)")[![pepakriz](https://avatars.githubusercontent.com/u/383294?v=4)](https://github.com/pepakriz "pepakriz (2 commits)")[![enumag](https://avatars.githubusercontent.com/u/539462?v=4)](https://github.com/enumag "enumag (2 commits)")[![Bleksak](https://avatars.githubusercontent.com/u/5411554?v=4)](https://github.com/Bleksak "Bleksak (1 commits)")

---

Tags

nette-frameworkphpphp7phpstanstatic-analysisstatic-analyzerstatic-code-analysistesting

###  Code Quality

TestsPHPUnit

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpstan-phpstan-nette/health.svg)

```
[![Health](https://phpackages.com/badges/phpstan-phpstan-nette/health.svg)](https://phpackages.com/packages/phpstan-phpstan-nette)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

78768.9M1.5k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

66766.6M1.1k](/packages/phpstan-phpstan-doctrine)[phpat/phpat

PHP Architecture Tester

1.2k3.5M32](/packages/phpat-phpat)[spaze/phpstan-disallowed-calls

PHPStan rules to detect disallowed method &amp; function calls, constant, namespace, attribute, property &amp; superglobal usages, with powerful rules to re-allow a call or a usage in places where it should be allowed.

33320.0M375](/packages/spaze-phpstan-disallowed-calls)[mglaman/phpstan-drupal

Drupal extension and rules for PHPStan

20829.0M124](/packages/mglaman-phpstan-drupal)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
