GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - phpstan/phpstan-nette: Nette Framework class reflection extension for PHPStan & framework-specific rules

BranchesTags
Open more actions menu

Latest commit

 

History

343 Commits
343 Commits

Folders and files

NameName
Last commit message
Last commit date
.agents
.agents
 
 
.github
.github
 
 
e2e/bug-208
e2e/bug-208
 
 
src
src
 
 
stubs
stubs
 
 
tests
tests
 
 
tmp
tmp
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CLAUDE.md
CLAUDE.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
collision-detector.json
collision-detector.json
 
 
composer.json
composer.json
 
 
extension.neon
extension.neon
 
 
phpstan.neon
phpstan.neon
 
 
phpunit.xml
phpunit.xml
 
 
rules.neon
rules.neon
 
 

Repository files navigation

Nette Framework extension for PHPStan

Build Latest Stable Version License

  • PHPStan
  • Nette Framework

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
  • Magic Nette\Object and Nette\SmartObject 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

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

About

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

Topics

nette-frameworkphpphp7phpstanstatic-analysisstatic-analyzerstatic-code-analysistesting

Resources

Readme
MIT license

Security policy

Security policy
Activity
Custom properties

Stars

119 stars

Watchers

7 watching

Forks

46 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.