Skip to content

0.3

Compare
Choose a tag to compare
@ondrejmirtes ondrejmirtes released this 27 Nov 19:17

Major new features:

  • Rule levels. If you want to use PHPStan but your codebase isn't up to speed with strong typing and PHPStan's strict checks, you can choose from currently 5 levels (0 is the loosest and 4 is the strictest) by passing --level to analyse command. Default level is 0.
  • Custom rulesets. This builds on the idea of rule levels by enabling you to create your own rulesets without limiting yourself to predefined levels. Create your own ruleset by selecting which rules you want to check by copying the service definitions from the built-in config level files in conf directory to your PHPStan project config file. Don't forget to set the parameter customRulesetUsed in parameters section of your project config file.
  • Finding useless casts like (string) 'foo'.
  • Checking the types of operands of strict comparison operators - e. g. 'foo' === 5 will always evaluate to false.

BC breaks:

  • When using a custom project config file, you have to pass the --level option to analyse command (default value does not apply here - I need some way to identify whether a custom ruleset is used or not).
  • For strictest checks, you now have to pass --level 4 (currently highest level) to analyse command.

Enhancements:

  • Removed dependency on gettext
  • Support for Closure::call()
  • Specifying return types of several array functions which depend on argument types
  • CallableType accepts obects of type Closure
  • CallableType accepts an array that is possible a callable
  • Specifying types of expressions using is_* functions
  • Specifying types using expressions in assert()
  • Division and other binary operations with floats result in mixed if either operand is mixed

Bugfixes:

  • Futher reinforce resolving type names from phpDocs
  • Closure return type is nullable when the typehint is not present