@@ -82,6 +82,9 @@ class ClassReflection
82
82
/** @var ClassConstantReflection[] */
83
83
private array $ constants = [];
84
84
85
+ /** @var EnumCaseReflection[]|null */
86
+ private ?array $ enumCases = null ;
87
+
85
88
/** @var int[]|null */
86
89
private ?array $ classHierarchyDistances = null ;
87
90
@@ -752,6 +755,10 @@ public function getEnumCases(): array
752
755
throw new ShouldNotHappenException ();
753
756
}
754
757
758
+ if ($ this ->enumCases !== null ) {
759
+ return $ this ->enumCases ;
760
+ }
761
+
755
762
$ cases = [];
756
763
$ initializerExprContext = InitializerExprContext::fromClassReflection ($ this );
757
764
foreach ($ this ->reflection ->getCases () as $ case ) {
@@ -764,7 +771,7 @@ public function getEnumCases(): array
764
771
$ cases [$ caseName ] = new EnumCaseReflection ($ this , $ caseName , $ valueType );
765
772
}
766
773
767
- return $ cases ;
774
+ return $ this -> enumCases = $ cases ;
768
775
}
769
776
770
777
public function getEnumCase (string $ name ): EnumCaseReflection
@@ -777,6 +784,10 @@ public function getEnumCase(string $name): EnumCaseReflection
777
784
throw new ShouldNotHappenException ();
778
785
}
779
786
787
+ if ($ this ->enumCases !== null && array_key_exists ($ name , $ this ->enumCases )) {
788
+ return $ this ->enumCases [$ name ];
789
+ }
790
+
780
791
$ case = $ this ->reflection ->getCase ($ name );
781
792
$ valueType = null ;
782
793
if ($ case instanceof ReflectionEnumBackedCase) {
0 commit comments