@@ -299,7 +299,7 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st
299
299
try {
300
300
$ a [$ prefix .'default ' ] = $ v = $ c ->getDefaultValue ();
301
301
if ($ c ->isDefaultValueConstant () && !\is_object ($ v )) {
302
- $ a [$ prefix .'default ' ] = new ConstStub ($ c -> getDefaultValueConstantName (), $ v );
302
+ $ a [$ prefix .'default ' ] = new ConstStub (self :: getDefaultValueConstantName ($ c ), $ v );
303
303
}
304
304
if (null === $ v ) {
305
305
unset($ a [$ prefix .'allowsNull ' ]);
@@ -383,7 +383,7 @@ public static function getSignature(array $a)
383
383
$ signature .= ' = ' ;
384
384
385
385
if ($ param ->isDefaultValueConstant ()) {
386
- $ signature .= substr (strrchr ('\\' .$ param -> getDefaultValueConstantName (), '\\' ), 1 );
386
+ $ signature .= substr (strrchr ('\\' .self :: getDefaultValueConstantName ($ param ), '\\' ), 1 );
387
387
} elseif (null === $ v ) {
388
388
$ signature .= 'null ' ;
389
389
} elseif (\is_array ($ v )) {
@@ -445,4 +445,19 @@ private static function addAttributes(array &$a, \Reflector $c, string $prefix =
445
445
}
446
446
}
447
447
}
448
+
449
+ private static function getDefaultValueConstantName (\ReflectionParameter $ param ): ?string
450
+ {
451
+ $ namespacedConstant = $ param ->getDefaultValueConstantName ();
452
+
453
+ if (null !== $ namespacedConstant && str_contains ($ namespacedConstant , '\\' ) && !\defined ($ namespacedConstant )) {
454
+ $ globalConstant = '\\' .preg_replace ('/^.* \\\\([^ \\\\]+)$/ ' , '$1 ' , $ namespacedConstant );
455
+
456
+ if (\defined ($ globalConstant ) && $ param ->getDefaultValue () === \constant ($ globalConstant )) {
457
+ return $ globalConstant ;
458
+ }
459
+ }
460
+
461
+ return $ namespacedConstant ;
462
+ }
448
463
}
0 commit comments