@@ -112,8 +112,8 @@ function doFoo(int $intA, int $intB, string $s, bool $bool, $numericS, float $fl
112
112
assertType ('int ' , pow ($ intA , 1 ));
113
113
assertType ('int ' , $ intA ** '1 ' );
114
114
115
- assertType ('(float|int) ' , pow ($ intA , $ s ));
116
- assertType ('(float|int) ' , $ intA ** $ s );
115
+ assertType ('*ERROR* ' , pow ($ intA , $ s ));
116
+ assertType ('*ERROR* ' , $ intA ** $ s );
117
117
118
118
assertType ('(float|int) ' , pow ($ intA , $ bool )); // could be int
119
119
assertType ('(float|int) ' , $ intA ** $ bool ); // could be int
@@ -161,11 +161,11 @@ function doFoo(int $intA, int $intB, string $s, bool $bool, $numericS, float $fl
161
161
162
162
assertType ('NAN ' , pow (-1 ,5.5 ));
163
163
164
- assertType ('1 ' , pow ($ s , 0 ));
165
- assertType ('1 ' , $ s ** '0 ' );
166
- assertType ('1 ' , $ s ** false );
167
- assertType ('(float|int) ' , pow ($ s , 1 ));
168
- assertType ('(float|int) ' , $ s ** '1 ' );
164
+ assertType ('*ERROR* ' , pow ($ s , 0 ));
165
+ assertType ('*ERROR* ' , $ s ** '0 ' );
166
+ assertType ('*ERROR* ' , $ s ** false );
167
+ assertType ('*ERROR* ' , pow ($ s , 1 ));
168
+ assertType ('*ERROR* ' , $ s ** '1 ' );
169
169
assertType ('*ERROR* ' , $ s ** $ arr );
170
170
assertType ('*ERROR* ' , $ s ** []);
171
171
@@ -177,3 +177,23 @@ function doFoo(int $intA, int $intB, string $s, bool $bool, $numericS, float $fl
177
177
assertType ('*ERROR* ' , $ bool ** $ arr );
178
178
assertType ('*ERROR* ' , $ bool ** []);
179
179
};
180
+
181
+ function invalidConstantOperands (): void {
182
+ assertType ('*ERROR* ' , 'a ' ** 1 );
183
+ assertType ('*ERROR* ' , 1 ** 'a ' );
184
+
185
+ assertType ('*ERROR* ' , [] ** 1 );
186
+ assertType ('*ERROR* ' , 1 ** []);
187
+
188
+ assertType ('*ERROR* ' , (new \stdClass ()) ** 1 );
189
+ assertType ('*ERROR* ' , 1 ** (new \stdClass ()));
190
+ }
191
+
192
+ function validConstantOperands (): void {
193
+ assertType ('1 ' , '1 ' ** 1 );
194
+ assertType ('1 ' , 1 ** '1 ' );
195
+ assertType ('1 ' , '1 ' ** '1 ' );
196
+
197
+ assertType ('1 ' , true ** 1 );
198
+ assertType ('1 ' , 1 ** false );
199
+ }
0 commit comments