Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public function getMarking(object $subject): Marking
try {
$marking = ($this->getGetter($subject))();
} catch (\Error $e) {
$unInitializedPropertyMessage = \sprintf('Typed property %s::$%s must not be accessed before initialization', get_debug_type($subject), $this->property);
if ($e->getMessage() !== $unInitializedPropertyMessage) {
if (!str_starts_with($e->getMessage(), 'Typed property ') || !str_ends_with($e->getMessage(), '::$'.$this->property.' must not be accessed before initialization')) {
throw $e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ public function testGetMarkingWithUninitializedProperty2()
$markingStore->getMarking($subject);
}

public function testGetMarkingWithUninitializedPropertyInheritance()
{
$subject = new ChildInheritingProperty();

$markingStore = new MethodMarkingStore(true, 'place');
$marking = $markingStore->getMarking($subject);

$this->assertCount(0, $marking->getPlaces());
}

private function createValueObject(string $markingValue): object
{
return new class($markingValue) {
Expand All @@ -124,3 +134,12 @@ public function __toString(): string
};
}
}

class ParentWithProperty
{
public string $place;
}

class ChildInheritingProperty extends ParentWithProperty
{
}