Skip to content

Commit 280deb8

Browse files
committed
Fix Undefined property: Microsoft\PhpParser\Node\ArrayElement::$memberName
Fixes N1ebieski#1
1 parent 5823a57 commit 280deb8

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

app/Parsers/MemberAccessExpressionParser.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ public function parse(MemberAccessExpression $node)
3030

3131
if ($child instanceof Variable) {
3232
if ($child->getName() === 'this') {
33-
if ($child->getParent()->getParent() instanceof CallExpression) {
33+
$parent = $child->getParent();
34+
35+
if ($parent?->getParent() instanceof CallExpression) {
3436
// They are calling a method on the current class
3537
$result = $this->context->nearestClassDefinition();
3638

@@ -41,12 +43,14 @@ public function parse(MemberAccessExpression $node)
4143
continue;
4244
}
4345

44-
$propName = $child->getParent()->memberName->getFullText($node->getRoot()->getFullText());
46+
if ($parent instanceof MemberAccessExpression) {
47+
$propName = $parent->memberName->getFullText($node->getRoot()->getFullText());
4548

46-
$result = $this->context->searchForProperty($propName);
49+
$result = $this->context->searchForProperty($propName);
4750

48-
if ($result) {
49-
$this->context->className = $result['types'][0] ?? null;
51+
if ($result) {
52+
$this->context->className = $result['types'][0] ?? null;
53+
}
5054
}
5155

5256
continue;

0 commit comments

Comments
 (0)