What's Changed
Merged symplify/phpstan-extensions into this package (#270)
symplify/phpstan-extensions had only a few classes, so it now lives here. This brings:
- Return type extensions (in
config/phpstan-extensions.neon, all opt-in, off by default):- Symfony
Container::get($id)resolved to the$idtype, and FinderSplFileInfo::getRealPath()resolved tostring - Laravel
Container::make($id)resolved to the$idtype - Native
getcwd()/dirname()/realpath()resolved tostring
- Symfony
SymplifyErrorFormatter— a compact error formatter, usable viaerrorFormat: symplify
New rules
NewOverSettersRuleported fromtomasvotruba/ctor— opt-in viactor: true(#267)- PHPUnit mock rules merged from
rector/mockstan— opt-in viamocks: true(#268)
New parameters
| Parameter | Default | What it enables |
|---|---|---|
ctor |
false |
NewOverSettersRule + its collector — flags new followed by setter calls that should be constructor arguments (#267) |
mocks |
false |
PHPUnit mock rules from rector/mockstan (#268) |
symfonyReturnType |
false |
Symfony Container::get() and Finder SplFileInfo::getRealPath() return type extensions (#270) |
laravelReturnType |
false |
Laravel Container::make() return type extension (#270) |
pathStrings |
false |
getcwd() / dirname() / realpath() always-string return type extension (#270) |
Example phpstan.neon
All of the above ship in the package and are auto-loaded by phpstan/extension-installer —
you only flip the parameters. The topic rule sets (Doctrine, naming, Symfony, …) stay opt-in
via includes:.
# phpstan.neon
includes:
# opt-in topic rule sets (optional)
- vendor/symplify/phpstan-rules/config/symplify-rules.neon
- vendor/symplify/phpstan-rules/config/naming-rules.neon
- vendor/symplify/phpstan-rules/config/doctrine-rules.neon
- vendor/symplify/phpstan-rules/config/symfony-rules.neon
parameters:
# opt-in rules
ctor: true # NewOverSettersRule
mocks: true # PHPUnit mock rules
# opt-in return type extensions
symfonyReturnType: true # Container::get() + Finder SplFileInfo::getRealPath()
laravelReturnType: true # Container::make()
pathStrings: true # getcwd()/dirname()/realpath() => stringRun with the bundled error formatter:
vendor/bin/phpstan analyse --error-format symplifyImprovements
- Bump to PHP 8.4 (#271)
- Add
CLAUDE.mdwith project metadata (#269) - Document missing PHPStan rules in README with examples
- Remove Rector-specific rules section from README
Full Changelog: 14.10.0...14.11.0