Skip to content

0.16.4

Choose a tag to compare

@dereuromark dereuromark released this 17 Sep 14:04
· 262 commits to master since this release

Improvements

  • Allow new "iterable generics" syntax to be used, disabling some of the built-in checks in this case (until the next major).
  • Add SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly sniff for FQCN checks.
  • Add Spryker.Commenting.DocBlockConst sniff to make sure PHPStan uses the correct type for analysis.

All changes here are BC under correct standards and/or auto-fixable to allow a smooth upgrade.
It is recommended to run this first over a freshly branched master and fast-track this into master.
Then all other branches can have master merged. This way the changes will have minimal impact.
You can also always silence certain sniffs until the upgrade is ready.

Docblocks for class constants

Turns out PHPStan assumes a "mixed" kind of result for constants that are extended/extendable.
In this case, even if a constant is e.g. only declared and used as string, it kills all static analyzing in usage.
Adding docblocks to all class constants with the @var type defined makes it possible to detect issues here in code early on.
This release ships with reporting for all constants that are trivial and can be easily auto-fixed. It currently skips the non-trivial ones.
Those non-trivial ones (e.g. using another const) are not relevant, though, as the inheritance has those also already typed as defined.

Iterable generics

With this release we prepare for the next major which will enforce iterable generics (<>) that succeed the deprecated [] syntax.

  • You can now already use e.g. array<string, string> instead of string[] to also express that the key is an associative key of the array.
  • (int|string)[] now is array<int|string>
  • Nesting is also easier to document: string[][] is now array<array<string>> where possibly also the keys might be useful/recommended to document with the corresponding type - especially if associative.
  • Object collections can now be cleanly defined: \ArrayObject|\Generated\Shared\Transfer\PriceProductTransfer[] can be better documented as \ArrayObject<int, \Generated\Shared\Transfer\PriceProductTransfer>

Anything more complex can always go into the phpstan-* tags as before, same for shapes {}.