Rebuilds PHP code from an abstract syntax tree.
BSD-3-CLAUSE License
apply
stying to arbitrary paths by passing file and directoryPublished by pmjones about 1 year ago
Force visibility on class members
Rename Property to ClassProperty
Style ClassMethod separately from Function
Published by pmjones about 1 year ago
Make heredoc and nowdoc expansive in args and arrays
Comments now track what kind of Node they are on
Published by pmjones about 1 year ago
Improve presentation of inline comments.
Rename Styler::functionBodyClipWhen() to functionBodyCondenseWhen().
Rename Styler::maybeNewline() to maybeDoubleNewline().
In Styler, replace clip+newline idiom with forceSingleNewline() method.
Published by pmjones about 1 year ago
Fixes a logic-breaking bug with inline docblock comments.
Previously, this source code ...
// set callbacks
$foo =
/** @param array<array-key, string> $bar */
function (array $bar) : string {
return baz($bar);
};
... would be presented as ...
// set callbacks$foo =
/** @param array<array-key, string> $bar */
function (array $bar) : string {
return baz($bar);
};
... thereby breaking the code. With this fix, it is presented as ...
// set callbacks
$foo =
/** @param array<array-key, string> $bar */
function (array $bar) : string {
return baz($bar);
};
... which corrects the logic-breaking bug, though the presentation leaves something to be desired.
Published by pmjones about 1 year ago
Inline comments, including end-of-line comments, are now presented with greater fidelity to the original code.
Other internal QA tooling changes and additions.
Published by pmjones about 1 year ago
Fix testing on Windows, with related Github workflow changes.
Add check
command, to see if any files need styling.
Published by pmjones about 1 year ago
Fix #4 (else if
now presented as elseif
)
Rename Styler::lastSeparatorChar()
to lastSeparator()
Add methods Styler::lastArgSeparator()
, lastArraySeparator()
, lastParamSeparator()
, lastMatchSeparator()
to allow for different last-item-separators on different constructs.
Updated docs & tests
Published by pmjones about 1 year ago
Add Styler::lastSeparatorChar() to specify comma (or no comma) on last item of split list.
Fix apply
command to honor the --force
option again.
Floats, integers, single-quoted strings, and non-interpolated double-quoted strings now display their original raw value, not a reconstructed value.
A file that starts with a return
now has the return on the same line as the opening <?php
tag.
Imports now get a blank line between use
statements of different types; this means groups of use
, use const
, and use function
will be visually separate from each other, though the Styler will not regroup or rearrange them.
Standalone const
statements are now grouped together instead of getting a blank line between them; class constants still have the blank line.
Fix name in help output.
Handle class constants separately from non-class constants.
Add Styler::functionBodyClipWhen().
Change how operators get modified; was setOperators(), now modOperators().
Published by pmjones about 1 year ago
Modify cache sytem:
Use the filemetime on the cache file instead of on the config file.
Add Cache::$config parameter to specify cache file location.
Consolidate open-brace and end-brace styling logic to their own methods.
Refactor Visitor.php to put enter/leave logic in separate methods.
Remove escaping on single-quoted strings.
Remove escaping on non-interpolation double-quoted strings.
Remove escaping on non-interpolation heredoc strings.
Second and subsequent parameters with attributes are now newline-separated.
Add basic customization document.
Published by pmjones about 1 year ago
Re-enable caching.
Config param cache
is removed; remove it from your config file.
Instead, caching uses the filemtime of the config file as the cache time.
Introduce package-specific exception class.
Clip condition and append-string are now customizable.
Published by pmjones about 1 year ago
Moved spacing classes to main namespace
Use class names, not other strings, for nesting identifiers
A single array argument now nestles up with parentheses
Improved fluency on statics, and initial fluent property is not split
Consolidate types of splits.
Clip newline above attributes
Mark expansives within arrays
Comments in arguments make arguments expansive
Consolidate attribute arguments into general arguments
Split arrow functions at =>
new
is no longer expansive
Address some addcslashes() handling of newlines when escaping strings
Published by pmjones about 1 year ago
Complete rewrite of code reassembly process using a Line object that splits into sub-Line objects, and applies splits to each Line independently.
Improved expansiveness handling.
Split rules now operate on a shared generic level rather than separate independent levels.
Styler sets default operators in constructor now; no need to call parent::setOperator() in extended Styler classes.
Something of a performance reduction (runs about 25% slower and uses about 25% more memory). When running PHP-Styler against itself:
Published by pmjones about 1 year ago
Roughly 8x speed improvement from removing php -l
linting in favor of PHP-Parser linting.
Cache is now ignored, though cache config remains.
Substantial improvements to line splitting and configurability of operators.
Still some problems with splitting when there are intervening unsplittable lines.
Published by pmjones about 1 year ago
Initial release.