Refactoring for PHP8.2

This commit is contained in:
2023-08-01 11:26:38 +00:00
parent 5dd4acf57d
commit 068b6f18aa
18 changed files with 375 additions and 782 deletions

View File

@@ -11,21 +11,21 @@ use Exception;
*/
class Guard
{
public static function argumentNotNull($value, $parameterName)
public static function argumentNotNull(mixed $value, string $parameterName): void
{
if ($value == null) {
throw new Exception($parameterName.' can not be null');
}
}
public static function argumentIsValidIndex($index, $count, $parameterName)
public static function argumentIsValidIndex(int $index, int $count, string $parameterName): void
{
if (($index < 0) || ($index >= $count)) {
throw new Exception($parameterName.' is an invalid index');
}
}
public static function argumentInRangeInclusive($value, $min, $max, $parameterName)
public static function argumentInRangeInclusive(float $value, float $min, float $max, string $parameterName): void
{
if (($value < $min) || ($value > $max)) {
throw new Exception($parameterName.' is not in the valid range ['.$min.', '.$max.']');