Releases: hihaho/phpstan-rules
3.1.2
Internal performance work on rule hot paths — every optimisation is strictly a filter-order or data-structure change. No behaviour change, no public API change, no new or removed errors, no new configuration keys. All five rules remain final readonly class.
NoUnsafeRequestHelperRule— short-circuit theReflectionProvider::hasFunction/getFunctionpair with astrtolower($node->name->getLast()) !== 'request'pre-check. Reflection used to fire on everyFuncCallin the configured namespaces; it now fires only on calls whose last name-segment could actually resolve to the globalrequest()helper. Alias-aware: PHPStan'sNameResolveralready rewritesuse function request as Ximports toFullyQualified('request')before the rule runs, soX('key')still flags. Locked with a newuse function request as reqregression stub.NoUnsafeRequestDataRule—in_array(strtolower($method), $listOf22, true)replaced byisset($lookup[strtolower($method)])against a flippedarray<string, true>built once in the constructor.classIsRequestno longer reconstructsnew ObjectType(Request::class)on every call; it reuses a single instance hoisted to a private readonly property.NoUnsafeRequestFacadeRule— sameisset-map treatment for unsafe methods;strtolower(Illuminate\Support\Facades\Request::class)hoisted to a private readonly property instead of recomputed per call; and the class-equality check (one string compare) now bails before the method-name lookup. Locked with a newuse Illuminate\Support\Facades\Request as RequestFacaderegression stub.NoInvadeInAppCode—$node->name->toString()is computed once into a local and reused across the two equality checks instead of being rebuilt twice.
Full Changelog: v3.1.1...v3.1.2
3.1.1
What's Changed
- Fix update-changelog workflow + backfill v3.1.0 entry by @SanderMuller in #45
Full Changelog: v3.1.0...v3.1.1
3.1.0
Added
- Three rules preventing unvalidated reads from
Illuminate\Http\Requestin application code:NoUnsafeRequestDataRule— flagsMethodCallon aRequestorFormRequestreceiver whose method is innoUnsafeRequestData.unsafeMethods. Defaults:input,all,get,query,post,only,except,collect,string,str,integer,boolean,float,json,keys,fluent,array,date,enum,enums,file,allFiles. Union-typed receivers (Request|Other) are flagged when any member is-aRequest. Scope-class exemption walks the inheritance chain — custom baseFormRequestclasses are transparent. Identifier:hihaho.validation.noUnsafeRequestData.NoUnsafeRequestHelperRule— flags therequest('key')direct-argument helper form. Uses PHPStan'sReflectionProviderto resolve imports and aliases (use function request as foo). Error message interpolates the literal key for grep-friendly triage. Zero-argumentrequest()is not flagged — chained method calls on its return are caught byNoUnsafeRequestDataRule. Identifier:hihaho.validation.noUnsafeRequestHelper.NoUnsafeRequestFacadeRule— flags static calls onIlluminate\Support\Facades\Request(e.g.Request::boolean('debug'),Request::file('attachment')). Identifier:hihaho.validation.noUnsafeRequestFacade.
noUnsafeRequestDataconfiguration block withunsafeMethods,namespaces, andexcludeNamespaces.excludeNamespacesdefaults toApp\ProvidersandApp\Http\Responses— both areas receive rawRequestvia framework-dictated signatures (RateLimiter::for(...)closures, Fortify response contracts) with no FormRequest entry point.App\Http\Resourcesis intentionally not defaulted; add it in your own config ifJsonResource::toArray(Request)reading raw request data is acceptable for your project.ChecksNamespace::namespaceStartsWithAny()helper for list-based namespace matching.
Changed
- Raw readers on a
FormRequesttypehint in a controller are now flagged.FormRequestauto-validation runs on dispatch, but inherited readers still return the full unvalidated payload including keys outsiderules(). Use$request->validated(),$request->safe(), or the array returned by$request->validate([...])instead. For Stringable / int / bool chaining,$request->safe()->string('key')mirrors$request->string('key')against validated input.
See README.md for full rule descriptions, configuration keys, and baseline categories.
Full Changelog: v3.0.0...v3.1.0
v3.0.0
Major version. Class-naming and routing conventions move to the sibling package hihaho/rector-rules as auto-fixers. This package keeps the rules that have no auto-fix counterpart. See UPGRADING.md for migration steps.
Removed
Rules\NamingClasses\Commands,Mail,Notifications,EloquentApiResources(andSuffixableRulebase). Replaced byAddCommandSuffixRector,AddMailSuffixRector,AddNotificationSuffixRector, andAddResourceSuffixRectorinhihaho/rector-rules.Rules\Routing\SlashInUrlandRules\Routing\RouteGroups. Replaced byNormalizeRoutePathRectorandRouteGroupArrayToMethodsRectorinhihaho/rector-rules.- PHP 8.2 support. Minimum is now
^8.3. illuminate/{console,http,mail,notifications,routing}dev deps. Onlyilluminate/supportremains inrequire.
Changed
ChainedNoDebugInNamespaceRulenow narrows matches to methods declared by a class in theIlluminate\namespace. A domain class with its own->dump()method is no longer a false positive.StaticChainedNoDebugInNamespaceRulenarrows the same way, with aFacadesubclass fallback soCache::dump()and other facades without@method static ... dump()annotations still flag via theFacade::__callStaticproxy.NoInvadeInAppCodeidentifier category corrected fromhihaho.debug.*tohihaho.generic.*(not a debug rule).- All rules now use
final readonly class,#[\Override]on interface implementations, and explicit@return list<IdentifierRuleError>annotations. OnlyAllowFacadeAliasInBladekeeps\ReflectionClassruntime reflection deliberately. PHPStan'sReflectionProviderdoes not invoke SPL autoloaders, so static discovery would silently miss every lazy Laravel facade alias. Documented in-source.extension.neon: rules shorthand for dependency-free rules,services:block only for the rule that needsReflectionProviderinjected.
Added
- Laravel 13 coverage in the CI test matrix.
illuminate/support: ^11.31 | ^12.0 | ^13.0was already declared; the matrix now exercises all three. - Rule test coverage: 44 tests across 5 rule classes. Every rule has identifier assertions, dynamic-call-edge coverage, outside-
App/Testsnegative cases, and regression guards for the narrowing (unknown receiver, union types, user-defined facade, unannotated Laravel facade, non-Facade aliased class). - Rector setup:
rector/rector ^2.0dev dep,rector.phpwithphp83set, import-name cleanup, and composerrector,format,qascripts. package-boost+orchestra/testbenchdev deps for managing.ai/skills/and injecting the verification-before-completion guideline block intoCLAUDE.md/AGENTS.md.CHANGELOG.mdbackfilled to v0.1.0 in Keep-a-Changelog format, plusupdate-changelog.ymlworkflow that keeps it current on future releases.- Laravel-package README: badges, per-rule docs, and cross-link to
hihaho/rector-rules.
CI
- Merged
rector.yml+fix-php-code-style-issues.ymlinto a singleauto-fix.ymlmutator (pull_request-only, same-repo PRs only). - New
update-changelog.yml(runs on release publish). analyzer.ymlandtests.yml: path filters, concurrency with cancel-in-progress, per-tool result caching, 5-minute timeouts, matrix-injection hardening via env vars.- All third-party actions pinned to commit SHAs.
Quality configs
- PHPStan:
strictRules.allRules, 100% constant type coverage, PhpStormeditorUrl. - Pint aligned with
hihaho/rector-rulessibling. - PHPUnit:
beStrictAboutTestsThatDoNotTestAnythingand a scoped<source>block.
What's Changed
- Bump shivammathur/setup-php from 2.36.0 to 2.37.0 by @dependabot[bot] in #43
- Package modernization by @SanderMuller in #44
Full Changelog: v2.2.0...v3.0.0
v2.2.0
What's Changed
- Bump actions/checkout from 4 to 6 by @dependabot[bot] in #40
- Fix bugs, improve performance, and expand test coverage by @SanderMuller in #41
- Harden GitHub Actions workflow security by @SanderMuller in #42
Full Changelog: v2.1.0...v2.2.0
v2.1.0
What's Changed
- Bump shivammathur/setup-php from 2.31.1 to 2.32.0 by @dependabot in #37
- Laravel 12 support by @SanderMuller in #38
Full Changelog: v2.0.1...v2.1.0
v2.0.1
What's Changed
- Handle resource collections in rules/naming classes/eloquent api resources by @SanderMuller in #36
Full Changelog: v2.0.0...v2.0.1
v1.2.1
What's Changed
Handle resource collections in rules/naming classes/eloquent api resources by @SanderMuller in #36
Full Changelog: v1.2.0...v1.2.1
V1.2.0
Backport v2 changes excluding PHPstan 2.0 to v1
v2.0.0
What's Changed
- Bump shivammathur/setup-php from 2.30.5 to 2.31.0 by @dependabot in #26
- Bump shivammathur/setup-php from 2.31.0 to 2.31.1 by @dependabot in #27
- Bump actions/checkout from 4.1.7 to 4.2.0 by @dependabot in #28
- Bump actions/checkout from 4.2.0 to 4.2.1 by @dependabot in #30
- Bump actions/checkout from 4.2.1 to 4.2.2 by @dependabot in #31
- [v2.0] Add PHP8.4 support & upgrade to PHPStan 2.0 by @SanderMuller in #34
New Contributors
- @SanderMuller made their first contribution in #34
Full Changelog: v1.1.1...v2.0.0