Skip to content

Commit

Permalink
ExplicitMethodCallOverMagicGetSetRector fix (#2719)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMystikJonas committed Jul 28, 2022
1 parent ec9c15a commit 8df7912
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector\Fixture;

use Rector\Tests\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector\Source\ObjectWithMagicCalls;

final class SomeClass
{
public function run(ObjectWithMagicCalls $magicObject)
{
return $magicObject->unknown;
}
}

?>

Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ private function refactorPropertyFetch(PropertyFetch $propertyFetch, Scope $scop
return null;
}

if (! $callerType->hasProperty($propertyName)->yes()) {
return null;
}

$propertyReflection = $callerType->getProperty($propertyName, $scope);
$propertyType = $propertyReflection->getReadableType();

Expand Down

0 comments on commit 8df7912

Please sign in to comment.