Skip to content

v6.0.0

Choose a tag to compare

@owenvoke owenvoke released this 27 Oct 13:11
· 2 commits to main since this release
7327d0c

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-installer is now required. It is a Composer plugin, so it must be allowed in your composer.json.
  • The coding-style PHPStan config is loaded automatically. Remove any includes of vendor/worksome/coding-style/phpstan.neon or vendor/worksome/coding-style/larastan.neon. If a file is included both manually and by the extension installer, PHPStan fails with These files are included multiple times.
  • Larastan and the strict rules are no longer dependencies. larastan/larastan and canvural/larastan-strict-rules are 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 a larastan argument. Larastan is loaded when it is installed. Calling configure(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

  1. 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
  2. Laravel projects only: require Larastan and the strict rules, if you don't already:

    composer require --dev larastan/larastan canvural/larastan-strict-rules
  3. Remove the coding-style includes from phpstan.neon (or phpstan.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.

  4. Remove the larastan argument from rector.php:

    -return WorksomeRectorConfig::configure(larastan: false)
    +return WorksomeRectorConfig::configure()
  5. Run vendor/bin/phpstan analyse and vendor/bin/rector process --dry-run to 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/larastan is installed. The strict rules load only when canvural/larastan-strict-rules is installed as well. A package in the extension installer's ignore list 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

  • DisallowPHPUnitRule now uses PHPStan's reflection instead of is_subclass_of(). Previously it autoloaded every class PHPStan analysed, which could crash analysis.
  • DisallowedAttributesRector now removes a disallowed attribute from a group (e.g. #[Pure, Other]) with Rector 2.8+.

Full Changelog: v5.2.0...v6.0.0