0.8
PHPStan is on Patreon! You can show your support by backing PHPStan on Patreon. Choose your reward from different tiers and be a part of PHPStan's sustainable future development. I will deeply appreciate it. Thanks!
PHPStan now has an on-line playground over at phpstan.org! Thanks to @JanTvrdik, you can try out the static analyser right in your browser!
Major new features:
- Parsing read-only/write-only properties with
@property-read
/@property-write
annotations. #285 (thanks @stekycz!) - Checking writing to read-only properties and reading from write-only properties (level 0 for accesses on
$this
and level 2 for the rest). This is useful in combo with@property-read|write
annotations and with custom class reflection extensions. - Reading and checking correctness of passed parameters to methods from
@method
annotations including variadic methods. #285 (thanks @stekycz!) - Check for duplicate keys in literal arrays (level 0)
- Checks for invalid key types in literal arrays, in
list()
and short array destructuring syntax, in writing to and reading from arrays (level 3) - Handle fatal errors when autoloading unknown classes/interfaces/traits #255 (thanks @Majkl578) This lowers the risk of a fatal error during analysis because of an unknown class.
Enhancements:
- For level 7 (checking possible nullables), PHPStan now considers check for truthy value as a confirmation of not-null value (
if ($possibleNullable)
) #278 #296 #291 - Added Checkstyle error formatter #271
- Getting annotation methods and properties also from interfaces #292
- Static calls on arbitrary expressions (not just on class names) are checked on level 2 and higher
- Separate setting to check arguments passed by reference on level 5. Use
checkArgumentsPassedByReference: true
in your config file if you're on a lower level and want to check this. - Read methods and properties from annotations also from traits
- Checking that constructors do not return anything (returned value is silently thrown away)
- Checking accessing properties on possible null values (level 7)
- Types assigned to properties are checked also for assign operations like
.=
- Simpler and faster caching without dependency on
nette/caching
#396 (thanks @kukulich!) - Parsing type of variable from
@var
annotation with type only #395 (thanks @stekycz!) TypeCombinator::combine
accepts multiple types as variadic argument
BC breaks:
- Removed support for PHP-Parser 2.x. #293 Use
phpstan/phpstan-shim
in case of conflicting dependencies. - Moved properties-related rules to
PHPStan\Rules\Properties
namespace. Rename the rules in case you're using completely custom ruleset (no predefined level). - Added isReadable/isWritable on PropertyReflection
Bugfixes:
- Fixed mysqli::query parameters count #280
- Fixed argument count for DateTimeZone::getTransitions() #297
- DateInterval has microseconds since PHP 7.1 #311
- Fixed looking for inheritDoc when the phpDoc is in an interface
- Fixed \Locale::getDisplayLanguage() and locale_get_display_language() 2nd parameter optionality #312
- Added first parameter to DOMDocument::saveHTML() #279
- Find dynamic return type extensions in case the scope class name case does not match the reality
- Fixed deleting non-existent memory limit file when the rule level is not passed as CLI option while it should
- Changed all use of "catched" to "caught" #341
- PHPStan does not crash on PHP 7.2 (full support coming soon)
- Type specifier: fixed handling of nested logical operators #338
- CallToCountOnlyWithArrayOrCountableRule: fixed union handling
- Add better description to "call on nullable" error #282
- Fixed internal error when analysing short array destructuring syntax from PHP 7.1 with missing item #368
- RequireParentConstructCallRule fix: supressed constructor calls are now detected correctly #312
- Fixed resolving variable and expression types from branches. This fixed a lot of issues in conditional code. #277 #299 #355
- Fixed overriding specified variable type in foreach and catch
- Fixed availability of variables in finally block defined in try and catch blocks with early termination
- Fixed undefined variables because of other assign operations #322
- Correct type for string with multiple parts in doublequotes #376
- Fixed imagewebp reflection - added 3rd optional parameter #389
- Fix "incorrect case" error when using trait aliases #391