composer update

This commit is contained in:
2020-05-10 09:29:56 +00:00
parent c6f807ebad
commit 8e93eececf
919 changed files with 11790 additions and 7005 deletions
+27 -3
View File
@@ -3,6 +3,30 @@ Changelog
## UNRELEASED
## 1.8.0
### Added
* added `Assert::notStartsWith()`
* added `Assert::notEndsWith()`
* added `Assert::inArray()`
* added `@psalm-pure` annotations to pure assertions
### Fixed
* Exception messages of comparisons between `DateTime(Immutalbe)` objects now display their date & time.
* Custom Exception messages for `Assert::count()` now use the values to render the exception message.
## 1.7.0 (2020-02-14)
### Added
* added `Assert::notFalse()`
* added `Assert::isAOf()`
* added `Assert::isAnyOf()`
* added `Assert::isNotA()`
## 1.6.0 (2019-11-24)
### Added
@@ -15,7 +39,7 @@ Changelog
### Fixed
* `ResourceBundle` & `SimpleXMLElement` now pass the `isCountable` assertions.
* `ResourceBundle` & `SimpleXMLElement` now pass the `isCountable` assertions.
They are countable, without implementing the `Countable` interface.
* The doc block of `range` now has the proper variables.
* An empty array will now pass `isList` and `isMap`. As it is a valid form of both.
@@ -28,12 +52,12 @@ If a non empty variant is needed, use `isNonEmptyList` or `isNonEmptyMap`.
* [#145](https://github.com/webmozart/assert/issues/145)
* [#146](https://github.com/webmozart/assert/pull/146)
* [#150](https://github.com/webmozart/assert/pull/150)
* If you use psalm, the minimum version needed is `3.6.0`. Which is enforced through a composer conflict.
* If you use psalm, the minimum version needed is `3.6.0`. Which is enforced through a composer conflict.
If you don't use psalm, then this has no impact.
## 1.5.0 (2019-08-24)
### Added
### Added
* added `Assert::uniqueValues()`
* added `Assert::unicodeLetters()`
+11 -4
View File
@@ -106,15 +106,19 @@ Method | Description
`isInstanceOf($value, $class, $message = '')` | Check that a value is an `instanceof` a class
`isInstanceOfAny($value, array $classes, $message = '')` | Check that a value is an `instanceof` a at least one class on the array of classes
`notInstanceOf($value, $class, $message = '')` | Check that a value is not an `instanceof` a class
`isAOf($value, $class, $message = '')` | Check that a value is of the class or has one of its parents
`isAnyOf($value, array $classes, $message = '')` | Check that a value a at least one of the class or has one of its parents
`isNotA($value, $class, $message = '')` | Check that a value is not of the class or has not one of its parents
`isArrayAccessible($value, $message = '')` | Check that a value can be accessed as an array
`uniqueValues($values, $message = '')` | Check that the given array contains unique values
### Comparison Assertions
Method | Description
----------------------------------------------- | --------------------------------------------------
----------------------------------------------- | ------------------------------------------------------------------
`true($value, $message = '')` | Check that a value is `true`
`false($value, $message = '')` | Check that a value is `false`
`notFalse($value, $message = '')` | Check that a value is not `false`
`null($value, $message = '')` | Check that a value is `null`
`notNull($value, $message = '')` | Check that a value is not `null`
`isEmpty($value, $message = '')` | Check that a value is `empty()`
@@ -128,7 +132,8 @@ Method | Description
`lessThan($value, $value2, $message = '')` | Check that a value is less than another
`lessThanEq($value, $value2, $message = '')` | Check that a value is less than or equal to another
`range($value, $min, $max, $message = '')` | Check that a value is within a range
`oneOf($value, array $values, $message = '')` | Check that a value is one of a list of values
`inArray($value, array $values, $message = '')` | Check that a value is one of a list of values
`oneOf($value, array $values, $message = '')` | Check that a value is one of a list of values (alias of `inArray`)
### String Assertions
@@ -140,8 +145,10 @@ Method | Description
`contains($value, $subString, $message = '')` | Check that a string contains a substring
`notContains($value, $subString, $message = '')` | Check that a string does not contains a substring
`startsWith($value, $prefix, $message = '')` | Check that a string has a prefix
`notStartsWith($value, $prefix, $message = '')` | Check that a string does not have a prefix
`startsWithLetter($value, $message = '')` | Check that a string starts with a letter
`endsWith($value, $suffix, $message = '')` | Check that a string has a suffix
`notEndsWith($value, $suffix, $message = '')` | Check that a string does not have a suffix
`regex($value, $pattern, $message = '')` | Check that a string matches a regular expression
`notRegex($value, $pattern, $message = '')` | Check that a string does not match a regular expression
`unicodeLetters($value, $message = '')` | Check that a string contains Unicode letters only
@@ -240,7 +247,7 @@ Overriding the following methods in your assertion class allows you to change th
* `protected static function typeToString($value)`
* This method is used for error messages, to convert the a value to a string representing its type.
* `protected static function strlen($value)`
* This method is used to calculate string lenght for relevant methods, using the `mb_strlen` if available and usefull.
* This method is used to calculate string length for relevant methods, using the `mb_strlen` if available and useful.
* `protected static function reportInvalidArgument($message)`
* This method is called when an assertion fails, with the specified error message. Here you can throw your own exception, or log something.
@@ -267,7 +274,7 @@ All contents of this package are licensed under the [MIT license].
[beberlei/assert]: https://github.com/beberlei/assert
[assert package]: https://github.com/beberlei/assert
[Composer]: https://getcomposer.org
[Bernhard Schussek]: http://webmozarts.com
[Bernhard Schussek]: https://webmozarts.com
[The Community Contributors]: https://github.com/webmozart/assert/graphs/contributors
[issue tracker]: https://github.com/webmozart/assert/issues
[Git repository]: https://github.com/webmozart/assert
-5
View File
@@ -1,5 +0,0 @@
{
"require": {
"vimeo/psalm": "^3.6"
}
}
+1 -1
View File
@@ -21,7 +21,7 @@
"phpunit/phpunit": "^4.8.36 || ^7.5.13"
},
"conflict": {
"vimeo/psalm": "<3.6.0"
"vimeo/psalm": "<3.9.1"
},
"autoload": {
"psr-4": {
+1
View File
@@ -4,6 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config ci/vendor/vimeo/psalm/config.xsd"
phpVersion="7.3"
>
<projectFiles>
<directory name="tests/static-analysis" />
+356 -51
View File
@@ -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)
{