77use PHPStan \Type \Constant \ConstantFloatType ;
88use PHPStan \Type \Constant \ConstantIntegerType ;
99use PHPStan \Type \Constant \ConstantStringType ;
10+ use PHPStan \Type \Enum \EnumCaseObjectType ;
1011use function count ;
1112use function strcasecmp ;
1213use function usort ;
@@ -96,6 +97,20 @@ public static function sortTypes(array $types): array
9697 return self ::compareStrings ($ a ->getValue (), $ b ->getValue ());
9798 }
9899
100+ if ($ a instanceof EnumCaseObjectType && $ b instanceof EnumCaseObjectType) {
101+ return self ::compareStrings (
102+ $ a ->getClassName () . ':: ' . $ a ->getEnumCaseName (),
103+ $ b ->getClassName () . ':: ' . $ b ->getEnumCaseName (),
104+ );
105+ }
106+
107+ if (
108+ ($ a instanceof CallableType || $ a instanceof ClosureType)
109+ && ($ b instanceof CallableType || $ b instanceof ClosureType)
110+ ) {
111+ return self ::compareStrings ($ a ->describe (VerbosityLevel::value ()), $ b ->describe (VerbosityLevel::value ()));
112+ }
113+
99114 if ($ a ->isConstantArray ()->yes () && $ b ->isConstantArray ()->yes ()) {
100115 if ($ a ->isIterableAtLeastOnce ()->no ()) {
101116 if ($ b ->isIterableAtLeastOnce ()->no ()) {
@@ -110,13 +125,6 @@ public static function sortTypes(array $types): array
110125 return self ::compareStrings ($ a ->describe (VerbosityLevel::value ()), $ b ->describe (VerbosityLevel::value ()));
111126 }
112127
113- if (
114- ($ a instanceof CallableType || $ a instanceof ClosureType)
115- && ($ b instanceof CallableType || $ b instanceof ClosureType)
116- ) {
117- return self ::compareStrings ($ a ->describe (VerbosityLevel::value ()), $ b ->describe (VerbosityLevel::value ()));
118- }
119-
120128 if ($ a ->isString ()->yes () && $ b ->isString ()->yes ()) {
121129 return self ::compareStrings ($ a ->describe (VerbosityLevel::precise ()), $ b ->describe (VerbosityLevel::precise ()));
122130 }
0 commit comments