Releases: phpstan/phpstan
2.1.33
Improvements 🔧
- Cache files in OptimizedDirectorySourceLocatorFactory (#4577), #13852, thanks @staabm!
- Add more numeric-string inferences after string concat (#4447), thanks @VincentLanglet!
- Improve EnumSanityRule (#4543), #13768, thanks @VincentLanglet!
- Too wide bool return type is not reported in trivial methods (#4444), #13482, thanks @staabm!
Bugfixes 🐛
- De-duplicate phpstan.php errors (#4560) (#4560), #13813, thanks @staabm!
- Fix default level message (phpstan/phpstan-src@9ab9647)
- [PHP 8.5]
ini_get("max_memory_limit")is a string (#4574), thanks @staabm! - Revert changes to ArrayMapArgVisitor which switch the order of named arguments (phpstan/phpstan-src@f562834)
- Fix "Array does not have offset" in
curl_setopt_array()(#4590), #13862, thanks @staabm! - OversizedArray is not truthy (#4556), #13797, thanks @VincentLanglet!
- Do not instantiate Accessory without string type (#4550), #13784, thanks @VincentLanglet!
- Narrow CURLOPT_SHARE accepting type (#4611), thanks @staabm!
Function signature fixes 🤖
- Fix return-type for DOMNode::C14N (#4608), thanks @tvdijen!
- Fix DOMNode::C14N bad definition (#4361), #8096, thanks @VincentLanglet!
- Fix time not being considered an impure function. (#4609), #13874, thanks @mad-briller!
Internals 🔍
- Simplify ClassReflection constructor (phpstan/phpstan-src@821ff76)
- Introduce ClassReflectionFactory (phpstan/phpstan-src@35470a0)
- Prevent global side-effect in Bug13813IntegrationTest (#4566), thanks @staabm!
- Parameter narrowMethodScopeFromConstructor in DI (phpstan/phpstan-src@05b80ef)
- Reduce ContainerFactory::postInitializeContainer() calls (#4572), thanks @staabm!
- TypeSpecifier as an interface (phpstan/phpstan-src@fc6a2b1)
- Change where TypeSpecifier is set into TypeSpecifierAwareExtension (phpstan/phpstan-src@36cf9a1)
- Enable FileCacheStorage for OptimizedDirectorySourceLocatorFactory in tests (#4576), thanks @staabm!
- Upload baseline on downgraded code (phpstan/phpstan-src@057c79f)
- More precise return type for gatherAssertTypes (#4614), thanks @staabm!
- AnalyserIntegrationTest uses
narrowMethodScopeFromConstructor: true(phpstan/phpstan-src@dc9bf7f)
2.1.32
Improvements 🔧
- [PHP 8.5] Pipe operator support (phpstan/phpstan-src@e9df52e)
- [PHP 8.5] Report deprecated casts (phpstan/phpstan-src@d0a77d1)
- [PHP 8.5] Report deprecated backtick operator (phpstan/phpstan-src@9405233)
- [PHP 8.5] Added PHP_BUILD_DATE type (#4468), thanks @staabm!
- [PHP 8.5] Global constants support attributes (phpstan/phpstan-src@6958f86)
- [PHP 8.5] Add support for FILTER_THROW_ON_FAILURE for filter_var (#4495), thanks @canvural!
- [PHP 8.5] Add
array_firstandarray_lastreturn type extensions (#4499) (#4499), thanks @canvural! - [PHP 8.5] Support for deprecated traits (phpstan/phpstan-src@f0675a7)
- [PHP 8.5] Support for
#[Override]on properties (phpstan/phpstan-src@8b85e62) - [PHP 8.5] clone with support (phpstan/phpstan-src@5a9471a)
- [PHP 8.5] Support for
Closure::getCurrent()(phpstan/phpstan-src@e3ac5ee) - [PHP 8.5] Support for casts in constant (initializer) expressions (phpstan/phpstan-src@df5ede5)
- [PHP 8.5] Support for first class callables in constant expressions (initializers) (phpstan/phpstan-src@f436abf)
- [PHP 8.5] Support for static Closures in constant expressions (initializers) (phpstan/phpstan-src@ab704f4)
- [PHP 8.5] Support for asymmetric visibility in static properties (phpstan/phpstan-src@8b2b97f)
- NodeCallbackInvoker interface to invoke all PHPStan rules on a synthetic AST node (#4429)
- The interface NodeCallbackInvoker can be typehinted in 2nd parameter of
Rule::processNode() - See full explanation
- CompositeRule can be used to test rules using NodeCallbackInvoker (#4438), thanks @staabm!
- The interface NodeCallbackInvoker can be typehinted in 2nd parameter of
- InvalidIncDecOperationRule - make aware of deprecation of
--(PHP 8.3) and++(PHP 8.5) on non-numeric strings (phpstan/phpstan-src@0ff7e44) - InvalidIncDecOperationRule - make aware of more deprecations (phpstan/phpstan-src@3d6bbe4)
- InvalidPromotedPropertiesRule - report
finalin promoted property on PHP < 8.5 (phpstan/phpstan-src@e5de6b8) - The
(void)cast is supported only on PHP 8.5 and later. (phpstan/phpstan-src@53b87e0) - Rules about
#[NoDiscard]report errors only on PHP 8.5+, errors are non-ignorable (phpstan/phpstan-src@d00b769) - Rules about
#[NoDiscard]report when call is in(void)cast but should not (phpstan/phpstan-src@099b87a) - Understand always-overwritten arrays in foreach (#4534), #2273, #13730
- Support writing to array in foreach with value-by-ref (#4537)
- Report unknown parameter for implicit variadic methods (#4481) (#4481), #13719, thanks @VincentLanglet!
- IgnoreErrorExtension is a valid conditional tag (#4488), thanks @staabm!
- Reduce file-parsing in ResultCacheManager (#4491), thanks @staabm!
- Faster AutowiredAttributeServicesExtension->processParameters() (#4489) (#4489), thanks @staabm!
- Detect duplicated args passed to a variadic parameter (#4498), #13710, thanks @takaram!
- Add support for statement in conditional tags (#4512), thanks @VincentLanglet!
- Include identifier in
gitlaberror format (#4421), thanks @spawnia! - PropertyInClassRule - move supportsPropertyHooks check to bottom to have more errors reported (phpstan/phpstan-src@6ccdba2)
- TooWideMethodThrowTypeRule - new opt-in option for reporting too-wide implicit (inherited)
@throws(phpstan/phpstan-src@b6a2e0f), #13696, #13671
Bugfixes 🐛
- Fixed infinite recursion with late-resolvable types (phpstan/phpstan-src@7f3ad70), #13685
- Infer
non-empty-list/arrayafterarray_key_exists($i, $arr)(#4440) (#4440), thanks @staabm! !array_key_exists()should implyarrayfor PHP8+ (#4417), #6209, #13301, thanks @staabm!- Invalidate native expression types after clearstatcache call (#4448) (#4448), #11484, thanks @VincentLanglet!
- Use the same scalar limit for sprintf and concat (#4454), #13378, thanks @VincentLanglet!
- Handle impure/throw point of inherited constructors of anonymous classes (#4455), #13698, thanks @takaram!
- Adjust a bunch of places for first-class callables and nullsafe operators (phpstan/phpstan-src@e437c5a)
- Fix sprintf() types and placeholders (#4463), thanks @staabm!
- Fix return type inference from immediately invoked closure (phpstan/phpstan-src@3702305)
- Fix crashes in ParametersAcceptorSelector (#4467), #13714, thanks @staabm!
- Fix null coalesce false positive for multi-dimensional array in loop (#4475), thanks @schlndh!
- Fix type of clone expression (phpstan/phpstan-src@020adb5)
- Ensure that JetBrains terminal sees correct relative path (#4479), #13697, thanks @caufang!
- Fix for losing
array_key_existsinference when adding a false condition (#4473) (#4473), #11276, thanks @staabm! - Fix filter var on uncertainty flags (#4418), #11485, thanks @VincentLanglet!
- TestCaseSourceLocatorFactory - skip polyfills based on PHP version (phpstan/phpstan-src@f63b423)
- Fix
composerAutoloaderProjectPathsarray so that the items always refer to dir with composer.json in it (#4522), phpstan/phpstan-doctrine#646 - Add support for union of constant integer for filter_var (#4519), thanks @VincentLanglet!
- Child class of parent class that uses a trait with a constant can redeclare the constant with a different value (phpstan/phpstan-src@9f415ae), #13119
Function signature fixes 🤖
Internals 🔍
- SimultaneousTypeTraverserTest for improved UnionType implementation (phpstan/phpstan-src@0bddac1)
- Fix
BenevolentUnionType::traverseSimultaneously()(phpstan/phpstan-src@856a9f1) - Improve
IntersectionType::traverseSimultaneously()for arrays (phpstan/phpstan-src@0693e5a) - Changelog generator: Use better API to associate commit with a merged PR (phpstan/phpstan-src@e153fa4)
- Use GraphQL to find autoclosed issues when a PR is merged (phpstan/phpstan-src@2f69398)
- GenerateFactory - allow setting the result type in attribute, override create method return type (#4429)
- Narrow errors array type to list (#4445), thanks @staabm!
- No memory_limit for tests as PHPUnit recommends (#4449)
- Compute allowedArrayType only once (#4453), thanks @VincentLanglet!
- Narrow types (#4465), thanks @staabm!
- Revert "MemoryCacheStorage - var_export the data to reproduce certain issues" (ht...
2.1.31
Bleeding edge 🔪
- AssignToByRefExprFromForeachRule (level 1) (phpstan/phpstan-src@0624342), #13625, #11120
- Validate curl_setopt_array parameter array (#4395), #13615, thanks @staabm!
- Restrict accepted args of
php_uname()(#4359), thanks @dktapps! array_rand()requires anon-empty-arrayas of PHP 8 (#4397), thanks @staabm!- Report implicit (inherited) too-wide
@throwstype (phpstan/phpstan-src@3eaad7f)
If you want to see the shape of things to come and adopt bleeding edge features early, you can include this config file in your project's phpstan.neon:
includes:
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
Of course, there are no backwards compatibility guarantees when you include this file. The behaviour and reported errors can change in minor versions with this file included. Learn more
Improvements 🔧
- New config parameter
exceptions.check.throwTypeCovariance(phpstan/phpstan-src@3f7e878), #13649 - New config parameter
checkTooWideThrowTypesInProtectedAndPublicMethods(phpstan/phpstan-src@9fc483d), #13258-
- made TooWideMethodThrowTypeRule behaviour similar to TooWideMethodReturnTypehintRule
-
- made TooWidePropertyHookThrowTypeRule to be similar to TooWideMethodReturnTypehintRule (phpstan/phpstan-src@67ef20b)
-
- Useful tip about what
@throwsshould be added when the implicit one is too wide (phpstan/phpstan-src@8031040) - Relax strict printf parameter check (#4400), thanks @schlndh!
- Support union types in curl_setopt validation (#4396), thanks @staabm!
- Do not report non existent offset for invalid ones (#4398), thanks @VincentLanglet!
- Report float and null offset based on PHP version (#4406), #13592, thanks @VincentLanglet!
Bugfixes 🐛
- Fix list type lost in for loop (#4403), #12807, thanks @staabm!
- Improve support of FILTER_REQUIRE_ARRAY (#4410), #11863, thanks @VincentLanglet!
- Add VersionCompareFunctionDynamicThrowTypeExtension (#4408), #13515, thanks @VincentLanglet!
- Fix
OversizedArrayType::isSubTypeOf()(#4407), #13509, thanks @VincentLanglet! - Fix "array_rand() - offset might not exists" (#4383), #12981, thanks @staabm!
- Avoid crashing on enum without value (#4336) (#4336), #7927, thanks @VincentLanglet!
- Special-case LateResolvableType in
UnionType::isSuperTypeOf()(phpstan/phpstan-src@47a820b), #13652, #11033 - Object with dynamic property assignments cannot report too-wide types on properties (phpstan/phpstan-src@851ab2c), #13624
- Setting array offset on a property should pick types from original UnionType still present in the current property type (phpstan/phpstan-src@a8cae55), #13654, #7880
- Do not compile special DI container for workers (phpstan/phpstan-src@8fd0fda)
- This should solve occasional errors like:
Warning: rename(phpstan/cache/nette.configurator/Container_be4038c220.php.tmp,phpstan/cache/nette.configurator/Container_be4038c220.php): No such file or directory in phar:///vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/ContainerLoader.php on line 68Unable to create file 'phpstan/cache/nette.configurator/Container_be4038c220.php'.
- Result cache - fix restoring errors from stub files (#4424), #12826
- DefaultStubFilesProvider - normalize stub file paths (phpstan/phpstan-src@d78a5d8, phpstan/phpstan-src@e4e4eaa)
- Exclude first-party stubs from validation (#4190), thanks @blyxxyz!
- Overriding
@propertytags - take native type into account if the scope can read the native property (phpstan/phpstan-src@bc20ce4), #13537 - Infer
mixed~array<mixed> | array<string>(#4425) (#4425), #13628, #12930, thanks @VincentLanglet! - Fix reportNestedTooWideType (improve
UnionType::traverseSimultaneously()) (phpstan/phpstan-src@6597ef6)
Function signature fixes 🤖
- Fix extract signature (#4402), #13434, thanks @VincentLanglet!
- Improve is_resource inference (#4411), #10394, thanks @VincentLanglet!
- Mark redis method as impure (#4409), #10215, thanks @VincentLanglet!
- Dynamic DOM return type (#4354), #9200, thanks @VincentLanglet!
- Fix XDOMPath::query() return type (#4373), #13595, thanks @stefanfisk!
Internals 🔍
- MutatingScope::unsetExpression can be private (phpstan/phpstan-src@a2ebe49)
- Reduce visibility of some methods to private (#4404), thanks @staabm!
- Get rid of
instanceof *Typechecks (#4405), thanks @staabm! - Fix PHP version and grammar in README.md (#4420), thanks @spawnia!
- Use
UnionType::filterTypes()in one more place (phpstan/phpstan-src@3e78ccf) - Revert "Narrow type on setting offsets of properties" (phpstan/phpstan-src@4c36e11)
- No longer needed after phpstan/phpstan-src@a8cae55
- Extract ParentMethodHelper (phpstan/phpstan-src@d072ced)
2.1.30
Improvements 🔧
- Alternative solution to disable cloning with
--prefer-sourcethat does not need another repository (0eb327e) - TableErrorFormatter: Link path in JetBrain IDEs (#4369), thanks @vrana!
- Improve ConstantArrayType inference (#4376), thanks @staabm!
- use string instead of
__stringandstringablein printf parameter error message (#4377), thanks @schlndh! - Inherit PHPDoc return type in child method with narrower native return type (#4384), #12481, #11364, #10600, #13588
- Rely on RuleLevelHelper in InvalidKeyInArrayItemRule (#4379), thanks @VincentLanglet!
Bugfixes 🐛
- False positive "
non-empty-array<int, int>might not be a list" when change existing list key (#4351), #13035, thanks @staabm! - Remove duplicate method in error message (#4371), #12557, thanks @VincentLanglet!
- Fix "Offset (int|string) might not exist on array" after
array_keys($arr)(#4381), #12926, thanks @staabm! - Fix "offset might not exist" false-positives when offset is a expression (#4372), #9494, #12115, #12805, #12931, #13214, #13039, #13538, thanks @staabm!
- Skip deep expression when root expression changes while scope generalization (#4390), thanks @staabm!
- When assigning nested array offset, union the value with empty array if the offset might be nonexistent (phpstan/phpstan-src@23dc4e7), #12078, #10640, #10025, #6173
- Fix
ArrayType::hasOffsetValueType(#4387), thanks @VincentLanglet! - Fix regression about appending
[]to existing offsets (phpstan/phpstan-src@f880231), #10438
Function signature fixes 🤖
- add bcround function signature for PHP 8.4 (#4367), #13364, thanks @themasch!
- Remove stream_get_meta_data from delta file (#4360), thanks @miken32!
- Add
stream_socket_{client,server}stubs for@param-out(#4391), #12622, #13605, thanks @msbit!
Internals 🔍
- Simplify ClassReflectionExtensions (#4374), thanks @staabm!
- Simplify *StatementWithoutImpurePointsRule (#4375), thanks @staabm!
- Cleanup
instanceof Typechecks (#4380), thanks @staabm! - Replace instanceof checks in JsonThrowOnErrorDynamicReturnTypeExtension (#4155), thanks @Khartir!
- Added regression test (#4382), #12115, thanks @staabm!
- Get rid of
instanceof ErrorType(phpstan/phpstan-src@3adc625) - Improve CombinationHelper PHPDoc (#4386), thanks @VincentLanglet!
1.12.32
Alternative solution to disable cloning with --prefer-source that does not need another repository
2.1.29
Improvements 🔧
- Custom Composer source for cloning
phpstan/phpstan - Add optional strict check for printf parameter types (#4349), #13496, thanks @schlndh!
- Set parameter
checkStrictPrintfPlaceholderTypes: trueto turn this on
- Set parameter
Bugfixes 🐛
- After
trim($s) !== ''the$scan still bemixed(phpstan/phpstan-src@88b7f50), #13552 - Fix false positive about never written property when assigned in foreach key or value (phpstan/phpstan-src@4b4836a), #9213
- Improve function signatures with functionMap only for built-in symbols (phpstan/phpstan-src@326c6ec), #13556, #12151, #11303, #9486
- [PHP 8.5] Fix warning: "unexpected NAN value was coerced to string" (#4368), thanks @staabm!
Function signature fixes 🤖
Internals 🔍
- Add non regression test for issue #9386 (#4348), thanks @VincentLanglet!
- Faster code downgrade to speed up CI (#4352), thanks @staabm!
- Refactor TooWideTypeCheck - report errors based on narrowed original type (phpstan/phpstan-src@5468ddd)
- Use TooWideTypeCheck in TooWideParameterOutTypeCheck (phpstan/phpstan-src@0e695a4)
- TooWideTypeCheck - do not report PHPDocs that are not subtype of native type (phpstan/phpstan-src@2ecc069)
- TooWidePropertyTypeRule - property without native type and with default value is not implicitly nullable (phpstan/phpstan-src@6115511)
- Simplify many processAssignVar with new processVirtualAssign method (phpstan/phpstan-src@4d119ba), #9213
- Added comment (#4358), thanks @staabm!
- Switch to ramsey/composer-install action (#4365)
1.12.31
Custom Composer source for cloning phpstan/phpstan. Learn more: https://github.com/phpstan/phpstan-phar-composer-source
This hotfix release fixes PHPStan version number in CLI output.
1.12.30
Custom Composer source for cloning phpstan/phpstan. Learn more: https://github.com/phpstan/phpstan-phar-composer-source
2.1.28
Improvements 🔧
- [PHP 8.5] Add support for
#[\NoDiscard](#4253), thanks @DanielEScherzer! - Narrow
l/r/trim()arg on comparison to''(#4340), thanks @staabm!
Bugfixes 🐛
- AssertRuleHelper - InitializerExprTypeResolver does not have support for resolving method call types, use Scope instead (phpstan/phpstan-src@3559a4a)
- Iterate over methods from other extension even when native PHP method exists (but cannot be called from the current scope) (phpstan/phpstan-src@79dfb6a), #13540
- Fix PHP 8.3 polyfill (phpstan/phpstan-src@17c4fe5), #13545
- Narrow offset after
isset()on list (#4345), #12933, thanks @staabm! - PHPDoc tag
@propertyshould only be taken into account for protected properties and outside access when the declaring class allows dynamic properties (phpstan/phpstan-src@5772b1a), #13537
Internals 🔍
- Tests - always initialize the container (phpstan/phpstan-src@398622a), #13494
- Fix tests that should but do not extend PHPStanTestCase (phpstan/phpstan-src@88d185c)
- Fix DeprecationProviderTest for PHP < 8.0 (phpstan/phpstan-src@c0318bc)
- Init container before DataProvider is called (#4342) (#4342), thanks @staabm!
- Init container also for tests without dataprovider (#4346), thanks @staabm!
2.1.27
Bugfixes 🐛
- Fix internal error with
checkDynamicProperties: true(phpstan/phpstan-src@c657260), #13529 - Private property with
@property-readis still writable inside the class (phpstan/phpstan-src@0d1fef1), #13530 - PhpPropertyReflection can have different readable/writable type when amended by
@property(phpstan/phpstan-src@439efe7) - Allow overriding PHPDoc type of a protected property in a subclass (phpstan/phpstan-src@1064566)
- Allow to override property union type with
@propertytag subtype (phpstan/phpstan-src@0814669)
Function signature fixes 🤖
- Add missing
idateidentifiers (#4338), thanks @SplotyCode!
Internals 🔍
- PhpClassReflectionExtension no longer implements extension interfaces (phpstan/phpstan-src@b69bb4a)
- Restore original ReflectionProvider and PhpVersion into their static accessors dutifully (#4339)
- PhpPropertyReflection - accept Type object as native type instead of AST node (phpstan/phpstan-src@c5d17f8)