Skip to content

Commit 3972812

Browse files
committed
find nearest class def
1 parent eec73fe commit 3972812

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

app/Contexts/AbstractContext.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ public function addPropertyToNearestClassDefinition(string $name, $types = [])
129129
}
130130
}
131131

132+
public function nearestClassDefinition()
133+
{
134+
if ($this instanceof ClassDefinition) {
135+
return $this;
136+
}
137+
138+
return $this->parent?->nearestClassDefinition() ?? null;
139+
}
140+
132141
public function searchForProperty(string $name)
133142
{
134143
if ($this instanceof ClassDefinition) {

0 commit comments

Comments
 (0)