Skip to content

Commit

Permalink
[CodeQuality] Skip multiple lines on JoinStringConcatRector (#6404)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik authored Oct 29, 2024
1 parent 61ebcc5 commit d246d27
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\Concat\JoinStringConcatRector\Fixture;

class SkipMultiplelines
{
public function run()
{
return 'a' .
'b' .
'c' .
'd';
}
}
7 changes: 7 additions & 0 deletions rules/CodeQuality/Rector/Concat/JoinStringConcatRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ public function refactor(Node $node): ?Node
return null;
}

$leftStartLine = $node->left->getStartLine();
$rightStartLine = $node->right->getStartLine();

if ($leftStartLine > 0 && $rightStartLine > 0 && $rightStartLine > $leftStartLine) {
return null;
}

return $this->joinConcatIfStrings($node->left, $node->right);
}

Expand Down

0 comments on commit d246d27

Please sign in to comment.