@@ -304,50 +304,53 @@ public function equals(Type $type): bool
304304 public function describe (VerbosityLevel $ level ): string
305305 {
306306 return $ level ->handle (
307- function () use ($ level ): string {
308- $ typeNames = [];
309- $ isList = $ this ->isList ()->yes ();
310- $ valueType = null ;
311- foreach ($ this ->getSortedTypes () as $ type ) {
312- if ($ isList ) {
313- if ($ type instanceof ArrayType || $ type instanceof ConstantArrayType) {
314- $ valueType = $ type ->getIterableValueType ();
315- continue ;
316- }
317- if ($ type instanceof NonEmptyArrayType) {
318- continue ;
319- }
320- }
321- if ($ type instanceof AccessoryType) {
322- continue ;
323- }
324- $ typeNames [] = $ type ->generalize (GeneralizePrecision::lessSpecific ())->describe ($ level );
307+ fn (): string => $ this ->describeType ($ level ),
308+ fn (): string => $ this ->describeItself ($ level , true ),
309+ fn (): string => $ this ->describeItself ($ level , false ),
310+ );
311+ }
312+
313+ private function describeType (VerbosityLevel $ level ): string
314+ {
315+ $ typeNames = [];
316+ $ isList = $ this ->isList ()->yes ();
317+ $ valueType = null ;
318+ foreach ($ this ->getSortedTypes () as $ type ) {
319+ if ($ isList ) {
320+ if ($ type instanceof ArrayType || $ type instanceof ConstantArrayType) {
321+ $ valueType = $ type ->getIterableValueType ();
322+ continue ;
325323 }
324+ if ($ type instanceof NonEmptyArrayType) {
325+ continue ;
326+ }
327+ }
328+ if ($ type instanceof AccessoryType) {
329+ continue ;
330+ }
331+ $ typeNames [] = $ type ->generalize (GeneralizePrecision::lessSpecific ())->describe ($ level );
332+ }
326333
327- if ($ isList ) {
328- $ isMixedValueType = $ valueType instanceof MixedType && $ valueType ->describe (VerbosityLevel::precise ()) === 'mixed ' && !$ valueType ->isExplicitMixed ();
329- $ innerType = '' ;
330- if ($ valueType !== null && !$ isMixedValueType ) {
331- $ innerType = sprintf ('<%s> ' , $ valueType ->describe ($ level ));
332- }
334+ if ($ isList ) {
335+ $ isMixedValueType = $ valueType instanceof MixedType && $ valueType ->describe (VerbosityLevel::precise ()) === 'mixed ' && !$ valueType ->isExplicitMixed ();
336+ $ innerType = '' ;
337+ if ($ valueType !== null && !$ isMixedValueType ) {
338+ $ innerType = sprintf ('<%s> ' , $ valueType ->describe ($ level ));
339+ }
333340
334- $ typeNames [] = 'list ' . $ innerType ;
335- }
341+ $ typeNames [] = 'list ' . $ innerType ;
342+ }
336343
337- usort ($ typeNames , static function ($ a , $ b ) {
338- $ cmp = strcasecmp ($ a , $ b );
339- if ($ cmp !== 0 ) {
340- return $ cmp ;
341- }
344+ usort ($ typeNames , static function ($ a , $ b ) {
345+ $ cmp = strcasecmp ($ a , $ b );
346+ if ($ cmp !== 0 ) {
347+ return $ cmp ;
348+ }
342349
343- return $ a <=> $ b ;
344- });
350+ return $ a <=> $ b ;
351+ });
345352
346- return implode ('& ' , $ typeNames );
347- },
348- fn (): string => $ this ->describeItself ($ level , true ),
349- fn (): string => $ this ->describeItself ($ level , false ),
350- );
353+ return implode ('& ' , $ typeNames );
351354 }
352355
353356 private function describeItself (VerbosityLevel $ level , bool $ skipAccessoryTypes ): string
0 commit comments