Name | Modified | Size | Downloads / Week |
---|---|---|---|
Parent folder | |||
phpstan.phar | 2025-07-17 | 25.1 MB | |
phpstan.phar.asc | 2025-07-17 | 833 Bytes | |
2.1.18 source code.tar.gz | 2025-07-17 | 3.8 MB | |
2.1.18 source code.zip | 2025-07-17 | 3.8 MB | |
README.md | 2025-07-17 | 10.6 kB | |
Totals: 5 Items | 32.8 MB | 0 |
Bleeding edge 🔪
- Name string expr check in ClassConstantRule (#3910), thanks @zonuexe!
- Name string expr check in AccessPropertiesCheck (#4094), thanks @zonuexe!
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 🔧
- Add
@phpstan-sealed
support (#4095), thanks @VincentLanglet! - This release includes improvements and bugfixes from PHPStan 1.12.28
- Validate registered services tags against implemented interface (https://github.com/phpstan/phpstan-src/commit/f375a814c453ee4220322e238d5d1ace59810f45)
- Only change exit code with
--fail-without-result-cache
when the error formatter returns 0 (https://github.com/phpstan/phpstan-src/commit/df9fa6e04b636bbcd16d49ec213f13fbb45026a6) - Normalize arguments before calling into TypeSpecifyingExtensions (#4034), [#13088], thanks @staabm!
- Use
count()
return type inObjectType::getArraySize()
(#4072, #4078), thanks @vojtech-dobes! - Add method to get ObjectType from ClassReflection and EnumCaseReflection (#4099), thanks @calebdw!
- Playground & Issue bot: PhpdocCommentRule (#4074), thanks @staabm!
- Describe array shape key in quotes unless valid identifier (#4071), thanks @vojtech-dobes!
- Improve TrimDynamicReturnType for constant strings (#4028), thanks @VincentLanglet!
- Introduce ArrayPadDynamicReturnTypeExtension (#4017), [#12305], thanks @VincentLanglet!
- Introduce
PDO::connect
dynamic method return type extension (#4015), [#12359], thanks @VincentLanglet! - Add
PhpVersion::__construct
to BC promise (#4022), [#8582], thanks @VincentLanglet! - Support
switch
on::class
(#4011), [#13069], thanks @VincentLanglet! - More precise
array_keys
return type (#3590), [#11928], thanks @staabm!
Bugfixes 🐛
- Fix
ClosureType::equals()
for pure/impure closures (https://github.com/phpstan/phpstan-src/commit/02066c7350e4a60a5cdcabacc613bd62ae0bf907), [#13067] - Fix for benevolent union (#4039), [#13098], thanks @VincentLanglet!
- Fix resolving generics from phpstorm-stubs (https://github.com/phpstan/phpstan-src/commit/c0f2e9e9235db973784d88b107bc8c14ecb647d0), [#13171]
- Correctly retrieve hasSideEffects metadata for inherited methods (#4079), [#13201], thanks @zonuexe!
- ObjectType: fix hasConstant behaviour (#4089), thanks @janedbal!
- Explicitly use StreamSelectLoop for PHPStan Pro download (#4077), thanks @calebdw!
- stream_get_contents() does not return FALSE unless an invalid position is provided (#4092), [#3396], thanks @staabm!
- Revert "non-falsy-string cannot be converted to 0" (#3997), thanks @VincentLanglet!
- Improve return type of array map by invoking dynamic function return type extensions for the callback (#4068), [#11180], [#3156], thanks @VincentLanglet!
- Avoid false positive
in_array()
always true (#4073), [#13151], [#8818], [#12755], [#12412], thanks @VincentLanglet! - Fix always-true detection in in_array with union type haystack (#3888), [#12755], thanks @sayuprc!
- Fix NAN inferences (#4040), [#13097], thanks @VincentLanglet!
- Fix
MixedType->equals(ErrorType)
(#3934), thanks @staabm! - Handle class without namespace for internal rule (#3998), [#13041], thanks @VincentLanglet!
- Resolve substr based on configured PHP version instead of runtime PHP version (#4061), [#13129], thanks @VincentLanglet!
- Keep list on
unset()
with nested dim fetch (#3964), [#12927], [#12330], [#11171], [#8282], [#12754], thanks @staabm!
Function signature fixes 🤖
- These DateTimeInterface methods are pure (https://github.com/phpstan/phpstan-src/commit/7534ee1a3755ac6c1a9f563159dbc9a0756993f5)
- More precise return type for
posix_getpwnam()
(#4091), [#12254], thanks @zonuexe! - Fix
SimpleXMLElement::xpath
return type (#4096), thanks @VincentLanglet! - Fix fwrite (#4087), thanks @VincentLanglet!
- Update
locale_get_display_x()
return types (#4085), thanks @cfahner! - Fix
DOMElement::$attributes
stub (#4029), [#13076], thanks @VincentLanglet! - Improve mb detect encoding signature (#4020), [#8922], thanks @VincentLanglet!
Internals 🔍
- Moved the list of relative paths in parameters to
parametersSchema.neon
(https://github.com/phpstan/phpstan-src/commit/72c2a8da27960198a00c40075649d71a6a4fdebb) - This now allows extensions to declare which of their custom parameters should be treated as relative path to expand
- Scaffolding for auto-fixable rules
- This feature will be fully released in PHPStan 2.2.0
- phpstan-src embraces attributes!
- This is enabled thanks to olvlvl/composer-attribute-collector and AutowiredAttributeServicesExtension
- PHPStan still supports PHP 7.4 because this package bakes compiled list of classes and parameters with attributes to a plain PHP file
vendor/attributes.php
. - Slimmer config files
- Services are now registered with the help of these attributes:
- Rules and collectors for specific levels are registered with:
- phpstan-src now includes more custom opinionated rules specific to development of PHPStan itself
- Attributes must have named arguments (https://github.com/phpstan/phpstan-src/commit/676ad27fc14abf18ebd026c0247b61ad9d568d92)
- Use named arguments instead of passing default parameter values https://github.com/phpstan/phpstan-src/commit/35fbc87a4b05a2f4884480a3e0f5dbd61a8b49a5
- As a limitation of simple-downgrader, this does not apply to MethodCall. Only to New_, StaticCall, and FuncCall.
- Add
#[Override]
for methods overriding 3rd party (https://github.com/phpstan/phpstan-src/commit/98ed73222bb3a69e58f5633074041a65256673b6) - SkipTestsWithRequiresPhpAttributeRule (https://github.com/phpstan/phpstan-src/pull/4056/commits/6851343e570bc1e79580972243deed80b3bc5e39)
- Simplify property memoization for Flyweight pattern by replacing it with
??=
(#4084), thanks @zonuexe! - Simplify by replacing chained
$var === const
within_array()
(#4098), thanks @zonuexe! - DI Container - throw unprefixed exception (https://github.com/phpstan/phpstan-src/commit/24436631a3c69deb8d914dc01cb6486cc85d5680)
- Require Box with Composer (#2955)
- Use 7.4 for PHP-Scoper PHP version (#2955), thanks @ondrejmirtes!
- Update to PHPUnit 10 ((#4046))
- Update to PHPUnit 11 (#4057)
- Upgrade bashunit:0.20 (#4048), thanks @Chemaclass!
- Add
assertSuperType
testing utility (#4066), thanks @vojtech-dobes! - Use str_starts_with() instead of strpos() (#4083), thanks @zonuexe!
- Avoid duplicating the same strpos() function call (#4083), thanks @zonuexe!
- Add
Type::spliceArray()
, improvesplice_array()
array type narrowing (#3952), thanks @herndlm!