2.1.23
Whopping 88 issues were solved in this release! @VincentLanglet and @staabm are the true GOATs here.
Bleeding edge 🔪
- Improve comparison against
BcMath\Number(#3995), #13001, thanks @schlndh! - Check printf parameter types (#3977), thanks @schlndh!
- Report
booltype as too-wide when onlytrueorfalseis assigned (#4243), #13384, thanks @staabm!
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 🔧
- dynamicConstantNames - allow specifying constant type (#3583), thanks @ssigwart!
- Learn more: https://phpstan.org/config-reference#constants
- Add ConstFetchNode support in array shape key (#4289), #5773, #6989, thanks @VincentLanglet!
- This syntax is now supported:
array{Foo::BAR: int}
- This syntax is now supported:
- Add
*ParameterClosureThisextensions (#4273), thanks @calebdw! - Introduce
checkTooWideParameterOutInProtectedAndPublicMethods(#4229), #12080, thanks @VincentLanglet! - Place UniversalObjectCratesClassReflectionExtension last (#4207), #13342, thanks @calebdw!
- [PHP 8.5] Fix deprecation warnings with
ReflectionProperty::setAccessible()(#4230), thanks @staabm! - [PHP 8.5] Fix deprecation (phpstan/phpstan-src@d36a97f)
- [PHP 8.5] Fix deprecation (phpstan/phpstan-src@103d193)
- Update nikic/php-parser to 5.6.1 (phpstan/phpstan-src@f5aae9c)
- Resolve
array~listasnon-empty-array(#4225), #9734, thanks @VincentLanglet! - Add support for template bound null type (#4267), #13048, #12894, #12989, thanks @SplotyCode!
- Fix performance problem in AnnotationsPropertiesClassReflectionExtension (#4268), #13425, thanks @staabm!
- [PHP 8.5] Increment on non-numeric string is deprecated, use
str_increment()instead (#4262), thanks @staabm! - [PHP 8.5] Fix "Using null as an array offset is deprecated, use an empty string instead" (#4301), thanks @staabm!
- [PHP 8.5] another deprecation (phpstan/phpstan-src@44deb6b)
- MatchExpressionRule - ignore
reportAlwaysTrueInLastConditionwith enums (#4286), thanks @vrana! - Respect rule level in InvalidKeyInArrayDimFetchRule (#4166), thanks @VincentLanglet!
- Improve
TypeCombinator::unionWithSubtractedType(#4200), thanks @VincentLanglet! - Update
curl_getinfo()return types (#4279), thanks @FeBe95! - Detect more possibly-nonexistent offset types (#4164), #1061, thanks @VincentLanglet!
- Allow
ReflectionClass<covariant X>even on PHP 8.3- (phpstan/phpstan-src@9435151), #13452 - Report always true/false comparison against
nullonly for native properties without native type (phpstan/phpstan-src@802fa6e), #11609 - Report accessing private properties on non-final classes in
??condition (phpstan/phpstan-src@9e24fa2), #12645 - ConsistentConstructorDeclarationRule (phpstan/phpstan-src@66af941)
- Check
new static()arguments when paired with@phpstan-consistent-constructor(phpstan/phpstan-src@4274cfb)
Bugfixes 🐛
- Resolve
statictype in method@throws(#4128), #11900, thanks @VincentLanglet! - Fix wrong inference on preg_match != false (#4223), #11708, #11908, thanks @VincentLanglet!
- ObjectShapeType - do not access
Type::getProperty()before making sureType::hasProperty()is yes (phpstan/phpstan-src@3beb667), #13424 - Fix plus operator with constant arrays (#4266), #11912, thanks @SplotyCode!
- Fix false positive about assign to protected property from a subclass (phpstan/phpstan-src@6bf3ce7), #13123
- Prevent infinite recursion when describing template type with default value (phpstan/phpstan-src@c5d7128), #13163
- Fix FilterFunctionReturnTypeHelper for
FILTER_*constants redeclared with wrong type (#4199), #10483, #10661, thanks @VincentLanglet! - Fix for unmatched ignored trait error being reported with partial analysis (phpstan/phpstan-src@cd6b3fd)
- Fix Promoted vs. regular property inconsistency with generics (#4157), #13049, thanks @sayuprc!
- Note already loaded
vendor/hoa/protocol/Wrapper.phpin__composer_autoload_files(#4275), #13369 - Make DOMNamedNodeMap generic (#4211), #13365, thanks @stefanfisk!
- Fix hasOffsetValueType with object (#4272), thanks @VincentLanglet!
- Handle default parameter value in
@phpstan-assert(#4226), #9435, thanks @VincentLanglet! - Do not report non existent offset when it s an array creation (#4204), #12447, #7286, #3803, thanks @VincentLanglet!
- Escape tag in githubErrorFormatter (#4198), #10051, thanks @VincentLanglet!
- Fix hasOffsetValueType for arrays (#4277), #13455, thanks @VincentLanglet!
- Fix non-final object cast to array (#4167), #2730, thanks @VincentLanglet!
- Fix
ConstantFloatType::toString(#4278), #12225, thanks @VincentLanglet! - Fix array_map with accessory HasOffsetValueType (phpstan/phpstan-src@e8b3111), #13395
- Improve implode signature (#4159), #5760, #12079, thanks @VincentLanglet!
- Check magic methods on final classes for allow dynamic properties (#4285), #13450, thanks @calebdw!
- Stop PHPDoc arrays with specified key type being converted to iterables when the native type is iterable (phpstan/phpstan-src@b042caa), #13411
- Faster
ArrayType::hasOffsetValueType()(#4288), #13455, thanks @staabm! - Fix false positive of function.alreadyNarrowedType (function call variable assignment) (#4237), #13268, #12087, #9666, #9445, #7773 thanks @staabm!
- Improve ReplaceFunctionsDynamicReturnTypeExtension (#4023), #9870, thanks @VincentLanglet!
- Fix count inferences (#4149), #13111, thanks @VincentLanglet!
- Fix ImpossibleInstanceOfRule (#4154), #10036, thanks @VincentLanglet!
- Fix
array_columninference (#4201), #10367, thanks @VincentLanglet! non-empty-arraymight be empty afterarray_keys()with filter (#4295), #13377, thanks @staabm!- Allow possibly undefined property on left side of
??(phpstan/phpstan-src@a06db02), #11424, #10379 - Fix incorrect analyzing of array_shift with non-empty-list property (#4294), #13438, #2888, #3387, #2560, #2457, #11846, thanks @staabm!
- Implemented NativeTypeExpr (#4302), #10595, #11322, thanks @staabm!
- Fix bug with nested methods in anonymous classes in methods (phpstan/phpstan-src@c985b85)
- Fix call to ParserNodeTypeToPHPStanType in FunctionDefinitionCheck (phpstan/phpstan-src@71f22e7)
- ClosureTypeFactory - fix
staticreturn type resolution in closure (phpstan/phpstan-src@6b9644e, phpstan/phpstan-src@af3f105), #13298 - Fix while loop inside another loop during scope stabilization phase (phpstan/phpstan-src@94b6012), #13385
- PHPDoc tag
@phpstan-consistent-constructorno longer requires constructor to exist (phpstan/phpstan-src@b7e305f), #11316 - Fix ConsistentConstructorRule (phpstan/phpstan-src@b6ad10a)
- Fix NewStaticRule when there's
@phpstan-consistent-constructorbut constructor implementation is in a parent (phpstan/phpstan-src@be3c27a), #10722
Function signature fixes 🤖
- Remove some Ds stubs from functionMap (#4218), thanks @VincentLanglet!
- Remove som AMQP stubs for functionMap (#4217), thanks @VincentLanglet!
- Remove some solr definition in functionMap (#4219), thanks @VincentLanglet!
- Remove more solr definition (#4221), thanks @VincentLanglet!
- Remove useless reflection stubs (#4232), thanks @VincentLanglet!
- Remove methods similar to phpstorm stubs (#4231), thanks @VincentLanglet!
- Fix PDOStatement getIterator return type (#3974), #8886, thanks @mbolli!
- Fix
RedisCluster::scansignature (#4195), thanks @DKhalil! - Improve debug_backtrace args type (phpstan/phpstan-src@864e4f6)
- Better
Exception::getTrace()return type (#4264), thanks @keradus! - Declare assert-if-true for filesystem functions (#4234), #6788, thanks @staabm!
- Fix session_set_cookie_params signature (#4194), #7772, thanks @VincentLanglet!
- Fix
SimpleXMLElement::offsetSet(#4196), thanks @VincentLanglet! - Remove ownerDocument stub (#4197), thanks @VincentLanglet!
- Fix
RedisCluster::multi()return type (#4283), #13392, thanks @sayuprc! - Update
xml_*_handlersignature (#4254), #9970, thanks @VincentLanglet!
Internals 🔍
- Move isOffsetAccessLegal to MaybeOffsetAccessibleTypeTrait (#4205), thanks @VincentLanglet!
- Add phpdoc for generators in unit tests (#4212), thanks @Flyingmana!
- Added regression test (#4216), #13310, thanks @staabm!
- Get rid of couple
instanceof *Typechecks in TypeCombinator (#4244), thanks @canvural! - Remove unused
shouldGeneralizeInferredTypemethod from template type classes (#4269), thanks @SplotyCode! - Extract TooWideReturnTypeCheck (#4260), thanks @staabm!
- Add non regression test (#4176), #3761, thanks @VincentLanglet!
- Regression test (#4182), #4993, thanks @VincentLanglet!
- Simplify tests in which treatPhpDocTypesAsCertain is always true (#4274), thanks @staabm!
- Remove obsolete note (phpstan/phpstan-src@6238750)
- Add PHPDoc types for iterators in unit tests (#4276), thanks @Flyingmana!
- Simplify ParametersAcceptorSelector (#4160), thanks @staabm!
- Added regression test (#4241), #10312, thanks @staabm!
- Add
PhpFunctionFromParserNodeReflection::isMethodOrPropertyHook()(phpstan/phpstan-src@2c53ed6), #13393 - Regression tests (phpstan/phpstan-src@dcda566), #7824, #10819
- Regression test (phpstan/phpstan-src@3380dc5), #9204
- Use phpstan/build-cs (phpstan/phpstan-src@ecfd995)
- Regression test (phpstan/phpstan-src@7870d2d), #13135
- Add non regression test(#4175), #3616, thanks @VincentLanglet!
- Add non regression test (#4181), #4809, thanks @VincentLanglet!
- Add non regression test (#4183), #5206, thanks @VincentLanglet!
- Add non regression test (#4189), #13267, thanks @VincentLanglet!
- Add non regression tests (#4280), #11761, thanks @VincentLanglet!
- Regression test (phpstan/phpstan-src@0e706b3), #4532
- Regression test (phpstan/phpstan-src@305e592), #10492
- Regression test (phpstan/phpstan-src@bfa860e), #8668
- Added regression test (#4300), #12273, thanks @staabm!
- Added regression test (#4306), thanks @staabm!
- Added regression test (#4308), #7225, thanks @staabm!
- Added regression test (#4310), #13469, thanks @staabm!
- If condition analysis improvement (phpstan/phpstan-src@e4eae3b)
- isFinal can be asked outside of
$constructor instanceof PhpMethodReflection(phpstan/phpstan-src@85fd1a4)