Skip to content

Commit 2759132

Browse files
committed
final touch: fix escape
1 parent 1abb4ea commit 2759132

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Rector\Tests\Php85\Rector\ShellExec\ShellExecFunctionCallOverBackticksRector\Fixture;
4+
5+
class MultiVariable
6+
{
7+
public function run()
8+
{
9+
$a = 'X';
10+
$b = 'Y';
11+
$output = `echo $a ' and ' $b`;
12+
13+
echo $output;
14+
}
15+
}
16+
17+
?>
18+
-----
19+
<?php
20+
21+
namespace Rector\Tests\Php85\Rector\ShellExec\ShellExecFunctionCallOverBackticksRector\Fixture;
22+
23+
class MultiVariable
24+
{
25+
public function run()
26+
{
27+
$a = 'X';
28+
$b = 'Y';
29+
$output = shell_exec('echo ' . $a . ' and ' . $b);
30+
31+
echo $output;
32+
}
33+
}
34+
35+
?>

rules/Php85/Rector/ShellExec/ShellExecFunctionCallOverBackticksRector.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public function refactor(Node $node): ?Node
5959
$exprs = [];
6060
foreach ($node->parts as $part) {
6161
if ($part instanceof InterpolatedStringPart) {
62-
// keep as single-quoted string literal and escape single quotes inside
63-
$escaped = str_replace("'", "\\'", $part->value);
64-
$exprs[] = new String_($escaped);
62+
$exprs[] = new String_($part->value);
6563
continue;
6664
}
6765

0 commit comments

Comments
 (0)