@@ -43,9 +43,21 @@ public function test3() {
4343 /**
4444 * @psalm-param int<-4, 42> $rangedOne
4545 * @psalm-param int<min, max> $rangedTwo
46+ * @psalm-param int<1, 6>|null $rangedThree
47+ * @psalm-param ?int<-70, -30> $rangedFour
4648 * @return void
4749 */
48- public function test4 (int $ rangedOne , int $ rangedTwo ) {
50+ public function test4 (int $ rangedOne , int $ rangedTwo , ?int $ rangedThree , ?int $ rangedFour ) {
51+ }
52+
53+ /**
54+ * @param int<-4, 42> $rangedOne
55+ * @param int<min, max> $rangedTwo
56+ * @param int<1, 6>|null $rangedThree
57+ * @param ?int<-70, -30> $rangedFour
58+ * @return void
59+ */
60+ public function test5 (int $ rangedOne , int $ rangedTwo , ?int $ rangedThree , ?int $ rangedFour ) {
4961 }
5062}
5163
@@ -132,9 +144,6 @@ public function testReadTypeIntAnnotations(): void {
132144 public function arguments3 ($ a , float $ b , int $ c , $ d ) {
133145 }
134146
135- /**
136- * @requires PHP 7
137- */
138147 public function testReadTypeIntAnnotationsScalarTypes (): void {
139148 $ reader = new ControllerMethodReflector ();
140149 $ reader ->reflect (
@@ -228,7 +237,7 @@ public function testInheritanceOverrideNoDocblock(): void {
228237 $ this ->assertFalse ($ reader ->hasAnnotation ('Annotation ' ));
229238 }
230239
231- public function testRangeDetection (): void {
240+ public function testRangeDetectionPsalm (): void {
232241 $ reader = new ControllerMethodReflector ();
233242 $ reader ->reflect ('Test\AppFramework\Utility\EndController ' , 'test4 ' );
234243
@@ -239,5 +248,34 @@ public function testRangeDetection(): void {
239248 $ rangeInfo2 = $ reader ->getRange ('rangedTwo ' );
240249 $ this ->assertSame (PHP_INT_MIN , $ rangeInfo2 ['min ' ]);
241250 $ this ->assertSame (PHP_INT_MAX , $ rangeInfo2 ['max ' ]);
251+
252+ $ rangeInfo3 = $ reader ->getRange ('rangedThree ' );
253+ $ this ->assertSame (1 , $ rangeInfo3 ['min ' ]);
254+ $ this ->assertSame (6 , $ rangeInfo3 ['max ' ]);
255+
256+ $ rangeInfo3 = $ reader ->getRange ('rangedFour ' );
257+ $ this ->assertSame (-70 , $ rangeInfo3 ['min ' ]);
258+ $ this ->assertSame (-30 , $ rangeInfo3 ['max ' ]);
259+ }
260+
261+ public function testRangeDetectionNative (): void {
262+ $ reader = new ControllerMethodReflector ();
263+ $ reader ->reflect ('Test\AppFramework\Utility\EndController ' , 'test5 ' );
264+
265+ $ rangeInfo1 = $ reader ->getRange ('rangedOne ' );
266+ $ this ->assertSame (-4 , $ rangeInfo1 ['min ' ]);
267+ $ this ->assertSame (42 , $ rangeInfo1 ['max ' ]);
268+
269+ $ rangeInfo2 = $ reader ->getRange ('rangedTwo ' );
270+ $ this ->assertSame (PHP_INT_MIN , $ rangeInfo2 ['min ' ]);
271+ $ this ->assertSame (PHP_INT_MAX , $ rangeInfo2 ['max ' ]);
272+
273+ $ rangeInfo3 = $ reader ->getRange ('rangedThree ' );
274+ $ this ->assertSame (1 , $ rangeInfo3 ['min ' ]);
275+ $ this ->assertSame (6 , $ rangeInfo3 ['max ' ]);
276+
277+ $ rangeInfo3 = $ reader ->getRange ('rangedFour ' );
278+ $ this ->assertSame (-70 , $ rangeInfo3 ['min ' ]);
279+ $ this ->assertSame (-30 , $ rangeInfo3 ['max ' ]);
242280 }
243281}
0 commit comments