@@ -182,7 +182,7 @@ public function getUnresolvedPropertyPrototype(string $propertyName, ClassMember
182
182
} else {
183
183
$ canAccessProperty = $ scope ->getClassReflection ()->getName ();
184
184
}
185
- $ description = $ this ->describeCache ( );
185
+ $ description = $ this ->describe (VerbosityLevel:: cache () );
186
186
187
187
if (isset (self ::$ properties [$ description ][$ propertyName ][$ canAccessProperty ])) {
188
188
return self ::$ properties [$ description ][$ propertyName ][$ canAccessProperty ];
@@ -321,14 +321,8 @@ public function isSuperTypeOf(Type $type): IsSuperTypeOfResult
321
321
return IsSuperTypeOfResult::createNo ();
322
322
}
323
323
324
- $ thisDescription = $ this ->describeCache ();
325
-
326
- if ($ type instanceof self) {
327
- $ description = $ type ->describeCache ();
328
- } else {
329
- $ description = $ type ->describe (VerbosityLevel::cache ());
330
- }
331
-
324
+ $ thisDescription = $ this ->describe (VerbosityLevel::cache ());
325
+ $ description = $ type ->describe (VerbosityLevel::cache ());
332
326
if (isset (self ::$ superTypes [$ thisDescription ][$ description ])) {
333
327
return self ::$ superTypes [$ thisDescription ][$ description ];
334
328
}
@@ -516,15 +510,33 @@ public function describe(VerbosityLevel $level): string
516
510
$ preciseNameCallback ,
517
511
$ preciseWithSubtracted ,
518
512
function () use ($ preciseWithSubtracted ): string {
513
+ if ($ this ->cachedDescription !== null ) {
514
+ return $ this ->cachedDescription ;
515
+ }
516
+
517
+ $ description = $ preciseWithSubtracted ();
518
+
519
+ if ($ this instanceof GenericObjectType) {
520
+ $ description .= '< ' ;
521
+ $ typeDescriptions = [];
522
+ foreach ($ this ->getTypes () as $ type ) {
523
+ $ typeDescriptions [] = $ type ->describe (VerbosityLevel::cache ());
524
+ }
525
+ $ description .= '< ' . implode (', ' , $ typeDescriptions ) . '> ' ;
526
+ }
527
+
519
528
$ reflection = $ this ->classReflection ;
520
- $ line = '' ;
521
529
if ($ reflection !== null ) {
522
- $ line .= '- ' ;
523
- $ line .= (string ) $ reflection ->getNativeReflection ()->getStartLine ();
524
- $ line .= '- ' ;
530
+ $ description .= '- ' ;
531
+ $ description .= (string ) $ reflection ->getNativeReflection ()->getStartLine ();
532
+ $ description .= '- ' ;
533
+
534
+ if ($ reflection ->hasFinalByKeywordOverride ()) {
535
+ $ description .= 'f= ' . ($ reflection ->isFinalByKeyword () ? 't ' : 'f ' );
536
+ }
525
537
}
526
538
527
- return $ preciseWithSubtracted () . ' - ' . static ::class . ' - ' . $ line . $ this ->describeAdditionalCacheKey ();
539
+ return $ this -> cachedDescription = $ description . $ this ->describeAdditionalCacheKey ();
528
540
},
529
541
);
530
542
}
@@ -534,47 +546,6 @@ protected function describeAdditionalCacheKey(): string
534
546
return '' ;
535
547
}
536
548
537
- private function describeCache (): string
538
- {
539
- if ($ this ->cachedDescription !== null ) {
540
- return $ this ->cachedDescription ;
541
- }
542
-
543
- if (static ::class !== self ::class) {
544
- return $ this ->cachedDescription = $ this ->describe (VerbosityLevel::cache ());
545
- }
546
-
547
- $ description = $ this ->className ;
548
-
549
- if ($ this instanceof GenericObjectType) {
550
- $ description .= '< ' ;
551
- $ typeDescriptions = [];
552
- foreach ($ this ->getTypes () as $ type ) {
553
- $ typeDescriptions [] = $ type ->describe (VerbosityLevel::cache ());
554
- }
555
- $ description .= '< ' . implode (', ' , $ typeDescriptions ) . '> ' ;
556
- }
557
-
558
- if ($ this ->subtractedType !== null ) {
559
- $ description .= $ this ->subtractedType instanceof UnionType
560
- ? sprintf ('~(%s) ' , $ this ->subtractedType ->describe (VerbosityLevel::cache ()))
561
- : sprintf ('~%s ' , $ this ->subtractedType ->describe (VerbosityLevel::cache ()));
562
- }
563
-
564
- $ reflection = $ this ->classReflection ;
565
- if ($ reflection !== null ) {
566
- $ description .= '- ' ;
567
- $ description .= (string ) $ reflection ->getNativeReflection ()->getStartLine ();
568
- $ description .= '- ' ;
569
-
570
- if ($ reflection ->hasFinalByKeywordOverride ()) {
571
- $ description .= 'f= ' . ($ reflection ->isFinalByKeyword () ? 't ' : 'f ' );
572
- }
573
- }
574
-
575
- return $ this ->cachedDescription = $ description ;
576
- }
577
-
578
549
public function toNumber (): Type
579
550
{
580
551
if ($ this ->isInstanceOf ('SimpleXMLElement ' )->yes ()) {
@@ -777,7 +748,7 @@ public function getUnresolvedMethodPrototype(string $methodName, ClassMemberAcce
777
748
} else {
778
749
$ canCallMethod = $ scope ->getClassReflection ()->getName ();
779
750
}
780
- $ description = $ this ->describeCache ( );
751
+ $ description = $ this ->describe (VerbosityLevel:: cache () );
781
752
if (isset (self ::$ methods [$ description ][$ methodName ][$ canCallMethod ])) {
782
753
return self ::$ methods [$ description ][$ methodName ][$ canCallMethod ];
783
754
}
@@ -1266,7 +1237,7 @@ public function getEnumCases(): array
1266
1237
return [];
1267
1238
}
1268
1239
1269
- $ cacheKey = $ this ->describeCache ( );
1240
+ $ cacheKey = $ this ->describe (VerbosityLevel:: cache () );
1270
1241
if (array_key_exists ($ cacheKey , self ::$ enumCases )) {
1271
1242
return self ::$ enumCases [$ cacheKey ];
1272
1243
}
@@ -1529,7 +1500,7 @@ public function getAncestorWithClassName(string $className): ?self
1529
1500
return $ this ->currentAncestors [$ className ];
1530
1501
}
1531
1502
1532
- $ description = $ this ->describeCache ( );
1503
+ $ description = $ this ->describe (VerbosityLevel:: cache () );
1533
1504
if (
1534
1505
array_key_exists ($ description , self ::$ ancestors )
1535
1506
&& array_key_exists ($ className , self ::$ ancestors [$ description ])
0 commit comments