Skip to content

Commit

Permalink
[Php81] Skip execution operator on NullToStrictStringFuncCallArgRect…
Browse files Browse the repository at this point in the history
…or (#5667)

* [Php81] Skip execution operator on NullToStrictStringFuncCallArgRector

* [Php81] Skip execution operator on NullToStrictStringFuncCallArgRector
  • Loading branch information
samsonasik committed Feb 27, 2024
1 parent a56ee1e commit b95ff29
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
@@ -0,0 +1,11 @@
<?php

namespace Rector\Tests\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector\Fixture;

final class SkipExecutionOp
{
public function run(string $search, string $replace)
{
str_replace($search, $replace, `ls -l`);
}
}
Expand Up @@ -11,6 +11,7 @@
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\ShellExec;
use PhpParser\Node\Identifier;
use PhpParser\Node\Scalar\Encapsed;
use PhpParser\Node\Scalar\String_;
Expand Down Expand Up @@ -174,6 +175,10 @@ private function processNullToStrictStringOnNodePosition(

$argValue = $args[$position]->value;

if ($argValue instanceof ShellExec) {
return null;
}

if ($argValue instanceof ConstFetch && $this->valueResolver->isNull($argValue)) {
$args[$position]->value = new String_('');
$funcCall->args = $args;
Expand Down

0 comments on commit b95ff29

Please sign in to comment.