Skip to content

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