Skip to content

Released version 1.3.4

Choose a tag to compare

@dg dg released this 09 Nov 13:15
· 60 commits to master since this release

✨ New Features

  • A check too long for one screen now ends with what to read first: the few decisions most of its violations break, with their counts, and how many of them dresscode fix repairs
  • file.invalidUtf8 – reports a byte that is no part of a UTF-8 character, as a file saved in another encoding has. Only reported, since the original encoding cannot be told from the bytes. forbidden in every standard
  • multiline.items.coalesce and multiline.items.pipe – a line of ?? or |> too wide spreads its operands as it does for the other operators, [perLine, fill] in every standard. nette leaves ?? out of the width, so ?? throw new … stays on the line of the value it guards
  • expressions.comparison.loose now fixes an integer compared with a float number and the other way round, writing the number in the type of the other operand: round($x) == 0 becomes round($x) === 0.0. Needs typeAnalysis: phpstan
  • upgrading.syntax.promotedProperties promotes a property with a doc comment too, moving the comment above the parameter, so a constructor no longer comes out half promoted
  • upgrading.functions.arrayFirstLast turns $posts ? reset($posts) : null into plain array_first($posts) and $x = explode(…); $x = end($x); into one $x = array_last(explode(…));. Its fix is risky only where the internal pointer or an empty array can really matter
  • comments.firstColumn: optional keeps a line commented out in the first column of an indented block where it stands. Under the default forbidden such a comment takes the indentation of the line below, now without doubling the indentation left after //

🐛 Bug Fixes

  • Upgrading follows the lowest version composer.json allows: what a later version of PHP or of a package deprecated is neither rewritten nor reported while the code must still run on the older one, where the replacement may be missing. Likewise @deprecated counts only in a package installed at its lowest allowed version
  • PHP templates keep their shape: braces.alternativeSyntax leaves <?php if ($a): ?> … <?php endif ?> around markup as it is, and braces.bracelessBody gives <?php foreach ($items as $v) echo $v; ?> its braces on that line instead of spreading the body through the markup
  • mistakes.invisibleCharacter leaves the no-break space U+00A0 in strings and comments, where typography puts it on purpose; in a name it is still reported
  • A key of dresscode.neon whose whole content is commented out loads as if it were not there
  • upgrading.api.replacedClasses and upgrading.declarations.deprecatedClass rewrite Old::class only as a risky fix where it is data (an operand of ===, a match arm, a needle of in_array(), an array key), as the new name changes what such code compares
  • With typeAnalysis: phpstan, a project whose bootstrapFiles load its own autoload with an older phpstan/phpdoc-parser runs without errors
  • upgrading.syntax.spreadForArrayMerge keeps the items of a merged array on the lines they stood on
  • A line too wide spreads more tidily around a ternary, around a call assigned before or, and or xor, and in the head of a foreach, whose iterated array spreads before what follows as

🛡️ Robustness

  • When an extension stops PHPStan from starting, the warning names its package and version and suggests updating it
  • On Windows, OPcache is off for the whole run, so a single process with JIT (--jobs 1) runs stable too
  • types.declaration.property reports every property of a grouped declaration, public $a, $b;
  • upgrading.php.nullArrayKey and upgrading.php.floatArrayKey no longer take the key of a loop over an empty array for null or a float
  • file.strictTypes.position no longer doubles the blank lines around a declaration it moves up to the opening tag, and multiline.semicolon accepts a semicolon below links of a chain commented out