Hello everyone 👋
I announced today that PHPStan 1.0 is going to be released on November 1st 2021.
I'm approaching you as one of the most popular projects using PHPStan internally. I'd love if you could prepare your code for PHPStan 1.0 in advance so that it's ready to release on the same day.
Here's a brief guide how to approach the upgrade:
- Create a branch 🌴
- Update your composer.json to
"phpstan/phpstan": "^1.0", add "minimum-stability": "dev" and "prefer-stable": true if necessary.
- Update your code with the BC breaks below in mind. 🔧
- Fix the code so that it passes PHPStan's analysis 🤓
- Wait for PHPStan 1.0 release on November 1st, merge your branch and tag the next major version 👍
Thank you!
Here are the BC breaks. The list is huge but most of those have very little impact.
There are new rules around using PHPStan internals in regard to backward compatibility promise: https://phpstan.org/developing-extensions/backward-compatibility-promise
It's possible that not everything you use is covered by it - so I'm here to help you to transition to correct usage, or add some @api annotations in PHPStan itself so that more is covered by the promise. Let me know!
BC breaks for end-users
The following are interesting only if you create a custom ruleset in your configuration file:
BC breaks for extension developers
Hello everyone 👋
I announced today that PHPStan 1.0 is going to be released on November 1st 2021.
I'm approaching you as one of the most popular projects using PHPStan internally. I'd love if you could prepare your code for PHPStan 1.0 in advance so that it's ready to release on the same day.
Here's a brief guide how to approach the upgrade:
"phpstan/phpstan": "^1.0", add"minimum-stability": "dev"and"prefer-stable": trueif necessary.Thank you!
Here are the BC breaks. The list is huge but most of those have very little impact.
There are new rules around using PHPStan internals in regard to backward compatibility promise: https://phpstan.org/developing-extensions/backward-compatibility-promise
It's possible that not everything you use is covered by it - so I'm here to help you to transition to correct usage, or add some
@apiannotations in PHPStan itself so that more is covered by the promise. Let me know!BC breaks for end-users
maxis now level 9. Feel free to updatemaxto8if your code isn't ready.numeric-string(it was previously described asstring&numeric), and also array shapes.baselineNeonerror formatter, use--generate-baselineCLI option instead (phpstan/phpstan-src@492cfbc)polluteCatchScopeWithTryAssignmentsconfig parameter (phpstan/phpstan-src@8933c7e)autoload_filesparameter - use Discovering Symbols instead (phpstan/phpstan-src@7a21246)autoload_directoriesparameter - use Discovering Symbols instead (phpstan/phpstan-src@f67b48a)bootstrapparameter - usebootstrapFilesinstead (phpstan/phpstan-src@1baa294)implicitThrowsconfiguration parameter toexceptions.implicitThrows(phpstan/phpstan-src@96b7c48)--paths-fileCLI option (phpstan/phpstan-src@5670cf2)dump-depscommand (phpstan/phpstan-src@9c7017c)excludes_analyseoption, useexcludePathsinstead (phpstan/phpstan-src@d25c5e5)The following are interesting only if you create a custom ruleset in your configuration file:
DeadCatchRule, replaced byCatchWithUnthrownExceptionRule(phpstan/phpstan-src@4dba60b)VariableCertaintyInIssetRule, replaced byIssetRule(phpstan/phpstan-src@2e858de)MissingClosureNativeReturnTypehintRule, no longer needed thanks to type inference (phpstan/phpstan-src@1c34d8d)BC breaks for extension developers
CompoundTypeHelper(phpstan/phpstan-src@145c4e3)CommentHelper(phpstan/phpstan-src@ebad6f6)DependencyDumper(phpstan/phpstan-src@9c7017c)PHPStan\Reflection\Generic\ResolvedFunctionVariant, replaced byPHPStan\Reflection\ResolvedFunctionVariant(phpstan/phpstan-src@1cc6c81)ClassReflection::getNativeMethods(), usegetNativeReflection()instead (phpstan/phpstan-src@d2c1446)PhpPropertyReflection::hasPhpDoc(), replaced byhasPhpDocType()(phpstan/phpstan-src@bedd5be)NodeDependenciesno longer iterable (phpstan/phpstan-src@f76875a)TestCasetoPHPStanTestCase(#634), thanks @frankdejonge!StaticTypeandThisType- requireClassReflectionin constructor (phpstan/phpstan-src@7aabc84)PHPStanTestCase- extensions can no longer be provided by overriding methods fromPHPStanTestCase. UsegetAdditionalConfigFiles()instead. (phpstan/phpstan-src@65efd93, phpstan/phpstan-src@239291a)|falseto|null(phpstan/phpstan-src@629ccf6)BrokerAwareExtension(phpstan/phpstan-src@db2f7fb)PHPStanTestCase::createBroker(). UsecreateReflectionProvider()instead. (phpstan/phpstan-src@1e5cf58)PHPStan\Broker\Broker. UsePHPStan\Reflection\ReflectionProviderinstead. (phpstan/phpstan-src@c775594)PHPStan\Broker\Broker::getInstance(). UsePHPStan\Reflection\ReflectionProviderStaticAccessorinstead. (phpstan/phpstan-src@4e7d60d)