Skip to content

Commit cc33add

Browse files
committed
fix(reflection): support generic syntax in getIterableType
1 parent b8e9d21 commit cc33add

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/reflection/src/PropertyReflector.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,15 @@ public function getIterableType(): ?TypeReflector
9898
return null;
9999
}
100100

101-
preg_match('/@var ([\\\\\w]+)\[]/', $doc, $match);
101+
if (preg_match('/@var\s+([\\\\\w]+)\[\]/', $doc, $match)) {
102+
return new TypeReflector(ltrim($match[1], '\\'));
103+
}
102104

103-
if (! isset($match[1])) {
104-
return null;
105+
if (preg_match('/@var\s+(?:list|array)<([\\\\\w]+)>/', $doc, $match)) {
106+
return new TypeReflector(ltrim($match[1], '\\'));
105107
}
106108

107-
return new TypeReflector(ltrim($match[1], '\\'));
109+
return null;
108110
}
109111

110112
public function isUninitialized(object $object): bool

0 commit comments

Comments
 (0)