@@ -1763,6 +1763,7 @@ private function resolveType(Expr $node): Type
1763
1763
} elseif ($ node instanceof Expr \PreInc || $ node instanceof Expr \PreDec) {
1764
1764
$ varType = $ this ->getType ($ node ->var );
1765
1765
$ varScalars = TypeUtils::getConstantScalars ($ varType );
1766
+ $ stringType = new StringType ();
1766
1767
if (count ($ varScalars ) > 0 ) {
1767
1768
$ newTypes = [];
1768
1769
@@ -1777,19 +1778,18 @@ private function resolveType(Expr $node): Type
1777
1778
$ newTypes [] = $ this ->getTypeFromValue ($ varValue );
1778
1779
}
1779
1780
return TypeCombinator::union (...$ newTypes );
1780
- } elseif ($ varType instanceof IntegerRangeType) {
1781
- return $ varType ->shift ($ node instanceof Expr \PreInc ? +1 : -1 );
1782
- }
1783
-
1784
- $ stringType = new StringType ();
1785
- if ($ stringType ->isSuperTypeOf ($ varType )->yes ()) {
1781
+ } elseif ($ stringType ->isSuperTypeOf ($ varType )->yes ()) {
1786
1782
if ($ varType ->isLiteralString ()->yes ()) {
1787
1783
return new IntersectionType ([$ stringType , new AccessoryLiteralStringType ()]);
1788
1784
}
1789
1785
return $ stringType ;
1790
1786
}
1791
1787
1792
- return $ varType ->toNumber ();
1788
+ if ($ node instanceof Expr \PreInc) {
1789
+ return $ this ->getType (new BinaryOp \Plus ($ node ->var , new LNumber (1 )));
1790
+ }
1791
+
1792
+ return $ this ->getType (new BinaryOp \Minus ($ node ->var , new LNumber (1 )));
1793
1793
} elseif ($ node instanceof Expr \Yield_) {
1794
1794
$ functionReflection = $ this ->getFunction ();
1795
1795
if ($ functionReflection === null ) {
0 commit comments