Commit a7b2630
Implement GMP operator type specifying extension
Add GmpOperatorTypeSpecifyingExtension to properly infer return types
for GMP operator overloads. GMP supports arithmetic (+, -, *, /, %, **),
bitwise (&, |, ^, ~, <<, >>), and comparison (<, <=, >, >=, ==, !=, <=>)
operators.
The extension only claims support when both operands are GMP-compatible
(GMP, int, or numeric-string). Operations with incompatible types like
stdClass are left to the default type inference.
Also update InitializerExprTypeResolver to call operator extensions
early for object types in resolveCommonMath and bitwise methods, and
add explicit GMP handling for unary operators (-$a, ~$a).
Fixes phpstan/phpstan#14288
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent 16c6f82 commit a7b2630
File tree
3 files changed
+123
-3
lines changed- src
- Reflection
- Type/Php
- tests/PHPStan/Analyser/nsrt
3 files changed
+123
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
986 | 986 | | |
987 | 987 | | |
988 | 988 | | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
989 | 997 | | |
990 | 998 | | |
991 | 999 | | |
| |||
1044 | 1052 | | |
1045 | 1053 | | |
1046 | 1054 | | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
1047 | 1063 | | |
1048 | 1064 | | |
1049 | 1065 | | |
| |||
1092 | 1108 | | |
1093 | 1109 | | |
1094 | 1110 | | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
1095 | 1119 | | |
1096 | 1120 | | |
1097 | 1121 | | |
| |||
2034 | 2058 | | |
2035 | 2059 | | |
2036 | 2060 | | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
2037 | 2072 | | |
2038 | 2073 | | |
2039 | 2074 | | |
| |||
2581 | 2616 | | |
2582 | 2617 | | |
2583 | 2618 | | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
2584 | 2624 | | |
2585 | 2625 | | |
2586 | 2626 | | |
| |||
2622 | 2662 | | |
2623 | 2663 | | |
2624 | 2664 | | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
2625 | 2670 | | |
2626 | 2671 | | |
2627 | 2672 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
170 | | - | |
171 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
| |||
0 commit comments