From 1f028d558fb7c2af8ba3e2cc9f2450571c385a05 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 8 Oct 2025 07:50:10 +0700 Subject: [PATCH 01/12] [Php85] Add ShellExecFunctionCallOverBackticksRector --- config/set/php85.php | 2 + .../Fixture/fixture.php.inc | 29 ++++++++ ...xecFunctionCallOverBackticksRectorTest.php | 28 ++++++++ .../config/configured_rule.php | 13 ++++ ...ellExecFunctionCallOverBackticksRector.php | 69 +++++++++++++++++++ .../PropertyFetch/RenamePropertyRector.php | 5 +- src/ValueObject/PhpVersionFeature.php | 6 ++ 7 files changed, 150 insertions(+), 2 deletions(-) create mode 100644 rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/fixture.php.inc create mode 100644 rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/ShellExecFunctionCallOverBackticksRectorTest.php create mode 100644 rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/config/configured_rule.php create mode 100644 rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php diff --git a/config/set/php85.php b/config/set/php85.php index a118ca891b9..33e526c3bf2 100644 --- a/config/set/php85.php +++ b/config/set/php85.php @@ -16,6 +16,7 @@ use Rector\Php85\Rector\FuncCall\ChrArgModuloRector; use Rector\Php85\Rector\FuncCall\OrdSingleByteRector; use Rector\Php85\Rector\FuncCall\RemoveFinfoBufferContextArgRector; +use Rector\Php85\Rector\ShellExec\ShellExecFunctionCallOverBackticksRector; use Rector\Php85\Rector\Switch_\ColonAfterSwitchCaseRector; use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector; use Rector\Removing\ValueObject\RemoveFuncCallArg; @@ -43,6 +44,7 @@ SleepToSerializeRector::class, OrdSingleByteRector::class, WakeupToUnserializeRector::class, + ShellExecFunctionCallOverBackticksRector::class, ] ); diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/fixture.php.inc b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/fixture.php.inc new file mode 100644 index 00000000000..b34d248be0e --- /dev/null +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/fixture.php.inc @@ -0,0 +1,29 @@ +$output"; + } +} + +?> +----- +$output"; + } +} + +?> \ No newline at end of file diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/ShellExecFunctionCallOverBackticksRectorTest.php b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/ShellExecFunctionCallOverBackticksRectorTest.php new file mode 100644 index 00000000000..bbd7ff55c27 --- /dev/null +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/ShellExecFunctionCallOverBackticksRectorTest.php @@ -0,0 +1,28 @@ +doTestFile($filePath); + } + + public static function provideData(): Iterator + { + return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); + } + + public function provideConfigFilePath(): string + { + return __DIR__ . '/config/configured_rule.php'; + } +} diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/config/configured_rule.php b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/config/configured_rule.php new file mode 100644 index 00000000000..ba0bc248b6f --- /dev/null +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/config/configured_rule.php @@ -0,0 +1,13 @@ +rule(ShellExecFunctionCallOverBackticksRector::class); + + $rectorConfig->phpVersion(PhpVersion::PHP_85); +}; diff --git a/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php b/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php new file mode 100644 index 00000000000..592b82678b8 --- /dev/null +++ b/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php @@ -0,0 +1,69 @@ +$output"; +CODE_SAMPLE + , + <<<'CODE_SAMPLE' +$output = shell_exec('ls -al'); +echo "
$output
"; +CODE_SAMPLE + ), + ] + ); + } + + public function getNodeTypes(): array + { + return [ShellExec::class]; + } + + /** + * @param ShellExec $node + */ + public function refactor(Node $node): Node + { + $args = array_map(function (Node $node): Node { + if ($node instanceof InterpolatedStringPart) { + return new Arg(new String_($node->value)); + } + + return new Arg($node); + }, $node->parts); + + return $this->nodeFactory->createFuncCall('shell_exec', $args); + } + + public function provideMinPhpVersion(): int + { + return PhpVersionFeature::DEPRECATE_BACKTICKS; + } +} diff --git a/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php b/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php index 1071f22eb86..c995057363a 100644 --- a/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php +++ b/rules/Renaming/Rector/PropertyFetch/RenamePropertyRector.php @@ -111,8 +111,9 @@ private function renameProperty(ClassLike $classLike, RenameProperty $renameProp $property->props[0]->name = new VarLikeIdentifier($newProperty); } - private function refactorPropertyFetch(PropertyFetch|StaticPropertyFetch $propertyFetch): null|PropertyFetch|StaticPropertyFetch - { + private function refactorPropertyFetch( + PropertyFetch|StaticPropertyFetch $propertyFetch + ): null|PropertyFetch|StaticPropertyFetch { foreach ($this->renamedProperties as $renamedProperty) { $oldProperty = $renamedProperty->getOldProperty(); if (! $this->isName($propertyFetch, $oldProperty)) { diff --git a/src/ValueObject/PhpVersionFeature.php b/src/ValueObject/PhpVersionFeature.php index 6730eebcb47..20cf7566cef 100644 --- a/src/ValueObject/PhpVersionFeature.php +++ b/src/ValueObject/PhpVersionFeature.php @@ -834,4 +834,10 @@ final class PhpVersionFeature * @var int */ public const DEPRECATE_ORD_WITH_MULTIBYTE_STRING = PhpVersion::PHP_85; + + /** + * @see https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_backticks_as_an_alias_for_shell_exec + * @var int + */ + public const DEPRECATE_BACKTICKS = PhpVersion::PHP_85; } From d87630b4aa4ed4f937d0ee5b2b608e98816f09f9 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 8 Oct 2025 07:53:00 +0700 Subject: [PATCH 02/12] fix phpstan --- .../ShellExecFunctionCallOverBackticksRectorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/ShellExecFunctionCallOverBackticksRectorTest.php b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/ShellExecFunctionCallOverBackticksRectorTest.php index bbd7ff55c27..988002eff25 100644 --- a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/ShellExecFunctionCallOverBackticksRectorTest.php +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/ShellExecFunctionCallOverBackticksRectorTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\Tests\Php85\Rector\FuncCall\ShellExecFunctionCallOverBackticksRector; +namespace Rector\Tests\Php85\Rector\ShellExec\ShellExecFunctionCallOverBackticksRector; use Iterator; use PHPUnit\Framework\Attributes\DataProvider; From c00a787072e983be09272d615d592ef5f9f8293d Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 8 Oct 2025 07:53:39 +0700 Subject: [PATCH 03/12] eol --- .../Fixture/fixture.php.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/fixture.php.inc b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/fixture.php.inc index b34d248be0e..cbec9525569 100644 --- a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/fixture.php.inc +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/fixture.php.inc @@ -26,4 +26,4 @@ class Fixture } } -?> \ No newline at end of file +?> From f63fdb5f0f565afd7313be43f06ca611f3f82bb7 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 8 Oct 2025 09:28:04 +0700 Subject: [PATCH 04/12] add fixture with variable --- .../Fixture/with_variable.php.inc | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/with_variable.php.inc diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/with_variable.php.inc b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/with_variable.php.inc new file mode 100644 index 00000000000..202371d6c4f --- /dev/null +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/with_variable.php.inc @@ -0,0 +1,43 @@ +$output"; + echo "
$output2
"; + echo "
$output3
"; + } +} + +?> +----- +$output"; + echo "
$output2
"; + echo "
$output3
"; + } +} + +?> From 4dc4d35ec2ea2c6626e6fe0c70b864f7ae8b5e3a Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 8 Oct 2025 09:30:18 +0700 Subject: [PATCH 05/12] update fixture --- .../Fixture/with_variable.php.inc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/with_variable.php.inc b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/with_variable.php.inc index 202371d6c4f..611241be116 100644 --- a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/with_variable.php.inc +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/with_variable.php.inc @@ -9,12 +9,10 @@ class WithVariable $dir = __DIR__; $var = 'example'; - $output = `ls -al`; - $output2 = `ls $dir`; - $output3 = `echo "value: $var"`; + $output = `ls $dir`; + $output2 = `echo "value: $var"`; echo "
$output
"; echo "
$output2
"; - echo "
$output3
"; } } @@ -31,10 +29,8 @@ class WithVariable $dir = __DIR__; $var = 'example'; - $output = shell_exec("ls -al"); $output2 = shell_exec("ls $dir"); $output3 = shell_exec("echo \"value: $var\""); - echo "
$output
"; echo "
$output2
"; echo "
$output3
"; } From a89beb0dabc7e9bf3781e0c2ac5e71f556c41916 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 8 Oct 2025 09:31:49 +0700 Subject: [PATCH 06/12] update fixture --- .../Fixture/with_variable.php.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/with_variable.php.inc b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/with_variable.php.inc index 611241be116..807f3700f85 100644 --- a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/with_variable.php.inc +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/with_variable.php.inc @@ -29,10 +29,10 @@ class WithVariable $dir = __DIR__; $var = 'example'; - $output2 = shell_exec("ls $dir"); - $output3 = shell_exec("echo \"value: $var\""); + $output = shell_exec("ls $dir"); + $output2 = shell_exec("echo \"value: $var\""); + echo "
$output
"; echo "
$output2
"; - echo "
$output3
"; } } From 1abb4ea384e5d656cafbcaa73b15408050a45767 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 8 Oct 2025 09:40:22 +0700 Subject: [PATCH 07/12] Fix --- .../Fixture/skip_empty_backticks.php.inc | 11 ++++++ .../Fixture/with_variable.php.inc | 4 +-- ...ellExecFunctionCallOverBackticksRector.php | 36 +++++++++++++++---- 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/skip_empty_backticks.php.inc diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/skip_empty_backticks.php.inc b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/skip_empty_backticks.php.inc new file mode 100644 index 00000000000..16118ad59d7 --- /dev/null +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/skip_empty_backticks.php.inc @@ -0,0 +1,11 @@ +$output"; echo "
$output2
"; } diff --git a/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php b/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php index 592b82678b8..6d7a16ce6b0 100644 --- a/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php +++ b/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php @@ -6,6 +6,7 @@ use PhpParser\Node; use PhpParser\Node\Arg; +use PhpParser\Node\Expr\BinaryOp\Concat; use PhpParser\Node\Expr\ShellExec; use PhpParser\Node\InterpolatedStringPart; use PhpParser\Node\Scalar\String_; @@ -49,17 +50,38 @@ public function getNodeTypes(): array /** * @param ShellExec $node */ - public function refactor(Node $node): Node + public function refactor(Node $node): ?Node { - $args = array_map(function (Node $node): Node { - if ($node instanceof InterpolatedStringPart) { - return new Arg(new String_($node->value)); + if ($node->parts === []) { + return null; + } + + $exprs = []; + foreach ($node->parts as $part) { + if ($part instanceof InterpolatedStringPart) { + // keep as single-quoted string literal and escape single quotes inside + $escaped = str_replace("'", "\\'", $part->value); + $exprs[] = new String_($escaped); + continue; } - return new Arg($node); - }, $node->parts); + // other parts are Expr (variables, function calls, etc.) + // keep them as-is so they are concatenated + $exprs[] = $part; + } + + // reduce to single concatenated expression + if (count($exprs) === 1) { + $argExpr = $exprs[0]; + } else { + $argExpr = array_shift($exprs); + foreach ($exprs as $expr) { + $argExpr = new Concat($argExpr, $expr); + } + } - return $this->nodeFactory->createFuncCall('shell_exec', $args); + // create single Arg and call shell_exec + return $this->nodeFactory->createFuncCall('shell_exec', [new Arg($argExpr)]); } public function provideMinPhpVersion(): int From 2759132bc93ffc07e1e483efda5dc74e77ab2c0f Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 8 Oct 2025 11:14:34 +0700 Subject: [PATCH 08/12] final touch: fix escape --- .../Fixture/multi_variable.php.inc | 35 +++++++++++++++++++ ...ellExecFunctionCallOverBackticksRector.php | 4 +-- 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variable.php.inc diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variable.php.inc b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variable.php.inc new file mode 100644 index 00000000000..40d3cb8fde2 --- /dev/null +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variable.php.inc @@ -0,0 +1,35 @@ + +----- + \ No newline at end of file diff --git a/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php b/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php index 6d7a16ce6b0..6a82a3bca48 100644 --- a/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php +++ b/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php @@ -59,9 +59,7 @@ public function refactor(Node $node): ?Node $exprs = []; foreach ($node->parts as $part) { if ($part instanceof InterpolatedStringPart) { - // keep as single-quoted string literal and escape single quotes inside - $escaped = str_replace("'", "\\'", $part->value); - $exprs[] = new String_($escaped); + $exprs[] = new String_($part->value); continue; } From ba7b5130efbd14dd3d6f8156fdce6a84081df362 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 8 Oct 2025 11:15:21 +0700 Subject: [PATCH 09/12] final touch: grammar --- .../{multi_variable.php.inc => multi_variables.php.inc} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/{multi_variable.php.inc => multi_variables.php.inc} (92%) diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variable.php.inc b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variables.php.inc similarity index 92% rename from rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variable.php.inc rename to rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variables.php.inc index 40d3cb8fde2..49407479d39 100644 --- a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variable.php.inc +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variables.php.inc @@ -2,7 +2,7 @@ namespace Rector\Tests\Php85\Rector\ShellExec\ShellExecFunctionCallOverBackticksRector\Fixture; -class MultiVariable +class MultiVariables { public function run() { @@ -20,7 +20,7 @@ class MultiVariable namespace Rector\Tests\Php85\Rector\ShellExec\ShellExecFunctionCallOverBackticksRector\Fixture; -class MultiVariable +class MultiVariables { public function run() { @@ -32,4 +32,4 @@ class MultiVariable } } -?> \ No newline at end of file +?> From ade93c0b988a27f0e1fb92eddf845f54d3a587ac Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 8 Oct 2025 11:15:47 +0700 Subject: [PATCH 10/12] final touch: fix fixture --- .../Fixture/multi_variables.php.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variables.php.inc b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variables.php.inc index 49407479d39..e8893ce4c80 100644 --- a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variables.php.inc +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variables.php.inc @@ -26,7 +26,7 @@ class MultiVariables { $a = 'X'; $b = 'Y'; - $output = shell_exec('echo ' . $a . ' and ' . $b); + $output = shell_exec('echo ' . $a . ' \' and \' ' . $b); echo $output; } From 00c1bea963f40cecf0afc90e6448b835f4107a53 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 8 Oct 2025 11:28:03 +0700 Subject: [PATCH 11/12] final touch: fixture for single quote inside --- .../Fixture/multi_variables.php.inc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variables.php.inc b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variables.php.inc index e8893ce4c80..519a1971922 100644 --- a/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variables.php.inc +++ b/rules-tests/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector/Fixture/multi_variables.php.inc @@ -8,8 +8,11 @@ class MultiVariables { $a = 'X'; $b = 'Y'; + $output = `echo $a ' and ' $b`; + echo $output; + $output = `echo $a and $b`; echo $output; } } @@ -26,8 +29,11 @@ class MultiVariables { $a = 'X'; $b = 'Y'; + $output = shell_exec('echo ' . $a . ' \' and \' ' . $b); + echo $output; + $output = shell_exec('echo ' . $a . ' and ' . $b); echo $output; } } From 30d48f3343bcb2a62f2543a922c3e77732eb1b5b Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 8 Oct 2025 11:44:08 +0700 Subject: [PATCH 12/12] final touch: clean up loop --- .../ShellExecFunctionCallOverBackticksRector.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php b/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php index 6a82a3bca48..ab63d8dc69a 100644 --- a/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php +++ b/rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php @@ -69,13 +69,9 @@ public function refactor(Node $node): ?Node } // reduce to single concatenated expression - if (count($exprs) === 1) { - $argExpr = $exprs[0]; - } else { - $argExpr = array_shift($exprs); - foreach ($exprs as $expr) { - $argExpr = new Concat($argExpr, $expr); - } + $argExpr = array_shift($exprs); + foreach ($exprs as $expr) { + $argExpr = new Concat($argExpr, $expr); } // create single Arg and call shell_exec