diff --git a/app/Parsers/MemberAccessExpressionParser.php b/app/Parsers/MemberAccessExpressionParser.php index e087dc4..7fb14d9 100644 --- a/app/Parsers/MemberAccessExpressionParser.php +++ b/app/Parsers/MemberAccessExpressionParser.php @@ -30,7 +30,9 @@ public function parse(MemberAccessExpression $node) if ($child instanceof Variable) { if ($child->getName() === 'this') { - if ($child->getParent()->getParent() instanceof CallExpression) { + $parent = $child->getParent(); + + if ($parent?->getParent() instanceof CallExpression) { // They are calling a method on the current class $result = $this->context->nearestClassDefinition(); @@ -41,12 +43,14 @@ public function parse(MemberAccessExpression $node) continue; } - $propName = $child->getParent()->memberName->getFullText($node->getRoot()->getFullText()); + if ($parent instanceof MemberAccessExpression) { + $propName = $parent->memberName->getFullText($node->getRoot()->getFullText()); - $result = $this->context->searchForProperty($propName); + $result = $this->context->searchForProperty($propName); - if ($result) { - $this->context->className = $result['types'][0] ?? null; + if ($result) { + $this->context->className = $result['types'][0] ?? null; + } } continue;