@@ -494,50 +494,56 @@ private static function compareTypesInUnion(Type $a, Type $b): ?array
494494
495495 if (
496496 $ a instanceof ConstantStringType
497- && $ a ->getValue () === ''
498- && ($ b ->describe (VerbosityLevel::value ()) === 'non-empty-string '
499- || $ b ->describe (VerbosityLevel::value ()) === 'non-falsy-string ' )
500497 ) {
501- return [null , self ::intersect (
502- new StringType (),
503- ...self ::getAccessoryCaseStringTypes ($ b ),
504- )];
505- }
506-
507- if (
508- $ b instanceof ConstantStringType
509- && $ b ->getValue () === ''
510- && ($ a ->describe (VerbosityLevel::value ()) === 'non-empty-string '
511- || $ a ->describe (VerbosityLevel::value ()) === 'non-falsy-string ' )
512- ) {
513- return [self ::intersect (
514- new StringType (),
515- ...self ::getAccessoryCaseStringTypes ($ a ),
516- ), null ];
517- }
518-
519- if (
520- $ a instanceof ConstantStringType
521- && $ a ->getValue () === '0 '
522- && $ b ->describe (VerbosityLevel::value ()) === 'non-falsy-string '
523- ) {
524- return [null , self ::intersect (
525- new StringType (),
526- new AccessoryNonEmptyStringType (),
527- ...self ::getAccessoryCaseStringTypes ($ b ),
528- )];
498+ $ description = $ b ->describe (VerbosityLevel::value ());
499+ if (
500+ $ a ->getValue () === ''
501+ && ($ description === 'non-empty-string '
502+ || $ description === 'non-falsy-string ' )
503+ ) {
504+ return [null , self ::intersect (
505+ new StringType (),
506+ ...self ::getAccessoryCaseStringTypes ($ b ),
507+ )];
508+ }
509+
510+ if (
511+ $ a ->getValue () === '0 '
512+ && $ description === 'non-falsy-string '
513+ ) {
514+ return [null , self ::intersect (
515+ new StringType (),
516+ new AccessoryNonEmptyStringType (),
517+ ...self ::getAccessoryCaseStringTypes ($ b ),
518+ )];
519+ }
529520 }
530521
531522 if (
532523 $ b instanceof ConstantStringType
533- && $ b ->getValue () === '0 '
534- && $ a ->describe (VerbosityLevel::value ()) === 'non-falsy-string '
535524 ) {
536- return [self ::intersect (
537- new StringType (),
538- new AccessoryNonEmptyStringType (),
539- ...self ::getAccessoryCaseStringTypes ($ a ),
540- ), null ];
525+ $ description = $ a ->describe (VerbosityLevel::value ());
526+ if (
527+ $ b ->getValue () === ''
528+ && ($ description === 'non-empty-string '
529+ || $ description === 'non-falsy-string ' )
530+ ) {
531+ return [self ::intersect (
532+ new StringType (),
533+ ...self ::getAccessoryCaseStringTypes ($ a ),
534+ ), null ];
535+ }
536+
537+ if (
538+ $ b ->getValue () === '0 '
539+ && $ description === 'non-falsy-string '
540+ ) {
541+ return [self ::intersect (
542+ new StringType (),
543+ new AccessoryNonEmptyStringType (),
544+ ...self ::getAccessoryCaseStringTypes ($ a ),
545+ ), null ];
546+ }
541547 }
542548
543549 return null ;
0 commit comments