Skip to content

Commit b0d4bfd

Browse files
committed
Fix accessing parent properties in PsalmApi::$properties->getProperty
1 parent 20cf3c9 commit b0d4bfd

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
"vimeo/psalm": "^4.26"
2525
},
2626
"require-dev": {
27-
"fp4php/functional": "v5.x-dev"
27+
"fp4php/functional": "^5.0"
2828
}
2929
}

src/Toolkit/Properties.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,20 @@ public function getStorage(string|TNamedObject|ClassLikeStorage $object, string
2222
? PsalmApi::$classlikes->getStorage($object)
2323
: Option::some($object);
2424

25-
return $storage->flatMap(fn(ClassLikeStorage $s) => at($s->properties, $property)->orElse(
26-
fn() => self::getAppearingStorage($s, $property),
27-
));
25+
return $storage->flatMap(
26+
fn(ClassLikeStorage $s) => at($s->properties, $property)
27+
->orElse(fn() => self::getAppearingStorage($s, $property))
28+
->orElse(fn() => self::getFromParent($s, $property)),
29+
);
30+
}
31+
32+
/**
33+
* @return Option<PropertyStorage>
34+
*/
35+
private function getFromParent(ClassLikeStorage $storage, string $property): Option
36+
{
37+
return Option::fromNullable($storage->parent_class)
38+
->flatMap(fn(string $parent) => $this->getStorage($parent, $property));
2839
}
2940

3041
/**

0 commit comments

Comments
 (0)