@@ -524,46 +524,20 @@ private function resolveType(Expr $node): Type
524524 return new NeverType (true );
525525 }
526526
527- if (
528- $ node instanceof Expr \BinaryOp \Greater
529- || $ node instanceof Expr \BinaryOp \GreaterOrEqual
530- || $ node instanceof Expr \BinaryOp \Smaller
531- || $ node instanceof Expr \BinaryOp \SmallerOrEqual
532- ) {
533- $ leftType = $ this ->getType ($ node ->left );
534- $ rightType = $ this ->getType ($ node ->right );
535-
536- if ($ rightType instanceof ConstantIntegerType) {
537- $ rightValue = $ rightType ->getValue ();
538-
539- if ($ node instanceof Expr \BinaryOp \Greater) {
540- $ rightIntervalType = IntegerRangeType::fromInterval ($ rightValue + 1 , null );
541- } elseif ($ node instanceof Expr \BinaryOp \GreaterOrEqual) {
542- $ rightIntervalType = IntegerRangeType::fromInterval ($ rightValue , null );
543- } elseif ($ node instanceof Expr \BinaryOp \Smaller) {
544- $ rightIntervalType = IntegerRangeType::fromInterval (null , $ rightValue - 1 );
545- } else {
546- $ rightIntervalType = IntegerRangeType::fromInterval (null , $ rightValue );
547- }
548-
549- return $ rightIntervalType ->isSuperTypeOf ($ leftType ->toInteger ())->toBooleanType ();
550- } elseif ($ leftType instanceof ConstantIntegerType) {
551- $ leftValue = $ leftType ->getValue ();
527+ if ($ node instanceof Expr \BinaryOp \Smaller) {
528+ return $ this ->getType ($ node ->left )->isSmallerThan ($ this ->getType ($ node ->right ))->toBooleanType ();
529+ }
552530
553- if ($ node instanceof Expr \BinaryOp \Smaller) {
554- $ leftIntervalType = IntegerRangeType::fromInterval ($ leftValue + 1 , null );
555- } elseif ($ node instanceof Expr \BinaryOp \SmallerOrEqual) {
556- $ leftIntervalType = IntegerRangeType::fromInterval ($ leftValue , null );
557- } elseif ($ node instanceof Expr \BinaryOp \Greater) {
558- $ leftIntervalType = IntegerRangeType::fromInterval (null , $ leftValue - 1 );
559- } else {
560- $ leftIntervalType = IntegerRangeType::fromInterval (null , $ leftValue );
561- }
531+ if ($ node instanceof Expr \BinaryOp \SmallerOrEqual) {
532+ return $ this ->getType ($ node ->left )->isSmallerThan ($ this ->getType ($ node ->right ), true )->toBooleanType ();
533+ }
562534
563- return $ leftIntervalType ->isSuperTypeOf ($ rightType ->toInteger ())->toBooleanType ();
564- }
535+ if ($ node instanceof Expr \BinaryOp \Greater) {
536+ return $ this ->getType ($ node ->right )->isSmallerThan ($ this ->getType ($ node ->left ))->toBooleanType ();
537+ }
565538
566- return new BooleanType ();
539+ if ($ node instanceof Expr \BinaryOp \GreaterOrEqual) {
540+ return $ this ->getType ($ node ->right )->isSmallerThan ($ this ->getType ($ node ->left ), true )->toBooleanType ();
567541 }
568542
569543 if (
0 commit comments