Skip to content
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

Merged
merged 1 commit into from
May 18, 2019
Merged

Update PrettyPrinter.php #62

merged 1 commit into from
May 18, 2019

Conversation

matak
Copy link
Contributor

@matak matak commented Apr 25, 2019

This could be solution to #61. This counts lines difference between stms and insert new line character for every empty line.

This could be solution to phpowermove#61. This counts lines difference between stms and insert new line character for every empty line.
Copy link
Member

@gossi gossi left a 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$nodeBefore = NULL;
$prevNode = null;

}

if ($indent) {
return preg_replace('~\n(?!$|' . $this->noIndentToken . ')~', "\n ", $result);
Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

travis says:

Suggested change
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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go modern 😉:

Suggested change
$comments = $node->getAttribute('comments', array());
$comments = $node->getAttribute('comments', []);

@gossi gossi merged commit 83c363d into phpowermove:master May 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants