phpstan/phpstan-nette
PHPStan extension for the Nette Framework providing precise type inference for components, DI container getByType/createInstance, forms, dynamic Html methods, magic properties, and presenters, plus optional rules for regex validation and Nette\Object deprecation.
larastan/larastan; if there is Nette code in the portfolio (legacy app, acquired service, admin panel), this package is the correct quality tooling for that surface.@method/@property docblocks, and type-narrowing helpers for Nette's magic (createComponent*, getByType(Foo::class), getValues($asArray), Html dynamic methods, SmartObject properties). That is ongoing maintenance with no product differentiation — a clear "buy" (and it's free/MIT, dev-only).rules.neon) are enabled in the blocking pipeline or advisory-only.getByType/createInstance returning wrong types), untyped component lookup in presenters, form value arrays with wrong shapes, missing exception rethrows (e.g. AbortException), invalid regex passed to Nette\Utils\Strings, and use of deprecated Nette\Object. These are exactly the classes of bug that escape code review and surface as 500s in production.Adopt when all of the following hold:
Nette\Utils), ideally Nette 3/4.require-dev dependency and wire it via phpstan/extension-installer (one line) or a manual extension.neon include; rules.neon opt-in separately so the stricter framework rules can be trialed before they block merges.Look elsewhere (or skip) when:
larastan/larastan instead; this package will provide only Nette\* symbols that don't exist in your codebase. Do not add it "just in case" — it adds CI surface for zero signal.One-liner: a free, dev-only PHPStan add-on that teaches our static analyzer how Nette's "magic" works, so type errors in presenters, DI lookups, forms and string utilities are caught in CI instead of in production.
For executives: zero license cost (MIT), zero runtime risk (dev dependency only), and a small, bounded integration effort (composer require + one config include). The payoff is defect prevention in exactly the areas where Nette hides types from the analyzer — DI resolution, component factories, form value arrays — plus guardrails against deprecated patterns and swallowed exceptions. Success is measured in reduced type-related incidents in Nette services, lower baseline error counts over time, and faster onboarding of engineers who can't hold Nette's magic conventions in their heads.
For engineering: one command, composer require --dev phpstan/phpstan-nette, then either rely on phpstan/extension-installer or add vendor/phpstan/phpstan-nette/extension.neon to the config; add rules.neon when ready. It gives correct types for Container::getComponent() and $component['name'], getByType(Foo::class), getValues()/getUntrustedValues() shapes, Strings::match/matchAll array shapes and replace callback types, lookup()/getPresenter()/getSession() nullability, Html dynamic methods, and SmartObject magic properties — all things PHPStan cannot infer on its own. Ship it in advisory mode first, publish the error count, then ratchet to blocking.
The caveat to state up front, not bury: if this assessment is being made in service of a Laravel roadmap, the recommendation is no-go on this package and yes to Larastan; this extension belongs in the plan only for as long as Nette code remains in production, and should carry an explicit decommission date tied to that migration.
How can I help you explore Laravel packages today?