Skip to content

Commit 2be5b0c

Browse files
committed
handle nulls for searchForVar and addPropertyToNearestClassDefinition
1 parent 3d8d743 commit 2be5b0c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/Contexts/AbstractContext.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,12 @@ public function initNew(AbstractContext $newContext)
9898
return $newContext;
9999
}
100100

101-
public function searchForVar(string $name): AssignmentValue|string|null
101+
public function searchForVar(?string $name): AssignmentValue|string|null
102102
{
103+
if ($name === null) {
104+
return null;
105+
}
106+
103107
if (property_exists($this, 'parameters') && $this->parameters instanceof Parameters) {
104108
foreach ($this->parameters->children as $param) {
105109
if ($param->name === $name) {
@@ -117,8 +121,12 @@ public function searchForVar(string $name): AssignmentValue|string|null
117121
return $this->parent?->searchForVar($name) ?? null;
118122
}
119123

120-
public function addPropertyToNearestClassDefinition(string $name, $types = [])
124+
public function addPropertyToNearestClassDefinition(?string $name, $types = [])
121125
{
126+
if ($name === null) {
127+
return;
128+
}
129+
122130
if ($this instanceof ClassDefinition) {
123131
$this->properties[] = [
124132
'name' => $name,

0 commit comments

Comments
 (0)