@@ -4100,24 +4100,30 @@ private function generalizeType(Type $a, Type $b, int $depth): Type
41004100
41014101 $ gotGreater = false ;
41024102 $ gotSmaller = false ;
4103- $ newMin = $ min ;
4104- $ newMax = $ max ;
41054103 foreach ($ constantIntegers ['b ' ] as $ int ) {
41064104 if ($ int ->getValue () > $ max ) {
41074105 $ gotGreater = true ;
41084106 }
4109- if ($ int ->getValue () < $ min ) {
4110- $ gotSmaller = true ;
4111- }
4112- if ($ int ->getValue () < $ newMin ) {
4113- $ newMin = $ int ->getValue ();
4114- }
4115- if ($ int ->getValue () > $ newMax ) {
4116- $ newMax = $ int ->getValue ();
4107+ if ($ int ->getValue () >= $ min ) {
4108+ continue ;
41174109 }
4110+
4111+ $ gotSmaller = true ;
41184112 }
41194113
41204114 if ($ gotGreater && $ gotSmaller ) {
4115+ $ newMin = $ min ;
4116+ $ newMax = $ max ;
4117+ foreach ($ constantIntegers ['b ' ] as $ int ) {
4118+ if ($ int ->getValue () < $ newMin ) {
4119+ $ newMin = $ int ->getValue ();
4120+ }
4121+ if ($ int ->getValue () <= $ newMax ) {
4122+ continue ;
4123+ }
4124+
4125+ $ newMax = $ int ->getValue ();
4126+ }
41214127 $ resultTypes [] = IntegerRangeType::fromInterval ($ newMin , $ newMax );
41224128 } elseif ($ gotGreater ) {
41234129 $ resultTypes [] = IntegerRangeType::fromInterval ($ min , null );
@@ -4168,8 +4174,6 @@ private function generalizeType(Type $a, Type $b, int $depth): Type
41684174
41694175 $ gotGreater = false ;
41704176 $ gotSmaller = false ;
4171- $ newMin = $ min ;
4172- $ newMax = $ max ;
41734177 foreach ($ integerRanges ['b ' ] as $ range ) {
41744178 if ($ range ->getMin () === null ) {
41754179 $ rangeMin = PHP_INT_MIN ;
@@ -4185,15 +4189,11 @@ private function generalizeType(Type $a, Type $b, int $depth): Type
41854189 if ($ rangeMax > $ max ) {
41864190 $ gotGreater = true ;
41874191 }
4188- if ($ rangeMin < $ min ) {
4189- $ gotSmaller = true ;
4190- }
4191- if ($ rangeMin < $ newMin ) {
4192- $ newMin = $ rangeMin ;
4193- }
4194- if ($ rangeMax > $ newMax ) {
4195- $ newMax = $ rangeMax ;
4192+ if ($ rangeMin >= $ min ) {
4193+ continue ;
41964194 }
4195+
4196+ $ gotSmaller = true ;
41974197 }
41984198
41994199 if ($ min === PHP_INT_MIN ) {
@@ -4202,15 +4202,9 @@ private function generalizeType(Type $a, Type $b, int $depth): Type
42024202 if ($ max === PHP_INT_MAX ) {
42034203 $ max = null ;
42044204 }
4205- if ($ newMin === PHP_INT_MIN ) {
4206- $ newMin = null ;
4207- }
4208- if ($ newMax === PHP_INT_MAX ) {
4209- $ newMax = null ;
4210- }
42114205
42124206 if ($ gotGreater && $ gotSmaller ) {
4213- $ resultTypes [] = IntegerRangeType:: fromInterval ( $ newMin , $ newMax );
4207+ $ resultTypes [] = new IntegerType ( );
42144208 } elseif ($ gotGreater ) {
42154209 $ resultTypes [] = IntegerRangeType::fromInterval ($ min , null );
42164210 } elseif ($ gotSmaller ) {
0 commit comments