Skip to content

Commit

Permalink
[CodingStyle] Skip concat on first arg on ConsistentImplodeRector (#3702
Browse files Browse the repository at this point in the history
)

* Add failing test fixture for ConsistentImplodeRector

# Failing Test for ConsistentImplodeRector

Based on https://getrector.com/demo/ec054f63-0f4e-489d-a3da-fa87581814f0

Reported in rectorphp/rector#7903

* Use the type to check for string in ConsistentImplodeRector

* Change fixture name
  • Loading branch information
nerones authored and samsonasik committed May 8, 2023
1 parent 50b22de commit 61f8bfd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Rector\Tests\CodingStyle\Rector\FuncCall\ConsistentImplodeRector\Fixture;

final class SkipConcatOnFirstArg
{
public function run()
{
implode('|' . ' ', 'should not be changed');
}
}

?>
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public function refactor(Node $node): ?Node
/** @var Arg $arg0 */
$arg0 = $node->args[0];
$firstArgumentValue = $arg0->value;
if ($firstArgumentValue instanceof String_) {

$firstArgumentType = $this->getType($firstArgumentValue);
if ($firstArgumentType->isString()->yes()) {
return null;
}

Expand Down

0 comments on commit 61f8bfd

Please sign in to comment.