Skip to content

Commit ec3414d

Browse files
committed
add fixture to proof scoped dynamic variable
1 parent d40ba5d commit ec3414d

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace Rector\Tests\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector\Fixture;
4+
5+
class ScopedDynamicVariable
6+
{
7+
public function build(array $params): string
8+
{
9+
$addHelpMessage = true;
10+
11+
foreach (['addHelpMessage'] as $f) {
12+
if (isset($params[$f])) {
13+
${$f} = (bool) $params[$f];
14+
}
15+
}
16+
17+
if ($addHelpMessage) {
18+
return 'help';
19+
}
20+
21+
return 'no help';
22+
}
23+
24+
public function differentScope()
25+
{
26+
$int = 1;
27+
if ($int === 1) {
28+
return 'hi';
29+
}
30+
}
31+
}
32+
33+
?>
34+
-----
35+
<?php
36+
37+
namespace Rector\Tests\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector\Fixture;
38+
39+
class ScopedDynamicVariable
40+
{
41+
public function build(array $params): string
42+
{
43+
$addHelpMessage = true;
44+
45+
foreach (['addHelpMessage'] as $f) {
46+
if (isset($params[$f])) {
47+
${$f} = (bool) $params[$f];
48+
}
49+
}
50+
51+
if ($addHelpMessage) {
52+
return 'help';
53+
}
54+
55+
return 'no help';
56+
}
57+
58+
public function differentScope()
59+
{
60+
$int = 1;
61+
return 'hi';
62+
}
63+
}
64+
65+
?>

0 commit comments

Comments
 (0)