-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update PrettyPrinter.php #62
Conversation
This could be solution to phpowermove#61. This counts lines difference between stms and insert new line character for every empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic is fine, I like the diff :)
Please use php-cs-fixer (profile is included in the repo) for formatting.
Also please add tests, that cover your problem (so future releases don't regress here). Make sure, tests cover both code profiles existent atm: https://github.com/gossi/php-code-profiles/tree/master/profiles
*/ | ||
protected function pStmts(array $nodes, $indent = true) { | ||
$result = ''; | ||
$nodeBefore = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$nodeBefore = NULL; | |
$prevNode = null; |
} | ||
|
||
if ($indent) { | ||
return preg_replace('~\n(?!$|' . $this->noIndentToken . ')~', "\n ", $result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use code profile for indentation character(s) here.
* | ||
* @return string Pretty printed statements | ||
*/ | ||
protected function pStmts(array $nodes, $indent = true) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
travis says:
protected function pStmts(array $nodes, $indent = true) { | |
protected function pStmts(array $nodes, bool $indent = true): string { |
$result = ''; | ||
$nodeBefore = NULL; | ||
foreach ($nodes as $node) { | ||
$comments = $node->getAttribute('comments', array()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go modern 😉:
$comments = $node->getAttribute('comments', array()); | |
$comments = $node->getAttribute('comments', []); |
This could be solution to #61. This counts lines difference between stms and insert new line character for every empty line.