mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Forbid min bound greater than max bound in int range
This commit is contained in:
parent
a7e98f4bfc
commit
9beb0a62b2
@ -863,6 +863,10 @@ class TypeParser
|
|||||||
return new TPositiveInt();
|
return new TPositiveInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_int($min_bound) && is_int($max_bound) && $min_bound > $max_bound) {
|
||||||
|
throw new TypeParseTreeException("Min bound can't be greater than max bound");
|
||||||
|
}
|
||||||
|
|
||||||
return new TIntRange($min_bound, $max_bound);
|
return new TIntRange($min_bound, $max_bound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -798,6 +798,16 @@ class IntRangeTest extends TestCase
|
|||||||
}',
|
}',
|
||||||
'error_message' => 'InvalidDocblock',
|
'error_message' => 'InvalidDocblock',
|
||||||
],
|
],
|
||||||
|
'minGreaterThanMax' => [
|
||||||
|
'<?php
|
||||||
|
/**
|
||||||
|
* @param int<4, 3> $a
|
||||||
|
*/
|
||||||
|
function scope(int $a){
|
||||||
|
return $a;
|
||||||
|
}',
|
||||||
|
'error_message' => 'InvalidDocblock',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user