@@ -356,27 +356,31 @@ private static function resolveArrayShape(ArrayShapeNode $node, \ReflectionClass
356356 /** @var ConstExprIntegerNode|ConstExprStringNode|ConstFetchNode|IdentifierTypeNode|null $keyName */
357357 $ keyName = $ item ->keyName ;
358358
359- // --- CRASH AND DUMP AST NODE CLASS ON PHP 8.2 ---
360- if ($ keyName !== null ) {
361- $ classStr = get_class ($ keyName );
362- $ valStr = method_exists ($ keyName , '__toString ' ) ? (string ) $ keyName : 'unknown ' ;
363-
364- if (str_contains ($ valStr , 'self:: ' )) {
365- throw new \RuntimeException ("[DEBUG PHP 8.2] AST Class: {$ classStr } | Value: {$ valStr }" );
366- }
367- }
368- // -------------------------------------------------
369-
370359 $ className = null ;
371360 $ constName = null ;
372361
362+ $ debugClass = $ keyName !== null ? get_class ($ keyName ) : 'null ' ;
363+ $ debugVal = $ keyName !== null && method_exists ($ keyName , '__toString ' ) ? (string ) $ keyName : 'unknown ' ;
364+ fwrite (STDERR , "\n[DEBUG] ArrayShapeItem KeyType: {$ debugClass } | Value: {$ debugVal }\n" );
365+
366+ if ($ keyName instanceof IdentifierTypeNode) {
367+ fwrite (STDERR , "[DEBUG] IdentifierName: {$ keyName ->name }\n" );
368+ }
369+
373370 if ($ keyName instanceof ConstFetchNode && $ keyName ->className !== '' ) {
374371 $ className = $ keyName ->className ;
375372 $ constName = $ keyName ->name ;
376373 } elseif ($ keyName instanceof IdentifierTypeNode && str_contains ($ keyName ->name , ':: ' )) {
374+ // Fallback for phpstan/phpdoc-parser v1.x/v2.0 which parses constants as Identifiers
377375 [$ className , $ constName ] = explode (':: ' , $ keyName ->name , 2 );
378376 }
379377
378+ if ($ className !== null && $ constName !== null ) {
379+ fwrite (STDERR , "[DEBUG] Split into Class: {$ className } | Const: {$ constName }\n" );
380+ } else {
381+ fwrite (STDERR , "[DEBUG] Did NOT split into Class and Const. \n" );
382+ }
383+
380384 if ($ className !== null && $ constName !== null ) {
381385 $ lowerClassName = strtolower ($ className );
382386 $ declaringClass = $ ref instanceof \ReflectionMethod ? $ ref ->getDeclaringClass ()->getName () : null ;
@@ -390,9 +394,14 @@ private static function resolveArrayShape(ArrayShapeNode $node, \ReflectionClass
390394 $ resolvedClass = self ::resolveFqcn ($ className , $ ref );
391395 }
392396
397+ fwrite (STDERR , "[DEBUG] Resolved Target Class for Reflection: {$ resolvedClass }\n" );
398+
393399 $ resolvedKeyNode = self ::resolveConstantKeyValue ($ resolvedClass , $ constName );
394400 if ($ resolvedKeyNode !== null ) {
401+ fwrite (STDERR , "[DEBUG] Successfully Reflected Constant! New Value: {$ resolvedKeyNode ->value }\n" );
395402 $ keyName = $ resolvedKeyNode ;
403+ } else {
404+ fwrite (STDERR , "[DEBUG] FAILED to Reflect Constant! \n" );
396405 }
397406 }
398407
0 commit comments