Skip to content

Commit d246d27

Browse files
authored
[CodeQuality] Skip multiple lines on JoinStringConcatRector (#6404)
1 parent 61ebcc5 commit d246d27

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Rector\Tests\CodeQuality\Rector\Concat\JoinStringConcatRector\Fixture;
4+
5+
class SkipMultiplelines
6+
{
7+
public function run()
8+
{
9+
return 'a' .
10+
'b' .
11+
'c' .
12+
'd';
13+
}
14+
}

rules/CodeQuality/Rector/Concat/JoinStringConcatRector.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ public function refactor(Node $node): ?Node
8181
return null;
8282
}
8383

84+
$leftStartLine = $node->left->getStartLine();
85+
$rightStartLine = $node->right->getStartLine();
86+
87+
if ($leftStartLine > 0 && $rightStartLine > 0 && $rightStartLine > $leftStartLine) {
88+
return null;
89+
}
90+
8491
return $this->joinConcatIfStrings($node->left, $node->right);
8592
}
8693

0 commit comments

Comments
 (0)