File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed
Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff 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
@@ -151,7 +153,7 @@ public function hasDefaultValue(): bool
151153
152154 $ hasDefaultValue = $ this ->reflectionProperty ->hasDefaultValue ();
153155
154- $ hasPromotedDefaultValue = $ this ->isPromoted () && $ constructorParameters [$ this ->getName ()]->isDefaultValueAvailable ();
156+ $ hasPromotedDefaultValue = $ this ->isPromoted () && isset ( $ constructorParameters [ $ this -> getName ()]) && $ constructorParameters [$ this ->getName ()]->isDefaultValueAvailable ();
155157
156158 return $ hasDefaultValue || $ hasPromotedDefaultValue ;
157159 }
Original file line number Diff line number Diff line change 66
77use BackedEnum ;
88use DateTimeInterface ;
9- use Exception ;
109use Generator ;
1110use Iterator ;
1211use ReflectionClass as PHPReflectionClass ;
@@ -232,7 +231,13 @@ private function resolveDefinition(PHPReflector|PHPReflectionType|string $reflec
232231 }
233232
234233 if ($ reflector instanceof PHPReflectionParameter || $ reflector instanceof PHPReflectionProperty) {
235- return $ this ->resolveDefinition ($ reflector ->getType ());
234+ $ type = $ reflector ->getType ();
235+
236+ if ($ type === null ) {
237+ return 'mixed ' ;
238+ }
239+
240+ return $ this ->resolveDefinition ($ type );
236241 }
237242
238243 if ($ reflector instanceof PHPReflectionClass) {
@@ -257,7 +262,9 @@ private function resolveDefinition(PHPReflector|PHPReflectionType|string $reflec
257262 ));
258263 }
259264
260- throw new Exception ('Could not resolve type ' );
265+ throw new \InvalidArgumentException (
266+ sprintf ('Could not resolve type for reflector of type: %s ' , get_debug_type ($ reflector )),
267+ );
261268 }
262269
263270 private function resolveIsNullable (PHPReflectionType |PHPReflector |string $ reflector ): bool
@@ -267,7 +274,9 @@ private function resolveIsNullable(PHPReflectionType|PHPReflector|string $reflec
267274 }
268275
269276 if ($ reflector instanceof PHPReflectionParameter || $ reflector instanceof PHPReflectionProperty) {
270- return $ reflector ->getType ()->allowsNull ();
277+ $ type = $ reflector ->getType ();
278+
279+ return $ type === null || $ type ->allowsNull ();
271280 }
272281
273282 if ($ reflector instanceof PHPReflectionType) {
You can’t perform that action at this time.
0 commit comments