composer update
This commit is contained in:
+356
-51
@@ -15,6 +15,8 @@ use ArrayAccess;
|
||||
use BadMethodCallException;
|
||||
use Closure;
|
||||
use Countable;
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use ResourceBundle;
|
||||
@@ -45,10 +47,14 @@ use Traversable;
|
||||
* @method static void nullOrIsInstanceOf($value, $class, $message = '')
|
||||
* @method static void nullOrNotInstanceOf($value, $class, $message = '')
|
||||
* @method static void nullOrIsInstanceOfAny($value, $classes, $message = '')
|
||||
* @method static void nullOrIsAOf($value, $classes, $message = '')
|
||||
* @method static void nullOrIsAnyOf($value, $classes, $message = '')
|
||||
* @method static void nullOrIsNotA($value, $classes, $message = '')
|
||||
* @method static void nullOrIsEmpty($value, $message = '')
|
||||
* @method static void nullOrNotEmpty($value, $message = '')
|
||||
* @method static void nullOrTrue($value, $message = '')
|
||||
* @method static void nullOrFalse($value, $message = '')
|
||||
* @method static void nullOrNotFalse($value, $message = '')
|
||||
* @method static void nullOrIp($value, $message = '')
|
||||
* @method static void nullOrIpv4($value, $message = '')
|
||||
* @method static void nullOrIpv6($value, $message = '')
|
||||
@@ -64,12 +70,15 @@ use Traversable;
|
||||
* @method static void nullOrLessThanEq($value, $limit, $message = '')
|
||||
* @method static void nullOrRange($value, $min, $max, $message = '')
|
||||
* @method static void nullOrOneOf($value, $values, $message = '')
|
||||
* @method static void nullOrInArray($value, $values, $message = '')
|
||||
* @method static void nullOrContains($value, $subString, $message = '')
|
||||
* @method static void nullOrNotContains($value, $subString, $message = '')
|
||||
* @method static void nullOrNotWhitespaceOnly($value, $message = '')
|
||||
* @method static void nullOrStartsWith($value, $prefix, $message = '')
|
||||
* @method static void nullOrNotStartsWith($value, $prefix, $message = '')
|
||||
* @method static void nullOrStartsWithLetter($value, $message = '')
|
||||
* @method static void nullOrEndsWith($value, $suffix, $message = '')
|
||||
* @method static void nullOrNotEndsWith($value, $suffix, $message = '')
|
||||
* @method static void nullOrRegex($value, $pattern, $message = '')
|
||||
* @method static void nullOrNotRegex($value, $pattern, $message = '')
|
||||
* @method static void nullOrUnicodeLetters($value, $message = '')
|
||||
@@ -128,12 +137,16 @@ use Traversable;
|
||||
* @method static void allIsInstanceOf($values, $class, $message = '')
|
||||
* @method static void allNotInstanceOf($values, $class, $message = '')
|
||||
* @method static void allIsInstanceOfAny($values, $classes, $message = '')
|
||||
* @method static void allIsAOf($values, $class, $message = '')
|
||||
* @method static void allIsAnyOf($values, $class, $message = '')
|
||||
* @method static void allIsNotA($values, $class, $message = '')
|
||||
* @method static void allNull($values, $message = '')
|
||||
* @method static void allNotNull($values, $message = '')
|
||||
* @method static void allIsEmpty($values, $message = '')
|
||||
* @method static void allNotEmpty($values, $message = '')
|
||||
* @method static void allTrue($values, $message = '')
|
||||
* @method static void allFalse($values, $message = '')
|
||||
* @method static void allNotFalse($values, $message = '')
|
||||
* @method static void allIp($values, $message = '')
|
||||
* @method static void allIpv4($values, $message = '')
|
||||
* @method static void allIpv6($values, $message = '')
|
||||
@@ -149,12 +162,15 @@ use Traversable;
|
||||
* @method static void allLessThanEq($values, $limit, $message = '')
|
||||
* @method static void allRange($values, $min, $max, $message = '')
|
||||
* @method static void allOneOf($values, $values, $message = '')
|
||||
* @method static void allInArray($values, $values, $message = '')
|
||||
* @method static void allContains($values, $subString, $message = '')
|
||||
* @method static void allNotContains($values, $subString, $message = '')
|
||||
* @method static void allNotWhitespaceOnly($values, $message = '')
|
||||
* @method static void allStartsWith($values, $prefix, $message = '')
|
||||
* @method static void allNotStartsWith($values, $prefix, $message = '')
|
||||
* @method static void allStartsWithLetter($values, $message = '')
|
||||
* @method static void allEndsWith($values, $suffix, $message = '')
|
||||
* @method static void allNotEndsWith($values, $suffix, $message = '')
|
||||
* @method static void allRegex($values, $pattern, $message = '')
|
||||
* @method static void allNotRegex($values, $pattern, $message = '')
|
||||
* @method static void allUnicodeLetters($values, $message = '')
|
||||
@@ -201,6 +217,7 @@ use Traversable;
|
||||
class Assert
|
||||
{
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert string $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -219,6 +236,10 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert string $value
|
||||
* @psalm-assert !empty $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $message
|
||||
*
|
||||
@@ -231,6 +252,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert int $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -249,6 +271,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert numeric $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -267,6 +290,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert float $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -285,6 +309,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert numeric $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -303,6 +328,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert int $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -321,6 +347,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert bool $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -339,6 +366,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert scalar $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -357,6 +385,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert object $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -375,6 +404,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert resource $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -402,6 +432,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert callable $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -420,6 +451,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert array $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -438,6 +470,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert iterable $value
|
||||
*
|
||||
* @deprecated use "isIterable" or "isInstanceOf" instead
|
||||
@@ -466,6 +499,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert array|ArrayAccess $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $message
|
||||
*
|
||||
@@ -482,6 +518,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert countable $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -505,6 +542,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert iterable $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -523,6 +561,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-template ExpectedType of object
|
||||
* @psalm-param class-string<ExpectedType> $class
|
||||
* @psalm-assert ExpectedType $value
|
||||
@@ -545,6 +584,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-template ExpectedType of object
|
||||
* @psalm-param class-string<ExpectedType> $class
|
||||
* @psalm-assert !ExpectedType $value
|
||||
@@ -567,6 +607,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-param array<class-string> $classes
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param array<object|string> $classes
|
||||
* @param string $message
|
||||
@@ -589,6 +632,85 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-template ExpectedType of object
|
||||
* @psalm-param class-string<ExpectedType> $class
|
||||
* @psalm-assert ExpectedType|class-string<ExpectedType> $value
|
||||
*
|
||||
* @param object|string $value
|
||||
* @param string $class
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function isAOf($value, $class, $message = '')
|
||||
{
|
||||
static::string($class, 'Expected class as a string. Got: %s');
|
||||
|
||||
if (!\is_a($value, $class, \is_string($value))) {
|
||||
static::reportInvalidArgument(sprintf(
|
||||
$message ?: 'Expected an instance of this class or to this class among his parents %2$s. Got: %s',
|
||||
static::typeToString($value),
|
||||
$class
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-template UnexpectedType of object
|
||||
* @psalm-param class-string<UnexpectedType> $class
|
||||
* @psalm-assert !UnexpectedType $value
|
||||
* @psalm-assert !class-string<UnexpectedType> $value
|
||||
*
|
||||
* @param object|string $value
|
||||
* @param string $class
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function isNotA($value, $class, $message = '')
|
||||
{
|
||||
static::string($class, 'Expected class as a string. Got: %s');
|
||||
|
||||
if (\is_a($value, $class, \is_string($value))) {
|
||||
static::reportInvalidArgument(sprintf(
|
||||
$message ?: 'Expected an instance of this class or to this class among his parents other than %2$s. Got: %s',
|
||||
static::typeToString($value),
|
||||
$class
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-param array<class-string> $classes
|
||||
*
|
||||
* @param object|string $value
|
||||
* @param string[] $classes
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function isAnyOf($value, array $classes, $message = '')
|
||||
{
|
||||
foreach ($classes as $class) {
|
||||
static::string($class, 'Expected class as a string. Got: %s');
|
||||
|
||||
if (\is_a($value, $class, \is_string($value))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static::reportInvalidArgument(sprintf(
|
||||
$message ?: 'Expected an any of instance of this class or to this class among his parents other than %2$s. Got: %s',
|
||||
static::typeToString($value),
|
||||
\implode(', ', \array_map(array('static', 'valueToString'), $classes))
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert empty $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -607,6 +729,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert !empty $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -625,6 +748,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert null $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -643,6 +767,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert !null $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -660,6 +785,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert true $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -678,6 +804,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert false $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -695,6 +822,23 @@ class Assert
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-assert !false $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function notFalse($value, $message = '')
|
||||
{
|
||||
if (false === $value) {
|
||||
static::reportInvalidArgument(
|
||||
$message ?: 'Expected a value other than false.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param string $message
|
||||
@@ -819,6 +963,8 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $expect
|
||||
* @param string $message
|
||||
@@ -837,6 +983,8 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $expect
|
||||
* @param string $message
|
||||
@@ -854,6 +1002,8 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $limit
|
||||
* @param string $message
|
||||
@@ -872,6 +1022,8 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $limit
|
||||
* @param string $message
|
||||
@@ -890,6 +1042,8 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $limit
|
||||
* @param string $message
|
||||
@@ -908,6 +1062,8 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $limit
|
||||
* @param string $message
|
||||
@@ -928,6 +1084,8 @@ class Assert
|
||||
/**
|
||||
* Inclusive range, so Assert::(3, 3, 5) passes.
|
||||
*
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $min
|
||||
* @param mixed $max
|
||||
@@ -948,7 +1106,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* Does strict comparison, so Assert::oneOf(3, ['3']) does not pass the assertion.
|
||||
* A more human-readable alias of Assert::inArray().
|
||||
*
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param array $values
|
||||
@@ -957,6 +1117,22 @@ class Assert
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function oneOf($value, array $values, $message = '')
|
||||
{
|
||||
static::inArray($value, $values, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does strict comparison, so Assert::inArray(3, ['3']) does not pass the assertion.
|
||||
*
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param array $values
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function inArray($value, array $values, $message = '')
|
||||
{
|
||||
if (!\in_array($value, $values, true)) {
|
||||
static::reportInvalidArgument(\sprintf(
|
||||
@@ -968,7 +1144,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $subString
|
||||
* @param string $message
|
||||
*
|
||||
@@ -986,7 +1164,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $subString
|
||||
* @param string $message
|
||||
*
|
||||
@@ -1004,7 +1184,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@@ -1020,7 +1202,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $prefix
|
||||
* @param string $message
|
||||
*
|
||||
@@ -1038,6 +1222,28 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $prefix
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function notStartsWith($value, $prefix, $message = '')
|
||||
{
|
||||
if (0 === \strpos($value, $prefix)) {
|
||||
static::reportInvalidArgument(\sprintf(
|
||||
$message ?: 'Expected a value not to start with %2$s. Got: %s',
|
||||
static::valueToString($value),
|
||||
static::valueToString($prefix)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $message
|
||||
*
|
||||
@@ -1065,7 +1271,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $suffix
|
||||
* @param string $message
|
||||
*
|
||||
@@ -1083,8 +1291,30 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param mixed $pattern
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $suffix
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function notEndsWith($value, $suffix, $message = '')
|
||||
{
|
||||
if ($suffix === \substr($value, -\strlen($suffix))) {
|
||||
static::reportInvalidArgument(\sprintf(
|
||||
$message ?: 'Expected a value not to end with %2$s. Got: %s',
|
||||
static::valueToString($value),
|
||||
static::valueToString($suffix)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $pattern
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@@ -1100,8 +1330,10 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param mixed $pattern
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $pattern
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@@ -1119,6 +1351,8 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $message
|
||||
*
|
||||
@@ -1137,6 +1371,8 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $message
|
||||
*
|
||||
@@ -1160,7 +1396,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@@ -1181,7 +1419,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@@ -1202,7 +1442,10 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @psalm-pure
|
||||
* @psalm-assert lowercase-string $value
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@@ -1223,7 +1466,10 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @psalm-pure
|
||||
* @psalm-assert !lowercase-string $value
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@@ -1244,8 +1490,10 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param mixed $length
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param int $length
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@@ -1264,9 +1512,11 @@ class Assert
|
||||
/**
|
||||
* Inclusive min.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $min
|
||||
* @param string $message
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param int|float $min
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
@@ -1284,9 +1534,11 @@ class Assert
|
||||
/**
|
||||
* Inclusive max.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $max
|
||||
* @param string $message
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param int|float $max
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
@@ -1304,10 +1556,12 @@ class Assert
|
||||
/**
|
||||
* Inclusive , so Assert::lengthBetween('asd', 3, 5); passes the assertion.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $min
|
||||
* @param mixed $max
|
||||
* @param string $message
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param int|float $min
|
||||
* @param int|float $max
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
@@ -1382,7 +1636,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param string $value
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@@ -1398,7 +1652,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @param string $value
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@@ -1414,8 +1668,6 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-assert class-string $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $message
|
||||
*
|
||||
@@ -1432,6 +1684,11 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-template ExpectedType of object
|
||||
* @psalm-param class-string<ExpectedType> $class
|
||||
* @psalm-assert class-string<ExpectedType>|ExpectedType $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string|object $class
|
||||
* @param string $message
|
||||
@@ -1450,8 +1707,6 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-assert class-string $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param string $message
|
||||
*
|
||||
@@ -1468,6 +1723,11 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-template ExpectedType of object
|
||||
* @psalm-param class-string<ExpectedType> $interface
|
||||
* @psalm-assert class-string<ExpectedType> $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $interface
|
||||
* @param string $message
|
||||
@@ -1486,6 +1746,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-param class-string|object $classOrObject
|
||||
*
|
||||
* @param string|object $classOrObject
|
||||
* @param mixed $property
|
||||
* @param string $message
|
||||
@@ -1503,6 +1766,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-param class-string|object $classOrObject
|
||||
*
|
||||
* @param string|object $classOrObject
|
||||
* @param mixed $property
|
||||
* @param string $message
|
||||
@@ -1520,6 +1786,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-param class-string|object $classOrObject
|
||||
*
|
||||
* @param string|object $classOrObject
|
||||
* @param mixed $method
|
||||
* @param string $message
|
||||
@@ -1537,6 +1806,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-param class-string|object $classOrObject
|
||||
*
|
||||
* @param string|object $classOrObject
|
||||
* @param mixed $method
|
||||
* @param string $message
|
||||
@@ -1554,6 +1826,8 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param array $array
|
||||
* @param string|int $key
|
||||
* @param string $message
|
||||
@@ -1571,6 +1845,8 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param array $array
|
||||
* @param string|int $key
|
||||
* @param string $message
|
||||
@@ -1590,6 +1866,7 @@ class Assert
|
||||
/**
|
||||
* Checks if a value is a valid array key (int or string).
|
||||
*
|
||||
* @psalm-pure
|
||||
* @psalm-assert array-key $value
|
||||
*
|
||||
* @param mixed $value
|
||||
@@ -1610,9 +1887,9 @@ class Assert
|
||||
/**
|
||||
* Does not check if $array is countable, this can generate a warning on php versions after 7.2.
|
||||
*
|
||||
* @param mixed $array
|
||||
* @param mixed $number
|
||||
* @param string $message
|
||||
* @param Countable|array $array
|
||||
* @param int $number
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
@@ -1621,16 +1898,20 @@ class Assert
|
||||
static::eq(
|
||||
\count($array),
|
||||
$number,
|
||||
$message ?: \sprintf('Expected an array to contain %d elements. Got: %d.', $number, \count($array))
|
||||
\sprintf(
|
||||
$message ?: 'Expected an array to contain %d elements. Got: %d.',
|
||||
$number,
|
||||
\count($array)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does not check if $array is countable, this can generate a warning on php versions after 7.2.
|
||||
*
|
||||
* @param mixed $array
|
||||
* @param mixed $min
|
||||
* @param string $message
|
||||
* @param Countable|array $array
|
||||
* @param int|float $min
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
@@ -1648,9 +1929,9 @@ class Assert
|
||||
/**
|
||||
* Does not check if $array is countable, this can generate a warning on php versions after 7.2.
|
||||
*
|
||||
* @param mixed $array
|
||||
* @param mixed $max
|
||||
* @param string $message
|
||||
* @param Countable|array $array
|
||||
* @param int|float $max
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
@@ -1668,10 +1949,10 @@ class Assert
|
||||
/**
|
||||
* Does not check if $array is countable, this can generate a warning on php versions after 7.2.
|
||||
*
|
||||
* @param mixed $array
|
||||
* @param mixed $min
|
||||
* @param mixed $max
|
||||
* @param string $message
|
||||
* @param Countable|array $array
|
||||
* @param int|float $min
|
||||
* @param int|float $max
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
@@ -1690,6 +1971,7 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-assert list $array
|
||||
*
|
||||
* @param mixed $array
|
||||
@@ -1707,7 +1989,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-assert non-empty-list $array
|
||||
* @psalm-pure
|
||||
* @psalm-assert list $array
|
||||
* @psalm-assert !empty $array
|
||||
*
|
||||
* @param mixed $array
|
||||
* @param string $message
|
||||
@@ -1721,6 +2005,11 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-template T
|
||||
* @psalm-param mixed|array<T> $array
|
||||
* @psalm-assert array<string, T> $array
|
||||
*
|
||||
* @param mixed $array
|
||||
* @param string $message
|
||||
*
|
||||
@@ -1739,6 +2028,12 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
* @psalm-template T
|
||||
* @psalm-param mixed|array<T> $array
|
||||
* @psalm-assert array<string, T> $array
|
||||
* @psalm-assert !empty $array
|
||||
*
|
||||
* @param mixed $array
|
||||
* @param string $message
|
||||
*
|
||||
@@ -1751,7 +2046,9 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @psalm-pure
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
@@ -1775,9 +2072,11 @@ class Assert
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Closure $expression
|
||||
* @param string|object $class
|
||||
* @param string $message
|
||||
* @psalm-param class-string<Throwable>
|
||||
*
|
||||
* @param Closure $expression
|
||||
* @param string $class
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
@@ -1868,6 +2167,10 @@ class Assert
|
||||
return \get_class($value).': '.self::valueToString($value->__toString());
|
||||
}
|
||||
|
||||
if ($value instanceof DateTime || $value instanceof DateTimeImmutable) {
|
||||
return \get_class($value).': '.self::valueToString($value->format('c'));
|
||||
}
|
||||
|
||||
return \get_class($value);
|
||||
}
|
||||
|
||||
@@ -1909,6 +2212,8 @@ class Assert
|
||||
* @param string $message
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*
|
||||
* @psalm-pure this method is not supposed to perform side-effects
|
||||
*/
|
||||
protected static function reportInvalidArgument($message)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user