Repository navigation
v6.0.0
PHPStan extensions are now loaded through phpstan/extension-installer. The Worksome rules no longer need to be included in your phpstan.neon, and Larastan is now optional.
Breaking changes
phpstan/extension-installeris now required. It is a Composer plugin, so it must be allowed in yourcomposer.json.- The coding-style PHPStan config is loaded automatically. Remove any includes of
vendor/worksome/coding-style/phpstan.neonorvendor/worksome/coding-style/larastan.neon. If a file is included both manually and by the extension installer, PHPStan fails withThese files are included multiple times. - Larastan and the strict rules are no longer dependencies.
larastan/larastanandcanvural/larastan-strict-rulesare now suggested packages, so Laravel projects must require them directly. If a project doesn't install them, the Laravel rules are not loaded and no error is reported. WorksomeRectorConfig::configure()no longer takes alarastanargument. Larastan is loaded when it is installed. Callingconfigure(larastan: ...)now fails with an unknown named parameter error.- Rector no longer loads your project's
phpstan.neon. Rector now receives the extension configs registered with the extension installer, which provide everything it needs for type inference.
Upgrade guide
-
Update the package and allow the extension installer plugin:
composer config allow-plugins.phpstan/extension-installer true composer require --dev worksome/coding-style:^6.0 -
Laravel projects only: require Larastan and the strict rules, if you don't already:
composer require --dev larastan/larastan canvural/larastan-strict-rules
-
Remove the coding-style includes from
phpstan.neon(orphpstan.neon.dist):includes: - - ./vendor/worksome/coding-style/larastan.neon - - ./vendor/worksome/coding-style/phpstan.neon - phpstan-baseline.neon
Also remove includes of any other extension that registers itself with the extension installer, for example:
- - vendor/cmixin/business-day/extension.neon - - vendor/worksome/phpstan-request-factories/extension.neon
If PHPStan reports
These files are included multiple times, remove the files it lists. -
Remove the
larastanargument fromrector.php:-return WorksomeRectorConfig::configure(larastan: false) +return WorksomeRectorConfig::configure()
-
Run
vendor/bin/phpstan analyseandvendor/bin/rector process --dry-runto confirm everything still passes.
Things to be aware of
- Other installed extensions are now loaded too. The extension installer loads every PHPStan extension installed in your project, not just the ones from this package. Examples include Carbon and Pest. This is the intended setup for those packages, but it could change the errors PHPStan reports.
- Laravel rules are loaded only when the packages are present. The Laravel rules load when
larastan/larastanis installed. The strict rules load only whencanvural/larastan-strict-rulesis installed as well. A package in the extension installer'signorelist is treated as not installed. - Non-Laravel projects no longer install the Laravel stack. Larastan and the
illuminate/*packages it pulled in are removed when you update.
Fixes
DisallowPHPUnitRulenow uses PHPStan's reflection instead ofis_subclass_of(). Previously it autoloaded every class PHPStan analysed, which could crash analysis.DisallowedAttributesRectornow removes a disallowed attribute from a group (e.g.#[Pure, Other]) with Rector 2.8+.
Full Changelog: v5.2.0...v6.0.0