simplesamlphp /
assert
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace SimpleSAML\Assert; |
||
| 6 | |||
| 7 | use BadMethodCallException; // Requires ext-spl |
||
| 8 | use DateTime; // Requires ext-date |
||
| 9 | use DateTimeImmutable; // Requires ext-date |
||
| 10 | use InvalidArgumentException; // Requires ext-spl |
||
| 11 | use Throwable; |
||
| 12 | use UnitEnum; |
||
|
0 ignored issues
–
show
|
|||
| 13 | use Webmozart\Assert\Assert as Webmozart; |
||
| 14 | |||
| 15 | use function array_pop; |
||
| 16 | use function array_unshift; |
||
| 17 | use function call_user_func_array; |
||
| 18 | use function end; |
||
| 19 | use function is_object; |
||
| 20 | use function is_resource; |
||
| 21 | use function is_string; |
||
| 22 | use function is_subclass_of; |
||
| 23 | use function lcfirst; |
||
| 24 | use function method_exists; |
||
| 25 | use function preg_match; // Requires ext-pcre |
||
| 26 | use function strval; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Webmozart\Assert wrapper class |
||
| 30 | * |
||
| 31 | * @package simplesamlphp/assert |
||
| 32 | * |
||
| 33 | * @method static void string(mixed $value, string $message = '', string $exception = '') |
||
| 34 | * @method static void stringNotEmpty(mixed $value, string $message = '', string $exception = '') |
||
| 35 | * @method static void integer(mixed $value, string $message = '', string $exception = '') |
||
| 36 | * @method static void integerish(mixed $value, string $message = '', string $exception = '') |
||
| 37 | * @method static void positiveInteger(mixed $value, string $message = '', string $exception = '') |
||
| 38 | * @method static void float(mixed $value, string $message = '', string $exception = '') |
||
| 39 | * @method static void numeric(mixed $value, string $message = '', string $exception = '') |
||
| 40 | * @method static void natural(mixed $value, string $message = '', string $exception = '') |
||
| 41 | * @method static void boolean(mixed $value, string $message = '', string $exception = '') |
||
| 42 | * @method static void scalar(mixed $value, string $message = '', string $exception = '') |
||
| 43 | * @method static void object(mixed $value, string $message = '', string $exception = '') |
||
| 44 | * @method static void resource(mixed $value, string|null $type, string $message = '', string $exception = '') |
||
| 45 | * @method static void isCallable(mixed $value, string $message = '', string $exception = '') |
||
| 46 | * @method static void isArray(mixed $value, string $message = '', string $exception = '') |
||
| 47 | * @method static void isTraversable(mixed $value, string $message = '', string $exception = '') |
||
| 48 | * @method static void isArrayAccessible(mixed $value, string $message = '', string $exception = '') |
||
| 49 | * @method static void isCountable(mixed $value, string $message = '', string $exception = '') |
||
| 50 | * @method static void isIterable(mixed $value, string $message = '', string $exception = '') |
||
| 51 | * @method static void isInstanceOf(mixed $value, string|object $class, string $message = '', string $exception = '') |
||
| 52 | * @method static void notInstanceOf(mixed $value, string|object $class, string $message = '', string $exception = '') |
||
| 53 | * @method static void isInstanceOfAny(mixed $value, array<object|string> $classes, string $message = '', string $exception = '') |
||
| 54 | * @method static void isAOf(string|object $value, string $class, string $message = '', string $exception = '') |
||
| 55 | * @method static void isNotA(string|object $value, string $class, string $message = '', string $exception = '') |
||
| 56 | * @method static void isAnyOf(string|object $value, string[] $classes, string $message = '', string $exception = '') |
||
| 57 | * @method static void isEmpty(mixed $value, string $message = '', string $exception = '') |
||
| 58 | * @method static void notEmpty(mixed $value, string $message = '', string $exception = '') |
||
| 59 | * @method static void null(mixed $value, string $message = '', string $exception = '') |
||
| 60 | * @method static void notNull(mixed $value, string $message = '', string $exception = '') |
||
| 61 | * @method static void true(mixed $value, string $message = '', string $exception = '') |
||
| 62 | * @method static void false(mixed $value, string $message = '', string $exception = '') |
||
| 63 | * @method static void notFalse(mixed $value, string $message = '', string $exception = '') |
||
| 64 | * @method static void ip(mixed $value, string $message = '', string $exception = '') |
||
| 65 | * @method static void ipv4(mixed $value, string $message = '', string $exception = '') |
||
| 66 | * @method static void ipv6(mixed $value, string $message = '', string $exception = '') |
||
| 67 | * @method static void email(mixed $value, string $message = '', string $exception = '') |
||
| 68 | * @method static void uniqueValues(mixed[] $values, string $message = '', string $exception = '') |
||
| 69 | * @method static void eq(mixed $value, mixed $expect, string $message = '', string $exception = '') |
||
| 70 | * @method static void notEq(mixed $value, mixed $expect, string $message = '', string $exception = '') |
||
| 71 | * @method static void same(mixed $value, mixed $expect, string $message = '', string $exception = '') |
||
| 72 | * @method static void notSame(mixed $value, mixed $expect, string $message = '', string $exception = '') |
||
| 73 | * @method static void greaterThan(mixed $value, mixed $limit, string $message = '', string $exception = '') |
||
| 74 | * @method static void greaterThanEq(mixed $value, mixed $limit, string $message = '', string $exception = '') |
||
| 75 | * @method static void lessThan(mixed $value, mixed $limit, string $message = '', string $exception = '') |
||
| 76 | * @method static void lessThanEq(mixed $value, mixed $limit, string $message = '', string $exception = '') |
||
| 77 | * @method static void range(mixed $value, mixed $min, mixed $max, string $message = '', string $exception = '') |
||
| 78 | * @method static void oneOf(mixed $value, mixed[] $values, string $message = '', string $exception = '') |
||
| 79 | * @method static void inArray(mixed $value, mixed $values, string $message = '', string $exception = '') |
||
| 80 | * @method static void contains(string $value, string $subString, string $message = '', string $exception = '') |
||
| 81 | * @method static void notContains(string $value, string $subString, string $message = '', string $exception = '') |
||
| 82 | * @method static void notWhitespaceOnly($value, string $message = '', string $exception = '') |
||
| 83 | * @method static void startsWith(string $value, string $prefix, string $message = '', string $exception = '') |
||
| 84 | * @method static void notStartsWith(string $value, string $prefix, string $message = '', string $exception = '') |
||
| 85 | * @method static void startsWithLetter(mixed $value, string $message = '', string $exception = '') |
||
| 86 | * @method static void endsWith(string $value, string $suffix, string $message = '', string $exception = '') |
||
| 87 | * @method static void notEndsWith(string $value, string $suffix, string $message = '', string $exception = '') |
||
| 88 | * @method static void regex(string $value, string $pattern, string $message = '', string $exception = '') |
||
| 89 | * @method static void notRegex(string $value, string $pattern, string $message = '', string $exception = '') |
||
| 90 | * @method static void unicodeLetters(mixed $value, string $message = '', string $exception = '') |
||
| 91 | * @method static void alpha(mixed $value, string $message = '', string $exception = '') |
||
| 92 | * @method static void digits(string $value, string $message = '', string $exception = '') |
||
| 93 | * @method static void alnum(string $value, string $message = '', string $exception = '') |
||
| 94 | * @method static void lower(string $value, string $message = '', string $exception = '') |
||
| 95 | * @method static void upper(string $value, string $message = '', string $exception = '') |
||
| 96 | * @method static void length(string $value, int $length, string $message = '', string $exception = '') |
||
| 97 | * @method static void minLength(string $value, int|float $min, string $message = '', string $exception = '') |
||
| 98 | * @method static void maxLength(string $value, int|float $max, string $message = '', string $exception = '') |
||
| 99 | * @method static void lengthBetween(string $value, int|float $min, int|float $max, string $message = '', string $exception = '') |
||
| 100 | * @method static void fileExists(mixed $value, string $message = '', string $exception = '') |
||
| 101 | * @method static void file(mixed $value, string $message = '', string $exception = '') |
||
| 102 | * @method static void directory(mixed $value, string $message = '', string $exception = '') |
||
| 103 | * @method static void readable(string $value, string $message = '', string $exception = '') |
||
| 104 | * @method static void writable(string $value, string $message = '', string $exception = '') |
||
| 105 | * @method static void classExists(mixed $value, string $message = '', string $exception = '') |
||
| 106 | * @method static void subclassOf(mixed $value, string|object $class, string $message = '', string $exception = '') |
||
| 107 | * @method static void interfaceExists(mixed $value, string $message = '', string $exception = '') |
||
| 108 | * @method static void implementsInterface(mixed $value, mixed $interface, string $message = '', string $exception = '') |
||
| 109 | * @method static void propertyExists(string|object $classOrObject, mixed $property, string $message = '', string $exception = '') |
||
| 110 | * @method static void propertyNotExists(string|object $classOrObject, mixed $property, string $message = '', string $exception = '') |
||
| 111 | * @method static void methodExists(string|object $classOrObject, mixed $method, string $message = '', string $exception = '') |
||
| 112 | * @method static void methodNotExists(string|object $classOrObject, mixed $method, string $message = '', string $exception = '') |
||
| 113 | * @method static void keyExists(mixed[] $array, string|int $key, string $message = '', string $exception = '') |
||
| 114 | * @method static void keyNotExists(mixed[] $array, string|int $key, string $message = '', string $exception = '') |
||
| 115 | * @method static void validArrayKey($value, string $message = '', string $exception = '') |
||
| 116 | * @method static void count(\Countable|mixed[] $array, int $number, string $message = '', string $exception = '') |
||
| 117 | * @method static void minCount(\Countable|mixed[] $array, int|float $min, string $message = '', string $exception = '') |
||
| 118 | * @method static void maxCount(\Countable|mixed[] $array, int|float $max, string $message = '', string $exception = '') |
||
| 119 | * @method static void countBetween(\Countable|mixed[] $array, int|float $min, int|float $max, string $message = '', string $exception = '') |
||
| 120 | * @method static void isList(mixed $array, string $message = '', string $exception = '') |
||
| 121 | * @method static void isNonEmptyList(mixed $array, string $message = '', string $exception = '') |
||
| 122 | * @method static void isMap(mixed $array, string $message = '', string $exception = '') |
||
| 123 | * @method static void isNonEmptyMap(mixed $array, string $message = '', string $exception = '') |
||
| 124 | * @method static void uuid(string $value, string $message = '', string $exception = '') |
||
| 125 | * @method static void throws(\Closure $expression, string $class = 'Exception', string $message = '', string $exception = '') |
||
| 126 | * |
||
| 127 | * @method static void nullOrString(mixed $value, string $message = '', string $exception = '') |
||
| 128 | * @method static void allString(mixed $value, string $message = '', string $exception = '') |
||
| 129 | * @method static void nullOrStringNotEmpty(mixed $value, string $message = '', string $exception = '') |
||
| 130 | * @method static void allStringNotEmpty(mixed $value, string $message = '', string $exception = '') |
||
| 131 | * @method static void nullOrInteger(mixed $value, string $message = '', string $exception = '') |
||
| 132 | * @method static void allInteger(mixed $value, string $message = '', string $exception = '') |
||
| 133 | * @method static void nullOrIntegerish(mixed $value, string $message = '', string $exception = '') |
||
| 134 | * @method static void allIntegerish(mixed $value, string $message = '', string $exception = '') |
||
| 135 | * @method static void nullOrPositiveInteger(mixed $value, string $message = '', string $exception = '') |
||
| 136 | * @method static void allPositiveInteger(mixed $value, string $message = '', string $exception = '') |
||
| 137 | * @method static void nullOrFloat(mixed $value, string $message = '', string $exception = '') |
||
| 138 | * @method static void allFloat(mixed $value, string $message = '', string $exception = '') |
||
| 139 | * @method static void nullOrNumeric(mixed $value, string $message = '', string $exception = '') |
||
| 140 | * @method static void allNumeric(mixed $value, string $message = '', string $exception = '') |
||
| 141 | * @method static void nullOrNatural(mixed $value, string $message = '', string $exception = '') |
||
| 142 | * @method static void allNatural(mixed $value, string $message = '', string $exception = '') |
||
| 143 | * @method static void nullOrBoolean(mixed $value, string $message = '', string $exception = '') |
||
| 144 | * @method static void allBoolean(mixed $value, string $message = '', string $exception = '') |
||
| 145 | * @method static void nullOrScalar(mixed $value, string $message = '', string $exception = '') |
||
| 146 | * @method static void allScalar(mixed $value, string $message = '', string $exception = '') |
||
| 147 | * @method static void nullOrObject(mixed $value, string $message = '', string $exception = '') |
||
| 148 | * @method static void allObject(mixed $value, string $message = '', string $exception = '') |
||
| 149 | * @method static void nullOrResource(mixed $value, string|null $type, string $message = '', string $exception = '') |
||
| 150 | * @method static void allResource(mixed $value, string|null $type, string $message = '', string $exception = '') |
||
| 151 | * @method static void nullOrIsCallable(mixed $value, string $message = '', string $exception = '') |
||
| 152 | * @method static void allIsCallable(mixed $value, string $message = '', string $exception = '') |
||
| 153 | * @method static void nullOrIsArray(mixed $value, string $message = '', string $exception = '') |
||
| 154 | * @method static void allIsArray(mixed $value, string $message = '', string $exception = '') |
||
| 155 | * @method static void nullOrIsTraversable(mixed $value, string $message = '', string $exception = '') |
||
| 156 | * @method static void allIsTraversable(mixed $value, string $message = '', string $exception = '') |
||
| 157 | * @method static void nullOrIsArrayAccessible(mixed $value, string $message = '', string $exception = '') |
||
| 158 | * @method static void allIsArrayAccessible(mixed $value, string $message = '', string $exception = '') |
||
| 159 | * @method static void nullOrIsCountable(mixed $value, string $message = '', string $exception = '') |
||
| 160 | * @method static void allIsCountable(mixed $value, string $message = '', string $exception = '') |
||
| 161 | * @method static void nullOrIsIterable(mixed $value, string $message = '', string $exception = '') |
||
| 162 | * @method static void allIsIterable(mixed $value, string $message = '', string $exception = '') |
||
| 163 | * @method static void nullOrIsInstanceOf(mixed $value, string|object $class, string $message = '', string $exception = '') |
||
| 164 | * @method static void allIsInstanceOf(mixed $value, string|object $class, string $message = '', string $exception = '') |
||
| 165 | * @method static void nullOrNotInstanceOf(mixed $value, string|object $class, string $message = '', string $exception = '') |
||
| 166 | * @method static void allNotInstanceOf(mixed $value, string|object $class, string $message = '', string $exception = '') |
||
| 167 | * @method static void nullOrIsInstanceOfAny(mixed $value, array<object|string> $classes, string $message = '', string $exception = '') |
||
| 168 | * @method static void allIsInstanceOfAny(mixed $value, array<object|string> $classes, string $message = '', string $exception = '') |
||
| 169 | * @method static void nullOrIsAOf(object|string|null $value, string $class, string $message = '', string $exception = '') |
||
| 170 | * @method static void allIsAOf(object|string|null $value, string $class, string $message = '', string $exception = '') |
||
| 171 | * @method static void nullOrIsNotA(object|string|null $value, string $class, string $message = '', string $exception = '') |
||
| 172 | * @method static void allIsNotA(iterable<object|string> $value, string $class, string $message = '', string $exception = '') |
||
| 173 | * @method static void nullOrIsAnyOf(object|string|null $value, string[] $classes, string $message = '', string $exception = '') |
||
| 174 | * @method static void allIsAnyOf(iterable<object|string> $value, string[] $classes, string $message = '', string $exception = '') |
||
| 175 | * @method static void nullOrIsEmpty(mixed $value, string $message = '', string $exception = '') |
||
| 176 | * @method static void allIsEmpty(mixed $value, string $message = '', string $exception = '') |
||
| 177 | * @method static void nullOrNotEmpty(mixed $value, string $message = '', string $exception = '') |
||
| 178 | * @method static void allNotEmpty(mixed $value, string $message = '', string $exception = '') |
||
| 179 | * @method static void allNull(mixed $value, string $message = '', string $exception = '') |
||
| 180 | * @method static void allNotNull(mixed $value, string $message = '', string $exception = '') |
||
| 181 | * @method static void nullOrTrue(mixed $value, string $message = '', string $exception = '') |
||
| 182 | * @method static void allTrue(mixed $value, string $message = '', string $exception = '') |
||
| 183 | * @method static void nullOrFalse(mixed $value, string $message = '', string $exception = '') |
||
| 184 | * @method static void allFalse(mixed $value, string $message = '', string $exception = '') |
||
| 185 | * @method static void nullOrNotFalse(mixed $value, string $message = '', string $exception = '') |
||
| 186 | * @method static void allNotFalse(mixed $value, string $message = '', string $exception = '') |
||
| 187 | * @method static void nullOrIp(mixed $value, string $message = '', string $exception = '') |
||
| 188 | * @method static void allIp(mixed $value, string $message = '', string $exception = '') |
||
| 189 | * @method static void nullOrIpv4(mixed $value, string $message = '', string $exception = '') |
||
| 190 | * @method static void allIpv4(mixed $value, string $message = '', string $exception = '') |
||
| 191 | * @method static void nullOrIpv6(mixed $value, string $message = '', string $exception = '') |
||
| 192 | * @method static void allIpv6(mixed $value, string $message = '', string $exception = '') |
||
| 193 | * @method static void nullOrEmail(mixed $value, string $message = '', string $exception = '') |
||
| 194 | * @method static void allEmail(mixed $value, string $message = '', string $exception = '') |
||
| 195 | * @method static void nullOrUniqueValues(mixed[]|null $values, string $message = '', string $exception = '') |
||
| 196 | * @method static void allUniqueValues(iterable<mixed[]> $values, string $message = '', string $exception = '') |
||
| 197 | * @method static void nullOrEq(mixed $value, mixed $expect, string $message = '', string $exception = '') |
||
| 198 | * @method static void allEq(mixed $value, mixed $expect, string $message = '', string $exception = '') |
||
| 199 | * @method static void nullOrNotEq(mixed $value, mixed $expect, string $message = '', string $exception = '') |
||
| 200 | * @method static void allNotEq(mixed $value, mixed $expect, string $message = '', string $exception = '') |
||
| 201 | * @method static void nullOrSame(mixed $value, mixed $expect, string $message = '', string $exception = '') |
||
| 202 | * @method static void allSame(mixed $value, mixed $expect, string $message = '', string $exception = '') |
||
| 203 | * @method static void nullOrNotSame(mixed $value, mixed $expect, string $message = '', string $exception = '') |
||
| 204 | * @method static void allNotSame(mixed $value, mixed $expect, string $message = '', string $exception = '') |
||
| 205 | * @method static void nullOrGreaterThan(mixed $value, mixed $limit, string $message = '', string $exception = '') |
||
| 206 | * @method static void allGreaterThan(mixed $value, mixed $limit, string $message = '', string $exception = '') |
||
| 207 | * @method static void nullOrGreaterThanEq(mixed $value, mixed $limit, string $message = '', string $exception = '') |
||
| 208 | * @method static void allGreaterThanEq(mixed $value, mixed $limit, string $message = '', string $exception = '') |
||
| 209 | * @method static void nullOrLessThan(mixed $value, mixed $limit, string $message = '', string $exception = '') |
||
| 210 | * @method static void allLessThan(mixed $value, mixed $limit, string $message = '', string $exception = '') |
||
| 211 | * @method static void nullOrLessThanEq(mixed $value, mixed $limit, string $message = '', string $exception = '') |
||
| 212 | * @method static void allLessThanEq(mixed $value, mixed $limit, string $message = '', string $exception = '') |
||
| 213 | * @method static void nullOrRange(mixed $value, mixed $min, mixed $max, string $message = '', string $exception = '') |
||
| 214 | * @method static void allRange(mixed $value, mixed $min, mixed $max, string $message = '', string $exception = '') |
||
| 215 | * @method static void nullOrOneOf(mixed $value, mixed[] $values, string $message = '', string $exception = '') |
||
| 216 | * @method static void allOneOf(mixed $value, mixed[] $values, string $message = '', string $exception = '') |
||
| 217 | * @method static void nullOrInArray(mixed $value, mixed[] $values, string $message = '', string $exception = '') |
||
| 218 | * @method static void allInArray(mixed $value, mixed[] $values, string $message = '', string $exception = '') |
||
| 219 | * @method static void nullOrContains(string|null $value, string $subString, string $message = '', string $exception = '') |
||
| 220 | * @method static void allContains(string[] $value, string $subString, string $message = '', string $exception = '') |
||
| 221 | * @method static void nullOrNotContains(string|null $value, string $subString, string $message = '', string $exception = '') |
||
| 222 | * @method static void allNotContains(string[] $value, string $subString, string $message = '', string $exception = '') |
||
| 223 | * @method static void nullOrNotWhitespaceOnly(string|null $value, string $message = '', string $exception = '') |
||
| 224 | * @method static void allNotWhitespaceOnly(string[] $value, string $message = '', string $exception = '') |
||
| 225 | * @method static void nullOrStartsWith(string|null $value, string $prefix, string $message = '', string $exception = '') |
||
| 226 | * @method static void allStartsWith(string[] $value, string $prefix, string $message = '', string $exception = '') |
||
| 227 | * @method static void nullOrNotStartsWith(string|null $value, string $prefix, string $message = '', string $exception = '') |
||
| 228 | * @method static void allNotStartsWith(string[] $value, string $prefix, string $message = '', string $exception = '') |
||
| 229 | * @method static void nullOrStartsWithLetter(mixed $value, string $message = '', string $exception = '') |
||
| 230 | * @method static void allStartsWithLetter(string[] $value, string $message = '', string $exception = '') |
||
| 231 | * @method static void nullOrEndsWith(string|null $value, string $suffix, string $message = '', string $exception = '') |
||
| 232 | * @method static void allEndsWith(string[] $value, string $suffix, string $message = '', string $exception = '') |
||
| 233 | * @method static void nullOrNotEndsWith(string|null $value, string $suffix, string $message = '', string $exception = '') |
||
| 234 | * @method static void allNotEndsWith(string[] $value, string $suffix, string $message = '', string $exception = '') |
||
| 235 | * @method static void nullOrRegex(string|null $value, string $prefix, string $message = '', string $exception = '') |
||
| 236 | * @method static void allRegex(string[] $value, string $prefix, string $message = '', string $exception = '') |
||
| 237 | * @method static void nullOrNotRegex(string|null $value, string $prefix, string $message = '', string $exception = '') |
||
| 238 | * @method static void allNotRegex(string[] $value, string $prefix, string $message = '', string $exception = '') |
||
| 239 | * @method static void nullOrUnicodeLetters(mixed $value, string $message = '', string $exception = '') |
||
| 240 | * @method static void allUnicodeLetters(mixed $value, string $message = '', string $exception = '') |
||
| 241 | * @method static void nullOrAlpha(mixed $value, string $message = '', string $exception = '') |
||
| 242 | * @method static void allAlpha(string[] $value, string $message = '', string $exception = '') |
||
| 243 | * @method static void nullOrDigits(string|null $value, string $message = '', string $exception = '') |
||
| 244 | * @method static void allDigits(string[] $value, string $message = '', string $exception = '') |
||
| 245 | * @method static void nullOrAlnum(string|null $value, string $message = '', string $exception = '') |
||
| 246 | * @method static void allAlnum(string[] $value, string $message = '', string $exception = '') |
||
| 247 | * @method static void nullOrLower(string|null $value, string $message = '', string $exception = '') |
||
| 248 | * @method static void allLower(string[] $value, string $message = '', string $exception = '') |
||
| 249 | * @method static void nullOrUpper(string|null $value, string $message = '', string $exception = '') |
||
| 250 | * @method static void allUpper(string[] $value, string $message = '', string $exception = '') |
||
| 251 | * @method static void nullOrLength(string|null $value, int $length, string $message = '', string $exception = '') |
||
| 252 | * @method static void allLength(string[] $value, int $length, string $message = '', string $exception = '') |
||
| 253 | * @method static void nullOrMinLength(string|null $value, int|float $min, string $message = '', string $exception = '') |
||
| 254 | * @method static void allMinLength(string[] $value, int|float $min, string $message = '', string $exception = '') |
||
| 255 | * @method static void nullOrMaxLength(string|null $value, int|float $max, string $message = '', string $exception = '') |
||
| 256 | * @method static void allMaxLength(string[] $value, int|float $max, string $message = '', string $exception = '') |
||
| 257 | * @method static void nullOrLengthBetween(string|null $value, int|float $min, int|float $max, string $message = '', string $exception = '') |
||
| 258 | * @method static void allLengthBetween(string[] $value, int|float $min, int|float $max, string $message = '', string $exception = '') |
||
| 259 | * @method static void nullOrFileExists(mixed $value, string $message = '', string $exception = '') |
||
| 260 | * @method static void allFileExists(mixed $value, string $message = '', string $exception = '') |
||
| 261 | * @method static void nullOrFile(mixed $value, string $message = '', string $exception = '') |
||
| 262 | * @method static void allFile(mixed $value, string $message = '', string $exception = '') |
||
| 263 | * @method static void nullOrDirectory(mixed $value, string $message = '', string $exception = '') |
||
| 264 | * @method static void allDirectory(mixed $value, string $message = '', string $exception = '') |
||
| 265 | * @method static void nullOrReadable(string|null $value, string $message = '', string $exception = '') |
||
| 266 | * @method static void allReadable(string[] $value, string $message = '', string $exception = '') |
||
| 267 | * @method static void nullOrWritable(string|null $value, string $message = '', string $exception = '') |
||
| 268 | * @method static void allWritable(string[] $value, string $message = '', string $exception = '') |
||
| 269 | * @method static void nullOrClassExists(mixed $value, string $message = '', string $exception = '') |
||
| 270 | * @method static void allClassExists(mixed $value, string $message = '', string $exception = '') |
||
| 271 | * @method static void nullOrSubclassOf(mixed $value, string|object $class, string $message = '', string $exception = '') |
||
| 272 | * @method static void allSubclassOf(mixed $value, string|object $class, string $message = '', string $exception = '') |
||
| 273 | * @method static void nullOrInterfaceExists(mixed $value, string $message = '', string $exception = '') |
||
| 274 | * @method static void allInterfaceExists(mixed $value, string $message = '', string $exception = '') |
||
| 275 | * @method static void nullOrImplementsInterface(mixed $value, mixed $interface, string $message = '', string $exception = '') |
||
| 276 | * @method static void allImplementsInterface(mixed $value, mixed $interface, string $message = '', string $exception = '') |
||
| 277 | * @method static void nullOrPropertyExists(string|object|null $classOrObject, mixed $property, string $message = '', string $exception = '') |
||
| 278 | * @method static void allPropertyExists(iterable<string|object> $classOrObject, mixed $property, string $message = '', string $exception = '') |
||
| 279 | * @method static void nullOrPropertyNotExists(string|object|null $classOrObject, mixed $property, string $message = '', string $exception = '') |
||
| 280 | * @method static void allPropertyNotExists(iterable<string|object> $classOrObject, mixed $property, string $message = '', string $exception = '') |
||
| 281 | * @method static void nullOrMethodExists(string|object|null $classOrObject, mixed $method, string $message = '', string $exception = '') |
||
| 282 | * @method static void allMethodExists(iterable<string|object> $classOrObject, mixed $method, string $message = '', string $exception = '') |
||
| 283 | * @method static void nullOrMethodNotExists(string|object|null $classOrObject, mixed $method, string $message = '', string $exception = '') |
||
| 284 | * @method static void allMethodNotExists(iterable<string|object> $classOrObject, mixed $method, string $message = '', string $exception = '') |
||
| 285 | * @method static void nullOrKeyExists(mixed[]|null $array, string|int $key, string $message = '', string $exception = '') |
||
| 286 | * @method static void allKeyExists(iterable<mixed[]> $array, string|int $key, string $message = '', string $exception = '') |
||
| 287 | * @method static void nullOrKeyNotExists(mixed[]|null $array, string|int $key, string $message = '', string $exception = '') |
||
| 288 | * @method static void allKeyNotExists(iterable<mixed[]> $array, string|int $key, string $message = '', string $exception = '') |
||
| 289 | * @method static void nullOrValidArrayKey(mixed $value, string $message = '', string $exception = '') |
||
| 290 | * @method static void allValidArrayKey(mixed $value, string $message = '', string $exception = '') |
||
| 291 | * @method static void nullOrCount(\Countable|mixed[]|null $array, int $number, string $message = '', string $exception = '') |
||
| 292 | * @method static void allCount(iterable<\Countable|mixed[]> $array, int $number, string $message = '', string $exception = '') |
||
| 293 | * @method static void nullOrMinCount(\Countable|mixed[]|null $array, int|float $min, string $message = '', string $exception = '') |
||
| 294 | * @method static void allMinCount(iterable<\Countable|mixed[]> $array, int|float $min, string $message = '', string $exception = '') |
||
| 295 | * @method static void nullOrMaxCount(\Countable|mixed[]|null $array, int|float $max, string $message = '', string $exception = '') |
||
| 296 | * @method static void allMaxCount(iterable<\Countable|mixed[]> $array, int|float $max, string $message = '', string $exception = '') |
||
| 297 | * @method static void nullOrCountBetween(\Countable|mixed[]|null $array, int|float $min, int|float $max, string $message = '', string $exception = '') |
||
| 298 | * @method static void allCountBetween(iterable<\Countable|mixed[]> $array, int|float $min, int|float $max, string $message = '', string $exception = '') |
||
| 299 | * @method static void nullOrIsList(mixed $array, string $message = '', string $exception = '') |
||
| 300 | * @method static void allIsList(mixed $array, string $message = '', string $exception = '') |
||
| 301 | * @method static void nullOrIsNonEmptyList(mixed $array, string $message = '', string $exception = '') |
||
| 302 | * @method static void allIsNonEmptyList(mixed $array, string $message = '', string $exception = '') |
||
| 303 | * @method static void nullOrIsMap(mixed $array, string $message = '', string $exception = '') |
||
| 304 | * @method static void allIsMap(mixed $array, string $message = '', string $exception = '') |
||
| 305 | * @method static void nullOrIsNonEmptyMap(mixed $array, string $message = '', string $exception = '') |
||
| 306 | * @method static void allIsNonEmptyMap(mixed $array, string $message = '', string $exception = '') |
||
| 307 | * @method static void nullOrUuid(string|null $value, string $message = '', string $exception = '') |
||
| 308 | * @method static void allUuid(string[] $value, string $message = '', string $exception = '') |
||
| 309 | * @method static void nullOrThrows(\Closure|null $expression, string $class, string $message = '', string $exception = '') |
||
| 310 | * @method static void allThrows(\Closure[] $expression, string $class, string $message = '', string $exception = '') |
||
| 311 | * |
||
| 312 | * @method static void validBase64(mixed $value, string $message = '', string $exception = '') |
||
| 313 | * @method static void notInArray(mixed $value, mixed[] $values, string $message = '', string $exception = '') |
||
| 314 | * @method static void validURN(mixed $value, string $message = '', string $exception = '') |
||
| 315 | * @method static void validURI(mixed $value, string $message = '', string $exception = '') |
||
| 316 | * @method static void validURL(mixed $value, string $message = '', string $exception = '') |
||
| 317 | * @method static void nullOrValidBase64(mixed $value, string $message = '', string $exception = '') |
||
| 318 | * @method static void nullOrNotInArray(mixed $value, mixed[] $values, string $message = '', string $exception = '') |
||
| 319 | * @method static void nullOrValidURN(mixed $value, string $message = '', string $exception = '') |
||
| 320 | * @method static void nullOrValidURI(mixed $value, string $message = '', string $exception = '') |
||
| 321 | * @method static void nullOrValidURL(mixed $value, string $message = '', string $exception = '') |
||
| 322 | * @method static void allValidBase64(mixed $value, string $message = '', string $exception = '') |
||
| 323 | * @method static void allNotInArray(mixed $value, mixed[] $values, string $message = '', string $exception = '') |
||
| 324 | * @method static void allValidURN(mixed $value, string $message = '', string $exception = '') |
||
| 325 | * @method static void allValidURI(mixed $value, string $message = '', string $exception = '') |
||
| 326 | * @method static void allValidURL(mixed $value, string $message = '', string $exception = '') |
||
| 327 | */ |
||
| 328 | class Assert |
||
| 329 | { |
||
| 330 | use Base64Trait; |
||
| 331 | use NotInArrayTrait; |
||
| 332 | use URITrait; |
||
| 333 | |||
| 334 | |||
| 335 | /** |
||
| 336 | * @param string $name |
||
| 337 | * @param mixed[] $arguments |
||
| 338 | */ |
||
| 339 | public static function __callStatic(string $name, array $arguments): void |
||
| 340 | { |
||
| 341 | // Handle Exception-parameter |
||
| 342 | $exception = AssertionFailedException::class; |
||
| 343 | |||
| 344 | $last = end($arguments); |
||
| 345 | if (is_string($last) && class_exists($last) && is_subclass_of($last, Throwable::class)) { |
||
| 346 | $exception = $last; |
||
| 347 | array_pop($arguments); |
||
| 348 | } |
||
| 349 | |||
| 350 | try { |
||
| 351 | // Putting Webmozart first, since the most calls will be to their native assertions |
||
| 352 | if (method_exists(Webmozart::class, $name)) { |
||
| 353 | $callable = [Webmozart::class, $name]; |
||
| 354 | (is_callable($callable)) && call_user_func_array($callable, $arguments); |
||
| 355 | return; |
||
| 356 | } elseif (method_exists(static::class, $name)) { |
||
| 357 | $callable = [static::class, $name]; |
||
| 358 | (is_callable($callable)) && call_user_func_array($callable, $arguments); |
||
| 359 | return; |
||
| 360 | } elseif (preg_match('/^nullOr(.+)$/i', $name, $matches)) { |
||
| 361 | $method = lcfirst($matches[1]); |
||
| 362 | if (method_exists(Webmozart::class, $method)) { |
||
| 363 | call_user_func_array([static::class, 'nullOr'], [[Webmozart::class, $method], $arguments]); |
||
| 364 | } elseif (method_exists(static::class, $method)) { |
||
| 365 | call_user_func_array([static::class, 'nullOr'], [[static::class, $method], $arguments]); |
||
| 366 | } else { |
||
| 367 | throw new BadMethodCallException(sprintf("Assertion named `%s` does not exists.", $method)); |
||
| 368 | } |
||
| 369 | } elseif (preg_match('/^all(.+)$/i', $name, $matches)) { |
||
| 370 | $method = lcfirst($matches[1]); |
||
| 371 | if (method_exists(Webmozart::class, $method)) { |
||
| 372 | call_user_func_array([static::class, 'all'], [[Webmozart::class, $method], $arguments]); |
||
| 373 | } elseif (method_exists(static::class, $method)) { |
||
| 374 | call_user_func_array([static::class, 'all'], [[static::class, $method], $arguments]); |
||
| 375 | } else { |
||
| 376 | throw new BadMethodCallException(sprintf("Assertion named `%s` does not exists.", $method)); |
||
| 377 | } |
||
| 378 | } else { |
||
| 379 | throw new BadMethodCallException(sprintf("Assertion named `%s` does not exists.", $name)); |
||
| 380 | } |
||
| 381 | } catch (InvalidArgumentException $e) { |
||
| 382 | throw new $exception($e->getMessage()); |
||
| 383 | } |
||
| 384 | } |
||
| 385 | |||
| 386 | |||
| 387 | /** |
||
| 388 | * Handle nullOr* for either Webmozart or for our custom assertions |
||
| 389 | * |
||
| 390 | * @param callable $method |
||
| 391 | * @param mixed[] $arguments |
||
| 392 | * @return void |
||
| 393 | */ |
||
| 394 | private static function nullOr(callable $method, array $arguments): void |
||
| 395 | { |
||
| 396 | $value = reset($arguments); |
||
| 397 | ($value === null) || call_user_func_array($method, $arguments); |
||
| 398 | } |
||
| 399 | |||
| 400 | |||
| 401 | /** |
||
| 402 | * all* for our custom assertions |
||
| 403 | * |
||
| 404 | * @param callable $method |
||
| 405 | * @param mixed[] $arguments |
||
| 406 | * @return void |
||
| 407 | */ |
||
| 408 | private static function all(callable $method, array $arguments): void |
||
| 409 | { |
||
| 410 | $values = array_pop($arguments); |
||
| 411 | foreach ($values as $value) { |
||
| 412 | $tmp = $arguments; |
||
| 413 | array_unshift($tmp, $value); |
||
| 414 | call_user_func_array($method, $tmp); |
||
| 415 | } |
||
| 416 | } |
||
| 417 | |||
| 418 | |||
| 419 | /** |
||
| 420 | * @param mixed $value |
||
| 421 | * |
||
| 422 | * @return string |
||
| 423 | */ |
||
| 424 | protected static function valueToString(mixed $value): string |
||
| 425 | { |
||
| 426 | if (is_resource($value)) { |
||
| 427 | return 'resource'; |
||
| 428 | } |
||
| 429 | |||
| 430 | if (null === $value) { |
||
| 431 | return 'null'; |
||
| 432 | } |
||
| 433 | |||
| 434 | if (true === $value) { |
||
| 435 | return 'true'; |
||
| 436 | } |
||
| 437 | |||
| 438 | if (false === $value) { |
||
| 439 | return 'false'; |
||
| 440 | } |
||
| 441 | |||
| 442 | if (is_array($value)) { |
||
| 443 | return 'array'; |
||
| 444 | } |
||
| 445 | |||
| 446 | if (is_object($value)) { |
||
| 447 | if (method_exists($value, '__toString')) { |
||
| 448 | return $value::class . ': ' . self::valueToString($value->__toString()); |
||
| 449 | } |
||
| 450 | |||
| 451 | if ($value instanceof DateTime || $value instanceof DateTimeImmutable) { |
||
| 452 | return $value::class . ': ' . self::valueToString($value->format('c')); |
||
| 453 | } |
||
| 454 | |||
| 455 | if ($value instanceof UnitEnum) { |
||
| 456 | return $value::class . '::' . $value->name; |
||
| 457 | } |
||
| 458 | |||
| 459 | return $value::class; |
||
| 460 | } |
||
| 461 | |||
| 462 | if (is_string($value)) { |
||
| 463 | return '"' . $value . '"'; |
||
| 464 | } |
||
| 465 | |||
| 466 | return strval($value); |
||
| 467 | } |
||
| 468 | } |
||
| 469 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths