diff --git a/src/Assert.php b/src/Assert.php index 7058112..5cc1664 100644 --- a/src/Assert.php +++ b/src/Assert.php @@ -39,18 +39,22 @@ class Assert * * @psalm-assert string $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function string($value, $message = '') { if (!\is_string($value)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected a string. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : \sprintf( + $message ?: 'Expected a string. Got: %s', + static::typeToString($value) + ) + ); } } @@ -59,8 +63,8 @@ public static function string($value, $message = '') * * @psalm-assert non-empty-string $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -75,18 +79,22 @@ public static function stringNotEmpty($value, $message = '') * * @psalm-assert int $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function integer($value, $message = '') { if (!\is_int($value)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected an integer. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected an integer. Got: %s', + static::typeToString($value) + ) + ); } } @@ -95,18 +103,22 @@ public static function integer($value, $message = '') * * @psalm-assert numeric $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function integerish($value, $message = '') { if (!\is_numeric($value) || $value != (int) $value) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected an integerish value. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected an integerish value. Got: %s', + static::typeToString($value) + ) + ); } } @@ -135,18 +147,22 @@ public static function positiveInteger($value, $message = '') * * @psalm-assert float $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function float($value, $message = '') { if (!\is_float($value)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected a float. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected a float. Got: %s', + static::typeToString($value) + ) + ); } } @@ -155,18 +171,22 @@ public static function float($value, $message = '') * * @psalm-assert numeric $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function numeric($value, $message = '') { if (!\is_numeric($value)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected a numeric. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected a numeric. Got: %s', + static::typeToString($value) + ) + ); } } @@ -175,8 +195,8 @@ public static function numeric($value, $message = '') * * @psalm-assert positive-int|0 $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -195,18 +215,22 @@ public static function natural($value, $message = '') * * @psalm-assert bool $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function boolean($value, $message = '') { if (!\is_bool($value)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected a boolean. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected a boolean. Got: %s', + static::typeToString($value) + ) + ); } } @@ -215,18 +239,22 @@ public static function boolean($value, $message = '') * * @psalm-assert scalar $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function scalar($value, $message = '') { if (!\is_scalar($value)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected a scalar. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected a scalar. Got: %s', + static::typeToString($value) + ) + ); } } @@ -235,18 +263,22 @@ public static function scalar($value, $message = '') * * @psalm-assert object $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function object($value, $message = '') { if (!\is_object($value)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected an object. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected an object. Got: %s', + static::typeToString($value) + ) + ); } } @@ -264,11 +296,14 @@ public static function object($value, $message = '') public static function resource($value, $type = null, $message = '') { if (!\is_resource($value)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected a resource. Got: %s', - static::typeToString($value), - $type // User supplied message might include the second placeholder. - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected a resource. Got: %s', + static::typeToString($value), + $type // User supplied message might include the second placeholder.) + ); } if ($type && $type !== \get_resource_type($value)) { @@ -285,18 +320,22 @@ public static function resource($value, $type = null, $message = '') * * @psalm-assert callable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function isCallable($value, $message = '') { if (!\is_callable($value)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected a callable. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected a callable. Got: %s', + static::typeToString($value) + ) + ); } } @@ -305,18 +344,22 @@ public static function isCallable($value, $message = '') * * @psalm-assert array $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function isArray($value, $message = '') { if (!\is_array($value)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected an array. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected an array. Got: %s', + static::typeToString($value) + ) + ); } } @@ -327,8 +370,8 @@ public static function isArray($value, $message = '') * * @deprecated use "isIterable" or "isInstanceOf" instead * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -343,10 +386,14 @@ public static function isTraversable($value, $message = '') ); if (!\is_array($value) && !($value instanceof Traversable)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected a traversable. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected a traversable. Got: %s', + static::typeToString($value) + ) + ); } } @@ -355,18 +402,22 @@ public static function isTraversable($value, $message = '') * * @psalm-assert array|ArrayAccess $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function isArrayAccessible($value, $message = '') { if (!\is_array($value) && !($value instanceof ArrayAccess)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected an array accessible. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected an array accessible. Got: %s', + static::typeToString($value) + ) + ); } } @@ -375,8 +426,8 @@ public static function isArrayAccessible($value, $message = '') * * @psalm-assert countable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -388,10 +439,14 @@ public static function isCountable($value, $message = '') && !($value instanceof ResourceBundle) && !($value instanceof SimpleXMLElement) ) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected a countable. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected a countable. Got: %s', + static::typeToString($value) + ) + ); } } @@ -400,18 +455,22 @@ public static function isCountable($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function isIterable($value, $message = '') { if (!\is_array($value) && !($value instanceof Traversable)) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected an iterable. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected an iterable. Got: %s', + static::typeToString($value) + ) + ); } } @@ -583,8 +642,8 @@ public static function isAnyOf($value, array $classes, $message = '') * * @psalm-assert empty $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -603,8 +662,8 @@ public static function isEmpty($value, $message = '') * * @psalm-assert !empty $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -623,8 +682,8 @@ public static function notEmpty($value, $message = '') * * @psalm-assert null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -643,8 +702,8 @@ public static function null($value, $message = '') * * @psalm-assert !null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -662,8 +721,8 @@ public static function notNull($value, $message = '') * * @psalm-assert true $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -682,8 +741,8 @@ public static function true($value, $message = '') * * @psalm-assert false $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -702,8 +761,8 @@ public static function false($value, $message = '') * * @psalm-assert !false $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -717,8 +776,8 @@ public static function notFalse($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -733,8 +792,8 @@ public static function ip($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -749,8 +808,8 @@ public static function ipv4($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -765,8 +824,8 @@ public static function ipv6($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -783,8 +842,7 @@ public static function email($value, $message = '') /** * Does non strict comparisons on the items, so ['3', 3] will not pass the assertion. * - * @param array $values - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -805,9 +863,9 @@ public static function uniqueValues(array $values, $message = '') } /** - * @param mixed $value + * @param mixed $value * @param mixed $expect - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -823,9 +881,9 @@ public static function eq($value, $expect, $message = '') } /** - * @param mixed $value + * @param mixed $value * @param mixed $expect - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -842,9 +900,9 @@ public static function notEq($value, $expect, $message = '') /** * @psalm-pure * - * @param mixed $value + * @param mixed $value * @param mixed $expect - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -862,9 +920,9 @@ public static function same($value, $expect, $message = '') /** * @psalm-pure * - * @param mixed $value + * @param mixed $value * @param mixed $expect - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -881,9 +939,9 @@ public static function notSame($value, $expect, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $limit - * @param string $message + * @param mixed $value + * @param mixed $limit + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -901,9 +959,9 @@ public static function greaterThan($value, $limit, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $limit - * @param string $message + * @param mixed $value + * @param mixed $limit + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -921,9 +979,9 @@ public static function greaterThanEq($value, $limit, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $limit - * @param string $message + * @param mixed $value + * @param mixed $limit + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -941,9 +999,9 @@ public static function lessThan($value, $limit, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $limit - * @param string $message + * @param mixed $value + * @param mixed $limit + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -963,10 +1021,10 @@ public static function lessThanEq($value, $limit, $message = '') * * @psalm-pure * - * @param mixed $value + * @param mixed $value * @param mixed $min * @param mixed $max - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -987,9 +1045,9 @@ public static function range($value, $min, $max, $message = '') * * @psalm-pure * - * @param mixed $value - * @param array $values - * @param string $message + * @param mixed $value + * @param array $values + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1003,9 +1061,9 @@ public static function oneOf($value, array $values, $message = '') * * @psalm-pure * - * @param mixed $value - * @param array $values - * @param string $message + * @param mixed $value + * @param array $values + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1023,9 +1081,9 @@ public static function inArray($value, array $values, $message = '') /** * @psalm-pure * - * @param string $value - * @param string $subString - * @param string $message + * @param string $value + * @param string $subString + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1043,9 +1101,9 @@ public static function contains($value, $subString, $message = '') /** * @psalm-pure * - * @param string $value - * @param string $subString - * @param string $message + * @param string $value + * @param string $subString + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1063,8 +1121,8 @@ public static function notContains($value, $subString, $message = '') /** * @psalm-pure * - * @param string $value - * @param string $message + * @param string $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1081,9 +1139,9 @@ public static function notWhitespaceOnly($value, $message = '') /** * @psalm-pure * - * @param string $value - * @param string $prefix - * @param string $message + * @param string $value + * @param string $prefix + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1101,9 +1159,9 @@ public static function startsWith($value, $prefix, $message = '') /** * @psalm-pure * - * @param string $value - * @param string $prefix - * @param string $message + * @param string $value + * @param string $prefix + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1121,8 +1179,8 @@ public static function notStartsWith($value, $prefix, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1150,9 +1208,9 @@ public static function startsWithLetter($value, $message = '') /** * @psalm-pure * - * @param string $value - * @param string $suffix - * @param string $message + * @param string $value + * @param string $suffix + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1170,9 +1228,9 @@ public static function endsWith($value, $suffix, $message = '') /** * @psalm-pure * - * @param string $value - * @param string $suffix - * @param string $message + * @param string $value + * @param string $suffix + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1192,7 +1250,7 @@ public static function notEndsWith($value, $suffix, $message = '') * * @param string $value * @param string $pattern - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1211,7 +1269,7 @@ public static function regex($value, $pattern, $message = '') * * @param string $value * @param string $pattern - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1230,8 +1288,8 @@ public static function notRegex($value, $pattern, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1250,8 +1308,8 @@ public static function unicodeLetters($value, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1275,8 +1333,8 @@ public static function alpha($value, $message = '') /** * @psalm-pure * - * @param string $value - * @param string $message + * @param string $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1298,8 +1356,8 @@ public static function digits($value, $message = '') /** * @psalm-pure * - * @param string $value - * @param string $message + * @param string $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1323,8 +1381,8 @@ public static function alnum($value, $message = '') * * @psalm-assert lowercase-string $value * - * @param string $value - * @param string $message + * @param string $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1348,8 +1406,8 @@ public static function lower($value, $message = '') * * @psalm-assert !lowercase-string $value * - * @param string $value - * @param string $message + * @param string $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1373,7 +1431,7 @@ public static function upper($value, $message = '') * * @param string $value * @param int $length - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1461,8 +1519,8 @@ public static function lengthBetween($value, $min, $max, $message = '') /** * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1477,8 +1535,8 @@ public static function fileExists($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1493,8 +1551,8 @@ public static function file($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1509,8 +1567,8 @@ public static function directory($value, $message = '') } /** - * @param string $value - * @param string $message + * @param string $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1525,8 +1583,8 @@ public static function readable($value, $message = '') } /** - * @param string $value - * @param string $message + * @param string $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1543,8 +1601,8 @@ public static function writable($value, $message = '') /** * @psalm-assert class-string $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1587,8 +1645,8 @@ public static function subclassOf($value, $class, $message = '') /** * @psalm-assert class-string $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1611,9 +1669,9 @@ public static function interfaceExists($value, $message = '') * * @psalm-assert class-string $value * - * @param mixed $value + * @param mixed $value * @param mixed $interface - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1757,18 +1815,22 @@ public static function keyNotExists($array, $key, $message = '') * * @psalm-assert array-key $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ public static function validArrayKey($value, $message = '') { if (!(\is_int($value) || \is_string($value))) { - static::reportInvalidArgument(\sprintf( - $message ?: 'Expected string or integer. Got: %s', - static::typeToString($value) - )); + static::reportInvalidArgument( + is_callable($message) + ? $message() + : sprintf( + $message ?: 'Expected string or integer. Got: %s', + static::typeToString($value) + ) + ); } } @@ -1864,7 +1926,7 @@ public static function countBetween($array, $min, $max, $message = '') * @psalm-assert list $array * * @param mixed $array - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1904,7 +1966,7 @@ public static function isList($array, $message = '') * @psalm-assert non-empty-list $array * * @param mixed $array - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1924,7 +1986,7 @@ public static function isNonEmptyList($array, $message = '') * @psalm-assert array $array * * @param mixed $array - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1951,7 +2013,7 @@ public static function isMap($array, $message = '') * @psalm-assert !empty $array * * @param mixed $array - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -1964,8 +2026,8 @@ public static function isNonEmptyMap($array, $message = '') /** * @psalm-pure * - * @param string $value - * @param string $message + * @param string $value + * @param string|callable():string $message * * @throws InvalidArgumentException */ @@ -2125,7 +2187,7 @@ protected static function strlen($value) } /** - * @param string $message + * @param string|callable():string $message * * @throws InvalidArgumentException * @@ -2135,6 +2197,10 @@ protected static function strlen($value) */ protected static function reportInvalidArgument($message) { + if (is_callable($message)) { + $message = $message(); + } + throw new InvalidArgumentException($message); } diff --git a/src/Mixin.php b/src/Mixin.php index ae958ce..443af90 100644 --- a/src/Mixin.php +++ b/src/Mixin.php @@ -18,8 +18,8 @@ trait Mixin * * @psalm-assert string|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -35,8 +35,8 @@ public static function nullOrString($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -77,8 +77,8 @@ public static function allNullOrString($value, $message = '') * * @psalm-assert non-empty-string|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -94,8 +94,8 @@ public static function nullOrStringNotEmpty($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -136,8 +136,8 @@ public static function allNullOrStringNotEmpty($value, $message = '') * * @psalm-assert int|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -153,8 +153,8 @@ public static function nullOrInteger($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -195,8 +195,8 @@ public static function allNullOrInteger($value, $message = '') * * @psalm-assert numeric|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -212,8 +212,8 @@ public static function nullOrIntegerish($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -313,8 +313,8 @@ public static function allNullOrPositiveInteger($value, $message = '') * * @psalm-assert float|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -330,8 +330,8 @@ public static function nullOrFloat($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -372,8 +372,8 @@ public static function allNullOrFloat($value, $message = '') * * @psalm-assert numeric|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -389,8 +389,8 @@ public static function nullOrNumeric($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -431,8 +431,8 @@ public static function allNullOrNumeric($value, $message = '') * * @psalm-assert positive-int|0|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -448,8 +448,8 @@ public static function nullOrNatural($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -490,8 +490,8 @@ public static function allNullOrNatural($value, $message = '') * * @psalm-assert bool|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -507,8 +507,8 @@ public static function nullOrBoolean($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -549,8 +549,8 @@ public static function allNullOrBoolean($value, $message = '') * * @psalm-assert scalar|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -566,8 +566,8 @@ public static function nullOrScalar($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -608,8 +608,8 @@ public static function allNullOrScalar($value, $message = '') * * @psalm-assert object|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -625,8 +625,8 @@ public static function nullOrObject($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -729,8 +729,8 @@ public static function allNullOrResource($value, $type = null, $message = '') * * @psalm-assert callable|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -746,8 +746,8 @@ public static function nullOrIsCallable($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -788,8 +788,8 @@ public static function allNullOrIsCallable($value, $message = '') * * @psalm-assert array|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -805,8 +805,8 @@ public static function nullOrIsArray($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -849,8 +849,8 @@ public static function allNullOrIsArray($value, $message = '') * * @deprecated use "isIterable" or "isInstanceOf" instead * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -868,8 +868,8 @@ public static function nullOrIsTraversable($value, $message = '') * * @deprecated use "isIterable" or "isInstanceOf" instead * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -912,8 +912,8 @@ public static function allNullOrIsTraversable($value, $message = '') * * @psalm-assert array|ArrayAccess|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -929,8 +929,8 @@ public static function nullOrIsArrayAccessible($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -971,8 +971,8 @@ public static function allNullOrIsArrayAccessible($value, $message = '') * * @psalm-assert countable|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -988,8 +988,8 @@ public static function nullOrIsCountable($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1030,8 +1030,8 @@ public static function allNullOrIsCountable($value, $message = '') * * @psalm-assert iterable|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1047,8 +1047,8 @@ public static function nullOrIsIterable($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1482,8 +1482,8 @@ public static function allNullOrIsAnyOf($value, $classes, $message = '') * * @psalm-assert empty $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1499,8 +1499,8 @@ public static function nullOrIsEmpty($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1539,8 +1539,8 @@ public static function allNullOrIsEmpty($value, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1554,8 +1554,8 @@ public static function nullOrNotEmpty($value, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1596,8 +1596,8 @@ public static function allNullOrNotEmpty($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1615,8 +1615,8 @@ public static function allNull($value, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1636,8 +1636,8 @@ public static function allNotNull($value, $message = '') * * @psalm-assert true|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1653,8 +1653,8 @@ public static function nullOrTrue($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1695,8 +1695,8 @@ public static function allNullOrTrue($value, $message = '') * * @psalm-assert false|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1712,8 +1712,8 @@ public static function nullOrFalse($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1752,8 +1752,8 @@ public static function allNullOrFalse($value, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1767,8 +1767,8 @@ public static function nullOrNotFalse($value, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1805,8 +1805,8 @@ public static function allNullOrNotFalse($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1818,8 +1818,8 @@ public static function nullOrIp($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1852,8 +1852,8 @@ public static function allNullOrIp($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1865,8 +1865,8 @@ public static function nullOrIpv4($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1899,8 +1899,8 @@ public static function allNullOrIpv4($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1912,8 +1912,8 @@ public static function nullOrIpv6($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1946,8 +1946,8 @@ public static function allNullOrIpv6($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1959,8 +1959,8 @@ public static function nullOrEmail($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -1993,8 +1993,7 @@ public static function allNullOrEmail($value, $message = '') } /** - * @param array|null $values - * @param string $message + * @param string|callable():string $message * * @return void * @@ -2006,8 +2005,7 @@ public static function nullOrUniqueValues($values, $message = '') } /** - * @param iterable $values - * @param string $message + * @param string|callable():string $message * * @return void * @@ -2040,9 +2038,9 @@ public static function allNullOrUniqueValues($values, $message = '') } /** - * @param mixed $value - * @param mixed $expect - * @param string $message + * @param mixed $value + * @param mixed $expect + * @param string|callable():string $message * * @return void * @@ -2054,9 +2052,9 @@ public static function nullOrEq($value, $expect, $message = '') } /** - * @param mixed $value - * @param mixed $expect - * @param string $message + * @param mixed $value + * @param mixed $expect + * @param string|callable():string $message * * @return void * @@ -2090,9 +2088,9 @@ public static function allNullOrEq($value, $expect, $message = '') } /** - * @param mixed $value - * @param mixed $expect - * @param string $message + * @param mixed $value + * @param mixed $expect + * @param string|callable():string $message * * @return void * @@ -2104,9 +2102,9 @@ public static function nullOrNotEq($value, $expect, $message = '') } /** - * @param mixed $value - * @param mixed $expect - * @param string $message + * @param mixed $value + * @param mixed $expect + * @param string|callable():string $message * * @return void * @@ -2142,9 +2140,9 @@ public static function allNullOrNotEq($value, $expect, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $expect - * @param string $message + * @param mixed $value + * @param mixed $expect + * @param string|callable():string $message * * @return void * @@ -2158,9 +2156,9 @@ public static function nullOrSame($value, $expect, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $expect - * @param string $message + * @param mixed $value + * @param mixed $expect + * @param string|callable():string $message * * @return void * @@ -2198,9 +2196,9 @@ public static function allNullOrSame($value, $expect, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $expect - * @param string $message + * @param mixed $value + * @param mixed $expect + * @param string|callable():string $message * * @return void * @@ -2214,9 +2212,9 @@ public static function nullOrNotSame($value, $expect, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $expect - * @param string $message + * @param mixed $value + * @param mixed $expect + * @param string|callable():string $message * * @return void * @@ -2254,9 +2252,9 @@ public static function allNullOrNotSame($value, $expect, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $limit - * @param string $message + * @param mixed $value + * @param mixed $limit + * @param string|callable():string $message * * @return void * @@ -2270,9 +2268,9 @@ public static function nullOrGreaterThan($value, $limit, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $limit - * @param string $message + * @param mixed $value + * @param mixed $limit + * @param string|callable():string $message * * @return void * @@ -2310,9 +2308,9 @@ public static function allNullOrGreaterThan($value, $limit, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $limit - * @param string $message + * @param mixed $value + * @param mixed $limit + * @param string|callable():string $message * * @return void * @@ -2326,9 +2324,9 @@ public static function nullOrGreaterThanEq($value, $limit, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $limit - * @param string $message + * @param mixed $value + * @param mixed $limit + * @param string|callable():string $message * * @return void * @@ -2366,9 +2364,9 @@ public static function allNullOrGreaterThanEq($value, $limit, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $limit - * @param string $message + * @param mixed $value + * @param mixed $limit + * @param string|callable():string $message * * @return void * @@ -2382,9 +2380,9 @@ public static function nullOrLessThan($value, $limit, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $limit - * @param string $message + * @param mixed $value + * @param mixed $limit + * @param string|callable():string $message * * @return void * @@ -2422,9 +2420,9 @@ public static function allNullOrLessThan($value, $limit, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $limit - * @param string $message + * @param mixed $value + * @param mixed $limit + * @param string|callable():string $message * * @return void * @@ -2438,9 +2436,9 @@ public static function nullOrLessThanEq($value, $limit, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $limit - * @param string $message + * @param mixed $value + * @param mixed $limit + * @param string|callable():string $message * * @return void * @@ -2478,10 +2476,10 @@ public static function allNullOrLessThanEq($value, $limit, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $min - * @param mixed $max - * @param string $message + * @param mixed $value + * @param mixed $min + * @param mixed $max + * @param string|callable():string $message * * @return void * @@ -2495,10 +2493,10 @@ public static function nullOrRange($value, $min, $max, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param mixed $min - * @param mixed $max - * @param string $message + * @param mixed $value + * @param mixed $min + * @param mixed $max + * @param string|callable():string $message * * @return void * @@ -2537,9 +2535,9 @@ public static function allNullOrRange($value, $min, $max, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param array $values - * @param string $message + * @param mixed $value + * @param array $values + * @param string|callable():string $message * * @return void * @@ -2553,9 +2551,9 @@ public static function nullOrOneOf($value, $values, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param array $values - * @param string $message + * @param mixed $value + * @param array $values + * @param string|callable():string $message * * @return void * @@ -2593,9 +2591,9 @@ public static function allNullOrOneOf($value, $values, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param array $values - * @param string $message + * @param mixed $value + * @param array $values + * @param string|callable():string $message * * @return void * @@ -2609,9 +2607,9 @@ public static function nullOrInArray($value, $values, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param array $values - * @param string $message + * @param mixed $value + * @param array $values + * @param string|callable():string $message * * @return void * @@ -2649,9 +2647,9 @@ public static function allNullOrInArray($value, $values, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $subString - * @param string $message + * @param string|null $value + * @param string $subString + * @param string|callable():string $message * * @return void * @@ -2665,9 +2663,9 @@ public static function nullOrContains($value, $subString, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $subString - * @param string $message + * @param iterable $value + * @param string $subString + * @param string|callable():string $message * * @return void * @@ -2705,9 +2703,9 @@ public static function allNullOrContains($value, $subString, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $subString - * @param string $message + * @param string|null $value + * @param string $subString + * @param string|callable():string $message * * @return void * @@ -2721,9 +2719,9 @@ public static function nullOrNotContains($value, $subString, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $subString - * @param string $message + * @param iterable $value + * @param string $subString + * @param string|callable():string $message * * @return void * @@ -2761,8 +2759,8 @@ public static function allNullOrNotContains($value, $subString, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $message + * @param string|null $value + * @param string|callable():string $message * * @return void * @@ -2776,8 +2774,8 @@ public static function nullOrNotWhitespaceOnly($value, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $message + * @param iterable $value + * @param string|callable():string $message * * @return void * @@ -2814,9 +2812,9 @@ public static function allNullOrNotWhitespaceOnly($value, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $prefix - * @param string $message + * @param string|null $value + * @param string $prefix + * @param string|callable():string $message * * @return void * @@ -2830,9 +2828,9 @@ public static function nullOrStartsWith($value, $prefix, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $prefix - * @param string $message + * @param iterable $value + * @param string $prefix + * @param string|callable():string $message * * @return void * @@ -2870,9 +2868,9 @@ public static function allNullOrStartsWith($value, $prefix, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $prefix - * @param string $message + * @param string|null $value + * @param string $prefix + * @param string|callable():string $message * * @return void * @@ -2886,9 +2884,9 @@ public static function nullOrNotStartsWith($value, $prefix, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $prefix - * @param string $message + * @param iterable $value + * @param string $prefix + * @param string|callable():string $message * * @return void * @@ -2926,8 +2924,8 @@ public static function allNullOrNotStartsWith($value, $prefix, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -2941,8 +2939,8 @@ public static function nullOrStartsWithLetter($value, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -2979,9 +2977,9 @@ public static function allNullOrStartsWithLetter($value, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $suffix - * @param string $message + * @param string|null $value + * @param string $suffix + * @param string|callable():string $message * * @return void * @@ -2995,9 +2993,9 @@ public static function nullOrEndsWith($value, $suffix, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $suffix - * @param string $message + * @param iterable $value + * @param string $suffix + * @param string|callable():string $message * * @return void * @@ -3035,9 +3033,9 @@ public static function allNullOrEndsWith($value, $suffix, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $suffix - * @param string $message + * @param string|null $value + * @param string $suffix + * @param string|callable():string $message * * @return void * @@ -3051,9 +3049,9 @@ public static function nullOrNotEndsWith($value, $suffix, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $suffix - * @param string $message + * @param iterable $value + * @param string $suffix + * @param string|callable():string $message * * @return void * @@ -3091,9 +3089,9 @@ public static function allNullOrNotEndsWith($value, $suffix, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $pattern - * @param string $message + * @param string|null $value + * @param string $pattern + * @param string|callable():string $message * * @return void * @@ -3107,9 +3105,9 @@ public static function nullOrRegex($value, $pattern, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $pattern - * @param string $message + * @param iterable $value + * @param string $pattern + * @param string|callable():string $message * * @return void * @@ -3147,9 +3145,9 @@ public static function allNullOrRegex($value, $pattern, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $pattern - * @param string $message + * @param string|null $value + * @param string $pattern + * @param string|callable():string $message * * @return void * @@ -3163,9 +3161,9 @@ public static function nullOrNotRegex($value, $pattern, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $pattern - * @param string $message + * @param iterable $value + * @param string $pattern + * @param string|callable():string $message * * @return void * @@ -3203,8 +3201,8 @@ public static function allNullOrNotRegex($value, $pattern, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -3218,8 +3216,8 @@ public static function nullOrUnicodeLetters($value, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -3256,8 +3254,8 @@ public static function allNullOrUnicodeLetters($value, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -3271,8 +3269,8 @@ public static function nullOrAlpha($value, $message = '') /** * @psalm-pure * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -3309,8 +3307,8 @@ public static function allNullOrAlpha($value, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $message + * @param string|null $value + * @param string|callable():string $message * * @return void * @@ -3324,8 +3322,8 @@ public static function nullOrDigits($value, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $message + * @param iterable $value + * @param string|callable():string $message * * @return void * @@ -3362,8 +3360,8 @@ public static function allNullOrDigits($value, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $message + * @param string|null $value + * @param string|callable():string $message * * @return void * @@ -3377,8 +3375,8 @@ public static function nullOrAlnum($value, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $message + * @param iterable $value + * @param string|callable():string $message * * @return void * @@ -3417,8 +3415,8 @@ public static function allNullOrAlnum($value, $message = '') * * @psalm-assert lowercase-string|null $value * - * @param string|null $value - * @param string $message + * @param string|null $value + * @param string|callable():string $message * * @return void * @@ -3434,8 +3432,8 @@ public static function nullOrLower($value, $message = '') * * @psalm-assert iterable $value * - * @param iterable $value - * @param string $message + * @param iterable $value + * @param string|callable():string $message * * @return void * @@ -3474,8 +3472,8 @@ public static function allNullOrLower($value, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $message + * @param string|null $value + * @param string|callable():string $message * * @return void * @@ -3489,8 +3487,8 @@ public static function nullOrUpper($value, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $message + * @param iterable $value + * @param string|callable():string $message * * @return void * @@ -3529,9 +3527,9 @@ public static function allNullOrUpper($value, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param int $length - * @param string $message + * @param string|null $value + * @param int $length + * @param string|callable():string $message * * @return void * @@ -3545,9 +3543,9 @@ public static function nullOrLength($value, $length, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param int $length - * @param string $message + * @param iterable $value + * @param int $length + * @param string|callable():string $message * * @return void * @@ -3754,8 +3752,8 @@ public static function allNullOrLengthBetween($value, $min, $max, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -3767,8 +3765,8 @@ public static function nullOrFileExists($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -3801,8 +3799,8 @@ public static function allNullOrFileExists($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -3814,8 +3812,8 @@ public static function nullOrFile($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -3848,8 +3846,8 @@ public static function allNullOrFile($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -3861,8 +3859,8 @@ public static function nullOrDirectory($value, $message = '') } /** - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -3895,8 +3893,8 @@ public static function allNullOrDirectory($value, $message = '') } /** - * @param string|null $value - * @param string $message + * @param string|null $value + * @param string|callable():string $message * * @return void * @@ -3908,8 +3906,8 @@ public static function nullOrReadable($value, $message = '') } /** - * @param iterable $value - * @param string $message + * @param iterable $value + * @param string|callable():string $message * * @return void * @@ -3942,8 +3940,8 @@ public static function allNullOrReadable($value, $message = '') } /** - * @param string|null $value - * @param string $message + * @param string|null $value + * @param string|callable():string $message * * @return void * @@ -3955,8 +3953,8 @@ public static function nullOrWritable($value, $message = '') } /** - * @param iterable $value - * @param string $message + * @param iterable $value + * @param string|callable():string $message * * @return void * @@ -3991,8 +3989,8 @@ public static function allNullOrWritable($value, $message = '') /** * @psalm-assert class-string|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -4006,8 +4004,8 @@ public static function nullOrClassExists($value, $message = '') /** * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -4112,8 +4110,8 @@ public static function allNullOrSubclassOf($value, $class, $message = '') /** * @psalm-assert class-string|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -4127,8 +4125,8 @@ public static function nullOrInterfaceExists($value, $message = '') /** * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -4169,9 +4167,9 @@ public static function allNullOrInterfaceExists($value, $message = '') * @psalm-param class-string $interface * @psalm-assert class-string|null $value * - * @param mixed $value - * @param mixed $interface - * @param string $message + * @param mixed $value + * @param mixed $interface + * @param string|callable():string $message * * @return void * @@ -4189,9 +4187,9 @@ public static function nullOrImplementsInterface($value, $interface, $message = * @psalm-param class-string $interface * @psalm-assert iterable> $value * - * @param mixed $value - * @param mixed $interface - * @param string $message + * @param mixed $value + * @param mixed $interface + * @param string|callable():string $message * * @return void * @@ -4595,8 +4593,8 @@ public static function allNullOrKeyNotExists($array, $key, $message = '') * * @psalm-assert array-key|null $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -4612,8 +4610,8 @@ public static function nullOrValidArrayKey($value, $message = '') * * @psalm-assert iterable $value * - * @param mixed $value - * @param string $message + * @param mixed $value + * @param string|callable():string $message * * @return void * @@ -4857,8 +4855,8 @@ public static function allNullOrCountBetween($array, $min, $max, $message = '') * * @psalm-assert list|null $array * - * @param mixed $array - * @param string $message + * @param mixed $array + * @param string|callable():string $message * * @return void * @@ -4874,8 +4872,8 @@ public static function nullOrIsList($array, $message = '') * * @psalm-assert iterable $array * - * @param mixed $array - * @param string $message + * @param mixed $array + * @param string|callable():string $message * * @return void * @@ -4916,8 +4914,8 @@ public static function allNullOrIsList($array, $message = '') * * @psalm-assert non-empty-list|null $array * - * @param mixed $array - * @param string $message + * @param mixed $array + * @param string|callable():string $message * * @return void * @@ -4933,8 +4931,8 @@ public static function nullOrIsNonEmptyList($array, $message = '') * * @psalm-assert iterable $array * - * @param mixed $array - * @param string $message + * @param mixed $array + * @param string|callable():string $message * * @return void * @@ -4977,8 +4975,8 @@ public static function allNullOrIsNonEmptyList($array, $message = '') * @psalm-param mixed|array|null $array * @psalm-assert array|null $array * - * @param mixed $array - * @param string $message + * @param mixed $array + * @param string|callable():string $message * * @return void * @@ -4996,8 +4994,8 @@ public static function nullOrIsMap($array, $message = '') * @psalm-param iterable> $array * @psalm-assert iterable> $array * - * @param mixed $array - * @param string $message + * @param mixed $array + * @param string|callable():string $message * * @return void * @@ -5041,8 +5039,8 @@ public static function allNullOrIsMap($array, $message = '') * @psalm-template T * @psalm-param mixed|array|null $array * - * @param mixed $array - * @param string $message + * @param mixed $array + * @param string|callable():string $message * * @return void * @@ -5059,8 +5057,8 @@ public static function nullOrIsNonEmptyMap($array, $message = '') * @psalm-template T * @psalm-param iterable> $array * - * @param mixed $array - * @param string $message + * @param mixed $array + * @param string|callable():string $message * * @return void * @@ -5102,8 +5100,8 @@ public static function allNullOrIsNonEmptyMap($array, $message = '') /** * @psalm-pure * - * @param string|null $value - * @param string $message + * @param string|null $value + * @param string|callable():string $message * * @return void * @@ -5117,8 +5115,8 @@ public static function nullOrUuid($value, $message = '') /** * @psalm-pure * - * @param iterable $value - * @param string $message + * @param iterable $value + * @param string|callable():string $message * * @return void * diff --git a/tests/AssertTest.php b/tests/AssertTest.php index b95eba1..8d25aea 100644 --- a/tests/AssertTest.php +++ b/tests/AssertTest.php @@ -775,6 +775,26 @@ public function testConvertValuesToStrings($method, $args, $exceptionMessage) call_user_func_array(array('Webmozart\Assert\Assert', $method), $args); } + public function testLazyExceptionMessage() + { + $exceptionMessage = 'Audax ususs ducunt ad historia.'; + + $isInit = false; + + $thunk = function () use ($exceptionMessage, &$isInit) { + $isInit = true; + + return $exceptionMessage; + }; + + Assert::string('', $thunk); + self::assertFalse($isInit); + + $this->expectException('\InvalidArgumentException'); + $this->expectExceptionMessage($exceptionMessage); + Assert::string(null, $thunk); + } + public function testAnUnknownMethodThrowsABadMethodCall() { $this->expectException('\BadMethodCallException');