Skip to content

Commit

Permalink
Skip StrvalToType for strval first class callable syntax (#4046)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoImparfait committed Jun 2, 2023
1 parent 897cdda commit b8a0e84
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\FuncCall\StrvalToTypeCastRector\Fixture;

final class SkipFirstClassCallable
{
public function run()
{
$arr = array_map(
strval(...),
[1, 2, 3]
);

return $arr;
}
}
4 changes: 4 additions & 0 deletions rules/CodeQuality/Rector/FuncCall/StrvalToTypeCastRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public function refactor(Node $node): ?Node
return null;
}

if ($node->isFirstClassCallable()) {
return null;
}

if (! isset($node->getArgs()[0])) {
return null;
}
Expand Down

0 comments on commit b8a0e84

Please sign in to comment.