summaryrefslogtreecommitdiff
path: root/vendor/webmozart/assert/src/Assert.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/webmozart/assert/src/Assert.php')
-rw-r--r--vendor/webmozart/assert/src/Assert.php38
1 files changed, 26 insertions, 12 deletions
diff --git a/vendor/webmozart/assert/src/Assert.php b/vendor/webmozart/assert/src/Assert.php
index e0fbabc86..db1f3a51a 100644
--- a/vendor/webmozart/assert/src/Assert.php
+++ b/vendor/webmozart/assert/src/Assert.php
@@ -463,7 +463,7 @@ class Assert
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected an instance of any of %2$s. Got: %s',
static::typeToString($value),
- \implode(', ', \array_map(array('static', 'valueToString'), $classes))
+ \implode(', ', \array_map(array(static::class, 'valueToString'), $classes))
));
}
@@ -485,8 +485,8 @@ class Assert
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),
+ $message ?: 'Expected an instance of this class or to this class among its parents "%2$s". Got: %s',
+ static::valueToString($value),
$class
));
}
@@ -511,8 +511,8 @@ class Assert
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),
+ $message ?: 'Expected an instance of this class or to this class among its parents other than "%2$s". Got: %s',
+ static::valueToString($value),
$class
));
}
@@ -539,9 +539,9 @@ class Assert
}
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))
+ $message ?: 'Expected an instance of any of this classes or any of those classes among their parents "%2$s". Got: %s',
+ static::valueToString($value),
+ \implode(', ', $classes)
));
}
@@ -975,7 +975,7 @@ class Assert
static::reportInvalidArgument(\sprintf(
$message ?: 'Expected one of: %2$s. Got: %s',
static::valueToString($value),
- \implode(', ', \array_map(array('static', 'valueToString'), $values))
+ \implode(', ', \array_map(array(static::class, 'valueToString'), $values))
));
}
}
@@ -1822,11 +1822,24 @@ class Assert
*/
public static function isList($array, $message = '')
{
- if (!\is_array($array) || $array !== \array_values($array)) {
+ if (!\is_array($array)) {
static::reportInvalidArgument(
$message ?: 'Expected list - non-associative array.'
);
}
+
+ if ($array === \array_values($array)) {
+ return;
+ }
+
+ $nextKey = -1;
+ foreach ($array as $k => $v) {
+ if ($k !== ++$nextKey) {
+ static::reportInvalidArgument(
+ $message ?: 'Expected list - non-associative array.'
+ );
+ }
+ }
}
/**
@@ -1955,7 +1968,7 @@ class Assert
if ('nullOr' === \substr($name, 0, 6)) {
if (null !== $arguments[0]) {
$method = \lcfirst(\substr($name, 6));
- \call_user_func_array(array('static', $method), $arguments);
+ \call_user_func_array(array(static::class, $method), $arguments);
}
return;
@@ -1970,7 +1983,7 @@ class Assert
foreach ($arguments[0] as $entry) {
$args[0] = $entry;
- \call_user_func_array(array('static', $method), $args);
+ \call_user_func_array(array(static::class, $method), $args);
}
return;
@@ -2054,6 +2067,7 @@ class Assert
* @throws InvalidArgumentException
*
* @psalm-pure this method is not supposed to perform side-effects
+ * @psalm-return never
*/
protected static function reportInvalidArgument($message)
{