Skip to content

Commit 9d80512

Browse files
authored
[DowngradePhp81] Allow downgrade ReflectionMethod on DowngradeSetAccessibleReflectionPropertyRector (#296)
* [DowngradePhp81] Allow downgrade ReflectionMethod on DowngradeSetAccessibleReflectionPropertyRector * [DowngradePhp81] Allow downgrade ReflectionMethod on DowngradeSetAccessibleReflectionPropertyRector
1 parent 7c5025b commit 9d80512

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Rector\Tests\DowngradePhp81\Rector\StmtsAwareInterface\DowngradeSetAccessibleReflectionPropertyRector\Fixture;
4+
5+
class OnReflectionMethod
6+
{
7+
public function run($object)
8+
{
9+
$reflectionMethod = new \ReflectionMethod($object, 'bar');
10+
return $reflectionMethod->__invoke($object, []);
11+
}
12+
}
13+
14+
?>
15+
-----
16+
<?php
17+
18+
namespace Rector\Tests\DowngradePhp81\Rector\StmtsAwareInterface\DowngradeSetAccessibleReflectionPropertyRector\Fixture;
19+
20+
class OnReflectionMethod
21+
{
22+
public function run($object)
23+
{
24+
$reflectionMethod = new \ReflectionMethod($object, 'bar');
25+
$reflectionMethod->setAccessible(true);
26+
return $reflectionMethod->__invoke($object, []);
27+
}
28+
}
29+
30+
?>

rules/DowngradePhp81/Rector/StmtsAwareInterface/DowngradeSetAccessibleReflectionPropertyRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function refactor(Node $node): ?Node
9494
}
9595

9696
$new = $assign->expr;
97-
if (! $this->isName($new->class, 'ReflectionProperty')) {
97+
if (! $this->isNames($new->class, ['ReflectionProperty', 'ReflectionMethod'])) {
9898
continue;
9999
}
100100

0 commit comments

Comments
 (0)