Releases: lkrms/pretty-php
v0.4.30
Changed
- Update dependencies and packaging
Fixed
- An upstream issue where "-" could not be given as the only argument has been fixed
v0.4.29
Changed
-
Convert shell-style comments (
#
) to C++-style comments (//
) -
Add a space between
//
and subsequent text -
Remove leading and trailing empty lines from PHP docblocks
-
Preserve indentation when normalising PHP docblocks
-
Improve heuristics so C-style comments (
/* ... */
) are normalised like PHP docblocks more consistently -
Don't reindent multiline comments beside code if they have text in column 1, e.g.
<?php foo(); /* this comment starts after column 1 but has text in column 1 */
v0.4.28
Changed
-
Revert change to logical operator placement in v0.4.27
This change was intended to improve the readability of PSR-12-compliant control structure expressions, but output was inconsistent and there were unforeseen side-effects, so v0.4.26 behaviour has been restored. Apologies for the disruption!
-
In strict PSR-12 mode, move comments beside the closing brace of classes, interfaces, etc. to the next line
-
Move multi-line docblocks beside code to their own line
-
When adding blank lines before statements, respect continuation of earlier comments
-
Remove blank lines between subsequent one-line
declare
statements -
For vertical spacing purposes, treat consecutive property declarations as the same declaration type, regardless of syntax (e.g. when
var
is mixed withprivate
)
Fixed
-
Fix issue where blank lines are added after
<?php
when there are two or more subsequent declarations of the same type -
If subsequent declaration types are different, propagate spacing from earlier siblings of the same type to avoid output like the following (there should be a blank line between
class B
andclass C
):<?php class A { public function a() {} } class B {} class C {}
-
Add blank lines before comments that trigger vertical expansion of declarations, preventing output like:
<?php class A { public $foo; public $bar; // There should be a blank line above this public $baz; public $qux; }
v0.4.27
Added
- Add
StrictExpressions
rule for PSR-12-compliant handling of multi-line control structure expressions
Changed
- Move logical operators to the start of the line in contexts where hanging indentation will not be applied
Fixed
- Improve
PreserveLineBreaks
heuristics to fix an issue where leading operators remain at the end of a line when followed by!
on the next line
v0.4.26
Fixed
- Fix issue where backslashes in heredocs are escaped unnecessarily
- Fix additional escaping issues, e.g. in strings like
"\\\{$a}"
v0.4.25
Changed
- Normalise constant parts of all strings--including heredocs and between backtick operators--not just single- and double-quoted constant strings
- Remove unnecessary backslash escapes
- Escape
"\x1b"
as"\e"
Fixed
- Fix regression in v0.4.24 where unnecessary backslashes are added in some contexts (sorry!)
v0.4.24
Changed
- Unescape leading tabs in strings when using tabs for indentation
- Remove
T_BAD_CHARACTER
tokens
v0.4.23
Changed
- Improve performance by removing unnecessary type checking
v0.4.22
Changed
-
Adjust preservation of line breaks and blank lines
- Don't preserve newlines after close braces that aren't structural (where "structural" essentially means "may enclose statements")
- Collapse blank lines between list items and in other expression contexts (e.g.
for
loop expressions), including before comments - If one expression in a
for
loop is at the start of a line, add a newline before the others
-
Don't sort
use <trait>
statementsChanging the order of traits inserted into a class changes the order its members are reported, so behaviour removed in v0.4.15 has been restored
-
When sorting imports, don't treat one-line comments as continuations if there is a change of type
-
If chained method calls would render as below, move the first call in the chain to the next line:
// Before $foxtrot->foo( // ) ->baz(); // After $foxtrot ->foo( // ) ->baz();
v0.4.21
Changed
- Change default sort order of alias/import statements to depth-first
- To restore the previous behaviour, use
--sort-imports-by name
or set "Sort Imports By" to "name"
- To restore the previous behaviour, use
- When sorting by name, don't place grouped alias/import statements below ungrouped imports
- Collapse space after
;
infor
loops if the next expression is empty - Preserve newlines before and after attributes
- Add a newline before every parameter, not just annotated parameters, when splitting parameter lists to accommodate attributes
Fixed
- Fix issue where blocks that start with an empty statement (e.g.
function () { ; // ...
) are not indented correctly - Fix issue where anonymous class declarations are not always recognised
- Fix issue where newlines are added after inline comments between control structure tokens, leading to unnecessary indentation
- Fix issue where arrow function alignment fails in strict PSR-12 mode
- Fix
align-lists
issue where list items appearing consecutively on the same line are not always aligned correctly