diff --git a/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php b/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php index f0e9e45f2cb..92b07591223 100644 --- a/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php +++ b/rules/Php70/Rector/StaticCall/StaticCallOnNonStaticToInstanceCallRector.php @@ -158,6 +158,9 @@ private function shouldSkip(string $methodName, string $className, StaticCall $s } $scope = $staticCall->getAttribute(AttributeKey::SCOPE); + if (! $scope instanceof \PHPStan\Analyser\Scope) { + return true; + } $parentClassName = $this->parentClassScopeResolver->resolveParentClassName($scope); return $className === $parentClassName; diff --git a/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php b/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php index 6d22804a9ac..b4e7e8b7472 100644 --- a/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php +++ b/rules/Visibility/Rector/ClassMethod/ChangeMethodVisibilityRector.php @@ -98,6 +98,9 @@ public function getNodeTypes(): array public function refactor(Node $node): ?Node { $scope = $node->getAttribute(AttributeKey::SCOPE); + if (! $scope instanceof \PHPStan\Analyser\Scope) { + return true; + } $parentClassName = $this->parentClassScopeResolver->resolveParentClassName($scope); if ($parentClassName === null) {