Skip to content

Releases: phpstan/phpstan

0.3

27 Nov 19:17
Compare
Choose a tag to compare
0.3

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

0.2.2

22 Nov 20:32
Compare
Choose a tag to compare
  • Fixed name resolving when skipping some syntax-unsuitable names like New

0.2.1

22 Nov 07:30
Compare
Choose a tag to compare
  • Fixed checking implode() call with just one parameter $pieces
  • Fixed a crashing issue when a different version of a class from the autoloaded one is analyzed

0.2

20 Nov 15:40
Compare
Choose a tag to compare
0.2

Major new features:

  • Check types of values assigned to properties
  • Checking return types from class methods and anonymous functions
  • Check types of values appended to arrays
  • Check property access and method calls on non-objects
  • Support /** @var $foo \Type */, /** @var \Type $foo */ and /* @var ... */ preceding a variable assign
  • Support for bootstrap file (0f16708)
  • Rules are now registered via a tag so users can register their own rules (#13 - thanks @pepakriz!)
  • ArrayType knows its item type; used in foreach and dimfetches
  • Support for getting types from static calls and fetching static properties
  • Support for void type
  • Improved \Closure::bind support - it correctly checks code inside the closure

BC breaks:

  • Config option polluteScopeWithForLoopInitialAssignments renamed to polluteScopeWithLoopInitialAssignments and also applies to while-loop
  • Method parameters with typehints in both phpDocs and native PHP can now resolve to a different type (973cc8f, 93e868d, f649596)

BC breaks for authors of extensions:

  • Introducing ParameterReflection::isPassedByReference() (424eb9d)
  • Removed Scope::isInClosureBind(), type of $this is correctly resolved even inside the closure; access to private properties is also not reported when the scope is set to the correct class

Enhancements:

  • Alias analyse command to analyze (#8 - thanks @Mikulas)
  • All parameters passed by reference can create a new variable in outer scope, not just a few listed ones (05498a5)
  • Variables assigned in elseifs are available in subsequent elseifs and in else
  • Concatenated strings are always StringType
  • Handle negated instanceofs in more complex conditions
  • stdClass and SimpleXMLElement are universal object crates by default
  • Support for instanceof in cases of switch(true)
  • Checking array type of properties and method typehints
  • Performance optimization: ClassReflection - stop on first accessible property from current scope (2e64fbb)
  • Performance optimization: FileTypeMapper - additional in-memory cache to prevent frequent disk access (433804f)
  • Type of spaceship <=> operator is detected as an integer

Bugfixes:

  • Support for assigning variable with =&
  • Typehints are case-insensitive (so that NULL means the same thing as null)
  • Reinforce resolving type names from phpDocs so that internal errors do not occur
  • Fixed checking access to static properties with dynamic name
  • Do not throw an exception when unsetting undefined variable
  • Do not show progress bar in case of early errors
  • Fixed name-resolving bug when an annotation contains "new" keyword
  • Universal object crates - real properties are preferred
  • Detect variadic parameters correctly as arrays
  • Fixing PHP bug #71416

Initial release

17 Jul 20:10
Compare
Choose a tag to compare

Hello world!