@@ -18,9 +18,9 @@ |
||
| 18 | 18 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Client\ClientInterface; |
| 19 | 19 | class NoResurrect implements ResurrectInterface |
| 20 | 20 | { |
| 21 | - protected ClientInterface $client; |
|
| 22 | - public function ping(Node $node) : bool |
|
| 23 | - { |
|
| 24 | - return \false; |
|
| 25 | - } |
|
| 21 | + protected ClientInterface $client; |
|
| 22 | + public function ping(Node $node) : bool |
|
| 23 | + { |
|
| 24 | + return \false; |
|
| 25 | + } |
|
| 26 | 26 | } |
@@ -16,8 +16,7 @@ |
||
| 16 | 16 | |
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node; |
| 18 | 18 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Client\ClientInterface; |
| 19 | -class NoResurrect implements ResurrectInterface |
|
| 20 | -{ |
|
| 19 | +class NoResurrect implements ResurrectInterface { |
|
| 21 | 20 | protected ClientInterface $client; |
| 22 | 21 | public function ping(Node $node) : bool |
| 23 | 22 | { |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | * Elasticsearch B.V licenses this file to you under the MIT License. |
| 12 | 12 | * See the LICENSE file in the project root for more information. |
| 13 | 13 | */ |
| 14 | -declare (strict_types=1); |
|
| 14 | +declare(strict_types=1); |
|
| 15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Resurrect; |
| 16 | 16 | |
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node; |
@@ -18,5 +18,5 @@ |
||
| 18 | 18 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Client\ClientInterface; |
| 19 | 19 | interface ResurrectInterface |
| 20 | 20 | { |
| 21 | - public function ping(Node $node) : bool; |
|
| 21 | + public function ping(Node $node) : bool; |
|
| 22 | 22 | } |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | |
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node; |
| 18 | 18 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Client\ClientInterface; |
| 19 | -interface ResurrectInterface |
|
| 20 | -{ |
|
| 19 | +interface ResurrectInterface { |
|
| 21 | 20 | public function ping(Node $node) : bool; |
| 22 | 21 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | * Elasticsearch B.V licenses this file to you under the MIT License. |
| 12 | 12 | * See the LICENSE file in the project root for more information. |
| 13 | 13 | */ |
| 14 | -declare (strict_types=1); |
|
| 14 | +declare(strict_types=1); |
|
| 15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Resurrect; |
| 16 | 16 | |
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node; |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface; |
| 18 | 18 | interface OnSuccessInterface |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @return mixed |
|
| 22 | - */ |
|
| 23 | - public function success(ResponseInterface $request, int $count); |
|
| 20 | + /** |
|
| 21 | + * @return mixed |
|
| 22 | + */ |
|
| 23 | + public function success(ResponseInterface $request, int $count); |
|
| 24 | 24 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | * Elasticsearch B.V licenses this file to you under the MIT License. |
| 12 | 12 | * See the LICENSE file in the project root for more information. |
| 13 | 13 | */ |
| 14 | -declare (strict_types=1); |
|
| 14 | +declare(strict_types=1); |
|
| 15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Async; |
| 16 | 16 | |
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface; |
@@ -15,8 +15,7 @@ |
||
| 15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Async; |
| 16 | 16 | |
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface; |
| 18 | -interface OnSuccessInterface |
|
| 19 | -{ |
|
| 18 | +interface OnSuccessInterface { |
|
| 20 | 19 | /** |
| 21 | 20 | * @return mixed |
| 22 | 21 | */ |
@@ -17,8 +17,8 @@ |
||
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface; |
| 18 | 18 | class OnSuccessDefault implements OnSuccessInterface |
| 19 | 19 | { |
| 20 | - public function success(ResponseInterface $response, int $count) |
|
| 21 | - { |
|
| 22 | - return $response; |
|
| 23 | - } |
|
| 20 | + public function success(ResponseInterface $response, int $count) |
|
| 21 | + { |
|
| 22 | + return $response; |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -15,8 +15,7 @@ |
||
| 15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Async; |
| 16 | 16 | |
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface; |
| 18 | -class OnSuccessDefault implements OnSuccessInterface |
|
| 19 | -{ |
|
| 18 | +class OnSuccessDefault implements OnSuccessInterface { |
|
| 20 | 19 | public function success(ResponseInterface $response, int $count) |
| 21 | 20 | { |
| 22 | 21 | return $response; |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | * Elasticsearch B.V licenses this file to you under the MIT License. |
| 12 | 12 | * See the LICENSE file in the project root for more information. |
| 13 | 13 | */ |
| 14 | -declare (strict_types=1); |
|
| 14 | +declare(strict_types=1); |
|
| 15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Async; |
| 16 | 16 | |
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface; |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\RequestInterface; |
| 20 | 20 | class OnFailureDefault implements OnFailureInterface |
| 21 | 21 | { |
| 22 | - public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null) : void |
|
| 23 | - { |
|
| 24 | - } |
|
| 22 | + public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null) : void |
|
| 23 | + { |
|
| 24 | + } |
|
| 25 | 25 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | * Elasticsearch B.V licenses this file to you under the MIT License. |
| 12 | 12 | * See the LICENSE file in the project root for more information. |
| 13 | 13 | */ |
| 14 | -declare (strict_types=1); |
|
| 14 | +declare(strict_types=1); |
|
| 15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Async; |
| 16 | 16 | |
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node; |
@@ -17,8 +17,7 @@ |
||
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node; |
| 18 | 18 | use Exception; |
| 19 | 19 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\RequestInterface; |
| 20 | -class OnFailureDefault implements OnFailureInterface |
|
| 21 | -{ |
|
| 20 | +class OnFailureDefault implements OnFailureInterface { |
|
| 22 | 21 | public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null) : void |
| 23 | 22 | { |
| 24 | 23 | } |
@@ -19,5 +19,5 @@ |
||
| 19 | 19 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\RequestInterface; |
| 20 | 20 | interface OnFailureInterface |
| 21 | 21 | { |
| 22 | - public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null) : void; |
|
| 22 | + public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null) : void; |
|
| 23 | 23 | } |
@@ -17,7 +17,6 @@ |
||
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node; |
| 18 | 18 | use Exception; |
| 19 | 19 | use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\RequestInterface; |
| 20 | -interface OnFailureInterface |
|
| 21 | -{ |
|
| 20 | +interface OnFailureInterface { |
|
| 22 | 21 | public function failure(Exception $e, RequestInterface $request, int $count, Node $node = null) : void; |
| 23 | 22 | } |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | * Elasticsearch B.V licenses this file to you under the MIT License. |
| 12 | 12 | * See the LICENSE file in the project root for more information. |
| 13 | 13 | */ |
| 14 | -declare (strict_types=1); |
|
| 14 | +declare(strict_types=1); |
|
| 15 | 15 | namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Async; |
| 16 | 16 | |
| 17 | 17 | use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node; |
@@ -13,5077 +13,5077 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | trait Mixin |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * @psalm-pure |
|
| 18 | - * @psalm-assert string|null $value |
|
| 19 | - * |
|
| 20 | - * @param mixed $value |
|
| 21 | - * @param string $message |
|
| 22 | - * |
|
| 23 | - * @throws InvalidArgumentException |
|
| 24 | - * |
|
| 25 | - * @return void |
|
| 26 | - */ |
|
| 27 | - public static function nullOrString($value, $message = '') |
|
| 28 | - { |
|
| 29 | - null === $value || static::string($value, $message); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @psalm-pure |
|
| 34 | - * @psalm-assert iterable<string> $value |
|
| 35 | - * |
|
| 36 | - * @param mixed $value |
|
| 37 | - * @param string $message |
|
| 38 | - * |
|
| 39 | - * @throws InvalidArgumentException |
|
| 40 | - * |
|
| 41 | - * @return void |
|
| 42 | - */ |
|
| 43 | - public static function allString($value, $message = '') |
|
| 44 | - { |
|
| 45 | - static::isIterable($value); |
|
| 46 | - |
|
| 47 | - foreach ($value as $entry) { |
|
| 48 | - static::string($entry, $message); |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @psalm-pure |
|
| 54 | - * @psalm-assert iterable<string|null> $value |
|
| 55 | - * |
|
| 56 | - * @param mixed $value |
|
| 57 | - * @param string $message |
|
| 58 | - * |
|
| 59 | - * @throws InvalidArgumentException |
|
| 60 | - * |
|
| 61 | - * @return void |
|
| 62 | - */ |
|
| 63 | - public static function allNullOrString($value, $message = '') |
|
| 64 | - { |
|
| 65 | - static::isIterable($value); |
|
| 66 | - |
|
| 67 | - foreach ($value as $entry) { |
|
| 68 | - null === $entry || static::string($entry, $message); |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @psalm-pure |
|
| 74 | - * @psalm-assert non-empty-string|null $value |
|
| 75 | - * |
|
| 76 | - * @param mixed $value |
|
| 77 | - * @param string $message |
|
| 78 | - * |
|
| 79 | - * @throws InvalidArgumentException |
|
| 80 | - * |
|
| 81 | - * @return void |
|
| 82 | - */ |
|
| 83 | - public static function nullOrStringNotEmpty($value, $message = '') |
|
| 84 | - { |
|
| 85 | - null === $value || static::stringNotEmpty($value, $message); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * @psalm-pure |
|
| 90 | - * @psalm-assert iterable<non-empty-string> $value |
|
| 91 | - * |
|
| 92 | - * @param mixed $value |
|
| 93 | - * @param string $message |
|
| 94 | - * |
|
| 95 | - * @throws InvalidArgumentException |
|
| 96 | - * |
|
| 97 | - * @return void |
|
| 98 | - */ |
|
| 99 | - public static function allStringNotEmpty($value, $message = '') |
|
| 100 | - { |
|
| 101 | - static::isIterable($value); |
|
| 102 | - |
|
| 103 | - foreach ($value as $entry) { |
|
| 104 | - static::stringNotEmpty($entry, $message); |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * @psalm-pure |
|
| 110 | - * @psalm-assert iterable<non-empty-string|null> $value |
|
| 111 | - * |
|
| 112 | - * @param mixed $value |
|
| 113 | - * @param string $message |
|
| 114 | - * |
|
| 115 | - * @throws InvalidArgumentException |
|
| 116 | - * |
|
| 117 | - * @return void |
|
| 118 | - */ |
|
| 119 | - public static function allNullOrStringNotEmpty($value, $message = '') |
|
| 120 | - { |
|
| 121 | - static::isIterable($value); |
|
| 122 | - |
|
| 123 | - foreach ($value as $entry) { |
|
| 124 | - null === $entry || static::stringNotEmpty($entry, $message); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @psalm-pure |
|
| 130 | - * @psalm-assert int|null $value |
|
| 131 | - * |
|
| 132 | - * @param mixed $value |
|
| 133 | - * @param string $message |
|
| 134 | - * |
|
| 135 | - * @throws InvalidArgumentException |
|
| 136 | - * |
|
| 137 | - * @return void |
|
| 138 | - */ |
|
| 139 | - public static function nullOrInteger($value, $message = '') |
|
| 140 | - { |
|
| 141 | - null === $value || static::integer($value, $message); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * @psalm-pure |
|
| 146 | - * @psalm-assert iterable<int> $value |
|
| 147 | - * |
|
| 148 | - * @param mixed $value |
|
| 149 | - * @param string $message |
|
| 150 | - * |
|
| 151 | - * @throws InvalidArgumentException |
|
| 152 | - * |
|
| 153 | - * @return void |
|
| 154 | - */ |
|
| 155 | - public static function allInteger($value, $message = '') |
|
| 156 | - { |
|
| 157 | - static::isIterable($value); |
|
| 158 | - |
|
| 159 | - foreach ($value as $entry) { |
|
| 160 | - static::integer($entry, $message); |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * @psalm-pure |
|
| 166 | - * @psalm-assert iterable<int|null> $value |
|
| 167 | - * |
|
| 168 | - * @param mixed $value |
|
| 169 | - * @param string $message |
|
| 170 | - * |
|
| 171 | - * @throws InvalidArgumentException |
|
| 172 | - * |
|
| 173 | - * @return void |
|
| 174 | - */ |
|
| 175 | - public static function allNullOrInteger($value, $message = '') |
|
| 176 | - { |
|
| 177 | - static::isIterable($value); |
|
| 178 | - |
|
| 179 | - foreach ($value as $entry) { |
|
| 180 | - null === $entry || static::integer($entry, $message); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * @psalm-pure |
|
| 186 | - * @psalm-assert numeric|null $value |
|
| 187 | - * |
|
| 188 | - * @param mixed $value |
|
| 189 | - * @param string $message |
|
| 190 | - * |
|
| 191 | - * @throws InvalidArgumentException |
|
| 192 | - * |
|
| 193 | - * @return void |
|
| 194 | - */ |
|
| 195 | - public static function nullOrIntegerish($value, $message = '') |
|
| 196 | - { |
|
| 197 | - null === $value || static::integerish($value, $message); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * @psalm-pure |
|
| 202 | - * @psalm-assert iterable<numeric> $value |
|
| 203 | - * |
|
| 204 | - * @param mixed $value |
|
| 205 | - * @param string $message |
|
| 206 | - * |
|
| 207 | - * @throws InvalidArgumentException |
|
| 208 | - * |
|
| 209 | - * @return void |
|
| 210 | - */ |
|
| 211 | - public static function allIntegerish($value, $message = '') |
|
| 212 | - { |
|
| 213 | - static::isIterable($value); |
|
| 214 | - |
|
| 215 | - foreach ($value as $entry) { |
|
| 216 | - static::integerish($entry, $message); |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * @psalm-pure |
|
| 222 | - * @psalm-assert iterable<numeric|null> $value |
|
| 223 | - * |
|
| 224 | - * @param mixed $value |
|
| 225 | - * @param string $message |
|
| 226 | - * |
|
| 227 | - * @throws InvalidArgumentException |
|
| 228 | - * |
|
| 229 | - * @return void |
|
| 230 | - */ |
|
| 231 | - public static function allNullOrIntegerish($value, $message = '') |
|
| 232 | - { |
|
| 233 | - static::isIterable($value); |
|
| 234 | - |
|
| 235 | - foreach ($value as $entry) { |
|
| 236 | - null === $entry || static::integerish($entry, $message); |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * @psalm-pure |
|
| 242 | - * @psalm-assert positive-int|null $value |
|
| 243 | - * |
|
| 244 | - * @param mixed $value |
|
| 245 | - * @param string $message |
|
| 246 | - * |
|
| 247 | - * @throws InvalidArgumentException |
|
| 248 | - * |
|
| 249 | - * @return void |
|
| 250 | - */ |
|
| 251 | - public static function nullOrPositiveInteger($value, $message = '') |
|
| 252 | - { |
|
| 253 | - null === $value || static::positiveInteger($value, $message); |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * @psalm-pure |
|
| 258 | - * @psalm-assert iterable<positive-int> $value |
|
| 259 | - * |
|
| 260 | - * @param mixed $value |
|
| 261 | - * @param string $message |
|
| 262 | - * |
|
| 263 | - * @throws InvalidArgumentException |
|
| 264 | - * |
|
| 265 | - * @return void |
|
| 266 | - */ |
|
| 267 | - public static function allPositiveInteger($value, $message = '') |
|
| 268 | - { |
|
| 269 | - static::isIterable($value); |
|
| 270 | - |
|
| 271 | - foreach ($value as $entry) { |
|
| 272 | - static::positiveInteger($entry, $message); |
|
| 273 | - } |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - /** |
|
| 277 | - * @psalm-pure |
|
| 278 | - * @psalm-assert iterable<positive-int|null> $value |
|
| 279 | - * |
|
| 280 | - * @param mixed $value |
|
| 281 | - * @param string $message |
|
| 282 | - * |
|
| 283 | - * @throws InvalidArgumentException |
|
| 284 | - * |
|
| 285 | - * @return void |
|
| 286 | - */ |
|
| 287 | - public static function allNullOrPositiveInteger($value, $message = '') |
|
| 288 | - { |
|
| 289 | - static::isIterable($value); |
|
| 290 | - |
|
| 291 | - foreach ($value as $entry) { |
|
| 292 | - null === $entry || static::positiveInteger($entry, $message); |
|
| 293 | - } |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * @psalm-pure |
|
| 298 | - * @psalm-assert float|null $value |
|
| 299 | - * |
|
| 300 | - * @param mixed $value |
|
| 301 | - * @param string $message |
|
| 302 | - * |
|
| 303 | - * @throws InvalidArgumentException |
|
| 304 | - * |
|
| 305 | - * @return void |
|
| 306 | - */ |
|
| 307 | - public static function nullOrFloat($value, $message = '') |
|
| 308 | - { |
|
| 309 | - null === $value || static::float($value, $message); |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * @psalm-pure |
|
| 314 | - * @psalm-assert iterable<float> $value |
|
| 315 | - * |
|
| 316 | - * @param mixed $value |
|
| 317 | - * @param string $message |
|
| 318 | - * |
|
| 319 | - * @throws InvalidArgumentException |
|
| 320 | - * |
|
| 321 | - * @return void |
|
| 322 | - */ |
|
| 323 | - public static function allFloat($value, $message = '') |
|
| 324 | - { |
|
| 325 | - static::isIterable($value); |
|
| 326 | - |
|
| 327 | - foreach ($value as $entry) { |
|
| 328 | - static::float($entry, $message); |
|
| 329 | - } |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - /** |
|
| 333 | - * @psalm-pure |
|
| 334 | - * @psalm-assert iterable<float|null> $value |
|
| 335 | - * |
|
| 336 | - * @param mixed $value |
|
| 337 | - * @param string $message |
|
| 338 | - * |
|
| 339 | - * @throws InvalidArgumentException |
|
| 340 | - * |
|
| 341 | - * @return void |
|
| 342 | - */ |
|
| 343 | - public static function allNullOrFloat($value, $message = '') |
|
| 344 | - { |
|
| 345 | - static::isIterable($value); |
|
| 346 | - |
|
| 347 | - foreach ($value as $entry) { |
|
| 348 | - null === $entry || static::float($entry, $message); |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * @psalm-pure |
|
| 354 | - * @psalm-assert numeric|null $value |
|
| 355 | - * |
|
| 356 | - * @param mixed $value |
|
| 357 | - * @param string $message |
|
| 358 | - * |
|
| 359 | - * @throws InvalidArgumentException |
|
| 360 | - * |
|
| 361 | - * @return void |
|
| 362 | - */ |
|
| 363 | - public static function nullOrNumeric($value, $message = '') |
|
| 364 | - { |
|
| 365 | - null === $value || static::numeric($value, $message); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - /** |
|
| 369 | - * @psalm-pure |
|
| 370 | - * @psalm-assert iterable<numeric> $value |
|
| 371 | - * |
|
| 372 | - * @param mixed $value |
|
| 373 | - * @param string $message |
|
| 374 | - * |
|
| 375 | - * @throws InvalidArgumentException |
|
| 376 | - * |
|
| 377 | - * @return void |
|
| 378 | - */ |
|
| 379 | - public static function allNumeric($value, $message = '') |
|
| 380 | - { |
|
| 381 | - static::isIterable($value); |
|
| 382 | - |
|
| 383 | - foreach ($value as $entry) { |
|
| 384 | - static::numeric($entry, $message); |
|
| 385 | - } |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * @psalm-pure |
|
| 390 | - * @psalm-assert iterable<numeric|null> $value |
|
| 391 | - * |
|
| 392 | - * @param mixed $value |
|
| 393 | - * @param string $message |
|
| 394 | - * |
|
| 395 | - * @throws InvalidArgumentException |
|
| 396 | - * |
|
| 397 | - * @return void |
|
| 398 | - */ |
|
| 399 | - public static function allNullOrNumeric($value, $message = '') |
|
| 400 | - { |
|
| 401 | - static::isIterable($value); |
|
| 402 | - |
|
| 403 | - foreach ($value as $entry) { |
|
| 404 | - null === $entry || static::numeric($entry, $message); |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * @psalm-pure |
|
| 410 | - * @psalm-assert positive-int|0|null $value |
|
| 411 | - * |
|
| 412 | - * @param mixed $value |
|
| 413 | - * @param string $message |
|
| 414 | - * |
|
| 415 | - * @throws InvalidArgumentException |
|
| 416 | - * |
|
| 417 | - * @return void |
|
| 418 | - */ |
|
| 419 | - public static function nullOrNatural($value, $message = '') |
|
| 420 | - { |
|
| 421 | - null === $value || static::natural($value, $message); |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * @psalm-pure |
|
| 426 | - * @psalm-assert iterable<positive-int|0> $value |
|
| 427 | - * |
|
| 428 | - * @param mixed $value |
|
| 429 | - * @param string $message |
|
| 430 | - * |
|
| 431 | - * @throws InvalidArgumentException |
|
| 432 | - * |
|
| 433 | - * @return void |
|
| 434 | - */ |
|
| 435 | - public static function allNatural($value, $message = '') |
|
| 436 | - { |
|
| 437 | - static::isIterable($value); |
|
| 438 | - |
|
| 439 | - foreach ($value as $entry) { |
|
| 440 | - static::natural($entry, $message); |
|
| 441 | - } |
|
| 442 | - } |
|
| 443 | - |
|
| 444 | - /** |
|
| 445 | - * @psalm-pure |
|
| 446 | - * @psalm-assert iterable<positive-int|0|null> $value |
|
| 447 | - * |
|
| 448 | - * @param mixed $value |
|
| 449 | - * @param string $message |
|
| 450 | - * |
|
| 451 | - * @throws InvalidArgumentException |
|
| 452 | - * |
|
| 453 | - * @return void |
|
| 454 | - */ |
|
| 455 | - public static function allNullOrNatural($value, $message = '') |
|
| 456 | - { |
|
| 457 | - static::isIterable($value); |
|
| 458 | - |
|
| 459 | - foreach ($value as $entry) { |
|
| 460 | - null === $entry || static::natural($entry, $message); |
|
| 461 | - } |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - /** |
|
| 465 | - * @psalm-pure |
|
| 466 | - * @psalm-assert bool|null $value |
|
| 467 | - * |
|
| 468 | - * @param mixed $value |
|
| 469 | - * @param string $message |
|
| 470 | - * |
|
| 471 | - * @throws InvalidArgumentException |
|
| 472 | - * |
|
| 473 | - * @return void |
|
| 474 | - */ |
|
| 475 | - public static function nullOrBoolean($value, $message = '') |
|
| 476 | - { |
|
| 477 | - null === $value || static::boolean($value, $message); |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - /** |
|
| 481 | - * @psalm-pure |
|
| 482 | - * @psalm-assert iterable<bool> $value |
|
| 483 | - * |
|
| 484 | - * @param mixed $value |
|
| 485 | - * @param string $message |
|
| 486 | - * |
|
| 487 | - * @throws InvalidArgumentException |
|
| 488 | - * |
|
| 489 | - * @return void |
|
| 490 | - */ |
|
| 491 | - public static function allBoolean($value, $message = '') |
|
| 492 | - { |
|
| 493 | - static::isIterable($value); |
|
| 494 | - |
|
| 495 | - foreach ($value as $entry) { |
|
| 496 | - static::boolean($entry, $message); |
|
| 497 | - } |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - /** |
|
| 501 | - * @psalm-pure |
|
| 502 | - * @psalm-assert iterable<bool|null> $value |
|
| 503 | - * |
|
| 504 | - * @param mixed $value |
|
| 505 | - * @param string $message |
|
| 506 | - * |
|
| 507 | - * @throws InvalidArgumentException |
|
| 508 | - * |
|
| 509 | - * @return void |
|
| 510 | - */ |
|
| 511 | - public static function allNullOrBoolean($value, $message = '') |
|
| 512 | - { |
|
| 513 | - static::isIterable($value); |
|
| 514 | - |
|
| 515 | - foreach ($value as $entry) { |
|
| 516 | - null === $entry || static::boolean($entry, $message); |
|
| 517 | - } |
|
| 518 | - } |
|
| 519 | - |
|
| 520 | - /** |
|
| 521 | - * @psalm-pure |
|
| 522 | - * @psalm-assert scalar|null $value |
|
| 523 | - * |
|
| 524 | - * @param mixed $value |
|
| 525 | - * @param string $message |
|
| 526 | - * |
|
| 527 | - * @throws InvalidArgumentException |
|
| 528 | - * |
|
| 529 | - * @return void |
|
| 530 | - */ |
|
| 531 | - public static function nullOrScalar($value, $message = '') |
|
| 532 | - { |
|
| 533 | - null === $value || static::scalar($value, $message); |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - /** |
|
| 537 | - * @psalm-pure |
|
| 538 | - * @psalm-assert iterable<scalar> $value |
|
| 539 | - * |
|
| 540 | - * @param mixed $value |
|
| 541 | - * @param string $message |
|
| 542 | - * |
|
| 543 | - * @throws InvalidArgumentException |
|
| 544 | - * |
|
| 545 | - * @return void |
|
| 546 | - */ |
|
| 547 | - public static function allScalar($value, $message = '') |
|
| 548 | - { |
|
| 549 | - static::isIterable($value); |
|
| 550 | - |
|
| 551 | - foreach ($value as $entry) { |
|
| 552 | - static::scalar($entry, $message); |
|
| 553 | - } |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - /** |
|
| 557 | - * @psalm-pure |
|
| 558 | - * @psalm-assert iterable<scalar|null> $value |
|
| 559 | - * |
|
| 560 | - * @param mixed $value |
|
| 561 | - * @param string $message |
|
| 562 | - * |
|
| 563 | - * @throws InvalidArgumentException |
|
| 564 | - * |
|
| 565 | - * @return void |
|
| 566 | - */ |
|
| 567 | - public static function allNullOrScalar($value, $message = '') |
|
| 568 | - { |
|
| 569 | - static::isIterable($value); |
|
| 570 | - |
|
| 571 | - foreach ($value as $entry) { |
|
| 572 | - null === $entry || static::scalar($entry, $message); |
|
| 573 | - } |
|
| 574 | - } |
|
| 575 | - |
|
| 576 | - /** |
|
| 577 | - * @psalm-pure |
|
| 578 | - * @psalm-assert object|null $value |
|
| 579 | - * |
|
| 580 | - * @param mixed $value |
|
| 581 | - * @param string $message |
|
| 582 | - * |
|
| 583 | - * @throws InvalidArgumentException |
|
| 584 | - * |
|
| 585 | - * @return void |
|
| 586 | - */ |
|
| 587 | - public static function nullOrObject($value, $message = '') |
|
| 588 | - { |
|
| 589 | - null === $value || static::object($value, $message); |
|
| 590 | - } |
|
| 591 | - |
|
| 592 | - /** |
|
| 593 | - * @psalm-pure |
|
| 594 | - * @psalm-assert iterable<object> $value |
|
| 595 | - * |
|
| 596 | - * @param mixed $value |
|
| 597 | - * @param string $message |
|
| 598 | - * |
|
| 599 | - * @throws InvalidArgumentException |
|
| 600 | - * |
|
| 601 | - * @return void |
|
| 602 | - */ |
|
| 603 | - public static function allObject($value, $message = '') |
|
| 604 | - { |
|
| 605 | - static::isIterable($value); |
|
| 606 | - |
|
| 607 | - foreach ($value as $entry) { |
|
| 608 | - static::object($entry, $message); |
|
| 609 | - } |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - /** |
|
| 613 | - * @psalm-pure |
|
| 614 | - * @psalm-assert iterable<object|null> $value |
|
| 615 | - * |
|
| 616 | - * @param mixed $value |
|
| 617 | - * @param string $message |
|
| 618 | - * |
|
| 619 | - * @throws InvalidArgumentException |
|
| 620 | - * |
|
| 621 | - * @return void |
|
| 622 | - */ |
|
| 623 | - public static function allNullOrObject($value, $message = '') |
|
| 624 | - { |
|
| 625 | - static::isIterable($value); |
|
| 626 | - |
|
| 627 | - foreach ($value as $entry) { |
|
| 628 | - null === $entry || static::object($entry, $message); |
|
| 629 | - } |
|
| 630 | - } |
|
| 631 | - |
|
| 632 | - /** |
|
| 633 | - * @psalm-pure |
|
| 634 | - * @psalm-assert resource|null $value |
|
| 635 | - * |
|
| 636 | - * @param mixed $value |
|
| 637 | - * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php |
|
| 638 | - * @param string $message |
|
| 639 | - * |
|
| 640 | - * @throws InvalidArgumentException |
|
| 641 | - * |
|
| 642 | - * @return void |
|
| 643 | - */ |
|
| 644 | - public static function nullOrResource($value, $type = null, $message = '') |
|
| 645 | - { |
|
| 646 | - null === $value || static::resource($value, $type, $message); |
|
| 647 | - } |
|
| 648 | - |
|
| 649 | - /** |
|
| 650 | - * @psalm-pure |
|
| 651 | - * @psalm-assert iterable<resource> $value |
|
| 652 | - * |
|
| 653 | - * @param mixed $value |
|
| 654 | - * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php |
|
| 655 | - * @param string $message |
|
| 656 | - * |
|
| 657 | - * @throws InvalidArgumentException |
|
| 658 | - * |
|
| 659 | - * @return void |
|
| 660 | - */ |
|
| 661 | - public static function allResource($value, $type = null, $message = '') |
|
| 662 | - { |
|
| 663 | - static::isIterable($value); |
|
| 664 | - |
|
| 665 | - foreach ($value as $entry) { |
|
| 666 | - static::resource($entry, $type, $message); |
|
| 667 | - } |
|
| 668 | - } |
|
| 669 | - |
|
| 670 | - /** |
|
| 671 | - * @psalm-pure |
|
| 672 | - * @psalm-assert iterable<resource|null> $value |
|
| 673 | - * |
|
| 674 | - * @param mixed $value |
|
| 675 | - * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php |
|
| 676 | - * @param string $message |
|
| 677 | - * |
|
| 678 | - * @throws InvalidArgumentException |
|
| 679 | - * |
|
| 680 | - * @return void |
|
| 681 | - */ |
|
| 682 | - public static function allNullOrResource($value, $type = null, $message = '') |
|
| 683 | - { |
|
| 684 | - static::isIterable($value); |
|
| 685 | - |
|
| 686 | - foreach ($value as $entry) { |
|
| 687 | - null === $entry || static::resource($entry, $type, $message); |
|
| 688 | - } |
|
| 689 | - } |
|
| 690 | - |
|
| 691 | - /** |
|
| 692 | - * @psalm-pure |
|
| 693 | - * @psalm-assert callable|null $value |
|
| 694 | - * |
|
| 695 | - * @param mixed $value |
|
| 696 | - * @param string $message |
|
| 697 | - * |
|
| 698 | - * @throws InvalidArgumentException |
|
| 699 | - * |
|
| 700 | - * @return void |
|
| 701 | - */ |
|
| 702 | - public static function nullOrIsCallable($value, $message = '') |
|
| 703 | - { |
|
| 704 | - null === $value || static::isCallable($value, $message); |
|
| 705 | - } |
|
| 706 | - |
|
| 707 | - /** |
|
| 708 | - * @psalm-pure |
|
| 709 | - * @psalm-assert iterable<callable> $value |
|
| 710 | - * |
|
| 711 | - * @param mixed $value |
|
| 712 | - * @param string $message |
|
| 713 | - * |
|
| 714 | - * @throws InvalidArgumentException |
|
| 715 | - * |
|
| 716 | - * @return void |
|
| 717 | - */ |
|
| 718 | - public static function allIsCallable($value, $message = '') |
|
| 719 | - { |
|
| 720 | - static::isIterable($value); |
|
| 721 | - |
|
| 722 | - foreach ($value as $entry) { |
|
| 723 | - static::isCallable($entry, $message); |
|
| 724 | - } |
|
| 725 | - } |
|
| 726 | - |
|
| 727 | - /** |
|
| 728 | - * @psalm-pure |
|
| 729 | - * @psalm-assert iterable<callable|null> $value |
|
| 730 | - * |
|
| 731 | - * @param mixed $value |
|
| 732 | - * @param string $message |
|
| 733 | - * |
|
| 734 | - * @throws InvalidArgumentException |
|
| 735 | - * |
|
| 736 | - * @return void |
|
| 737 | - */ |
|
| 738 | - public static function allNullOrIsCallable($value, $message = '') |
|
| 739 | - { |
|
| 740 | - static::isIterable($value); |
|
| 741 | - |
|
| 742 | - foreach ($value as $entry) { |
|
| 743 | - null === $entry || static::isCallable($entry, $message); |
|
| 744 | - } |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - /** |
|
| 748 | - * @psalm-pure |
|
| 749 | - * @psalm-assert array|null $value |
|
| 750 | - * |
|
| 751 | - * @param mixed $value |
|
| 752 | - * @param string $message |
|
| 753 | - * |
|
| 754 | - * @throws InvalidArgumentException |
|
| 755 | - * |
|
| 756 | - * @return void |
|
| 757 | - */ |
|
| 758 | - public static function nullOrIsArray($value, $message = '') |
|
| 759 | - { |
|
| 760 | - null === $value || static::isArray($value, $message); |
|
| 761 | - } |
|
| 762 | - |
|
| 763 | - /** |
|
| 764 | - * @psalm-pure |
|
| 765 | - * @psalm-assert iterable<array> $value |
|
| 766 | - * |
|
| 767 | - * @param mixed $value |
|
| 768 | - * @param string $message |
|
| 769 | - * |
|
| 770 | - * @throws InvalidArgumentException |
|
| 771 | - * |
|
| 772 | - * @return void |
|
| 773 | - */ |
|
| 774 | - public static function allIsArray($value, $message = '') |
|
| 775 | - { |
|
| 776 | - static::isIterable($value); |
|
| 777 | - |
|
| 778 | - foreach ($value as $entry) { |
|
| 779 | - static::isArray($entry, $message); |
|
| 780 | - } |
|
| 781 | - } |
|
| 782 | - |
|
| 783 | - /** |
|
| 784 | - * @psalm-pure |
|
| 785 | - * @psalm-assert iterable<array|null> $value |
|
| 786 | - * |
|
| 787 | - * @param mixed $value |
|
| 788 | - * @param string $message |
|
| 789 | - * |
|
| 790 | - * @throws InvalidArgumentException |
|
| 791 | - * |
|
| 792 | - * @return void |
|
| 793 | - */ |
|
| 794 | - public static function allNullOrIsArray($value, $message = '') |
|
| 795 | - { |
|
| 796 | - static::isIterable($value); |
|
| 797 | - |
|
| 798 | - foreach ($value as $entry) { |
|
| 799 | - null === $entry || static::isArray($entry, $message); |
|
| 800 | - } |
|
| 801 | - } |
|
| 802 | - |
|
| 803 | - /** |
|
| 804 | - * @psalm-pure |
|
| 805 | - * @psalm-assert iterable|null $value |
|
| 806 | - * |
|
| 807 | - * @deprecated use "isIterable" or "isInstanceOf" instead |
|
| 808 | - * |
|
| 809 | - * @param mixed $value |
|
| 810 | - * @param string $message |
|
| 811 | - * |
|
| 812 | - * @throws InvalidArgumentException |
|
| 813 | - * |
|
| 814 | - * @return void |
|
| 815 | - */ |
|
| 816 | - public static function nullOrIsTraversable($value, $message = '') |
|
| 817 | - { |
|
| 818 | - null === $value || static::isTraversable($value, $message); |
|
| 819 | - } |
|
| 820 | - |
|
| 821 | - /** |
|
| 822 | - * @psalm-pure |
|
| 823 | - * @psalm-assert iterable<iterable> $value |
|
| 824 | - * |
|
| 825 | - * @deprecated use "isIterable" or "isInstanceOf" instead |
|
| 826 | - * |
|
| 827 | - * @param mixed $value |
|
| 828 | - * @param string $message |
|
| 829 | - * |
|
| 830 | - * @throws InvalidArgumentException |
|
| 831 | - * |
|
| 832 | - * @return void |
|
| 833 | - */ |
|
| 834 | - public static function allIsTraversable($value, $message = '') |
|
| 835 | - { |
|
| 836 | - static::isIterable($value); |
|
| 837 | - |
|
| 838 | - foreach ($value as $entry) { |
|
| 839 | - static::isTraversable($entry, $message); |
|
| 840 | - } |
|
| 841 | - } |
|
| 842 | - |
|
| 843 | - /** |
|
| 844 | - * @psalm-pure |
|
| 845 | - * @psalm-assert iterable<iterable|null> $value |
|
| 846 | - * |
|
| 847 | - * @deprecated use "isIterable" or "isInstanceOf" instead |
|
| 848 | - * |
|
| 849 | - * @param mixed $value |
|
| 850 | - * @param string $message |
|
| 851 | - * |
|
| 852 | - * @throws InvalidArgumentException |
|
| 853 | - * |
|
| 854 | - * @return void |
|
| 855 | - */ |
|
| 856 | - public static function allNullOrIsTraversable($value, $message = '') |
|
| 857 | - { |
|
| 858 | - static::isIterable($value); |
|
| 859 | - |
|
| 860 | - foreach ($value as $entry) { |
|
| 861 | - null === $entry || static::isTraversable($entry, $message); |
|
| 862 | - } |
|
| 863 | - } |
|
| 864 | - |
|
| 865 | - /** |
|
| 866 | - * @psalm-pure |
|
| 867 | - * @psalm-assert array|ArrayAccess|null $value |
|
| 868 | - * |
|
| 869 | - * @param mixed $value |
|
| 870 | - * @param string $message |
|
| 871 | - * |
|
| 872 | - * @throws InvalidArgumentException |
|
| 873 | - * |
|
| 874 | - * @return void |
|
| 875 | - */ |
|
| 876 | - public static function nullOrIsArrayAccessible($value, $message = '') |
|
| 877 | - { |
|
| 878 | - null === $value || static::isArrayAccessible($value, $message); |
|
| 879 | - } |
|
| 880 | - |
|
| 881 | - /** |
|
| 882 | - * @psalm-pure |
|
| 883 | - * @psalm-assert iterable<array|ArrayAccess> $value |
|
| 884 | - * |
|
| 885 | - * @param mixed $value |
|
| 886 | - * @param string $message |
|
| 887 | - * |
|
| 888 | - * @throws InvalidArgumentException |
|
| 889 | - * |
|
| 890 | - * @return void |
|
| 891 | - */ |
|
| 892 | - public static function allIsArrayAccessible($value, $message = '') |
|
| 893 | - { |
|
| 894 | - static::isIterable($value); |
|
| 895 | - |
|
| 896 | - foreach ($value as $entry) { |
|
| 897 | - static::isArrayAccessible($entry, $message); |
|
| 898 | - } |
|
| 899 | - } |
|
| 900 | - |
|
| 901 | - /** |
|
| 902 | - * @psalm-pure |
|
| 903 | - * @psalm-assert iterable<array|ArrayAccess|null> $value |
|
| 904 | - * |
|
| 905 | - * @param mixed $value |
|
| 906 | - * @param string $message |
|
| 907 | - * |
|
| 908 | - * @throws InvalidArgumentException |
|
| 909 | - * |
|
| 910 | - * @return void |
|
| 911 | - */ |
|
| 912 | - public static function allNullOrIsArrayAccessible($value, $message = '') |
|
| 913 | - { |
|
| 914 | - static::isIterable($value); |
|
| 915 | - |
|
| 916 | - foreach ($value as $entry) { |
|
| 917 | - null === $entry || static::isArrayAccessible($entry, $message); |
|
| 918 | - } |
|
| 919 | - } |
|
| 920 | - |
|
| 921 | - /** |
|
| 922 | - * @psalm-pure |
|
| 923 | - * @psalm-assert countable|null $value |
|
| 924 | - * |
|
| 925 | - * @param mixed $value |
|
| 926 | - * @param string $message |
|
| 927 | - * |
|
| 928 | - * @throws InvalidArgumentException |
|
| 929 | - * |
|
| 930 | - * @return void |
|
| 931 | - */ |
|
| 932 | - public static function nullOrIsCountable($value, $message = '') |
|
| 933 | - { |
|
| 934 | - null === $value || static::isCountable($value, $message); |
|
| 935 | - } |
|
| 936 | - |
|
| 937 | - /** |
|
| 938 | - * @psalm-pure |
|
| 939 | - * @psalm-assert iterable<countable> $value |
|
| 940 | - * |
|
| 941 | - * @param mixed $value |
|
| 942 | - * @param string $message |
|
| 943 | - * |
|
| 944 | - * @throws InvalidArgumentException |
|
| 945 | - * |
|
| 946 | - * @return void |
|
| 947 | - */ |
|
| 948 | - public static function allIsCountable($value, $message = '') |
|
| 949 | - { |
|
| 950 | - static::isIterable($value); |
|
| 951 | - |
|
| 952 | - foreach ($value as $entry) { |
|
| 953 | - static::isCountable($entry, $message); |
|
| 954 | - } |
|
| 955 | - } |
|
| 956 | - |
|
| 957 | - /** |
|
| 958 | - * @psalm-pure |
|
| 959 | - * @psalm-assert iterable<countable|null> $value |
|
| 960 | - * |
|
| 961 | - * @param mixed $value |
|
| 962 | - * @param string $message |
|
| 963 | - * |
|
| 964 | - * @throws InvalidArgumentException |
|
| 965 | - * |
|
| 966 | - * @return void |
|
| 967 | - */ |
|
| 968 | - public static function allNullOrIsCountable($value, $message = '') |
|
| 969 | - { |
|
| 970 | - static::isIterable($value); |
|
| 971 | - |
|
| 972 | - foreach ($value as $entry) { |
|
| 973 | - null === $entry || static::isCountable($entry, $message); |
|
| 974 | - } |
|
| 975 | - } |
|
| 976 | - |
|
| 977 | - /** |
|
| 978 | - * @psalm-pure |
|
| 979 | - * @psalm-assert iterable|null $value |
|
| 980 | - * |
|
| 981 | - * @param mixed $value |
|
| 982 | - * @param string $message |
|
| 983 | - * |
|
| 984 | - * @throws InvalidArgumentException |
|
| 985 | - * |
|
| 986 | - * @return void |
|
| 987 | - */ |
|
| 988 | - public static function nullOrIsIterable($value, $message = '') |
|
| 989 | - { |
|
| 990 | - null === $value || static::isIterable($value, $message); |
|
| 991 | - } |
|
| 992 | - |
|
| 993 | - /** |
|
| 994 | - * @psalm-pure |
|
| 995 | - * @psalm-assert iterable<iterable> $value |
|
| 996 | - * |
|
| 997 | - * @param mixed $value |
|
| 998 | - * @param string $message |
|
| 999 | - * |
|
| 1000 | - * @throws InvalidArgumentException |
|
| 1001 | - * |
|
| 1002 | - * @return void |
|
| 1003 | - */ |
|
| 1004 | - public static function allIsIterable($value, $message = '') |
|
| 1005 | - { |
|
| 1006 | - static::isIterable($value); |
|
| 1007 | - |
|
| 1008 | - foreach ($value as $entry) { |
|
| 1009 | - static::isIterable($entry, $message); |
|
| 1010 | - } |
|
| 1011 | - } |
|
| 1012 | - |
|
| 1013 | - /** |
|
| 1014 | - * @psalm-pure |
|
| 1015 | - * @psalm-assert iterable<iterable|null> $value |
|
| 1016 | - * |
|
| 1017 | - * @param mixed $value |
|
| 1018 | - * @param string $message |
|
| 1019 | - * |
|
| 1020 | - * @throws InvalidArgumentException |
|
| 1021 | - * |
|
| 1022 | - * @return void |
|
| 1023 | - */ |
|
| 1024 | - public static function allNullOrIsIterable($value, $message = '') |
|
| 1025 | - { |
|
| 1026 | - static::isIterable($value); |
|
| 1027 | - |
|
| 1028 | - foreach ($value as $entry) { |
|
| 1029 | - null === $entry || static::isIterable($entry, $message); |
|
| 1030 | - } |
|
| 1031 | - } |
|
| 1032 | - |
|
| 1033 | - /** |
|
| 1034 | - * @psalm-pure |
|
| 1035 | - * @psalm-template ExpectedType of object |
|
| 1036 | - * @psalm-param class-string<ExpectedType> $class |
|
| 1037 | - * @psalm-assert ExpectedType|null $value |
|
| 1038 | - * |
|
| 1039 | - * @param mixed $value |
|
| 1040 | - * @param string|object $class |
|
| 1041 | - * @param string $message |
|
| 1042 | - * |
|
| 1043 | - * @throws InvalidArgumentException |
|
| 1044 | - * |
|
| 1045 | - * @return void |
|
| 1046 | - */ |
|
| 1047 | - public static function nullOrIsInstanceOf($value, $class, $message = '') |
|
| 1048 | - { |
|
| 1049 | - null === $value || static::isInstanceOf($value, $class, $message); |
|
| 1050 | - } |
|
| 1051 | - |
|
| 1052 | - /** |
|
| 1053 | - * @psalm-pure |
|
| 1054 | - * @psalm-template ExpectedType of object |
|
| 1055 | - * @psalm-param class-string<ExpectedType> $class |
|
| 1056 | - * @psalm-assert iterable<ExpectedType> $value |
|
| 1057 | - * |
|
| 1058 | - * @param mixed $value |
|
| 1059 | - * @param string|object $class |
|
| 1060 | - * @param string $message |
|
| 1061 | - * |
|
| 1062 | - * @throws InvalidArgumentException |
|
| 1063 | - * |
|
| 1064 | - * @return void |
|
| 1065 | - */ |
|
| 1066 | - public static function allIsInstanceOf($value, $class, $message = '') |
|
| 1067 | - { |
|
| 1068 | - static::isIterable($value); |
|
| 1069 | - |
|
| 1070 | - foreach ($value as $entry) { |
|
| 1071 | - static::isInstanceOf($entry, $class, $message); |
|
| 1072 | - } |
|
| 1073 | - } |
|
| 1074 | - |
|
| 1075 | - /** |
|
| 1076 | - * @psalm-pure |
|
| 1077 | - * @psalm-template ExpectedType of object |
|
| 1078 | - * @psalm-param class-string<ExpectedType> $class |
|
| 1079 | - * @psalm-assert iterable<ExpectedType|null> $value |
|
| 1080 | - * |
|
| 1081 | - * @param mixed $value |
|
| 1082 | - * @param string|object $class |
|
| 1083 | - * @param string $message |
|
| 1084 | - * |
|
| 1085 | - * @throws InvalidArgumentException |
|
| 1086 | - * |
|
| 1087 | - * @return void |
|
| 1088 | - */ |
|
| 1089 | - public static function allNullOrIsInstanceOf($value, $class, $message = '') |
|
| 1090 | - { |
|
| 1091 | - static::isIterable($value); |
|
| 1092 | - |
|
| 1093 | - foreach ($value as $entry) { |
|
| 1094 | - null === $entry || static::isInstanceOf($entry, $class, $message); |
|
| 1095 | - } |
|
| 1096 | - } |
|
| 1097 | - |
|
| 1098 | - /** |
|
| 1099 | - * @psalm-pure |
|
| 1100 | - * @psalm-template ExpectedType of object |
|
| 1101 | - * @psalm-param class-string<ExpectedType> $class |
|
| 1102 | - * |
|
| 1103 | - * @param mixed $value |
|
| 1104 | - * @param string|object $class |
|
| 1105 | - * @param string $message |
|
| 1106 | - * |
|
| 1107 | - * @throws InvalidArgumentException |
|
| 1108 | - * |
|
| 1109 | - * @return void |
|
| 1110 | - */ |
|
| 1111 | - public static function nullOrNotInstanceOf($value, $class, $message = '') |
|
| 1112 | - { |
|
| 1113 | - null === $value || static::notInstanceOf($value, $class, $message); |
|
| 1114 | - } |
|
| 1115 | - |
|
| 1116 | - /** |
|
| 1117 | - * @psalm-pure |
|
| 1118 | - * @psalm-template ExpectedType of object |
|
| 1119 | - * @psalm-param class-string<ExpectedType> $class |
|
| 1120 | - * |
|
| 1121 | - * @param mixed $value |
|
| 1122 | - * @param string|object $class |
|
| 1123 | - * @param string $message |
|
| 1124 | - * |
|
| 1125 | - * @throws InvalidArgumentException |
|
| 1126 | - * |
|
| 1127 | - * @return void |
|
| 1128 | - */ |
|
| 1129 | - public static function allNotInstanceOf($value, $class, $message = '') |
|
| 1130 | - { |
|
| 1131 | - static::isIterable($value); |
|
| 1132 | - |
|
| 1133 | - foreach ($value as $entry) { |
|
| 1134 | - static::notInstanceOf($entry, $class, $message); |
|
| 1135 | - } |
|
| 1136 | - } |
|
| 1137 | - |
|
| 1138 | - /** |
|
| 1139 | - * @psalm-pure |
|
| 1140 | - * @psalm-template ExpectedType of object |
|
| 1141 | - * @psalm-param class-string<ExpectedType> $class |
|
| 1142 | - * @psalm-assert iterable<!ExpectedType|null> $value |
|
| 1143 | - * |
|
| 1144 | - * @param mixed $value |
|
| 1145 | - * @param string|object $class |
|
| 1146 | - * @param string $message |
|
| 1147 | - * |
|
| 1148 | - * @throws InvalidArgumentException |
|
| 1149 | - * |
|
| 1150 | - * @return void |
|
| 1151 | - */ |
|
| 1152 | - public static function allNullOrNotInstanceOf($value, $class, $message = '') |
|
| 1153 | - { |
|
| 1154 | - static::isIterable($value); |
|
| 1155 | - |
|
| 1156 | - foreach ($value as $entry) { |
|
| 1157 | - null === $entry || static::notInstanceOf($entry, $class, $message); |
|
| 1158 | - } |
|
| 1159 | - } |
|
| 1160 | - |
|
| 1161 | - /** |
|
| 1162 | - * @psalm-pure |
|
| 1163 | - * @psalm-param array<class-string> $classes |
|
| 1164 | - * |
|
| 1165 | - * @param mixed $value |
|
| 1166 | - * @param array<object|string> $classes |
|
| 1167 | - * @param string $message |
|
| 1168 | - * |
|
| 1169 | - * @throws InvalidArgumentException |
|
| 1170 | - * |
|
| 1171 | - * @return void |
|
| 1172 | - */ |
|
| 1173 | - public static function nullOrIsInstanceOfAny($value, $classes, $message = '') |
|
| 1174 | - { |
|
| 1175 | - null === $value || static::isInstanceOfAny($value, $classes, $message); |
|
| 1176 | - } |
|
| 1177 | - |
|
| 1178 | - /** |
|
| 1179 | - * @psalm-pure |
|
| 1180 | - * @psalm-param array<class-string> $classes |
|
| 1181 | - * |
|
| 1182 | - * @param mixed $value |
|
| 1183 | - * @param array<object|string> $classes |
|
| 1184 | - * @param string $message |
|
| 1185 | - * |
|
| 1186 | - * @throws InvalidArgumentException |
|
| 1187 | - * |
|
| 1188 | - * @return void |
|
| 1189 | - */ |
|
| 1190 | - public static function allIsInstanceOfAny($value, $classes, $message = '') |
|
| 1191 | - { |
|
| 1192 | - static::isIterable($value); |
|
| 1193 | - |
|
| 1194 | - foreach ($value as $entry) { |
|
| 1195 | - static::isInstanceOfAny($entry, $classes, $message); |
|
| 1196 | - } |
|
| 1197 | - } |
|
| 1198 | - |
|
| 1199 | - /** |
|
| 1200 | - * @psalm-pure |
|
| 1201 | - * @psalm-param array<class-string> $classes |
|
| 1202 | - * |
|
| 1203 | - * @param mixed $value |
|
| 1204 | - * @param array<object|string> $classes |
|
| 1205 | - * @param string $message |
|
| 1206 | - * |
|
| 1207 | - * @throws InvalidArgumentException |
|
| 1208 | - * |
|
| 1209 | - * @return void |
|
| 1210 | - */ |
|
| 1211 | - public static function allNullOrIsInstanceOfAny($value, $classes, $message = '') |
|
| 1212 | - { |
|
| 1213 | - static::isIterable($value); |
|
| 1214 | - |
|
| 1215 | - foreach ($value as $entry) { |
|
| 1216 | - null === $entry || static::isInstanceOfAny($entry, $classes, $message); |
|
| 1217 | - } |
|
| 1218 | - } |
|
| 1219 | - |
|
| 1220 | - /** |
|
| 1221 | - * @psalm-pure |
|
| 1222 | - * @psalm-template ExpectedType of object |
|
| 1223 | - * @psalm-param class-string<ExpectedType> $class |
|
| 1224 | - * @psalm-assert ExpectedType|class-string<ExpectedType>|null $value |
|
| 1225 | - * |
|
| 1226 | - * @param object|string|null $value |
|
| 1227 | - * @param string $class |
|
| 1228 | - * @param string $message |
|
| 1229 | - * |
|
| 1230 | - * @throws InvalidArgumentException |
|
| 1231 | - * |
|
| 1232 | - * @return void |
|
| 1233 | - */ |
|
| 1234 | - public static function nullOrIsAOf($value, $class, $message = '') |
|
| 1235 | - { |
|
| 1236 | - null === $value || static::isAOf($value, $class, $message); |
|
| 1237 | - } |
|
| 1238 | - |
|
| 1239 | - /** |
|
| 1240 | - * @psalm-pure |
|
| 1241 | - * @psalm-template ExpectedType of object |
|
| 1242 | - * @psalm-param class-string<ExpectedType> $class |
|
| 1243 | - * @psalm-assert iterable<ExpectedType|class-string<ExpectedType>> $value |
|
| 1244 | - * |
|
| 1245 | - * @param iterable<object|string> $value |
|
| 1246 | - * @param string $class |
|
| 1247 | - * @param string $message |
|
| 1248 | - * |
|
| 1249 | - * @throws InvalidArgumentException |
|
| 1250 | - * |
|
| 1251 | - * @return void |
|
| 1252 | - */ |
|
| 1253 | - public static function allIsAOf($value, $class, $message = '') |
|
| 1254 | - { |
|
| 1255 | - static::isIterable($value); |
|
| 1256 | - |
|
| 1257 | - foreach ($value as $entry) { |
|
| 1258 | - static::isAOf($entry, $class, $message); |
|
| 1259 | - } |
|
| 1260 | - } |
|
| 1261 | - |
|
| 1262 | - /** |
|
| 1263 | - * @psalm-pure |
|
| 1264 | - * @psalm-template ExpectedType of object |
|
| 1265 | - * @psalm-param class-string<ExpectedType> $class |
|
| 1266 | - * @psalm-assert iterable<ExpectedType|class-string<ExpectedType>|null> $value |
|
| 1267 | - * |
|
| 1268 | - * @param iterable<object|string|null> $value |
|
| 1269 | - * @param string $class |
|
| 1270 | - * @param string $message |
|
| 1271 | - * |
|
| 1272 | - * @throws InvalidArgumentException |
|
| 1273 | - * |
|
| 1274 | - * @return void |
|
| 1275 | - */ |
|
| 1276 | - public static function allNullOrIsAOf($value, $class, $message = '') |
|
| 1277 | - { |
|
| 1278 | - static::isIterable($value); |
|
| 1279 | - |
|
| 1280 | - foreach ($value as $entry) { |
|
| 1281 | - null === $entry || static::isAOf($entry, $class, $message); |
|
| 1282 | - } |
|
| 1283 | - } |
|
| 1284 | - |
|
| 1285 | - /** |
|
| 1286 | - * @psalm-pure |
|
| 1287 | - * @psalm-template UnexpectedType of object |
|
| 1288 | - * @psalm-param class-string<UnexpectedType> $class |
|
| 1289 | - * |
|
| 1290 | - * @param object|string|null $value |
|
| 1291 | - * @param string $class |
|
| 1292 | - * @param string $message |
|
| 1293 | - * |
|
| 1294 | - * @throws InvalidArgumentException |
|
| 1295 | - * |
|
| 1296 | - * @return void |
|
| 1297 | - */ |
|
| 1298 | - public static function nullOrIsNotA($value, $class, $message = '') |
|
| 1299 | - { |
|
| 1300 | - null === $value || static::isNotA($value, $class, $message); |
|
| 1301 | - } |
|
| 1302 | - |
|
| 1303 | - /** |
|
| 1304 | - * @psalm-pure |
|
| 1305 | - * @psalm-template UnexpectedType of object |
|
| 1306 | - * @psalm-param class-string<UnexpectedType> $class |
|
| 1307 | - * |
|
| 1308 | - * @param iterable<object|string> $value |
|
| 1309 | - * @param string $class |
|
| 1310 | - * @param string $message |
|
| 1311 | - * |
|
| 1312 | - * @throws InvalidArgumentException |
|
| 1313 | - * |
|
| 1314 | - * @return void |
|
| 1315 | - */ |
|
| 1316 | - public static function allIsNotA($value, $class, $message = '') |
|
| 1317 | - { |
|
| 1318 | - static::isIterable($value); |
|
| 1319 | - |
|
| 1320 | - foreach ($value as $entry) { |
|
| 1321 | - static::isNotA($entry, $class, $message); |
|
| 1322 | - } |
|
| 1323 | - } |
|
| 1324 | - |
|
| 1325 | - /** |
|
| 1326 | - * @psalm-pure |
|
| 1327 | - * @psalm-template UnexpectedType of object |
|
| 1328 | - * @psalm-param class-string<UnexpectedType> $class |
|
| 1329 | - * @psalm-assert iterable<!UnexpectedType|null> $value |
|
| 1330 | - * @psalm-assert iterable<!class-string<UnexpectedType>|null> $value |
|
| 1331 | - * |
|
| 1332 | - * @param iterable<object|string|null> $value |
|
| 1333 | - * @param string $class |
|
| 1334 | - * @param string $message |
|
| 1335 | - * |
|
| 1336 | - * @throws InvalidArgumentException |
|
| 1337 | - * |
|
| 1338 | - * @return void |
|
| 1339 | - */ |
|
| 1340 | - public static function allNullOrIsNotA($value, $class, $message = '') |
|
| 1341 | - { |
|
| 1342 | - static::isIterable($value); |
|
| 1343 | - |
|
| 1344 | - foreach ($value as $entry) { |
|
| 1345 | - null === $entry || static::isNotA($entry, $class, $message); |
|
| 1346 | - } |
|
| 1347 | - } |
|
| 1348 | - |
|
| 1349 | - /** |
|
| 1350 | - * @psalm-pure |
|
| 1351 | - * @psalm-param array<class-string> $classes |
|
| 1352 | - * |
|
| 1353 | - * @param object|string|null $value |
|
| 1354 | - * @param string[] $classes |
|
| 1355 | - * @param string $message |
|
| 1356 | - * |
|
| 1357 | - * @throws InvalidArgumentException |
|
| 1358 | - * |
|
| 1359 | - * @return void |
|
| 1360 | - */ |
|
| 1361 | - public static function nullOrIsAnyOf($value, $classes, $message = '') |
|
| 1362 | - { |
|
| 1363 | - null === $value || static::isAnyOf($value, $classes, $message); |
|
| 1364 | - } |
|
| 1365 | - |
|
| 1366 | - /** |
|
| 1367 | - * @psalm-pure |
|
| 1368 | - * @psalm-param array<class-string> $classes |
|
| 1369 | - * |
|
| 1370 | - * @param iterable<object|string> $value |
|
| 1371 | - * @param string[] $classes |
|
| 1372 | - * @param string $message |
|
| 1373 | - * |
|
| 1374 | - * @throws InvalidArgumentException |
|
| 1375 | - * |
|
| 1376 | - * @return void |
|
| 1377 | - */ |
|
| 1378 | - public static function allIsAnyOf($value, $classes, $message = '') |
|
| 1379 | - { |
|
| 1380 | - static::isIterable($value); |
|
| 1381 | - |
|
| 1382 | - foreach ($value as $entry) { |
|
| 1383 | - static::isAnyOf($entry, $classes, $message); |
|
| 1384 | - } |
|
| 1385 | - } |
|
| 1386 | - |
|
| 1387 | - /** |
|
| 1388 | - * @psalm-pure |
|
| 1389 | - * @psalm-param array<class-string> $classes |
|
| 1390 | - * |
|
| 1391 | - * @param iterable<object|string|null> $value |
|
| 1392 | - * @param string[] $classes |
|
| 1393 | - * @param string $message |
|
| 1394 | - * |
|
| 1395 | - * @throws InvalidArgumentException |
|
| 1396 | - * |
|
| 1397 | - * @return void |
|
| 1398 | - */ |
|
| 1399 | - public static function allNullOrIsAnyOf($value, $classes, $message = '') |
|
| 1400 | - { |
|
| 1401 | - static::isIterable($value); |
|
| 1402 | - |
|
| 1403 | - foreach ($value as $entry) { |
|
| 1404 | - null === $entry || static::isAnyOf($entry, $classes, $message); |
|
| 1405 | - } |
|
| 1406 | - } |
|
| 1407 | - |
|
| 1408 | - /** |
|
| 1409 | - * @psalm-pure |
|
| 1410 | - * @psalm-assert empty $value |
|
| 1411 | - * |
|
| 1412 | - * @param mixed $value |
|
| 1413 | - * @param string $message |
|
| 1414 | - * |
|
| 1415 | - * @throws InvalidArgumentException |
|
| 1416 | - * |
|
| 1417 | - * @return void |
|
| 1418 | - */ |
|
| 1419 | - public static function nullOrIsEmpty($value, $message = '') |
|
| 1420 | - { |
|
| 1421 | - null === $value || static::isEmpty($value, $message); |
|
| 1422 | - } |
|
| 1423 | - |
|
| 1424 | - /** |
|
| 1425 | - * @psalm-pure |
|
| 1426 | - * @psalm-assert iterable<empty> $value |
|
| 1427 | - * |
|
| 1428 | - * @param mixed $value |
|
| 1429 | - * @param string $message |
|
| 1430 | - * |
|
| 1431 | - * @throws InvalidArgumentException |
|
| 1432 | - * |
|
| 1433 | - * @return void |
|
| 1434 | - */ |
|
| 1435 | - public static function allIsEmpty($value, $message = '') |
|
| 1436 | - { |
|
| 1437 | - static::isIterable($value); |
|
| 1438 | - |
|
| 1439 | - foreach ($value as $entry) { |
|
| 1440 | - static::isEmpty($entry, $message); |
|
| 1441 | - } |
|
| 1442 | - } |
|
| 1443 | - |
|
| 1444 | - /** |
|
| 1445 | - * @psalm-pure |
|
| 1446 | - * @psalm-assert iterable<empty|null> $value |
|
| 1447 | - * |
|
| 1448 | - * @param mixed $value |
|
| 1449 | - * @param string $message |
|
| 1450 | - * |
|
| 1451 | - * @throws InvalidArgumentException |
|
| 1452 | - * |
|
| 1453 | - * @return void |
|
| 1454 | - */ |
|
| 1455 | - public static function allNullOrIsEmpty($value, $message = '') |
|
| 1456 | - { |
|
| 1457 | - static::isIterable($value); |
|
| 1458 | - |
|
| 1459 | - foreach ($value as $entry) { |
|
| 1460 | - null === $entry || static::isEmpty($entry, $message); |
|
| 1461 | - } |
|
| 1462 | - } |
|
| 1463 | - |
|
| 1464 | - /** |
|
| 1465 | - * @psalm-pure |
|
| 1466 | - * |
|
| 1467 | - * @param mixed $value |
|
| 1468 | - * @param string $message |
|
| 1469 | - * |
|
| 1470 | - * @throws InvalidArgumentException |
|
| 1471 | - * |
|
| 1472 | - * @return void |
|
| 1473 | - */ |
|
| 1474 | - public static function nullOrNotEmpty($value, $message = '') |
|
| 1475 | - { |
|
| 1476 | - null === $value || static::notEmpty($value, $message); |
|
| 1477 | - } |
|
| 1478 | - |
|
| 1479 | - /** |
|
| 1480 | - * @psalm-pure |
|
| 1481 | - * |
|
| 1482 | - * @param mixed $value |
|
| 1483 | - * @param string $message |
|
| 1484 | - * |
|
| 1485 | - * @throws InvalidArgumentException |
|
| 1486 | - * |
|
| 1487 | - * @return void |
|
| 1488 | - */ |
|
| 1489 | - public static function allNotEmpty($value, $message = '') |
|
| 1490 | - { |
|
| 1491 | - static::isIterable($value); |
|
| 1492 | - |
|
| 1493 | - foreach ($value as $entry) { |
|
| 1494 | - static::notEmpty($entry, $message); |
|
| 1495 | - } |
|
| 1496 | - } |
|
| 1497 | - |
|
| 1498 | - /** |
|
| 1499 | - * @psalm-pure |
|
| 1500 | - * @psalm-assert iterable<!empty|null> $value |
|
| 1501 | - * |
|
| 1502 | - * @param mixed $value |
|
| 1503 | - * @param string $message |
|
| 1504 | - * |
|
| 1505 | - * @throws InvalidArgumentException |
|
| 1506 | - * |
|
| 1507 | - * @return void |
|
| 1508 | - */ |
|
| 1509 | - public static function allNullOrNotEmpty($value, $message = '') |
|
| 1510 | - { |
|
| 1511 | - static::isIterable($value); |
|
| 1512 | - |
|
| 1513 | - foreach ($value as $entry) { |
|
| 1514 | - null === $entry || static::notEmpty($entry, $message); |
|
| 1515 | - } |
|
| 1516 | - } |
|
| 1517 | - |
|
| 1518 | - /** |
|
| 1519 | - * @psalm-pure |
|
| 1520 | - * @psalm-assert iterable<null> $value |
|
| 1521 | - * |
|
| 1522 | - * @param mixed $value |
|
| 1523 | - * @param string $message |
|
| 1524 | - * |
|
| 1525 | - * @throws InvalidArgumentException |
|
| 1526 | - * |
|
| 1527 | - * @return void |
|
| 1528 | - */ |
|
| 1529 | - public static function allNull($value, $message = '') |
|
| 1530 | - { |
|
| 1531 | - static::isIterable($value); |
|
| 1532 | - |
|
| 1533 | - foreach ($value as $entry) { |
|
| 1534 | - static::null($entry, $message); |
|
| 1535 | - } |
|
| 1536 | - } |
|
| 1537 | - |
|
| 1538 | - /** |
|
| 1539 | - * @psalm-pure |
|
| 1540 | - * |
|
| 1541 | - * @param mixed $value |
|
| 1542 | - * @param string $message |
|
| 1543 | - * |
|
| 1544 | - * @throws InvalidArgumentException |
|
| 1545 | - * |
|
| 1546 | - * @return void |
|
| 1547 | - */ |
|
| 1548 | - public static function allNotNull($value, $message = '') |
|
| 1549 | - { |
|
| 1550 | - static::isIterable($value); |
|
| 1551 | - |
|
| 1552 | - foreach ($value as $entry) { |
|
| 1553 | - static::notNull($entry, $message); |
|
| 1554 | - } |
|
| 1555 | - } |
|
| 1556 | - |
|
| 1557 | - /** |
|
| 1558 | - * @psalm-pure |
|
| 1559 | - * @psalm-assert true|null $value |
|
| 1560 | - * |
|
| 1561 | - * @param mixed $value |
|
| 1562 | - * @param string $message |
|
| 1563 | - * |
|
| 1564 | - * @throws InvalidArgumentException |
|
| 1565 | - * |
|
| 1566 | - * @return void |
|
| 1567 | - */ |
|
| 1568 | - public static function nullOrTrue($value, $message = '') |
|
| 1569 | - { |
|
| 1570 | - null === $value || static::true($value, $message); |
|
| 1571 | - } |
|
| 1572 | - |
|
| 1573 | - /** |
|
| 1574 | - * @psalm-pure |
|
| 1575 | - * @psalm-assert iterable<true> $value |
|
| 1576 | - * |
|
| 1577 | - * @param mixed $value |
|
| 1578 | - * @param string $message |
|
| 1579 | - * |
|
| 1580 | - * @throws InvalidArgumentException |
|
| 1581 | - * |
|
| 1582 | - * @return void |
|
| 1583 | - */ |
|
| 1584 | - public static function allTrue($value, $message = '') |
|
| 1585 | - { |
|
| 1586 | - static::isIterable($value); |
|
| 1587 | - |
|
| 1588 | - foreach ($value as $entry) { |
|
| 1589 | - static::true($entry, $message); |
|
| 1590 | - } |
|
| 1591 | - } |
|
| 1592 | - |
|
| 1593 | - /** |
|
| 1594 | - * @psalm-pure |
|
| 1595 | - * @psalm-assert iterable<true|null> $value |
|
| 1596 | - * |
|
| 1597 | - * @param mixed $value |
|
| 1598 | - * @param string $message |
|
| 1599 | - * |
|
| 1600 | - * @throws InvalidArgumentException |
|
| 1601 | - * |
|
| 1602 | - * @return void |
|
| 1603 | - */ |
|
| 1604 | - public static function allNullOrTrue($value, $message = '') |
|
| 1605 | - { |
|
| 1606 | - static::isIterable($value); |
|
| 1607 | - |
|
| 1608 | - foreach ($value as $entry) { |
|
| 1609 | - null === $entry || static::true($entry, $message); |
|
| 1610 | - } |
|
| 1611 | - } |
|
| 1612 | - |
|
| 1613 | - /** |
|
| 1614 | - * @psalm-pure |
|
| 1615 | - * @psalm-assert false|null $value |
|
| 1616 | - * |
|
| 1617 | - * @param mixed $value |
|
| 1618 | - * @param string $message |
|
| 1619 | - * |
|
| 1620 | - * @throws InvalidArgumentException |
|
| 1621 | - * |
|
| 1622 | - * @return void |
|
| 1623 | - */ |
|
| 1624 | - public static function nullOrFalse($value, $message = '') |
|
| 1625 | - { |
|
| 1626 | - null === $value || static::false($value, $message); |
|
| 1627 | - } |
|
| 1628 | - |
|
| 1629 | - /** |
|
| 1630 | - * @psalm-pure |
|
| 1631 | - * @psalm-assert iterable<false> $value |
|
| 1632 | - * |
|
| 1633 | - * @param mixed $value |
|
| 1634 | - * @param string $message |
|
| 1635 | - * |
|
| 1636 | - * @throws InvalidArgumentException |
|
| 1637 | - * |
|
| 1638 | - * @return void |
|
| 1639 | - */ |
|
| 1640 | - public static function allFalse($value, $message = '') |
|
| 1641 | - { |
|
| 1642 | - static::isIterable($value); |
|
| 1643 | - |
|
| 1644 | - foreach ($value as $entry) { |
|
| 1645 | - static::false($entry, $message); |
|
| 1646 | - } |
|
| 1647 | - } |
|
| 1648 | - |
|
| 1649 | - /** |
|
| 1650 | - * @psalm-pure |
|
| 1651 | - * @psalm-assert iterable<false|null> $value |
|
| 1652 | - * |
|
| 1653 | - * @param mixed $value |
|
| 1654 | - * @param string $message |
|
| 1655 | - * |
|
| 1656 | - * @throws InvalidArgumentException |
|
| 1657 | - * |
|
| 1658 | - * @return void |
|
| 1659 | - */ |
|
| 1660 | - public static function allNullOrFalse($value, $message = '') |
|
| 1661 | - { |
|
| 1662 | - static::isIterable($value); |
|
| 1663 | - |
|
| 1664 | - foreach ($value as $entry) { |
|
| 1665 | - null === $entry || static::false($entry, $message); |
|
| 1666 | - } |
|
| 1667 | - } |
|
| 1668 | - |
|
| 1669 | - /** |
|
| 1670 | - * @psalm-pure |
|
| 1671 | - * |
|
| 1672 | - * @param mixed $value |
|
| 1673 | - * @param string $message |
|
| 1674 | - * |
|
| 1675 | - * @throws InvalidArgumentException |
|
| 1676 | - * |
|
| 1677 | - * @return void |
|
| 1678 | - */ |
|
| 1679 | - public static function nullOrNotFalse($value, $message = '') |
|
| 1680 | - { |
|
| 1681 | - null === $value || static::notFalse($value, $message); |
|
| 1682 | - } |
|
| 1683 | - |
|
| 1684 | - /** |
|
| 1685 | - * @psalm-pure |
|
| 1686 | - * |
|
| 1687 | - * @param mixed $value |
|
| 1688 | - * @param string $message |
|
| 1689 | - * |
|
| 1690 | - * @throws InvalidArgumentException |
|
| 1691 | - * |
|
| 1692 | - * @return void |
|
| 1693 | - */ |
|
| 1694 | - public static function allNotFalse($value, $message = '') |
|
| 1695 | - { |
|
| 1696 | - static::isIterable($value); |
|
| 1697 | - |
|
| 1698 | - foreach ($value as $entry) { |
|
| 1699 | - static::notFalse($entry, $message); |
|
| 1700 | - } |
|
| 1701 | - } |
|
| 1702 | - |
|
| 1703 | - /** |
|
| 1704 | - * @psalm-pure |
|
| 1705 | - * @psalm-assert iterable<!false|null> $value |
|
| 1706 | - * |
|
| 1707 | - * @param mixed $value |
|
| 1708 | - * @param string $message |
|
| 1709 | - * |
|
| 1710 | - * @throws InvalidArgumentException |
|
| 1711 | - * |
|
| 1712 | - * @return void |
|
| 1713 | - */ |
|
| 1714 | - public static function allNullOrNotFalse($value, $message = '') |
|
| 1715 | - { |
|
| 1716 | - static::isIterable($value); |
|
| 1717 | - |
|
| 1718 | - foreach ($value as $entry) { |
|
| 1719 | - null === $entry || static::notFalse($entry, $message); |
|
| 1720 | - } |
|
| 1721 | - } |
|
| 1722 | - |
|
| 1723 | - /** |
|
| 1724 | - * @param mixed $value |
|
| 1725 | - * @param string $message |
|
| 1726 | - * |
|
| 1727 | - * @throws InvalidArgumentException |
|
| 1728 | - * |
|
| 1729 | - * @return void |
|
| 1730 | - */ |
|
| 1731 | - public static function nullOrIp($value, $message = '') |
|
| 1732 | - { |
|
| 1733 | - null === $value || static::ip($value, $message); |
|
| 1734 | - } |
|
| 1735 | - |
|
| 1736 | - /** |
|
| 1737 | - * @param mixed $value |
|
| 1738 | - * @param string $message |
|
| 1739 | - * |
|
| 1740 | - * @throws InvalidArgumentException |
|
| 1741 | - * |
|
| 1742 | - * @return void |
|
| 1743 | - */ |
|
| 1744 | - public static function allIp($value, $message = '') |
|
| 1745 | - { |
|
| 1746 | - static::isIterable($value); |
|
| 1747 | - |
|
| 1748 | - foreach ($value as $entry) { |
|
| 1749 | - static::ip($entry, $message); |
|
| 1750 | - } |
|
| 1751 | - } |
|
| 1752 | - |
|
| 1753 | - /** |
|
| 1754 | - * @param mixed $value |
|
| 1755 | - * @param string $message |
|
| 1756 | - * |
|
| 1757 | - * @throws InvalidArgumentException |
|
| 1758 | - * |
|
| 1759 | - * @return void |
|
| 1760 | - */ |
|
| 1761 | - public static function allNullOrIp($value, $message = '') |
|
| 1762 | - { |
|
| 1763 | - static::isIterable($value); |
|
| 1764 | - |
|
| 1765 | - foreach ($value as $entry) { |
|
| 1766 | - null === $entry || static::ip($entry, $message); |
|
| 1767 | - } |
|
| 1768 | - } |
|
| 1769 | - |
|
| 1770 | - /** |
|
| 1771 | - * @param mixed $value |
|
| 1772 | - * @param string $message |
|
| 1773 | - * |
|
| 1774 | - * @throws InvalidArgumentException |
|
| 1775 | - * |
|
| 1776 | - * @return void |
|
| 1777 | - */ |
|
| 1778 | - public static function nullOrIpv4($value, $message = '') |
|
| 1779 | - { |
|
| 1780 | - null === $value || static::ipv4($value, $message); |
|
| 1781 | - } |
|
| 1782 | - |
|
| 1783 | - /** |
|
| 1784 | - * @param mixed $value |
|
| 1785 | - * @param string $message |
|
| 1786 | - * |
|
| 1787 | - * @throws InvalidArgumentException |
|
| 1788 | - * |
|
| 1789 | - * @return void |
|
| 1790 | - */ |
|
| 1791 | - public static function allIpv4($value, $message = '') |
|
| 1792 | - { |
|
| 1793 | - static::isIterable($value); |
|
| 1794 | - |
|
| 1795 | - foreach ($value as $entry) { |
|
| 1796 | - static::ipv4($entry, $message); |
|
| 1797 | - } |
|
| 1798 | - } |
|
| 1799 | - |
|
| 1800 | - /** |
|
| 1801 | - * @param mixed $value |
|
| 1802 | - * @param string $message |
|
| 1803 | - * |
|
| 1804 | - * @throws InvalidArgumentException |
|
| 1805 | - * |
|
| 1806 | - * @return void |
|
| 1807 | - */ |
|
| 1808 | - public static function allNullOrIpv4($value, $message = '') |
|
| 1809 | - { |
|
| 1810 | - static::isIterable($value); |
|
| 1811 | - |
|
| 1812 | - foreach ($value as $entry) { |
|
| 1813 | - null === $entry || static::ipv4($entry, $message); |
|
| 1814 | - } |
|
| 1815 | - } |
|
| 1816 | - |
|
| 1817 | - /** |
|
| 1818 | - * @param mixed $value |
|
| 1819 | - * @param string $message |
|
| 1820 | - * |
|
| 1821 | - * @throws InvalidArgumentException |
|
| 1822 | - * |
|
| 1823 | - * @return void |
|
| 1824 | - */ |
|
| 1825 | - public static function nullOrIpv6($value, $message = '') |
|
| 1826 | - { |
|
| 1827 | - null === $value || static::ipv6($value, $message); |
|
| 1828 | - } |
|
| 1829 | - |
|
| 1830 | - /** |
|
| 1831 | - * @param mixed $value |
|
| 1832 | - * @param string $message |
|
| 1833 | - * |
|
| 1834 | - * @throws InvalidArgumentException |
|
| 1835 | - * |
|
| 1836 | - * @return void |
|
| 1837 | - */ |
|
| 1838 | - public static function allIpv6($value, $message = '') |
|
| 1839 | - { |
|
| 1840 | - static::isIterable($value); |
|
| 1841 | - |
|
| 1842 | - foreach ($value as $entry) { |
|
| 1843 | - static::ipv6($entry, $message); |
|
| 1844 | - } |
|
| 1845 | - } |
|
| 1846 | - |
|
| 1847 | - /** |
|
| 1848 | - * @param mixed $value |
|
| 1849 | - * @param string $message |
|
| 1850 | - * |
|
| 1851 | - * @throws InvalidArgumentException |
|
| 1852 | - * |
|
| 1853 | - * @return void |
|
| 1854 | - */ |
|
| 1855 | - public static function allNullOrIpv6($value, $message = '') |
|
| 1856 | - { |
|
| 1857 | - static::isIterable($value); |
|
| 1858 | - |
|
| 1859 | - foreach ($value as $entry) { |
|
| 1860 | - null === $entry || static::ipv6($entry, $message); |
|
| 1861 | - } |
|
| 1862 | - } |
|
| 1863 | - |
|
| 1864 | - /** |
|
| 1865 | - * @param mixed $value |
|
| 1866 | - * @param string $message |
|
| 1867 | - * |
|
| 1868 | - * @throws InvalidArgumentException |
|
| 1869 | - * |
|
| 1870 | - * @return void |
|
| 1871 | - */ |
|
| 1872 | - public static function nullOrEmail($value, $message = '') |
|
| 1873 | - { |
|
| 1874 | - null === $value || static::email($value, $message); |
|
| 1875 | - } |
|
| 1876 | - |
|
| 1877 | - /** |
|
| 1878 | - * @param mixed $value |
|
| 1879 | - * @param string $message |
|
| 1880 | - * |
|
| 1881 | - * @throws InvalidArgumentException |
|
| 1882 | - * |
|
| 1883 | - * @return void |
|
| 1884 | - */ |
|
| 1885 | - public static function allEmail($value, $message = '') |
|
| 1886 | - { |
|
| 1887 | - static::isIterable($value); |
|
| 1888 | - |
|
| 1889 | - foreach ($value as $entry) { |
|
| 1890 | - static::email($entry, $message); |
|
| 1891 | - } |
|
| 1892 | - } |
|
| 1893 | - |
|
| 1894 | - /** |
|
| 1895 | - * @param mixed $value |
|
| 1896 | - * @param string $message |
|
| 1897 | - * |
|
| 1898 | - * @throws InvalidArgumentException |
|
| 1899 | - * |
|
| 1900 | - * @return void |
|
| 1901 | - */ |
|
| 1902 | - public static function allNullOrEmail($value, $message = '') |
|
| 1903 | - { |
|
| 1904 | - static::isIterable($value); |
|
| 1905 | - |
|
| 1906 | - foreach ($value as $entry) { |
|
| 1907 | - null === $entry || static::email($entry, $message); |
|
| 1908 | - } |
|
| 1909 | - } |
|
| 1910 | - |
|
| 1911 | - /** |
|
| 1912 | - * @param array|null $values |
|
| 1913 | - * @param string $message |
|
| 1914 | - * |
|
| 1915 | - * @throws InvalidArgumentException |
|
| 1916 | - * |
|
| 1917 | - * @return void |
|
| 1918 | - */ |
|
| 1919 | - public static function nullOrUniqueValues($values, $message = '') |
|
| 1920 | - { |
|
| 1921 | - null === $values || static::uniqueValues($values, $message); |
|
| 1922 | - } |
|
| 1923 | - |
|
| 1924 | - /** |
|
| 1925 | - * @param iterable<array> $values |
|
| 1926 | - * @param string $message |
|
| 1927 | - * |
|
| 1928 | - * @throws InvalidArgumentException |
|
| 1929 | - * |
|
| 1930 | - * @return void |
|
| 1931 | - */ |
|
| 1932 | - public static function allUniqueValues($values, $message = '') |
|
| 1933 | - { |
|
| 1934 | - static::isIterable($values); |
|
| 1935 | - |
|
| 1936 | - foreach ($values as $entry) { |
|
| 1937 | - static::uniqueValues($entry, $message); |
|
| 1938 | - } |
|
| 1939 | - } |
|
| 1940 | - |
|
| 1941 | - /** |
|
| 1942 | - * @param iterable<array|null> $values |
|
| 1943 | - * @param string $message |
|
| 1944 | - * |
|
| 1945 | - * @throws InvalidArgumentException |
|
| 1946 | - * |
|
| 1947 | - * @return void |
|
| 1948 | - */ |
|
| 1949 | - public static function allNullOrUniqueValues($values, $message = '') |
|
| 1950 | - { |
|
| 1951 | - static::isIterable($values); |
|
| 1952 | - |
|
| 1953 | - foreach ($values as $entry) { |
|
| 1954 | - null === $entry || static::uniqueValues($entry, $message); |
|
| 1955 | - } |
|
| 1956 | - } |
|
| 1957 | - |
|
| 1958 | - /** |
|
| 1959 | - * @param mixed $value |
|
| 1960 | - * @param mixed $expect |
|
| 1961 | - * @param string $message |
|
| 1962 | - * |
|
| 1963 | - * @throws InvalidArgumentException |
|
| 1964 | - * |
|
| 1965 | - * @return void |
|
| 1966 | - */ |
|
| 1967 | - public static function nullOrEq($value, $expect, $message = '') |
|
| 1968 | - { |
|
| 1969 | - null === $value || static::eq($value, $expect, $message); |
|
| 1970 | - } |
|
| 1971 | - |
|
| 1972 | - /** |
|
| 1973 | - * @param mixed $value |
|
| 1974 | - * @param mixed $expect |
|
| 1975 | - * @param string $message |
|
| 1976 | - * |
|
| 1977 | - * @throws InvalidArgumentException |
|
| 1978 | - * |
|
| 1979 | - * @return void |
|
| 1980 | - */ |
|
| 1981 | - public static function allEq($value, $expect, $message = '') |
|
| 1982 | - { |
|
| 1983 | - static::isIterable($value); |
|
| 1984 | - |
|
| 1985 | - foreach ($value as $entry) { |
|
| 1986 | - static::eq($entry, $expect, $message); |
|
| 1987 | - } |
|
| 1988 | - } |
|
| 1989 | - |
|
| 1990 | - /** |
|
| 1991 | - * @param mixed $value |
|
| 1992 | - * @param mixed $expect |
|
| 1993 | - * @param string $message |
|
| 1994 | - * |
|
| 1995 | - * @throws InvalidArgumentException |
|
| 1996 | - * |
|
| 1997 | - * @return void |
|
| 1998 | - */ |
|
| 1999 | - public static function allNullOrEq($value, $expect, $message = '') |
|
| 2000 | - { |
|
| 2001 | - static::isIterable($value); |
|
| 2002 | - |
|
| 2003 | - foreach ($value as $entry) { |
|
| 2004 | - null === $entry || static::eq($entry, $expect, $message); |
|
| 2005 | - } |
|
| 2006 | - } |
|
| 2007 | - |
|
| 2008 | - /** |
|
| 2009 | - * @param mixed $value |
|
| 2010 | - * @param mixed $expect |
|
| 2011 | - * @param string $message |
|
| 2012 | - * |
|
| 2013 | - * @throws InvalidArgumentException |
|
| 2014 | - * |
|
| 2015 | - * @return void |
|
| 2016 | - */ |
|
| 2017 | - public static function nullOrNotEq($value, $expect, $message = '') |
|
| 2018 | - { |
|
| 2019 | - null === $value || static::notEq($value, $expect, $message); |
|
| 2020 | - } |
|
| 2021 | - |
|
| 2022 | - /** |
|
| 2023 | - * @param mixed $value |
|
| 2024 | - * @param mixed $expect |
|
| 2025 | - * @param string $message |
|
| 2026 | - * |
|
| 2027 | - * @throws InvalidArgumentException |
|
| 2028 | - * |
|
| 2029 | - * @return void |
|
| 2030 | - */ |
|
| 2031 | - public static function allNotEq($value, $expect, $message = '') |
|
| 2032 | - { |
|
| 2033 | - static::isIterable($value); |
|
| 2034 | - |
|
| 2035 | - foreach ($value as $entry) { |
|
| 2036 | - static::notEq($entry, $expect, $message); |
|
| 2037 | - } |
|
| 2038 | - } |
|
| 2039 | - |
|
| 2040 | - /** |
|
| 2041 | - * @param mixed $value |
|
| 2042 | - * @param mixed $expect |
|
| 2043 | - * @param string $message |
|
| 2044 | - * |
|
| 2045 | - * @throws InvalidArgumentException |
|
| 2046 | - * |
|
| 2047 | - * @return void |
|
| 2048 | - */ |
|
| 2049 | - public static function allNullOrNotEq($value, $expect, $message = '') |
|
| 2050 | - { |
|
| 2051 | - static::isIterable($value); |
|
| 2052 | - |
|
| 2053 | - foreach ($value as $entry) { |
|
| 2054 | - null === $entry || static::notEq($entry, $expect, $message); |
|
| 2055 | - } |
|
| 2056 | - } |
|
| 2057 | - |
|
| 2058 | - /** |
|
| 2059 | - * @psalm-pure |
|
| 2060 | - * |
|
| 2061 | - * @param mixed $value |
|
| 2062 | - * @param mixed $expect |
|
| 2063 | - * @param string $message |
|
| 2064 | - * |
|
| 2065 | - * @throws InvalidArgumentException |
|
| 2066 | - * |
|
| 2067 | - * @return void |
|
| 2068 | - */ |
|
| 2069 | - public static function nullOrSame($value, $expect, $message = '') |
|
| 2070 | - { |
|
| 2071 | - null === $value || static::same($value, $expect, $message); |
|
| 2072 | - } |
|
| 2073 | - |
|
| 2074 | - /** |
|
| 2075 | - * @psalm-pure |
|
| 2076 | - * |
|
| 2077 | - * @param mixed $value |
|
| 2078 | - * @param mixed $expect |
|
| 2079 | - * @param string $message |
|
| 2080 | - * |
|
| 2081 | - * @throws InvalidArgumentException |
|
| 2082 | - * |
|
| 2083 | - * @return void |
|
| 2084 | - */ |
|
| 2085 | - public static function allSame($value, $expect, $message = '') |
|
| 2086 | - { |
|
| 2087 | - static::isIterable($value); |
|
| 2088 | - |
|
| 2089 | - foreach ($value as $entry) { |
|
| 2090 | - static::same($entry, $expect, $message); |
|
| 2091 | - } |
|
| 2092 | - } |
|
| 2093 | - |
|
| 2094 | - /** |
|
| 2095 | - * @psalm-pure |
|
| 2096 | - * |
|
| 2097 | - * @param mixed $value |
|
| 2098 | - * @param mixed $expect |
|
| 2099 | - * @param string $message |
|
| 2100 | - * |
|
| 2101 | - * @throws InvalidArgumentException |
|
| 2102 | - * |
|
| 2103 | - * @return void |
|
| 2104 | - */ |
|
| 2105 | - public static function allNullOrSame($value, $expect, $message = '') |
|
| 2106 | - { |
|
| 2107 | - static::isIterable($value); |
|
| 2108 | - |
|
| 2109 | - foreach ($value as $entry) { |
|
| 2110 | - null === $entry || static::same($entry, $expect, $message); |
|
| 2111 | - } |
|
| 2112 | - } |
|
| 2113 | - |
|
| 2114 | - /** |
|
| 2115 | - * @psalm-pure |
|
| 2116 | - * |
|
| 2117 | - * @param mixed $value |
|
| 2118 | - * @param mixed $expect |
|
| 2119 | - * @param string $message |
|
| 2120 | - * |
|
| 2121 | - * @throws InvalidArgumentException |
|
| 2122 | - * |
|
| 2123 | - * @return void |
|
| 2124 | - */ |
|
| 2125 | - public static function nullOrNotSame($value, $expect, $message = '') |
|
| 2126 | - { |
|
| 2127 | - null === $value || static::notSame($value, $expect, $message); |
|
| 2128 | - } |
|
| 2129 | - |
|
| 2130 | - /** |
|
| 2131 | - * @psalm-pure |
|
| 2132 | - * |
|
| 2133 | - * @param mixed $value |
|
| 2134 | - * @param mixed $expect |
|
| 2135 | - * @param string $message |
|
| 2136 | - * |
|
| 2137 | - * @throws InvalidArgumentException |
|
| 2138 | - * |
|
| 2139 | - * @return void |
|
| 2140 | - */ |
|
| 2141 | - public static function allNotSame($value, $expect, $message = '') |
|
| 2142 | - { |
|
| 2143 | - static::isIterable($value); |
|
| 2144 | - |
|
| 2145 | - foreach ($value as $entry) { |
|
| 2146 | - static::notSame($entry, $expect, $message); |
|
| 2147 | - } |
|
| 2148 | - } |
|
| 2149 | - |
|
| 2150 | - /** |
|
| 2151 | - * @psalm-pure |
|
| 2152 | - * |
|
| 2153 | - * @param mixed $value |
|
| 2154 | - * @param mixed $expect |
|
| 2155 | - * @param string $message |
|
| 2156 | - * |
|
| 2157 | - * @throws InvalidArgumentException |
|
| 2158 | - * |
|
| 2159 | - * @return void |
|
| 2160 | - */ |
|
| 2161 | - public static function allNullOrNotSame($value, $expect, $message = '') |
|
| 2162 | - { |
|
| 2163 | - static::isIterable($value); |
|
| 2164 | - |
|
| 2165 | - foreach ($value as $entry) { |
|
| 2166 | - null === $entry || static::notSame($entry, $expect, $message); |
|
| 2167 | - } |
|
| 2168 | - } |
|
| 2169 | - |
|
| 2170 | - /** |
|
| 2171 | - * @psalm-pure |
|
| 2172 | - * |
|
| 2173 | - * @param mixed $value |
|
| 2174 | - * @param mixed $limit |
|
| 2175 | - * @param string $message |
|
| 2176 | - * |
|
| 2177 | - * @throws InvalidArgumentException |
|
| 2178 | - * |
|
| 2179 | - * @return void |
|
| 2180 | - */ |
|
| 2181 | - public static function nullOrGreaterThan($value, $limit, $message = '') |
|
| 2182 | - { |
|
| 2183 | - null === $value || static::greaterThan($value, $limit, $message); |
|
| 2184 | - } |
|
| 2185 | - |
|
| 2186 | - /** |
|
| 2187 | - * @psalm-pure |
|
| 2188 | - * |
|
| 2189 | - * @param mixed $value |
|
| 2190 | - * @param mixed $limit |
|
| 2191 | - * @param string $message |
|
| 2192 | - * |
|
| 2193 | - * @throws InvalidArgumentException |
|
| 2194 | - * |
|
| 2195 | - * @return void |
|
| 2196 | - */ |
|
| 2197 | - public static function allGreaterThan($value, $limit, $message = '') |
|
| 2198 | - { |
|
| 2199 | - static::isIterable($value); |
|
| 2200 | - |
|
| 2201 | - foreach ($value as $entry) { |
|
| 2202 | - static::greaterThan($entry, $limit, $message); |
|
| 2203 | - } |
|
| 2204 | - } |
|
| 2205 | - |
|
| 2206 | - /** |
|
| 2207 | - * @psalm-pure |
|
| 2208 | - * |
|
| 2209 | - * @param mixed $value |
|
| 2210 | - * @param mixed $limit |
|
| 2211 | - * @param string $message |
|
| 2212 | - * |
|
| 2213 | - * @throws InvalidArgumentException |
|
| 2214 | - * |
|
| 2215 | - * @return void |
|
| 2216 | - */ |
|
| 2217 | - public static function allNullOrGreaterThan($value, $limit, $message = '') |
|
| 2218 | - { |
|
| 2219 | - static::isIterable($value); |
|
| 2220 | - |
|
| 2221 | - foreach ($value as $entry) { |
|
| 2222 | - null === $entry || static::greaterThan($entry, $limit, $message); |
|
| 2223 | - } |
|
| 2224 | - } |
|
| 2225 | - |
|
| 2226 | - /** |
|
| 2227 | - * @psalm-pure |
|
| 2228 | - * |
|
| 2229 | - * @param mixed $value |
|
| 2230 | - * @param mixed $limit |
|
| 2231 | - * @param string $message |
|
| 2232 | - * |
|
| 2233 | - * @throws InvalidArgumentException |
|
| 2234 | - * |
|
| 2235 | - * @return void |
|
| 2236 | - */ |
|
| 2237 | - public static function nullOrGreaterThanEq($value, $limit, $message = '') |
|
| 2238 | - { |
|
| 2239 | - null === $value || static::greaterThanEq($value, $limit, $message); |
|
| 2240 | - } |
|
| 2241 | - |
|
| 2242 | - /** |
|
| 2243 | - * @psalm-pure |
|
| 2244 | - * |
|
| 2245 | - * @param mixed $value |
|
| 2246 | - * @param mixed $limit |
|
| 2247 | - * @param string $message |
|
| 2248 | - * |
|
| 2249 | - * @throws InvalidArgumentException |
|
| 2250 | - * |
|
| 2251 | - * @return void |
|
| 2252 | - */ |
|
| 2253 | - public static function allGreaterThanEq($value, $limit, $message = '') |
|
| 2254 | - { |
|
| 2255 | - static::isIterable($value); |
|
| 2256 | - |
|
| 2257 | - foreach ($value as $entry) { |
|
| 2258 | - static::greaterThanEq($entry, $limit, $message); |
|
| 2259 | - } |
|
| 2260 | - } |
|
| 2261 | - |
|
| 2262 | - /** |
|
| 2263 | - * @psalm-pure |
|
| 2264 | - * |
|
| 2265 | - * @param mixed $value |
|
| 2266 | - * @param mixed $limit |
|
| 2267 | - * @param string $message |
|
| 2268 | - * |
|
| 2269 | - * @throws InvalidArgumentException |
|
| 2270 | - * |
|
| 2271 | - * @return void |
|
| 2272 | - */ |
|
| 2273 | - public static function allNullOrGreaterThanEq($value, $limit, $message = '') |
|
| 2274 | - { |
|
| 2275 | - static::isIterable($value); |
|
| 2276 | - |
|
| 2277 | - foreach ($value as $entry) { |
|
| 2278 | - null === $entry || static::greaterThanEq($entry, $limit, $message); |
|
| 2279 | - } |
|
| 2280 | - } |
|
| 2281 | - |
|
| 2282 | - /** |
|
| 2283 | - * @psalm-pure |
|
| 2284 | - * |
|
| 2285 | - * @param mixed $value |
|
| 2286 | - * @param mixed $limit |
|
| 2287 | - * @param string $message |
|
| 2288 | - * |
|
| 2289 | - * @throws InvalidArgumentException |
|
| 2290 | - * |
|
| 2291 | - * @return void |
|
| 2292 | - */ |
|
| 2293 | - public static function nullOrLessThan($value, $limit, $message = '') |
|
| 2294 | - { |
|
| 2295 | - null === $value || static::lessThan($value, $limit, $message); |
|
| 2296 | - } |
|
| 2297 | - |
|
| 2298 | - /** |
|
| 2299 | - * @psalm-pure |
|
| 2300 | - * |
|
| 2301 | - * @param mixed $value |
|
| 2302 | - * @param mixed $limit |
|
| 2303 | - * @param string $message |
|
| 2304 | - * |
|
| 2305 | - * @throws InvalidArgumentException |
|
| 2306 | - * |
|
| 2307 | - * @return void |
|
| 2308 | - */ |
|
| 2309 | - public static function allLessThan($value, $limit, $message = '') |
|
| 2310 | - { |
|
| 2311 | - static::isIterable($value); |
|
| 2312 | - |
|
| 2313 | - foreach ($value as $entry) { |
|
| 2314 | - static::lessThan($entry, $limit, $message); |
|
| 2315 | - } |
|
| 2316 | - } |
|
| 2317 | - |
|
| 2318 | - /** |
|
| 2319 | - * @psalm-pure |
|
| 2320 | - * |
|
| 2321 | - * @param mixed $value |
|
| 2322 | - * @param mixed $limit |
|
| 2323 | - * @param string $message |
|
| 2324 | - * |
|
| 2325 | - * @throws InvalidArgumentException |
|
| 2326 | - * |
|
| 2327 | - * @return void |
|
| 2328 | - */ |
|
| 2329 | - public static function allNullOrLessThan($value, $limit, $message = '') |
|
| 2330 | - { |
|
| 2331 | - static::isIterable($value); |
|
| 2332 | - |
|
| 2333 | - foreach ($value as $entry) { |
|
| 2334 | - null === $entry || static::lessThan($entry, $limit, $message); |
|
| 2335 | - } |
|
| 2336 | - } |
|
| 2337 | - |
|
| 2338 | - /** |
|
| 2339 | - * @psalm-pure |
|
| 2340 | - * |
|
| 2341 | - * @param mixed $value |
|
| 2342 | - * @param mixed $limit |
|
| 2343 | - * @param string $message |
|
| 2344 | - * |
|
| 2345 | - * @throws InvalidArgumentException |
|
| 2346 | - * |
|
| 2347 | - * @return void |
|
| 2348 | - */ |
|
| 2349 | - public static function nullOrLessThanEq($value, $limit, $message = '') |
|
| 2350 | - { |
|
| 2351 | - null === $value || static::lessThanEq($value, $limit, $message); |
|
| 2352 | - } |
|
| 2353 | - |
|
| 2354 | - /** |
|
| 2355 | - * @psalm-pure |
|
| 2356 | - * |
|
| 2357 | - * @param mixed $value |
|
| 2358 | - * @param mixed $limit |
|
| 2359 | - * @param string $message |
|
| 2360 | - * |
|
| 2361 | - * @throws InvalidArgumentException |
|
| 2362 | - * |
|
| 2363 | - * @return void |
|
| 2364 | - */ |
|
| 2365 | - public static function allLessThanEq($value, $limit, $message = '') |
|
| 2366 | - { |
|
| 2367 | - static::isIterable($value); |
|
| 2368 | - |
|
| 2369 | - foreach ($value as $entry) { |
|
| 2370 | - static::lessThanEq($entry, $limit, $message); |
|
| 2371 | - } |
|
| 2372 | - } |
|
| 2373 | - |
|
| 2374 | - /** |
|
| 2375 | - * @psalm-pure |
|
| 2376 | - * |
|
| 2377 | - * @param mixed $value |
|
| 2378 | - * @param mixed $limit |
|
| 2379 | - * @param string $message |
|
| 2380 | - * |
|
| 2381 | - * @throws InvalidArgumentException |
|
| 2382 | - * |
|
| 2383 | - * @return void |
|
| 2384 | - */ |
|
| 2385 | - public static function allNullOrLessThanEq($value, $limit, $message = '') |
|
| 2386 | - { |
|
| 2387 | - static::isIterable($value); |
|
| 2388 | - |
|
| 2389 | - foreach ($value as $entry) { |
|
| 2390 | - null === $entry || static::lessThanEq($entry, $limit, $message); |
|
| 2391 | - } |
|
| 2392 | - } |
|
| 2393 | - |
|
| 2394 | - /** |
|
| 2395 | - * @psalm-pure |
|
| 2396 | - * |
|
| 2397 | - * @param mixed $value |
|
| 2398 | - * @param mixed $min |
|
| 2399 | - * @param mixed $max |
|
| 2400 | - * @param string $message |
|
| 2401 | - * |
|
| 2402 | - * @throws InvalidArgumentException |
|
| 2403 | - * |
|
| 2404 | - * @return void |
|
| 2405 | - */ |
|
| 2406 | - public static function nullOrRange($value, $min, $max, $message = '') |
|
| 2407 | - { |
|
| 2408 | - null === $value || static::range($value, $min, $max, $message); |
|
| 2409 | - } |
|
| 2410 | - |
|
| 2411 | - /** |
|
| 2412 | - * @psalm-pure |
|
| 2413 | - * |
|
| 2414 | - * @param mixed $value |
|
| 2415 | - * @param mixed $min |
|
| 2416 | - * @param mixed $max |
|
| 2417 | - * @param string $message |
|
| 2418 | - * |
|
| 2419 | - * @throws InvalidArgumentException |
|
| 2420 | - * |
|
| 2421 | - * @return void |
|
| 2422 | - */ |
|
| 2423 | - public static function allRange($value, $min, $max, $message = '') |
|
| 2424 | - { |
|
| 2425 | - static::isIterable($value); |
|
| 2426 | - |
|
| 2427 | - foreach ($value as $entry) { |
|
| 2428 | - static::range($entry, $min, $max, $message); |
|
| 2429 | - } |
|
| 2430 | - } |
|
| 2431 | - |
|
| 2432 | - /** |
|
| 2433 | - * @psalm-pure |
|
| 2434 | - * |
|
| 2435 | - * @param mixed $value |
|
| 2436 | - * @param mixed $min |
|
| 2437 | - * @param mixed $max |
|
| 2438 | - * @param string $message |
|
| 2439 | - * |
|
| 2440 | - * @throws InvalidArgumentException |
|
| 2441 | - * |
|
| 2442 | - * @return void |
|
| 2443 | - */ |
|
| 2444 | - public static function allNullOrRange($value, $min, $max, $message = '') |
|
| 2445 | - { |
|
| 2446 | - static::isIterable($value); |
|
| 2447 | - |
|
| 2448 | - foreach ($value as $entry) { |
|
| 2449 | - null === $entry || static::range($entry, $min, $max, $message); |
|
| 2450 | - } |
|
| 2451 | - } |
|
| 2452 | - |
|
| 2453 | - /** |
|
| 2454 | - * @psalm-pure |
|
| 2455 | - * |
|
| 2456 | - * @param mixed $value |
|
| 2457 | - * @param array $values |
|
| 2458 | - * @param string $message |
|
| 2459 | - * |
|
| 2460 | - * @throws InvalidArgumentException |
|
| 2461 | - * |
|
| 2462 | - * @return void |
|
| 2463 | - */ |
|
| 2464 | - public static function nullOrOneOf($value, $values, $message = '') |
|
| 2465 | - { |
|
| 2466 | - null === $value || static::oneOf($value, $values, $message); |
|
| 2467 | - } |
|
| 2468 | - |
|
| 2469 | - /** |
|
| 2470 | - * @psalm-pure |
|
| 2471 | - * |
|
| 2472 | - * @param mixed $value |
|
| 2473 | - * @param array $values |
|
| 2474 | - * @param string $message |
|
| 2475 | - * |
|
| 2476 | - * @throws InvalidArgumentException |
|
| 2477 | - * |
|
| 2478 | - * @return void |
|
| 2479 | - */ |
|
| 2480 | - public static function allOneOf($value, $values, $message = '') |
|
| 2481 | - { |
|
| 2482 | - static::isIterable($value); |
|
| 2483 | - |
|
| 2484 | - foreach ($value as $entry) { |
|
| 2485 | - static::oneOf($entry, $values, $message); |
|
| 2486 | - } |
|
| 2487 | - } |
|
| 2488 | - |
|
| 2489 | - /** |
|
| 2490 | - * @psalm-pure |
|
| 2491 | - * |
|
| 2492 | - * @param mixed $value |
|
| 2493 | - * @param array $values |
|
| 2494 | - * @param string $message |
|
| 2495 | - * |
|
| 2496 | - * @throws InvalidArgumentException |
|
| 2497 | - * |
|
| 2498 | - * @return void |
|
| 2499 | - */ |
|
| 2500 | - public static function allNullOrOneOf($value, $values, $message = '') |
|
| 2501 | - { |
|
| 2502 | - static::isIterable($value); |
|
| 2503 | - |
|
| 2504 | - foreach ($value as $entry) { |
|
| 2505 | - null === $entry || static::oneOf($entry, $values, $message); |
|
| 2506 | - } |
|
| 2507 | - } |
|
| 2508 | - |
|
| 2509 | - /** |
|
| 2510 | - * @psalm-pure |
|
| 2511 | - * |
|
| 2512 | - * @param mixed $value |
|
| 2513 | - * @param array $values |
|
| 2514 | - * @param string $message |
|
| 2515 | - * |
|
| 2516 | - * @throws InvalidArgumentException |
|
| 2517 | - * |
|
| 2518 | - * @return void |
|
| 2519 | - */ |
|
| 2520 | - public static function nullOrInArray($value, $values, $message = '') |
|
| 2521 | - { |
|
| 2522 | - null === $value || static::inArray($value, $values, $message); |
|
| 2523 | - } |
|
| 2524 | - |
|
| 2525 | - /** |
|
| 2526 | - * @psalm-pure |
|
| 2527 | - * |
|
| 2528 | - * @param mixed $value |
|
| 2529 | - * @param array $values |
|
| 2530 | - * @param string $message |
|
| 2531 | - * |
|
| 2532 | - * @throws InvalidArgumentException |
|
| 2533 | - * |
|
| 2534 | - * @return void |
|
| 2535 | - */ |
|
| 2536 | - public static function allInArray($value, $values, $message = '') |
|
| 2537 | - { |
|
| 2538 | - static::isIterable($value); |
|
| 2539 | - |
|
| 2540 | - foreach ($value as $entry) { |
|
| 2541 | - static::inArray($entry, $values, $message); |
|
| 2542 | - } |
|
| 2543 | - } |
|
| 2544 | - |
|
| 2545 | - /** |
|
| 2546 | - * @psalm-pure |
|
| 2547 | - * |
|
| 2548 | - * @param mixed $value |
|
| 2549 | - * @param array $values |
|
| 2550 | - * @param string $message |
|
| 2551 | - * |
|
| 2552 | - * @throws InvalidArgumentException |
|
| 2553 | - * |
|
| 2554 | - * @return void |
|
| 2555 | - */ |
|
| 2556 | - public static function allNullOrInArray($value, $values, $message = '') |
|
| 2557 | - { |
|
| 2558 | - static::isIterable($value); |
|
| 2559 | - |
|
| 2560 | - foreach ($value as $entry) { |
|
| 2561 | - null === $entry || static::inArray($entry, $values, $message); |
|
| 2562 | - } |
|
| 2563 | - } |
|
| 2564 | - |
|
| 2565 | - /** |
|
| 2566 | - * @psalm-pure |
|
| 2567 | - * |
|
| 2568 | - * @param string|null $value |
|
| 2569 | - * @param string $subString |
|
| 2570 | - * @param string $message |
|
| 2571 | - * |
|
| 2572 | - * @throws InvalidArgumentException |
|
| 2573 | - * |
|
| 2574 | - * @return void |
|
| 2575 | - */ |
|
| 2576 | - public static function nullOrContains($value, $subString, $message = '') |
|
| 2577 | - { |
|
| 2578 | - null === $value || static::contains($value, $subString, $message); |
|
| 2579 | - } |
|
| 2580 | - |
|
| 2581 | - /** |
|
| 2582 | - * @psalm-pure |
|
| 2583 | - * |
|
| 2584 | - * @param iterable<string> $value |
|
| 2585 | - * @param string $subString |
|
| 2586 | - * @param string $message |
|
| 2587 | - * |
|
| 2588 | - * @throws InvalidArgumentException |
|
| 2589 | - * |
|
| 2590 | - * @return void |
|
| 2591 | - */ |
|
| 2592 | - public static function allContains($value, $subString, $message = '') |
|
| 2593 | - { |
|
| 2594 | - static::isIterable($value); |
|
| 2595 | - |
|
| 2596 | - foreach ($value as $entry) { |
|
| 2597 | - static::contains($entry, $subString, $message); |
|
| 2598 | - } |
|
| 2599 | - } |
|
| 2600 | - |
|
| 2601 | - /** |
|
| 2602 | - * @psalm-pure |
|
| 2603 | - * |
|
| 2604 | - * @param iterable<string|null> $value |
|
| 2605 | - * @param string $subString |
|
| 2606 | - * @param string $message |
|
| 2607 | - * |
|
| 2608 | - * @throws InvalidArgumentException |
|
| 2609 | - * |
|
| 2610 | - * @return void |
|
| 2611 | - */ |
|
| 2612 | - public static function allNullOrContains($value, $subString, $message = '') |
|
| 2613 | - { |
|
| 2614 | - static::isIterable($value); |
|
| 2615 | - |
|
| 2616 | - foreach ($value as $entry) { |
|
| 2617 | - null === $entry || static::contains($entry, $subString, $message); |
|
| 2618 | - } |
|
| 2619 | - } |
|
| 2620 | - |
|
| 2621 | - /** |
|
| 2622 | - * @psalm-pure |
|
| 2623 | - * |
|
| 2624 | - * @param string|null $value |
|
| 2625 | - * @param string $subString |
|
| 2626 | - * @param string $message |
|
| 2627 | - * |
|
| 2628 | - * @throws InvalidArgumentException |
|
| 2629 | - * |
|
| 2630 | - * @return void |
|
| 2631 | - */ |
|
| 2632 | - public static function nullOrNotContains($value, $subString, $message = '') |
|
| 2633 | - { |
|
| 2634 | - null === $value || static::notContains($value, $subString, $message); |
|
| 2635 | - } |
|
| 2636 | - |
|
| 2637 | - /** |
|
| 2638 | - * @psalm-pure |
|
| 2639 | - * |
|
| 2640 | - * @param iterable<string> $value |
|
| 2641 | - * @param string $subString |
|
| 2642 | - * @param string $message |
|
| 2643 | - * |
|
| 2644 | - * @throws InvalidArgumentException |
|
| 2645 | - * |
|
| 2646 | - * @return void |
|
| 2647 | - */ |
|
| 2648 | - public static function allNotContains($value, $subString, $message = '') |
|
| 2649 | - { |
|
| 2650 | - static::isIterable($value); |
|
| 2651 | - |
|
| 2652 | - foreach ($value as $entry) { |
|
| 2653 | - static::notContains($entry, $subString, $message); |
|
| 2654 | - } |
|
| 2655 | - } |
|
| 2656 | - |
|
| 2657 | - /** |
|
| 2658 | - * @psalm-pure |
|
| 2659 | - * |
|
| 2660 | - * @param iterable<string|null> $value |
|
| 2661 | - * @param string $subString |
|
| 2662 | - * @param string $message |
|
| 2663 | - * |
|
| 2664 | - * @throws InvalidArgumentException |
|
| 2665 | - * |
|
| 2666 | - * @return void |
|
| 2667 | - */ |
|
| 2668 | - public static function allNullOrNotContains($value, $subString, $message = '') |
|
| 2669 | - { |
|
| 2670 | - static::isIterable($value); |
|
| 2671 | - |
|
| 2672 | - foreach ($value as $entry) { |
|
| 2673 | - null === $entry || static::notContains($entry, $subString, $message); |
|
| 2674 | - } |
|
| 2675 | - } |
|
| 2676 | - |
|
| 2677 | - /** |
|
| 2678 | - * @psalm-pure |
|
| 2679 | - * |
|
| 2680 | - * @param string|null $value |
|
| 2681 | - * @param string $message |
|
| 2682 | - * |
|
| 2683 | - * @throws InvalidArgumentException |
|
| 2684 | - * |
|
| 2685 | - * @return void |
|
| 2686 | - */ |
|
| 2687 | - public static function nullOrNotWhitespaceOnly($value, $message = '') |
|
| 2688 | - { |
|
| 2689 | - null === $value || static::notWhitespaceOnly($value, $message); |
|
| 2690 | - } |
|
| 2691 | - |
|
| 2692 | - /** |
|
| 2693 | - * @psalm-pure |
|
| 2694 | - * |
|
| 2695 | - * @param iterable<string> $value |
|
| 2696 | - * @param string $message |
|
| 2697 | - * |
|
| 2698 | - * @throws InvalidArgumentException |
|
| 2699 | - * |
|
| 2700 | - * @return void |
|
| 2701 | - */ |
|
| 2702 | - public static function allNotWhitespaceOnly($value, $message = '') |
|
| 2703 | - { |
|
| 2704 | - static::isIterable($value); |
|
| 2705 | - |
|
| 2706 | - foreach ($value as $entry) { |
|
| 2707 | - static::notWhitespaceOnly($entry, $message); |
|
| 2708 | - } |
|
| 2709 | - } |
|
| 2710 | - |
|
| 2711 | - /** |
|
| 2712 | - * @psalm-pure |
|
| 2713 | - * |
|
| 2714 | - * @param iterable<string|null> $value |
|
| 2715 | - * @param string $message |
|
| 2716 | - * |
|
| 2717 | - * @throws InvalidArgumentException |
|
| 2718 | - * |
|
| 2719 | - * @return void |
|
| 2720 | - */ |
|
| 2721 | - public static function allNullOrNotWhitespaceOnly($value, $message = '') |
|
| 2722 | - { |
|
| 2723 | - static::isIterable($value); |
|
| 2724 | - |
|
| 2725 | - foreach ($value as $entry) { |
|
| 2726 | - null === $entry || static::notWhitespaceOnly($entry, $message); |
|
| 2727 | - } |
|
| 2728 | - } |
|
| 2729 | - |
|
| 2730 | - /** |
|
| 2731 | - * @psalm-pure |
|
| 2732 | - * |
|
| 2733 | - * @param string|null $value |
|
| 2734 | - * @param string $prefix |
|
| 2735 | - * @param string $message |
|
| 2736 | - * |
|
| 2737 | - * @throws InvalidArgumentException |
|
| 2738 | - * |
|
| 2739 | - * @return void |
|
| 2740 | - */ |
|
| 2741 | - public static function nullOrStartsWith($value, $prefix, $message = '') |
|
| 2742 | - { |
|
| 2743 | - null === $value || static::startsWith($value, $prefix, $message); |
|
| 2744 | - } |
|
| 2745 | - |
|
| 2746 | - /** |
|
| 2747 | - * @psalm-pure |
|
| 2748 | - * |
|
| 2749 | - * @param iterable<string> $value |
|
| 2750 | - * @param string $prefix |
|
| 2751 | - * @param string $message |
|
| 2752 | - * |
|
| 2753 | - * @throws InvalidArgumentException |
|
| 2754 | - * |
|
| 2755 | - * @return void |
|
| 2756 | - */ |
|
| 2757 | - public static function allStartsWith($value, $prefix, $message = '') |
|
| 2758 | - { |
|
| 2759 | - static::isIterable($value); |
|
| 2760 | - |
|
| 2761 | - foreach ($value as $entry) { |
|
| 2762 | - static::startsWith($entry, $prefix, $message); |
|
| 2763 | - } |
|
| 2764 | - } |
|
| 2765 | - |
|
| 2766 | - /** |
|
| 2767 | - * @psalm-pure |
|
| 2768 | - * |
|
| 2769 | - * @param iterable<string|null> $value |
|
| 2770 | - * @param string $prefix |
|
| 2771 | - * @param string $message |
|
| 2772 | - * |
|
| 2773 | - * @throws InvalidArgumentException |
|
| 2774 | - * |
|
| 2775 | - * @return void |
|
| 2776 | - */ |
|
| 2777 | - public static function allNullOrStartsWith($value, $prefix, $message = '') |
|
| 2778 | - { |
|
| 2779 | - static::isIterable($value); |
|
| 2780 | - |
|
| 2781 | - foreach ($value as $entry) { |
|
| 2782 | - null === $entry || static::startsWith($entry, $prefix, $message); |
|
| 2783 | - } |
|
| 2784 | - } |
|
| 2785 | - |
|
| 2786 | - /** |
|
| 2787 | - * @psalm-pure |
|
| 2788 | - * |
|
| 2789 | - * @param string|null $value |
|
| 2790 | - * @param string $prefix |
|
| 2791 | - * @param string $message |
|
| 2792 | - * |
|
| 2793 | - * @throws InvalidArgumentException |
|
| 2794 | - * |
|
| 2795 | - * @return void |
|
| 2796 | - */ |
|
| 2797 | - public static function nullOrNotStartsWith($value, $prefix, $message = '') |
|
| 2798 | - { |
|
| 2799 | - null === $value || static::notStartsWith($value, $prefix, $message); |
|
| 2800 | - } |
|
| 2801 | - |
|
| 2802 | - /** |
|
| 2803 | - * @psalm-pure |
|
| 2804 | - * |
|
| 2805 | - * @param iterable<string> $value |
|
| 2806 | - * @param string $prefix |
|
| 2807 | - * @param string $message |
|
| 2808 | - * |
|
| 2809 | - * @throws InvalidArgumentException |
|
| 2810 | - * |
|
| 2811 | - * @return void |
|
| 2812 | - */ |
|
| 2813 | - public static function allNotStartsWith($value, $prefix, $message = '') |
|
| 2814 | - { |
|
| 2815 | - static::isIterable($value); |
|
| 2816 | - |
|
| 2817 | - foreach ($value as $entry) { |
|
| 2818 | - static::notStartsWith($entry, $prefix, $message); |
|
| 2819 | - } |
|
| 2820 | - } |
|
| 2821 | - |
|
| 2822 | - /** |
|
| 2823 | - * @psalm-pure |
|
| 2824 | - * |
|
| 2825 | - * @param iterable<string|null> $value |
|
| 2826 | - * @param string $prefix |
|
| 2827 | - * @param string $message |
|
| 2828 | - * |
|
| 2829 | - * @throws InvalidArgumentException |
|
| 2830 | - * |
|
| 2831 | - * @return void |
|
| 2832 | - */ |
|
| 2833 | - public static function allNullOrNotStartsWith($value, $prefix, $message = '') |
|
| 2834 | - { |
|
| 2835 | - static::isIterable($value); |
|
| 2836 | - |
|
| 2837 | - foreach ($value as $entry) { |
|
| 2838 | - null === $entry || static::notStartsWith($entry, $prefix, $message); |
|
| 2839 | - } |
|
| 2840 | - } |
|
| 2841 | - |
|
| 2842 | - /** |
|
| 2843 | - * @psalm-pure |
|
| 2844 | - * |
|
| 2845 | - * @param mixed $value |
|
| 2846 | - * @param string $message |
|
| 2847 | - * |
|
| 2848 | - * @throws InvalidArgumentException |
|
| 2849 | - * |
|
| 2850 | - * @return void |
|
| 2851 | - */ |
|
| 2852 | - public static function nullOrStartsWithLetter($value, $message = '') |
|
| 2853 | - { |
|
| 2854 | - null === $value || static::startsWithLetter($value, $message); |
|
| 2855 | - } |
|
| 2856 | - |
|
| 2857 | - /** |
|
| 2858 | - * @psalm-pure |
|
| 2859 | - * |
|
| 2860 | - * @param mixed $value |
|
| 2861 | - * @param string $message |
|
| 2862 | - * |
|
| 2863 | - * @throws InvalidArgumentException |
|
| 2864 | - * |
|
| 2865 | - * @return void |
|
| 2866 | - */ |
|
| 2867 | - public static function allStartsWithLetter($value, $message = '') |
|
| 2868 | - { |
|
| 2869 | - static::isIterable($value); |
|
| 2870 | - |
|
| 2871 | - foreach ($value as $entry) { |
|
| 2872 | - static::startsWithLetter($entry, $message); |
|
| 2873 | - } |
|
| 2874 | - } |
|
| 2875 | - |
|
| 2876 | - /** |
|
| 2877 | - * @psalm-pure |
|
| 2878 | - * |
|
| 2879 | - * @param mixed $value |
|
| 2880 | - * @param string $message |
|
| 2881 | - * |
|
| 2882 | - * @throws InvalidArgumentException |
|
| 2883 | - * |
|
| 2884 | - * @return void |
|
| 2885 | - */ |
|
| 2886 | - public static function allNullOrStartsWithLetter($value, $message = '') |
|
| 2887 | - { |
|
| 2888 | - static::isIterable($value); |
|
| 2889 | - |
|
| 2890 | - foreach ($value as $entry) { |
|
| 2891 | - null === $entry || static::startsWithLetter($entry, $message); |
|
| 2892 | - } |
|
| 2893 | - } |
|
| 2894 | - |
|
| 2895 | - /** |
|
| 2896 | - * @psalm-pure |
|
| 2897 | - * |
|
| 2898 | - * @param string|null $value |
|
| 2899 | - * @param string $suffix |
|
| 2900 | - * @param string $message |
|
| 2901 | - * |
|
| 2902 | - * @throws InvalidArgumentException |
|
| 2903 | - * |
|
| 2904 | - * @return void |
|
| 2905 | - */ |
|
| 2906 | - public static function nullOrEndsWith($value, $suffix, $message = '') |
|
| 2907 | - { |
|
| 2908 | - null === $value || static::endsWith($value, $suffix, $message); |
|
| 2909 | - } |
|
| 2910 | - |
|
| 2911 | - /** |
|
| 2912 | - * @psalm-pure |
|
| 2913 | - * |
|
| 2914 | - * @param iterable<string> $value |
|
| 2915 | - * @param string $suffix |
|
| 2916 | - * @param string $message |
|
| 2917 | - * |
|
| 2918 | - * @throws InvalidArgumentException |
|
| 2919 | - * |
|
| 2920 | - * @return void |
|
| 2921 | - */ |
|
| 2922 | - public static function allEndsWith($value, $suffix, $message = '') |
|
| 2923 | - { |
|
| 2924 | - static::isIterable($value); |
|
| 2925 | - |
|
| 2926 | - foreach ($value as $entry) { |
|
| 2927 | - static::endsWith($entry, $suffix, $message); |
|
| 2928 | - } |
|
| 2929 | - } |
|
| 2930 | - |
|
| 2931 | - /** |
|
| 2932 | - * @psalm-pure |
|
| 2933 | - * |
|
| 2934 | - * @param iterable<string|null> $value |
|
| 2935 | - * @param string $suffix |
|
| 2936 | - * @param string $message |
|
| 2937 | - * |
|
| 2938 | - * @throws InvalidArgumentException |
|
| 2939 | - * |
|
| 2940 | - * @return void |
|
| 2941 | - */ |
|
| 2942 | - public static function allNullOrEndsWith($value, $suffix, $message = '') |
|
| 2943 | - { |
|
| 2944 | - static::isIterable($value); |
|
| 2945 | - |
|
| 2946 | - foreach ($value as $entry) { |
|
| 2947 | - null === $entry || static::endsWith($entry, $suffix, $message); |
|
| 2948 | - } |
|
| 2949 | - } |
|
| 2950 | - |
|
| 2951 | - /** |
|
| 2952 | - * @psalm-pure |
|
| 2953 | - * |
|
| 2954 | - * @param string|null $value |
|
| 2955 | - * @param string $suffix |
|
| 2956 | - * @param string $message |
|
| 2957 | - * |
|
| 2958 | - * @throws InvalidArgumentException |
|
| 2959 | - * |
|
| 2960 | - * @return void |
|
| 2961 | - */ |
|
| 2962 | - public static function nullOrNotEndsWith($value, $suffix, $message = '') |
|
| 2963 | - { |
|
| 2964 | - null === $value || static::notEndsWith($value, $suffix, $message); |
|
| 2965 | - } |
|
| 2966 | - |
|
| 2967 | - /** |
|
| 2968 | - * @psalm-pure |
|
| 2969 | - * |
|
| 2970 | - * @param iterable<string> $value |
|
| 2971 | - * @param string $suffix |
|
| 2972 | - * @param string $message |
|
| 2973 | - * |
|
| 2974 | - * @throws InvalidArgumentException |
|
| 2975 | - * |
|
| 2976 | - * @return void |
|
| 2977 | - */ |
|
| 2978 | - public static function allNotEndsWith($value, $suffix, $message = '') |
|
| 2979 | - { |
|
| 2980 | - static::isIterable($value); |
|
| 2981 | - |
|
| 2982 | - foreach ($value as $entry) { |
|
| 2983 | - static::notEndsWith($entry, $suffix, $message); |
|
| 2984 | - } |
|
| 2985 | - } |
|
| 2986 | - |
|
| 2987 | - /** |
|
| 2988 | - * @psalm-pure |
|
| 2989 | - * |
|
| 2990 | - * @param iterable<string|null> $value |
|
| 2991 | - * @param string $suffix |
|
| 2992 | - * @param string $message |
|
| 2993 | - * |
|
| 2994 | - * @throws InvalidArgumentException |
|
| 2995 | - * |
|
| 2996 | - * @return void |
|
| 2997 | - */ |
|
| 2998 | - public static function allNullOrNotEndsWith($value, $suffix, $message = '') |
|
| 2999 | - { |
|
| 3000 | - static::isIterable($value); |
|
| 3001 | - |
|
| 3002 | - foreach ($value as $entry) { |
|
| 3003 | - null === $entry || static::notEndsWith($entry, $suffix, $message); |
|
| 3004 | - } |
|
| 3005 | - } |
|
| 3006 | - |
|
| 3007 | - /** |
|
| 3008 | - * @psalm-pure |
|
| 3009 | - * |
|
| 3010 | - * @param string|null $value |
|
| 3011 | - * @param string $pattern |
|
| 3012 | - * @param string $message |
|
| 3013 | - * |
|
| 3014 | - * @throws InvalidArgumentException |
|
| 3015 | - * |
|
| 3016 | - * @return void |
|
| 3017 | - */ |
|
| 3018 | - public static function nullOrRegex($value, $pattern, $message = '') |
|
| 3019 | - { |
|
| 3020 | - null === $value || static::regex($value, $pattern, $message); |
|
| 3021 | - } |
|
| 3022 | - |
|
| 3023 | - /** |
|
| 3024 | - * @psalm-pure |
|
| 3025 | - * |
|
| 3026 | - * @param iterable<string> $value |
|
| 3027 | - * @param string $pattern |
|
| 3028 | - * @param string $message |
|
| 3029 | - * |
|
| 3030 | - * @throws InvalidArgumentException |
|
| 3031 | - * |
|
| 3032 | - * @return void |
|
| 3033 | - */ |
|
| 3034 | - public static function allRegex($value, $pattern, $message = '') |
|
| 3035 | - { |
|
| 3036 | - static::isIterable($value); |
|
| 3037 | - |
|
| 3038 | - foreach ($value as $entry) { |
|
| 3039 | - static::regex($entry, $pattern, $message); |
|
| 3040 | - } |
|
| 3041 | - } |
|
| 3042 | - |
|
| 3043 | - /** |
|
| 3044 | - * @psalm-pure |
|
| 3045 | - * |
|
| 3046 | - * @param iterable<string|null> $value |
|
| 3047 | - * @param string $pattern |
|
| 3048 | - * @param string $message |
|
| 3049 | - * |
|
| 3050 | - * @throws InvalidArgumentException |
|
| 3051 | - * |
|
| 3052 | - * @return void |
|
| 3053 | - */ |
|
| 3054 | - public static function allNullOrRegex($value, $pattern, $message = '') |
|
| 3055 | - { |
|
| 3056 | - static::isIterable($value); |
|
| 3057 | - |
|
| 3058 | - foreach ($value as $entry) { |
|
| 3059 | - null === $entry || static::regex($entry, $pattern, $message); |
|
| 3060 | - } |
|
| 3061 | - } |
|
| 3062 | - |
|
| 3063 | - /** |
|
| 3064 | - * @psalm-pure |
|
| 3065 | - * |
|
| 3066 | - * @param string|null $value |
|
| 3067 | - * @param string $pattern |
|
| 3068 | - * @param string $message |
|
| 3069 | - * |
|
| 3070 | - * @throws InvalidArgumentException |
|
| 3071 | - * |
|
| 3072 | - * @return void |
|
| 3073 | - */ |
|
| 3074 | - public static function nullOrNotRegex($value, $pattern, $message = '') |
|
| 3075 | - { |
|
| 3076 | - null === $value || static::notRegex($value, $pattern, $message); |
|
| 3077 | - } |
|
| 3078 | - |
|
| 3079 | - /** |
|
| 3080 | - * @psalm-pure |
|
| 3081 | - * |
|
| 3082 | - * @param iterable<string> $value |
|
| 3083 | - * @param string $pattern |
|
| 3084 | - * @param string $message |
|
| 3085 | - * |
|
| 3086 | - * @throws InvalidArgumentException |
|
| 3087 | - * |
|
| 3088 | - * @return void |
|
| 3089 | - */ |
|
| 3090 | - public static function allNotRegex($value, $pattern, $message = '') |
|
| 3091 | - { |
|
| 3092 | - static::isIterable($value); |
|
| 3093 | - |
|
| 3094 | - foreach ($value as $entry) { |
|
| 3095 | - static::notRegex($entry, $pattern, $message); |
|
| 3096 | - } |
|
| 3097 | - } |
|
| 3098 | - |
|
| 3099 | - /** |
|
| 3100 | - * @psalm-pure |
|
| 3101 | - * |
|
| 3102 | - * @param iterable<string|null> $value |
|
| 3103 | - * @param string $pattern |
|
| 3104 | - * @param string $message |
|
| 3105 | - * |
|
| 3106 | - * @throws InvalidArgumentException |
|
| 3107 | - * |
|
| 3108 | - * @return void |
|
| 3109 | - */ |
|
| 3110 | - public static function allNullOrNotRegex($value, $pattern, $message = '') |
|
| 3111 | - { |
|
| 3112 | - static::isIterable($value); |
|
| 3113 | - |
|
| 3114 | - foreach ($value as $entry) { |
|
| 3115 | - null === $entry || static::notRegex($entry, $pattern, $message); |
|
| 3116 | - } |
|
| 3117 | - } |
|
| 3118 | - |
|
| 3119 | - /** |
|
| 3120 | - * @psalm-pure |
|
| 3121 | - * |
|
| 3122 | - * @param mixed $value |
|
| 3123 | - * @param string $message |
|
| 3124 | - * |
|
| 3125 | - * @throws InvalidArgumentException |
|
| 3126 | - * |
|
| 3127 | - * @return void |
|
| 3128 | - */ |
|
| 3129 | - public static function nullOrUnicodeLetters($value, $message = '') |
|
| 3130 | - { |
|
| 3131 | - null === $value || static::unicodeLetters($value, $message); |
|
| 3132 | - } |
|
| 3133 | - |
|
| 3134 | - /** |
|
| 3135 | - * @psalm-pure |
|
| 3136 | - * |
|
| 3137 | - * @param mixed $value |
|
| 3138 | - * @param string $message |
|
| 3139 | - * |
|
| 3140 | - * @throws InvalidArgumentException |
|
| 3141 | - * |
|
| 3142 | - * @return void |
|
| 3143 | - */ |
|
| 3144 | - public static function allUnicodeLetters($value, $message = '') |
|
| 3145 | - { |
|
| 3146 | - static::isIterable($value); |
|
| 3147 | - |
|
| 3148 | - foreach ($value as $entry) { |
|
| 3149 | - static::unicodeLetters($entry, $message); |
|
| 3150 | - } |
|
| 3151 | - } |
|
| 3152 | - |
|
| 3153 | - /** |
|
| 3154 | - * @psalm-pure |
|
| 3155 | - * |
|
| 3156 | - * @param mixed $value |
|
| 3157 | - * @param string $message |
|
| 3158 | - * |
|
| 3159 | - * @throws InvalidArgumentException |
|
| 3160 | - * |
|
| 3161 | - * @return void |
|
| 3162 | - */ |
|
| 3163 | - public static function allNullOrUnicodeLetters($value, $message = '') |
|
| 3164 | - { |
|
| 3165 | - static::isIterable($value); |
|
| 3166 | - |
|
| 3167 | - foreach ($value as $entry) { |
|
| 3168 | - null === $entry || static::unicodeLetters($entry, $message); |
|
| 3169 | - } |
|
| 3170 | - } |
|
| 3171 | - |
|
| 3172 | - /** |
|
| 3173 | - * @psalm-pure |
|
| 3174 | - * |
|
| 3175 | - * @param mixed $value |
|
| 3176 | - * @param string $message |
|
| 3177 | - * |
|
| 3178 | - * @throws InvalidArgumentException |
|
| 3179 | - * |
|
| 3180 | - * @return void |
|
| 3181 | - */ |
|
| 3182 | - public static function nullOrAlpha($value, $message = '') |
|
| 3183 | - { |
|
| 3184 | - null === $value || static::alpha($value, $message); |
|
| 3185 | - } |
|
| 3186 | - |
|
| 3187 | - /** |
|
| 3188 | - * @psalm-pure |
|
| 3189 | - * |
|
| 3190 | - * @param mixed $value |
|
| 3191 | - * @param string $message |
|
| 3192 | - * |
|
| 3193 | - * @throws InvalidArgumentException |
|
| 3194 | - * |
|
| 3195 | - * @return void |
|
| 3196 | - */ |
|
| 3197 | - public static function allAlpha($value, $message = '') |
|
| 3198 | - { |
|
| 3199 | - static::isIterable($value); |
|
| 3200 | - |
|
| 3201 | - foreach ($value as $entry) { |
|
| 3202 | - static::alpha($entry, $message); |
|
| 3203 | - } |
|
| 3204 | - } |
|
| 3205 | - |
|
| 3206 | - /** |
|
| 3207 | - * @psalm-pure |
|
| 3208 | - * |
|
| 3209 | - * @param mixed $value |
|
| 3210 | - * @param string $message |
|
| 3211 | - * |
|
| 3212 | - * @throws InvalidArgumentException |
|
| 3213 | - * |
|
| 3214 | - * @return void |
|
| 3215 | - */ |
|
| 3216 | - public static function allNullOrAlpha($value, $message = '') |
|
| 3217 | - { |
|
| 3218 | - static::isIterable($value); |
|
| 3219 | - |
|
| 3220 | - foreach ($value as $entry) { |
|
| 3221 | - null === $entry || static::alpha($entry, $message); |
|
| 3222 | - } |
|
| 3223 | - } |
|
| 3224 | - |
|
| 3225 | - /** |
|
| 3226 | - * @psalm-pure |
|
| 3227 | - * |
|
| 3228 | - * @param string|null $value |
|
| 3229 | - * @param string $message |
|
| 3230 | - * |
|
| 3231 | - * @throws InvalidArgumentException |
|
| 3232 | - * |
|
| 3233 | - * @return void |
|
| 3234 | - */ |
|
| 3235 | - public static function nullOrDigits($value, $message = '') |
|
| 3236 | - { |
|
| 3237 | - null === $value || static::digits($value, $message); |
|
| 3238 | - } |
|
| 3239 | - |
|
| 3240 | - /** |
|
| 3241 | - * @psalm-pure |
|
| 3242 | - * |
|
| 3243 | - * @param iterable<string> $value |
|
| 3244 | - * @param string $message |
|
| 3245 | - * |
|
| 3246 | - * @throws InvalidArgumentException |
|
| 3247 | - * |
|
| 3248 | - * @return void |
|
| 3249 | - */ |
|
| 3250 | - public static function allDigits($value, $message = '') |
|
| 3251 | - { |
|
| 3252 | - static::isIterable($value); |
|
| 3253 | - |
|
| 3254 | - foreach ($value as $entry) { |
|
| 3255 | - static::digits($entry, $message); |
|
| 3256 | - } |
|
| 3257 | - } |
|
| 3258 | - |
|
| 3259 | - /** |
|
| 3260 | - * @psalm-pure |
|
| 3261 | - * |
|
| 3262 | - * @param iterable<string|null> $value |
|
| 3263 | - * @param string $message |
|
| 3264 | - * |
|
| 3265 | - * @throws InvalidArgumentException |
|
| 3266 | - * |
|
| 3267 | - * @return void |
|
| 3268 | - */ |
|
| 3269 | - public static function allNullOrDigits($value, $message = '') |
|
| 3270 | - { |
|
| 3271 | - static::isIterable($value); |
|
| 3272 | - |
|
| 3273 | - foreach ($value as $entry) { |
|
| 3274 | - null === $entry || static::digits($entry, $message); |
|
| 3275 | - } |
|
| 3276 | - } |
|
| 3277 | - |
|
| 3278 | - /** |
|
| 3279 | - * @psalm-pure |
|
| 3280 | - * |
|
| 3281 | - * @param string|null $value |
|
| 3282 | - * @param string $message |
|
| 3283 | - * |
|
| 3284 | - * @throws InvalidArgumentException |
|
| 3285 | - * |
|
| 3286 | - * @return void |
|
| 3287 | - */ |
|
| 3288 | - public static function nullOrAlnum($value, $message = '') |
|
| 3289 | - { |
|
| 3290 | - null === $value || static::alnum($value, $message); |
|
| 3291 | - } |
|
| 3292 | - |
|
| 3293 | - /** |
|
| 3294 | - * @psalm-pure |
|
| 3295 | - * |
|
| 3296 | - * @param iterable<string> $value |
|
| 3297 | - * @param string $message |
|
| 3298 | - * |
|
| 3299 | - * @throws InvalidArgumentException |
|
| 3300 | - * |
|
| 3301 | - * @return void |
|
| 3302 | - */ |
|
| 3303 | - public static function allAlnum($value, $message = '') |
|
| 3304 | - { |
|
| 3305 | - static::isIterable($value); |
|
| 3306 | - |
|
| 3307 | - foreach ($value as $entry) { |
|
| 3308 | - static::alnum($entry, $message); |
|
| 3309 | - } |
|
| 3310 | - } |
|
| 3311 | - |
|
| 3312 | - /** |
|
| 3313 | - * @psalm-pure |
|
| 3314 | - * |
|
| 3315 | - * @param iterable<string|null> $value |
|
| 3316 | - * @param string $message |
|
| 3317 | - * |
|
| 3318 | - * @throws InvalidArgumentException |
|
| 3319 | - * |
|
| 3320 | - * @return void |
|
| 3321 | - */ |
|
| 3322 | - public static function allNullOrAlnum($value, $message = '') |
|
| 3323 | - { |
|
| 3324 | - static::isIterable($value); |
|
| 3325 | - |
|
| 3326 | - foreach ($value as $entry) { |
|
| 3327 | - null === $entry || static::alnum($entry, $message); |
|
| 3328 | - } |
|
| 3329 | - } |
|
| 3330 | - |
|
| 3331 | - /** |
|
| 3332 | - * @psalm-pure |
|
| 3333 | - * @psalm-assert lowercase-string|null $value |
|
| 3334 | - * |
|
| 3335 | - * @param string|null $value |
|
| 3336 | - * @param string $message |
|
| 3337 | - * |
|
| 3338 | - * @throws InvalidArgumentException |
|
| 3339 | - * |
|
| 3340 | - * @return void |
|
| 3341 | - */ |
|
| 3342 | - public static function nullOrLower($value, $message = '') |
|
| 3343 | - { |
|
| 3344 | - null === $value || static::lower($value, $message); |
|
| 3345 | - } |
|
| 3346 | - |
|
| 3347 | - /** |
|
| 3348 | - * @psalm-pure |
|
| 3349 | - * @psalm-assert iterable<lowercase-string> $value |
|
| 3350 | - * |
|
| 3351 | - * @param iterable<string> $value |
|
| 3352 | - * @param string $message |
|
| 3353 | - * |
|
| 3354 | - * @throws InvalidArgumentException |
|
| 3355 | - * |
|
| 3356 | - * @return void |
|
| 3357 | - */ |
|
| 3358 | - public static function allLower($value, $message = '') |
|
| 3359 | - { |
|
| 3360 | - static::isIterable($value); |
|
| 3361 | - |
|
| 3362 | - foreach ($value as $entry) { |
|
| 3363 | - static::lower($entry, $message); |
|
| 3364 | - } |
|
| 3365 | - } |
|
| 3366 | - |
|
| 3367 | - /** |
|
| 3368 | - * @psalm-pure |
|
| 3369 | - * @psalm-assert iterable<lowercase-string|null> $value |
|
| 3370 | - * |
|
| 3371 | - * @param iterable<string|null> $value |
|
| 3372 | - * @param string $message |
|
| 3373 | - * |
|
| 3374 | - * @throws InvalidArgumentException |
|
| 3375 | - * |
|
| 3376 | - * @return void |
|
| 3377 | - */ |
|
| 3378 | - public static function allNullOrLower($value, $message = '') |
|
| 3379 | - { |
|
| 3380 | - static::isIterable($value); |
|
| 3381 | - |
|
| 3382 | - foreach ($value as $entry) { |
|
| 3383 | - null === $entry || static::lower($entry, $message); |
|
| 3384 | - } |
|
| 3385 | - } |
|
| 3386 | - |
|
| 3387 | - /** |
|
| 3388 | - * @psalm-pure |
|
| 3389 | - * |
|
| 3390 | - * @param string|null $value |
|
| 3391 | - * @param string $message |
|
| 3392 | - * |
|
| 3393 | - * @throws InvalidArgumentException |
|
| 3394 | - * |
|
| 3395 | - * @return void |
|
| 3396 | - */ |
|
| 3397 | - public static function nullOrUpper($value, $message = '') |
|
| 3398 | - { |
|
| 3399 | - null === $value || static::upper($value, $message); |
|
| 3400 | - } |
|
| 3401 | - |
|
| 3402 | - /** |
|
| 3403 | - * @psalm-pure |
|
| 3404 | - * |
|
| 3405 | - * @param iterable<string> $value |
|
| 3406 | - * @param string $message |
|
| 3407 | - * |
|
| 3408 | - * @throws InvalidArgumentException |
|
| 3409 | - * |
|
| 3410 | - * @return void |
|
| 3411 | - */ |
|
| 3412 | - public static function allUpper($value, $message = '') |
|
| 3413 | - { |
|
| 3414 | - static::isIterable($value); |
|
| 3415 | - |
|
| 3416 | - foreach ($value as $entry) { |
|
| 3417 | - static::upper($entry, $message); |
|
| 3418 | - } |
|
| 3419 | - } |
|
| 3420 | - |
|
| 3421 | - /** |
|
| 3422 | - * @psalm-pure |
|
| 3423 | - * @psalm-assert iterable<!lowercase-string|null> $value |
|
| 3424 | - * |
|
| 3425 | - * @param iterable<string|null> $value |
|
| 3426 | - * @param string $message |
|
| 3427 | - * |
|
| 3428 | - * @throws InvalidArgumentException |
|
| 3429 | - * |
|
| 3430 | - * @return void |
|
| 3431 | - */ |
|
| 3432 | - public static function allNullOrUpper($value, $message = '') |
|
| 3433 | - { |
|
| 3434 | - static::isIterable($value); |
|
| 3435 | - |
|
| 3436 | - foreach ($value as $entry) { |
|
| 3437 | - null === $entry || static::upper($entry, $message); |
|
| 3438 | - } |
|
| 3439 | - } |
|
| 3440 | - |
|
| 3441 | - /** |
|
| 3442 | - * @psalm-pure |
|
| 3443 | - * |
|
| 3444 | - * @param string|null $value |
|
| 3445 | - * @param int $length |
|
| 3446 | - * @param string $message |
|
| 3447 | - * |
|
| 3448 | - * @throws InvalidArgumentException |
|
| 3449 | - * |
|
| 3450 | - * @return void |
|
| 3451 | - */ |
|
| 3452 | - public static function nullOrLength($value, $length, $message = '') |
|
| 3453 | - { |
|
| 3454 | - null === $value || static::length($value, $length, $message); |
|
| 3455 | - } |
|
| 3456 | - |
|
| 3457 | - /** |
|
| 3458 | - * @psalm-pure |
|
| 3459 | - * |
|
| 3460 | - * @param iterable<string> $value |
|
| 3461 | - * @param int $length |
|
| 3462 | - * @param string $message |
|
| 3463 | - * |
|
| 3464 | - * @throws InvalidArgumentException |
|
| 3465 | - * |
|
| 3466 | - * @return void |
|
| 3467 | - */ |
|
| 3468 | - public static function allLength($value, $length, $message = '') |
|
| 3469 | - { |
|
| 3470 | - static::isIterable($value); |
|
| 3471 | - |
|
| 3472 | - foreach ($value as $entry) { |
|
| 3473 | - static::length($entry, $length, $message); |
|
| 3474 | - } |
|
| 3475 | - } |
|
| 3476 | - |
|
| 3477 | - /** |
|
| 3478 | - * @psalm-pure |
|
| 3479 | - * |
|
| 3480 | - * @param iterable<string|null> $value |
|
| 3481 | - * @param int $length |
|
| 3482 | - * @param string $message |
|
| 3483 | - * |
|
| 3484 | - * @throws InvalidArgumentException |
|
| 3485 | - * |
|
| 3486 | - * @return void |
|
| 3487 | - */ |
|
| 3488 | - public static function allNullOrLength($value, $length, $message = '') |
|
| 3489 | - { |
|
| 3490 | - static::isIterable($value); |
|
| 3491 | - |
|
| 3492 | - foreach ($value as $entry) { |
|
| 3493 | - null === $entry || static::length($entry, $length, $message); |
|
| 3494 | - } |
|
| 3495 | - } |
|
| 3496 | - |
|
| 3497 | - /** |
|
| 3498 | - * @psalm-pure |
|
| 3499 | - * |
|
| 3500 | - * @param string|null $value |
|
| 3501 | - * @param int|float $min |
|
| 3502 | - * @param string $message |
|
| 3503 | - * |
|
| 3504 | - * @throws InvalidArgumentException |
|
| 3505 | - * |
|
| 3506 | - * @return void |
|
| 3507 | - */ |
|
| 3508 | - public static function nullOrMinLength($value, $min, $message = '') |
|
| 3509 | - { |
|
| 3510 | - null === $value || static::minLength($value, $min, $message); |
|
| 3511 | - } |
|
| 3512 | - |
|
| 3513 | - /** |
|
| 3514 | - * @psalm-pure |
|
| 3515 | - * |
|
| 3516 | - * @param iterable<string> $value |
|
| 3517 | - * @param int|float $min |
|
| 3518 | - * @param string $message |
|
| 3519 | - * |
|
| 3520 | - * @throws InvalidArgumentException |
|
| 3521 | - * |
|
| 3522 | - * @return void |
|
| 3523 | - */ |
|
| 3524 | - public static function allMinLength($value, $min, $message = '') |
|
| 3525 | - { |
|
| 3526 | - static::isIterable($value); |
|
| 3527 | - |
|
| 3528 | - foreach ($value as $entry) { |
|
| 3529 | - static::minLength($entry, $min, $message); |
|
| 3530 | - } |
|
| 3531 | - } |
|
| 3532 | - |
|
| 3533 | - /** |
|
| 3534 | - * @psalm-pure |
|
| 3535 | - * |
|
| 3536 | - * @param iterable<string|null> $value |
|
| 3537 | - * @param int|float $min |
|
| 3538 | - * @param string $message |
|
| 3539 | - * |
|
| 3540 | - * @throws InvalidArgumentException |
|
| 3541 | - * |
|
| 3542 | - * @return void |
|
| 3543 | - */ |
|
| 3544 | - public static function allNullOrMinLength($value, $min, $message = '') |
|
| 3545 | - { |
|
| 3546 | - static::isIterable($value); |
|
| 3547 | - |
|
| 3548 | - foreach ($value as $entry) { |
|
| 3549 | - null === $entry || static::minLength($entry, $min, $message); |
|
| 3550 | - } |
|
| 3551 | - } |
|
| 3552 | - |
|
| 3553 | - /** |
|
| 3554 | - * @psalm-pure |
|
| 3555 | - * |
|
| 3556 | - * @param string|null $value |
|
| 3557 | - * @param int|float $max |
|
| 3558 | - * @param string $message |
|
| 3559 | - * |
|
| 3560 | - * @throws InvalidArgumentException |
|
| 3561 | - * |
|
| 3562 | - * @return void |
|
| 3563 | - */ |
|
| 3564 | - public static function nullOrMaxLength($value, $max, $message = '') |
|
| 3565 | - { |
|
| 3566 | - null === $value || static::maxLength($value, $max, $message); |
|
| 3567 | - } |
|
| 3568 | - |
|
| 3569 | - /** |
|
| 3570 | - * @psalm-pure |
|
| 3571 | - * |
|
| 3572 | - * @param iterable<string> $value |
|
| 3573 | - * @param int|float $max |
|
| 3574 | - * @param string $message |
|
| 3575 | - * |
|
| 3576 | - * @throws InvalidArgumentException |
|
| 3577 | - * |
|
| 3578 | - * @return void |
|
| 3579 | - */ |
|
| 3580 | - public static function allMaxLength($value, $max, $message = '') |
|
| 3581 | - { |
|
| 3582 | - static::isIterable($value); |
|
| 3583 | - |
|
| 3584 | - foreach ($value as $entry) { |
|
| 3585 | - static::maxLength($entry, $max, $message); |
|
| 3586 | - } |
|
| 3587 | - } |
|
| 3588 | - |
|
| 3589 | - /** |
|
| 3590 | - * @psalm-pure |
|
| 3591 | - * |
|
| 3592 | - * @param iterable<string|null> $value |
|
| 3593 | - * @param int|float $max |
|
| 3594 | - * @param string $message |
|
| 3595 | - * |
|
| 3596 | - * @throws InvalidArgumentException |
|
| 3597 | - * |
|
| 3598 | - * @return void |
|
| 3599 | - */ |
|
| 3600 | - public static function allNullOrMaxLength($value, $max, $message = '') |
|
| 3601 | - { |
|
| 3602 | - static::isIterable($value); |
|
| 3603 | - |
|
| 3604 | - foreach ($value as $entry) { |
|
| 3605 | - null === $entry || static::maxLength($entry, $max, $message); |
|
| 3606 | - } |
|
| 3607 | - } |
|
| 3608 | - |
|
| 3609 | - /** |
|
| 3610 | - * @psalm-pure |
|
| 3611 | - * |
|
| 3612 | - * @param string|null $value |
|
| 3613 | - * @param int|float $min |
|
| 3614 | - * @param int|float $max |
|
| 3615 | - * @param string $message |
|
| 3616 | - * |
|
| 3617 | - * @throws InvalidArgumentException |
|
| 3618 | - * |
|
| 3619 | - * @return void |
|
| 3620 | - */ |
|
| 3621 | - public static function nullOrLengthBetween($value, $min, $max, $message = '') |
|
| 3622 | - { |
|
| 3623 | - null === $value || static::lengthBetween($value, $min, $max, $message); |
|
| 3624 | - } |
|
| 3625 | - |
|
| 3626 | - /** |
|
| 3627 | - * @psalm-pure |
|
| 3628 | - * |
|
| 3629 | - * @param iterable<string> $value |
|
| 3630 | - * @param int|float $min |
|
| 3631 | - * @param int|float $max |
|
| 3632 | - * @param string $message |
|
| 3633 | - * |
|
| 3634 | - * @throws InvalidArgumentException |
|
| 3635 | - * |
|
| 3636 | - * @return void |
|
| 3637 | - */ |
|
| 3638 | - public static function allLengthBetween($value, $min, $max, $message = '') |
|
| 3639 | - { |
|
| 3640 | - static::isIterable($value); |
|
| 3641 | - |
|
| 3642 | - foreach ($value as $entry) { |
|
| 3643 | - static::lengthBetween($entry, $min, $max, $message); |
|
| 3644 | - } |
|
| 3645 | - } |
|
| 3646 | - |
|
| 3647 | - /** |
|
| 3648 | - * @psalm-pure |
|
| 3649 | - * |
|
| 3650 | - * @param iterable<string|null> $value |
|
| 3651 | - * @param int|float $min |
|
| 3652 | - * @param int|float $max |
|
| 3653 | - * @param string $message |
|
| 3654 | - * |
|
| 3655 | - * @throws InvalidArgumentException |
|
| 3656 | - * |
|
| 3657 | - * @return void |
|
| 3658 | - */ |
|
| 3659 | - public static function allNullOrLengthBetween($value, $min, $max, $message = '') |
|
| 3660 | - { |
|
| 3661 | - static::isIterable($value); |
|
| 3662 | - |
|
| 3663 | - foreach ($value as $entry) { |
|
| 3664 | - null === $entry || static::lengthBetween($entry, $min, $max, $message); |
|
| 3665 | - } |
|
| 3666 | - } |
|
| 3667 | - |
|
| 3668 | - /** |
|
| 3669 | - * @param mixed $value |
|
| 3670 | - * @param string $message |
|
| 3671 | - * |
|
| 3672 | - * @throws InvalidArgumentException |
|
| 3673 | - * |
|
| 3674 | - * @return void |
|
| 3675 | - */ |
|
| 3676 | - public static function nullOrFileExists($value, $message = '') |
|
| 3677 | - { |
|
| 3678 | - null === $value || static::fileExists($value, $message); |
|
| 3679 | - } |
|
| 3680 | - |
|
| 3681 | - /** |
|
| 3682 | - * @param mixed $value |
|
| 3683 | - * @param string $message |
|
| 3684 | - * |
|
| 3685 | - * @throws InvalidArgumentException |
|
| 3686 | - * |
|
| 3687 | - * @return void |
|
| 3688 | - */ |
|
| 3689 | - public static function allFileExists($value, $message = '') |
|
| 3690 | - { |
|
| 3691 | - static::isIterable($value); |
|
| 3692 | - |
|
| 3693 | - foreach ($value as $entry) { |
|
| 3694 | - static::fileExists($entry, $message); |
|
| 3695 | - } |
|
| 3696 | - } |
|
| 3697 | - |
|
| 3698 | - /** |
|
| 3699 | - * @param mixed $value |
|
| 3700 | - * @param string $message |
|
| 3701 | - * |
|
| 3702 | - * @throws InvalidArgumentException |
|
| 3703 | - * |
|
| 3704 | - * @return void |
|
| 3705 | - */ |
|
| 3706 | - public static function allNullOrFileExists($value, $message = '') |
|
| 3707 | - { |
|
| 3708 | - static::isIterable($value); |
|
| 3709 | - |
|
| 3710 | - foreach ($value as $entry) { |
|
| 3711 | - null === $entry || static::fileExists($entry, $message); |
|
| 3712 | - } |
|
| 3713 | - } |
|
| 3714 | - |
|
| 3715 | - /** |
|
| 3716 | - * @param mixed $value |
|
| 3717 | - * @param string $message |
|
| 3718 | - * |
|
| 3719 | - * @throws InvalidArgumentException |
|
| 3720 | - * |
|
| 3721 | - * @return void |
|
| 3722 | - */ |
|
| 3723 | - public static function nullOrFile($value, $message = '') |
|
| 3724 | - { |
|
| 3725 | - null === $value || static::file($value, $message); |
|
| 3726 | - } |
|
| 3727 | - |
|
| 3728 | - /** |
|
| 3729 | - * @param mixed $value |
|
| 3730 | - * @param string $message |
|
| 3731 | - * |
|
| 3732 | - * @throws InvalidArgumentException |
|
| 3733 | - * |
|
| 3734 | - * @return void |
|
| 3735 | - */ |
|
| 3736 | - public static function allFile($value, $message = '') |
|
| 3737 | - { |
|
| 3738 | - static::isIterable($value); |
|
| 3739 | - |
|
| 3740 | - foreach ($value as $entry) { |
|
| 3741 | - static::file($entry, $message); |
|
| 3742 | - } |
|
| 3743 | - } |
|
| 3744 | - |
|
| 3745 | - /** |
|
| 3746 | - * @param mixed $value |
|
| 3747 | - * @param string $message |
|
| 3748 | - * |
|
| 3749 | - * @throws InvalidArgumentException |
|
| 3750 | - * |
|
| 3751 | - * @return void |
|
| 3752 | - */ |
|
| 3753 | - public static function allNullOrFile($value, $message = '') |
|
| 3754 | - { |
|
| 3755 | - static::isIterable($value); |
|
| 3756 | - |
|
| 3757 | - foreach ($value as $entry) { |
|
| 3758 | - null === $entry || static::file($entry, $message); |
|
| 3759 | - } |
|
| 3760 | - } |
|
| 3761 | - |
|
| 3762 | - /** |
|
| 3763 | - * @param mixed $value |
|
| 3764 | - * @param string $message |
|
| 3765 | - * |
|
| 3766 | - * @throws InvalidArgumentException |
|
| 3767 | - * |
|
| 3768 | - * @return void |
|
| 3769 | - */ |
|
| 3770 | - public static function nullOrDirectory($value, $message = '') |
|
| 3771 | - { |
|
| 3772 | - null === $value || static::directory($value, $message); |
|
| 3773 | - } |
|
| 3774 | - |
|
| 3775 | - /** |
|
| 3776 | - * @param mixed $value |
|
| 3777 | - * @param string $message |
|
| 3778 | - * |
|
| 3779 | - * @throws InvalidArgumentException |
|
| 3780 | - * |
|
| 3781 | - * @return void |
|
| 3782 | - */ |
|
| 3783 | - public static function allDirectory($value, $message = '') |
|
| 3784 | - { |
|
| 3785 | - static::isIterable($value); |
|
| 3786 | - |
|
| 3787 | - foreach ($value as $entry) { |
|
| 3788 | - static::directory($entry, $message); |
|
| 3789 | - } |
|
| 3790 | - } |
|
| 3791 | - |
|
| 3792 | - /** |
|
| 3793 | - * @param mixed $value |
|
| 3794 | - * @param string $message |
|
| 3795 | - * |
|
| 3796 | - * @throws InvalidArgumentException |
|
| 3797 | - * |
|
| 3798 | - * @return void |
|
| 3799 | - */ |
|
| 3800 | - public static function allNullOrDirectory($value, $message = '') |
|
| 3801 | - { |
|
| 3802 | - static::isIterable($value); |
|
| 3803 | - |
|
| 3804 | - foreach ($value as $entry) { |
|
| 3805 | - null === $entry || static::directory($entry, $message); |
|
| 3806 | - } |
|
| 3807 | - } |
|
| 3808 | - |
|
| 3809 | - /** |
|
| 3810 | - * @param string|null $value |
|
| 3811 | - * @param string $message |
|
| 3812 | - * |
|
| 3813 | - * @throws InvalidArgumentException |
|
| 3814 | - * |
|
| 3815 | - * @return void |
|
| 3816 | - */ |
|
| 3817 | - public static function nullOrReadable($value, $message = '') |
|
| 3818 | - { |
|
| 3819 | - null === $value || static::readable($value, $message); |
|
| 3820 | - } |
|
| 3821 | - |
|
| 3822 | - /** |
|
| 3823 | - * @param iterable<string> $value |
|
| 3824 | - * @param string $message |
|
| 3825 | - * |
|
| 3826 | - * @throws InvalidArgumentException |
|
| 3827 | - * |
|
| 3828 | - * @return void |
|
| 3829 | - */ |
|
| 3830 | - public static function allReadable($value, $message = '') |
|
| 3831 | - { |
|
| 3832 | - static::isIterable($value); |
|
| 3833 | - |
|
| 3834 | - foreach ($value as $entry) { |
|
| 3835 | - static::readable($entry, $message); |
|
| 3836 | - } |
|
| 3837 | - } |
|
| 3838 | - |
|
| 3839 | - /** |
|
| 3840 | - * @param iterable<string|null> $value |
|
| 3841 | - * @param string $message |
|
| 3842 | - * |
|
| 3843 | - * @throws InvalidArgumentException |
|
| 3844 | - * |
|
| 3845 | - * @return void |
|
| 3846 | - */ |
|
| 3847 | - public static function allNullOrReadable($value, $message = '') |
|
| 3848 | - { |
|
| 3849 | - static::isIterable($value); |
|
| 3850 | - |
|
| 3851 | - foreach ($value as $entry) { |
|
| 3852 | - null === $entry || static::readable($entry, $message); |
|
| 3853 | - } |
|
| 3854 | - } |
|
| 3855 | - |
|
| 3856 | - /** |
|
| 3857 | - * @param string|null $value |
|
| 3858 | - * @param string $message |
|
| 3859 | - * |
|
| 3860 | - * @throws InvalidArgumentException |
|
| 3861 | - * |
|
| 3862 | - * @return void |
|
| 3863 | - */ |
|
| 3864 | - public static function nullOrWritable($value, $message = '') |
|
| 3865 | - { |
|
| 3866 | - null === $value || static::writable($value, $message); |
|
| 3867 | - } |
|
| 3868 | - |
|
| 3869 | - /** |
|
| 3870 | - * @param iterable<string> $value |
|
| 3871 | - * @param string $message |
|
| 3872 | - * |
|
| 3873 | - * @throws InvalidArgumentException |
|
| 3874 | - * |
|
| 3875 | - * @return void |
|
| 3876 | - */ |
|
| 3877 | - public static function allWritable($value, $message = '') |
|
| 3878 | - { |
|
| 3879 | - static::isIterable($value); |
|
| 3880 | - |
|
| 3881 | - foreach ($value as $entry) { |
|
| 3882 | - static::writable($entry, $message); |
|
| 3883 | - } |
|
| 3884 | - } |
|
| 3885 | - |
|
| 3886 | - /** |
|
| 3887 | - * @param iterable<string|null> $value |
|
| 3888 | - * @param string $message |
|
| 3889 | - * |
|
| 3890 | - * @throws InvalidArgumentException |
|
| 3891 | - * |
|
| 3892 | - * @return void |
|
| 3893 | - */ |
|
| 3894 | - public static function allNullOrWritable($value, $message = '') |
|
| 3895 | - { |
|
| 3896 | - static::isIterable($value); |
|
| 3897 | - |
|
| 3898 | - foreach ($value as $entry) { |
|
| 3899 | - null === $entry || static::writable($entry, $message); |
|
| 3900 | - } |
|
| 3901 | - } |
|
| 3902 | - |
|
| 3903 | - /** |
|
| 3904 | - * @psalm-assert class-string|null $value |
|
| 3905 | - * |
|
| 3906 | - * @param mixed $value |
|
| 3907 | - * @param string $message |
|
| 3908 | - * |
|
| 3909 | - * @throws InvalidArgumentException |
|
| 3910 | - * |
|
| 3911 | - * @return void |
|
| 3912 | - */ |
|
| 3913 | - public static function nullOrClassExists($value, $message = '') |
|
| 3914 | - { |
|
| 3915 | - null === $value || static::classExists($value, $message); |
|
| 3916 | - } |
|
| 3917 | - |
|
| 3918 | - /** |
|
| 3919 | - * @psalm-assert iterable<class-string> $value |
|
| 3920 | - * |
|
| 3921 | - * @param mixed $value |
|
| 3922 | - * @param string $message |
|
| 3923 | - * |
|
| 3924 | - * @throws InvalidArgumentException |
|
| 3925 | - * |
|
| 3926 | - * @return void |
|
| 3927 | - */ |
|
| 3928 | - public static function allClassExists($value, $message = '') |
|
| 3929 | - { |
|
| 3930 | - static::isIterable($value); |
|
| 3931 | - |
|
| 3932 | - foreach ($value as $entry) { |
|
| 3933 | - static::classExists($entry, $message); |
|
| 3934 | - } |
|
| 3935 | - } |
|
| 3936 | - |
|
| 3937 | - /** |
|
| 3938 | - * @psalm-assert iterable<class-string|null> $value |
|
| 3939 | - * |
|
| 3940 | - * @param mixed $value |
|
| 3941 | - * @param string $message |
|
| 3942 | - * |
|
| 3943 | - * @throws InvalidArgumentException |
|
| 3944 | - * |
|
| 3945 | - * @return void |
|
| 3946 | - */ |
|
| 3947 | - public static function allNullOrClassExists($value, $message = '') |
|
| 3948 | - { |
|
| 3949 | - static::isIterable($value); |
|
| 3950 | - |
|
| 3951 | - foreach ($value as $entry) { |
|
| 3952 | - null === $entry || static::classExists($entry, $message); |
|
| 3953 | - } |
|
| 3954 | - } |
|
| 3955 | - |
|
| 3956 | - /** |
|
| 3957 | - * @psalm-pure |
|
| 3958 | - * @psalm-template ExpectedType of object |
|
| 3959 | - * @psalm-param class-string<ExpectedType> $class |
|
| 3960 | - * @psalm-assert class-string<ExpectedType>|ExpectedType|null $value |
|
| 3961 | - * |
|
| 3962 | - * @param mixed $value |
|
| 3963 | - * @param string|object $class |
|
| 3964 | - * @param string $message |
|
| 3965 | - * |
|
| 3966 | - * @throws InvalidArgumentException |
|
| 3967 | - * |
|
| 3968 | - * @return void |
|
| 3969 | - */ |
|
| 3970 | - public static function nullOrSubclassOf($value, $class, $message = '') |
|
| 3971 | - { |
|
| 3972 | - null === $value || static::subclassOf($value, $class, $message); |
|
| 3973 | - } |
|
| 3974 | - |
|
| 3975 | - /** |
|
| 3976 | - * @psalm-pure |
|
| 3977 | - * @psalm-template ExpectedType of object |
|
| 3978 | - * @psalm-param class-string<ExpectedType> $class |
|
| 3979 | - * @psalm-assert iterable<class-string<ExpectedType>|ExpectedType> $value |
|
| 3980 | - * |
|
| 3981 | - * @param mixed $value |
|
| 3982 | - * @param string|object $class |
|
| 3983 | - * @param string $message |
|
| 3984 | - * |
|
| 3985 | - * @throws InvalidArgumentException |
|
| 3986 | - * |
|
| 3987 | - * @return void |
|
| 3988 | - */ |
|
| 3989 | - public static function allSubclassOf($value, $class, $message = '') |
|
| 3990 | - { |
|
| 3991 | - static::isIterable($value); |
|
| 3992 | - |
|
| 3993 | - foreach ($value as $entry) { |
|
| 3994 | - static::subclassOf($entry, $class, $message); |
|
| 3995 | - } |
|
| 3996 | - } |
|
| 3997 | - |
|
| 3998 | - /** |
|
| 3999 | - * @psalm-pure |
|
| 4000 | - * @psalm-template ExpectedType of object |
|
| 4001 | - * @psalm-param class-string<ExpectedType> $class |
|
| 4002 | - * @psalm-assert iterable<class-string<ExpectedType>|ExpectedType|null> $value |
|
| 4003 | - * |
|
| 4004 | - * @param mixed $value |
|
| 4005 | - * @param string|object $class |
|
| 4006 | - * @param string $message |
|
| 4007 | - * |
|
| 4008 | - * @throws InvalidArgumentException |
|
| 4009 | - * |
|
| 4010 | - * @return void |
|
| 4011 | - */ |
|
| 4012 | - public static function allNullOrSubclassOf($value, $class, $message = '') |
|
| 4013 | - { |
|
| 4014 | - static::isIterable($value); |
|
| 4015 | - |
|
| 4016 | - foreach ($value as $entry) { |
|
| 4017 | - null === $entry || static::subclassOf($entry, $class, $message); |
|
| 4018 | - } |
|
| 4019 | - } |
|
| 4020 | - |
|
| 4021 | - /** |
|
| 4022 | - * @psalm-assert class-string|null $value |
|
| 4023 | - * |
|
| 4024 | - * @param mixed $value |
|
| 4025 | - * @param string $message |
|
| 4026 | - * |
|
| 4027 | - * @throws InvalidArgumentException |
|
| 4028 | - * |
|
| 4029 | - * @return void |
|
| 4030 | - */ |
|
| 4031 | - public static function nullOrInterfaceExists($value, $message = '') |
|
| 4032 | - { |
|
| 4033 | - null === $value || static::interfaceExists($value, $message); |
|
| 4034 | - } |
|
| 4035 | - |
|
| 4036 | - /** |
|
| 4037 | - * @psalm-assert iterable<class-string> $value |
|
| 4038 | - * |
|
| 4039 | - * @param mixed $value |
|
| 4040 | - * @param string $message |
|
| 4041 | - * |
|
| 4042 | - * @throws InvalidArgumentException |
|
| 4043 | - * |
|
| 4044 | - * @return void |
|
| 4045 | - */ |
|
| 4046 | - public static function allInterfaceExists($value, $message = '') |
|
| 4047 | - { |
|
| 4048 | - static::isIterable($value); |
|
| 4049 | - |
|
| 4050 | - foreach ($value as $entry) { |
|
| 4051 | - static::interfaceExists($entry, $message); |
|
| 4052 | - } |
|
| 4053 | - } |
|
| 4054 | - |
|
| 4055 | - /** |
|
| 4056 | - * @psalm-assert iterable<class-string|null> $value |
|
| 4057 | - * |
|
| 4058 | - * @param mixed $value |
|
| 4059 | - * @param string $message |
|
| 4060 | - * |
|
| 4061 | - * @throws InvalidArgumentException |
|
| 4062 | - * |
|
| 4063 | - * @return void |
|
| 4064 | - */ |
|
| 4065 | - public static function allNullOrInterfaceExists($value, $message = '') |
|
| 4066 | - { |
|
| 4067 | - static::isIterable($value); |
|
| 4068 | - |
|
| 4069 | - foreach ($value as $entry) { |
|
| 4070 | - null === $entry || static::interfaceExists($entry, $message); |
|
| 4071 | - } |
|
| 4072 | - } |
|
| 4073 | - |
|
| 4074 | - /** |
|
| 4075 | - * @psalm-pure |
|
| 4076 | - * @psalm-template ExpectedType of object |
|
| 4077 | - * @psalm-param class-string<ExpectedType> $interface |
|
| 4078 | - * @psalm-assert class-string<ExpectedType>|null $value |
|
| 4079 | - * |
|
| 4080 | - * @param mixed $value |
|
| 4081 | - * @param mixed $interface |
|
| 4082 | - * @param string $message |
|
| 4083 | - * |
|
| 4084 | - * @throws InvalidArgumentException |
|
| 4085 | - * |
|
| 4086 | - * @return void |
|
| 4087 | - */ |
|
| 4088 | - public static function nullOrImplementsInterface($value, $interface, $message = '') |
|
| 4089 | - { |
|
| 4090 | - null === $value || static::implementsInterface($value, $interface, $message); |
|
| 4091 | - } |
|
| 4092 | - |
|
| 4093 | - /** |
|
| 4094 | - * @psalm-pure |
|
| 4095 | - * @psalm-template ExpectedType of object |
|
| 4096 | - * @psalm-param class-string<ExpectedType> $interface |
|
| 4097 | - * @psalm-assert iterable<class-string<ExpectedType>> $value |
|
| 4098 | - * |
|
| 4099 | - * @param mixed $value |
|
| 4100 | - * @param mixed $interface |
|
| 4101 | - * @param string $message |
|
| 4102 | - * |
|
| 4103 | - * @throws InvalidArgumentException |
|
| 4104 | - * |
|
| 4105 | - * @return void |
|
| 4106 | - */ |
|
| 4107 | - public static function allImplementsInterface($value, $interface, $message = '') |
|
| 4108 | - { |
|
| 4109 | - static::isIterable($value); |
|
| 4110 | - |
|
| 4111 | - foreach ($value as $entry) { |
|
| 4112 | - static::implementsInterface($entry, $interface, $message); |
|
| 4113 | - } |
|
| 4114 | - } |
|
| 4115 | - |
|
| 4116 | - /** |
|
| 4117 | - * @psalm-pure |
|
| 4118 | - * @psalm-template ExpectedType of object |
|
| 4119 | - * @psalm-param class-string<ExpectedType> $interface |
|
| 4120 | - * @psalm-assert iterable<class-string<ExpectedType>|null> $value |
|
| 4121 | - * |
|
| 4122 | - * @param mixed $value |
|
| 4123 | - * @param mixed $interface |
|
| 4124 | - * @param string $message |
|
| 4125 | - * |
|
| 4126 | - * @throws InvalidArgumentException |
|
| 4127 | - * |
|
| 4128 | - * @return void |
|
| 4129 | - */ |
|
| 4130 | - public static function allNullOrImplementsInterface($value, $interface, $message = '') |
|
| 4131 | - { |
|
| 4132 | - static::isIterable($value); |
|
| 4133 | - |
|
| 4134 | - foreach ($value as $entry) { |
|
| 4135 | - null === $entry || static::implementsInterface($entry, $interface, $message); |
|
| 4136 | - } |
|
| 4137 | - } |
|
| 4138 | - |
|
| 4139 | - /** |
|
| 4140 | - * @psalm-pure |
|
| 4141 | - * @psalm-param class-string|object|null $classOrObject |
|
| 4142 | - * |
|
| 4143 | - * @param string|object|null $classOrObject |
|
| 4144 | - * @param mixed $property |
|
| 4145 | - * @param string $message |
|
| 4146 | - * |
|
| 4147 | - * @throws InvalidArgumentException |
|
| 4148 | - * |
|
| 4149 | - * @return void |
|
| 4150 | - */ |
|
| 4151 | - public static function nullOrPropertyExists($classOrObject, $property, $message = '') |
|
| 4152 | - { |
|
| 4153 | - null === $classOrObject || static::propertyExists($classOrObject, $property, $message); |
|
| 4154 | - } |
|
| 4155 | - |
|
| 4156 | - /** |
|
| 4157 | - * @psalm-pure |
|
| 4158 | - * @psalm-param iterable<class-string|object> $classOrObject |
|
| 4159 | - * |
|
| 4160 | - * @param iterable<string|object> $classOrObject |
|
| 4161 | - * @param mixed $property |
|
| 4162 | - * @param string $message |
|
| 4163 | - * |
|
| 4164 | - * @throws InvalidArgumentException |
|
| 4165 | - * |
|
| 4166 | - * @return void |
|
| 4167 | - */ |
|
| 4168 | - public static function allPropertyExists($classOrObject, $property, $message = '') |
|
| 4169 | - { |
|
| 4170 | - static::isIterable($classOrObject); |
|
| 4171 | - |
|
| 4172 | - foreach ($classOrObject as $entry) { |
|
| 4173 | - static::propertyExists($entry, $property, $message); |
|
| 4174 | - } |
|
| 4175 | - } |
|
| 4176 | - |
|
| 4177 | - /** |
|
| 4178 | - * @psalm-pure |
|
| 4179 | - * @psalm-param iterable<class-string|object|null> $classOrObject |
|
| 4180 | - * |
|
| 4181 | - * @param iterable<string|object|null> $classOrObject |
|
| 4182 | - * @param mixed $property |
|
| 4183 | - * @param string $message |
|
| 4184 | - * |
|
| 4185 | - * @throws InvalidArgumentException |
|
| 4186 | - * |
|
| 4187 | - * @return void |
|
| 4188 | - */ |
|
| 4189 | - public static function allNullOrPropertyExists($classOrObject, $property, $message = '') |
|
| 4190 | - { |
|
| 4191 | - static::isIterable($classOrObject); |
|
| 4192 | - |
|
| 4193 | - foreach ($classOrObject as $entry) { |
|
| 4194 | - null === $entry || static::propertyExists($entry, $property, $message); |
|
| 4195 | - } |
|
| 4196 | - } |
|
| 4197 | - |
|
| 4198 | - /** |
|
| 4199 | - * @psalm-pure |
|
| 4200 | - * @psalm-param class-string|object|null $classOrObject |
|
| 4201 | - * |
|
| 4202 | - * @param string|object|null $classOrObject |
|
| 4203 | - * @param mixed $property |
|
| 4204 | - * @param string $message |
|
| 4205 | - * |
|
| 4206 | - * @throws InvalidArgumentException |
|
| 4207 | - * |
|
| 4208 | - * @return void |
|
| 4209 | - */ |
|
| 4210 | - public static function nullOrPropertyNotExists($classOrObject, $property, $message = '') |
|
| 4211 | - { |
|
| 4212 | - null === $classOrObject || static::propertyNotExists($classOrObject, $property, $message); |
|
| 4213 | - } |
|
| 4214 | - |
|
| 4215 | - /** |
|
| 4216 | - * @psalm-pure |
|
| 4217 | - * @psalm-param iterable<class-string|object> $classOrObject |
|
| 4218 | - * |
|
| 4219 | - * @param iterable<string|object> $classOrObject |
|
| 4220 | - * @param mixed $property |
|
| 4221 | - * @param string $message |
|
| 4222 | - * |
|
| 4223 | - * @throws InvalidArgumentException |
|
| 4224 | - * |
|
| 4225 | - * @return void |
|
| 4226 | - */ |
|
| 4227 | - public static function allPropertyNotExists($classOrObject, $property, $message = '') |
|
| 4228 | - { |
|
| 4229 | - static::isIterable($classOrObject); |
|
| 4230 | - |
|
| 4231 | - foreach ($classOrObject as $entry) { |
|
| 4232 | - static::propertyNotExists($entry, $property, $message); |
|
| 4233 | - } |
|
| 4234 | - } |
|
| 4235 | - |
|
| 4236 | - /** |
|
| 4237 | - * @psalm-pure |
|
| 4238 | - * @psalm-param iterable<class-string|object|null> $classOrObject |
|
| 4239 | - * |
|
| 4240 | - * @param iterable<string|object|null> $classOrObject |
|
| 4241 | - * @param mixed $property |
|
| 4242 | - * @param string $message |
|
| 4243 | - * |
|
| 4244 | - * @throws InvalidArgumentException |
|
| 4245 | - * |
|
| 4246 | - * @return void |
|
| 4247 | - */ |
|
| 4248 | - public static function allNullOrPropertyNotExists($classOrObject, $property, $message = '') |
|
| 4249 | - { |
|
| 4250 | - static::isIterable($classOrObject); |
|
| 4251 | - |
|
| 4252 | - foreach ($classOrObject as $entry) { |
|
| 4253 | - null === $entry || static::propertyNotExists($entry, $property, $message); |
|
| 4254 | - } |
|
| 4255 | - } |
|
| 4256 | - |
|
| 4257 | - /** |
|
| 4258 | - * @psalm-pure |
|
| 4259 | - * @psalm-param class-string|object|null $classOrObject |
|
| 4260 | - * |
|
| 4261 | - * @param string|object|null $classOrObject |
|
| 4262 | - * @param mixed $method |
|
| 4263 | - * @param string $message |
|
| 4264 | - * |
|
| 4265 | - * @throws InvalidArgumentException |
|
| 4266 | - * |
|
| 4267 | - * @return void |
|
| 4268 | - */ |
|
| 4269 | - public static function nullOrMethodExists($classOrObject, $method, $message = '') |
|
| 4270 | - { |
|
| 4271 | - null === $classOrObject || static::methodExists($classOrObject, $method, $message); |
|
| 4272 | - } |
|
| 4273 | - |
|
| 4274 | - /** |
|
| 4275 | - * @psalm-pure |
|
| 4276 | - * @psalm-param iterable<class-string|object> $classOrObject |
|
| 4277 | - * |
|
| 4278 | - * @param iterable<string|object> $classOrObject |
|
| 4279 | - * @param mixed $method |
|
| 4280 | - * @param string $message |
|
| 4281 | - * |
|
| 4282 | - * @throws InvalidArgumentException |
|
| 4283 | - * |
|
| 4284 | - * @return void |
|
| 4285 | - */ |
|
| 4286 | - public static function allMethodExists($classOrObject, $method, $message = '') |
|
| 4287 | - { |
|
| 4288 | - static::isIterable($classOrObject); |
|
| 4289 | - |
|
| 4290 | - foreach ($classOrObject as $entry) { |
|
| 4291 | - static::methodExists($entry, $method, $message); |
|
| 4292 | - } |
|
| 4293 | - } |
|
| 4294 | - |
|
| 4295 | - /** |
|
| 4296 | - * @psalm-pure |
|
| 4297 | - * @psalm-param iterable<class-string|object|null> $classOrObject |
|
| 4298 | - * |
|
| 4299 | - * @param iterable<string|object|null> $classOrObject |
|
| 4300 | - * @param mixed $method |
|
| 4301 | - * @param string $message |
|
| 4302 | - * |
|
| 4303 | - * @throws InvalidArgumentException |
|
| 4304 | - * |
|
| 4305 | - * @return void |
|
| 4306 | - */ |
|
| 4307 | - public static function allNullOrMethodExists($classOrObject, $method, $message = '') |
|
| 4308 | - { |
|
| 4309 | - static::isIterable($classOrObject); |
|
| 4310 | - |
|
| 4311 | - foreach ($classOrObject as $entry) { |
|
| 4312 | - null === $entry || static::methodExists($entry, $method, $message); |
|
| 4313 | - } |
|
| 4314 | - } |
|
| 4315 | - |
|
| 4316 | - /** |
|
| 4317 | - * @psalm-pure |
|
| 4318 | - * @psalm-param class-string|object|null $classOrObject |
|
| 4319 | - * |
|
| 4320 | - * @param string|object|null $classOrObject |
|
| 4321 | - * @param mixed $method |
|
| 4322 | - * @param string $message |
|
| 4323 | - * |
|
| 4324 | - * @throws InvalidArgumentException |
|
| 4325 | - * |
|
| 4326 | - * @return void |
|
| 4327 | - */ |
|
| 4328 | - public static function nullOrMethodNotExists($classOrObject, $method, $message = '') |
|
| 4329 | - { |
|
| 4330 | - null === $classOrObject || static::methodNotExists($classOrObject, $method, $message); |
|
| 4331 | - } |
|
| 4332 | - |
|
| 4333 | - /** |
|
| 4334 | - * @psalm-pure |
|
| 4335 | - * @psalm-param iterable<class-string|object> $classOrObject |
|
| 4336 | - * |
|
| 4337 | - * @param iterable<string|object> $classOrObject |
|
| 4338 | - * @param mixed $method |
|
| 4339 | - * @param string $message |
|
| 4340 | - * |
|
| 4341 | - * @throws InvalidArgumentException |
|
| 4342 | - * |
|
| 4343 | - * @return void |
|
| 4344 | - */ |
|
| 4345 | - public static function allMethodNotExists($classOrObject, $method, $message = '') |
|
| 4346 | - { |
|
| 4347 | - static::isIterable($classOrObject); |
|
| 4348 | - |
|
| 4349 | - foreach ($classOrObject as $entry) { |
|
| 4350 | - static::methodNotExists($entry, $method, $message); |
|
| 4351 | - } |
|
| 4352 | - } |
|
| 4353 | - |
|
| 4354 | - /** |
|
| 4355 | - * @psalm-pure |
|
| 4356 | - * @psalm-param iterable<class-string|object|null> $classOrObject |
|
| 4357 | - * |
|
| 4358 | - * @param iterable<string|object|null> $classOrObject |
|
| 4359 | - * @param mixed $method |
|
| 4360 | - * @param string $message |
|
| 4361 | - * |
|
| 4362 | - * @throws InvalidArgumentException |
|
| 4363 | - * |
|
| 4364 | - * @return void |
|
| 4365 | - */ |
|
| 4366 | - public static function allNullOrMethodNotExists($classOrObject, $method, $message = '') |
|
| 4367 | - { |
|
| 4368 | - static::isIterable($classOrObject); |
|
| 4369 | - |
|
| 4370 | - foreach ($classOrObject as $entry) { |
|
| 4371 | - null === $entry || static::methodNotExists($entry, $method, $message); |
|
| 4372 | - } |
|
| 4373 | - } |
|
| 4374 | - |
|
| 4375 | - /** |
|
| 4376 | - * @psalm-pure |
|
| 4377 | - * |
|
| 4378 | - * @param array|null $array |
|
| 4379 | - * @param string|int $key |
|
| 4380 | - * @param string $message |
|
| 4381 | - * |
|
| 4382 | - * @throws InvalidArgumentException |
|
| 4383 | - * |
|
| 4384 | - * @return void |
|
| 4385 | - */ |
|
| 4386 | - public static function nullOrKeyExists($array, $key, $message = '') |
|
| 4387 | - { |
|
| 4388 | - null === $array || static::keyExists($array, $key, $message); |
|
| 4389 | - } |
|
| 4390 | - |
|
| 4391 | - /** |
|
| 4392 | - * @psalm-pure |
|
| 4393 | - * |
|
| 4394 | - * @param iterable<array> $array |
|
| 4395 | - * @param string|int $key |
|
| 4396 | - * @param string $message |
|
| 4397 | - * |
|
| 4398 | - * @throws InvalidArgumentException |
|
| 4399 | - * |
|
| 4400 | - * @return void |
|
| 4401 | - */ |
|
| 4402 | - public static function allKeyExists($array, $key, $message = '') |
|
| 4403 | - { |
|
| 4404 | - static::isIterable($array); |
|
| 4405 | - |
|
| 4406 | - foreach ($array as $entry) { |
|
| 4407 | - static::keyExists($entry, $key, $message); |
|
| 4408 | - } |
|
| 4409 | - } |
|
| 4410 | - |
|
| 4411 | - /** |
|
| 4412 | - * @psalm-pure |
|
| 4413 | - * |
|
| 4414 | - * @param iterable<array|null> $array |
|
| 4415 | - * @param string|int $key |
|
| 4416 | - * @param string $message |
|
| 4417 | - * |
|
| 4418 | - * @throws InvalidArgumentException |
|
| 4419 | - * |
|
| 4420 | - * @return void |
|
| 4421 | - */ |
|
| 4422 | - public static function allNullOrKeyExists($array, $key, $message = '') |
|
| 4423 | - { |
|
| 4424 | - static::isIterable($array); |
|
| 4425 | - |
|
| 4426 | - foreach ($array as $entry) { |
|
| 4427 | - null === $entry || static::keyExists($entry, $key, $message); |
|
| 4428 | - } |
|
| 4429 | - } |
|
| 4430 | - |
|
| 4431 | - /** |
|
| 4432 | - * @psalm-pure |
|
| 4433 | - * |
|
| 4434 | - * @param array|null $array |
|
| 4435 | - * @param string|int $key |
|
| 4436 | - * @param string $message |
|
| 4437 | - * |
|
| 4438 | - * @throws InvalidArgumentException |
|
| 4439 | - * |
|
| 4440 | - * @return void |
|
| 4441 | - */ |
|
| 4442 | - public static function nullOrKeyNotExists($array, $key, $message = '') |
|
| 4443 | - { |
|
| 4444 | - null === $array || static::keyNotExists($array, $key, $message); |
|
| 4445 | - } |
|
| 4446 | - |
|
| 4447 | - /** |
|
| 4448 | - * @psalm-pure |
|
| 4449 | - * |
|
| 4450 | - * @param iterable<array> $array |
|
| 4451 | - * @param string|int $key |
|
| 4452 | - * @param string $message |
|
| 4453 | - * |
|
| 4454 | - * @throws InvalidArgumentException |
|
| 4455 | - * |
|
| 4456 | - * @return void |
|
| 4457 | - */ |
|
| 4458 | - public static function allKeyNotExists($array, $key, $message = '') |
|
| 4459 | - { |
|
| 4460 | - static::isIterable($array); |
|
| 4461 | - |
|
| 4462 | - foreach ($array as $entry) { |
|
| 4463 | - static::keyNotExists($entry, $key, $message); |
|
| 4464 | - } |
|
| 4465 | - } |
|
| 4466 | - |
|
| 4467 | - /** |
|
| 4468 | - * @psalm-pure |
|
| 4469 | - * |
|
| 4470 | - * @param iterable<array|null> $array |
|
| 4471 | - * @param string|int $key |
|
| 4472 | - * @param string $message |
|
| 4473 | - * |
|
| 4474 | - * @throws InvalidArgumentException |
|
| 4475 | - * |
|
| 4476 | - * @return void |
|
| 4477 | - */ |
|
| 4478 | - public static function allNullOrKeyNotExists($array, $key, $message = '') |
|
| 4479 | - { |
|
| 4480 | - static::isIterable($array); |
|
| 4481 | - |
|
| 4482 | - foreach ($array as $entry) { |
|
| 4483 | - null === $entry || static::keyNotExists($entry, $key, $message); |
|
| 4484 | - } |
|
| 4485 | - } |
|
| 4486 | - |
|
| 4487 | - /** |
|
| 4488 | - * @psalm-pure |
|
| 4489 | - * @psalm-assert array-key|null $value |
|
| 4490 | - * |
|
| 4491 | - * @param mixed $value |
|
| 4492 | - * @param string $message |
|
| 4493 | - * |
|
| 4494 | - * @throws InvalidArgumentException |
|
| 4495 | - * |
|
| 4496 | - * @return void |
|
| 4497 | - */ |
|
| 4498 | - public static function nullOrValidArrayKey($value, $message = '') |
|
| 4499 | - { |
|
| 4500 | - null === $value || static::validArrayKey($value, $message); |
|
| 4501 | - } |
|
| 4502 | - |
|
| 4503 | - /** |
|
| 4504 | - * @psalm-pure |
|
| 4505 | - * @psalm-assert iterable<array-key> $value |
|
| 4506 | - * |
|
| 4507 | - * @param mixed $value |
|
| 4508 | - * @param string $message |
|
| 4509 | - * |
|
| 4510 | - * @throws InvalidArgumentException |
|
| 4511 | - * |
|
| 4512 | - * @return void |
|
| 4513 | - */ |
|
| 4514 | - public static function allValidArrayKey($value, $message = '') |
|
| 4515 | - { |
|
| 4516 | - static::isIterable($value); |
|
| 4517 | - |
|
| 4518 | - foreach ($value as $entry) { |
|
| 4519 | - static::validArrayKey($entry, $message); |
|
| 4520 | - } |
|
| 4521 | - } |
|
| 4522 | - |
|
| 4523 | - /** |
|
| 4524 | - * @psalm-pure |
|
| 4525 | - * @psalm-assert iterable<array-key|null> $value |
|
| 4526 | - * |
|
| 4527 | - * @param mixed $value |
|
| 4528 | - * @param string $message |
|
| 4529 | - * |
|
| 4530 | - * @throws InvalidArgumentException |
|
| 4531 | - * |
|
| 4532 | - * @return void |
|
| 4533 | - */ |
|
| 4534 | - public static function allNullOrValidArrayKey($value, $message = '') |
|
| 4535 | - { |
|
| 4536 | - static::isIterable($value); |
|
| 4537 | - |
|
| 4538 | - foreach ($value as $entry) { |
|
| 4539 | - null === $entry || static::validArrayKey($entry, $message); |
|
| 4540 | - } |
|
| 4541 | - } |
|
| 4542 | - |
|
| 4543 | - /** |
|
| 4544 | - * @param Countable|array|null $array |
|
| 4545 | - * @param int $number |
|
| 4546 | - * @param string $message |
|
| 4547 | - * |
|
| 4548 | - * @throws InvalidArgumentException |
|
| 4549 | - * |
|
| 4550 | - * @return void |
|
| 4551 | - */ |
|
| 4552 | - public static function nullOrCount($array, $number, $message = '') |
|
| 4553 | - { |
|
| 4554 | - null === $array || static::count($array, $number, $message); |
|
| 4555 | - } |
|
| 4556 | - |
|
| 4557 | - /** |
|
| 4558 | - * @param iterable<Countable|array> $array |
|
| 4559 | - * @param int $number |
|
| 4560 | - * @param string $message |
|
| 4561 | - * |
|
| 4562 | - * @throws InvalidArgumentException |
|
| 4563 | - * |
|
| 4564 | - * @return void |
|
| 4565 | - */ |
|
| 4566 | - public static function allCount($array, $number, $message = '') |
|
| 4567 | - { |
|
| 4568 | - static::isIterable($array); |
|
| 4569 | - |
|
| 4570 | - foreach ($array as $entry) { |
|
| 4571 | - static::count($entry, $number, $message); |
|
| 4572 | - } |
|
| 4573 | - } |
|
| 4574 | - |
|
| 4575 | - /** |
|
| 4576 | - * @param iterable<Countable|array|null> $array |
|
| 4577 | - * @param int $number |
|
| 4578 | - * @param string $message |
|
| 4579 | - * |
|
| 4580 | - * @throws InvalidArgumentException |
|
| 4581 | - * |
|
| 4582 | - * @return void |
|
| 4583 | - */ |
|
| 4584 | - public static function allNullOrCount($array, $number, $message = '') |
|
| 4585 | - { |
|
| 4586 | - static::isIterable($array); |
|
| 4587 | - |
|
| 4588 | - foreach ($array as $entry) { |
|
| 4589 | - null === $entry || static::count($entry, $number, $message); |
|
| 4590 | - } |
|
| 4591 | - } |
|
| 4592 | - |
|
| 4593 | - /** |
|
| 4594 | - * @param Countable|array|null $array |
|
| 4595 | - * @param int|float $min |
|
| 4596 | - * @param string $message |
|
| 4597 | - * |
|
| 4598 | - * @throws InvalidArgumentException |
|
| 4599 | - * |
|
| 4600 | - * @return void |
|
| 4601 | - */ |
|
| 4602 | - public static function nullOrMinCount($array, $min, $message = '') |
|
| 4603 | - { |
|
| 4604 | - null === $array || static::minCount($array, $min, $message); |
|
| 4605 | - } |
|
| 4606 | - |
|
| 4607 | - /** |
|
| 4608 | - * @param iterable<Countable|array> $array |
|
| 4609 | - * @param int|float $min |
|
| 4610 | - * @param string $message |
|
| 4611 | - * |
|
| 4612 | - * @throws InvalidArgumentException |
|
| 4613 | - * |
|
| 4614 | - * @return void |
|
| 4615 | - */ |
|
| 4616 | - public static function allMinCount($array, $min, $message = '') |
|
| 4617 | - { |
|
| 4618 | - static::isIterable($array); |
|
| 4619 | - |
|
| 4620 | - foreach ($array as $entry) { |
|
| 4621 | - static::minCount($entry, $min, $message); |
|
| 4622 | - } |
|
| 4623 | - } |
|
| 4624 | - |
|
| 4625 | - /** |
|
| 4626 | - * @param iterable<Countable|array|null> $array |
|
| 4627 | - * @param int|float $min |
|
| 4628 | - * @param string $message |
|
| 4629 | - * |
|
| 4630 | - * @throws InvalidArgumentException |
|
| 4631 | - * |
|
| 4632 | - * @return void |
|
| 4633 | - */ |
|
| 4634 | - public static function allNullOrMinCount($array, $min, $message = '') |
|
| 4635 | - { |
|
| 4636 | - static::isIterable($array); |
|
| 4637 | - |
|
| 4638 | - foreach ($array as $entry) { |
|
| 4639 | - null === $entry || static::minCount($entry, $min, $message); |
|
| 4640 | - } |
|
| 4641 | - } |
|
| 4642 | - |
|
| 4643 | - /** |
|
| 4644 | - * @param Countable|array|null $array |
|
| 4645 | - * @param int|float $max |
|
| 4646 | - * @param string $message |
|
| 4647 | - * |
|
| 4648 | - * @throws InvalidArgumentException |
|
| 4649 | - * |
|
| 4650 | - * @return void |
|
| 4651 | - */ |
|
| 4652 | - public static function nullOrMaxCount($array, $max, $message = '') |
|
| 4653 | - { |
|
| 4654 | - null === $array || static::maxCount($array, $max, $message); |
|
| 4655 | - } |
|
| 4656 | - |
|
| 4657 | - /** |
|
| 4658 | - * @param iterable<Countable|array> $array |
|
| 4659 | - * @param int|float $max |
|
| 4660 | - * @param string $message |
|
| 4661 | - * |
|
| 4662 | - * @throws InvalidArgumentException |
|
| 4663 | - * |
|
| 4664 | - * @return void |
|
| 4665 | - */ |
|
| 4666 | - public static function allMaxCount($array, $max, $message = '') |
|
| 4667 | - { |
|
| 4668 | - static::isIterable($array); |
|
| 4669 | - |
|
| 4670 | - foreach ($array as $entry) { |
|
| 4671 | - static::maxCount($entry, $max, $message); |
|
| 4672 | - } |
|
| 4673 | - } |
|
| 4674 | - |
|
| 4675 | - /** |
|
| 4676 | - * @param iterable<Countable|array|null> $array |
|
| 4677 | - * @param int|float $max |
|
| 4678 | - * @param string $message |
|
| 4679 | - * |
|
| 4680 | - * @throws InvalidArgumentException |
|
| 4681 | - * |
|
| 4682 | - * @return void |
|
| 4683 | - */ |
|
| 4684 | - public static function allNullOrMaxCount($array, $max, $message = '') |
|
| 4685 | - { |
|
| 4686 | - static::isIterable($array); |
|
| 4687 | - |
|
| 4688 | - foreach ($array as $entry) { |
|
| 4689 | - null === $entry || static::maxCount($entry, $max, $message); |
|
| 4690 | - } |
|
| 4691 | - } |
|
| 4692 | - |
|
| 4693 | - /** |
|
| 4694 | - * @param Countable|array|null $array |
|
| 4695 | - * @param int|float $min |
|
| 4696 | - * @param int|float $max |
|
| 4697 | - * @param string $message |
|
| 4698 | - * |
|
| 4699 | - * @throws InvalidArgumentException |
|
| 4700 | - * |
|
| 4701 | - * @return void |
|
| 4702 | - */ |
|
| 4703 | - public static function nullOrCountBetween($array, $min, $max, $message = '') |
|
| 4704 | - { |
|
| 4705 | - null === $array || static::countBetween($array, $min, $max, $message); |
|
| 4706 | - } |
|
| 4707 | - |
|
| 4708 | - /** |
|
| 4709 | - * @param iterable<Countable|array> $array |
|
| 4710 | - * @param int|float $min |
|
| 4711 | - * @param int|float $max |
|
| 4712 | - * @param string $message |
|
| 4713 | - * |
|
| 4714 | - * @throws InvalidArgumentException |
|
| 4715 | - * |
|
| 4716 | - * @return void |
|
| 4717 | - */ |
|
| 4718 | - public static function allCountBetween($array, $min, $max, $message = '') |
|
| 4719 | - { |
|
| 4720 | - static::isIterable($array); |
|
| 4721 | - |
|
| 4722 | - foreach ($array as $entry) { |
|
| 4723 | - static::countBetween($entry, $min, $max, $message); |
|
| 4724 | - } |
|
| 4725 | - } |
|
| 4726 | - |
|
| 4727 | - /** |
|
| 4728 | - * @param iterable<Countable|array|null> $array |
|
| 4729 | - * @param int|float $min |
|
| 4730 | - * @param int|float $max |
|
| 4731 | - * @param string $message |
|
| 4732 | - * |
|
| 4733 | - * @throws InvalidArgumentException |
|
| 4734 | - * |
|
| 4735 | - * @return void |
|
| 4736 | - */ |
|
| 4737 | - public static function allNullOrCountBetween($array, $min, $max, $message = '') |
|
| 4738 | - { |
|
| 4739 | - static::isIterable($array); |
|
| 4740 | - |
|
| 4741 | - foreach ($array as $entry) { |
|
| 4742 | - null === $entry || static::countBetween($entry, $min, $max, $message); |
|
| 4743 | - } |
|
| 4744 | - } |
|
| 4745 | - |
|
| 4746 | - /** |
|
| 4747 | - * @psalm-pure |
|
| 4748 | - * @psalm-assert list|null $array |
|
| 4749 | - * |
|
| 4750 | - * @param mixed $array |
|
| 4751 | - * @param string $message |
|
| 4752 | - * |
|
| 4753 | - * @throws InvalidArgumentException |
|
| 4754 | - * |
|
| 4755 | - * @return void |
|
| 4756 | - */ |
|
| 4757 | - public static function nullOrIsList($array, $message = '') |
|
| 4758 | - { |
|
| 4759 | - null === $array || static::isList($array, $message); |
|
| 4760 | - } |
|
| 4761 | - |
|
| 4762 | - /** |
|
| 4763 | - * @psalm-pure |
|
| 4764 | - * @psalm-assert iterable<list> $array |
|
| 4765 | - * |
|
| 4766 | - * @param mixed $array |
|
| 4767 | - * @param string $message |
|
| 4768 | - * |
|
| 4769 | - * @throws InvalidArgumentException |
|
| 4770 | - * |
|
| 4771 | - * @return void |
|
| 4772 | - */ |
|
| 4773 | - public static function allIsList($array, $message = '') |
|
| 4774 | - { |
|
| 4775 | - static::isIterable($array); |
|
| 4776 | - |
|
| 4777 | - foreach ($array as $entry) { |
|
| 4778 | - static::isList($entry, $message); |
|
| 4779 | - } |
|
| 4780 | - } |
|
| 4781 | - |
|
| 4782 | - /** |
|
| 4783 | - * @psalm-pure |
|
| 4784 | - * @psalm-assert iterable<list|null> $array |
|
| 4785 | - * |
|
| 4786 | - * @param mixed $array |
|
| 4787 | - * @param string $message |
|
| 4788 | - * |
|
| 4789 | - * @throws InvalidArgumentException |
|
| 4790 | - * |
|
| 4791 | - * @return void |
|
| 4792 | - */ |
|
| 4793 | - public static function allNullOrIsList($array, $message = '') |
|
| 4794 | - { |
|
| 4795 | - static::isIterable($array); |
|
| 4796 | - |
|
| 4797 | - foreach ($array as $entry) { |
|
| 4798 | - null === $entry || static::isList($entry, $message); |
|
| 4799 | - } |
|
| 4800 | - } |
|
| 4801 | - |
|
| 4802 | - /** |
|
| 4803 | - * @psalm-pure |
|
| 4804 | - * @psalm-assert non-empty-list|null $array |
|
| 4805 | - * |
|
| 4806 | - * @param mixed $array |
|
| 4807 | - * @param string $message |
|
| 4808 | - * |
|
| 4809 | - * @throws InvalidArgumentException |
|
| 4810 | - * |
|
| 4811 | - * @return void |
|
| 4812 | - */ |
|
| 4813 | - public static function nullOrIsNonEmptyList($array, $message = '') |
|
| 4814 | - { |
|
| 4815 | - null === $array || static::isNonEmptyList($array, $message); |
|
| 4816 | - } |
|
| 4817 | - |
|
| 4818 | - /** |
|
| 4819 | - * @psalm-pure |
|
| 4820 | - * @psalm-assert iterable<non-empty-list> $array |
|
| 4821 | - * |
|
| 4822 | - * @param mixed $array |
|
| 4823 | - * @param string $message |
|
| 4824 | - * |
|
| 4825 | - * @throws InvalidArgumentException |
|
| 4826 | - * |
|
| 4827 | - * @return void |
|
| 4828 | - */ |
|
| 4829 | - public static function allIsNonEmptyList($array, $message = '') |
|
| 4830 | - { |
|
| 4831 | - static::isIterable($array); |
|
| 4832 | - |
|
| 4833 | - foreach ($array as $entry) { |
|
| 4834 | - static::isNonEmptyList($entry, $message); |
|
| 4835 | - } |
|
| 4836 | - } |
|
| 4837 | - |
|
| 4838 | - /** |
|
| 4839 | - * @psalm-pure |
|
| 4840 | - * @psalm-assert iterable<non-empty-list|null> $array |
|
| 4841 | - * |
|
| 4842 | - * @param mixed $array |
|
| 4843 | - * @param string $message |
|
| 4844 | - * |
|
| 4845 | - * @throws InvalidArgumentException |
|
| 4846 | - * |
|
| 4847 | - * @return void |
|
| 4848 | - */ |
|
| 4849 | - public static function allNullOrIsNonEmptyList($array, $message = '') |
|
| 4850 | - { |
|
| 4851 | - static::isIterable($array); |
|
| 4852 | - |
|
| 4853 | - foreach ($array as $entry) { |
|
| 4854 | - null === $entry || static::isNonEmptyList($entry, $message); |
|
| 4855 | - } |
|
| 4856 | - } |
|
| 4857 | - |
|
| 4858 | - /** |
|
| 4859 | - * @psalm-pure |
|
| 4860 | - * @psalm-template T |
|
| 4861 | - * @psalm-param mixed|array<T>|null $array |
|
| 4862 | - * @psalm-assert array<string, T>|null $array |
|
| 4863 | - * |
|
| 4864 | - * @param mixed $array |
|
| 4865 | - * @param string $message |
|
| 4866 | - * |
|
| 4867 | - * @throws InvalidArgumentException |
|
| 4868 | - * |
|
| 4869 | - * @return void |
|
| 4870 | - */ |
|
| 4871 | - public static function nullOrIsMap($array, $message = '') |
|
| 4872 | - { |
|
| 4873 | - null === $array || static::isMap($array, $message); |
|
| 4874 | - } |
|
| 4875 | - |
|
| 4876 | - /** |
|
| 4877 | - * @psalm-pure |
|
| 4878 | - * @psalm-template T |
|
| 4879 | - * @psalm-param iterable<mixed|array<T>> $array |
|
| 4880 | - * @psalm-assert iterable<array<string, T>> $array |
|
| 4881 | - * |
|
| 4882 | - * @param mixed $array |
|
| 4883 | - * @param string $message |
|
| 4884 | - * |
|
| 4885 | - * @throws InvalidArgumentException |
|
| 4886 | - * |
|
| 4887 | - * @return void |
|
| 4888 | - */ |
|
| 4889 | - public static function allIsMap($array, $message = '') |
|
| 4890 | - { |
|
| 4891 | - static::isIterable($array); |
|
| 4892 | - |
|
| 4893 | - foreach ($array as $entry) { |
|
| 4894 | - static::isMap($entry, $message); |
|
| 4895 | - } |
|
| 4896 | - } |
|
| 4897 | - |
|
| 4898 | - /** |
|
| 4899 | - * @psalm-pure |
|
| 4900 | - * @psalm-template T |
|
| 4901 | - * @psalm-param iterable<mixed|array<T>|null> $array |
|
| 4902 | - * @psalm-assert iterable<array<string, T>|null> $array |
|
| 4903 | - * |
|
| 4904 | - * @param mixed $array |
|
| 4905 | - * @param string $message |
|
| 4906 | - * |
|
| 4907 | - * @throws InvalidArgumentException |
|
| 4908 | - * |
|
| 4909 | - * @return void |
|
| 4910 | - */ |
|
| 4911 | - public static function allNullOrIsMap($array, $message = '') |
|
| 4912 | - { |
|
| 4913 | - static::isIterable($array); |
|
| 4914 | - |
|
| 4915 | - foreach ($array as $entry) { |
|
| 4916 | - null === $entry || static::isMap($entry, $message); |
|
| 4917 | - } |
|
| 4918 | - } |
|
| 4919 | - |
|
| 4920 | - /** |
|
| 4921 | - * @psalm-pure |
|
| 4922 | - * @psalm-template T |
|
| 4923 | - * @psalm-param mixed|array<T>|null $array |
|
| 4924 | - * |
|
| 4925 | - * @param mixed $array |
|
| 4926 | - * @param string $message |
|
| 4927 | - * |
|
| 4928 | - * @throws InvalidArgumentException |
|
| 4929 | - * |
|
| 4930 | - * @return void |
|
| 4931 | - */ |
|
| 4932 | - public static function nullOrIsNonEmptyMap($array, $message = '') |
|
| 4933 | - { |
|
| 4934 | - null === $array || static::isNonEmptyMap($array, $message); |
|
| 4935 | - } |
|
| 4936 | - |
|
| 4937 | - /** |
|
| 4938 | - * @psalm-pure |
|
| 4939 | - * @psalm-template T |
|
| 4940 | - * @psalm-param iterable<mixed|array<T>> $array |
|
| 4941 | - * |
|
| 4942 | - * @param mixed $array |
|
| 4943 | - * @param string $message |
|
| 4944 | - * |
|
| 4945 | - * @throws InvalidArgumentException |
|
| 4946 | - * |
|
| 4947 | - * @return void |
|
| 4948 | - */ |
|
| 4949 | - public static function allIsNonEmptyMap($array, $message = '') |
|
| 4950 | - { |
|
| 4951 | - static::isIterable($array); |
|
| 4952 | - |
|
| 4953 | - foreach ($array as $entry) { |
|
| 4954 | - static::isNonEmptyMap($entry, $message); |
|
| 4955 | - } |
|
| 4956 | - } |
|
| 4957 | - |
|
| 4958 | - /** |
|
| 4959 | - * @psalm-pure |
|
| 4960 | - * @psalm-template T |
|
| 4961 | - * @psalm-param iterable<mixed|array<T>|null> $array |
|
| 4962 | - * @psalm-assert iterable<array<string, T>|null> $array |
|
| 4963 | - * @psalm-assert iterable<!empty|null> $array |
|
| 4964 | - * |
|
| 4965 | - * @param mixed $array |
|
| 4966 | - * @param string $message |
|
| 4967 | - * |
|
| 4968 | - * @throws InvalidArgumentException |
|
| 4969 | - * |
|
| 4970 | - * @return void |
|
| 4971 | - */ |
|
| 4972 | - public static function allNullOrIsNonEmptyMap($array, $message = '') |
|
| 4973 | - { |
|
| 4974 | - static::isIterable($array); |
|
| 4975 | - |
|
| 4976 | - foreach ($array as $entry) { |
|
| 4977 | - null === $entry || static::isNonEmptyMap($entry, $message); |
|
| 4978 | - } |
|
| 4979 | - } |
|
| 4980 | - |
|
| 4981 | - /** |
|
| 4982 | - * @psalm-pure |
|
| 4983 | - * |
|
| 4984 | - * @param string|null $value |
|
| 4985 | - * @param string $message |
|
| 4986 | - * |
|
| 4987 | - * @throws InvalidArgumentException |
|
| 4988 | - * |
|
| 4989 | - * @return void |
|
| 4990 | - */ |
|
| 4991 | - public static function nullOrUuid($value, $message = '') |
|
| 4992 | - { |
|
| 4993 | - null === $value || static::uuid($value, $message); |
|
| 4994 | - } |
|
| 4995 | - |
|
| 4996 | - /** |
|
| 4997 | - * @psalm-pure |
|
| 4998 | - * |
|
| 4999 | - * @param iterable<string> $value |
|
| 5000 | - * @param string $message |
|
| 5001 | - * |
|
| 5002 | - * @throws InvalidArgumentException |
|
| 5003 | - * |
|
| 5004 | - * @return void |
|
| 5005 | - */ |
|
| 5006 | - public static function allUuid($value, $message = '') |
|
| 5007 | - { |
|
| 5008 | - static::isIterable($value); |
|
| 5009 | - |
|
| 5010 | - foreach ($value as $entry) { |
|
| 5011 | - static::uuid($entry, $message); |
|
| 5012 | - } |
|
| 5013 | - } |
|
| 5014 | - |
|
| 5015 | - /** |
|
| 5016 | - * @psalm-pure |
|
| 5017 | - * |
|
| 5018 | - * @param iterable<string|null> $value |
|
| 5019 | - * @param string $message |
|
| 5020 | - * |
|
| 5021 | - * @throws InvalidArgumentException |
|
| 5022 | - * |
|
| 5023 | - * @return void |
|
| 5024 | - */ |
|
| 5025 | - public static function allNullOrUuid($value, $message = '') |
|
| 5026 | - { |
|
| 5027 | - static::isIterable($value); |
|
| 5028 | - |
|
| 5029 | - foreach ($value as $entry) { |
|
| 5030 | - null === $entry || static::uuid($entry, $message); |
|
| 5031 | - } |
|
| 5032 | - } |
|
| 5033 | - |
|
| 5034 | - /** |
|
| 5035 | - * @psalm-param class-string<Throwable> $class |
|
| 5036 | - * |
|
| 5037 | - * @param Closure|null $expression |
|
| 5038 | - * @param string $class |
|
| 5039 | - * @param string $message |
|
| 5040 | - * |
|
| 5041 | - * @throws InvalidArgumentException |
|
| 5042 | - * |
|
| 5043 | - * @return void |
|
| 5044 | - */ |
|
| 5045 | - public static function nullOrThrows($expression, $class = 'Exception', $message = '') |
|
| 5046 | - { |
|
| 5047 | - null === $expression || static::throws($expression, $class, $message); |
|
| 5048 | - } |
|
| 5049 | - |
|
| 5050 | - /** |
|
| 5051 | - * @psalm-param class-string<Throwable> $class |
|
| 5052 | - * |
|
| 5053 | - * @param iterable<Closure> $expression |
|
| 5054 | - * @param string $class |
|
| 5055 | - * @param string $message |
|
| 5056 | - * |
|
| 5057 | - * @throws InvalidArgumentException |
|
| 5058 | - * |
|
| 5059 | - * @return void |
|
| 5060 | - */ |
|
| 5061 | - public static function allThrows($expression, $class = 'Exception', $message = '') |
|
| 5062 | - { |
|
| 5063 | - static::isIterable($expression); |
|
| 5064 | - |
|
| 5065 | - foreach ($expression as $entry) { |
|
| 5066 | - static::throws($entry, $class, $message); |
|
| 5067 | - } |
|
| 5068 | - } |
|
| 5069 | - |
|
| 5070 | - /** |
|
| 5071 | - * @psalm-param class-string<Throwable> $class |
|
| 5072 | - * |
|
| 5073 | - * @param iterable<Closure|null> $expression |
|
| 5074 | - * @param string $class |
|
| 5075 | - * @param string $message |
|
| 5076 | - * |
|
| 5077 | - * @throws InvalidArgumentException |
|
| 5078 | - * |
|
| 5079 | - * @return void |
|
| 5080 | - */ |
|
| 5081 | - public static function allNullOrThrows($expression, $class = 'Exception', $message = '') |
|
| 5082 | - { |
|
| 5083 | - static::isIterable($expression); |
|
| 5084 | - |
|
| 5085 | - foreach ($expression as $entry) { |
|
| 5086 | - null === $entry || static::throws($entry, $class, $message); |
|
| 5087 | - } |
|
| 5088 | - } |
|
| 16 | + /** |
|
| 17 | + * @psalm-pure |
|
| 18 | + * @psalm-assert string|null $value |
|
| 19 | + * |
|
| 20 | + * @param mixed $value |
|
| 21 | + * @param string $message |
|
| 22 | + * |
|
| 23 | + * @throws InvalidArgumentException |
|
| 24 | + * |
|
| 25 | + * @return void |
|
| 26 | + */ |
|
| 27 | + public static function nullOrString($value, $message = '') |
|
| 28 | + { |
|
| 29 | + null === $value || static::string($value, $message); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @psalm-pure |
|
| 34 | + * @psalm-assert iterable<string> $value |
|
| 35 | + * |
|
| 36 | + * @param mixed $value |
|
| 37 | + * @param string $message |
|
| 38 | + * |
|
| 39 | + * @throws InvalidArgumentException |
|
| 40 | + * |
|
| 41 | + * @return void |
|
| 42 | + */ |
|
| 43 | + public static function allString($value, $message = '') |
|
| 44 | + { |
|
| 45 | + static::isIterable($value); |
|
| 46 | + |
|
| 47 | + foreach ($value as $entry) { |
|
| 48 | + static::string($entry, $message); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @psalm-pure |
|
| 54 | + * @psalm-assert iterable<string|null> $value |
|
| 55 | + * |
|
| 56 | + * @param mixed $value |
|
| 57 | + * @param string $message |
|
| 58 | + * |
|
| 59 | + * @throws InvalidArgumentException |
|
| 60 | + * |
|
| 61 | + * @return void |
|
| 62 | + */ |
|
| 63 | + public static function allNullOrString($value, $message = '') |
|
| 64 | + { |
|
| 65 | + static::isIterable($value); |
|
| 66 | + |
|
| 67 | + foreach ($value as $entry) { |
|
| 68 | + null === $entry || static::string($entry, $message); |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @psalm-pure |
|
| 74 | + * @psalm-assert non-empty-string|null $value |
|
| 75 | + * |
|
| 76 | + * @param mixed $value |
|
| 77 | + * @param string $message |
|
| 78 | + * |
|
| 79 | + * @throws InvalidArgumentException |
|
| 80 | + * |
|
| 81 | + * @return void |
|
| 82 | + */ |
|
| 83 | + public static function nullOrStringNotEmpty($value, $message = '') |
|
| 84 | + { |
|
| 85 | + null === $value || static::stringNotEmpty($value, $message); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * @psalm-pure |
|
| 90 | + * @psalm-assert iterable<non-empty-string> $value |
|
| 91 | + * |
|
| 92 | + * @param mixed $value |
|
| 93 | + * @param string $message |
|
| 94 | + * |
|
| 95 | + * @throws InvalidArgumentException |
|
| 96 | + * |
|
| 97 | + * @return void |
|
| 98 | + */ |
|
| 99 | + public static function allStringNotEmpty($value, $message = '') |
|
| 100 | + { |
|
| 101 | + static::isIterable($value); |
|
| 102 | + |
|
| 103 | + foreach ($value as $entry) { |
|
| 104 | + static::stringNotEmpty($entry, $message); |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * @psalm-pure |
|
| 110 | + * @psalm-assert iterable<non-empty-string|null> $value |
|
| 111 | + * |
|
| 112 | + * @param mixed $value |
|
| 113 | + * @param string $message |
|
| 114 | + * |
|
| 115 | + * @throws InvalidArgumentException |
|
| 116 | + * |
|
| 117 | + * @return void |
|
| 118 | + */ |
|
| 119 | + public static function allNullOrStringNotEmpty($value, $message = '') |
|
| 120 | + { |
|
| 121 | + static::isIterable($value); |
|
| 122 | + |
|
| 123 | + foreach ($value as $entry) { |
|
| 124 | + null === $entry || static::stringNotEmpty($entry, $message); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @psalm-pure |
|
| 130 | + * @psalm-assert int|null $value |
|
| 131 | + * |
|
| 132 | + * @param mixed $value |
|
| 133 | + * @param string $message |
|
| 134 | + * |
|
| 135 | + * @throws InvalidArgumentException |
|
| 136 | + * |
|
| 137 | + * @return void |
|
| 138 | + */ |
|
| 139 | + public static function nullOrInteger($value, $message = '') |
|
| 140 | + { |
|
| 141 | + null === $value || static::integer($value, $message); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * @psalm-pure |
|
| 146 | + * @psalm-assert iterable<int> $value |
|
| 147 | + * |
|
| 148 | + * @param mixed $value |
|
| 149 | + * @param string $message |
|
| 150 | + * |
|
| 151 | + * @throws InvalidArgumentException |
|
| 152 | + * |
|
| 153 | + * @return void |
|
| 154 | + */ |
|
| 155 | + public static function allInteger($value, $message = '') |
|
| 156 | + { |
|
| 157 | + static::isIterable($value); |
|
| 158 | + |
|
| 159 | + foreach ($value as $entry) { |
|
| 160 | + static::integer($entry, $message); |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * @psalm-pure |
|
| 166 | + * @psalm-assert iterable<int|null> $value |
|
| 167 | + * |
|
| 168 | + * @param mixed $value |
|
| 169 | + * @param string $message |
|
| 170 | + * |
|
| 171 | + * @throws InvalidArgumentException |
|
| 172 | + * |
|
| 173 | + * @return void |
|
| 174 | + */ |
|
| 175 | + public static function allNullOrInteger($value, $message = '') |
|
| 176 | + { |
|
| 177 | + static::isIterable($value); |
|
| 178 | + |
|
| 179 | + foreach ($value as $entry) { |
|
| 180 | + null === $entry || static::integer($entry, $message); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * @psalm-pure |
|
| 186 | + * @psalm-assert numeric|null $value |
|
| 187 | + * |
|
| 188 | + * @param mixed $value |
|
| 189 | + * @param string $message |
|
| 190 | + * |
|
| 191 | + * @throws InvalidArgumentException |
|
| 192 | + * |
|
| 193 | + * @return void |
|
| 194 | + */ |
|
| 195 | + public static function nullOrIntegerish($value, $message = '') |
|
| 196 | + { |
|
| 197 | + null === $value || static::integerish($value, $message); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * @psalm-pure |
|
| 202 | + * @psalm-assert iterable<numeric> $value |
|
| 203 | + * |
|
| 204 | + * @param mixed $value |
|
| 205 | + * @param string $message |
|
| 206 | + * |
|
| 207 | + * @throws InvalidArgumentException |
|
| 208 | + * |
|
| 209 | + * @return void |
|
| 210 | + */ |
|
| 211 | + public static function allIntegerish($value, $message = '') |
|
| 212 | + { |
|
| 213 | + static::isIterable($value); |
|
| 214 | + |
|
| 215 | + foreach ($value as $entry) { |
|
| 216 | + static::integerish($entry, $message); |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * @psalm-pure |
|
| 222 | + * @psalm-assert iterable<numeric|null> $value |
|
| 223 | + * |
|
| 224 | + * @param mixed $value |
|
| 225 | + * @param string $message |
|
| 226 | + * |
|
| 227 | + * @throws InvalidArgumentException |
|
| 228 | + * |
|
| 229 | + * @return void |
|
| 230 | + */ |
|
| 231 | + public static function allNullOrIntegerish($value, $message = '') |
|
| 232 | + { |
|
| 233 | + static::isIterable($value); |
|
| 234 | + |
|
| 235 | + foreach ($value as $entry) { |
|
| 236 | + null === $entry || static::integerish($entry, $message); |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * @psalm-pure |
|
| 242 | + * @psalm-assert positive-int|null $value |
|
| 243 | + * |
|
| 244 | + * @param mixed $value |
|
| 245 | + * @param string $message |
|
| 246 | + * |
|
| 247 | + * @throws InvalidArgumentException |
|
| 248 | + * |
|
| 249 | + * @return void |
|
| 250 | + */ |
|
| 251 | + public static function nullOrPositiveInteger($value, $message = '') |
|
| 252 | + { |
|
| 253 | + null === $value || static::positiveInteger($value, $message); |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * @psalm-pure |
|
| 258 | + * @psalm-assert iterable<positive-int> $value |
|
| 259 | + * |
|
| 260 | + * @param mixed $value |
|
| 261 | + * @param string $message |
|
| 262 | + * |
|
| 263 | + * @throws InvalidArgumentException |
|
| 264 | + * |
|
| 265 | + * @return void |
|
| 266 | + */ |
|
| 267 | + public static function allPositiveInteger($value, $message = '') |
|
| 268 | + { |
|
| 269 | + static::isIterable($value); |
|
| 270 | + |
|
| 271 | + foreach ($value as $entry) { |
|
| 272 | + static::positiveInteger($entry, $message); |
|
| 273 | + } |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * @psalm-pure |
|
| 278 | + * @psalm-assert iterable<positive-int|null> $value |
|
| 279 | + * |
|
| 280 | + * @param mixed $value |
|
| 281 | + * @param string $message |
|
| 282 | + * |
|
| 283 | + * @throws InvalidArgumentException |
|
| 284 | + * |
|
| 285 | + * @return void |
|
| 286 | + */ |
|
| 287 | + public static function allNullOrPositiveInteger($value, $message = '') |
|
| 288 | + { |
|
| 289 | + static::isIterable($value); |
|
| 290 | + |
|
| 291 | + foreach ($value as $entry) { |
|
| 292 | + null === $entry || static::positiveInteger($entry, $message); |
|
| 293 | + } |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * @psalm-pure |
|
| 298 | + * @psalm-assert float|null $value |
|
| 299 | + * |
|
| 300 | + * @param mixed $value |
|
| 301 | + * @param string $message |
|
| 302 | + * |
|
| 303 | + * @throws InvalidArgumentException |
|
| 304 | + * |
|
| 305 | + * @return void |
|
| 306 | + */ |
|
| 307 | + public static function nullOrFloat($value, $message = '') |
|
| 308 | + { |
|
| 309 | + null === $value || static::float($value, $message); |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * @psalm-pure |
|
| 314 | + * @psalm-assert iterable<float> $value |
|
| 315 | + * |
|
| 316 | + * @param mixed $value |
|
| 317 | + * @param string $message |
|
| 318 | + * |
|
| 319 | + * @throws InvalidArgumentException |
|
| 320 | + * |
|
| 321 | + * @return void |
|
| 322 | + */ |
|
| 323 | + public static function allFloat($value, $message = '') |
|
| 324 | + { |
|
| 325 | + static::isIterable($value); |
|
| 326 | + |
|
| 327 | + foreach ($value as $entry) { |
|
| 328 | + static::float($entry, $message); |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * @psalm-pure |
|
| 334 | + * @psalm-assert iterable<float|null> $value |
|
| 335 | + * |
|
| 336 | + * @param mixed $value |
|
| 337 | + * @param string $message |
|
| 338 | + * |
|
| 339 | + * @throws InvalidArgumentException |
|
| 340 | + * |
|
| 341 | + * @return void |
|
| 342 | + */ |
|
| 343 | + public static function allNullOrFloat($value, $message = '') |
|
| 344 | + { |
|
| 345 | + static::isIterable($value); |
|
| 346 | + |
|
| 347 | + foreach ($value as $entry) { |
|
| 348 | + null === $entry || static::float($entry, $message); |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * @psalm-pure |
|
| 354 | + * @psalm-assert numeric|null $value |
|
| 355 | + * |
|
| 356 | + * @param mixed $value |
|
| 357 | + * @param string $message |
|
| 358 | + * |
|
| 359 | + * @throws InvalidArgumentException |
|
| 360 | + * |
|
| 361 | + * @return void |
|
| 362 | + */ |
|
| 363 | + public static function nullOrNumeric($value, $message = '') |
|
| 364 | + { |
|
| 365 | + null === $value || static::numeric($value, $message); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + /** |
|
| 369 | + * @psalm-pure |
|
| 370 | + * @psalm-assert iterable<numeric> $value |
|
| 371 | + * |
|
| 372 | + * @param mixed $value |
|
| 373 | + * @param string $message |
|
| 374 | + * |
|
| 375 | + * @throws InvalidArgumentException |
|
| 376 | + * |
|
| 377 | + * @return void |
|
| 378 | + */ |
|
| 379 | + public static function allNumeric($value, $message = '') |
|
| 380 | + { |
|
| 381 | + static::isIterable($value); |
|
| 382 | + |
|
| 383 | + foreach ($value as $entry) { |
|
| 384 | + static::numeric($entry, $message); |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * @psalm-pure |
|
| 390 | + * @psalm-assert iterable<numeric|null> $value |
|
| 391 | + * |
|
| 392 | + * @param mixed $value |
|
| 393 | + * @param string $message |
|
| 394 | + * |
|
| 395 | + * @throws InvalidArgumentException |
|
| 396 | + * |
|
| 397 | + * @return void |
|
| 398 | + */ |
|
| 399 | + public static function allNullOrNumeric($value, $message = '') |
|
| 400 | + { |
|
| 401 | + static::isIterable($value); |
|
| 402 | + |
|
| 403 | + foreach ($value as $entry) { |
|
| 404 | + null === $entry || static::numeric($entry, $message); |
|
| 405 | + } |
|
| 406 | + } |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * @psalm-pure |
|
| 410 | + * @psalm-assert positive-int|0|null $value |
|
| 411 | + * |
|
| 412 | + * @param mixed $value |
|
| 413 | + * @param string $message |
|
| 414 | + * |
|
| 415 | + * @throws InvalidArgumentException |
|
| 416 | + * |
|
| 417 | + * @return void |
|
| 418 | + */ |
|
| 419 | + public static function nullOrNatural($value, $message = '') |
|
| 420 | + { |
|
| 421 | + null === $value || static::natural($value, $message); |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * @psalm-pure |
|
| 426 | + * @psalm-assert iterable<positive-int|0> $value |
|
| 427 | + * |
|
| 428 | + * @param mixed $value |
|
| 429 | + * @param string $message |
|
| 430 | + * |
|
| 431 | + * @throws InvalidArgumentException |
|
| 432 | + * |
|
| 433 | + * @return void |
|
| 434 | + */ |
|
| 435 | + public static function allNatural($value, $message = '') |
|
| 436 | + { |
|
| 437 | + static::isIterable($value); |
|
| 438 | + |
|
| 439 | + foreach ($value as $entry) { |
|
| 440 | + static::natural($entry, $message); |
|
| 441 | + } |
|
| 442 | + } |
|
| 443 | + |
|
| 444 | + /** |
|
| 445 | + * @psalm-pure |
|
| 446 | + * @psalm-assert iterable<positive-int|0|null> $value |
|
| 447 | + * |
|
| 448 | + * @param mixed $value |
|
| 449 | + * @param string $message |
|
| 450 | + * |
|
| 451 | + * @throws InvalidArgumentException |
|
| 452 | + * |
|
| 453 | + * @return void |
|
| 454 | + */ |
|
| 455 | + public static function allNullOrNatural($value, $message = '') |
|
| 456 | + { |
|
| 457 | + static::isIterable($value); |
|
| 458 | + |
|
| 459 | + foreach ($value as $entry) { |
|
| 460 | + null === $entry || static::natural($entry, $message); |
|
| 461 | + } |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + /** |
|
| 465 | + * @psalm-pure |
|
| 466 | + * @psalm-assert bool|null $value |
|
| 467 | + * |
|
| 468 | + * @param mixed $value |
|
| 469 | + * @param string $message |
|
| 470 | + * |
|
| 471 | + * @throws InvalidArgumentException |
|
| 472 | + * |
|
| 473 | + * @return void |
|
| 474 | + */ |
|
| 475 | + public static function nullOrBoolean($value, $message = '') |
|
| 476 | + { |
|
| 477 | + null === $value || static::boolean($value, $message); |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + /** |
|
| 481 | + * @psalm-pure |
|
| 482 | + * @psalm-assert iterable<bool> $value |
|
| 483 | + * |
|
| 484 | + * @param mixed $value |
|
| 485 | + * @param string $message |
|
| 486 | + * |
|
| 487 | + * @throws InvalidArgumentException |
|
| 488 | + * |
|
| 489 | + * @return void |
|
| 490 | + */ |
|
| 491 | + public static function allBoolean($value, $message = '') |
|
| 492 | + { |
|
| 493 | + static::isIterable($value); |
|
| 494 | + |
|
| 495 | + foreach ($value as $entry) { |
|
| 496 | + static::boolean($entry, $message); |
|
| 497 | + } |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + /** |
|
| 501 | + * @psalm-pure |
|
| 502 | + * @psalm-assert iterable<bool|null> $value |
|
| 503 | + * |
|
| 504 | + * @param mixed $value |
|
| 505 | + * @param string $message |
|
| 506 | + * |
|
| 507 | + * @throws InvalidArgumentException |
|
| 508 | + * |
|
| 509 | + * @return void |
|
| 510 | + */ |
|
| 511 | + public static function allNullOrBoolean($value, $message = '') |
|
| 512 | + { |
|
| 513 | + static::isIterable($value); |
|
| 514 | + |
|
| 515 | + foreach ($value as $entry) { |
|
| 516 | + null === $entry || static::boolean($entry, $message); |
|
| 517 | + } |
|
| 518 | + } |
|
| 519 | + |
|
| 520 | + /** |
|
| 521 | + * @psalm-pure |
|
| 522 | + * @psalm-assert scalar|null $value |
|
| 523 | + * |
|
| 524 | + * @param mixed $value |
|
| 525 | + * @param string $message |
|
| 526 | + * |
|
| 527 | + * @throws InvalidArgumentException |
|
| 528 | + * |
|
| 529 | + * @return void |
|
| 530 | + */ |
|
| 531 | + public static function nullOrScalar($value, $message = '') |
|
| 532 | + { |
|
| 533 | + null === $value || static::scalar($value, $message); |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + /** |
|
| 537 | + * @psalm-pure |
|
| 538 | + * @psalm-assert iterable<scalar> $value |
|
| 539 | + * |
|
| 540 | + * @param mixed $value |
|
| 541 | + * @param string $message |
|
| 542 | + * |
|
| 543 | + * @throws InvalidArgumentException |
|
| 544 | + * |
|
| 545 | + * @return void |
|
| 546 | + */ |
|
| 547 | + public static function allScalar($value, $message = '') |
|
| 548 | + { |
|
| 549 | + static::isIterable($value); |
|
| 550 | + |
|
| 551 | + foreach ($value as $entry) { |
|
| 552 | + static::scalar($entry, $message); |
|
| 553 | + } |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + /** |
|
| 557 | + * @psalm-pure |
|
| 558 | + * @psalm-assert iterable<scalar|null> $value |
|
| 559 | + * |
|
| 560 | + * @param mixed $value |
|
| 561 | + * @param string $message |
|
| 562 | + * |
|
| 563 | + * @throws InvalidArgumentException |
|
| 564 | + * |
|
| 565 | + * @return void |
|
| 566 | + */ |
|
| 567 | + public static function allNullOrScalar($value, $message = '') |
|
| 568 | + { |
|
| 569 | + static::isIterable($value); |
|
| 570 | + |
|
| 571 | + foreach ($value as $entry) { |
|
| 572 | + null === $entry || static::scalar($entry, $message); |
|
| 573 | + } |
|
| 574 | + } |
|
| 575 | + |
|
| 576 | + /** |
|
| 577 | + * @psalm-pure |
|
| 578 | + * @psalm-assert object|null $value |
|
| 579 | + * |
|
| 580 | + * @param mixed $value |
|
| 581 | + * @param string $message |
|
| 582 | + * |
|
| 583 | + * @throws InvalidArgumentException |
|
| 584 | + * |
|
| 585 | + * @return void |
|
| 586 | + */ |
|
| 587 | + public static function nullOrObject($value, $message = '') |
|
| 588 | + { |
|
| 589 | + null === $value || static::object($value, $message); |
|
| 590 | + } |
|
| 591 | + |
|
| 592 | + /** |
|
| 593 | + * @psalm-pure |
|
| 594 | + * @psalm-assert iterable<object> $value |
|
| 595 | + * |
|
| 596 | + * @param mixed $value |
|
| 597 | + * @param string $message |
|
| 598 | + * |
|
| 599 | + * @throws InvalidArgumentException |
|
| 600 | + * |
|
| 601 | + * @return void |
|
| 602 | + */ |
|
| 603 | + public static function allObject($value, $message = '') |
|
| 604 | + { |
|
| 605 | + static::isIterable($value); |
|
| 606 | + |
|
| 607 | + foreach ($value as $entry) { |
|
| 608 | + static::object($entry, $message); |
|
| 609 | + } |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + /** |
|
| 613 | + * @psalm-pure |
|
| 614 | + * @psalm-assert iterable<object|null> $value |
|
| 615 | + * |
|
| 616 | + * @param mixed $value |
|
| 617 | + * @param string $message |
|
| 618 | + * |
|
| 619 | + * @throws InvalidArgumentException |
|
| 620 | + * |
|
| 621 | + * @return void |
|
| 622 | + */ |
|
| 623 | + public static function allNullOrObject($value, $message = '') |
|
| 624 | + { |
|
| 625 | + static::isIterable($value); |
|
| 626 | + |
|
| 627 | + foreach ($value as $entry) { |
|
| 628 | + null === $entry || static::object($entry, $message); |
|
| 629 | + } |
|
| 630 | + } |
|
| 631 | + |
|
| 632 | + /** |
|
| 633 | + * @psalm-pure |
|
| 634 | + * @psalm-assert resource|null $value |
|
| 635 | + * |
|
| 636 | + * @param mixed $value |
|
| 637 | + * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php |
|
| 638 | + * @param string $message |
|
| 639 | + * |
|
| 640 | + * @throws InvalidArgumentException |
|
| 641 | + * |
|
| 642 | + * @return void |
|
| 643 | + */ |
|
| 644 | + public static function nullOrResource($value, $type = null, $message = '') |
|
| 645 | + { |
|
| 646 | + null === $value || static::resource($value, $type, $message); |
|
| 647 | + } |
|
| 648 | + |
|
| 649 | + /** |
|
| 650 | + * @psalm-pure |
|
| 651 | + * @psalm-assert iterable<resource> $value |
|
| 652 | + * |
|
| 653 | + * @param mixed $value |
|
| 654 | + * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php |
|
| 655 | + * @param string $message |
|
| 656 | + * |
|
| 657 | + * @throws InvalidArgumentException |
|
| 658 | + * |
|
| 659 | + * @return void |
|
| 660 | + */ |
|
| 661 | + public static function allResource($value, $type = null, $message = '') |
|
| 662 | + { |
|
| 663 | + static::isIterable($value); |
|
| 664 | + |
|
| 665 | + foreach ($value as $entry) { |
|
| 666 | + static::resource($entry, $type, $message); |
|
| 667 | + } |
|
| 668 | + } |
|
| 669 | + |
|
| 670 | + /** |
|
| 671 | + * @psalm-pure |
|
| 672 | + * @psalm-assert iterable<resource|null> $value |
|
| 673 | + * |
|
| 674 | + * @param mixed $value |
|
| 675 | + * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php |
|
| 676 | + * @param string $message |
|
| 677 | + * |
|
| 678 | + * @throws InvalidArgumentException |
|
| 679 | + * |
|
| 680 | + * @return void |
|
| 681 | + */ |
|
| 682 | + public static function allNullOrResource($value, $type = null, $message = '') |
|
| 683 | + { |
|
| 684 | + static::isIterable($value); |
|
| 685 | + |
|
| 686 | + foreach ($value as $entry) { |
|
| 687 | + null === $entry || static::resource($entry, $type, $message); |
|
| 688 | + } |
|
| 689 | + } |
|
| 690 | + |
|
| 691 | + /** |
|
| 692 | + * @psalm-pure |
|
| 693 | + * @psalm-assert callable|null $value |
|
| 694 | + * |
|
| 695 | + * @param mixed $value |
|
| 696 | + * @param string $message |
|
| 697 | + * |
|
| 698 | + * @throws InvalidArgumentException |
|
| 699 | + * |
|
| 700 | + * @return void |
|
| 701 | + */ |
|
| 702 | + public static function nullOrIsCallable($value, $message = '') |
|
| 703 | + { |
|
| 704 | + null === $value || static::isCallable($value, $message); |
|
| 705 | + } |
|
| 706 | + |
|
| 707 | + /** |
|
| 708 | + * @psalm-pure |
|
| 709 | + * @psalm-assert iterable<callable> $value |
|
| 710 | + * |
|
| 711 | + * @param mixed $value |
|
| 712 | + * @param string $message |
|
| 713 | + * |
|
| 714 | + * @throws InvalidArgumentException |
|
| 715 | + * |
|
| 716 | + * @return void |
|
| 717 | + */ |
|
| 718 | + public static function allIsCallable($value, $message = '') |
|
| 719 | + { |
|
| 720 | + static::isIterable($value); |
|
| 721 | + |
|
| 722 | + foreach ($value as $entry) { |
|
| 723 | + static::isCallable($entry, $message); |
|
| 724 | + } |
|
| 725 | + } |
|
| 726 | + |
|
| 727 | + /** |
|
| 728 | + * @psalm-pure |
|
| 729 | + * @psalm-assert iterable<callable|null> $value |
|
| 730 | + * |
|
| 731 | + * @param mixed $value |
|
| 732 | + * @param string $message |
|
| 733 | + * |
|
| 734 | + * @throws InvalidArgumentException |
|
| 735 | + * |
|
| 736 | + * @return void |
|
| 737 | + */ |
|
| 738 | + public static function allNullOrIsCallable($value, $message = '') |
|
| 739 | + { |
|
| 740 | + static::isIterable($value); |
|
| 741 | + |
|
| 742 | + foreach ($value as $entry) { |
|
| 743 | + null === $entry || static::isCallable($entry, $message); |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + /** |
|
| 748 | + * @psalm-pure |
|
| 749 | + * @psalm-assert array|null $value |
|
| 750 | + * |
|
| 751 | + * @param mixed $value |
|
| 752 | + * @param string $message |
|
| 753 | + * |
|
| 754 | + * @throws InvalidArgumentException |
|
| 755 | + * |
|
| 756 | + * @return void |
|
| 757 | + */ |
|
| 758 | + public static function nullOrIsArray($value, $message = '') |
|
| 759 | + { |
|
| 760 | + null === $value || static::isArray($value, $message); |
|
| 761 | + } |
|
| 762 | + |
|
| 763 | + /** |
|
| 764 | + * @psalm-pure |
|
| 765 | + * @psalm-assert iterable<array> $value |
|
| 766 | + * |
|
| 767 | + * @param mixed $value |
|
| 768 | + * @param string $message |
|
| 769 | + * |
|
| 770 | + * @throws InvalidArgumentException |
|
| 771 | + * |
|
| 772 | + * @return void |
|
| 773 | + */ |
|
| 774 | + public static function allIsArray($value, $message = '') |
|
| 775 | + { |
|
| 776 | + static::isIterable($value); |
|
| 777 | + |
|
| 778 | + foreach ($value as $entry) { |
|
| 779 | + static::isArray($entry, $message); |
|
| 780 | + } |
|
| 781 | + } |
|
| 782 | + |
|
| 783 | + /** |
|
| 784 | + * @psalm-pure |
|
| 785 | + * @psalm-assert iterable<array|null> $value |
|
| 786 | + * |
|
| 787 | + * @param mixed $value |
|
| 788 | + * @param string $message |
|
| 789 | + * |
|
| 790 | + * @throws InvalidArgumentException |
|
| 791 | + * |
|
| 792 | + * @return void |
|
| 793 | + */ |
|
| 794 | + public static function allNullOrIsArray($value, $message = '') |
|
| 795 | + { |
|
| 796 | + static::isIterable($value); |
|
| 797 | + |
|
| 798 | + foreach ($value as $entry) { |
|
| 799 | + null === $entry || static::isArray($entry, $message); |
|
| 800 | + } |
|
| 801 | + } |
|
| 802 | + |
|
| 803 | + /** |
|
| 804 | + * @psalm-pure |
|
| 805 | + * @psalm-assert iterable|null $value |
|
| 806 | + * |
|
| 807 | + * @deprecated use "isIterable" or "isInstanceOf" instead |
|
| 808 | + * |
|
| 809 | + * @param mixed $value |
|
| 810 | + * @param string $message |
|
| 811 | + * |
|
| 812 | + * @throws InvalidArgumentException |
|
| 813 | + * |
|
| 814 | + * @return void |
|
| 815 | + */ |
|
| 816 | + public static function nullOrIsTraversable($value, $message = '') |
|
| 817 | + { |
|
| 818 | + null === $value || static::isTraversable($value, $message); |
|
| 819 | + } |
|
| 820 | + |
|
| 821 | + /** |
|
| 822 | + * @psalm-pure |
|
| 823 | + * @psalm-assert iterable<iterable> $value |
|
| 824 | + * |
|
| 825 | + * @deprecated use "isIterable" or "isInstanceOf" instead |
|
| 826 | + * |
|
| 827 | + * @param mixed $value |
|
| 828 | + * @param string $message |
|
| 829 | + * |
|
| 830 | + * @throws InvalidArgumentException |
|
| 831 | + * |
|
| 832 | + * @return void |
|
| 833 | + */ |
|
| 834 | + public static function allIsTraversable($value, $message = '') |
|
| 835 | + { |
|
| 836 | + static::isIterable($value); |
|
| 837 | + |
|
| 838 | + foreach ($value as $entry) { |
|
| 839 | + static::isTraversable($entry, $message); |
|
| 840 | + } |
|
| 841 | + } |
|
| 842 | + |
|
| 843 | + /** |
|
| 844 | + * @psalm-pure |
|
| 845 | + * @psalm-assert iterable<iterable|null> $value |
|
| 846 | + * |
|
| 847 | + * @deprecated use "isIterable" or "isInstanceOf" instead |
|
| 848 | + * |
|
| 849 | + * @param mixed $value |
|
| 850 | + * @param string $message |
|
| 851 | + * |
|
| 852 | + * @throws InvalidArgumentException |
|
| 853 | + * |
|
| 854 | + * @return void |
|
| 855 | + */ |
|
| 856 | + public static function allNullOrIsTraversable($value, $message = '') |
|
| 857 | + { |
|
| 858 | + static::isIterable($value); |
|
| 859 | + |
|
| 860 | + foreach ($value as $entry) { |
|
| 861 | + null === $entry || static::isTraversable($entry, $message); |
|
| 862 | + } |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + /** |
|
| 866 | + * @psalm-pure |
|
| 867 | + * @psalm-assert array|ArrayAccess|null $value |
|
| 868 | + * |
|
| 869 | + * @param mixed $value |
|
| 870 | + * @param string $message |
|
| 871 | + * |
|
| 872 | + * @throws InvalidArgumentException |
|
| 873 | + * |
|
| 874 | + * @return void |
|
| 875 | + */ |
|
| 876 | + public static function nullOrIsArrayAccessible($value, $message = '') |
|
| 877 | + { |
|
| 878 | + null === $value || static::isArrayAccessible($value, $message); |
|
| 879 | + } |
|
| 880 | + |
|
| 881 | + /** |
|
| 882 | + * @psalm-pure |
|
| 883 | + * @psalm-assert iterable<array|ArrayAccess> $value |
|
| 884 | + * |
|
| 885 | + * @param mixed $value |
|
| 886 | + * @param string $message |
|
| 887 | + * |
|
| 888 | + * @throws InvalidArgumentException |
|
| 889 | + * |
|
| 890 | + * @return void |
|
| 891 | + */ |
|
| 892 | + public static function allIsArrayAccessible($value, $message = '') |
|
| 893 | + { |
|
| 894 | + static::isIterable($value); |
|
| 895 | + |
|
| 896 | + foreach ($value as $entry) { |
|
| 897 | + static::isArrayAccessible($entry, $message); |
|
| 898 | + } |
|
| 899 | + } |
|
| 900 | + |
|
| 901 | + /** |
|
| 902 | + * @psalm-pure |
|
| 903 | + * @psalm-assert iterable<array|ArrayAccess|null> $value |
|
| 904 | + * |
|
| 905 | + * @param mixed $value |
|
| 906 | + * @param string $message |
|
| 907 | + * |
|
| 908 | + * @throws InvalidArgumentException |
|
| 909 | + * |
|
| 910 | + * @return void |
|
| 911 | + */ |
|
| 912 | + public static function allNullOrIsArrayAccessible($value, $message = '') |
|
| 913 | + { |
|
| 914 | + static::isIterable($value); |
|
| 915 | + |
|
| 916 | + foreach ($value as $entry) { |
|
| 917 | + null === $entry || static::isArrayAccessible($entry, $message); |
|
| 918 | + } |
|
| 919 | + } |
|
| 920 | + |
|
| 921 | + /** |
|
| 922 | + * @psalm-pure |
|
| 923 | + * @psalm-assert countable|null $value |
|
| 924 | + * |
|
| 925 | + * @param mixed $value |
|
| 926 | + * @param string $message |
|
| 927 | + * |
|
| 928 | + * @throws InvalidArgumentException |
|
| 929 | + * |
|
| 930 | + * @return void |
|
| 931 | + */ |
|
| 932 | + public static function nullOrIsCountable($value, $message = '') |
|
| 933 | + { |
|
| 934 | + null === $value || static::isCountable($value, $message); |
|
| 935 | + } |
|
| 936 | + |
|
| 937 | + /** |
|
| 938 | + * @psalm-pure |
|
| 939 | + * @psalm-assert iterable<countable> $value |
|
| 940 | + * |
|
| 941 | + * @param mixed $value |
|
| 942 | + * @param string $message |
|
| 943 | + * |
|
| 944 | + * @throws InvalidArgumentException |
|
| 945 | + * |
|
| 946 | + * @return void |
|
| 947 | + */ |
|
| 948 | + public static function allIsCountable($value, $message = '') |
|
| 949 | + { |
|
| 950 | + static::isIterable($value); |
|
| 951 | + |
|
| 952 | + foreach ($value as $entry) { |
|
| 953 | + static::isCountable($entry, $message); |
|
| 954 | + } |
|
| 955 | + } |
|
| 956 | + |
|
| 957 | + /** |
|
| 958 | + * @psalm-pure |
|
| 959 | + * @psalm-assert iterable<countable|null> $value |
|
| 960 | + * |
|
| 961 | + * @param mixed $value |
|
| 962 | + * @param string $message |
|
| 963 | + * |
|
| 964 | + * @throws InvalidArgumentException |
|
| 965 | + * |
|
| 966 | + * @return void |
|
| 967 | + */ |
|
| 968 | + public static function allNullOrIsCountable($value, $message = '') |
|
| 969 | + { |
|
| 970 | + static::isIterable($value); |
|
| 971 | + |
|
| 972 | + foreach ($value as $entry) { |
|
| 973 | + null === $entry || static::isCountable($entry, $message); |
|
| 974 | + } |
|
| 975 | + } |
|
| 976 | + |
|
| 977 | + /** |
|
| 978 | + * @psalm-pure |
|
| 979 | + * @psalm-assert iterable|null $value |
|
| 980 | + * |
|
| 981 | + * @param mixed $value |
|
| 982 | + * @param string $message |
|
| 983 | + * |
|
| 984 | + * @throws InvalidArgumentException |
|
| 985 | + * |
|
| 986 | + * @return void |
|
| 987 | + */ |
|
| 988 | + public static function nullOrIsIterable($value, $message = '') |
|
| 989 | + { |
|
| 990 | + null === $value || static::isIterable($value, $message); |
|
| 991 | + } |
|
| 992 | + |
|
| 993 | + /** |
|
| 994 | + * @psalm-pure |
|
| 995 | + * @psalm-assert iterable<iterable> $value |
|
| 996 | + * |
|
| 997 | + * @param mixed $value |
|
| 998 | + * @param string $message |
|
| 999 | + * |
|
| 1000 | + * @throws InvalidArgumentException |
|
| 1001 | + * |
|
| 1002 | + * @return void |
|
| 1003 | + */ |
|
| 1004 | + public static function allIsIterable($value, $message = '') |
|
| 1005 | + { |
|
| 1006 | + static::isIterable($value); |
|
| 1007 | + |
|
| 1008 | + foreach ($value as $entry) { |
|
| 1009 | + static::isIterable($entry, $message); |
|
| 1010 | + } |
|
| 1011 | + } |
|
| 1012 | + |
|
| 1013 | + /** |
|
| 1014 | + * @psalm-pure |
|
| 1015 | + * @psalm-assert iterable<iterable|null> $value |
|
| 1016 | + * |
|
| 1017 | + * @param mixed $value |
|
| 1018 | + * @param string $message |
|
| 1019 | + * |
|
| 1020 | + * @throws InvalidArgumentException |
|
| 1021 | + * |
|
| 1022 | + * @return void |
|
| 1023 | + */ |
|
| 1024 | + public static function allNullOrIsIterable($value, $message = '') |
|
| 1025 | + { |
|
| 1026 | + static::isIterable($value); |
|
| 1027 | + |
|
| 1028 | + foreach ($value as $entry) { |
|
| 1029 | + null === $entry || static::isIterable($entry, $message); |
|
| 1030 | + } |
|
| 1031 | + } |
|
| 1032 | + |
|
| 1033 | + /** |
|
| 1034 | + * @psalm-pure |
|
| 1035 | + * @psalm-template ExpectedType of object |
|
| 1036 | + * @psalm-param class-string<ExpectedType> $class |
|
| 1037 | + * @psalm-assert ExpectedType|null $value |
|
| 1038 | + * |
|
| 1039 | + * @param mixed $value |
|
| 1040 | + * @param string|object $class |
|
| 1041 | + * @param string $message |
|
| 1042 | + * |
|
| 1043 | + * @throws InvalidArgumentException |
|
| 1044 | + * |
|
| 1045 | + * @return void |
|
| 1046 | + */ |
|
| 1047 | + public static function nullOrIsInstanceOf($value, $class, $message = '') |
|
| 1048 | + { |
|
| 1049 | + null === $value || static::isInstanceOf($value, $class, $message); |
|
| 1050 | + } |
|
| 1051 | + |
|
| 1052 | + /** |
|
| 1053 | + * @psalm-pure |
|
| 1054 | + * @psalm-template ExpectedType of object |
|
| 1055 | + * @psalm-param class-string<ExpectedType> $class |
|
| 1056 | + * @psalm-assert iterable<ExpectedType> $value |
|
| 1057 | + * |
|
| 1058 | + * @param mixed $value |
|
| 1059 | + * @param string|object $class |
|
| 1060 | + * @param string $message |
|
| 1061 | + * |
|
| 1062 | + * @throws InvalidArgumentException |
|
| 1063 | + * |
|
| 1064 | + * @return void |
|
| 1065 | + */ |
|
| 1066 | + public static function allIsInstanceOf($value, $class, $message = '') |
|
| 1067 | + { |
|
| 1068 | + static::isIterable($value); |
|
| 1069 | + |
|
| 1070 | + foreach ($value as $entry) { |
|
| 1071 | + static::isInstanceOf($entry, $class, $message); |
|
| 1072 | + } |
|
| 1073 | + } |
|
| 1074 | + |
|
| 1075 | + /** |
|
| 1076 | + * @psalm-pure |
|
| 1077 | + * @psalm-template ExpectedType of object |
|
| 1078 | + * @psalm-param class-string<ExpectedType> $class |
|
| 1079 | + * @psalm-assert iterable<ExpectedType|null> $value |
|
| 1080 | + * |
|
| 1081 | + * @param mixed $value |
|
| 1082 | + * @param string|object $class |
|
| 1083 | + * @param string $message |
|
| 1084 | + * |
|
| 1085 | + * @throws InvalidArgumentException |
|
| 1086 | + * |
|
| 1087 | + * @return void |
|
| 1088 | + */ |
|
| 1089 | + public static function allNullOrIsInstanceOf($value, $class, $message = '') |
|
| 1090 | + { |
|
| 1091 | + static::isIterable($value); |
|
| 1092 | + |
|
| 1093 | + foreach ($value as $entry) { |
|
| 1094 | + null === $entry || static::isInstanceOf($entry, $class, $message); |
|
| 1095 | + } |
|
| 1096 | + } |
|
| 1097 | + |
|
| 1098 | + /** |
|
| 1099 | + * @psalm-pure |
|
| 1100 | + * @psalm-template ExpectedType of object |
|
| 1101 | + * @psalm-param class-string<ExpectedType> $class |
|
| 1102 | + * |
|
| 1103 | + * @param mixed $value |
|
| 1104 | + * @param string|object $class |
|
| 1105 | + * @param string $message |
|
| 1106 | + * |
|
| 1107 | + * @throws InvalidArgumentException |
|
| 1108 | + * |
|
| 1109 | + * @return void |
|
| 1110 | + */ |
|
| 1111 | + public static function nullOrNotInstanceOf($value, $class, $message = '') |
|
| 1112 | + { |
|
| 1113 | + null === $value || static::notInstanceOf($value, $class, $message); |
|
| 1114 | + } |
|
| 1115 | + |
|
| 1116 | + /** |
|
| 1117 | + * @psalm-pure |
|
| 1118 | + * @psalm-template ExpectedType of object |
|
| 1119 | + * @psalm-param class-string<ExpectedType> $class |
|
| 1120 | + * |
|
| 1121 | + * @param mixed $value |
|
| 1122 | + * @param string|object $class |
|
| 1123 | + * @param string $message |
|
| 1124 | + * |
|
| 1125 | + * @throws InvalidArgumentException |
|
| 1126 | + * |
|
| 1127 | + * @return void |
|
| 1128 | + */ |
|
| 1129 | + public static function allNotInstanceOf($value, $class, $message = '') |
|
| 1130 | + { |
|
| 1131 | + static::isIterable($value); |
|
| 1132 | + |
|
| 1133 | + foreach ($value as $entry) { |
|
| 1134 | + static::notInstanceOf($entry, $class, $message); |
|
| 1135 | + } |
|
| 1136 | + } |
|
| 1137 | + |
|
| 1138 | + /** |
|
| 1139 | + * @psalm-pure |
|
| 1140 | + * @psalm-template ExpectedType of object |
|
| 1141 | + * @psalm-param class-string<ExpectedType> $class |
|
| 1142 | + * @psalm-assert iterable<!ExpectedType|null> $value |
|
| 1143 | + * |
|
| 1144 | + * @param mixed $value |
|
| 1145 | + * @param string|object $class |
|
| 1146 | + * @param string $message |
|
| 1147 | + * |
|
| 1148 | + * @throws InvalidArgumentException |
|
| 1149 | + * |
|
| 1150 | + * @return void |
|
| 1151 | + */ |
|
| 1152 | + public static function allNullOrNotInstanceOf($value, $class, $message = '') |
|
| 1153 | + { |
|
| 1154 | + static::isIterable($value); |
|
| 1155 | + |
|
| 1156 | + foreach ($value as $entry) { |
|
| 1157 | + null === $entry || static::notInstanceOf($entry, $class, $message); |
|
| 1158 | + } |
|
| 1159 | + } |
|
| 1160 | + |
|
| 1161 | + /** |
|
| 1162 | + * @psalm-pure |
|
| 1163 | + * @psalm-param array<class-string> $classes |
|
| 1164 | + * |
|
| 1165 | + * @param mixed $value |
|
| 1166 | + * @param array<object|string> $classes |
|
| 1167 | + * @param string $message |
|
| 1168 | + * |
|
| 1169 | + * @throws InvalidArgumentException |
|
| 1170 | + * |
|
| 1171 | + * @return void |
|
| 1172 | + */ |
|
| 1173 | + public static function nullOrIsInstanceOfAny($value, $classes, $message = '') |
|
| 1174 | + { |
|
| 1175 | + null === $value || static::isInstanceOfAny($value, $classes, $message); |
|
| 1176 | + } |
|
| 1177 | + |
|
| 1178 | + /** |
|
| 1179 | + * @psalm-pure |
|
| 1180 | + * @psalm-param array<class-string> $classes |
|
| 1181 | + * |
|
| 1182 | + * @param mixed $value |
|
| 1183 | + * @param array<object|string> $classes |
|
| 1184 | + * @param string $message |
|
| 1185 | + * |
|
| 1186 | + * @throws InvalidArgumentException |
|
| 1187 | + * |
|
| 1188 | + * @return void |
|
| 1189 | + */ |
|
| 1190 | + public static function allIsInstanceOfAny($value, $classes, $message = '') |
|
| 1191 | + { |
|
| 1192 | + static::isIterable($value); |
|
| 1193 | + |
|
| 1194 | + foreach ($value as $entry) { |
|
| 1195 | + static::isInstanceOfAny($entry, $classes, $message); |
|
| 1196 | + } |
|
| 1197 | + } |
|
| 1198 | + |
|
| 1199 | + /** |
|
| 1200 | + * @psalm-pure |
|
| 1201 | + * @psalm-param array<class-string> $classes |
|
| 1202 | + * |
|
| 1203 | + * @param mixed $value |
|
| 1204 | + * @param array<object|string> $classes |
|
| 1205 | + * @param string $message |
|
| 1206 | + * |
|
| 1207 | + * @throws InvalidArgumentException |
|
| 1208 | + * |
|
| 1209 | + * @return void |
|
| 1210 | + */ |
|
| 1211 | + public static function allNullOrIsInstanceOfAny($value, $classes, $message = '') |
|
| 1212 | + { |
|
| 1213 | + static::isIterable($value); |
|
| 1214 | + |
|
| 1215 | + foreach ($value as $entry) { |
|
| 1216 | + null === $entry || static::isInstanceOfAny($entry, $classes, $message); |
|
| 1217 | + } |
|
| 1218 | + } |
|
| 1219 | + |
|
| 1220 | + /** |
|
| 1221 | + * @psalm-pure |
|
| 1222 | + * @psalm-template ExpectedType of object |
|
| 1223 | + * @psalm-param class-string<ExpectedType> $class |
|
| 1224 | + * @psalm-assert ExpectedType|class-string<ExpectedType>|null $value |
|
| 1225 | + * |
|
| 1226 | + * @param object|string|null $value |
|
| 1227 | + * @param string $class |
|
| 1228 | + * @param string $message |
|
| 1229 | + * |
|
| 1230 | + * @throws InvalidArgumentException |
|
| 1231 | + * |
|
| 1232 | + * @return void |
|
| 1233 | + */ |
|
| 1234 | + public static function nullOrIsAOf($value, $class, $message = '') |
|
| 1235 | + { |
|
| 1236 | + null === $value || static::isAOf($value, $class, $message); |
|
| 1237 | + } |
|
| 1238 | + |
|
| 1239 | + /** |
|
| 1240 | + * @psalm-pure |
|
| 1241 | + * @psalm-template ExpectedType of object |
|
| 1242 | + * @psalm-param class-string<ExpectedType> $class |
|
| 1243 | + * @psalm-assert iterable<ExpectedType|class-string<ExpectedType>> $value |
|
| 1244 | + * |
|
| 1245 | + * @param iterable<object|string> $value |
|
| 1246 | + * @param string $class |
|
| 1247 | + * @param string $message |
|
| 1248 | + * |
|
| 1249 | + * @throws InvalidArgumentException |
|
| 1250 | + * |
|
| 1251 | + * @return void |
|
| 1252 | + */ |
|
| 1253 | + public static function allIsAOf($value, $class, $message = '') |
|
| 1254 | + { |
|
| 1255 | + static::isIterable($value); |
|
| 1256 | + |
|
| 1257 | + foreach ($value as $entry) { |
|
| 1258 | + static::isAOf($entry, $class, $message); |
|
| 1259 | + } |
|
| 1260 | + } |
|
| 1261 | + |
|
| 1262 | + /** |
|
| 1263 | + * @psalm-pure |
|
| 1264 | + * @psalm-template ExpectedType of object |
|
| 1265 | + * @psalm-param class-string<ExpectedType> $class |
|
| 1266 | + * @psalm-assert iterable<ExpectedType|class-string<ExpectedType>|null> $value |
|
| 1267 | + * |
|
| 1268 | + * @param iterable<object|string|null> $value |
|
| 1269 | + * @param string $class |
|
| 1270 | + * @param string $message |
|
| 1271 | + * |
|
| 1272 | + * @throws InvalidArgumentException |
|
| 1273 | + * |
|
| 1274 | + * @return void |
|
| 1275 | + */ |
|
| 1276 | + public static function allNullOrIsAOf($value, $class, $message = '') |
|
| 1277 | + { |
|
| 1278 | + static::isIterable($value); |
|
| 1279 | + |
|
| 1280 | + foreach ($value as $entry) { |
|
| 1281 | + null === $entry || static::isAOf($entry, $class, $message); |
|
| 1282 | + } |
|
| 1283 | + } |
|
| 1284 | + |
|
| 1285 | + /** |
|
| 1286 | + * @psalm-pure |
|
| 1287 | + * @psalm-template UnexpectedType of object |
|
| 1288 | + * @psalm-param class-string<UnexpectedType> $class |
|
| 1289 | + * |
|
| 1290 | + * @param object|string|null $value |
|
| 1291 | + * @param string $class |
|
| 1292 | + * @param string $message |
|
| 1293 | + * |
|
| 1294 | + * @throws InvalidArgumentException |
|
| 1295 | + * |
|
| 1296 | + * @return void |
|
| 1297 | + */ |
|
| 1298 | + public static function nullOrIsNotA($value, $class, $message = '') |
|
| 1299 | + { |
|
| 1300 | + null === $value || static::isNotA($value, $class, $message); |
|
| 1301 | + } |
|
| 1302 | + |
|
| 1303 | + /** |
|
| 1304 | + * @psalm-pure |
|
| 1305 | + * @psalm-template UnexpectedType of object |
|
| 1306 | + * @psalm-param class-string<UnexpectedType> $class |
|
| 1307 | + * |
|
| 1308 | + * @param iterable<object|string> $value |
|
| 1309 | + * @param string $class |
|
| 1310 | + * @param string $message |
|
| 1311 | + * |
|
| 1312 | + * @throws InvalidArgumentException |
|
| 1313 | + * |
|
| 1314 | + * @return void |
|
| 1315 | + */ |
|
| 1316 | + public static function allIsNotA($value, $class, $message = '') |
|
| 1317 | + { |
|
| 1318 | + static::isIterable($value); |
|
| 1319 | + |
|
| 1320 | + foreach ($value as $entry) { |
|
| 1321 | + static::isNotA($entry, $class, $message); |
|
| 1322 | + } |
|
| 1323 | + } |
|
| 1324 | + |
|
| 1325 | + /** |
|
| 1326 | + * @psalm-pure |
|
| 1327 | + * @psalm-template UnexpectedType of object |
|
| 1328 | + * @psalm-param class-string<UnexpectedType> $class |
|
| 1329 | + * @psalm-assert iterable<!UnexpectedType|null> $value |
|
| 1330 | + * @psalm-assert iterable<!class-string<UnexpectedType>|null> $value |
|
| 1331 | + * |
|
| 1332 | + * @param iterable<object|string|null> $value |
|
| 1333 | + * @param string $class |
|
| 1334 | + * @param string $message |
|
| 1335 | + * |
|
| 1336 | + * @throws InvalidArgumentException |
|
| 1337 | + * |
|
| 1338 | + * @return void |
|
| 1339 | + */ |
|
| 1340 | + public static function allNullOrIsNotA($value, $class, $message = '') |
|
| 1341 | + { |
|
| 1342 | + static::isIterable($value); |
|
| 1343 | + |
|
| 1344 | + foreach ($value as $entry) { |
|
| 1345 | + null === $entry || static::isNotA($entry, $class, $message); |
|
| 1346 | + } |
|
| 1347 | + } |
|
| 1348 | + |
|
| 1349 | + /** |
|
| 1350 | + * @psalm-pure |
|
| 1351 | + * @psalm-param array<class-string> $classes |
|
| 1352 | + * |
|
| 1353 | + * @param object|string|null $value |
|
| 1354 | + * @param string[] $classes |
|
| 1355 | + * @param string $message |
|
| 1356 | + * |
|
| 1357 | + * @throws InvalidArgumentException |
|
| 1358 | + * |
|
| 1359 | + * @return void |
|
| 1360 | + */ |
|
| 1361 | + public static function nullOrIsAnyOf($value, $classes, $message = '') |
|
| 1362 | + { |
|
| 1363 | + null === $value || static::isAnyOf($value, $classes, $message); |
|
| 1364 | + } |
|
| 1365 | + |
|
| 1366 | + /** |
|
| 1367 | + * @psalm-pure |
|
| 1368 | + * @psalm-param array<class-string> $classes |
|
| 1369 | + * |
|
| 1370 | + * @param iterable<object|string> $value |
|
| 1371 | + * @param string[] $classes |
|
| 1372 | + * @param string $message |
|
| 1373 | + * |
|
| 1374 | + * @throws InvalidArgumentException |
|
| 1375 | + * |
|
| 1376 | + * @return void |
|
| 1377 | + */ |
|
| 1378 | + public static function allIsAnyOf($value, $classes, $message = '') |
|
| 1379 | + { |
|
| 1380 | + static::isIterable($value); |
|
| 1381 | + |
|
| 1382 | + foreach ($value as $entry) { |
|
| 1383 | + static::isAnyOf($entry, $classes, $message); |
|
| 1384 | + } |
|
| 1385 | + } |
|
| 1386 | + |
|
| 1387 | + /** |
|
| 1388 | + * @psalm-pure |
|
| 1389 | + * @psalm-param array<class-string> $classes |
|
| 1390 | + * |
|
| 1391 | + * @param iterable<object|string|null> $value |
|
| 1392 | + * @param string[] $classes |
|
| 1393 | + * @param string $message |
|
| 1394 | + * |
|
| 1395 | + * @throws InvalidArgumentException |
|
| 1396 | + * |
|
| 1397 | + * @return void |
|
| 1398 | + */ |
|
| 1399 | + public static function allNullOrIsAnyOf($value, $classes, $message = '') |
|
| 1400 | + { |
|
| 1401 | + static::isIterable($value); |
|
| 1402 | + |
|
| 1403 | + foreach ($value as $entry) { |
|
| 1404 | + null === $entry || static::isAnyOf($entry, $classes, $message); |
|
| 1405 | + } |
|
| 1406 | + } |
|
| 1407 | + |
|
| 1408 | + /** |
|
| 1409 | + * @psalm-pure |
|
| 1410 | + * @psalm-assert empty $value |
|
| 1411 | + * |
|
| 1412 | + * @param mixed $value |
|
| 1413 | + * @param string $message |
|
| 1414 | + * |
|
| 1415 | + * @throws InvalidArgumentException |
|
| 1416 | + * |
|
| 1417 | + * @return void |
|
| 1418 | + */ |
|
| 1419 | + public static function nullOrIsEmpty($value, $message = '') |
|
| 1420 | + { |
|
| 1421 | + null === $value || static::isEmpty($value, $message); |
|
| 1422 | + } |
|
| 1423 | + |
|
| 1424 | + /** |
|
| 1425 | + * @psalm-pure |
|
| 1426 | + * @psalm-assert iterable<empty> $value |
|
| 1427 | + * |
|
| 1428 | + * @param mixed $value |
|
| 1429 | + * @param string $message |
|
| 1430 | + * |
|
| 1431 | + * @throws InvalidArgumentException |
|
| 1432 | + * |
|
| 1433 | + * @return void |
|
| 1434 | + */ |
|
| 1435 | + public static function allIsEmpty($value, $message = '') |
|
| 1436 | + { |
|
| 1437 | + static::isIterable($value); |
|
| 1438 | + |
|
| 1439 | + foreach ($value as $entry) { |
|
| 1440 | + static::isEmpty($entry, $message); |
|
| 1441 | + } |
|
| 1442 | + } |
|
| 1443 | + |
|
| 1444 | + /** |
|
| 1445 | + * @psalm-pure |
|
| 1446 | + * @psalm-assert iterable<empty|null> $value |
|
| 1447 | + * |
|
| 1448 | + * @param mixed $value |
|
| 1449 | + * @param string $message |
|
| 1450 | + * |
|
| 1451 | + * @throws InvalidArgumentException |
|
| 1452 | + * |
|
| 1453 | + * @return void |
|
| 1454 | + */ |
|
| 1455 | + public static function allNullOrIsEmpty($value, $message = '') |
|
| 1456 | + { |
|
| 1457 | + static::isIterable($value); |
|
| 1458 | + |
|
| 1459 | + foreach ($value as $entry) { |
|
| 1460 | + null === $entry || static::isEmpty($entry, $message); |
|
| 1461 | + } |
|
| 1462 | + } |
|
| 1463 | + |
|
| 1464 | + /** |
|
| 1465 | + * @psalm-pure |
|
| 1466 | + * |
|
| 1467 | + * @param mixed $value |
|
| 1468 | + * @param string $message |
|
| 1469 | + * |
|
| 1470 | + * @throws InvalidArgumentException |
|
| 1471 | + * |
|
| 1472 | + * @return void |
|
| 1473 | + */ |
|
| 1474 | + public static function nullOrNotEmpty($value, $message = '') |
|
| 1475 | + { |
|
| 1476 | + null === $value || static::notEmpty($value, $message); |
|
| 1477 | + } |
|
| 1478 | + |
|
| 1479 | + /** |
|
| 1480 | + * @psalm-pure |
|
| 1481 | + * |
|
| 1482 | + * @param mixed $value |
|
| 1483 | + * @param string $message |
|
| 1484 | + * |
|
| 1485 | + * @throws InvalidArgumentException |
|
| 1486 | + * |
|
| 1487 | + * @return void |
|
| 1488 | + */ |
|
| 1489 | + public static function allNotEmpty($value, $message = '') |
|
| 1490 | + { |
|
| 1491 | + static::isIterable($value); |
|
| 1492 | + |
|
| 1493 | + foreach ($value as $entry) { |
|
| 1494 | + static::notEmpty($entry, $message); |
|
| 1495 | + } |
|
| 1496 | + } |
|
| 1497 | + |
|
| 1498 | + /** |
|
| 1499 | + * @psalm-pure |
|
| 1500 | + * @psalm-assert iterable<!empty|null> $value |
|
| 1501 | + * |
|
| 1502 | + * @param mixed $value |
|
| 1503 | + * @param string $message |
|
| 1504 | + * |
|
| 1505 | + * @throws InvalidArgumentException |
|
| 1506 | + * |
|
| 1507 | + * @return void |
|
| 1508 | + */ |
|
| 1509 | + public static function allNullOrNotEmpty($value, $message = '') |
|
| 1510 | + { |
|
| 1511 | + static::isIterable($value); |
|
| 1512 | + |
|
| 1513 | + foreach ($value as $entry) { |
|
| 1514 | + null === $entry || static::notEmpty($entry, $message); |
|
| 1515 | + } |
|
| 1516 | + } |
|
| 1517 | + |
|
| 1518 | + /** |
|
| 1519 | + * @psalm-pure |
|
| 1520 | + * @psalm-assert iterable<null> $value |
|
| 1521 | + * |
|
| 1522 | + * @param mixed $value |
|
| 1523 | + * @param string $message |
|
| 1524 | + * |
|
| 1525 | + * @throws InvalidArgumentException |
|
| 1526 | + * |
|
| 1527 | + * @return void |
|
| 1528 | + */ |
|
| 1529 | + public static function allNull($value, $message = '') |
|
| 1530 | + { |
|
| 1531 | + static::isIterable($value); |
|
| 1532 | + |
|
| 1533 | + foreach ($value as $entry) { |
|
| 1534 | + static::null($entry, $message); |
|
| 1535 | + } |
|
| 1536 | + } |
|
| 1537 | + |
|
| 1538 | + /** |
|
| 1539 | + * @psalm-pure |
|
| 1540 | + * |
|
| 1541 | + * @param mixed $value |
|
| 1542 | + * @param string $message |
|
| 1543 | + * |
|
| 1544 | + * @throws InvalidArgumentException |
|
| 1545 | + * |
|
| 1546 | + * @return void |
|
| 1547 | + */ |
|
| 1548 | + public static function allNotNull($value, $message = '') |
|
| 1549 | + { |
|
| 1550 | + static::isIterable($value); |
|
| 1551 | + |
|
| 1552 | + foreach ($value as $entry) { |
|
| 1553 | + static::notNull($entry, $message); |
|
| 1554 | + } |
|
| 1555 | + } |
|
| 1556 | + |
|
| 1557 | + /** |
|
| 1558 | + * @psalm-pure |
|
| 1559 | + * @psalm-assert true|null $value |
|
| 1560 | + * |
|
| 1561 | + * @param mixed $value |
|
| 1562 | + * @param string $message |
|
| 1563 | + * |
|
| 1564 | + * @throws InvalidArgumentException |
|
| 1565 | + * |
|
| 1566 | + * @return void |
|
| 1567 | + */ |
|
| 1568 | + public static function nullOrTrue($value, $message = '') |
|
| 1569 | + { |
|
| 1570 | + null === $value || static::true($value, $message); |
|
| 1571 | + } |
|
| 1572 | + |
|
| 1573 | + /** |
|
| 1574 | + * @psalm-pure |
|
| 1575 | + * @psalm-assert iterable<true> $value |
|
| 1576 | + * |
|
| 1577 | + * @param mixed $value |
|
| 1578 | + * @param string $message |
|
| 1579 | + * |
|
| 1580 | + * @throws InvalidArgumentException |
|
| 1581 | + * |
|
| 1582 | + * @return void |
|
| 1583 | + */ |
|
| 1584 | + public static function allTrue($value, $message = '') |
|
| 1585 | + { |
|
| 1586 | + static::isIterable($value); |
|
| 1587 | + |
|
| 1588 | + foreach ($value as $entry) { |
|
| 1589 | + static::true($entry, $message); |
|
| 1590 | + } |
|
| 1591 | + } |
|
| 1592 | + |
|
| 1593 | + /** |
|
| 1594 | + * @psalm-pure |
|
| 1595 | + * @psalm-assert iterable<true|null> $value |
|
| 1596 | + * |
|
| 1597 | + * @param mixed $value |
|
| 1598 | + * @param string $message |
|
| 1599 | + * |
|
| 1600 | + * @throws InvalidArgumentException |
|
| 1601 | + * |
|
| 1602 | + * @return void |
|
| 1603 | + */ |
|
| 1604 | + public static function allNullOrTrue($value, $message = '') |
|
| 1605 | + { |
|
| 1606 | + static::isIterable($value); |
|
| 1607 | + |
|
| 1608 | + foreach ($value as $entry) { |
|
| 1609 | + null === $entry || static::true($entry, $message); |
|
| 1610 | + } |
|
| 1611 | + } |
|
| 1612 | + |
|
| 1613 | + /** |
|
| 1614 | + * @psalm-pure |
|
| 1615 | + * @psalm-assert false|null $value |
|
| 1616 | + * |
|
| 1617 | + * @param mixed $value |
|
| 1618 | + * @param string $message |
|
| 1619 | + * |
|
| 1620 | + * @throws InvalidArgumentException |
|
| 1621 | + * |
|
| 1622 | + * @return void |
|
| 1623 | + */ |
|
| 1624 | + public static function nullOrFalse($value, $message = '') |
|
| 1625 | + { |
|
| 1626 | + null === $value || static::false($value, $message); |
|
| 1627 | + } |
|
| 1628 | + |
|
| 1629 | + /** |
|
| 1630 | + * @psalm-pure |
|
| 1631 | + * @psalm-assert iterable<false> $value |
|
| 1632 | + * |
|
| 1633 | + * @param mixed $value |
|
| 1634 | + * @param string $message |
|
| 1635 | + * |
|
| 1636 | + * @throws InvalidArgumentException |
|
| 1637 | + * |
|
| 1638 | + * @return void |
|
| 1639 | + */ |
|
| 1640 | + public static function allFalse($value, $message = '') |
|
| 1641 | + { |
|
| 1642 | + static::isIterable($value); |
|
| 1643 | + |
|
| 1644 | + foreach ($value as $entry) { |
|
| 1645 | + static::false($entry, $message); |
|
| 1646 | + } |
|
| 1647 | + } |
|
| 1648 | + |
|
| 1649 | + /** |
|
| 1650 | + * @psalm-pure |
|
| 1651 | + * @psalm-assert iterable<false|null> $value |
|
| 1652 | + * |
|
| 1653 | + * @param mixed $value |
|
| 1654 | + * @param string $message |
|
| 1655 | + * |
|
| 1656 | + * @throws InvalidArgumentException |
|
| 1657 | + * |
|
| 1658 | + * @return void |
|
| 1659 | + */ |
|
| 1660 | + public static function allNullOrFalse($value, $message = '') |
|
| 1661 | + { |
|
| 1662 | + static::isIterable($value); |
|
| 1663 | + |
|
| 1664 | + foreach ($value as $entry) { |
|
| 1665 | + null === $entry || static::false($entry, $message); |
|
| 1666 | + } |
|
| 1667 | + } |
|
| 1668 | + |
|
| 1669 | + /** |
|
| 1670 | + * @psalm-pure |
|
| 1671 | + * |
|
| 1672 | + * @param mixed $value |
|
| 1673 | + * @param string $message |
|
| 1674 | + * |
|
| 1675 | + * @throws InvalidArgumentException |
|
| 1676 | + * |
|
| 1677 | + * @return void |
|
| 1678 | + */ |
|
| 1679 | + public static function nullOrNotFalse($value, $message = '') |
|
| 1680 | + { |
|
| 1681 | + null === $value || static::notFalse($value, $message); |
|
| 1682 | + } |
|
| 1683 | + |
|
| 1684 | + /** |
|
| 1685 | + * @psalm-pure |
|
| 1686 | + * |
|
| 1687 | + * @param mixed $value |
|
| 1688 | + * @param string $message |
|
| 1689 | + * |
|
| 1690 | + * @throws InvalidArgumentException |
|
| 1691 | + * |
|
| 1692 | + * @return void |
|
| 1693 | + */ |
|
| 1694 | + public static function allNotFalse($value, $message = '') |
|
| 1695 | + { |
|
| 1696 | + static::isIterable($value); |
|
| 1697 | + |
|
| 1698 | + foreach ($value as $entry) { |
|
| 1699 | + static::notFalse($entry, $message); |
|
| 1700 | + } |
|
| 1701 | + } |
|
| 1702 | + |
|
| 1703 | + /** |
|
| 1704 | + * @psalm-pure |
|
| 1705 | + * @psalm-assert iterable<!false|null> $value |
|
| 1706 | + * |
|
| 1707 | + * @param mixed $value |
|
| 1708 | + * @param string $message |
|
| 1709 | + * |
|
| 1710 | + * @throws InvalidArgumentException |
|
| 1711 | + * |
|
| 1712 | + * @return void |
|
| 1713 | + */ |
|
| 1714 | + public static function allNullOrNotFalse($value, $message = '') |
|
| 1715 | + { |
|
| 1716 | + static::isIterable($value); |
|
| 1717 | + |
|
| 1718 | + foreach ($value as $entry) { |
|
| 1719 | + null === $entry || static::notFalse($entry, $message); |
|
| 1720 | + } |
|
| 1721 | + } |
|
| 1722 | + |
|
| 1723 | + /** |
|
| 1724 | + * @param mixed $value |
|
| 1725 | + * @param string $message |
|
| 1726 | + * |
|
| 1727 | + * @throws InvalidArgumentException |
|
| 1728 | + * |
|
| 1729 | + * @return void |
|
| 1730 | + */ |
|
| 1731 | + public static function nullOrIp($value, $message = '') |
|
| 1732 | + { |
|
| 1733 | + null === $value || static::ip($value, $message); |
|
| 1734 | + } |
|
| 1735 | + |
|
| 1736 | + /** |
|
| 1737 | + * @param mixed $value |
|
| 1738 | + * @param string $message |
|
| 1739 | + * |
|
| 1740 | + * @throws InvalidArgumentException |
|
| 1741 | + * |
|
| 1742 | + * @return void |
|
| 1743 | + */ |
|
| 1744 | + public static function allIp($value, $message = '') |
|
| 1745 | + { |
|
| 1746 | + static::isIterable($value); |
|
| 1747 | + |
|
| 1748 | + foreach ($value as $entry) { |
|
| 1749 | + static::ip($entry, $message); |
|
| 1750 | + } |
|
| 1751 | + } |
|
| 1752 | + |
|
| 1753 | + /** |
|
| 1754 | + * @param mixed $value |
|
| 1755 | + * @param string $message |
|
| 1756 | + * |
|
| 1757 | + * @throws InvalidArgumentException |
|
| 1758 | + * |
|
| 1759 | + * @return void |
|
| 1760 | + */ |
|
| 1761 | + public static function allNullOrIp($value, $message = '') |
|
| 1762 | + { |
|
| 1763 | + static::isIterable($value); |
|
| 1764 | + |
|
| 1765 | + foreach ($value as $entry) { |
|
| 1766 | + null === $entry || static::ip($entry, $message); |
|
| 1767 | + } |
|
| 1768 | + } |
|
| 1769 | + |
|
| 1770 | + /** |
|
| 1771 | + * @param mixed $value |
|
| 1772 | + * @param string $message |
|
| 1773 | + * |
|
| 1774 | + * @throws InvalidArgumentException |
|
| 1775 | + * |
|
| 1776 | + * @return void |
|
| 1777 | + */ |
|
| 1778 | + public static function nullOrIpv4($value, $message = '') |
|
| 1779 | + { |
|
| 1780 | + null === $value || static::ipv4($value, $message); |
|
| 1781 | + } |
|
| 1782 | + |
|
| 1783 | + /** |
|
| 1784 | + * @param mixed $value |
|
| 1785 | + * @param string $message |
|
| 1786 | + * |
|
| 1787 | + * @throws InvalidArgumentException |
|
| 1788 | + * |
|
| 1789 | + * @return void |
|
| 1790 | + */ |
|
| 1791 | + public static function allIpv4($value, $message = '') |
|
| 1792 | + { |
|
| 1793 | + static::isIterable($value); |
|
| 1794 | + |
|
| 1795 | + foreach ($value as $entry) { |
|
| 1796 | + static::ipv4($entry, $message); |
|
| 1797 | + } |
|
| 1798 | + } |
|
| 1799 | + |
|
| 1800 | + /** |
|
| 1801 | + * @param mixed $value |
|
| 1802 | + * @param string $message |
|
| 1803 | + * |
|
| 1804 | + * @throws InvalidArgumentException |
|
| 1805 | + * |
|
| 1806 | + * @return void |
|
| 1807 | + */ |
|
| 1808 | + public static function allNullOrIpv4($value, $message = '') |
|
| 1809 | + { |
|
| 1810 | + static::isIterable($value); |
|
| 1811 | + |
|
| 1812 | + foreach ($value as $entry) { |
|
| 1813 | + null === $entry || static::ipv4($entry, $message); |
|
| 1814 | + } |
|
| 1815 | + } |
|
| 1816 | + |
|
| 1817 | + /** |
|
| 1818 | + * @param mixed $value |
|
| 1819 | + * @param string $message |
|
| 1820 | + * |
|
| 1821 | + * @throws InvalidArgumentException |
|
| 1822 | + * |
|
| 1823 | + * @return void |
|
| 1824 | + */ |
|
| 1825 | + public static function nullOrIpv6($value, $message = '') |
|
| 1826 | + { |
|
| 1827 | + null === $value || static::ipv6($value, $message); |
|
| 1828 | + } |
|
| 1829 | + |
|
| 1830 | + /** |
|
| 1831 | + * @param mixed $value |
|
| 1832 | + * @param string $message |
|
| 1833 | + * |
|
| 1834 | + * @throws InvalidArgumentException |
|
| 1835 | + * |
|
| 1836 | + * @return void |
|
| 1837 | + */ |
|
| 1838 | + public static function allIpv6($value, $message = '') |
|
| 1839 | + { |
|
| 1840 | + static::isIterable($value); |
|
| 1841 | + |
|
| 1842 | + foreach ($value as $entry) { |
|
| 1843 | + static::ipv6($entry, $message); |
|
| 1844 | + } |
|
| 1845 | + } |
|
| 1846 | + |
|
| 1847 | + /** |
|
| 1848 | + * @param mixed $value |
|
| 1849 | + * @param string $message |
|
| 1850 | + * |
|
| 1851 | + * @throws InvalidArgumentException |
|
| 1852 | + * |
|
| 1853 | + * @return void |
|
| 1854 | + */ |
|
| 1855 | + public static function allNullOrIpv6($value, $message = '') |
|
| 1856 | + { |
|
| 1857 | + static::isIterable($value); |
|
| 1858 | + |
|
| 1859 | + foreach ($value as $entry) { |
|
| 1860 | + null === $entry || static::ipv6($entry, $message); |
|
| 1861 | + } |
|
| 1862 | + } |
|
| 1863 | + |
|
| 1864 | + /** |
|
| 1865 | + * @param mixed $value |
|
| 1866 | + * @param string $message |
|
| 1867 | + * |
|
| 1868 | + * @throws InvalidArgumentException |
|
| 1869 | + * |
|
| 1870 | + * @return void |
|
| 1871 | + */ |
|
| 1872 | + public static function nullOrEmail($value, $message = '') |
|
| 1873 | + { |
|
| 1874 | + null === $value || static::email($value, $message); |
|
| 1875 | + } |
|
| 1876 | + |
|
| 1877 | + /** |
|
| 1878 | + * @param mixed $value |
|
| 1879 | + * @param string $message |
|
| 1880 | + * |
|
| 1881 | + * @throws InvalidArgumentException |
|
| 1882 | + * |
|
| 1883 | + * @return void |
|
| 1884 | + */ |
|
| 1885 | + public static function allEmail($value, $message = '') |
|
| 1886 | + { |
|
| 1887 | + static::isIterable($value); |
|
| 1888 | + |
|
| 1889 | + foreach ($value as $entry) { |
|
| 1890 | + static::email($entry, $message); |
|
| 1891 | + } |
|
| 1892 | + } |
|
| 1893 | + |
|
| 1894 | + /** |
|
| 1895 | + * @param mixed $value |
|
| 1896 | + * @param string $message |
|
| 1897 | + * |
|
| 1898 | + * @throws InvalidArgumentException |
|
| 1899 | + * |
|
| 1900 | + * @return void |
|
| 1901 | + */ |
|
| 1902 | + public static function allNullOrEmail($value, $message = '') |
|
| 1903 | + { |
|
| 1904 | + static::isIterable($value); |
|
| 1905 | + |
|
| 1906 | + foreach ($value as $entry) { |
|
| 1907 | + null === $entry || static::email($entry, $message); |
|
| 1908 | + } |
|
| 1909 | + } |
|
| 1910 | + |
|
| 1911 | + /** |
|
| 1912 | + * @param array|null $values |
|
| 1913 | + * @param string $message |
|
| 1914 | + * |
|
| 1915 | + * @throws InvalidArgumentException |
|
| 1916 | + * |
|
| 1917 | + * @return void |
|
| 1918 | + */ |
|
| 1919 | + public static function nullOrUniqueValues($values, $message = '') |
|
| 1920 | + { |
|
| 1921 | + null === $values || static::uniqueValues($values, $message); |
|
| 1922 | + } |
|
| 1923 | + |
|
| 1924 | + /** |
|
| 1925 | + * @param iterable<array> $values |
|
| 1926 | + * @param string $message |
|
| 1927 | + * |
|
| 1928 | + * @throws InvalidArgumentException |
|
| 1929 | + * |
|
| 1930 | + * @return void |
|
| 1931 | + */ |
|
| 1932 | + public static function allUniqueValues($values, $message = '') |
|
| 1933 | + { |
|
| 1934 | + static::isIterable($values); |
|
| 1935 | + |
|
| 1936 | + foreach ($values as $entry) { |
|
| 1937 | + static::uniqueValues($entry, $message); |
|
| 1938 | + } |
|
| 1939 | + } |
|
| 1940 | + |
|
| 1941 | + /** |
|
| 1942 | + * @param iterable<array|null> $values |
|
| 1943 | + * @param string $message |
|
| 1944 | + * |
|
| 1945 | + * @throws InvalidArgumentException |
|
| 1946 | + * |
|
| 1947 | + * @return void |
|
| 1948 | + */ |
|
| 1949 | + public static function allNullOrUniqueValues($values, $message = '') |
|
| 1950 | + { |
|
| 1951 | + static::isIterable($values); |
|
| 1952 | + |
|
| 1953 | + foreach ($values as $entry) { |
|
| 1954 | + null === $entry || static::uniqueValues($entry, $message); |
|
| 1955 | + } |
|
| 1956 | + } |
|
| 1957 | + |
|
| 1958 | + /** |
|
| 1959 | + * @param mixed $value |
|
| 1960 | + * @param mixed $expect |
|
| 1961 | + * @param string $message |
|
| 1962 | + * |
|
| 1963 | + * @throws InvalidArgumentException |
|
| 1964 | + * |
|
| 1965 | + * @return void |
|
| 1966 | + */ |
|
| 1967 | + public static function nullOrEq($value, $expect, $message = '') |
|
| 1968 | + { |
|
| 1969 | + null === $value || static::eq($value, $expect, $message); |
|
| 1970 | + } |
|
| 1971 | + |
|
| 1972 | + /** |
|
| 1973 | + * @param mixed $value |
|
| 1974 | + * @param mixed $expect |
|
| 1975 | + * @param string $message |
|
| 1976 | + * |
|
| 1977 | + * @throws InvalidArgumentException |
|
| 1978 | + * |
|
| 1979 | + * @return void |
|
| 1980 | + */ |
|
| 1981 | + public static function allEq($value, $expect, $message = '') |
|
| 1982 | + { |
|
| 1983 | + static::isIterable($value); |
|
| 1984 | + |
|
| 1985 | + foreach ($value as $entry) { |
|
| 1986 | + static::eq($entry, $expect, $message); |
|
| 1987 | + } |
|
| 1988 | + } |
|
| 1989 | + |
|
| 1990 | + /** |
|
| 1991 | + * @param mixed $value |
|
| 1992 | + * @param mixed $expect |
|
| 1993 | + * @param string $message |
|
| 1994 | + * |
|
| 1995 | + * @throws InvalidArgumentException |
|
| 1996 | + * |
|
| 1997 | + * @return void |
|
| 1998 | + */ |
|
| 1999 | + public static function allNullOrEq($value, $expect, $message = '') |
|
| 2000 | + { |
|
| 2001 | + static::isIterable($value); |
|
| 2002 | + |
|
| 2003 | + foreach ($value as $entry) { |
|
| 2004 | + null === $entry || static::eq($entry, $expect, $message); |
|
| 2005 | + } |
|
| 2006 | + } |
|
| 2007 | + |
|
| 2008 | + /** |
|
| 2009 | + * @param mixed $value |
|
| 2010 | + * @param mixed $expect |
|
| 2011 | + * @param string $message |
|
| 2012 | + * |
|
| 2013 | + * @throws InvalidArgumentException |
|
| 2014 | + * |
|
| 2015 | + * @return void |
|
| 2016 | + */ |
|
| 2017 | + public static function nullOrNotEq($value, $expect, $message = '') |
|
| 2018 | + { |
|
| 2019 | + null === $value || static::notEq($value, $expect, $message); |
|
| 2020 | + } |
|
| 2021 | + |
|
| 2022 | + /** |
|
| 2023 | + * @param mixed $value |
|
| 2024 | + * @param mixed $expect |
|
| 2025 | + * @param string $message |
|
| 2026 | + * |
|
| 2027 | + * @throws InvalidArgumentException |
|
| 2028 | + * |
|
| 2029 | + * @return void |
|
| 2030 | + */ |
|
| 2031 | + public static function allNotEq($value, $expect, $message = '') |
|
| 2032 | + { |
|
| 2033 | + static::isIterable($value); |
|
| 2034 | + |
|
| 2035 | + foreach ($value as $entry) { |
|
| 2036 | + static::notEq($entry, $expect, $message); |
|
| 2037 | + } |
|
| 2038 | + } |
|
| 2039 | + |
|
| 2040 | + /** |
|
| 2041 | + * @param mixed $value |
|
| 2042 | + * @param mixed $expect |
|
| 2043 | + * @param string $message |
|
| 2044 | + * |
|
| 2045 | + * @throws InvalidArgumentException |
|
| 2046 | + * |
|
| 2047 | + * @return void |
|
| 2048 | + */ |
|
| 2049 | + public static function allNullOrNotEq($value, $expect, $message = '') |
|
| 2050 | + { |
|
| 2051 | + static::isIterable($value); |
|
| 2052 | + |
|
| 2053 | + foreach ($value as $entry) { |
|
| 2054 | + null === $entry || static::notEq($entry, $expect, $message); |
|
| 2055 | + } |
|
| 2056 | + } |
|
| 2057 | + |
|
| 2058 | + /** |
|
| 2059 | + * @psalm-pure |
|
| 2060 | + * |
|
| 2061 | + * @param mixed $value |
|
| 2062 | + * @param mixed $expect |
|
| 2063 | + * @param string $message |
|
| 2064 | + * |
|
| 2065 | + * @throws InvalidArgumentException |
|
| 2066 | + * |
|
| 2067 | + * @return void |
|
| 2068 | + */ |
|
| 2069 | + public static function nullOrSame($value, $expect, $message = '') |
|
| 2070 | + { |
|
| 2071 | + null === $value || static::same($value, $expect, $message); |
|
| 2072 | + } |
|
| 2073 | + |
|
| 2074 | + /** |
|
| 2075 | + * @psalm-pure |
|
| 2076 | + * |
|
| 2077 | + * @param mixed $value |
|
| 2078 | + * @param mixed $expect |
|
| 2079 | + * @param string $message |
|
| 2080 | + * |
|
| 2081 | + * @throws InvalidArgumentException |
|
| 2082 | + * |
|
| 2083 | + * @return void |
|
| 2084 | + */ |
|
| 2085 | + public static function allSame($value, $expect, $message = '') |
|
| 2086 | + { |
|
| 2087 | + static::isIterable($value); |
|
| 2088 | + |
|
| 2089 | + foreach ($value as $entry) { |
|
| 2090 | + static::same($entry, $expect, $message); |
|
| 2091 | + } |
|
| 2092 | + } |
|
| 2093 | + |
|
| 2094 | + /** |
|
| 2095 | + * @psalm-pure |
|
| 2096 | + * |
|
| 2097 | + * @param mixed $value |
|
| 2098 | + * @param mixed $expect |
|
| 2099 | + * @param string $message |
|
| 2100 | + * |
|
| 2101 | + * @throws InvalidArgumentException |
|
| 2102 | + * |
|
| 2103 | + * @return void |
|
| 2104 | + */ |
|
| 2105 | + public static function allNullOrSame($value, $expect, $message = '') |
|
| 2106 | + { |
|
| 2107 | + static::isIterable($value); |
|
| 2108 | + |
|
| 2109 | + foreach ($value as $entry) { |
|
| 2110 | + null === $entry || static::same($entry, $expect, $message); |
|
| 2111 | + } |
|
| 2112 | + } |
|
| 2113 | + |
|
| 2114 | + /** |
|
| 2115 | + * @psalm-pure |
|
| 2116 | + * |
|
| 2117 | + * @param mixed $value |
|
| 2118 | + * @param mixed $expect |
|
| 2119 | + * @param string $message |
|
| 2120 | + * |
|
| 2121 | + * @throws InvalidArgumentException |
|
| 2122 | + * |
|
| 2123 | + * @return void |
|
| 2124 | + */ |
|
| 2125 | + public static function nullOrNotSame($value, $expect, $message = '') |
|
| 2126 | + { |
|
| 2127 | + null === $value || static::notSame($value, $expect, $message); |
|
| 2128 | + } |
|
| 2129 | + |
|
| 2130 | + /** |
|
| 2131 | + * @psalm-pure |
|
| 2132 | + * |
|
| 2133 | + * @param mixed $value |
|
| 2134 | + * @param mixed $expect |
|
| 2135 | + * @param string $message |
|
| 2136 | + * |
|
| 2137 | + * @throws InvalidArgumentException |
|
| 2138 | + * |
|
| 2139 | + * @return void |
|
| 2140 | + */ |
|
| 2141 | + public static function allNotSame($value, $expect, $message = '') |
|
| 2142 | + { |
|
| 2143 | + static::isIterable($value); |
|
| 2144 | + |
|
| 2145 | + foreach ($value as $entry) { |
|
| 2146 | + static::notSame($entry, $expect, $message); |
|
| 2147 | + } |
|
| 2148 | + } |
|
| 2149 | + |
|
| 2150 | + /** |
|
| 2151 | + * @psalm-pure |
|
| 2152 | + * |
|
| 2153 | + * @param mixed $value |
|
| 2154 | + * @param mixed $expect |
|
| 2155 | + * @param string $message |
|
| 2156 | + * |
|
| 2157 | + * @throws InvalidArgumentException |
|
| 2158 | + * |
|
| 2159 | + * @return void |
|
| 2160 | + */ |
|
| 2161 | + public static function allNullOrNotSame($value, $expect, $message = '') |
|
| 2162 | + { |
|
| 2163 | + static::isIterable($value); |
|
| 2164 | + |
|
| 2165 | + foreach ($value as $entry) { |
|
| 2166 | + null === $entry || static::notSame($entry, $expect, $message); |
|
| 2167 | + } |
|
| 2168 | + } |
|
| 2169 | + |
|
| 2170 | + /** |
|
| 2171 | + * @psalm-pure |
|
| 2172 | + * |
|
| 2173 | + * @param mixed $value |
|
| 2174 | + * @param mixed $limit |
|
| 2175 | + * @param string $message |
|
| 2176 | + * |
|
| 2177 | + * @throws InvalidArgumentException |
|
| 2178 | + * |
|
| 2179 | + * @return void |
|
| 2180 | + */ |
|
| 2181 | + public static function nullOrGreaterThan($value, $limit, $message = '') |
|
| 2182 | + { |
|
| 2183 | + null === $value || static::greaterThan($value, $limit, $message); |
|
| 2184 | + } |
|
| 2185 | + |
|
| 2186 | + /** |
|
| 2187 | + * @psalm-pure |
|
| 2188 | + * |
|
| 2189 | + * @param mixed $value |
|
| 2190 | + * @param mixed $limit |
|
| 2191 | + * @param string $message |
|
| 2192 | + * |
|
| 2193 | + * @throws InvalidArgumentException |
|
| 2194 | + * |
|
| 2195 | + * @return void |
|
| 2196 | + */ |
|
| 2197 | + public static function allGreaterThan($value, $limit, $message = '') |
|
| 2198 | + { |
|
| 2199 | + static::isIterable($value); |
|
| 2200 | + |
|
| 2201 | + foreach ($value as $entry) { |
|
| 2202 | + static::greaterThan($entry, $limit, $message); |
|
| 2203 | + } |
|
| 2204 | + } |
|
| 2205 | + |
|
| 2206 | + /** |
|
| 2207 | + * @psalm-pure |
|
| 2208 | + * |
|
| 2209 | + * @param mixed $value |
|
| 2210 | + * @param mixed $limit |
|
| 2211 | + * @param string $message |
|
| 2212 | + * |
|
| 2213 | + * @throws InvalidArgumentException |
|
| 2214 | + * |
|
| 2215 | + * @return void |
|
| 2216 | + */ |
|
| 2217 | + public static function allNullOrGreaterThan($value, $limit, $message = '') |
|
| 2218 | + { |
|
| 2219 | + static::isIterable($value); |
|
| 2220 | + |
|
| 2221 | + foreach ($value as $entry) { |
|
| 2222 | + null === $entry || static::greaterThan($entry, $limit, $message); |
|
| 2223 | + } |
|
| 2224 | + } |
|
| 2225 | + |
|
| 2226 | + /** |
|
| 2227 | + * @psalm-pure |
|
| 2228 | + * |
|
| 2229 | + * @param mixed $value |
|
| 2230 | + * @param mixed $limit |
|
| 2231 | + * @param string $message |
|
| 2232 | + * |
|
| 2233 | + * @throws InvalidArgumentException |
|
| 2234 | + * |
|
| 2235 | + * @return void |
|
| 2236 | + */ |
|
| 2237 | + public static function nullOrGreaterThanEq($value, $limit, $message = '') |
|
| 2238 | + { |
|
| 2239 | + null === $value || static::greaterThanEq($value, $limit, $message); |
|
| 2240 | + } |
|
| 2241 | + |
|
| 2242 | + /** |
|
| 2243 | + * @psalm-pure |
|
| 2244 | + * |
|
| 2245 | + * @param mixed $value |
|
| 2246 | + * @param mixed $limit |
|
| 2247 | + * @param string $message |
|
| 2248 | + * |
|
| 2249 | + * @throws InvalidArgumentException |
|
| 2250 | + * |
|
| 2251 | + * @return void |
|
| 2252 | + */ |
|
| 2253 | + public static function allGreaterThanEq($value, $limit, $message = '') |
|
| 2254 | + { |
|
| 2255 | + static::isIterable($value); |
|
| 2256 | + |
|
| 2257 | + foreach ($value as $entry) { |
|
| 2258 | + static::greaterThanEq($entry, $limit, $message); |
|
| 2259 | + } |
|
| 2260 | + } |
|
| 2261 | + |
|
| 2262 | + /** |
|
| 2263 | + * @psalm-pure |
|
| 2264 | + * |
|
| 2265 | + * @param mixed $value |
|
| 2266 | + * @param mixed $limit |
|
| 2267 | + * @param string $message |
|
| 2268 | + * |
|
| 2269 | + * @throws InvalidArgumentException |
|
| 2270 | + * |
|
| 2271 | + * @return void |
|
| 2272 | + */ |
|
| 2273 | + public static function allNullOrGreaterThanEq($value, $limit, $message = '') |
|
| 2274 | + { |
|
| 2275 | + static::isIterable($value); |
|
| 2276 | + |
|
| 2277 | + foreach ($value as $entry) { |
|
| 2278 | + null === $entry || static::greaterThanEq($entry, $limit, $message); |
|
| 2279 | + } |
|
| 2280 | + } |
|
| 2281 | + |
|
| 2282 | + /** |
|
| 2283 | + * @psalm-pure |
|
| 2284 | + * |
|
| 2285 | + * @param mixed $value |
|
| 2286 | + * @param mixed $limit |
|
| 2287 | + * @param string $message |
|
| 2288 | + * |
|
| 2289 | + * @throws InvalidArgumentException |
|
| 2290 | + * |
|
| 2291 | + * @return void |
|
| 2292 | + */ |
|
| 2293 | + public static function nullOrLessThan($value, $limit, $message = '') |
|
| 2294 | + { |
|
| 2295 | + null === $value || static::lessThan($value, $limit, $message); |
|
| 2296 | + } |
|
| 2297 | + |
|
| 2298 | + /** |
|
| 2299 | + * @psalm-pure |
|
| 2300 | + * |
|
| 2301 | + * @param mixed $value |
|
| 2302 | + * @param mixed $limit |
|
| 2303 | + * @param string $message |
|
| 2304 | + * |
|
| 2305 | + * @throws InvalidArgumentException |
|
| 2306 | + * |
|
| 2307 | + * @return void |
|
| 2308 | + */ |
|
| 2309 | + public static function allLessThan($value, $limit, $message = '') |
|
| 2310 | + { |
|
| 2311 | + static::isIterable($value); |
|
| 2312 | + |
|
| 2313 | + foreach ($value as $entry) { |
|
| 2314 | + static::lessThan($entry, $limit, $message); |
|
| 2315 | + } |
|
| 2316 | + } |
|
| 2317 | + |
|
| 2318 | + /** |
|
| 2319 | + * @psalm-pure |
|
| 2320 | + * |
|
| 2321 | + * @param mixed $value |
|
| 2322 | + * @param mixed $limit |
|
| 2323 | + * @param string $message |
|
| 2324 | + * |
|
| 2325 | + * @throws InvalidArgumentException |
|
| 2326 | + * |
|
| 2327 | + * @return void |
|
| 2328 | + */ |
|
| 2329 | + public static function allNullOrLessThan($value, $limit, $message = '') |
|
| 2330 | + { |
|
| 2331 | + static::isIterable($value); |
|
| 2332 | + |
|
| 2333 | + foreach ($value as $entry) { |
|
| 2334 | + null === $entry || static::lessThan($entry, $limit, $message); |
|
| 2335 | + } |
|
| 2336 | + } |
|
| 2337 | + |
|
| 2338 | + /** |
|
| 2339 | + * @psalm-pure |
|
| 2340 | + * |
|
| 2341 | + * @param mixed $value |
|
| 2342 | + * @param mixed $limit |
|
| 2343 | + * @param string $message |
|
| 2344 | + * |
|
| 2345 | + * @throws InvalidArgumentException |
|
| 2346 | + * |
|
| 2347 | + * @return void |
|
| 2348 | + */ |
|
| 2349 | + public static function nullOrLessThanEq($value, $limit, $message = '') |
|
| 2350 | + { |
|
| 2351 | + null === $value || static::lessThanEq($value, $limit, $message); |
|
| 2352 | + } |
|
| 2353 | + |
|
| 2354 | + /** |
|
| 2355 | + * @psalm-pure |
|
| 2356 | + * |
|
| 2357 | + * @param mixed $value |
|
| 2358 | + * @param mixed $limit |
|
| 2359 | + * @param string $message |
|
| 2360 | + * |
|
| 2361 | + * @throws InvalidArgumentException |
|
| 2362 | + * |
|
| 2363 | + * @return void |
|
| 2364 | + */ |
|
| 2365 | + public static function allLessThanEq($value, $limit, $message = '') |
|
| 2366 | + { |
|
| 2367 | + static::isIterable($value); |
|
| 2368 | + |
|
| 2369 | + foreach ($value as $entry) { |
|
| 2370 | + static::lessThanEq($entry, $limit, $message); |
|
| 2371 | + } |
|
| 2372 | + } |
|
| 2373 | + |
|
| 2374 | + /** |
|
| 2375 | + * @psalm-pure |
|
| 2376 | + * |
|
| 2377 | + * @param mixed $value |
|
| 2378 | + * @param mixed $limit |
|
| 2379 | + * @param string $message |
|
| 2380 | + * |
|
| 2381 | + * @throws InvalidArgumentException |
|
| 2382 | + * |
|
| 2383 | + * @return void |
|
| 2384 | + */ |
|
| 2385 | + public static function allNullOrLessThanEq($value, $limit, $message = '') |
|
| 2386 | + { |
|
| 2387 | + static::isIterable($value); |
|
| 2388 | + |
|
| 2389 | + foreach ($value as $entry) { |
|
| 2390 | + null === $entry || static::lessThanEq($entry, $limit, $message); |
|
| 2391 | + } |
|
| 2392 | + } |
|
| 2393 | + |
|
| 2394 | + /** |
|
| 2395 | + * @psalm-pure |
|
| 2396 | + * |
|
| 2397 | + * @param mixed $value |
|
| 2398 | + * @param mixed $min |
|
| 2399 | + * @param mixed $max |
|
| 2400 | + * @param string $message |
|
| 2401 | + * |
|
| 2402 | + * @throws InvalidArgumentException |
|
| 2403 | + * |
|
| 2404 | + * @return void |
|
| 2405 | + */ |
|
| 2406 | + public static function nullOrRange($value, $min, $max, $message = '') |
|
| 2407 | + { |
|
| 2408 | + null === $value || static::range($value, $min, $max, $message); |
|
| 2409 | + } |
|
| 2410 | + |
|
| 2411 | + /** |
|
| 2412 | + * @psalm-pure |
|
| 2413 | + * |
|
| 2414 | + * @param mixed $value |
|
| 2415 | + * @param mixed $min |
|
| 2416 | + * @param mixed $max |
|
| 2417 | + * @param string $message |
|
| 2418 | + * |
|
| 2419 | + * @throws InvalidArgumentException |
|
| 2420 | + * |
|
| 2421 | + * @return void |
|
| 2422 | + */ |
|
| 2423 | + public static function allRange($value, $min, $max, $message = '') |
|
| 2424 | + { |
|
| 2425 | + static::isIterable($value); |
|
| 2426 | + |
|
| 2427 | + foreach ($value as $entry) { |
|
| 2428 | + static::range($entry, $min, $max, $message); |
|
| 2429 | + } |
|
| 2430 | + } |
|
| 2431 | + |
|
| 2432 | + /** |
|
| 2433 | + * @psalm-pure |
|
| 2434 | + * |
|
| 2435 | + * @param mixed $value |
|
| 2436 | + * @param mixed $min |
|
| 2437 | + * @param mixed $max |
|
| 2438 | + * @param string $message |
|
| 2439 | + * |
|
| 2440 | + * @throws InvalidArgumentException |
|
| 2441 | + * |
|
| 2442 | + * @return void |
|
| 2443 | + */ |
|
| 2444 | + public static function allNullOrRange($value, $min, $max, $message = '') |
|
| 2445 | + { |
|
| 2446 | + static::isIterable($value); |
|
| 2447 | + |
|
| 2448 | + foreach ($value as $entry) { |
|
| 2449 | + null === $entry || static::range($entry, $min, $max, $message); |
|
| 2450 | + } |
|
| 2451 | + } |
|
| 2452 | + |
|
| 2453 | + /** |
|
| 2454 | + * @psalm-pure |
|
| 2455 | + * |
|
| 2456 | + * @param mixed $value |
|
| 2457 | + * @param array $values |
|
| 2458 | + * @param string $message |
|
| 2459 | + * |
|
| 2460 | + * @throws InvalidArgumentException |
|
| 2461 | + * |
|
| 2462 | + * @return void |
|
| 2463 | + */ |
|
| 2464 | + public static function nullOrOneOf($value, $values, $message = '') |
|
| 2465 | + { |
|
| 2466 | + null === $value || static::oneOf($value, $values, $message); |
|
| 2467 | + } |
|
| 2468 | + |
|
| 2469 | + /** |
|
| 2470 | + * @psalm-pure |
|
| 2471 | + * |
|
| 2472 | + * @param mixed $value |
|
| 2473 | + * @param array $values |
|
| 2474 | + * @param string $message |
|
| 2475 | + * |
|
| 2476 | + * @throws InvalidArgumentException |
|
| 2477 | + * |
|
| 2478 | + * @return void |
|
| 2479 | + */ |
|
| 2480 | + public static function allOneOf($value, $values, $message = '') |
|
| 2481 | + { |
|
| 2482 | + static::isIterable($value); |
|
| 2483 | + |
|
| 2484 | + foreach ($value as $entry) { |
|
| 2485 | + static::oneOf($entry, $values, $message); |
|
| 2486 | + } |
|
| 2487 | + } |
|
| 2488 | + |
|
| 2489 | + /** |
|
| 2490 | + * @psalm-pure |
|
| 2491 | + * |
|
| 2492 | + * @param mixed $value |
|
| 2493 | + * @param array $values |
|
| 2494 | + * @param string $message |
|
| 2495 | + * |
|
| 2496 | + * @throws InvalidArgumentException |
|
| 2497 | + * |
|
| 2498 | + * @return void |
|
| 2499 | + */ |
|
| 2500 | + public static function allNullOrOneOf($value, $values, $message = '') |
|
| 2501 | + { |
|
| 2502 | + static::isIterable($value); |
|
| 2503 | + |
|
| 2504 | + foreach ($value as $entry) { |
|
| 2505 | + null === $entry || static::oneOf($entry, $values, $message); |
|
| 2506 | + } |
|
| 2507 | + } |
|
| 2508 | + |
|
| 2509 | + /** |
|
| 2510 | + * @psalm-pure |
|
| 2511 | + * |
|
| 2512 | + * @param mixed $value |
|
| 2513 | + * @param array $values |
|
| 2514 | + * @param string $message |
|
| 2515 | + * |
|
| 2516 | + * @throws InvalidArgumentException |
|
| 2517 | + * |
|
| 2518 | + * @return void |
|
| 2519 | + */ |
|
| 2520 | + public static function nullOrInArray($value, $values, $message = '') |
|
| 2521 | + { |
|
| 2522 | + null === $value || static::inArray($value, $values, $message); |
|
| 2523 | + } |
|
| 2524 | + |
|
| 2525 | + /** |
|
| 2526 | + * @psalm-pure |
|
| 2527 | + * |
|
| 2528 | + * @param mixed $value |
|
| 2529 | + * @param array $values |
|
| 2530 | + * @param string $message |
|
| 2531 | + * |
|
| 2532 | + * @throws InvalidArgumentException |
|
| 2533 | + * |
|
| 2534 | + * @return void |
|
| 2535 | + */ |
|
| 2536 | + public static function allInArray($value, $values, $message = '') |
|
| 2537 | + { |
|
| 2538 | + static::isIterable($value); |
|
| 2539 | + |
|
| 2540 | + foreach ($value as $entry) { |
|
| 2541 | + static::inArray($entry, $values, $message); |
|
| 2542 | + } |
|
| 2543 | + } |
|
| 2544 | + |
|
| 2545 | + /** |
|
| 2546 | + * @psalm-pure |
|
| 2547 | + * |
|
| 2548 | + * @param mixed $value |
|
| 2549 | + * @param array $values |
|
| 2550 | + * @param string $message |
|
| 2551 | + * |
|
| 2552 | + * @throws InvalidArgumentException |
|
| 2553 | + * |
|
| 2554 | + * @return void |
|
| 2555 | + */ |
|
| 2556 | + public static function allNullOrInArray($value, $values, $message = '') |
|
| 2557 | + { |
|
| 2558 | + static::isIterable($value); |
|
| 2559 | + |
|
| 2560 | + foreach ($value as $entry) { |
|
| 2561 | + null === $entry || static::inArray($entry, $values, $message); |
|
| 2562 | + } |
|
| 2563 | + } |
|
| 2564 | + |
|
| 2565 | + /** |
|
| 2566 | + * @psalm-pure |
|
| 2567 | + * |
|
| 2568 | + * @param string|null $value |
|
| 2569 | + * @param string $subString |
|
| 2570 | + * @param string $message |
|
| 2571 | + * |
|
| 2572 | + * @throws InvalidArgumentException |
|
| 2573 | + * |
|
| 2574 | + * @return void |
|
| 2575 | + */ |
|
| 2576 | + public static function nullOrContains($value, $subString, $message = '') |
|
| 2577 | + { |
|
| 2578 | + null === $value || static::contains($value, $subString, $message); |
|
| 2579 | + } |
|
| 2580 | + |
|
| 2581 | + /** |
|
| 2582 | + * @psalm-pure |
|
| 2583 | + * |
|
| 2584 | + * @param iterable<string> $value |
|
| 2585 | + * @param string $subString |
|
| 2586 | + * @param string $message |
|
| 2587 | + * |
|
| 2588 | + * @throws InvalidArgumentException |
|
| 2589 | + * |
|
| 2590 | + * @return void |
|
| 2591 | + */ |
|
| 2592 | + public static function allContains($value, $subString, $message = '') |
|
| 2593 | + { |
|
| 2594 | + static::isIterable($value); |
|
| 2595 | + |
|
| 2596 | + foreach ($value as $entry) { |
|
| 2597 | + static::contains($entry, $subString, $message); |
|
| 2598 | + } |
|
| 2599 | + } |
|
| 2600 | + |
|
| 2601 | + /** |
|
| 2602 | + * @psalm-pure |
|
| 2603 | + * |
|
| 2604 | + * @param iterable<string|null> $value |
|
| 2605 | + * @param string $subString |
|
| 2606 | + * @param string $message |
|
| 2607 | + * |
|
| 2608 | + * @throws InvalidArgumentException |
|
| 2609 | + * |
|
| 2610 | + * @return void |
|
| 2611 | + */ |
|
| 2612 | + public static function allNullOrContains($value, $subString, $message = '') |
|
| 2613 | + { |
|
| 2614 | + static::isIterable($value); |
|
| 2615 | + |
|
| 2616 | + foreach ($value as $entry) { |
|
| 2617 | + null === $entry || static::contains($entry, $subString, $message); |
|
| 2618 | + } |
|
| 2619 | + } |
|
| 2620 | + |
|
| 2621 | + /** |
|
| 2622 | + * @psalm-pure |
|
| 2623 | + * |
|
| 2624 | + * @param string|null $value |
|
| 2625 | + * @param string $subString |
|
| 2626 | + * @param string $message |
|
| 2627 | + * |
|
| 2628 | + * @throws InvalidArgumentException |
|
| 2629 | + * |
|
| 2630 | + * @return void |
|
| 2631 | + */ |
|
| 2632 | + public static function nullOrNotContains($value, $subString, $message = '') |
|
| 2633 | + { |
|
| 2634 | + null === $value || static::notContains($value, $subString, $message); |
|
| 2635 | + } |
|
| 2636 | + |
|
| 2637 | + /** |
|
| 2638 | + * @psalm-pure |
|
| 2639 | + * |
|
| 2640 | + * @param iterable<string> $value |
|
| 2641 | + * @param string $subString |
|
| 2642 | + * @param string $message |
|
| 2643 | + * |
|
| 2644 | + * @throws InvalidArgumentException |
|
| 2645 | + * |
|
| 2646 | + * @return void |
|
| 2647 | + */ |
|
| 2648 | + public static function allNotContains($value, $subString, $message = '') |
|
| 2649 | + { |
|
| 2650 | + static::isIterable($value); |
|
| 2651 | + |
|
| 2652 | + foreach ($value as $entry) { |
|
| 2653 | + static::notContains($entry, $subString, $message); |
|
| 2654 | + } |
|
| 2655 | + } |
|
| 2656 | + |
|
| 2657 | + /** |
|
| 2658 | + * @psalm-pure |
|
| 2659 | + * |
|
| 2660 | + * @param iterable<string|null> $value |
|
| 2661 | + * @param string $subString |
|
| 2662 | + * @param string $message |
|
| 2663 | + * |
|
| 2664 | + * @throws InvalidArgumentException |
|
| 2665 | + * |
|
| 2666 | + * @return void |
|
| 2667 | + */ |
|
| 2668 | + public static function allNullOrNotContains($value, $subString, $message = '') |
|
| 2669 | + { |
|
| 2670 | + static::isIterable($value); |
|
| 2671 | + |
|
| 2672 | + foreach ($value as $entry) { |
|
| 2673 | + null === $entry || static::notContains($entry, $subString, $message); |
|
| 2674 | + } |
|
| 2675 | + } |
|
| 2676 | + |
|
| 2677 | + /** |
|
| 2678 | + * @psalm-pure |
|
| 2679 | + * |
|
| 2680 | + * @param string|null $value |
|
| 2681 | + * @param string $message |
|
| 2682 | + * |
|
| 2683 | + * @throws InvalidArgumentException |
|
| 2684 | + * |
|
| 2685 | + * @return void |
|
| 2686 | + */ |
|
| 2687 | + public static function nullOrNotWhitespaceOnly($value, $message = '') |
|
| 2688 | + { |
|
| 2689 | + null === $value || static::notWhitespaceOnly($value, $message); |
|
| 2690 | + } |
|
| 2691 | + |
|
| 2692 | + /** |
|
| 2693 | + * @psalm-pure |
|
| 2694 | + * |
|
| 2695 | + * @param iterable<string> $value |
|
| 2696 | + * @param string $message |
|
| 2697 | + * |
|
| 2698 | + * @throws InvalidArgumentException |
|
| 2699 | + * |
|
| 2700 | + * @return void |
|
| 2701 | + */ |
|
| 2702 | + public static function allNotWhitespaceOnly($value, $message = '') |
|
| 2703 | + { |
|
| 2704 | + static::isIterable($value); |
|
| 2705 | + |
|
| 2706 | + foreach ($value as $entry) { |
|
| 2707 | + static::notWhitespaceOnly($entry, $message); |
|
| 2708 | + } |
|
| 2709 | + } |
|
| 2710 | + |
|
| 2711 | + /** |
|
| 2712 | + * @psalm-pure |
|
| 2713 | + * |
|
| 2714 | + * @param iterable<string|null> $value |
|
| 2715 | + * @param string $message |
|
| 2716 | + * |
|
| 2717 | + * @throws InvalidArgumentException |
|
| 2718 | + * |
|
| 2719 | + * @return void |
|
| 2720 | + */ |
|
| 2721 | + public static function allNullOrNotWhitespaceOnly($value, $message = '') |
|
| 2722 | + { |
|
| 2723 | + static::isIterable($value); |
|
| 2724 | + |
|
| 2725 | + foreach ($value as $entry) { |
|
| 2726 | + null === $entry || static::notWhitespaceOnly($entry, $message); |
|
| 2727 | + } |
|
| 2728 | + } |
|
| 2729 | + |
|
| 2730 | + /** |
|
| 2731 | + * @psalm-pure |
|
| 2732 | + * |
|
| 2733 | + * @param string|null $value |
|
| 2734 | + * @param string $prefix |
|
| 2735 | + * @param string $message |
|
| 2736 | + * |
|
| 2737 | + * @throws InvalidArgumentException |
|
| 2738 | + * |
|
| 2739 | + * @return void |
|
| 2740 | + */ |
|
| 2741 | + public static function nullOrStartsWith($value, $prefix, $message = '') |
|
| 2742 | + { |
|
| 2743 | + null === $value || static::startsWith($value, $prefix, $message); |
|
| 2744 | + } |
|
| 2745 | + |
|
| 2746 | + /** |
|
| 2747 | + * @psalm-pure |
|
| 2748 | + * |
|
| 2749 | + * @param iterable<string> $value |
|
| 2750 | + * @param string $prefix |
|
| 2751 | + * @param string $message |
|
| 2752 | + * |
|
| 2753 | + * @throws InvalidArgumentException |
|
| 2754 | + * |
|
| 2755 | + * @return void |
|
| 2756 | + */ |
|
| 2757 | + public static function allStartsWith($value, $prefix, $message = '') |
|
| 2758 | + { |
|
| 2759 | + static::isIterable($value); |
|
| 2760 | + |
|
| 2761 | + foreach ($value as $entry) { |
|
| 2762 | + static::startsWith($entry, $prefix, $message); |
|
| 2763 | + } |
|
| 2764 | + } |
|
| 2765 | + |
|
| 2766 | + /** |
|
| 2767 | + * @psalm-pure |
|
| 2768 | + * |
|
| 2769 | + * @param iterable<string|null> $value |
|
| 2770 | + * @param string $prefix |
|
| 2771 | + * @param string $message |
|
| 2772 | + * |
|
| 2773 | + * @throws InvalidArgumentException |
|
| 2774 | + * |
|
| 2775 | + * @return void |
|
| 2776 | + */ |
|
| 2777 | + public static function allNullOrStartsWith($value, $prefix, $message = '') |
|
| 2778 | + { |
|
| 2779 | + static::isIterable($value); |
|
| 2780 | + |
|
| 2781 | + foreach ($value as $entry) { |
|
| 2782 | + null === $entry || static::startsWith($entry, $prefix, $message); |
|
| 2783 | + } |
|
| 2784 | + } |
|
| 2785 | + |
|
| 2786 | + /** |
|
| 2787 | + * @psalm-pure |
|
| 2788 | + * |
|
| 2789 | + * @param string|null $value |
|
| 2790 | + * @param string $prefix |
|
| 2791 | + * @param string $message |
|
| 2792 | + * |
|
| 2793 | + * @throws InvalidArgumentException |
|
| 2794 | + * |
|
| 2795 | + * @return void |
|
| 2796 | + */ |
|
| 2797 | + public static function nullOrNotStartsWith($value, $prefix, $message = '') |
|
| 2798 | + { |
|
| 2799 | + null === $value || static::notStartsWith($value, $prefix, $message); |
|
| 2800 | + } |
|
| 2801 | + |
|
| 2802 | + /** |
|
| 2803 | + * @psalm-pure |
|
| 2804 | + * |
|
| 2805 | + * @param iterable<string> $value |
|
| 2806 | + * @param string $prefix |
|
| 2807 | + * @param string $message |
|
| 2808 | + * |
|
| 2809 | + * @throws InvalidArgumentException |
|
| 2810 | + * |
|
| 2811 | + * @return void |
|
| 2812 | + */ |
|
| 2813 | + public static function allNotStartsWith($value, $prefix, $message = '') |
|
| 2814 | + { |
|
| 2815 | + static::isIterable($value); |
|
| 2816 | + |
|
| 2817 | + foreach ($value as $entry) { |
|
| 2818 | + static::notStartsWith($entry, $prefix, $message); |
|
| 2819 | + } |
|
| 2820 | + } |
|
| 2821 | + |
|
| 2822 | + /** |
|
| 2823 | + * @psalm-pure |
|
| 2824 | + * |
|
| 2825 | + * @param iterable<string|null> $value |
|
| 2826 | + * @param string $prefix |
|
| 2827 | + * @param string $message |
|
| 2828 | + * |
|
| 2829 | + * @throws InvalidArgumentException |
|
| 2830 | + * |
|
| 2831 | + * @return void |
|
| 2832 | + */ |
|
| 2833 | + public static function allNullOrNotStartsWith($value, $prefix, $message = '') |
|
| 2834 | + { |
|
| 2835 | + static::isIterable($value); |
|
| 2836 | + |
|
| 2837 | + foreach ($value as $entry) { |
|
| 2838 | + null === $entry || static::notStartsWith($entry, $prefix, $message); |
|
| 2839 | + } |
|
| 2840 | + } |
|
| 2841 | + |
|
| 2842 | + /** |
|
| 2843 | + * @psalm-pure |
|
| 2844 | + * |
|
| 2845 | + * @param mixed $value |
|
| 2846 | + * @param string $message |
|
| 2847 | + * |
|
| 2848 | + * @throws InvalidArgumentException |
|
| 2849 | + * |
|
| 2850 | + * @return void |
|
| 2851 | + */ |
|
| 2852 | + public static function nullOrStartsWithLetter($value, $message = '') |
|
| 2853 | + { |
|
| 2854 | + null === $value || static::startsWithLetter($value, $message); |
|
| 2855 | + } |
|
| 2856 | + |
|
| 2857 | + /** |
|
| 2858 | + * @psalm-pure |
|
| 2859 | + * |
|
| 2860 | + * @param mixed $value |
|
| 2861 | + * @param string $message |
|
| 2862 | + * |
|
| 2863 | + * @throws InvalidArgumentException |
|
| 2864 | + * |
|
| 2865 | + * @return void |
|
| 2866 | + */ |
|
| 2867 | + public static function allStartsWithLetter($value, $message = '') |
|
| 2868 | + { |
|
| 2869 | + static::isIterable($value); |
|
| 2870 | + |
|
| 2871 | + foreach ($value as $entry) { |
|
| 2872 | + static::startsWithLetter($entry, $message); |
|
| 2873 | + } |
|
| 2874 | + } |
|
| 2875 | + |
|
| 2876 | + /** |
|
| 2877 | + * @psalm-pure |
|
| 2878 | + * |
|
| 2879 | + * @param mixed $value |
|
| 2880 | + * @param string $message |
|
| 2881 | + * |
|
| 2882 | + * @throws InvalidArgumentException |
|
| 2883 | + * |
|
| 2884 | + * @return void |
|
| 2885 | + */ |
|
| 2886 | + public static function allNullOrStartsWithLetter($value, $message = '') |
|
| 2887 | + { |
|
| 2888 | + static::isIterable($value); |
|
| 2889 | + |
|
| 2890 | + foreach ($value as $entry) { |
|
| 2891 | + null === $entry || static::startsWithLetter($entry, $message); |
|
| 2892 | + } |
|
| 2893 | + } |
|
| 2894 | + |
|
| 2895 | + /** |
|
| 2896 | + * @psalm-pure |
|
| 2897 | + * |
|
| 2898 | + * @param string|null $value |
|
| 2899 | + * @param string $suffix |
|
| 2900 | + * @param string $message |
|
| 2901 | + * |
|
| 2902 | + * @throws InvalidArgumentException |
|
| 2903 | + * |
|
| 2904 | + * @return void |
|
| 2905 | + */ |
|
| 2906 | + public static function nullOrEndsWith($value, $suffix, $message = '') |
|
| 2907 | + { |
|
| 2908 | + null === $value || static::endsWith($value, $suffix, $message); |
|
| 2909 | + } |
|
| 2910 | + |
|
| 2911 | + /** |
|
| 2912 | + * @psalm-pure |
|
| 2913 | + * |
|
| 2914 | + * @param iterable<string> $value |
|
| 2915 | + * @param string $suffix |
|
| 2916 | + * @param string $message |
|
| 2917 | + * |
|
| 2918 | + * @throws InvalidArgumentException |
|
| 2919 | + * |
|
| 2920 | + * @return void |
|
| 2921 | + */ |
|
| 2922 | + public static function allEndsWith($value, $suffix, $message = '') |
|
| 2923 | + { |
|
| 2924 | + static::isIterable($value); |
|
| 2925 | + |
|
| 2926 | + foreach ($value as $entry) { |
|
| 2927 | + static::endsWith($entry, $suffix, $message); |
|
| 2928 | + } |
|
| 2929 | + } |
|
| 2930 | + |
|
| 2931 | + /** |
|
| 2932 | + * @psalm-pure |
|
| 2933 | + * |
|
| 2934 | + * @param iterable<string|null> $value |
|
| 2935 | + * @param string $suffix |
|
| 2936 | + * @param string $message |
|
| 2937 | + * |
|
| 2938 | + * @throws InvalidArgumentException |
|
| 2939 | + * |
|
| 2940 | + * @return void |
|
| 2941 | + */ |
|
| 2942 | + public static function allNullOrEndsWith($value, $suffix, $message = '') |
|
| 2943 | + { |
|
| 2944 | + static::isIterable($value); |
|
| 2945 | + |
|
| 2946 | + foreach ($value as $entry) { |
|
| 2947 | + null === $entry || static::endsWith($entry, $suffix, $message); |
|
| 2948 | + } |
|
| 2949 | + } |
|
| 2950 | + |
|
| 2951 | + /** |
|
| 2952 | + * @psalm-pure |
|
| 2953 | + * |
|
| 2954 | + * @param string|null $value |
|
| 2955 | + * @param string $suffix |
|
| 2956 | + * @param string $message |
|
| 2957 | + * |
|
| 2958 | + * @throws InvalidArgumentException |
|
| 2959 | + * |
|
| 2960 | + * @return void |
|
| 2961 | + */ |
|
| 2962 | + public static function nullOrNotEndsWith($value, $suffix, $message = '') |
|
| 2963 | + { |
|
| 2964 | + null === $value || static::notEndsWith($value, $suffix, $message); |
|
| 2965 | + } |
|
| 2966 | + |
|
| 2967 | + /** |
|
| 2968 | + * @psalm-pure |
|
| 2969 | + * |
|
| 2970 | + * @param iterable<string> $value |
|
| 2971 | + * @param string $suffix |
|
| 2972 | + * @param string $message |
|
| 2973 | + * |
|
| 2974 | + * @throws InvalidArgumentException |
|
| 2975 | + * |
|
| 2976 | + * @return void |
|
| 2977 | + */ |
|
| 2978 | + public static function allNotEndsWith($value, $suffix, $message = '') |
|
| 2979 | + { |
|
| 2980 | + static::isIterable($value); |
|
| 2981 | + |
|
| 2982 | + foreach ($value as $entry) { |
|
| 2983 | + static::notEndsWith($entry, $suffix, $message); |
|
| 2984 | + } |
|
| 2985 | + } |
|
| 2986 | + |
|
| 2987 | + /** |
|
| 2988 | + * @psalm-pure |
|
| 2989 | + * |
|
| 2990 | + * @param iterable<string|null> $value |
|
| 2991 | + * @param string $suffix |
|
| 2992 | + * @param string $message |
|
| 2993 | + * |
|
| 2994 | + * @throws InvalidArgumentException |
|
| 2995 | + * |
|
| 2996 | + * @return void |
|
| 2997 | + */ |
|
| 2998 | + public static function allNullOrNotEndsWith($value, $suffix, $message = '') |
|
| 2999 | + { |
|
| 3000 | + static::isIterable($value); |
|
| 3001 | + |
|
| 3002 | + foreach ($value as $entry) { |
|
| 3003 | + null === $entry || static::notEndsWith($entry, $suffix, $message); |
|
| 3004 | + } |
|
| 3005 | + } |
|
| 3006 | + |
|
| 3007 | + /** |
|
| 3008 | + * @psalm-pure |
|
| 3009 | + * |
|
| 3010 | + * @param string|null $value |
|
| 3011 | + * @param string $pattern |
|
| 3012 | + * @param string $message |
|
| 3013 | + * |
|
| 3014 | + * @throws InvalidArgumentException |
|
| 3015 | + * |
|
| 3016 | + * @return void |
|
| 3017 | + */ |
|
| 3018 | + public static function nullOrRegex($value, $pattern, $message = '') |
|
| 3019 | + { |
|
| 3020 | + null === $value || static::regex($value, $pattern, $message); |
|
| 3021 | + } |
|
| 3022 | + |
|
| 3023 | + /** |
|
| 3024 | + * @psalm-pure |
|
| 3025 | + * |
|
| 3026 | + * @param iterable<string> $value |
|
| 3027 | + * @param string $pattern |
|
| 3028 | + * @param string $message |
|
| 3029 | + * |
|
| 3030 | + * @throws InvalidArgumentException |
|
| 3031 | + * |
|
| 3032 | + * @return void |
|
| 3033 | + */ |
|
| 3034 | + public static function allRegex($value, $pattern, $message = '') |
|
| 3035 | + { |
|
| 3036 | + static::isIterable($value); |
|
| 3037 | + |
|
| 3038 | + foreach ($value as $entry) { |
|
| 3039 | + static::regex($entry, $pattern, $message); |
|
| 3040 | + } |
|
| 3041 | + } |
|
| 3042 | + |
|
| 3043 | + /** |
|
| 3044 | + * @psalm-pure |
|
| 3045 | + * |
|
| 3046 | + * @param iterable<string|null> $value |
|
| 3047 | + * @param string $pattern |
|
| 3048 | + * @param string $message |
|
| 3049 | + * |
|
| 3050 | + * @throws InvalidArgumentException |
|
| 3051 | + * |
|
| 3052 | + * @return void |
|
| 3053 | + */ |
|
| 3054 | + public static function allNullOrRegex($value, $pattern, $message = '') |
|
| 3055 | + { |
|
| 3056 | + static::isIterable($value); |
|
| 3057 | + |
|
| 3058 | + foreach ($value as $entry) { |
|
| 3059 | + null === $entry || static::regex($entry, $pattern, $message); |
|
| 3060 | + } |
|
| 3061 | + } |
|
| 3062 | + |
|
| 3063 | + /** |
|
| 3064 | + * @psalm-pure |
|
| 3065 | + * |
|
| 3066 | + * @param string|null $value |
|
| 3067 | + * @param string $pattern |
|
| 3068 | + * @param string $message |
|
| 3069 | + * |
|
| 3070 | + * @throws InvalidArgumentException |
|
| 3071 | + * |
|
| 3072 | + * @return void |
|
| 3073 | + */ |
|
| 3074 | + public static function nullOrNotRegex($value, $pattern, $message = '') |
|
| 3075 | + { |
|
| 3076 | + null === $value || static::notRegex($value, $pattern, $message); |
|
| 3077 | + } |
|
| 3078 | + |
|
| 3079 | + /** |
|
| 3080 | + * @psalm-pure |
|
| 3081 | + * |
|
| 3082 | + * @param iterable<string> $value |
|
| 3083 | + * @param string $pattern |
|
| 3084 | + * @param string $message |
|
| 3085 | + * |
|
| 3086 | + * @throws InvalidArgumentException |
|
| 3087 | + * |
|
| 3088 | + * @return void |
|
| 3089 | + */ |
|
| 3090 | + public static function allNotRegex($value, $pattern, $message = '') |
|
| 3091 | + { |
|
| 3092 | + static::isIterable($value); |
|
| 3093 | + |
|
| 3094 | + foreach ($value as $entry) { |
|
| 3095 | + static::notRegex($entry, $pattern, $message); |
|
| 3096 | + } |
|
| 3097 | + } |
|
| 3098 | + |
|
| 3099 | + /** |
|
| 3100 | + * @psalm-pure |
|
| 3101 | + * |
|
| 3102 | + * @param iterable<string|null> $value |
|
| 3103 | + * @param string $pattern |
|
| 3104 | + * @param string $message |
|
| 3105 | + * |
|
| 3106 | + * @throws InvalidArgumentException |
|
| 3107 | + * |
|
| 3108 | + * @return void |
|
| 3109 | + */ |
|
| 3110 | + public static function allNullOrNotRegex($value, $pattern, $message = '') |
|
| 3111 | + { |
|
| 3112 | + static::isIterable($value); |
|
| 3113 | + |
|
| 3114 | + foreach ($value as $entry) { |
|
| 3115 | + null === $entry || static::notRegex($entry, $pattern, $message); |
|
| 3116 | + } |
|
| 3117 | + } |
|
| 3118 | + |
|
| 3119 | + /** |
|
| 3120 | + * @psalm-pure |
|
| 3121 | + * |
|
| 3122 | + * @param mixed $value |
|
| 3123 | + * @param string $message |
|
| 3124 | + * |
|
| 3125 | + * @throws InvalidArgumentException |
|
| 3126 | + * |
|
| 3127 | + * @return void |
|
| 3128 | + */ |
|
| 3129 | + public static function nullOrUnicodeLetters($value, $message = '') |
|
| 3130 | + { |
|
| 3131 | + null === $value || static::unicodeLetters($value, $message); |
|
| 3132 | + } |
|
| 3133 | + |
|
| 3134 | + /** |
|
| 3135 | + * @psalm-pure |
|
| 3136 | + * |
|
| 3137 | + * @param mixed $value |
|
| 3138 | + * @param string $message |
|
| 3139 | + * |
|
| 3140 | + * @throws InvalidArgumentException |
|
| 3141 | + * |
|
| 3142 | + * @return void |
|
| 3143 | + */ |
|
| 3144 | + public static function allUnicodeLetters($value, $message = '') |
|
| 3145 | + { |
|
| 3146 | + static::isIterable($value); |
|
| 3147 | + |
|
| 3148 | + foreach ($value as $entry) { |
|
| 3149 | + static::unicodeLetters($entry, $message); |
|
| 3150 | + } |
|
| 3151 | + } |
|
| 3152 | + |
|
| 3153 | + /** |
|
| 3154 | + * @psalm-pure |
|
| 3155 | + * |
|
| 3156 | + * @param mixed $value |
|
| 3157 | + * @param string $message |
|
| 3158 | + * |
|
| 3159 | + * @throws InvalidArgumentException |
|
| 3160 | + * |
|
| 3161 | + * @return void |
|
| 3162 | + */ |
|
| 3163 | + public static function allNullOrUnicodeLetters($value, $message = '') |
|
| 3164 | + { |
|
| 3165 | + static::isIterable($value); |
|
| 3166 | + |
|
| 3167 | + foreach ($value as $entry) { |
|
| 3168 | + null === $entry || static::unicodeLetters($entry, $message); |
|
| 3169 | + } |
|
| 3170 | + } |
|
| 3171 | + |
|
| 3172 | + /** |
|
| 3173 | + * @psalm-pure |
|
| 3174 | + * |
|
| 3175 | + * @param mixed $value |
|
| 3176 | + * @param string $message |
|
| 3177 | + * |
|
| 3178 | + * @throws InvalidArgumentException |
|
| 3179 | + * |
|
| 3180 | + * @return void |
|
| 3181 | + */ |
|
| 3182 | + public static function nullOrAlpha($value, $message = '') |
|
| 3183 | + { |
|
| 3184 | + null === $value || static::alpha($value, $message); |
|
| 3185 | + } |
|
| 3186 | + |
|
| 3187 | + /** |
|
| 3188 | + * @psalm-pure |
|
| 3189 | + * |
|
| 3190 | + * @param mixed $value |
|
| 3191 | + * @param string $message |
|
| 3192 | + * |
|
| 3193 | + * @throws InvalidArgumentException |
|
| 3194 | + * |
|
| 3195 | + * @return void |
|
| 3196 | + */ |
|
| 3197 | + public static function allAlpha($value, $message = '') |
|
| 3198 | + { |
|
| 3199 | + static::isIterable($value); |
|
| 3200 | + |
|
| 3201 | + foreach ($value as $entry) { |
|
| 3202 | + static::alpha($entry, $message); |
|
| 3203 | + } |
|
| 3204 | + } |
|
| 3205 | + |
|
| 3206 | + /** |
|
| 3207 | + * @psalm-pure |
|
| 3208 | + * |
|
| 3209 | + * @param mixed $value |
|
| 3210 | + * @param string $message |
|
| 3211 | + * |
|
| 3212 | + * @throws InvalidArgumentException |
|
| 3213 | + * |
|
| 3214 | + * @return void |
|
| 3215 | + */ |
|
| 3216 | + public static function allNullOrAlpha($value, $message = '') |
|
| 3217 | + { |
|
| 3218 | + static::isIterable($value); |
|
| 3219 | + |
|
| 3220 | + foreach ($value as $entry) { |
|
| 3221 | + null === $entry || static::alpha($entry, $message); |
|
| 3222 | + } |
|
| 3223 | + } |
|
| 3224 | + |
|
| 3225 | + /** |
|
| 3226 | + * @psalm-pure |
|
| 3227 | + * |
|
| 3228 | + * @param string|null $value |
|
| 3229 | + * @param string $message |
|
| 3230 | + * |
|
| 3231 | + * @throws InvalidArgumentException |
|
| 3232 | + * |
|
| 3233 | + * @return void |
|
| 3234 | + */ |
|
| 3235 | + public static function nullOrDigits($value, $message = '') |
|
| 3236 | + { |
|
| 3237 | + null === $value || static::digits($value, $message); |
|
| 3238 | + } |
|
| 3239 | + |
|
| 3240 | + /** |
|
| 3241 | + * @psalm-pure |
|
| 3242 | + * |
|
| 3243 | + * @param iterable<string> $value |
|
| 3244 | + * @param string $message |
|
| 3245 | + * |
|
| 3246 | + * @throws InvalidArgumentException |
|
| 3247 | + * |
|
| 3248 | + * @return void |
|
| 3249 | + */ |
|
| 3250 | + public static function allDigits($value, $message = '') |
|
| 3251 | + { |
|
| 3252 | + static::isIterable($value); |
|
| 3253 | + |
|
| 3254 | + foreach ($value as $entry) { |
|
| 3255 | + static::digits($entry, $message); |
|
| 3256 | + } |
|
| 3257 | + } |
|
| 3258 | + |
|
| 3259 | + /** |
|
| 3260 | + * @psalm-pure |
|
| 3261 | + * |
|
| 3262 | + * @param iterable<string|null> $value |
|
| 3263 | + * @param string $message |
|
| 3264 | + * |
|
| 3265 | + * @throws InvalidArgumentException |
|
| 3266 | + * |
|
| 3267 | + * @return void |
|
| 3268 | + */ |
|
| 3269 | + public static function allNullOrDigits($value, $message = '') |
|
| 3270 | + { |
|
| 3271 | + static::isIterable($value); |
|
| 3272 | + |
|
| 3273 | + foreach ($value as $entry) { |
|
| 3274 | + null === $entry || static::digits($entry, $message); |
|
| 3275 | + } |
|
| 3276 | + } |
|
| 3277 | + |
|
| 3278 | + /** |
|
| 3279 | + * @psalm-pure |
|
| 3280 | + * |
|
| 3281 | + * @param string|null $value |
|
| 3282 | + * @param string $message |
|
| 3283 | + * |
|
| 3284 | + * @throws InvalidArgumentException |
|
| 3285 | + * |
|
| 3286 | + * @return void |
|
| 3287 | + */ |
|
| 3288 | + public static function nullOrAlnum($value, $message = '') |
|
| 3289 | + { |
|
| 3290 | + null === $value || static::alnum($value, $message); |
|
| 3291 | + } |
|
| 3292 | + |
|
| 3293 | + /** |
|
| 3294 | + * @psalm-pure |
|
| 3295 | + * |
|
| 3296 | + * @param iterable<string> $value |
|
| 3297 | + * @param string $message |
|
| 3298 | + * |
|
| 3299 | + * @throws InvalidArgumentException |
|
| 3300 | + * |
|
| 3301 | + * @return void |
|
| 3302 | + */ |
|
| 3303 | + public static function allAlnum($value, $message = '') |
|
| 3304 | + { |
|
| 3305 | + static::isIterable($value); |
|
| 3306 | + |
|
| 3307 | + foreach ($value as $entry) { |
|
| 3308 | + static::alnum($entry, $message); |
|
| 3309 | + } |
|
| 3310 | + } |
|
| 3311 | + |
|
| 3312 | + /** |
|
| 3313 | + * @psalm-pure |
|
| 3314 | + * |
|
| 3315 | + * @param iterable<string|null> $value |
|
| 3316 | + * @param string $message |
|
| 3317 | + * |
|
| 3318 | + * @throws InvalidArgumentException |
|
| 3319 | + * |
|
| 3320 | + * @return void |
|
| 3321 | + */ |
|
| 3322 | + public static function allNullOrAlnum($value, $message = '') |
|
| 3323 | + { |
|
| 3324 | + static::isIterable($value); |
|
| 3325 | + |
|
| 3326 | + foreach ($value as $entry) { |
|
| 3327 | + null === $entry || static::alnum($entry, $message); |
|
| 3328 | + } |
|
| 3329 | + } |
|
| 3330 | + |
|
| 3331 | + /** |
|
| 3332 | + * @psalm-pure |
|
| 3333 | + * @psalm-assert lowercase-string|null $value |
|
| 3334 | + * |
|
| 3335 | + * @param string|null $value |
|
| 3336 | + * @param string $message |
|
| 3337 | + * |
|
| 3338 | + * @throws InvalidArgumentException |
|
| 3339 | + * |
|
| 3340 | + * @return void |
|
| 3341 | + */ |
|
| 3342 | + public static function nullOrLower($value, $message = '') |
|
| 3343 | + { |
|
| 3344 | + null === $value || static::lower($value, $message); |
|
| 3345 | + } |
|
| 3346 | + |
|
| 3347 | + /** |
|
| 3348 | + * @psalm-pure |
|
| 3349 | + * @psalm-assert iterable<lowercase-string> $value |
|
| 3350 | + * |
|
| 3351 | + * @param iterable<string> $value |
|
| 3352 | + * @param string $message |
|
| 3353 | + * |
|
| 3354 | + * @throws InvalidArgumentException |
|
| 3355 | + * |
|
| 3356 | + * @return void |
|
| 3357 | + */ |
|
| 3358 | + public static function allLower($value, $message = '') |
|
| 3359 | + { |
|
| 3360 | + static::isIterable($value); |
|
| 3361 | + |
|
| 3362 | + foreach ($value as $entry) { |
|
| 3363 | + static::lower($entry, $message); |
|
| 3364 | + } |
|
| 3365 | + } |
|
| 3366 | + |
|
| 3367 | + /** |
|
| 3368 | + * @psalm-pure |
|
| 3369 | + * @psalm-assert iterable<lowercase-string|null> $value |
|
| 3370 | + * |
|
| 3371 | + * @param iterable<string|null> $value |
|
| 3372 | + * @param string $message |
|
| 3373 | + * |
|
| 3374 | + * @throws InvalidArgumentException |
|
| 3375 | + * |
|
| 3376 | + * @return void |
|
| 3377 | + */ |
|
| 3378 | + public static function allNullOrLower($value, $message = '') |
|
| 3379 | + { |
|
| 3380 | + static::isIterable($value); |
|
| 3381 | + |
|
| 3382 | + foreach ($value as $entry) { |
|
| 3383 | + null === $entry || static::lower($entry, $message); |
|
| 3384 | + } |
|
| 3385 | + } |
|
| 3386 | + |
|
| 3387 | + /** |
|
| 3388 | + * @psalm-pure |
|
| 3389 | + * |
|
| 3390 | + * @param string|null $value |
|
| 3391 | + * @param string $message |
|
| 3392 | + * |
|
| 3393 | + * @throws InvalidArgumentException |
|
| 3394 | + * |
|
| 3395 | + * @return void |
|
| 3396 | + */ |
|
| 3397 | + public static function nullOrUpper($value, $message = '') |
|
| 3398 | + { |
|
| 3399 | + null === $value || static::upper($value, $message); |
|
| 3400 | + } |
|
| 3401 | + |
|
| 3402 | + /** |
|
| 3403 | + * @psalm-pure |
|
| 3404 | + * |
|
| 3405 | + * @param iterable<string> $value |
|
| 3406 | + * @param string $message |
|
| 3407 | + * |
|
| 3408 | + * @throws InvalidArgumentException |
|
| 3409 | + * |
|
| 3410 | + * @return void |
|
| 3411 | + */ |
|
| 3412 | + public static function allUpper($value, $message = '') |
|
| 3413 | + { |
|
| 3414 | + static::isIterable($value); |
|
| 3415 | + |
|
| 3416 | + foreach ($value as $entry) { |
|
| 3417 | + static::upper($entry, $message); |
|
| 3418 | + } |
|
| 3419 | + } |
|
| 3420 | + |
|
| 3421 | + /** |
|
| 3422 | + * @psalm-pure |
|
| 3423 | + * @psalm-assert iterable<!lowercase-string|null> $value |
|
| 3424 | + * |
|
| 3425 | + * @param iterable<string|null> $value |
|
| 3426 | + * @param string $message |
|
| 3427 | + * |
|
| 3428 | + * @throws InvalidArgumentException |
|
| 3429 | + * |
|
| 3430 | + * @return void |
|
| 3431 | + */ |
|
| 3432 | + public static function allNullOrUpper($value, $message = '') |
|
| 3433 | + { |
|
| 3434 | + static::isIterable($value); |
|
| 3435 | + |
|
| 3436 | + foreach ($value as $entry) { |
|
| 3437 | + null === $entry || static::upper($entry, $message); |
|
| 3438 | + } |
|
| 3439 | + } |
|
| 3440 | + |
|
| 3441 | + /** |
|
| 3442 | + * @psalm-pure |
|
| 3443 | + * |
|
| 3444 | + * @param string|null $value |
|
| 3445 | + * @param int $length |
|
| 3446 | + * @param string $message |
|
| 3447 | + * |
|
| 3448 | + * @throws InvalidArgumentException |
|
| 3449 | + * |
|
| 3450 | + * @return void |
|
| 3451 | + */ |
|
| 3452 | + public static function nullOrLength($value, $length, $message = '') |
|
| 3453 | + { |
|
| 3454 | + null === $value || static::length($value, $length, $message); |
|
| 3455 | + } |
|
| 3456 | + |
|
| 3457 | + /** |
|
| 3458 | + * @psalm-pure |
|
| 3459 | + * |
|
| 3460 | + * @param iterable<string> $value |
|
| 3461 | + * @param int $length |
|
| 3462 | + * @param string $message |
|
| 3463 | + * |
|
| 3464 | + * @throws InvalidArgumentException |
|
| 3465 | + * |
|
| 3466 | + * @return void |
|
| 3467 | + */ |
|
| 3468 | + public static function allLength($value, $length, $message = '') |
|
| 3469 | + { |
|
| 3470 | + static::isIterable($value); |
|
| 3471 | + |
|
| 3472 | + foreach ($value as $entry) { |
|
| 3473 | + static::length($entry, $length, $message); |
|
| 3474 | + } |
|
| 3475 | + } |
|
| 3476 | + |
|
| 3477 | + /** |
|
| 3478 | + * @psalm-pure |
|
| 3479 | + * |
|
| 3480 | + * @param iterable<string|null> $value |
|
| 3481 | + * @param int $length |
|
| 3482 | + * @param string $message |
|
| 3483 | + * |
|
| 3484 | + * @throws InvalidArgumentException |
|
| 3485 | + * |
|
| 3486 | + * @return void |
|
| 3487 | + */ |
|
| 3488 | + public static function allNullOrLength($value, $length, $message = '') |
|
| 3489 | + { |
|
| 3490 | + static::isIterable($value); |
|
| 3491 | + |
|
| 3492 | + foreach ($value as $entry) { |
|
| 3493 | + null === $entry || static::length($entry, $length, $message); |
|
| 3494 | + } |
|
| 3495 | + } |
|
| 3496 | + |
|
| 3497 | + /** |
|
| 3498 | + * @psalm-pure |
|
| 3499 | + * |
|
| 3500 | + * @param string|null $value |
|
| 3501 | + * @param int|float $min |
|
| 3502 | + * @param string $message |
|
| 3503 | + * |
|
| 3504 | + * @throws InvalidArgumentException |
|
| 3505 | + * |
|
| 3506 | + * @return void |
|
| 3507 | + */ |
|
| 3508 | + public static function nullOrMinLength($value, $min, $message = '') |
|
| 3509 | + { |
|
| 3510 | + null === $value || static::minLength($value, $min, $message); |
|
| 3511 | + } |
|
| 3512 | + |
|
| 3513 | + /** |
|
| 3514 | + * @psalm-pure |
|
| 3515 | + * |
|
| 3516 | + * @param iterable<string> $value |
|
| 3517 | + * @param int|float $min |
|
| 3518 | + * @param string $message |
|
| 3519 | + * |
|
| 3520 | + * @throws InvalidArgumentException |
|
| 3521 | + * |
|
| 3522 | + * @return void |
|
| 3523 | + */ |
|
| 3524 | + public static function allMinLength($value, $min, $message = '') |
|
| 3525 | + { |
|
| 3526 | + static::isIterable($value); |
|
| 3527 | + |
|
| 3528 | + foreach ($value as $entry) { |
|
| 3529 | + static::minLength($entry, $min, $message); |
|
| 3530 | + } |
|
| 3531 | + } |
|
| 3532 | + |
|
| 3533 | + /** |
|
| 3534 | + * @psalm-pure |
|
| 3535 | + * |
|
| 3536 | + * @param iterable<string|null> $value |
|
| 3537 | + * @param int|float $min |
|
| 3538 | + * @param string $message |
|
| 3539 | + * |
|
| 3540 | + * @throws InvalidArgumentException |
|
| 3541 | + * |
|
| 3542 | + * @return void |
|
| 3543 | + */ |
|
| 3544 | + public static function allNullOrMinLength($value, $min, $message = '') |
|
| 3545 | + { |
|
| 3546 | + static::isIterable($value); |
|
| 3547 | + |
|
| 3548 | + foreach ($value as $entry) { |
|
| 3549 | + null === $entry || static::minLength($entry, $min, $message); |
|
| 3550 | + } |
|
| 3551 | + } |
|
| 3552 | + |
|
| 3553 | + /** |
|
| 3554 | + * @psalm-pure |
|
| 3555 | + * |
|
| 3556 | + * @param string|null $value |
|
| 3557 | + * @param int|float $max |
|
| 3558 | + * @param string $message |
|
| 3559 | + * |
|
| 3560 | + * @throws InvalidArgumentException |
|
| 3561 | + * |
|
| 3562 | + * @return void |
|
| 3563 | + */ |
|
| 3564 | + public static function nullOrMaxLength($value, $max, $message = '') |
|
| 3565 | + { |
|
| 3566 | + null === $value || static::maxLength($value, $max, $message); |
|
| 3567 | + } |
|
| 3568 | + |
|
| 3569 | + /** |
|
| 3570 | + * @psalm-pure |
|
| 3571 | + * |
|
| 3572 | + * @param iterable<string> $value |
|
| 3573 | + * @param int|float $max |
|
| 3574 | + * @param string $message |
|
| 3575 | + * |
|
| 3576 | + * @throws InvalidArgumentException |
|
| 3577 | + * |
|
| 3578 | + * @return void |
|
| 3579 | + */ |
|
| 3580 | + public static function allMaxLength($value, $max, $message = '') |
|
| 3581 | + { |
|
| 3582 | + static::isIterable($value); |
|
| 3583 | + |
|
| 3584 | + foreach ($value as $entry) { |
|
| 3585 | + static::maxLength($entry, $max, $message); |
|
| 3586 | + } |
|
| 3587 | + } |
|
| 3588 | + |
|
| 3589 | + /** |
|
| 3590 | + * @psalm-pure |
|
| 3591 | + * |
|
| 3592 | + * @param iterable<string|null> $value |
|
| 3593 | + * @param int|float $max |
|
| 3594 | + * @param string $message |
|
| 3595 | + * |
|
| 3596 | + * @throws InvalidArgumentException |
|
| 3597 | + * |
|
| 3598 | + * @return void |
|
| 3599 | + */ |
|
| 3600 | + public static function allNullOrMaxLength($value, $max, $message = '') |
|
| 3601 | + { |
|
| 3602 | + static::isIterable($value); |
|
| 3603 | + |
|
| 3604 | + foreach ($value as $entry) { |
|
| 3605 | + null === $entry || static::maxLength($entry, $max, $message); |
|
| 3606 | + } |
|
| 3607 | + } |
|
| 3608 | + |
|
| 3609 | + /** |
|
| 3610 | + * @psalm-pure |
|
| 3611 | + * |
|
| 3612 | + * @param string|null $value |
|
| 3613 | + * @param int|float $min |
|
| 3614 | + * @param int|float $max |
|
| 3615 | + * @param string $message |
|
| 3616 | + * |
|
| 3617 | + * @throws InvalidArgumentException |
|
| 3618 | + * |
|
| 3619 | + * @return void |
|
| 3620 | + */ |
|
| 3621 | + public static function nullOrLengthBetween($value, $min, $max, $message = '') |
|
| 3622 | + { |
|
| 3623 | + null === $value || static::lengthBetween($value, $min, $max, $message); |
|
| 3624 | + } |
|
| 3625 | + |
|
| 3626 | + /** |
|
| 3627 | + * @psalm-pure |
|
| 3628 | + * |
|
| 3629 | + * @param iterable<string> $value |
|
| 3630 | + * @param int|float $min |
|
| 3631 | + * @param int|float $max |
|
| 3632 | + * @param string $message |
|
| 3633 | + * |
|
| 3634 | + * @throws InvalidArgumentException |
|
| 3635 | + * |
|
| 3636 | + * @return void |
|
| 3637 | + */ |
|
| 3638 | + public static function allLengthBetween($value, $min, $max, $message = '') |
|
| 3639 | + { |
|
| 3640 | + static::isIterable($value); |
|
| 3641 | + |
|
| 3642 | + foreach ($value as $entry) { |
|
| 3643 | + static::lengthBetween($entry, $min, $max, $message); |
|
| 3644 | + } |
|
| 3645 | + } |
|
| 3646 | + |
|
| 3647 | + /** |
|
| 3648 | + * @psalm-pure |
|
| 3649 | + * |
|
| 3650 | + * @param iterable<string|null> $value |
|
| 3651 | + * @param int|float $min |
|
| 3652 | + * @param int|float $max |
|
| 3653 | + * @param string $message |
|
| 3654 | + * |
|
| 3655 | + * @throws InvalidArgumentException |
|
| 3656 | + * |
|
| 3657 | + * @return void |
|
| 3658 | + */ |
|
| 3659 | + public static function allNullOrLengthBetween($value, $min, $max, $message = '') |
|
| 3660 | + { |
|
| 3661 | + static::isIterable($value); |
|
| 3662 | + |
|
| 3663 | + foreach ($value as $entry) { |
|
| 3664 | + null === $entry || static::lengthBetween($entry, $min, $max, $message); |
|
| 3665 | + } |
|
| 3666 | + } |
|
| 3667 | + |
|
| 3668 | + /** |
|
| 3669 | + * @param mixed $value |
|
| 3670 | + * @param string $message |
|
| 3671 | + * |
|
| 3672 | + * @throws InvalidArgumentException |
|
| 3673 | + * |
|
| 3674 | + * @return void |
|
| 3675 | + */ |
|
| 3676 | + public static function nullOrFileExists($value, $message = '') |
|
| 3677 | + { |
|
| 3678 | + null === $value || static::fileExists($value, $message); |
|
| 3679 | + } |
|
| 3680 | + |
|
| 3681 | + /** |
|
| 3682 | + * @param mixed $value |
|
| 3683 | + * @param string $message |
|
| 3684 | + * |
|
| 3685 | + * @throws InvalidArgumentException |
|
| 3686 | + * |
|
| 3687 | + * @return void |
|
| 3688 | + */ |
|
| 3689 | + public static function allFileExists($value, $message = '') |
|
| 3690 | + { |
|
| 3691 | + static::isIterable($value); |
|
| 3692 | + |
|
| 3693 | + foreach ($value as $entry) { |
|
| 3694 | + static::fileExists($entry, $message); |
|
| 3695 | + } |
|
| 3696 | + } |
|
| 3697 | + |
|
| 3698 | + /** |
|
| 3699 | + * @param mixed $value |
|
| 3700 | + * @param string $message |
|
| 3701 | + * |
|
| 3702 | + * @throws InvalidArgumentException |
|
| 3703 | + * |
|
| 3704 | + * @return void |
|
| 3705 | + */ |
|
| 3706 | + public static function allNullOrFileExists($value, $message = '') |
|
| 3707 | + { |
|
| 3708 | + static::isIterable($value); |
|
| 3709 | + |
|
| 3710 | + foreach ($value as $entry) { |
|
| 3711 | + null === $entry || static::fileExists($entry, $message); |
|
| 3712 | + } |
|
| 3713 | + } |
|
| 3714 | + |
|
| 3715 | + /** |
|
| 3716 | + * @param mixed $value |
|
| 3717 | + * @param string $message |
|
| 3718 | + * |
|
| 3719 | + * @throws InvalidArgumentException |
|
| 3720 | + * |
|
| 3721 | + * @return void |
|
| 3722 | + */ |
|
| 3723 | + public static function nullOrFile($value, $message = '') |
|
| 3724 | + { |
|
| 3725 | + null === $value || static::file($value, $message); |
|
| 3726 | + } |
|
| 3727 | + |
|
| 3728 | + /** |
|
| 3729 | + * @param mixed $value |
|
| 3730 | + * @param string $message |
|
| 3731 | + * |
|
| 3732 | + * @throws InvalidArgumentException |
|
| 3733 | + * |
|
| 3734 | + * @return void |
|
| 3735 | + */ |
|
| 3736 | + public static function allFile($value, $message = '') |
|
| 3737 | + { |
|
| 3738 | + static::isIterable($value); |
|
| 3739 | + |
|
| 3740 | + foreach ($value as $entry) { |
|
| 3741 | + static::file($entry, $message); |
|
| 3742 | + } |
|
| 3743 | + } |
|
| 3744 | + |
|
| 3745 | + /** |
|
| 3746 | + * @param mixed $value |
|
| 3747 | + * @param string $message |
|
| 3748 | + * |
|
| 3749 | + * @throws InvalidArgumentException |
|
| 3750 | + * |
|
| 3751 | + * @return void |
|
| 3752 | + */ |
|
| 3753 | + public static function allNullOrFile($value, $message = '') |
|
| 3754 | + { |
|
| 3755 | + static::isIterable($value); |
|
| 3756 | + |
|
| 3757 | + foreach ($value as $entry) { |
|
| 3758 | + null === $entry || static::file($entry, $message); |
|
| 3759 | + } |
|
| 3760 | + } |
|
| 3761 | + |
|
| 3762 | + /** |
|
| 3763 | + * @param mixed $value |
|
| 3764 | + * @param string $message |
|
| 3765 | + * |
|
| 3766 | + * @throws InvalidArgumentException |
|
| 3767 | + * |
|
| 3768 | + * @return void |
|
| 3769 | + */ |
|
| 3770 | + public static function nullOrDirectory($value, $message = '') |
|
| 3771 | + { |
|
| 3772 | + null === $value || static::directory($value, $message); |
|
| 3773 | + } |
|
| 3774 | + |
|
| 3775 | + /** |
|
| 3776 | + * @param mixed $value |
|
| 3777 | + * @param string $message |
|
| 3778 | + * |
|
| 3779 | + * @throws InvalidArgumentException |
|
| 3780 | + * |
|
| 3781 | + * @return void |
|
| 3782 | + */ |
|
| 3783 | + public static function allDirectory($value, $message = '') |
|
| 3784 | + { |
|
| 3785 | + static::isIterable($value); |
|
| 3786 | + |
|
| 3787 | + foreach ($value as $entry) { |
|
| 3788 | + static::directory($entry, $message); |
|
| 3789 | + } |
|
| 3790 | + } |
|
| 3791 | + |
|
| 3792 | + /** |
|
| 3793 | + * @param mixed $value |
|
| 3794 | + * @param string $message |
|
| 3795 | + * |
|
| 3796 | + * @throws InvalidArgumentException |
|
| 3797 | + * |
|
| 3798 | + * @return void |
|
| 3799 | + */ |
|
| 3800 | + public static function allNullOrDirectory($value, $message = '') |
|
| 3801 | + { |
|
| 3802 | + static::isIterable($value); |
|
| 3803 | + |
|
| 3804 | + foreach ($value as $entry) { |
|
| 3805 | + null === $entry || static::directory($entry, $message); |
|
| 3806 | + } |
|
| 3807 | + } |
|
| 3808 | + |
|
| 3809 | + /** |
|
| 3810 | + * @param string|null $value |
|
| 3811 | + * @param string $message |
|
| 3812 | + * |
|
| 3813 | + * @throws InvalidArgumentException |
|
| 3814 | + * |
|
| 3815 | + * @return void |
|
| 3816 | + */ |
|
| 3817 | + public static function nullOrReadable($value, $message = '') |
|
| 3818 | + { |
|
| 3819 | + null === $value || static::readable($value, $message); |
|
| 3820 | + } |
|
| 3821 | + |
|
| 3822 | + /** |
|
| 3823 | + * @param iterable<string> $value |
|
| 3824 | + * @param string $message |
|
| 3825 | + * |
|
| 3826 | + * @throws InvalidArgumentException |
|
| 3827 | + * |
|
| 3828 | + * @return void |
|
| 3829 | + */ |
|
| 3830 | + public static function allReadable($value, $message = '') |
|
| 3831 | + { |
|
| 3832 | + static::isIterable($value); |
|
| 3833 | + |
|
| 3834 | + foreach ($value as $entry) { |
|
| 3835 | + static::readable($entry, $message); |
|
| 3836 | + } |
|
| 3837 | + } |
|
| 3838 | + |
|
| 3839 | + /** |
|
| 3840 | + * @param iterable<string|null> $value |
|
| 3841 | + * @param string $message |
|
| 3842 | + * |
|
| 3843 | + * @throws InvalidArgumentException |
|
| 3844 | + * |
|
| 3845 | + * @return void |
|
| 3846 | + */ |
|
| 3847 | + public static function allNullOrReadable($value, $message = '') |
|
| 3848 | + { |
|
| 3849 | + static::isIterable($value); |
|
| 3850 | + |
|
| 3851 | + foreach ($value as $entry) { |
|
| 3852 | + null === $entry || static::readable($entry, $message); |
|
| 3853 | + } |
|
| 3854 | + } |
|
| 3855 | + |
|
| 3856 | + /** |
|
| 3857 | + * @param string|null $value |
|
| 3858 | + * @param string $message |
|
| 3859 | + * |
|
| 3860 | + * @throws InvalidArgumentException |
|
| 3861 | + * |
|
| 3862 | + * @return void |
|
| 3863 | + */ |
|
| 3864 | + public static function nullOrWritable($value, $message = '') |
|
| 3865 | + { |
|
| 3866 | + null === $value || static::writable($value, $message); |
|
| 3867 | + } |
|
| 3868 | + |
|
| 3869 | + /** |
|
| 3870 | + * @param iterable<string> $value |
|
| 3871 | + * @param string $message |
|
| 3872 | + * |
|
| 3873 | + * @throws InvalidArgumentException |
|
| 3874 | + * |
|
| 3875 | + * @return void |
|
| 3876 | + */ |
|
| 3877 | + public static function allWritable($value, $message = '') |
|
| 3878 | + { |
|
| 3879 | + static::isIterable($value); |
|
| 3880 | + |
|
| 3881 | + foreach ($value as $entry) { |
|
| 3882 | + static::writable($entry, $message); |
|
| 3883 | + } |
|
| 3884 | + } |
|
| 3885 | + |
|
| 3886 | + /** |
|
| 3887 | + * @param iterable<string|null> $value |
|
| 3888 | + * @param string $message |
|
| 3889 | + * |
|
| 3890 | + * @throws InvalidArgumentException |
|
| 3891 | + * |
|
| 3892 | + * @return void |
|
| 3893 | + */ |
|
| 3894 | + public static function allNullOrWritable($value, $message = '') |
|
| 3895 | + { |
|
| 3896 | + static::isIterable($value); |
|
| 3897 | + |
|
| 3898 | + foreach ($value as $entry) { |
|
| 3899 | + null === $entry || static::writable($entry, $message); |
|
| 3900 | + } |
|
| 3901 | + } |
|
| 3902 | + |
|
| 3903 | + /** |
|
| 3904 | + * @psalm-assert class-string|null $value |
|
| 3905 | + * |
|
| 3906 | + * @param mixed $value |
|
| 3907 | + * @param string $message |
|
| 3908 | + * |
|
| 3909 | + * @throws InvalidArgumentException |
|
| 3910 | + * |
|
| 3911 | + * @return void |
|
| 3912 | + */ |
|
| 3913 | + public static function nullOrClassExists($value, $message = '') |
|
| 3914 | + { |
|
| 3915 | + null === $value || static::classExists($value, $message); |
|
| 3916 | + } |
|
| 3917 | + |
|
| 3918 | + /** |
|
| 3919 | + * @psalm-assert iterable<class-string> $value |
|
| 3920 | + * |
|
| 3921 | + * @param mixed $value |
|
| 3922 | + * @param string $message |
|
| 3923 | + * |
|
| 3924 | + * @throws InvalidArgumentException |
|
| 3925 | + * |
|
| 3926 | + * @return void |
|
| 3927 | + */ |
|
| 3928 | + public static function allClassExists($value, $message = '') |
|
| 3929 | + { |
|
| 3930 | + static::isIterable($value); |
|
| 3931 | + |
|
| 3932 | + foreach ($value as $entry) { |
|
| 3933 | + static::classExists($entry, $message); |
|
| 3934 | + } |
|
| 3935 | + } |
|
| 3936 | + |
|
| 3937 | + /** |
|
| 3938 | + * @psalm-assert iterable<class-string|null> $value |
|
| 3939 | + * |
|
| 3940 | + * @param mixed $value |
|
| 3941 | + * @param string $message |
|
| 3942 | + * |
|
| 3943 | + * @throws InvalidArgumentException |
|
| 3944 | + * |
|
| 3945 | + * @return void |
|
| 3946 | + */ |
|
| 3947 | + public static function allNullOrClassExists($value, $message = '') |
|
| 3948 | + { |
|
| 3949 | + static::isIterable($value); |
|
| 3950 | + |
|
| 3951 | + foreach ($value as $entry) { |
|
| 3952 | + null === $entry || static::classExists($entry, $message); |
|
| 3953 | + } |
|
| 3954 | + } |
|
| 3955 | + |
|
| 3956 | + /** |
|
| 3957 | + * @psalm-pure |
|
| 3958 | + * @psalm-template ExpectedType of object |
|
| 3959 | + * @psalm-param class-string<ExpectedType> $class |
|
| 3960 | + * @psalm-assert class-string<ExpectedType>|ExpectedType|null $value |
|
| 3961 | + * |
|
| 3962 | + * @param mixed $value |
|
| 3963 | + * @param string|object $class |
|
| 3964 | + * @param string $message |
|
| 3965 | + * |
|
| 3966 | + * @throws InvalidArgumentException |
|
| 3967 | + * |
|
| 3968 | + * @return void |
|
| 3969 | + */ |
|
| 3970 | + public static function nullOrSubclassOf($value, $class, $message = '') |
|
| 3971 | + { |
|
| 3972 | + null === $value || static::subclassOf($value, $class, $message); |
|
| 3973 | + } |
|
| 3974 | + |
|
| 3975 | + /** |
|
| 3976 | + * @psalm-pure |
|
| 3977 | + * @psalm-template ExpectedType of object |
|
| 3978 | + * @psalm-param class-string<ExpectedType> $class |
|
| 3979 | + * @psalm-assert iterable<class-string<ExpectedType>|ExpectedType> $value |
|
| 3980 | + * |
|
| 3981 | + * @param mixed $value |
|
| 3982 | + * @param string|object $class |
|
| 3983 | + * @param string $message |
|
| 3984 | + * |
|
| 3985 | + * @throws InvalidArgumentException |
|
| 3986 | + * |
|
| 3987 | + * @return void |
|
| 3988 | + */ |
|
| 3989 | + public static function allSubclassOf($value, $class, $message = '') |
|
| 3990 | + { |
|
| 3991 | + static::isIterable($value); |
|
| 3992 | + |
|
| 3993 | + foreach ($value as $entry) { |
|
| 3994 | + static::subclassOf($entry, $class, $message); |
|
| 3995 | + } |
|
| 3996 | + } |
|
| 3997 | + |
|
| 3998 | + /** |
|
| 3999 | + * @psalm-pure |
|
| 4000 | + * @psalm-template ExpectedType of object |
|
| 4001 | + * @psalm-param class-string<ExpectedType> $class |
|
| 4002 | + * @psalm-assert iterable<class-string<ExpectedType>|ExpectedType|null> $value |
|
| 4003 | + * |
|
| 4004 | + * @param mixed $value |
|
| 4005 | + * @param string|object $class |
|
| 4006 | + * @param string $message |
|
| 4007 | + * |
|
| 4008 | + * @throws InvalidArgumentException |
|
| 4009 | + * |
|
| 4010 | + * @return void |
|
| 4011 | + */ |
|
| 4012 | + public static function allNullOrSubclassOf($value, $class, $message = '') |
|
| 4013 | + { |
|
| 4014 | + static::isIterable($value); |
|
| 4015 | + |
|
| 4016 | + foreach ($value as $entry) { |
|
| 4017 | + null === $entry || static::subclassOf($entry, $class, $message); |
|
| 4018 | + } |
|
| 4019 | + } |
|
| 4020 | + |
|
| 4021 | + /** |
|
| 4022 | + * @psalm-assert class-string|null $value |
|
| 4023 | + * |
|
| 4024 | + * @param mixed $value |
|
| 4025 | + * @param string $message |
|
| 4026 | + * |
|
| 4027 | + * @throws InvalidArgumentException |
|
| 4028 | + * |
|
| 4029 | + * @return void |
|
| 4030 | + */ |
|
| 4031 | + public static function nullOrInterfaceExists($value, $message = '') |
|
| 4032 | + { |
|
| 4033 | + null === $value || static::interfaceExists($value, $message); |
|
| 4034 | + } |
|
| 4035 | + |
|
| 4036 | + /** |
|
| 4037 | + * @psalm-assert iterable<class-string> $value |
|
| 4038 | + * |
|
| 4039 | + * @param mixed $value |
|
| 4040 | + * @param string $message |
|
| 4041 | + * |
|
| 4042 | + * @throws InvalidArgumentException |
|
| 4043 | + * |
|
| 4044 | + * @return void |
|
| 4045 | + */ |
|
| 4046 | + public static function allInterfaceExists($value, $message = '') |
|
| 4047 | + { |
|
| 4048 | + static::isIterable($value); |
|
| 4049 | + |
|
| 4050 | + foreach ($value as $entry) { |
|
| 4051 | + static::interfaceExists($entry, $message); |
|
| 4052 | + } |
|
| 4053 | + } |
|
| 4054 | + |
|
| 4055 | + /** |
|
| 4056 | + * @psalm-assert iterable<class-string|null> $value |
|
| 4057 | + * |
|
| 4058 | + * @param mixed $value |
|
| 4059 | + * @param string $message |
|
| 4060 | + * |
|
| 4061 | + * @throws InvalidArgumentException |
|
| 4062 | + * |
|
| 4063 | + * @return void |
|
| 4064 | + */ |
|
| 4065 | + public static function allNullOrInterfaceExists($value, $message = '') |
|
| 4066 | + { |
|
| 4067 | + static::isIterable($value); |
|
| 4068 | + |
|
| 4069 | + foreach ($value as $entry) { |
|
| 4070 | + null === $entry || static::interfaceExists($entry, $message); |
|
| 4071 | + } |
|
| 4072 | + } |
|
| 4073 | + |
|
| 4074 | + /** |
|
| 4075 | + * @psalm-pure |
|
| 4076 | + * @psalm-template ExpectedType of object |
|
| 4077 | + * @psalm-param class-string<ExpectedType> $interface |
|
| 4078 | + * @psalm-assert class-string<ExpectedType>|null $value |
|
| 4079 | + * |
|
| 4080 | + * @param mixed $value |
|
| 4081 | + * @param mixed $interface |
|
| 4082 | + * @param string $message |
|
| 4083 | + * |
|
| 4084 | + * @throws InvalidArgumentException |
|
| 4085 | + * |
|
| 4086 | + * @return void |
|
| 4087 | + */ |
|
| 4088 | + public static function nullOrImplementsInterface($value, $interface, $message = '') |
|
| 4089 | + { |
|
| 4090 | + null === $value || static::implementsInterface($value, $interface, $message); |
|
| 4091 | + } |
|
| 4092 | + |
|
| 4093 | + /** |
|
| 4094 | + * @psalm-pure |
|
| 4095 | + * @psalm-template ExpectedType of object |
|
| 4096 | + * @psalm-param class-string<ExpectedType> $interface |
|
| 4097 | + * @psalm-assert iterable<class-string<ExpectedType>> $value |
|
| 4098 | + * |
|
| 4099 | + * @param mixed $value |
|
| 4100 | + * @param mixed $interface |
|
| 4101 | + * @param string $message |
|
| 4102 | + * |
|
| 4103 | + * @throws InvalidArgumentException |
|
| 4104 | + * |
|
| 4105 | + * @return void |
|
| 4106 | + */ |
|
| 4107 | + public static function allImplementsInterface($value, $interface, $message = '') |
|
| 4108 | + { |
|
| 4109 | + static::isIterable($value); |
|
| 4110 | + |
|
| 4111 | + foreach ($value as $entry) { |
|
| 4112 | + static::implementsInterface($entry, $interface, $message); |
|
| 4113 | + } |
|
| 4114 | + } |
|
| 4115 | + |
|
| 4116 | + /** |
|
| 4117 | + * @psalm-pure |
|
| 4118 | + * @psalm-template ExpectedType of object |
|
| 4119 | + * @psalm-param class-string<ExpectedType> $interface |
|
| 4120 | + * @psalm-assert iterable<class-string<ExpectedType>|null> $value |
|
| 4121 | + * |
|
| 4122 | + * @param mixed $value |
|
| 4123 | + * @param mixed $interface |
|
| 4124 | + * @param string $message |
|
| 4125 | + * |
|
| 4126 | + * @throws InvalidArgumentException |
|
| 4127 | + * |
|
| 4128 | + * @return void |
|
| 4129 | + */ |
|
| 4130 | + public static function allNullOrImplementsInterface($value, $interface, $message = '') |
|
| 4131 | + { |
|
| 4132 | + static::isIterable($value); |
|
| 4133 | + |
|
| 4134 | + foreach ($value as $entry) { |
|
| 4135 | + null === $entry || static::implementsInterface($entry, $interface, $message); |
|
| 4136 | + } |
|
| 4137 | + } |
|
| 4138 | + |
|
| 4139 | + /** |
|
| 4140 | + * @psalm-pure |
|
| 4141 | + * @psalm-param class-string|object|null $classOrObject |
|
| 4142 | + * |
|
| 4143 | + * @param string|object|null $classOrObject |
|
| 4144 | + * @param mixed $property |
|
| 4145 | + * @param string $message |
|
| 4146 | + * |
|
| 4147 | + * @throws InvalidArgumentException |
|
| 4148 | + * |
|
| 4149 | + * @return void |
|
| 4150 | + */ |
|
| 4151 | + public static function nullOrPropertyExists($classOrObject, $property, $message = '') |
|
| 4152 | + { |
|
| 4153 | + null === $classOrObject || static::propertyExists($classOrObject, $property, $message); |
|
| 4154 | + } |
|
| 4155 | + |
|
| 4156 | + /** |
|
| 4157 | + * @psalm-pure |
|
| 4158 | + * @psalm-param iterable<class-string|object> $classOrObject |
|
| 4159 | + * |
|
| 4160 | + * @param iterable<string|object> $classOrObject |
|
| 4161 | + * @param mixed $property |
|
| 4162 | + * @param string $message |
|
| 4163 | + * |
|
| 4164 | + * @throws InvalidArgumentException |
|
| 4165 | + * |
|
| 4166 | + * @return void |
|
| 4167 | + */ |
|
| 4168 | + public static function allPropertyExists($classOrObject, $property, $message = '') |
|
| 4169 | + { |
|
| 4170 | + static::isIterable($classOrObject); |
|
| 4171 | + |
|
| 4172 | + foreach ($classOrObject as $entry) { |
|
| 4173 | + static::propertyExists($entry, $property, $message); |
|
| 4174 | + } |
|
| 4175 | + } |
|
| 4176 | + |
|
| 4177 | + /** |
|
| 4178 | + * @psalm-pure |
|
| 4179 | + * @psalm-param iterable<class-string|object|null> $classOrObject |
|
| 4180 | + * |
|
| 4181 | + * @param iterable<string|object|null> $classOrObject |
|
| 4182 | + * @param mixed $property |
|
| 4183 | + * @param string $message |
|
| 4184 | + * |
|
| 4185 | + * @throws InvalidArgumentException |
|
| 4186 | + * |
|
| 4187 | + * @return void |
|
| 4188 | + */ |
|
| 4189 | + public static function allNullOrPropertyExists($classOrObject, $property, $message = '') |
|
| 4190 | + { |
|
| 4191 | + static::isIterable($classOrObject); |
|
| 4192 | + |
|
| 4193 | + foreach ($classOrObject as $entry) { |
|
| 4194 | + null === $entry || static::propertyExists($entry, $property, $message); |
|
| 4195 | + } |
|
| 4196 | + } |
|
| 4197 | + |
|
| 4198 | + /** |
|
| 4199 | + * @psalm-pure |
|
| 4200 | + * @psalm-param class-string|object|null $classOrObject |
|
| 4201 | + * |
|
| 4202 | + * @param string|object|null $classOrObject |
|
| 4203 | + * @param mixed $property |
|
| 4204 | + * @param string $message |
|
| 4205 | + * |
|
| 4206 | + * @throws InvalidArgumentException |
|
| 4207 | + * |
|
| 4208 | + * @return void |
|
| 4209 | + */ |
|
| 4210 | + public static function nullOrPropertyNotExists($classOrObject, $property, $message = '') |
|
| 4211 | + { |
|
| 4212 | + null === $classOrObject || static::propertyNotExists($classOrObject, $property, $message); |
|
| 4213 | + } |
|
| 4214 | + |
|
| 4215 | + /** |
|
| 4216 | + * @psalm-pure |
|
| 4217 | + * @psalm-param iterable<class-string|object> $classOrObject |
|
| 4218 | + * |
|
| 4219 | + * @param iterable<string|object> $classOrObject |
|
| 4220 | + * @param mixed $property |
|
| 4221 | + * @param string $message |
|
| 4222 | + * |
|
| 4223 | + * @throws InvalidArgumentException |
|
| 4224 | + * |
|
| 4225 | + * @return void |
|
| 4226 | + */ |
|
| 4227 | + public static function allPropertyNotExists($classOrObject, $property, $message = '') |
|
| 4228 | + { |
|
| 4229 | + static::isIterable($classOrObject); |
|
| 4230 | + |
|
| 4231 | + foreach ($classOrObject as $entry) { |
|
| 4232 | + static::propertyNotExists($entry, $property, $message); |
|
| 4233 | + } |
|
| 4234 | + } |
|
| 4235 | + |
|
| 4236 | + /** |
|
| 4237 | + * @psalm-pure |
|
| 4238 | + * @psalm-param iterable<class-string|object|null> $classOrObject |
|
| 4239 | + * |
|
| 4240 | + * @param iterable<string|object|null> $classOrObject |
|
| 4241 | + * @param mixed $property |
|
| 4242 | + * @param string $message |
|
| 4243 | + * |
|
| 4244 | + * @throws InvalidArgumentException |
|
| 4245 | + * |
|
| 4246 | + * @return void |
|
| 4247 | + */ |
|
| 4248 | + public static function allNullOrPropertyNotExists($classOrObject, $property, $message = '') |
|
| 4249 | + { |
|
| 4250 | + static::isIterable($classOrObject); |
|
| 4251 | + |
|
| 4252 | + foreach ($classOrObject as $entry) { |
|
| 4253 | + null === $entry || static::propertyNotExists($entry, $property, $message); |
|
| 4254 | + } |
|
| 4255 | + } |
|
| 4256 | + |
|
| 4257 | + /** |
|
| 4258 | + * @psalm-pure |
|
| 4259 | + * @psalm-param class-string|object|null $classOrObject |
|
| 4260 | + * |
|
| 4261 | + * @param string|object|null $classOrObject |
|
| 4262 | + * @param mixed $method |
|
| 4263 | + * @param string $message |
|
| 4264 | + * |
|
| 4265 | + * @throws InvalidArgumentException |
|
| 4266 | + * |
|
| 4267 | + * @return void |
|
| 4268 | + */ |
|
| 4269 | + public static function nullOrMethodExists($classOrObject, $method, $message = '') |
|
| 4270 | + { |
|
| 4271 | + null === $classOrObject || static::methodExists($classOrObject, $method, $message); |
|
| 4272 | + } |
|
| 4273 | + |
|
| 4274 | + /** |
|
| 4275 | + * @psalm-pure |
|
| 4276 | + * @psalm-param iterable<class-string|object> $classOrObject |
|
| 4277 | + * |
|
| 4278 | + * @param iterable<string|object> $classOrObject |
|
| 4279 | + * @param mixed $method |
|
| 4280 | + * @param string $message |
|
| 4281 | + * |
|
| 4282 | + * @throws InvalidArgumentException |
|
| 4283 | + * |
|
| 4284 | + * @return void |
|
| 4285 | + */ |
|
| 4286 | + public static function allMethodExists($classOrObject, $method, $message = '') |
|
| 4287 | + { |
|
| 4288 | + static::isIterable($classOrObject); |
|
| 4289 | + |
|
| 4290 | + foreach ($classOrObject as $entry) { |
|
| 4291 | + static::methodExists($entry, $method, $message); |
|
| 4292 | + } |
|
| 4293 | + } |
|
| 4294 | + |
|
| 4295 | + /** |
|
| 4296 | + * @psalm-pure |
|
| 4297 | + * @psalm-param iterable<class-string|object|null> $classOrObject |
|
| 4298 | + * |
|
| 4299 | + * @param iterable<string|object|null> $classOrObject |
|
| 4300 | + * @param mixed $method |
|
| 4301 | + * @param string $message |
|
| 4302 | + * |
|
| 4303 | + * @throws InvalidArgumentException |
|
| 4304 | + * |
|
| 4305 | + * @return void |
|
| 4306 | + */ |
|
| 4307 | + public static function allNullOrMethodExists($classOrObject, $method, $message = '') |
|
| 4308 | + { |
|
| 4309 | + static::isIterable($classOrObject); |
|
| 4310 | + |
|
| 4311 | + foreach ($classOrObject as $entry) { |
|
| 4312 | + null === $entry || static::methodExists($entry, $method, $message); |
|
| 4313 | + } |
|
| 4314 | + } |
|
| 4315 | + |
|
| 4316 | + /** |
|
| 4317 | + * @psalm-pure |
|
| 4318 | + * @psalm-param class-string|object|null $classOrObject |
|
| 4319 | + * |
|
| 4320 | + * @param string|object|null $classOrObject |
|
| 4321 | + * @param mixed $method |
|
| 4322 | + * @param string $message |
|
| 4323 | + * |
|
| 4324 | + * @throws InvalidArgumentException |
|
| 4325 | + * |
|
| 4326 | + * @return void |
|
| 4327 | + */ |
|
| 4328 | + public static function nullOrMethodNotExists($classOrObject, $method, $message = '') |
|
| 4329 | + { |
|
| 4330 | + null === $classOrObject || static::methodNotExists($classOrObject, $method, $message); |
|
| 4331 | + } |
|
| 4332 | + |
|
| 4333 | + /** |
|
| 4334 | + * @psalm-pure |
|
| 4335 | + * @psalm-param iterable<class-string|object> $classOrObject |
|
| 4336 | + * |
|
| 4337 | + * @param iterable<string|object> $classOrObject |
|
| 4338 | + * @param mixed $method |
|
| 4339 | + * @param string $message |
|
| 4340 | + * |
|
| 4341 | + * @throws InvalidArgumentException |
|
| 4342 | + * |
|
| 4343 | + * @return void |
|
| 4344 | + */ |
|
| 4345 | + public static function allMethodNotExists($classOrObject, $method, $message = '') |
|
| 4346 | + { |
|
| 4347 | + static::isIterable($classOrObject); |
|
| 4348 | + |
|
| 4349 | + foreach ($classOrObject as $entry) { |
|
| 4350 | + static::methodNotExists($entry, $method, $message); |
|
| 4351 | + } |
|
| 4352 | + } |
|
| 4353 | + |
|
| 4354 | + /** |
|
| 4355 | + * @psalm-pure |
|
| 4356 | + * @psalm-param iterable<class-string|object|null> $classOrObject |
|
| 4357 | + * |
|
| 4358 | + * @param iterable<string|object|null> $classOrObject |
|
| 4359 | + * @param mixed $method |
|
| 4360 | + * @param string $message |
|
| 4361 | + * |
|
| 4362 | + * @throws InvalidArgumentException |
|
| 4363 | + * |
|
| 4364 | + * @return void |
|
| 4365 | + */ |
|
| 4366 | + public static function allNullOrMethodNotExists($classOrObject, $method, $message = '') |
|
| 4367 | + { |
|
| 4368 | + static::isIterable($classOrObject); |
|
| 4369 | + |
|
| 4370 | + foreach ($classOrObject as $entry) { |
|
| 4371 | + null === $entry || static::methodNotExists($entry, $method, $message); |
|
| 4372 | + } |
|
| 4373 | + } |
|
| 4374 | + |
|
| 4375 | + /** |
|
| 4376 | + * @psalm-pure |
|
| 4377 | + * |
|
| 4378 | + * @param array|null $array |
|
| 4379 | + * @param string|int $key |
|
| 4380 | + * @param string $message |
|
| 4381 | + * |
|
| 4382 | + * @throws InvalidArgumentException |
|
| 4383 | + * |
|
| 4384 | + * @return void |
|
| 4385 | + */ |
|
| 4386 | + public static function nullOrKeyExists($array, $key, $message = '') |
|
| 4387 | + { |
|
| 4388 | + null === $array || static::keyExists($array, $key, $message); |
|
| 4389 | + } |
|
| 4390 | + |
|
| 4391 | + /** |
|
| 4392 | + * @psalm-pure |
|
| 4393 | + * |
|
| 4394 | + * @param iterable<array> $array |
|
| 4395 | + * @param string|int $key |
|
| 4396 | + * @param string $message |
|
| 4397 | + * |
|
| 4398 | + * @throws InvalidArgumentException |
|
| 4399 | + * |
|
| 4400 | + * @return void |
|
| 4401 | + */ |
|
| 4402 | + public static function allKeyExists($array, $key, $message = '') |
|
| 4403 | + { |
|
| 4404 | + static::isIterable($array); |
|
| 4405 | + |
|
| 4406 | + foreach ($array as $entry) { |
|
| 4407 | + static::keyExists($entry, $key, $message); |
|
| 4408 | + } |
|
| 4409 | + } |
|
| 4410 | + |
|
| 4411 | + /** |
|
| 4412 | + * @psalm-pure |
|
| 4413 | + * |
|
| 4414 | + * @param iterable<array|null> $array |
|
| 4415 | + * @param string|int $key |
|
| 4416 | + * @param string $message |
|
| 4417 | + * |
|
| 4418 | + * @throws InvalidArgumentException |
|
| 4419 | + * |
|
| 4420 | + * @return void |
|
| 4421 | + */ |
|
| 4422 | + public static function allNullOrKeyExists($array, $key, $message = '') |
|
| 4423 | + { |
|
| 4424 | + static::isIterable($array); |
|
| 4425 | + |
|
| 4426 | + foreach ($array as $entry) { |
|
| 4427 | + null === $entry || static::keyExists($entry, $key, $message); |
|
| 4428 | + } |
|
| 4429 | + } |
|
| 4430 | + |
|
| 4431 | + /** |
|
| 4432 | + * @psalm-pure |
|
| 4433 | + * |
|
| 4434 | + * @param array|null $array |
|
| 4435 | + * @param string|int $key |
|
| 4436 | + * @param string $message |
|
| 4437 | + * |
|
| 4438 | + * @throws InvalidArgumentException |
|
| 4439 | + * |
|
| 4440 | + * @return void |
|
| 4441 | + */ |
|
| 4442 | + public static function nullOrKeyNotExists($array, $key, $message = '') |
|
| 4443 | + { |
|
| 4444 | + null === $array || static::keyNotExists($array, $key, $message); |
|
| 4445 | + } |
|
| 4446 | + |
|
| 4447 | + /** |
|
| 4448 | + * @psalm-pure |
|
| 4449 | + * |
|
| 4450 | + * @param iterable<array> $array |
|
| 4451 | + * @param string|int $key |
|
| 4452 | + * @param string $message |
|
| 4453 | + * |
|
| 4454 | + * @throws InvalidArgumentException |
|
| 4455 | + * |
|
| 4456 | + * @return void |
|
| 4457 | + */ |
|
| 4458 | + public static function allKeyNotExists($array, $key, $message = '') |
|
| 4459 | + { |
|
| 4460 | + static::isIterable($array); |
|
| 4461 | + |
|
| 4462 | + foreach ($array as $entry) { |
|
| 4463 | + static::keyNotExists($entry, $key, $message); |
|
| 4464 | + } |
|
| 4465 | + } |
|
| 4466 | + |
|
| 4467 | + /** |
|
| 4468 | + * @psalm-pure |
|
| 4469 | + * |
|
| 4470 | + * @param iterable<array|null> $array |
|
| 4471 | + * @param string|int $key |
|
| 4472 | + * @param string $message |
|
| 4473 | + * |
|
| 4474 | + * @throws InvalidArgumentException |
|
| 4475 | + * |
|
| 4476 | + * @return void |
|
| 4477 | + */ |
|
| 4478 | + public static function allNullOrKeyNotExists($array, $key, $message = '') |
|
| 4479 | + { |
|
| 4480 | + static::isIterable($array); |
|
| 4481 | + |
|
| 4482 | + foreach ($array as $entry) { |
|
| 4483 | + null === $entry || static::keyNotExists($entry, $key, $message); |
|
| 4484 | + } |
|
| 4485 | + } |
|
| 4486 | + |
|
| 4487 | + /** |
|
| 4488 | + * @psalm-pure |
|
| 4489 | + * @psalm-assert array-key|null $value |
|
| 4490 | + * |
|
| 4491 | + * @param mixed $value |
|
| 4492 | + * @param string $message |
|
| 4493 | + * |
|
| 4494 | + * @throws InvalidArgumentException |
|
| 4495 | + * |
|
| 4496 | + * @return void |
|
| 4497 | + */ |
|
| 4498 | + public static function nullOrValidArrayKey($value, $message = '') |
|
| 4499 | + { |
|
| 4500 | + null === $value || static::validArrayKey($value, $message); |
|
| 4501 | + } |
|
| 4502 | + |
|
| 4503 | + /** |
|
| 4504 | + * @psalm-pure |
|
| 4505 | + * @psalm-assert iterable<array-key> $value |
|
| 4506 | + * |
|
| 4507 | + * @param mixed $value |
|
| 4508 | + * @param string $message |
|
| 4509 | + * |
|
| 4510 | + * @throws InvalidArgumentException |
|
| 4511 | + * |
|
| 4512 | + * @return void |
|
| 4513 | + */ |
|
| 4514 | + public static function allValidArrayKey($value, $message = '') |
|
| 4515 | + { |
|
| 4516 | + static::isIterable($value); |
|
| 4517 | + |
|
| 4518 | + foreach ($value as $entry) { |
|
| 4519 | + static::validArrayKey($entry, $message); |
|
| 4520 | + } |
|
| 4521 | + } |
|
| 4522 | + |
|
| 4523 | + /** |
|
| 4524 | + * @psalm-pure |
|
| 4525 | + * @psalm-assert iterable<array-key|null> $value |
|
| 4526 | + * |
|
| 4527 | + * @param mixed $value |
|
| 4528 | + * @param string $message |
|
| 4529 | + * |
|
| 4530 | + * @throws InvalidArgumentException |
|
| 4531 | + * |
|
| 4532 | + * @return void |
|
| 4533 | + */ |
|
| 4534 | + public static function allNullOrValidArrayKey($value, $message = '') |
|
| 4535 | + { |
|
| 4536 | + static::isIterable($value); |
|
| 4537 | + |
|
| 4538 | + foreach ($value as $entry) { |
|
| 4539 | + null === $entry || static::validArrayKey($entry, $message); |
|
| 4540 | + } |
|
| 4541 | + } |
|
| 4542 | + |
|
| 4543 | + /** |
|
| 4544 | + * @param Countable|array|null $array |
|
| 4545 | + * @param int $number |
|
| 4546 | + * @param string $message |
|
| 4547 | + * |
|
| 4548 | + * @throws InvalidArgumentException |
|
| 4549 | + * |
|
| 4550 | + * @return void |
|
| 4551 | + */ |
|
| 4552 | + public static function nullOrCount($array, $number, $message = '') |
|
| 4553 | + { |
|
| 4554 | + null === $array || static::count($array, $number, $message); |
|
| 4555 | + } |
|
| 4556 | + |
|
| 4557 | + /** |
|
| 4558 | + * @param iterable<Countable|array> $array |
|
| 4559 | + * @param int $number |
|
| 4560 | + * @param string $message |
|
| 4561 | + * |
|
| 4562 | + * @throws InvalidArgumentException |
|
| 4563 | + * |
|
| 4564 | + * @return void |
|
| 4565 | + */ |
|
| 4566 | + public static function allCount($array, $number, $message = '') |
|
| 4567 | + { |
|
| 4568 | + static::isIterable($array); |
|
| 4569 | + |
|
| 4570 | + foreach ($array as $entry) { |
|
| 4571 | + static::count($entry, $number, $message); |
|
| 4572 | + } |
|
| 4573 | + } |
|
| 4574 | + |
|
| 4575 | + /** |
|
| 4576 | + * @param iterable<Countable|array|null> $array |
|
| 4577 | + * @param int $number |
|
| 4578 | + * @param string $message |
|
| 4579 | + * |
|
| 4580 | + * @throws InvalidArgumentException |
|
| 4581 | + * |
|
| 4582 | + * @return void |
|
| 4583 | + */ |
|
| 4584 | + public static function allNullOrCount($array, $number, $message = '') |
|
| 4585 | + { |
|
| 4586 | + static::isIterable($array); |
|
| 4587 | + |
|
| 4588 | + foreach ($array as $entry) { |
|
| 4589 | + null === $entry || static::count($entry, $number, $message); |
|
| 4590 | + } |
|
| 4591 | + } |
|
| 4592 | + |
|
| 4593 | + /** |
|
| 4594 | + * @param Countable|array|null $array |
|
| 4595 | + * @param int|float $min |
|
| 4596 | + * @param string $message |
|
| 4597 | + * |
|
| 4598 | + * @throws InvalidArgumentException |
|
| 4599 | + * |
|
| 4600 | + * @return void |
|
| 4601 | + */ |
|
| 4602 | + public static function nullOrMinCount($array, $min, $message = '') |
|
| 4603 | + { |
|
| 4604 | + null === $array || static::minCount($array, $min, $message); |
|
| 4605 | + } |
|
| 4606 | + |
|
| 4607 | + /** |
|
| 4608 | + * @param iterable<Countable|array> $array |
|
| 4609 | + * @param int|float $min |
|
| 4610 | + * @param string $message |
|
| 4611 | + * |
|
| 4612 | + * @throws InvalidArgumentException |
|
| 4613 | + * |
|
| 4614 | + * @return void |
|
| 4615 | + */ |
|
| 4616 | + public static function allMinCount($array, $min, $message = '') |
|
| 4617 | + { |
|
| 4618 | + static::isIterable($array); |
|
| 4619 | + |
|
| 4620 | + foreach ($array as $entry) { |
|
| 4621 | + static::minCount($entry, $min, $message); |
|
| 4622 | + } |
|
| 4623 | + } |
|
| 4624 | + |
|
| 4625 | + /** |
|
| 4626 | + * @param iterable<Countable|array|null> $array |
|
| 4627 | + * @param int|float $min |
|
| 4628 | + * @param string $message |
|
| 4629 | + * |
|
| 4630 | + * @throws InvalidArgumentException |
|
| 4631 | + * |
|
| 4632 | + * @return void |
|
| 4633 | + */ |
|
| 4634 | + public static function allNullOrMinCount($array, $min, $message = '') |
|
| 4635 | + { |
|
| 4636 | + static::isIterable($array); |
|
| 4637 | + |
|
| 4638 | + foreach ($array as $entry) { |
|
| 4639 | + null === $entry || static::minCount($entry, $min, $message); |
|
| 4640 | + } |
|
| 4641 | + } |
|
| 4642 | + |
|
| 4643 | + /** |
|
| 4644 | + * @param Countable|array|null $array |
|
| 4645 | + * @param int|float $max |
|
| 4646 | + * @param string $message |
|
| 4647 | + * |
|
| 4648 | + * @throws InvalidArgumentException |
|
| 4649 | + * |
|
| 4650 | + * @return void |
|
| 4651 | + */ |
|
| 4652 | + public static function nullOrMaxCount($array, $max, $message = '') |
|
| 4653 | + { |
|
| 4654 | + null === $array || static::maxCount($array, $max, $message); |
|
| 4655 | + } |
|
| 4656 | + |
|
| 4657 | + /** |
|
| 4658 | + * @param iterable<Countable|array> $array |
|
| 4659 | + * @param int|float $max |
|
| 4660 | + * @param string $message |
|
| 4661 | + * |
|
| 4662 | + * @throws InvalidArgumentException |
|
| 4663 | + * |
|
| 4664 | + * @return void |
|
| 4665 | + */ |
|
| 4666 | + public static function allMaxCount($array, $max, $message = '') |
|
| 4667 | + { |
|
| 4668 | + static::isIterable($array); |
|
| 4669 | + |
|
| 4670 | + foreach ($array as $entry) { |
|
| 4671 | + static::maxCount($entry, $max, $message); |
|
| 4672 | + } |
|
| 4673 | + } |
|
| 4674 | + |
|
| 4675 | + /** |
|
| 4676 | + * @param iterable<Countable|array|null> $array |
|
| 4677 | + * @param int|float $max |
|
| 4678 | + * @param string $message |
|
| 4679 | + * |
|
| 4680 | + * @throws InvalidArgumentException |
|
| 4681 | + * |
|
| 4682 | + * @return void |
|
| 4683 | + */ |
|
| 4684 | + public static function allNullOrMaxCount($array, $max, $message = '') |
|
| 4685 | + { |
|
| 4686 | + static::isIterable($array); |
|
| 4687 | + |
|
| 4688 | + foreach ($array as $entry) { |
|
| 4689 | + null === $entry || static::maxCount($entry, $max, $message); |
|
| 4690 | + } |
|
| 4691 | + } |
|
| 4692 | + |
|
| 4693 | + /** |
|
| 4694 | + * @param Countable|array|null $array |
|
| 4695 | + * @param int|float $min |
|
| 4696 | + * @param int|float $max |
|
| 4697 | + * @param string $message |
|
| 4698 | + * |
|
| 4699 | + * @throws InvalidArgumentException |
|
| 4700 | + * |
|
| 4701 | + * @return void |
|
| 4702 | + */ |
|
| 4703 | + public static function nullOrCountBetween($array, $min, $max, $message = '') |
|
| 4704 | + { |
|
| 4705 | + null === $array || static::countBetween($array, $min, $max, $message); |
|
| 4706 | + } |
|
| 4707 | + |
|
| 4708 | + /** |
|
| 4709 | + * @param iterable<Countable|array> $array |
|
| 4710 | + * @param int|float $min |
|
| 4711 | + * @param int|float $max |
|
| 4712 | + * @param string $message |
|
| 4713 | + * |
|
| 4714 | + * @throws InvalidArgumentException |
|
| 4715 | + * |
|
| 4716 | + * @return void |
|
| 4717 | + */ |
|
| 4718 | + public static function allCountBetween($array, $min, $max, $message = '') |
|
| 4719 | + { |
|
| 4720 | + static::isIterable($array); |
|
| 4721 | + |
|
| 4722 | + foreach ($array as $entry) { |
|
| 4723 | + static::countBetween($entry, $min, $max, $message); |
|
| 4724 | + } |
|
| 4725 | + } |
|
| 4726 | + |
|
| 4727 | + /** |
|
| 4728 | + * @param iterable<Countable|array|null> $array |
|
| 4729 | + * @param int|float $min |
|
| 4730 | + * @param int|float $max |
|
| 4731 | + * @param string $message |
|
| 4732 | + * |
|
| 4733 | + * @throws InvalidArgumentException |
|
| 4734 | + * |
|
| 4735 | + * @return void |
|
| 4736 | + */ |
|
| 4737 | + public static function allNullOrCountBetween($array, $min, $max, $message = '') |
|
| 4738 | + { |
|
| 4739 | + static::isIterable($array); |
|
| 4740 | + |
|
| 4741 | + foreach ($array as $entry) { |
|
| 4742 | + null === $entry || static::countBetween($entry, $min, $max, $message); |
|
| 4743 | + } |
|
| 4744 | + } |
|
| 4745 | + |
|
| 4746 | + /** |
|
| 4747 | + * @psalm-pure |
|
| 4748 | + * @psalm-assert list|null $array |
|
| 4749 | + * |
|
| 4750 | + * @param mixed $array |
|
| 4751 | + * @param string $message |
|
| 4752 | + * |
|
| 4753 | + * @throws InvalidArgumentException |
|
| 4754 | + * |
|
| 4755 | + * @return void |
|
| 4756 | + */ |
|
| 4757 | + public static function nullOrIsList($array, $message = '') |
|
| 4758 | + { |
|
| 4759 | + null === $array || static::isList($array, $message); |
|
| 4760 | + } |
|
| 4761 | + |
|
| 4762 | + /** |
|
| 4763 | + * @psalm-pure |
|
| 4764 | + * @psalm-assert iterable<list> $array |
|
| 4765 | + * |
|
| 4766 | + * @param mixed $array |
|
| 4767 | + * @param string $message |
|
| 4768 | + * |
|
| 4769 | + * @throws InvalidArgumentException |
|
| 4770 | + * |
|
| 4771 | + * @return void |
|
| 4772 | + */ |
|
| 4773 | + public static function allIsList($array, $message = '') |
|
| 4774 | + { |
|
| 4775 | + static::isIterable($array); |
|
| 4776 | + |
|
| 4777 | + foreach ($array as $entry) { |
|
| 4778 | + static::isList($entry, $message); |
|
| 4779 | + } |
|
| 4780 | + } |
|
| 4781 | + |
|
| 4782 | + /** |
|
| 4783 | + * @psalm-pure |
|
| 4784 | + * @psalm-assert iterable<list|null> $array |
|
| 4785 | + * |
|
| 4786 | + * @param mixed $array |
|
| 4787 | + * @param string $message |
|
| 4788 | + * |
|
| 4789 | + * @throws InvalidArgumentException |
|
| 4790 | + * |
|
| 4791 | + * @return void |
|
| 4792 | + */ |
|
| 4793 | + public static function allNullOrIsList($array, $message = '') |
|
| 4794 | + { |
|
| 4795 | + static::isIterable($array); |
|
| 4796 | + |
|
| 4797 | + foreach ($array as $entry) { |
|
| 4798 | + null === $entry || static::isList($entry, $message); |
|
| 4799 | + } |
|
| 4800 | + } |
|
| 4801 | + |
|
| 4802 | + /** |
|
| 4803 | + * @psalm-pure |
|
| 4804 | + * @psalm-assert non-empty-list|null $array |
|
| 4805 | + * |
|
| 4806 | + * @param mixed $array |
|
| 4807 | + * @param string $message |
|
| 4808 | + * |
|
| 4809 | + * @throws InvalidArgumentException |
|
| 4810 | + * |
|
| 4811 | + * @return void |
|
| 4812 | + */ |
|
| 4813 | + public static function nullOrIsNonEmptyList($array, $message = '') |
|
| 4814 | + { |
|
| 4815 | + null === $array || static::isNonEmptyList($array, $message); |
|
| 4816 | + } |
|
| 4817 | + |
|
| 4818 | + /** |
|
| 4819 | + * @psalm-pure |
|
| 4820 | + * @psalm-assert iterable<non-empty-list> $array |
|
| 4821 | + * |
|
| 4822 | + * @param mixed $array |
|
| 4823 | + * @param string $message |
|
| 4824 | + * |
|
| 4825 | + * @throws InvalidArgumentException |
|
| 4826 | + * |
|
| 4827 | + * @return void |
|
| 4828 | + */ |
|
| 4829 | + public static function allIsNonEmptyList($array, $message = '') |
|
| 4830 | + { |
|
| 4831 | + static::isIterable($array); |
|
| 4832 | + |
|
| 4833 | + foreach ($array as $entry) { |
|
| 4834 | + static::isNonEmptyList($entry, $message); |
|
| 4835 | + } |
|
| 4836 | + } |
|
| 4837 | + |
|
| 4838 | + /** |
|
| 4839 | + * @psalm-pure |
|
| 4840 | + * @psalm-assert iterable<non-empty-list|null> $array |
|
| 4841 | + * |
|
| 4842 | + * @param mixed $array |
|
| 4843 | + * @param string $message |
|
| 4844 | + * |
|
| 4845 | + * @throws InvalidArgumentException |
|
| 4846 | + * |
|
| 4847 | + * @return void |
|
| 4848 | + */ |
|
| 4849 | + public static function allNullOrIsNonEmptyList($array, $message = '') |
|
| 4850 | + { |
|
| 4851 | + static::isIterable($array); |
|
| 4852 | + |
|
| 4853 | + foreach ($array as $entry) { |
|
| 4854 | + null === $entry || static::isNonEmptyList($entry, $message); |
|
| 4855 | + } |
|
| 4856 | + } |
|
| 4857 | + |
|
| 4858 | + /** |
|
| 4859 | + * @psalm-pure |
|
| 4860 | + * @psalm-template T |
|
| 4861 | + * @psalm-param mixed|array<T>|null $array |
|
| 4862 | + * @psalm-assert array<string, T>|null $array |
|
| 4863 | + * |
|
| 4864 | + * @param mixed $array |
|
| 4865 | + * @param string $message |
|
| 4866 | + * |
|
| 4867 | + * @throws InvalidArgumentException |
|
| 4868 | + * |
|
| 4869 | + * @return void |
|
| 4870 | + */ |
|
| 4871 | + public static function nullOrIsMap($array, $message = '') |
|
| 4872 | + { |
|
| 4873 | + null === $array || static::isMap($array, $message); |
|
| 4874 | + } |
|
| 4875 | + |
|
| 4876 | + /** |
|
| 4877 | + * @psalm-pure |
|
| 4878 | + * @psalm-template T |
|
| 4879 | + * @psalm-param iterable<mixed|array<T>> $array |
|
| 4880 | + * @psalm-assert iterable<array<string, T>> $array |
|
| 4881 | + * |
|
| 4882 | + * @param mixed $array |
|
| 4883 | + * @param string $message |
|
| 4884 | + * |
|
| 4885 | + * @throws InvalidArgumentException |
|
| 4886 | + * |
|
| 4887 | + * @return void |
|
| 4888 | + */ |
|
| 4889 | + public static function allIsMap($array, $message = '') |
|
| 4890 | + { |
|
| 4891 | + static::isIterable($array); |
|
| 4892 | + |
|
| 4893 | + foreach ($array as $entry) { |
|
| 4894 | + static::isMap($entry, $message); |
|
| 4895 | + } |
|
| 4896 | + } |
|
| 4897 | + |
|
| 4898 | + /** |
|
| 4899 | + * @psalm-pure |
|
| 4900 | + * @psalm-template T |
|
| 4901 | + * @psalm-param iterable<mixed|array<T>|null> $array |
|
| 4902 | + * @psalm-assert iterable<array<string, T>|null> $array |
|
| 4903 | + * |
|
| 4904 | + * @param mixed $array |
|
| 4905 | + * @param string $message |
|
| 4906 | + * |
|
| 4907 | + * @throws InvalidArgumentException |
|
| 4908 | + * |
|
| 4909 | + * @return void |
|
| 4910 | + */ |
|
| 4911 | + public static function allNullOrIsMap($array, $message = '') |
|
| 4912 | + { |
|
| 4913 | + static::isIterable($array); |
|
| 4914 | + |
|
| 4915 | + foreach ($array as $entry) { |
|
| 4916 | + null === $entry || static::isMap($entry, $message); |
|
| 4917 | + } |
|
| 4918 | + } |
|
| 4919 | + |
|
| 4920 | + /** |
|
| 4921 | + * @psalm-pure |
|
| 4922 | + * @psalm-template T |
|
| 4923 | + * @psalm-param mixed|array<T>|null $array |
|
| 4924 | + * |
|
| 4925 | + * @param mixed $array |
|
| 4926 | + * @param string $message |
|
| 4927 | + * |
|
| 4928 | + * @throws InvalidArgumentException |
|
| 4929 | + * |
|
| 4930 | + * @return void |
|
| 4931 | + */ |
|
| 4932 | + public static function nullOrIsNonEmptyMap($array, $message = '') |
|
| 4933 | + { |
|
| 4934 | + null === $array || static::isNonEmptyMap($array, $message); |
|
| 4935 | + } |
|
| 4936 | + |
|
| 4937 | + /** |
|
| 4938 | + * @psalm-pure |
|
| 4939 | + * @psalm-template T |
|
| 4940 | + * @psalm-param iterable<mixed|array<T>> $array |
|
| 4941 | + * |
|
| 4942 | + * @param mixed $array |
|
| 4943 | + * @param string $message |
|
| 4944 | + * |
|
| 4945 | + * @throws InvalidArgumentException |
|
| 4946 | + * |
|
| 4947 | + * @return void |
|
| 4948 | + */ |
|
| 4949 | + public static function allIsNonEmptyMap($array, $message = '') |
|
| 4950 | + { |
|
| 4951 | + static::isIterable($array); |
|
| 4952 | + |
|
| 4953 | + foreach ($array as $entry) { |
|
| 4954 | + static::isNonEmptyMap($entry, $message); |
|
| 4955 | + } |
|
| 4956 | + } |
|
| 4957 | + |
|
| 4958 | + /** |
|
| 4959 | + * @psalm-pure |
|
| 4960 | + * @psalm-template T |
|
| 4961 | + * @psalm-param iterable<mixed|array<T>|null> $array |
|
| 4962 | + * @psalm-assert iterable<array<string, T>|null> $array |
|
| 4963 | + * @psalm-assert iterable<!empty|null> $array |
|
| 4964 | + * |
|
| 4965 | + * @param mixed $array |
|
| 4966 | + * @param string $message |
|
| 4967 | + * |
|
| 4968 | + * @throws InvalidArgumentException |
|
| 4969 | + * |
|
| 4970 | + * @return void |
|
| 4971 | + */ |
|
| 4972 | + public static function allNullOrIsNonEmptyMap($array, $message = '') |
|
| 4973 | + { |
|
| 4974 | + static::isIterable($array); |
|
| 4975 | + |
|
| 4976 | + foreach ($array as $entry) { |
|
| 4977 | + null === $entry || static::isNonEmptyMap($entry, $message); |
|
| 4978 | + } |
|
| 4979 | + } |
|
| 4980 | + |
|
| 4981 | + /** |
|
| 4982 | + * @psalm-pure |
|
| 4983 | + * |
|
| 4984 | + * @param string|null $value |
|
| 4985 | + * @param string $message |
|
| 4986 | + * |
|
| 4987 | + * @throws InvalidArgumentException |
|
| 4988 | + * |
|
| 4989 | + * @return void |
|
| 4990 | + */ |
|
| 4991 | + public static function nullOrUuid($value, $message = '') |
|
| 4992 | + { |
|
| 4993 | + null === $value || static::uuid($value, $message); |
|
| 4994 | + } |
|
| 4995 | + |
|
| 4996 | + /** |
|
| 4997 | + * @psalm-pure |
|
| 4998 | + * |
|
| 4999 | + * @param iterable<string> $value |
|
| 5000 | + * @param string $message |
|
| 5001 | + * |
|
| 5002 | + * @throws InvalidArgumentException |
|
| 5003 | + * |
|
| 5004 | + * @return void |
|
| 5005 | + */ |
|
| 5006 | + public static function allUuid($value, $message = '') |
|
| 5007 | + { |
|
| 5008 | + static::isIterable($value); |
|
| 5009 | + |
|
| 5010 | + foreach ($value as $entry) { |
|
| 5011 | + static::uuid($entry, $message); |
|
| 5012 | + } |
|
| 5013 | + } |
|
| 5014 | + |
|
| 5015 | + /** |
|
| 5016 | + * @psalm-pure |
|
| 5017 | + * |
|
| 5018 | + * @param iterable<string|null> $value |
|
| 5019 | + * @param string $message |
|
| 5020 | + * |
|
| 5021 | + * @throws InvalidArgumentException |
|
| 5022 | + * |
|
| 5023 | + * @return void |
|
| 5024 | + */ |
|
| 5025 | + public static function allNullOrUuid($value, $message = '') |
|
| 5026 | + { |
|
| 5027 | + static::isIterable($value); |
|
| 5028 | + |
|
| 5029 | + foreach ($value as $entry) { |
|
| 5030 | + null === $entry || static::uuid($entry, $message); |
|
| 5031 | + } |
|
| 5032 | + } |
|
| 5033 | + |
|
| 5034 | + /** |
|
| 5035 | + * @psalm-param class-string<Throwable> $class |
|
| 5036 | + * |
|
| 5037 | + * @param Closure|null $expression |
|
| 5038 | + * @param string $class |
|
| 5039 | + * @param string $message |
|
| 5040 | + * |
|
| 5041 | + * @throws InvalidArgumentException |
|
| 5042 | + * |
|
| 5043 | + * @return void |
|
| 5044 | + */ |
|
| 5045 | + public static function nullOrThrows($expression, $class = 'Exception', $message = '') |
|
| 5046 | + { |
|
| 5047 | + null === $expression || static::throws($expression, $class, $message); |
|
| 5048 | + } |
|
| 5049 | + |
|
| 5050 | + /** |
|
| 5051 | + * @psalm-param class-string<Throwable> $class |
|
| 5052 | + * |
|
| 5053 | + * @param iterable<Closure> $expression |
|
| 5054 | + * @param string $class |
|
| 5055 | + * @param string $message |
|
| 5056 | + * |
|
| 5057 | + * @throws InvalidArgumentException |
|
| 5058 | + * |
|
| 5059 | + * @return void |
|
| 5060 | + */ |
|
| 5061 | + public static function allThrows($expression, $class = 'Exception', $message = '') |
|
| 5062 | + { |
|
| 5063 | + static::isIterable($expression); |
|
| 5064 | + |
|
| 5065 | + foreach ($expression as $entry) { |
|
| 5066 | + static::throws($entry, $class, $message); |
|
| 5067 | + } |
|
| 5068 | + } |
|
| 5069 | + |
|
| 5070 | + /** |
|
| 5071 | + * @psalm-param class-string<Throwable> $class |
|
| 5072 | + * |
|
| 5073 | + * @param iterable<Closure|null> $expression |
|
| 5074 | + * @param string $class |
|
| 5075 | + * @param string $message |
|
| 5076 | + * |
|
| 5077 | + * @throws InvalidArgumentException |
|
| 5078 | + * |
|
| 5079 | + * @return void |
|
| 5080 | + */ |
|
| 5081 | + public static function allNullOrThrows($expression, $class = 'Exception', $message = '') |
|
| 5082 | + { |
|
| 5083 | + static::isIterable($expression); |
|
| 5084 | + |
|
| 5085 | + foreach ($expression as $entry) { |
|
| 5086 | + null === $entry || static::throws($entry, $class, $message); |
|
| 5087 | + } |
|
| 5088 | + } |
|
| 5089 | 5089 | } |
@@ -11,8 +11,7 @@ |
||
| 11 | 11 | * This trait provides nurllOr*, all* and allNullOr* variants of assertion base methods. |
| 12 | 12 | * Do not use this trait directly: it will change, and is not designed for reuse. |
| 13 | 13 | */ |
| 14 | -trait Mixin |
|
| 15 | -{ |
|
| 14 | +trait Mixin { |
|
| 16 | 15 | /** |
| 17 | 16 | * @psalm-pure |
| 18 | 17 | * @psalm-assert string|null $value |
@@ -32,2049 +32,2049 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class Assert |
| 34 | 34 | { |
| 35 | - use Mixin; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @psalm-pure |
|
| 39 | - * @psalm-assert string $value |
|
| 40 | - * |
|
| 41 | - * @param mixed $value |
|
| 42 | - * @param string $message |
|
| 43 | - * |
|
| 44 | - * @throws InvalidArgumentException |
|
| 45 | - */ |
|
| 46 | - public static function string($value, $message = '') |
|
| 47 | - { |
|
| 48 | - if (!\is_string($value)) { |
|
| 49 | - static::reportInvalidArgument(\sprintf( |
|
| 50 | - $message ?: 'Expected a string. Got: %s', |
|
| 51 | - static::typeToString($value) |
|
| 52 | - )); |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @psalm-pure |
|
| 58 | - * @psalm-assert non-empty-string $value |
|
| 59 | - * |
|
| 60 | - * @param mixed $value |
|
| 61 | - * @param string $message |
|
| 62 | - * |
|
| 63 | - * @throws InvalidArgumentException |
|
| 64 | - */ |
|
| 65 | - public static function stringNotEmpty($value, $message = '') |
|
| 66 | - { |
|
| 67 | - static::string($value, $message); |
|
| 68 | - static::notEq($value, '', $message); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @psalm-pure |
|
| 73 | - * @psalm-assert int $value |
|
| 74 | - * |
|
| 75 | - * @param mixed $value |
|
| 76 | - * @param string $message |
|
| 77 | - * |
|
| 78 | - * @throws InvalidArgumentException |
|
| 79 | - */ |
|
| 80 | - public static function integer($value, $message = '') |
|
| 81 | - { |
|
| 82 | - if (!\is_int($value)) { |
|
| 83 | - static::reportInvalidArgument(\sprintf( |
|
| 84 | - $message ?: 'Expected an integer. Got: %s', |
|
| 85 | - static::typeToString($value) |
|
| 86 | - )); |
|
| 87 | - } |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @psalm-pure |
|
| 92 | - * @psalm-assert numeric $value |
|
| 93 | - * |
|
| 94 | - * @param mixed $value |
|
| 95 | - * @param string $message |
|
| 96 | - * |
|
| 97 | - * @throws InvalidArgumentException |
|
| 98 | - */ |
|
| 99 | - public static function integerish($value, $message = '') |
|
| 100 | - { |
|
| 101 | - if (!\is_numeric($value) || $value != (int) $value) { |
|
| 102 | - static::reportInvalidArgument(\sprintf( |
|
| 103 | - $message ?: 'Expected an integerish value. Got: %s', |
|
| 104 | - static::typeToString($value) |
|
| 105 | - )); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @psalm-pure |
|
| 111 | - * @psalm-assert positive-int $value |
|
| 112 | - * |
|
| 113 | - * @param mixed $value |
|
| 114 | - * @param string $message |
|
| 115 | - * |
|
| 116 | - * @throws InvalidArgumentException |
|
| 117 | - */ |
|
| 118 | - public static function positiveInteger($value, $message = '') |
|
| 119 | - { |
|
| 120 | - if (!(\is_int($value) && $value > 0)) { |
|
| 121 | - static::reportInvalidArgument(\sprintf( |
|
| 122 | - $message ?: 'Expected a positive integer. Got: %s', |
|
| 123 | - static::valueToString($value) |
|
| 124 | - )); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @psalm-pure |
|
| 130 | - * @psalm-assert float $value |
|
| 131 | - * |
|
| 132 | - * @param mixed $value |
|
| 133 | - * @param string $message |
|
| 134 | - * |
|
| 135 | - * @throws InvalidArgumentException |
|
| 136 | - */ |
|
| 137 | - public static function float($value, $message = '') |
|
| 138 | - { |
|
| 139 | - if (!\is_float($value)) { |
|
| 140 | - static::reportInvalidArgument(\sprintf( |
|
| 141 | - $message ?: 'Expected a float. Got: %s', |
|
| 142 | - static::typeToString($value) |
|
| 143 | - )); |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * @psalm-pure |
|
| 149 | - * @psalm-assert numeric $value |
|
| 150 | - * |
|
| 151 | - * @param mixed $value |
|
| 152 | - * @param string $message |
|
| 153 | - * |
|
| 154 | - * @throws InvalidArgumentException |
|
| 155 | - */ |
|
| 156 | - public static function numeric($value, $message = '') |
|
| 157 | - { |
|
| 158 | - if (!\is_numeric($value)) { |
|
| 159 | - static::reportInvalidArgument(\sprintf( |
|
| 160 | - $message ?: 'Expected a numeric. Got: %s', |
|
| 161 | - static::typeToString($value) |
|
| 162 | - )); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * @psalm-pure |
|
| 168 | - * @psalm-assert positive-int|0 $value |
|
| 169 | - * |
|
| 170 | - * @param mixed $value |
|
| 171 | - * @param string $message |
|
| 172 | - * |
|
| 173 | - * @throws InvalidArgumentException |
|
| 174 | - */ |
|
| 175 | - public static function natural($value, $message = '') |
|
| 176 | - { |
|
| 177 | - if (!\is_int($value) || $value < 0) { |
|
| 178 | - static::reportInvalidArgument(\sprintf( |
|
| 179 | - $message ?: 'Expected a non-negative integer. Got: %s', |
|
| 180 | - static::valueToString($value) |
|
| 181 | - )); |
|
| 182 | - } |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * @psalm-pure |
|
| 187 | - * @psalm-assert bool $value |
|
| 188 | - * |
|
| 189 | - * @param mixed $value |
|
| 190 | - * @param string $message |
|
| 191 | - * |
|
| 192 | - * @throws InvalidArgumentException |
|
| 193 | - */ |
|
| 194 | - public static function boolean($value, $message = '') |
|
| 195 | - { |
|
| 196 | - if (!\is_bool($value)) { |
|
| 197 | - static::reportInvalidArgument(\sprintf( |
|
| 198 | - $message ?: 'Expected a boolean. Got: %s', |
|
| 199 | - static::typeToString($value) |
|
| 200 | - )); |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * @psalm-pure |
|
| 206 | - * @psalm-assert scalar $value |
|
| 207 | - * |
|
| 208 | - * @param mixed $value |
|
| 209 | - * @param string $message |
|
| 210 | - * |
|
| 211 | - * @throws InvalidArgumentException |
|
| 212 | - */ |
|
| 213 | - public static function scalar($value, $message = '') |
|
| 214 | - { |
|
| 215 | - if (!\is_scalar($value)) { |
|
| 216 | - static::reportInvalidArgument(\sprintf( |
|
| 217 | - $message ?: 'Expected a scalar. Got: %s', |
|
| 218 | - static::typeToString($value) |
|
| 219 | - )); |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * @psalm-pure |
|
| 225 | - * @psalm-assert object $value |
|
| 226 | - * |
|
| 227 | - * @param mixed $value |
|
| 228 | - * @param string $message |
|
| 229 | - * |
|
| 230 | - * @throws InvalidArgumentException |
|
| 231 | - */ |
|
| 232 | - public static function object($value, $message = '') |
|
| 233 | - { |
|
| 234 | - if (!\is_object($value)) { |
|
| 235 | - static::reportInvalidArgument(\sprintf( |
|
| 236 | - $message ?: 'Expected an object. Got: %s', |
|
| 237 | - static::typeToString($value) |
|
| 238 | - )); |
|
| 239 | - } |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * @psalm-pure |
|
| 244 | - * @psalm-assert resource $value |
|
| 245 | - * |
|
| 246 | - * @param mixed $value |
|
| 247 | - * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php |
|
| 248 | - * @param string $message |
|
| 249 | - * |
|
| 250 | - * @throws InvalidArgumentException |
|
| 251 | - */ |
|
| 252 | - public static function resource($value, $type = null, $message = '') |
|
| 253 | - { |
|
| 254 | - if (!\is_resource($value)) { |
|
| 255 | - static::reportInvalidArgument(\sprintf( |
|
| 256 | - $message ?: 'Expected a resource. Got: %s', |
|
| 257 | - static::typeToString($value) |
|
| 258 | - )); |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - if ($type && $type !== \get_resource_type($value)) { |
|
| 262 | - static::reportInvalidArgument(\sprintf( |
|
| 263 | - $message ?: 'Expected a resource of type %2$s. Got: %s', |
|
| 264 | - static::typeToString($value), |
|
| 265 | - $type |
|
| 266 | - )); |
|
| 267 | - } |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * @psalm-pure |
|
| 272 | - * @psalm-assert callable $value |
|
| 273 | - * |
|
| 274 | - * @param mixed $value |
|
| 275 | - * @param string $message |
|
| 276 | - * |
|
| 277 | - * @throws InvalidArgumentException |
|
| 278 | - */ |
|
| 279 | - public static function isCallable($value, $message = '') |
|
| 280 | - { |
|
| 281 | - if (!\is_callable($value)) { |
|
| 282 | - static::reportInvalidArgument(\sprintf( |
|
| 283 | - $message ?: 'Expected a callable. Got: %s', |
|
| 284 | - static::typeToString($value) |
|
| 285 | - )); |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - /** |
|
| 290 | - * @psalm-pure |
|
| 291 | - * @psalm-assert array $value |
|
| 292 | - * |
|
| 293 | - * @param mixed $value |
|
| 294 | - * @param string $message |
|
| 295 | - * |
|
| 296 | - * @throws InvalidArgumentException |
|
| 297 | - */ |
|
| 298 | - public static function isArray($value, $message = '') |
|
| 299 | - { |
|
| 300 | - if (!\is_array($value)) { |
|
| 301 | - static::reportInvalidArgument(\sprintf( |
|
| 302 | - $message ?: 'Expected an array. Got: %s', |
|
| 303 | - static::typeToString($value) |
|
| 304 | - )); |
|
| 305 | - } |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - /** |
|
| 309 | - * @psalm-pure |
|
| 310 | - * @psalm-assert iterable $value |
|
| 311 | - * |
|
| 312 | - * @deprecated use "isIterable" or "isInstanceOf" instead |
|
| 313 | - * |
|
| 314 | - * @param mixed $value |
|
| 315 | - * @param string $message |
|
| 316 | - * |
|
| 317 | - * @throws InvalidArgumentException |
|
| 318 | - */ |
|
| 319 | - public static function isTraversable($value, $message = '') |
|
| 320 | - { |
|
| 321 | - @\trigger_error( |
|
| 322 | - \sprintf( |
|
| 323 | - 'The "%s" assertion is deprecated. You should stop using it, as it will soon be removed in 2.0 version. Use "isIterable" or "isInstanceOf" instead.', |
|
| 324 | - __METHOD__ |
|
| 325 | - ), |
|
| 326 | - \E_USER_DEPRECATED |
|
| 327 | - ); |
|
| 328 | - |
|
| 329 | - if (!\is_array($value) && !($value instanceof Traversable)) { |
|
| 330 | - static::reportInvalidArgument(\sprintf( |
|
| 331 | - $message ?: 'Expected a traversable. Got: %s', |
|
| 332 | - static::typeToString($value) |
|
| 333 | - )); |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - /** |
|
| 338 | - * @psalm-pure |
|
| 339 | - * @psalm-assert array|ArrayAccess $value |
|
| 340 | - * |
|
| 341 | - * @param mixed $value |
|
| 342 | - * @param string $message |
|
| 343 | - * |
|
| 344 | - * @throws InvalidArgumentException |
|
| 345 | - */ |
|
| 346 | - public static function isArrayAccessible($value, $message = '') |
|
| 347 | - { |
|
| 348 | - if (!\is_array($value) && !($value instanceof ArrayAccess)) { |
|
| 349 | - static::reportInvalidArgument(\sprintf( |
|
| 350 | - $message ?: 'Expected an array accessible. Got: %s', |
|
| 351 | - static::typeToString($value) |
|
| 352 | - )); |
|
| 353 | - } |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * @psalm-pure |
|
| 358 | - * @psalm-assert countable $value |
|
| 359 | - * |
|
| 360 | - * @param mixed $value |
|
| 361 | - * @param string $message |
|
| 362 | - * |
|
| 363 | - * @throws InvalidArgumentException |
|
| 364 | - */ |
|
| 365 | - public static function isCountable($value, $message = '') |
|
| 366 | - { |
|
| 367 | - if ( |
|
| 368 | - !\is_array($value) |
|
| 369 | - && !($value instanceof Countable) |
|
| 370 | - && !($value instanceof ResourceBundle) |
|
| 371 | - && !($value instanceof SimpleXMLElement) |
|
| 372 | - ) { |
|
| 373 | - static::reportInvalidArgument(\sprintf( |
|
| 374 | - $message ?: 'Expected a countable. Got: %s', |
|
| 375 | - static::typeToString($value) |
|
| 376 | - )); |
|
| 377 | - } |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * @psalm-pure |
|
| 382 | - * @psalm-assert iterable $value |
|
| 383 | - * |
|
| 384 | - * @param mixed $value |
|
| 385 | - * @param string $message |
|
| 386 | - * |
|
| 387 | - * @throws InvalidArgumentException |
|
| 388 | - */ |
|
| 389 | - public static function isIterable($value, $message = '') |
|
| 390 | - { |
|
| 391 | - if (!\is_array($value) && !($value instanceof Traversable)) { |
|
| 392 | - static::reportInvalidArgument(\sprintf( |
|
| 393 | - $message ?: 'Expected an iterable. Got: %s', |
|
| 394 | - static::typeToString($value) |
|
| 395 | - )); |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - /** |
|
| 400 | - * @psalm-pure |
|
| 401 | - * @psalm-template ExpectedType of object |
|
| 402 | - * @psalm-param class-string<ExpectedType> $class |
|
| 403 | - * @psalm-assert ExpectedType $value |
|
| 404 | - * |
|
| 405 | - * @param mixed $value |
|
| 406 | - * @param string|object $class |
|
| 407 | - * @param string $message |
|
| 408 | - * |
|
| 409 | - * @throws InvalidArgumentException |
|
| 410 | - */ |
|
| 411 | - public static function isInstanceOf($value, $class, $message = '') |
|
| 412 | - { |
|
| 413 | - if (!($value instanceof $class)) { |
|
| 414 | - static::reportInvalidArgument(\sprintf( |
|
| 415 | - $message ?: 'Expected an instance of %2$s. Got: %s', |
|
| 416 | - static::typeToString($value), |
|
| 417 | - $class |
|
| 418 | - )); |
|
| 419 | - } |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - /** |
|
| 423 | - * @psalm-pure |
|
| 424 | - * @psalm-template ExpectedType of object |
|
| 425 | - * @psalm-param class-string<ExpectedType> $class |
|
| 426 | - * @psalm-assert !ExpectedType $value |
|
| 427 | - * |
|
| 428 | - * @param mixed $value |
|
| 429 | - * @param string|object $class |
|
| 430 | - * @param string $message |
|
| 431 | - * |
|
| 432 | - * @throws InvalidArgumentException |
|
| 433 | - */ |
|
| 434 | - public static function notInstanceOf($value, $class, $message = '') |
|
| 435 | - { |
|
| 436 | - if ($value instanceof $class) { |
|
| 437 | - static::reportInvalidArgument(\sprintf( |
|
| 438 | - $message ?: 'Expected an instance other than %2$s. Got: %s', |
|
| 439 | - static::typeToString($value), |
|
| 440 | - $class |
|
| 441 | - )); |
|
| 442 | - } |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - /** |
|
| 446 | - * @psalm-pure |
|
| 447 | - * @psalm-param array<class-string> $classes |
|
| 448 | - * |
|
| 449 | - * @param mixed $value |
|
| 450 | - * @param array<object|string> $classes |
|
| 451 | - * @param string $message |
|
| 452 | - * |
|
| 453 | - * @throws InvalidArgumentException |
|
| 454 | - */ |
|
| 455 | - public static function isInstanceOfAny($value, array $classes, $message = '') |
|
| 456 | - { |
|
| 457 | - foreach ($classes as $class) { |
|
| 458 | - if ($value instanceof $class) { |
|
| 459 | - return; |
|
| 460 | - } |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - static::reportInvalidArgument(\sprintf( |
|
| 464 | - $message ?: 'Expected an instance of any of %2$s. Got: %s', |
|
| 465 | - static::typeToString($value), |
|
| 466 | - \implode(', ', \array_map(array(static::class, 'valueToString'), $classes)) |
|
| 467 | - )); |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - /** |
|
| 471 | - * @psalm-pure |
|
| 472 | - * @psalm-template ExpectedType of object |
|
| 473 | - * @psalm-param class-string<ExpectedType> $class |
|
| 474 | - * @psalm-assert ExpectedType|class-string<ExpectedType> $value |
|
| 475 | - * |
|
| 476 | - * @param object|string $value |
|
| 477 | - * @param string $class |
|
| 478 | - * @param string $message |
|
| 479 | - * |
|
| 480 | - * @throws InvalidArgumentException |
|
| 481 | - */ |
|
| 482 | - public static function isAOf($value, $class, $message = '') |
|
| 483 | - { |
|
| 484 | - static::string($class, 'Expected class as a string. Got: %s'); |
|
| 485 | - |
|
| 486 | - if (!\is_a($value, $class, \is_string($value))) { |
|
| 487 | - static::reportInvalidArgument(sprintf( |
|
| 488 | - $message ?: 'Expected an instance of this class or to this class among its parents "%2$s". Got: %s', |
|
| 489 | - static::valueToString($value), |
|
| 490 | - $class |
|
| 491 | - )); |
|
| 492 | - } |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - /** |
|
| 496 | - * @psalm-pure |
|
| 497 | - * @psalm-template UnexpectedType of object |
|
| 498 | - * @psalm-param class-string<UnexpectedType> $class |
|
| 499 | - * @psalm-assert !UnexpectedType $value |
|
| 500 | - * @psalm-assert !class-string<UnexpectedType> $value |
|
| 501 | - * |
|
| 502 | - * @param object|string $value |
|
| 503 | - * @param string $class |
|
| 504 | - * @param string $message |
|
| 505 | - * |
|
| 506 | - * @throws InvalidArgumentException |
|
| 507 | - */ |
|
| 508 | - public static function isNotA($value, $class, $message = '') |
|
| 509 | - { |
|
| 510 | - static::string($class, 'Expected class as a string. Got: %s'); |
|
| 511 | - |
|
| 512 | - if (\is_a($value, $class, \is_string($value))) { |
|
| 513 | - static::reportInvalidArgument(sprintf( |
|
| 514 | - $message ?: 'Expected an instance of this class or to this class among its parents other than "%2$s". Got: %s', |
|
| 515 | - static::valueToString($value), |
|
| 516 | - $class |
|
| 517 | - )); |
|
| 518 | - } |
|
| 519 | - } |
|
| 520 | - |
|
| 521 | - /** |
|
| 522 | - * @psalm-pure |
|
| 523 | - * @psalm-param array<class-string> $classes |
|
| 524 | - * |
|
| 525 | - * @param object|string $value |
|
| 526 | - * @param string[] $classes |
|
| 527 | - * @param string $message |
|
| 528 | - * |
|
| 529 | - * @throws InvalidArgumentException |
|
| 530 | - */ |
|
| 531 | - public static function isAnyOf($value, array $classes, $message = '') |
|
| 532 | - { |
|
| 533 | - foreach ($classes as $class) { |
|
| 534 | - static::string($class, 'Expected class as a string. Got: %s'); |
|
| 535 | - |
|
| 536 | - if (\is_a($value, $class, \is_string($value))) { |
|
| 537 | - return; |
|
| 538 | - } |
|
| 539 | - } |
|
| 540 | - |
|
| 541 | - static::reportInvalidArgument(sprintf( |
|
| 542 | - $message ?: 'Expected an instance of any of this classes or any of those classes among their parents "%2$s". Got: %s', |
|
| 543 | - static::valueToString($value), |
|
| 544 | - \implode(', ', $classes) |
|
| 545 | - )); |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - /** |
|
| 549 | - * @psalm-pure |
|
| 550 | - * @psalm-assert empty $value |
|
| 551 | - * |
|
| 552 | - * @param mixed $value |
|
| 553 | - * @param string $message |
|
| 554 | - * |
|
| 555 | - * @throws InvalidArgumentException |
|
| 556 | - */ |
|
| 557 | - public static function isEmpty($value, $message = '') |
|
| 558 | - { |
|
| 559 | - if (!empty($value)) { |
|
| 560 | - static::reportInvalidArgument(\sprintf( |
|
| 561 | - $message ?: 'Expected an empty value. Got: %s', |
|
| 562 | - static::valueToString($value) |
|
| 563 | - )); |
|
| 564 | - } |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - /** |
|
| 568 | - * @psalm-pure |
|
| 569 | - * @psalm-assert !empty $value |
|
| 570 | - * |
|
| 571 | - * @param mixed $value |
|
| 572 | - * @param string $message |
|
| 573 | - * |
|
| 574 | - * @throws InvalidArgumentException |
|
| 575 | - */ |
|
| 576 | - public static function notEmpty($value, $message = '') |
|
| 577 | - { |
|
| 578 | - if (empty($value)) { |
|
| 579 | - static::reportInvalidArgument(\sprintf( |
|
| 580 | - $message ?: 'Expected a non-empty value. Got: %s', |
|
| 581 | - static::valueToString($value) |
|
| 582 | - )); |
|
| 583 | - } |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - /** |
|
| 587 | - * @psalm-pure |
|
| 588 | - * @psalm-assert null $value |
|
| 589 | - * |
|
| 590 | - * @param mixed $value |
|
| 591 | - * @param string $message |
|
| 592 | - * |
|
| 593 | - * @throws InvalidArgumentException |
|
| 594 | - */ |
|
| 595 | - public static function null($value, $message = '') |
|
| 596 | - { |
|
| 597 | - if (null !== $value) { |
|
| 598 | - static::reportInvalidArgument(\sprintf( |
|
| 599 | - $message ?: 'Expected null. Got: %s', |
|
| 600 | - static::valueToString($value) |
|
| 601 | - )); |
|
| 602 | - } |
|
| 603 | - } |
|
| 604 | - |
|
| 605 | - /** |
|
| 606 | - * @psalm-pure |
|
| 607 | - * @psalm-assert !null $value |
|
| 608 | - * |
|
| 609 | - * @param mixed $value |
|
| 610 | - * @param string $message |
|
| 611 | - * |
|
| 612 | - * @throws InvalidArgumentException |
|
| 613 | - */ |
|
| 614 | - public static function notNull($value, $message = '') |
|
| 615 | - { |
|
| 616 | - if (null === $value) { |
|
| 617 | - static::reportInvalidArgument( |
|
| 618 | - $message ?: 'Expected a value other than null.' |
|
| 619 | - ); |
|
| 620 | - } |
|
| 621 | - } |
|
| 622 | - |
|
| 623 | - /** |
|
| 624 | - * @psalm-pure |
|
| 625 | - * @psalm-assert true $value |
|
| 626 | - * |
|
| 627 | - * @param mixed $value |
|
| 628 | - * @param string $message |
|
| 629 | - * |
|
| 630 | - * @throws InvalidArgumentException |
|
| 631 | - */ |
|
| 632 | - public static function true($value, $message = '') |
|
| 633 | - { |
|
| 634 | - if (true !== $value) { |
|
| 635 | - static::reportInvalidArgument(\sprintf( |
|
| 636 | - $message ?: 'Expected a value to be true. Got: %s', |
|
| 637 | - static::valueToString($value) |
|
| 638 | - )); |
|
| 639 | - } |
|
| 640 | - } |
|
| 641 | - |
|
| 642 | - /** |
|
| 643 | - * @psalm-pure |
|
| 644 | - * @psalm-assert false $value |
|
| 645 | - * |
|
| 646 | - * @param mixed $value |
|
| 647 | - * @param string $message |
|
| 648 | - * |
|
| 649 | - * @throws InvalidArgumentException |
|
| 650 | - */ |
|
| 651 | - public static function false($value, $message = '') |
|
| 652 | - { |
|
| 653 | - if (false !== $value) { |
|
| 654 | - static::reportInvalidArgument(\sprintf( |
|
| 655 | - $message ?: 'Expected a value to be false. Got: %s', |
|
| 656 | - static::valueToString($value) |
|
| 657 | - )); |
|
| 658 | - } |
|
| 659 | - } |
|
| 660 | - |
|
| 661 | - /** |
|
| 662 | - * @psalm-pure |
|
| 663 | - * @psalm-assert !false $value |
|
| 664 | - * |
|
| 665 | - * @param mixed $value |
|
| 666 | - * @param string $message |
|
| 667 | - * |
|
| 668 | - * @throws InvalidArgumentException |
|
| 669 | - */ |
|
| 670 | - public static function notFalse($value, $message = '') |
|
| 671 | - { |
|
| 672 | - if (false === $value) { |
|
| 673 | - static::reportInvalidArgument( |
|
| 674 | - $message ?: 'Expected a value other than false.' |
|
| 675 | - ); |
|
| 676 | - } |
|
| 677 | - } |
|
| 678 | - |
|
| 679 | - /** |
|
| 680 | - * @param mixed $value |
|
| 681 | - * @param string $message |
|
| 682 | - * |
|
| 683 | - * @throws InvalidArgumentException |
|
| 684 | - */ |
|
| 685 | - public static function ip($value, $message = '') |
|
| 686 | - { |
|
| 687 | - if (false === \filter_var($value, \FILTER_VALIDATE_IP)) { |
|
| 688 | - static::reportInvalidArgument(\sprintf( |
|
| 689 | - $message ?: 'Expected a value to be an IP. Got: %s', |
|
| 690 | - static::valueToString($value) |
|
| 691 | - )); |
|
| 692 | - } |
|
| 693 | - } |
|
| 694 | - |
|
| 695 | - /** |
|
| 696 | - * @param mixed $value |
|
| 697 | - * @param string $message |
|
| 698 | - * |
|
| 699 | - * @throws InvalidArgumentException |
|
| 700 | - */ |
|
| 701 | - public static function ipv4($value, $message = '') |
|
| 702 | - { |
|
| 703 | - if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) { |
|
| 704 | - static::reportInvalidArgument(\sprintf( |
|
| 705 | - $message ?: 'Expected a value to be an IPv4. Got: %s', |
|
| 706 | - static::valueToString($value) |
|
| 707 | - )); |
|
| 708 | - } |
|
| 709 | - } |
|
| 710 | - |
|
| 711 | - /** |
|
| 712 | - * @param mixed $value |
|
| 713 | - * @param string $message |
|
| 714 | - * |
|
| 715 | - * @throws InvalidArgumentException |
|
| 716 | - */ |
|
| 717 | - public static function ipv6($value, $message = '') |
|
| 718 | - { |
|
| 719 | - if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) { |
|
| 720 | - static::reportInvalidArgument(\sprintf( |
|
| 721 | - $message ?: 'Expected a value to be an IPv6. Got: %s', |
|
| 722 | - static::valueToString($value) |
|
| 723 | - )); |
|
| 724 | - } |
|
| 725 | - } |
|
| 726 | - |
|
| 727 | - /** |
|
| 728 | - * @param mixed $value |
|
| 729 | - * @param string $message |
|
| 730 | - * |
|
| 731 | - * @throws InvalidArgumentException |
|
| 732 | - */ |
|
| 733 | - public static function email($value, $message = '') |
|
| 734 | - { |
|
| 735 | - if (false === \filter_var($value, FILTER_VALIDATE_EMAIL)) { |
|
| 736 | - static::reportInvalidArgument(\sprintf( |
|
| 737 | - $message ?: 'Expected a value to be a valid e-mail address. Got: %s', |
|
| 738 | - static::valueToString($value) |
|
| 739 | - )); |
|
| 740 | - } |
|
| 741 | - } |
|
| 742 | - |
|
| 743 | - /** |
|
| 744 | - * Does non strict comparisons on the items, so ['3', 3] will not pass the assertion. |
|
| 745 | - * |
|
| 746 | - * @param array $values |
|
| 747 | - * @param string $message |
|
| 748 | - * |
|
| 749 | - * @throws InvalidArgumentException |
|
| 750 | - */ |
|
| 751 | - public static function uniqueValues(array $values, $message = '') |
|
| 752 | - { |
|
| 753 | - $allValues = \count($values); |
|
| 754 | - $uniqueValues = \count(\array_unique($values)); |
|
| 755 | - |
|
| 756 | - if ($allValues !== $uniqueValues) { |
|
| 757 | - $difference = $allValues - $uniqueValues; |
|
| 758 | - |
|
| 759 | - static::reportInvalidArgument(\sprintf( |
|
| 760 | - $message ?: 'Expected an array of unique values, but %s of them %s duplicated', |
|
| 761 | - $difference, |
|
| 762 | - (1 === $difference ? 'is' : 'are') |
|
| 763 | - )); |
|
| 764 | - } |
|
| 765 | - } |
|
| 766 | - |
|
| 767 | - /** |
|
| 768 | - * @param mixed $value |
|
| 769 | - * @param mixed $expect |
|
| 770 | - * @param string $message |
|
| 771 | - * |
|
| 772 | - * @throws InvalidArgumentException |
|
| 773 | - */ |
|
| 774 | - public static function eq($value, $expect, $message = '') |
|
| 775 | - { |
|
| 776 | - if ($expect != $value) { |
|
| 777 | - static::reportInvalidArgument(\sprintf( |
|
| 778 | - $message ?: 'Expected a value equal to %2$s. Got: %s', |
|
| 779 | - static::valueToString($value), |
|
| 780 | - static::valueToString($expect) |
|
| 781 | - )); |
|
| 782 | - } |
|
| 783 | - } |
|
| 784 | - |
|
| 785 | - /** |
|
| 786 | - * @param mixed $value |
|
| 787 | - * @param mixed $expect |
|
| 788 | - * @param string $message |
|
| 789 | - * |
|
| 790 | - * @throws InvalidArgumentException |
|
| 791 | - */ |
|
| 792 | - public static function notEq($value, $expect, $message = '') |
|
| 793 | - { |
|
| 794 | - if ($expect == $value) { |
|
| 795 | - static::reportInvalidArgument(\sprintf( |
|
| 796 | - $message ?: 'Expected a different value than %s.', |
|
| 797 | - static::valueToString($expect) |
|
| 798 | - )); |
|
| 799 | - } |
|
| 800 | - } |
|
| 801 | - |
|
| 802 | - /** |
|
| 803 | - * @psalm-pure |
|
| 804 | - * |
|
| 805 | - * @param mixed $value |
|
| 806 | - * @param mixed $expect |
|
| 807 | - * @param string $message |
|
| 808 | - * |
|
| 809 | - * @throws InvalidArgumentException |
|
| 810 | - */ |
|
| 811 | - public static function same($value, $expect, $message = '') |
|
| 812 | - { |
|
| 813 | - if ($expect !== $value) { |
|
| 814 | - static::reportInvalidArgument(\sprintf( |
|
| 815 | - $message ?: 'Expected a value identical to %2$s. Got: %s', |
|
| 816 | - static::valueToString($value), |
|
| 817 | - static::valueToString($expect) |
|
| 818 | - )); |
|
| 819 | - } |
|
| 820 | - } |
|
| 821 | - |
|
| 822 | - /** |
|
| 823 | - * @psalm-pure |
|
| 824 | - * |
|
| 825 | - * @param mixed $value |
|
| 826 | - * @param mixed $expect |
|
| 827 | - * @param string $message |
|
| 828 | - * |
|
| 829 | - * @throws InvalidArgumentException |
|
| 830 | - */ |
|
| 831 | - public static function notSame($value, $expect, $message = '') |
|
| 832 | - { |
|
| 833 | - if ($expect === $value) { |
|
| 834 | - static::reportInvalidArgument(\sprintf( |
|
| 835 | - $message ?: 'Expected a value not identical to %s.', |
|
| 836 | - static::valueToString($expect) |
|
| 837 | - )); |
|
| 838 | - } |
|
| 839 | - } |
|
| 840 | - |
|
| 841 | - /** |
|
| 842 | - * @psalm-pure |
|
| 843 | - * |
|
| 844 | - * @param mixed $value |
|
| 845 | - * @param mixed $limit |
|
| 846 | - * @param string $message |
|
| 847 | - * |
|
| 848 | - * @throws InvalidArgumentException |
|
| 849 | - */ |
|
| 850 | - public static function greaterThan($value, $limit, $message = '') |
|
| 851 | - { |
|
| 852 | - if ($value <= $limit) { |
|
| 853 | - static::reportInvalidArgument(\sprintf( |
|
| 854 | - $message ?: 'Expected a value greater than %2$s. Got: %s', |
|
| 855 | - static::valueToString($value), |
|
| 856 | - static::valueToString($limit) |
|
| 857 | - )); |
|
| 858 | - } |
|
| 859 | - } |
|
| 860 | - |
|
| 861 | - /** |
|
| 862 | - * @psalm-pure |
|
| 863 | - * |
|
| 864 | - * @param mixed $value |
|
| 865 | - * @param mixed $limit |
|
| 866 | - * @param string $message |
|
| 867 | - * |
|
| 868 | - * @throws InvalidArgumentException |
|
| 869 | - */ |
|
| 870 | - public static function greaterThanEq($value, $limit, $message = '') |
|
| 871 | - { |
|
| 872 | - if ($value < $limit) { |
|
| 873 | - static::reportInvalidArgument(\sprintf( |
|
| 874 | - $message ?: 'Expected a value greater than or equal to %2$s. Got: %s', |
|
| 875 | - static::valueToString($value), |
|
| 876 | - static::valueToString($limit) |
|
| 877 | - )); |
|
| 878 | - } |
|
| 879 | - } |
|
| 880 | - |
|
| 881 | - /** |
|
| 882 | - * @psalm-pure |
|
| 883 | - * |
|
| 884 | - * @param mixed $value |
|
| 885 | - * @param mixed $limit |
|
| 886 | - * @param string $message |
|
| 887 | - * |
|
| 888 | - * @throws InvalidArgumentException |
|
| 889 | - */ |
|
| 890 | - public static function lessThan($value, $limit, $message = '') |
|
| 891 | - { |
|
| 892 | - if ($value >= $limit) { |
|
| 893 | - static::reportInvalidArgument(\sprintf( |
|
| 894 | - $message ?: 'Expected a value less than %2$s. Got: %s', |
|
| 895 | - static::valueToString($value), |
|
| 896 | - static::valueToString($limit) |
|
| 897 | - )); |
|
| 898 | - } |
|
| 899 | - } |
|
| 900 | - |
|
| 901 | - /** |
|
| 902 | - * @psalm-pure |
|
| 903 | - * |
|
| 904 | - * @param mixed $value |
|
| 905 | - * @param mixed $limit |
|
| 906 | - * @param string $message |
|
| 907 | - * |
|
| 908 | - * @throws InvalidArgumentException |
|
| 909 | - */ |
|
| 910 | - public static function lessThanEq($value, $limit, $message = '') |
|
| 911 | - { |
|
| 912 | - if ($value > $limit) { |
|
| 913 | - static::reportInvalidArgument(\sprintf( |
|
| 914 | - $message ?: 'Expected a value less than or equal to %2$s. Got: %s', |
|
| 915 | - static::valueToString($value), |
|
| 916 | - static::valueToString($limit) |
|
| 917 | - )); |
|
| 918 | - } |
|
| 919 | - } |
|
| 920 | - |
|
| 921 | - /** |
|
| 922 | - * Inclusive range, so Assert::(3, 3, 5) passes. |
|
| 923 | - * |
|
| 924 | - * @psalm-pure |
|
| 925 | - * |
|
| 926 | - * @param mixed $value |
|
| 927 | - * @param mixed $min |
|
| 928 | - * @param mixed $max |
|
| 929 | - * @param string $message |
|
| 930 | - * |
|
| 931 | - * @throws InvalidArgumentException |
|
| 932 | - */ |
|
| 933 | - public static function range($value, $min, $max, $message = '') |
|
| 934 | - { |
|
| 935 | - if ($value < $min || $value > $max) { |
|
| 936 | - static::reportInvalidArgument(\sprintf( |
|
| 937 | - $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 938 | - static::valueToString($value), |
|
| 939 | - static::valueToString($min), |
|
| 940 | - static::valueToString($max) |
|
| 941 | - )); |
|
| 942 | - } |
|
| 943 | - } |
|
| 944 | - |
|
| 945 | - /** |
|
| 946 | - * A more human-readable alias of Assert::inArray(). |
|
| 947 | - * |
|
| 948 | - * @psalm-pure |
|
| 949 | - * |
|
| 950 | - * @param mixed $value |
|
| 951 | - * @param array $values |
|
| 952 | - * @param string $message |
|
| 953 | - * |
|
| 954 | - * @throws InvalidArgumentException |
|
| 955 | - */ |
|
| 956 | - public static function oneOf($value, array $values, $message = '') |
|
| 957 | - { |
|
| 958 | - static::inArray($value, $values, $message); |
|
| 959 | - } |
|
| 960 | - |
|
| 961 | - /** |
|
| 962 | - * Does strict comparison, so Assert::inArray(3, ['3']) does not pass the assertion. |
|
| 963 | - * |
|
| 964 | - * @psalm-pure |
|
| 965 | - * |
|
| 966 | - * @param mixed $value |
|
| 967 | - * @param array $values |
|
| 968 | - * @param string $message |
|
| 969 | - * |
|
| 970 | - * @throws InvalidArgumentException |
|
| 971 | - */ |
|
| 972 | - public static function inArray($value, array $values, $message = '') |
|
| 973 | - { |
|
| 974 | - if (!\in_array($value, $values, true)) { |
|
| 975 | - static::reportInvalidArgument(\sprintf( |
|
| 976 | - $message ?: 'Expected one of: %2$s. Got: %s', |
|
| 977 | - static::valueToString($value), |
|
| 978 | - \implode(', ', \array_map(array(static::class, 'valueToString'), $values)) |
|
| 979 | - )); |
|
| 980 | - } |
|
| 981 | - } |
|
| 982 | - |
|
| 983 | - /** |
|
| 984 | - * @psalm-pure |
|
| 985 | - * |
|
| 986 | - * @param string $value |
|
| 987 | - * @param string $subString |
|
| 988 | - * @param string $message |
|
| 989 | - * |
|
| 990 | - * @throws InvalidArgumentException |
|
| 991 | - */ |
|
| 992 | - public static function contains($value, $subString, $message = '') |
|
| 993 | - { |
|
| 994 | - if (false === \strpos($value, $subString)) { |
|
| 995 | - static::reportInvalidArgument(\sprintf( |
|
| 996 | - $message ?: 'Expected a value to contain %2$s. Got: %s', |
|
| 997 | - static::valueToString($value), |
|
| 998 | - static::valueToString($subString) |
|
| 999 | - )); |
|
| 1000 | - } |
|
| 1001 | - } |
|
| 1002 | - |
|
| 1003 | - /** |
|
| 1004 | - * @psalm-pure |
|
| 1005 | - * |
|
| 1006 | - * @param string $value |
|
| 1007 | - * @param string $subString |
|
| 1008 | - * @param string $message |
|
| 1009 | - * |
|
| 1010 | - * @throws InvalidArgumentException |
|
| 1011 | - */ |
|
| 1012 | - public static function notContains($value, $subString, $message = '') |
|
| 1013 | - { |
|
| 1014 | - if (false !== \strpos($value, $subString)) { |
|
| 1015 | - static::reportInvalidArgument(\sprintf( |
|
| 1016 | - $message ?: '%2$s was not expected to be contained in a value. Got: %s', |
|
| 1017 | - static::valueToString($value), |
|
| 1018 | - static::valueToString($subString) |
|
| 1019 | - )); |
|
| 1020 | - } |
|
| 1021 | - } |
|
| 1022 | - |
|
| 1023 | - /** |
|
| 1024 | - * @psalm-pure |
|
| 1025 | - * |
|
| 1026 | - * @param string $value |
|
| 1027 | - * @param string $message |
|
| 1028 | - * |
|
| 1029 | - * @throws InvalidArgumentException |
|
| 1030 | - */ |
|
| 1031 | - public static function notWhitespaceOnly($value, $message = '') |
|
| 1032 | - { |
|
| 1033 | - if (\preg_match('/^\s*$/', $value)) { |
|
| 1034 | - static::reportInvalidArgument(\sprintf( |
|
| 1035 | - $message ?: 'Expected a non-whitespace string. Got: %s', |
|
| 1036 | - static::valueToString($value) |
|
| 1037 | - )); |
|
| 1038 | - } |
|
| 1039 | - } |
|
| 1040 | - |
|
| 1041 | - /** |
|
| 1042 | - * @psalm-pure |
|
| 1043 | - * |
|
| 1044 | - * @param string $value |
|
| 1045 | - * @param string $prefix |
|
| 1046 | - * @param string $message |
|
| 1047 | - * |
|
| 1048 | - * @throws InvalidArgumentException |
|
| 1049 | - */ |
|
| 1050 | - public static function startsWith($value, $prefix, $message = '') |
|
| 1051 | - { |
|
| 1052 | - if (0 !== \strpos($value, $prefix)) { |
|
| 1053 | - static::reportInvalidArgument(\sprintf( |
|
| 1054 | - $message ?: 'Expected a value to start with %2$s. Got: %s', |
|
| 1055 | - static::valueToString($value), |
|
| 1056 | - static::valueToString($prefix) |
|
| 1057 | - )); |
|
| 1058 | - } |
|
| 1059 | - } |
|
| 1060 | - |
|
| 1061 | - /** |
|
| 1062 | - * @psalm-pure |
|
| 1063 | - * |
|
| 1064 | - * @param string $value |
|
| 1065 | - * @param string $prefix |
|
| 1066 | - * @param string $message |
|
| 1067 | - * |
|
| 1068 | - * @throws InvalidArgumentException |
|
| 1069 | - */ |
|
| 1070 | - public static function notStartsWith($value, $prefix, $message = '') |
|
| 1071 | - { |
|
| 1072 | - if (0 === \strpos($value, $prefix)) { |
|
| 1073 | - static::reportInvalidArgument(\sprintf( |
|
| 1074 | - $message ?: 'Expected a value not to start with %2$s. Got: %s', |
|
| 1075 | - static::valueToString($value), |
|
| 1076 | - static::valueToString($prefix) |
|
| 1077 | - )); |
|
| 1078 | - } |
|
| 1079 | - } |
|
| 1080 | - |
|
| 1081 | - /** |
|
| 1082 | - * @psalm-pure |
|
| 1083 | - * |
|
| 1084 | - * @param mixed $value |
|
| 1085 | - * @param string $message |
|
| 1086 | - * |
|
| 1087 | - * @throws InvalidArgumentException |
|
| 1088 | - */ |
|
| 1089 | - public static function startsWithLetter($value, $message = '') |
|
| 1090 | - { |
|
| 1091 | - static::string($value); |
|
| 1092 | - |
|
| 1093 | - $valid = isset($value[0]); |
|
| 1094 | - |
|
| 1095 | - if ($valid) { |
|
| 1096 | - $locale = \setlocale(LC_CTYPE, 0); |
|
| 1097 | - \setlocale(LC_CTYPE, 'C'); |
|
| 1098 | - $valid = \ctype_alpha($value[0]); |
|
| 1099 | - \setlocale(LC_CTYPE, $locale); |
|
| 1100 | - } |
|
| 1101 | - |
|
| 1102 | - if (!$valid) { |
|
| 1103 | - static::reportInvalidArgument(\sprintf( |
|
| 1104 | - $message ?: 'Expected a value to start with a letter. Got: %s', |
|
| 1105 | - static::valueToString($value) |
|
| 1106 | - )); |
|
| 1107 | - } |
|
| 1108 | - } |
|
| 1109 | - |
|
| 1110 | - /** |
|
| 1111 | - * @psalm-pure |
|
| 1112 | - * |
|
| 1113 | - * @param string $value |
|
| 1114 | - * @param string $suffix |
|
| 1115 | - * @param string $message |
|
| 1116 | - * |
|
| 1117 | - * @throws InvalidArgumentException |
|
| 1118 | - */ |
|
| 1119 | - public static function endsWith($value, $suffix, $message = '') |
|
| 1120 | - { |
|
| 1121 | - if ($suffix !== \substr($value, -\strlen($suffix))) { |
|
| 1122 | - static::reportInvalidArgument(\sprintf( |
|
| 1123 | - $message ?: 'Expected a value to end with %2$s. Got: %s', |
|
| 1124 | - static::valueToString($value), |
|
| 1125 | - static::valueToString($suffix) |
|
| 1126 | - )); |
|
| 1127 | - } |
|
| 1128 | - } |
|
| 1129 | - |
|
| 1130 | - /** |
|
| 1131 | - * @psalm-pure |
|
| 1132 | - * |
|
| 1133 | - * @param string $value |
|
| 1134 | - * @param string $suffix |
|
| 1135 | - * @param string $message |
|
| 1136 | - * |
|
| 1137 | - * @throws InvalidArgumentException |
|
| 1138 | - */ |
|
| 1139 | - public static function notEndsWith($value, $suffix, $message = '') |
|
| 1140 | - { |
|
| 1141 | - if ($suffix === \substr($value, -\strlen($suffix))) { |
|
| 1142 | - static::reportInvalidArgument(\sprintf( |
|
| 1143 | - $message ?: 'Expected a value not to end with %2$s. Got: %s', |
|
| 1144 | - static::valueToString($value), |
|
| 1145 | - static::valueToString($suffix) |
|
| 1146 | - )); |
|
| 1147 | - } |
|
| 1148 | - } |
|
| 1149 | - |
|
| 1150 | - /** |
|
| 1151 | - * @psalm-pure |
|
| 1152 | - * |
|
| 1153 | - * @param string $value |
|
| 1154 | - * @param string $pattern |
|
| 1155 | - * @param string $message |
|
| 1156 | - * |
|
| 1157 | - * @throws InvalidArgumentException |
|
| 1158 | - */ |
|
| 1159 | - public static function regex($value, $pattern, $message = '') |
|
| 1160 | - { |
|
| 1161 | - if (!\preg_match($pattern, $value)) { |
|
| 1162 | - static::reportInvalidArgument(\sprintf( |
|
| 1163 | - $message ?: 'The value %s does not match the expected pattern.', |
|
| 1164 | - static::valueToString($value) |
|
| 1165 | - )); |
|
| 1166 | - } |
|
| 1167 | - } |
|
| 1168 | - |
|
| 1169 | - /** |
|
| 1170 | - * @psalm-pure |
|
| 1171 | - * |
|
| 1172 | - * @param string $value |
|
| 1173 | - * @param string $pattern |
|
| 1174 | - * @param string $message |
|
| 1175 | - * |
|
| 1176 | - * @throws InvalidArgumentException |
|
| 1177 | - */ |
|
| 1178 | - public static function notRegex($value, $pattern, $message = '') |
|
| 1179 | - { |
|
| 1180 | - if (\preg_match($pattern, $value, $matches, PREG_OFFSET_CAPTURE)) { |
|
| 1181 | - static::reportInvalidArgument(\sprintf( |
|
| 1182 | - $message ?: 'The value %s matches the pattern %s (at offset %d).', |
|
| 1183 | - static::valueToString($value), |
|
| 1184 | - static::valueToString($pattern), |
|
| 1185 | - $matches[0][1] |
|
| 1186 | - )); |
|
| 1187 | - } |
|
| 1188 | - } |
|
| 1189 | - |
|
| 1190 | - /** |
|
| 1191 | - * @psalm-pure |
|
| 1192 | - * |
|
| 1193 | - * @param mixed $value |
|
| 1194 | - * @param string $message |
|
| 1195 | - * |
|
| 1196 | - * @throws InvalidArgumentException |
|
| 1197 | - */ |
|
| 1198 | - public static function unicodeLetters($value, $message = '') |
|
| 1199 | - { |
|
| 1200 | - static::string($value); |
|
| 1201 | - |
|
| 1202 | - if (!\preg_match('/^\p{L}+$/u', $value)) { |
|
| 1203 | - static::reportInvalidArgument(\sprintf( |
|
| 1204 | - $message ?: 'Expected a value to contain only Unicode letters. Got: %s', |
|
| 1205 | - static::valueToString($value) |
|
| 1206 | - )); |
|
| 1207 | - } |
|
| 1208 | - } |
|
| 1209 | - |
|
| 1210 | - /** |
|
| 1211 | - * @psalm-pure |
|
| 1212 | - * |
|
| 1213 | - * @param mixed $value |
|
| 1214 | - * @param string $message |
|
| 1215 | - * |
|
| 1216 | - * @throws InvalidArgumentException |
|
| 1217 | - */ |
|
| 1218 | - public static function alpha($value, $message = '') |
|
| 1219 | - { |
|
| 1220 | - static::string($value); |
|
| 1221 | - |
|
| 1222 | - $locale = \setlocale(LC_CTYPE, 0); |
|
| 1223 | - \setlocale(LC_CTYPE, 'C'); |
|
| 1224 | - $valid = !\ctype_alpha($value); |
|
| 1225 | - \setlocale(LC_CTYPE, $locale); |
|
| 1226 | - |
|
| 1227 | - if ($valid) { |
|
| 1228 | - static::reportInvalidArgument(\sprintf( |
|
| 1229 | - $message ?: 'Expected a value to contain only letters. Got: %s', |
|
| 1230 | - static::valueToString($value) |
|
| 1231 | - )); |
|
| 1232 | - } |
|
| 1233 | - } |
|
| 1234 | - |
|
| 1235 | - /** |
|
| 1236 | - * @psalm-pure |
|
| 1237 | - * |
|
| 1238 | - * @param string $value |
|
| 1239 | - * @param string $message |
|
| 1240 | - * |
|
| 1241 | - * @throws InvalidArgumentException |
|
| 1242 | - */ |
|
| 1243 | - public static function digits($value, $message = '') |
|
| 1244 | - { |
|
| 1245 | - $locale = \setlocale(LC_CTYPE, 0); |
|
| 1246 | - \setlocale(LC_CTYPE, 'C'); |
|
| 1247 | - $valid = !\ctype_digit($value); |
|
| 1248 | - \setlocale(LC_CTYPE, $locale); |
|
| 1249 | - |
|
| 1250 | - if ($valid) { |
|
| 1251 | - static::reportInvalidArgument(\sprintf( |
|
| 1252 | - $message ?: 'Expected a value to contain digits only. Got: %s', |
|
| 1253 | - static::valueToString($value) |
|
| 1254 | - )); |
|
| 1255 | - } |
|
| 1256 | - } |
|
| 1257 | - |
|
| 1258 | - /** |
|
| 1259 | - * @psalm-pure |
|
| 1260 | - * |
|
| 1261 | - * @param string $value |
|
| 1262 | - * @param string $message |
|
| 1263 | - * |
|
| 1264 | - * @throws InvalidArgumentException |
|
| 1265 | - */ |
|
| 1266 | - public static function alnum($value, $message = '') |
|
| 1267 | - { |
|
| 1268 | - $locale = \setlocale(LC_CTYPE, 0); |
|
| 1269 | - \setlocale(LC_CTYPE, 'C'); |
|
| 1270 | - $valid = !\ctype_alnum($value); |
|
| 1271 | - \setlocale(LC_CTYPE, $locale); |
|
| 1272 | - |
|
| 1273 | - if ($valid) { |
|
| 1274 | - static::reportInvalidArgument(\sprintf( |
|
| 1275 | - $message ?: 'Expected a value to contain letters and digits only. Got: %s', |
|
| 1276 | - static::valueToString($value) |
|
| 1277 | - )); |
|
| 1278 | - } |
|
| 1279 | - } |
|
| 1280 | - |
|
| 1281 | - /** |
|
| 1282 | - * @psalm-pure |
|
| 1283 | - * @psalm-assert lowercase-string $value |
|
| 1284 | - * |
|
| 1285 | - * @param string $value |
|
| 1286 | - * @param string $message |
|
| 1287 | - * |
|
| 1288 | - * @throws InvalidArgumentException |
|
| 1289 | - */ |
|
| 1290 | - public static function lower($value, $message = '') |
|
| 1291 | - { |
|
| 1292 | - $locale = \setlocale(LC_CTYPE, 0); |
|
| 1293 | - \setlocale(LC_CTYPE, 'C'); |
|
| 1294 | - $valid = !\ctype_lower($value); |
|
| 1295 | - \setlocale(LC_CTYPE, $locale); |
|
| 1296 | - |
|
| 1297 | - if ($valid) { |
|
| 1298 | - static::reportInvalidArgument(\sprintf( |
|
| 1299 | - $message ?: 'Expected a value to contain lowercase characters only. Got: %s', |
|
| 1300 | - static::valueToString($value) |
|
| 1301 | - )); |
|
| 1302 | - } |
|
| 1303 | - } |
|
| 1304 | - |
|
| 1305 | - /** |
|
| 1306 | - * @psalm-pure |
|
| 1307 | - * @psalm-assert !lowercase-string $value |
|
| 1308 | - * |
|
| 1309 | - * @param string $value |
|
| 1310 | - * @param string $message |
|
| 1311 | - * |
|
| 1312 | - * @throws InvalidArgumentException |
|
| 1313 | - */ |
|
| 1314 | - public static function upper($value, $message = '') |
|
| 1315 | - { |
|
| 1316 | - $locale = \setlocale(LC_CTYPE, 0); |
|
| 1317 | - \setlocale(LC_CTYPE, 'C'); |
|
| 1318 | - $valid = !\ctype_upper($value); |
|
| 1319 | - \setlocale(LC_CTYPE, $locale); |
|
| 1320 | - |
|
| 1321 | - if ($valid) { |
|
| 1322 | - static::reportInvalidArgument(\sprintf( |
|
| 1323 | - $message ?: 'Expected a value to contain uppercase characters only. Got: %s', |
|
| 1324 | - static::valueToString($value) |
|
| 1325 | - )); |
|
| 1326 | - } |
|
| 1327 | - } |
|
| 1328 | - |
|
| 1329 | - /** |
|
| 1330 | - * @psalm-pure |
|
| 1331 | - * |
|
| 1332 | - * @param string $value |
|
| 1333 | - * @param int $length |
|
| 1334 | - * @param string $message |
|
| 1335 | - * |
|
| 1336 | - * @throws InvalidArgumentException |
|
| 1337 | - */ |
|
| 1338 | - public static function length($value, $length, $message = '') |
|
| 1339 | - { |
|
| 1340 | - if ($length !== static::strlen($value)) { |
|
| 1341 | - static::reportInvalidArgument(\sprintf( |
|
| 1342 | - $message ?: 'Expected a value to contain %2$s characters. Got: %s', |
|
| 1343 | - static::valueToString($value), |
|
| 1344 | - $length |
|
| 1345 | - )); |
|
| 1346 | - } |
|
| 1347 | - } |
|
| 1348 | - |
|
| 1349 | - /** |
|
| 1350 | - * Inclusive min. |
|
| 1351 | - * |
|
| 1352 | - * @psalm-pure |
|
| 1353 | - * |
|
| 1354 | - * @param string $value |
|
| 1355 | - * @param int|float $min |
|
| 1356 | - * @param string $message |
|
| 1357 | - * |
|
| 1358 | - * @throws InvalidArgumentException |
|
| 1359 | - */ |
|
| 1360 | - public static function minLength($value, $min, $message = '') |
|
| 1361 | - { |
|
| 1362 | - if (static::strlen($value) < $min) { |
|
| 1363 | - static::reportInvalidArgument(\sprintf( |
|
| 1364 | - $message ?: 'Expected a value to contain at least %2$s characters. Got: %s', |
|
| 1365 | - static::valueToString($value), |
|
| 1366 | - $min |
|
| 1367 | - )); |
|
| 1368 | - } |
|
| 1369 | - } |
|
| 1370 | - |
|
| 1371 | - /** |
|
| 1372 | - * Inclusive max. |
|
| 1373 | - * |
|
| 1374 | - * @psalm-pure |
|
| 1375 | - * |
|
| 1376 | - * @param string $value |
|
| 1377 | - * @param int|float $max |
|
| 1378 | - * @param string $message |
|
| 1379 | - * |
|
| 1380 | - * @throws InvalidArgumentException |
|
| 1381 | - */ |
|
| 1382 | - public static function maxLength($value, $max, $message = '') |
|
| 1383 | - { |
|
| 1384 | - if (static::strlen($value) > $max) { |
|
| 1385 | - static::reportInvalidArgument(\sprintf( |
|
| 1386 | - $message ?: 'Expected a value to contain at most %2$s characters. Got: %s', |
|
| 1387 | - static::valueToString($value), |
|
| 1388 | - $max |
|
| 1389 | - )); |
|
| 1390 | - } |
|
| 1391 | - } |
|
| 1392 | - |
|
| 1393 | - /** |
|
| 1394 | - * Inclusive , so Assert::lengthBetween('asd', 3, 5); passes the assertion. |
|
| 1395 | - * |
|
| 1396 | - * @psalm-pure |
|
| 1397 | - * |
|
| 1398 | - * @param string $value |
|
| 1399 | - * @param int|float $min |
|
| 1400 | - * @param int|float $max |
|
| 1401 | - * @param string $message |
|
| 1402 | - * |
|
| 1403 | - * @throws InvalidArgumentException |
|
| 1404 | - */ |
|
| 1405 | - public static function lengthBetween($value, $min, $max, $message = '') |
|
| 1406 | - { |
|
| 1407 | - $length = static::strlen($value); |
|
| 1408 | - |
|
| 1409 | - if ($length < $min || $length > $max) { |
|
| 1410 | - static::reportInvalidArgument(\sprintf( |
|
| 1411 | - $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 1412 | - static::valueToString($value), |
|
| 1413 | - $min, |
|
| 1414 | - $max |
|
| 1415 | - )); |
|
| 1416 | - } |
|
| 1417 | - } |
|
| 1418 | - |
|
| 1419 | - /** |
|
| 1420 | - * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |
|
| 1421 | - * |
|
| 1422 | - * @param mixed $value |
|
| 1423 | - * @param string $message |
|
| 1424 | - * |
|
| 1425 | - * @throws InvalidArgumentException |
|
| 1426 | - */ |
|
| 1427 | - public static function fileExists($value, $message = '') |
|
| 1428 | - { |
|
| 1429 | - static::string($value); |
|
| 1430 | - |
|
| 1431 | - if (!\file_exists($value)) { |
|
| 1432 | - static::reportInvalidArgument(\sprintf( |
|
| 1433 | - $message ?: 'The file %s does not exist.', |
|
| 1434 | - static::valueToString($value) |
|
| 1435 | - )); |
|
| 1436 | - } |
|
| 1437 | - } |
|
| 1438 | - |
|
| 1439 | - /** |
|
| 1440 | - * @param mixed $value |
|
| 1441 | - * @param string $message |
|
| 1442 | - * |
|
| 1443 | - * @throws InvalidArgumentException |
|
| 1444 | - */ |
|
| 1445 | - public static function file($value, $message = '') |
|
| 1446 | - { |
|
| 1447 | - static::fileExists($value, $message); |
|
| 1448 | - |
|
| 1449 | - if (!\is_file($value)) { |
|
| 1450 | - static::reportInvalidArgument(\sprintf( |
|
| 1451 | - $message ?: 'The path %s is not a file.', |
|
| 1452 | - static::valueToString($value) |
|
| 1453 | - )); |
|
| 1454 | - } |
|
| 1455 | - } |
|
| 1456 | - |
|
| 1457 | - /** |
|
| 1458 | - * @param mixed $value |
|
| 1459 | - * @param string $message |
|
| 1460 | - * |
|
| 1461 | - * @throws InvalidArgumentException |
|
| 1462 | - */ |
|
| 1463 | - public static function directory($value, $message = '') |
|
| 1464 | - { |
|
| 1465 | - static::fileExists($value, $message); |
|
| 1466 | - |
|
| 1467 | - if (!\is_dir($value)) { |
|
| 1468 | - static::reportInvalidArgument(\sprintf( |
|
| 1469 | - $message ?: 'The path %s is no directory.', |
|
| 1470 | - static::valueToString($value) |
|
| 1471 | - )); |
|
| 1472 | - } |
|
| 1473 | - } |
|
| 1474 | - |
|
| 1475 | - /** |
|
| 1476 | - * @param string $value |
|
| 1477 | - * @param string $message |
|
| 1478 | - * |
|
| 1479 | - * @throws InvalidArgumentException |
|
| 1480 | - */ |
|
| 1481 | - public static function readable($value, $message = '') |
|
| 1482 | - { |
|
| 1483 | - if (!\is_readable($value)) { |
|
| 1484 | - static::reportInvalidArgument(\sprintf( |
|
| 1485 | - $message ?: 'The path %s is not readable.', |
|
| 1486 | - static::valueToString($value) |
|
| 1487 | - )); |
|
| 1488 | - } |
|
| 1489 | - } |
|
| 1490 | - |
|
| 1491 | - /** |
|
| 1492 | - * @param string $value |
|
| 1493 | - * @param string $message |
|
| 1494 | - * |
|
| 1495 | - * @throws InvalidArgumentException |
|
| 1496 | - */ |
|
| 1497 | - public static function writable($value, $message = '') |
|
| 1498 | - { |
|
| 1499 | - if (!\is_writable($value)) { |
|
| 1500 | - static::reportInvalidArgument(\sprintf( |
|
| 1501 | - $message ?: 'The path %s is not writable.', |
|
| 1502 | - static::valueToString($value) |
|
| 1503 | - )); |
|
| 1504 | - } |
|
| 1505 | - } |
|
| 1506 | - |
|
| 1507 | - /** |
|
| 1508 | - * @psalm-assert class-string $value |
|
| 1509 | - * |
|
| 1510 | - * @param mixed $value |
|
| 1511 | - * @param string $message |
|
| 1512 | - * |
|
| 1513 | - * @throws InvalidArgumentException |
|
| 1514 | - */ |
|
| 1515 | - public static function classExists($value, $message = '') |
|
| 1516 | - { |
|
| 1517 | - if (!\class_exists($value)) { |
|
| 1518 | - static::reportInvalidArgument(\sprintf( |
|
| 1519 | - $message ?: 'Expected an existing class name. Got: %s', |
|
| 1520 | - static::valueToString($value) |
|
| 1521 | - )); |
|
| 1522 | - } |
|
| 1523 | - } |
|
| 1524 | - |
|
| 1525 | - /** |
|
| 1526 | - * @psalm-pure |
|
| 1527 | - * @psalm-template ExpectedType of object |
|
| 1528 | - * @psalm-param class-string<ExpectedType> $class |
|
| 1529 | - * @psalm-assert class-string<ExpectedType>|ExpectedType $value |
|
| 1530 | - * |
|
| 1531 | - * @param mixed $value |
|
| 1532 | - * @param string|object $class |
|
| 1533 | - * @param string $message |
|
| 1534 | - * |
|
| 1535 | - * @throws InvalidArgumentException |
|
| 1536 | - */ |
|
| 1537 | - public static function subclassOf($value, $class, $message = '') |
|
| 1538 | - { |
|
| 1539 | - if (!\is_subclass_of($value, $class)) { |
|
| 1540 | - static::reportInvalidArgument(\sprintf( |
|
| 1541 | - $message ?: 'Expected a sub-class of %2$s. Got: %s', |
|
| 1542 | - static::valueToString($value), |
|
| 1543 | - static::valueToString($class) |
|
| 1544 | - )); |
|
| 1545 | - } |
|
| 1546 | - } |
|
| 1547 | - |
|
| 1548 | - /** |
|
| 1549 | - * @psalm-assert class-string $value |
|
| 1550 | - * |
|
| 1551 | - * @param mixed $value |
|
| 1552 | - * @param string $message |
|
| 1553 | - * |
|
| 1554 | - * @throws InvalidArgumentException |
|
| 1555 | - */ |
|
| 1556 | - public static function interfaceExists($value, $message = '') |
|
| 1557 | - { |
|
| 1558 | - if (!\interface_exists($value)) { |
|
| 1559 | - static::reportInvalidArgument(\sprintf( |
|
| 1560 | - $message ?: 'Expected an existing interface name. got %s', |
|
| 1561 | - static::valueToString($value) |
|
| 1562 | - )); |
|
| 1563 | - } |
|
| 1564 | - } |
|
| 1565 | - |
|
| 1566 | - /** |
|
| 1567 | - * @psalm-pure |
|
| 1568 | - * @psalm-template ExpectedType of object |
|
| 1569 | - * @psalm-param class-string<ExpectedType> $interface |
|
| 1570 | - * @psalm-assert class-string<ExpectedType> $value |
|
| 1571 | - * |
|
| 1572 | - * @param mixed $value |
|
| 1573 | - * @param mixed $interface |
|
| 1574 | - * @param string $message |
|
| 1575 | - * |
|
| 1576 | - * @throws InvalidArgumentException |
|
| 1577 | - */ |
|
| 1578 | - public static function implementsInterface($value, $interface, $message = '') |
|
| 1579 | - { |
|
| 1580 | - if (!\in_array($interface, \class_implements($value))) { |
|
| 1581 | - static::reportInvalidArgument(\sprintf( |
|
| 1582 | - $message ?: 'Expected an implementation of %2$s. Got: %s', |
|
| 1583 | - static::valueToString($value), |
|
| 1584 | - static::valueToString($interface) |
|
| 1585 | - )); |
|
| 1586 | - } |
|
| 1587 | - } |
|
| 1588 | - |
|
| 1589 | - /** |
|
| 1590 | - * @psalm-pure |
|
| 1591 | - * @psalm-param class-string|object $classOrObject |
|
| 1592 | - * |
|
| 1593 | - * @param string|object $classOrObject |
|
| 1594 | - * @param mixed $property |
|
| 1595 | - * @param string $message |
|
| 1596 | - * |
|
| 1597 | - * @throws InvalidArgumentException |
|
| 1598 | - */ |
|
| 1599 | - public static function propertyExists($classOrObject, $property, $message = '') |
|
| 1600 | - { |
|
| 1601 | - if (!\property_exists($classOrObject, $property)) { |
|
| 1602 | - static::reportInvalidArgument(\sprintf( |
|
| 1603 | - $message ?: 'Expected the property %s to exist.', |
|
| 1604 | - static::valueToString($property) |
|
| 1605 | - )); |
|
| 1606 | - } |
|
| 1607 | - } |
|
| 1608 | - |
|
| 1609 | - /** |
|
| 1610 | - * @psalm-pure |
|
| 1611 | - * @psalm-param class-string|object $classOrObject |
|
| 1612 | - * |
|
| 1613 | - * @param string|object $classOrObject |
|
| 1614 | - * @param mixed $property |
|
| 1615 | - * @param string $message |
|
| 1616 | - * |
|
| 1617 | - * @throws InvalidArgumentException |
|
| 1618 | - */ |
|
| 1619 | - public static function propertyNotExists($classOrObject, $property, $message = '') |
|
| 1620 | - { |
|
| 1621 | - if (\property_exists($classOrObject, $property)) { |
|
| 1622 | - static::reportInvalidArgument(\sprintf( |
|
| 1623 | - $message ?: 'Expected the property %s to not exist.', |
|
| 1624 | - static::valueToString($property) |
|
| 1625 | - )); |
|
| 1626 | - } |
|
| 1627 | - } |
|
| 1628 | - |
|
| 1629 | - /** |
|
| 1630 | - * @psalm-pure |
|
| 1631 | - * @psalm-param class-string|object $classOrObject |
|
| 1632 | - * |
|
| 1633 | - * @param string|object $classOrObject |
|
| 1634 | - * @param mixed $method |
|
| 1635 | - * @param string $message |
|
| 1636 | - * |
|
| 1637 | - * @throws InvalidArgumentException |
|
| 1638 | - */ |
|
| 1639 | - public static function methodExists($classOrObject, $method, $message = '') |
|
| 1640 | - { |
|
| 1641 | - if (!(\is_string($classOrObject) || \is_object($classOrObject)) || !\method_exists($classOrObject, $method)) { |
|
| 1642 | - static::reportInvalidArgument(\sprintf( |
|
| 1643 | - $message ?: 'Expected the method %s to exist.', |
|
| 1644 | - static::valueToString($method) |
|
| 1645 | - )); |
|
| 1646 | - } |
|
| 1647 | - } |
|
| 1648 | - |
|
| 1649 | - /** |
|
| 1650 | - * @psalm-pure |
|
| 1651 | - * @psalm-param class-string|object $classOrObject |
|
| 1652 | - * |
|
| 1653 | - * @param string|object $classOrObject |
|
| 1654 | - * @param mixed $method |
|
| 1655 | - * @param string $message |
|
| 1656 | - * |
|
| 1657 | - * @throws InvalidArgumentException |
|
| 1658 | - */ |
|
| 1659 | - public static function methodNotExists($classOrObject, $method, $message = '') |
|
| 1660 | - { |
|
| 1661 | - if ((\is_string($classOrObject) || \is_object($classOrObject)) && \method_exists($classOrObject, $method)) { |
|
| 1662 | - static::reportInvalidArgument(\sprintf( |
|
| 1663 | - $message ?: 'Expected the method %s to not exist.', |
|
| 1664 | - static::valueToString($method) |
|
| 1665 | - )); |
|
| 1666 | - } |
|
| 1667 | - } |
|
| 1668 | - |
|
| 1669 | - /** |
|
| 1670 | - * @psalm-pure |
|
| 1671 | - * |
|
| 1672 | - * @param array $array |
|
| 1673 | - * @param string|int $key |
|
| 1674 | - * @param string $message |
|
| 1675 | - * |
|
| 1676 | - * @throws InvalidArgumentException |
|
| 1677 | - */ |
|
| 1678 | - public static function keyExists($array, $key, $message = '') |
|
| 1679 | - { |
|
| 1680 | - if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
| 1681 | - static::reportInvalidArgument(\sprintf( |
|
| 1682 | - $message ?: 'Expected the key %s to exist.', |
|
| 1683 | - static::valueToString($key) |
|
| 1684 | - )); |
|
| 1685 | - } |
|
| 1686 | - } |
|
| 1687 | - |
|
| 1688 | - /** |
|
| 1689 | - * @psalm-pure |
|
| 1690 | - * |
|
| 1691 | - * @param array $array |
|
| 1692 | - * @param string|int $key |
|
| 1693 | - * @param string $message |
|
| 1694 | - * |
|
| 1695 | - * @throws InvalidArgumentException |
|
| 1696 | - */ |
|
| 1697 | - public static function keyNotExists($array, $key, $message = '') |
|
| 1698 | - { |
|
| 1699 | - if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
| 1700 | - static::reportInvalidArgument(\sprintf( |
|
| 1701 | - $message ?: 'Expected the key %s to not exist.', |
|
| 1702 | - static::valueToString($key) |
|
| 1703 | - )); |
|
| 1704 | - } |
|
| 1705 | - } |
|
| 1706 | - |
|
| 1707 | - /** |
|
| 1708 | - * Checks if a value is a valid array key (int or string). |
|
| 1709 | - * |
|
| 1710 | - * @psalm-pure |
|
| 1711 | - * @psalm-assert array-key $value |
|
| 1712 | - * |
|
| 1713 | - * @param mixed $value |
|
| 1714 | - * @param string $message |
|
| 1715 | - * |
|
| 1716 | - * @throws InvalidArgumentException |
|
| 1717 | - */ |
|
| 1718 | - public static function validArrayKey($value, $message = '') |
|
| 1719 | - { |
|
| 1720 | - if (!(\is_int($value) || \is_string($value))) { |
|
| 1721 | - static::reportInvalidArgument(\sprintf( |
|
| 1722 | - $message ?: 'Expected string or integer. Got: %s', |
|
| 1723 | - static::typeToString($value) |
|
| 1724 | - )); |
|
| 1725 | - } |
|
| 1726 | - } |
|
| 1727 | - |
|
| 1728 | - /** |
|
| 1729 | - * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| 1730 | - * |
|
| 1731 | - * @param Countable|array $array |
|
| 1732 | - * @param int $number |
|
| 1733 | - * @param string $message |
|
| 1734 | - * |
|
| 1735 | - * @throws InvalidArgumentException |
|
| 1736 | - */ |
|
| 1737 | - public static function count($array, $number, $message = '') |
|
| 1738 | - { |
|
| 1739 | - static::eq( |
|
| 1740 | - \count($array), |
|
| 1741 | - $number, |
|
| 1742 | - \sprintf( |
|
| 1743 | - $message ?: 'Expected an array to contain %d elements. Got: %d.', |
|
| 1744 | - $number, |
|
| 1745 | - \count($array) |
|
| 1746 | - ) |
|
| 1747 | - ); |
|
| 1748 | - } |
|
| 1749 | - |
|
| 1750 | - /** |
|
| 1751 | - * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| 1752 | - * |
|
| 1753 | - * @param Countable|array $array |
|
| 1754 | - * @param int|float $min |
|
| 1755 | - * @param string $message |
|
| 1756 | - * |
|
| 1757 | - * @throws InvalidArgumentException |
|
| 1758 | - */ |
|
| 1759 | - public static function minCount($array, $min, $message = '') |
|
| 1760 | - { |
|
| 1761 | - if (\count($array) < $min) { |
|
| 1762 | - static::reportInvalidArgument(\sprintf( |
|
| 1763 | - $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 1764 | - \count($array), |
|
| 1765 | - $min |
|
| 1766 | - )); |
|
| 1767 | - } |
|
| 1768 | - } |
|
| 1769 | - |
|
| 1770 | - /** |
|
| 1771 | - * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| 1772 | - * |
|
| 1773 | - * @param Countable|array $array |
|
| 1774 | - * @param int|float $max |
|
| 1775 | - * @param string $message |
|
| 1776 | - * |
|
| 1777 | - * @throws InvalidArgumentException |
|
| 1778 | - */ |
|
| 1779 | - public static function maxCount($array, $max, $message = '') |
|
| 1780 | - { |
|
| 1781 | - if (\count($array) > $max) { |
|
| 1782 | - static::reportInvalidArgument(\sprintf( |
|
| 1783 | - $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 1784 | - \count($array), |
|
| 1785 | - $max |
|
| 1786 | - )); |
|
| 1787 | - } |
|
| 1788 | - } |
|
| 1789 | - |
|
| 1790 | - /** |
|
| 1791 | - * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| 1792 | - * |
|
| 1793 | - * @param Countable|array $array |
|
| 1794 | - * @param int|float $min |
|
| 1795 | - * @param int|float $max |
|
| 1796 | - * @param string $message |
|
| 1797 | - * |
|
| 1798 | - * @throws InvalidArgumentException |
|
| 1799 | - */ |
|
| 1800 | - public static function countBetween($array, $min, $max, $message = '') |
|
| 1801 | - { |
|
| 1802 | - $count = \count($array); |
|
| 1803 | - |
|
| 1804 | - if ($count < $min || $count > $max) { |
|
| 1805 | - static::reportInvalidArgument(\sprintf( |
|
| 1806 | - $message ?: 'Expected an array to contain between %2$d and %3$d elements. Got: %d', |
|
| 1807 | - $count, |
|
| 1808 | - $min, |
|
| 1809 | - $max |
|
| 1810 | - )); |
|
| 1811 | - } |
|
| 1812 | - } |
|
| 1813 | - |
|
| 1814 | - /** |
|
| 1815 | - * @psalm-pure |
|
| 1816 | - * @psalm-assert list $array |
|
| 1817 | - * |
|
| 1818 | - * @param mixed $array |
|
| 1819 | - * @param string $message |
|
| 1820 | - * |
|
| 1821 | - * @throws InvalidArgumentException |
|
| 1822 | - */ |
|
| 1823 | - public static function isList($array, $message = '') |
|
| 1824 | - { |
|
| 1825 | - if (!\is_array($array)) { |
|
| 1826 | - static::reportInvalidArgument( |
|
| 1827 | - $message ?: 'Expected list - non-associative array.' |
|
| 1828 | - ); |
|
| 1829 | - } |
|
| 1830 | - |
|
| 1831 | - if ($array === \array_values($array)) { |
|
| 1832 | - return; |
|
| 1833 | - } |
|
| 1834 | - |
|
| 1835 | - $nextKey = -1; |
|
| 1836 | - foreach ($array as $k => $v) { |
|
| 1837 | - if ($k !== ++$nextKey) { |
|
| 1838 | - static::reportInvalidArgument( |
|
| 1839 | - $message ?: 'Expected list - non-associative array.' |
|
| 1840 | - ); |
|
| 1841 | - } |
|
| 1842 | - } |
|
| 1843 | - } |
|
| 1844 | - |
|
| 1845 | - /** |
|
| 1846 | - * @psalm-pure |
|
| 1847 | - * @psalm-assert non-empty-list $array |
|
| 1848 | - * |
|
| 1849 | - * @param mixed $array |
|
| 1850 | - * @param string $message |
|
| 1851 | - * |
|
| 1852 | - * @throws InvalidArgumentException |
|
| 1853 | - */ |
|
| 1854 | - public static function isNonEmptyList($array, $message = '') |
|
| 1855 | - { |
|
| 1856 | - static::isList($array, $message); |
|
| 1857 | - static::notEmpty($array, $message); |
|
| 1858 | - } |
|
| 1859 | - |
|
| 1860 | - /** |
|
| 1861 | - * @psalm-pure |
|
| 1862 | - * @psalm-template T |
|
| 1863 | - * @psalm-param mixed|array<T> $array |
|
| 1864 | - * @psalm-assert array<string, T> $array |
|
| 1865 | - * |
|
| 1866 | - * @param mixed $array |
|
| 1867 | - * @param string $message |
|
| 1868 | - * |
|
| 1869 | - * @throws InvalidArgumentException |
|
| 1870 | - */ |
|
| 1871 | - public static function isMap($array, $message = '') |
|
| 1872 | - { |
|
| 1873 | - if ( |
|
| 1874 | - !\is_array($array) || |
|
| 1875 | - \array_keys($array) !== \array_filter(\array_keys($array), '\is_string') |
|
| 1876 | - ) { |
|
| 1877 | - static::reportInvalidArgument( |
|
| 1878 | - $message ?: 'Expected map - associative array with string keys.' |
|
| 1879 | - ); |
|
| 1880 | - } |
|
| 1881 | - } |
|
| 1882 | - |
|
| 1883 | - /** |
|
| 1884 | - * @psalm-pure |
|
| 1885 | - * @psalm-template T |
|
| 1886 | - * @psalm-param mixed|array<T> $array |
|
| 1887 | - * @psalm-assert array<string, T> $array |
|
| 1888 | - * @psalm-assert !empty $array |
|
| 1889 | - * |
|
| 1890 | - * @param mixed $array |
|
| 1891 | - * @param string $message |
|
| 1892 | - * |
|
| 1893 | - * @throws InvalidArgumentException |
|
| 1894 | - */ |
|
| 1895 | - public static function isNonEmptyMap($array, $message = '') |
|
| 1896 | - { |
|
| 1897 | - static::isMap($array, $message); |
|
| 1898 | - static::notEmpty($array, $message); |
|
| 1899 | - } |
|
| 1900 | - |
|
| 1901 | - /** |
|
| 1902 | - * @psalm-pure |
|
| 1903 | - * |
|
| 1904 | - * @param string $value |
|
| 1905 | - * @param string $message |
|
| 1906 | - * |
|
| 1907 | - * @throws InvalidArgumentException |
|
| 1908 | - */ |
|
| 1909 | - public static function uuid($value, $message = '') |
|
| 1910 | - { |
|
| 1911 | - $value = \str_replace(array('urn:', 'uuid:', '{', '}'), '', $value); |
|
| 1912 | - |
|
| 1913 | - // The nil UUID is special form of UUID that is specified to have all |
|
| 1914 | - // 128 bits set to zero. |
|
| 1915 | - if ('00000000-0000-0000-0000-000000000000' === $value) { |
|
| 1916 | - return; |
|
| 1917 | - } |
|
| 1918 | - |
|
| 1919 | - if (!\preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) { |
|
| 1920 | - static::reportInvalidArgument(\sprintf( |
|
| 1921 | - $message ?: 'Value %s is not a valid UUID.', |
|
| 1922 | - static::valueToString($value) |
|
| 1923 | - )); |
|
| 1924 | - } |
|
| 1925 | - } |
|
| 1926 | - |
|
| 1927 | - /** |
|
| 1928 | - * @psalm-param class-string<Throwable> $class |
|
| 1929 | - * |
|
| 1930 | - * @param Closure $expression |
|
| 1931 | - * @param string $class |
|
| 1932 | - * @param string $message |
|
| 1933 | - * |
|
| 1934 | - * @throws InvalidArgumentException |
|
| 1935 | - */ |
|
| 1936 | - public static function throws(Closure $expression, $class = 'Exception', $message = '') |
|
| 1937 | - { |
|
| 1938 | - static::string($class); |
|
| 1939 | - |
|
| 1940 | - $actual = 'none'; |
|
| 1941 | - |
|
| 1942 | - try { |
|
| 1943 | - $expression(); |
|
| 1944 | - } catch (Exception $e) { |
|
| 1945 | - $actual = \get_class($e); |
|
| 1946 | - if ($e instanceof $class) { |
|
| 1947 | - return; |
|
| 1948 | - } |
|
| 1949 | - } catch (Throwable $e) { |
|
| 1950 | - $actual = \get_class($e); |
|
| 1951 | - if ($e instanceof $class) { |
|
| 1952 | - return; |
|
| 1953 | - } |
|
| 1954 | - } |
|
| 1955 | - |
|
| 1956 | - static::reportInvalidArgument($message ?: \sprintf( |
|
| 1957 | - 'Expected to throw "%s", got "%s"', |
|
| 1958 | - $class, |
|
| 1959 | - $actual |
|
| 1960 | - )); |
|
| 1961 | - } |
|
| 1962 | - |
|
| 1963 | - /** |
|
| 1964 | - * @throws BadMethodCallException |
|
| 1965 | - */ |
|
| 1966 | - public static function __callStatic($name, $arguments) |
|
| 1967 | - { |
|
| 1968 | - if ('nullOr' === \substr($name, 0, 6)) { |
|
| 1969 | - if (null !== $arguments[0]) { |
|
| 1970 | - $method = \lcfirst(\substr($name, 6)); |
|
| 1971 | - \call_user_func_array(array(static::class, $method), $arguments); |
|
| 1972 | - } |
|
| 1973 | - |
|
| 1974 | - return; |
|
| 1975 | - } |
|
| 1976 | - |
|
| 1977 | - if ('all' === \substr($name, 0, 3)) { |
|
| 1978 | - static::isIterable($arguments[0]); |
|
| 1979 | - |
|
| 1980 | - $method = \lcfirst(\substr($name, 3)); |
|
| 1981 | - $args = $arguments; |
|
| 1982 | - |
|
| 1983 | - foreach ($arguments[0] as $entry) { |
|
| 1984 | - $args[0] = $entry; |
|
| 1985 | - |
|
| 1986 | - \call_user_func_array(array(static::class, $method), $args); |
|
| 1987 | - } |
|
| 1988 | - |
|
| 1989 | - return; |
|
| 1990 | - } |
|
| 1991 | - |
|
| 1992 | - throw new BadMethodCallException('No such method: '.$name); |
|
| 1993 | - } |
|
| 1994 | - |
|
| 1995 | - /** |
|
| 1996 | - * @param mixed $value |
|
| 1997 | - * |
|
| 1998 | - * @return string |
|
| 1999 | - */ |
|
| 2000 | - protected static function valueToString($value) |
|
| 2001 | - { |
|
| 2002 | - if (null === $value) { |
|
| 2003 | - return 'null'; |
|
| 2004 | - } |
|
| 2005 | - |
|
| 2006 | - if (true === $value) { |
|
| 2007 | - return 'true'; |
|
| 2008 | - } |
|
| 2009 | - |
|
| 2010 | - if (false === $value) { |
|
| 2011 | - return 'false'; |
|
| 2012 | - } |
|
| 2013 | - |
|
| 2014 | - if (\is_array($value)) { |
|
| 2015 | - return 'array'; |
|
| 2016 | - } |
|
| 2017 | - |
|
| 2018 | - if (\is_object($value)) { |
|
| 2019 | - if (\method_exists($value, '__toString')) { |
|
| 2020 | - return \get_class($value).': '.self::valueToString($value->__toString()); |
|
| 2021 | - } |
|
| 2022 | - |
|
| 2023 | - if ($value instanceof DateTime || $value instanceof DateTimeImmutable) { |
|
| 2024 | - return \get_class($value).': '.self::valueToString($value->format('c')); |
|
| 2025 | - } |
|
| 2026 | - |
|
| 2027 | - return \get_class($value); |
|
| 2028 | - } |
|
| 2029 | - |
|
| 2030 | - if (\is_resource($value)) { |
|
| 2031 | - return 'resource'; |
|
| 2032 | - } |
|
| 2033 | - |
|
| 2034 | - if (\is_string($value)) { |
|
| 2035 | - return '"'.$value.'"'; |
|
| 2036 | - } |
|
| 2037 | - |
|
| 2038 | - return (string) $value; |
|
| 2039 | - } |
|
| 2040 | - |
|
| 2041 | - /** |
|
| 2042 | - * @param mixed $value |
|
| 2043 | - * |
|
| 2044 | - * @return string |
|
| 2045 | - */ |
|
| 2046 | - protected static function typeToString($value) |
|
| 2047 | - { |
|
| 2048 | - return \is_object($value) ? \get_class($value) : \gettype($value); |
|
| 2049 | - } |
|
| 2050 | - |
|
| 2051 | - protected static function strlen($value) |
|
| 2052 | - { |
|
| 2053 | - if (!\function_exists('mb_detect_encoding')) { |
|
| 2054 | - return \strlen($value); |
|
| 2055 | - } |
|
| 2056 | - |
|
| 2057 | - if (false === $encoding = \mb_detect_encoding($value)) { |
|
| 2058 | - return \strlen($value); |
|
| 2059 | - } |
|
| 2060 | - |
|
| 2061 | - return \mb_strlen($value, $encoding); |
|
| 2062 | - } |
|
| 2063 | - |
|
| 2064 | - /** |
|
| 2065 | - * @param string $message |
|
| 2066 | - * |
|
| 2067 | - * @throws InvalidArgumentException |
|
| 2068 | - * |
|
| 2069 | - * @psalm-pure this method is not supposed to perform side-effects |
|
| 2070 | - * @psalm-return never |
|
| 2071 | - */ |
|
| 2072 | - protected static function reportInvalidArgument($message) |
|
| 2073 | - { |
|
| 2074 | - throw new InvalidArgumentException($message); |
|
| 2075 | - } |
|
| 2076 | - |
|
| 2077 | - private function __construct() |
|
| 2078 | - { |
|
| 2079 | - } |
|
| 35 | + use Mixin; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @psalm-pure |
|
| 39 | + * @psalm-assert string $value |
|
| 40 | + * |
|
| 41 | + * @param mixed $value |
|
| 42 | + * @param string $message |
|
| 43 | + * |
|
| 44 | + * @throws InvalidArgumentException |
|
| 45 | + */ |
|
| 46 | + public static function string($value, $message = '') |
|
| 47 | + { |
|
| 48 | + if (!\is_string($value)) { |
|
| 49 | + static::reportInvalidArgument(\sprintf( |
|
| 50 | + $message ?: 'Expected a string. Got: %s', |
|
| 51 | + static::typeToString($value) |
|
| 52 | + )); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @psalm-pure |
|
| 58 | + * @psalm-assert non-empty-string $value |
|
| 59 | + * |
|
| 60 | + * @param mixed $value |
|
| 61 | + * @param string $message |
|
| 62 | + * |
|
| 63 | + * @throws InvalidArgumentException |
|
| 64 | + */ |
|
| 65 | + public static function stringNotEmpty($value, $message = '') |
|
| 66 | + { |
|
| 67 | + static::string($value, $message); |
|
| 68 | + static::notEq($value, '', $message); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @psalm-pure |
|
| 73 | + * @psalm-assert int $value |
|
| 74 | + * |
|
| 75 | + * @param mixed $value |
|
| 76 | + * @param string $message |
|
| 77 | + * |
|
| 78 | + * @throws InvalidArgumentException |
|
| 79 | + */ |
|
| 80 | + public static function integer($value, $message = '') |
|
| 81 | + { |
|
| 82 | + if (!\is_int($value)) { |
|
| 83 | + static::reportInvalidArgument(\sprintf( |
|
| 84 | + $message ?: 'Expected an integer. Got: %s', |
|
| 85 | + static::typeToString($value) |
|
| 86 | + )); |
|
| 87 | + } |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @psalm-pure |
|
| 92 | + * @psalm-assert numeric $value |
|
| 93 | + * |
|
| 94 | + * @param mixed $value |
|
| 95 | + * @param string $message |
|
| 96 | + * |
|
| 97 | + * @throws InvalidArgumentException |
|
| 98 | + */ |
|
| 99 | + public static function integerish($value, $message = '') |
|
| 100 | + { |
|
| 101 | + if (!\is_numeric($value) || $value != (int) $value) { |
|
| 102 | + static::reportInvalidArgument(\sprintf( |
|
| 103 | + $message ?: 'Expected an integerish value. Got: %s', |
|
| 104 | + static::typeToString($value) |
|
| 105 | + )); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @psalm-pure |
|
| 111 | + * @psalm-assert positive-int $value |
|
| 112 | + * |
|
| 113 | + * @param mixed $value |
|
| 114 | + * @param string $message |
|
| 115 | + * |
|
| 116 | + * @throws InvalidArgumentException |
|
| 117 | + */ |
|
| 118 | + public static function positiveInteger($value, $message = '') |
|
| 119 | + { |
|
| 120 | + if (!(\is_int($value) && $value > 0)) { |
|
| 121 | + static::reportInvalidArgument(\sprintf( |
|
| 122 | + $message ?: 'Expected a positive integer. Got: %s', |
|
| 123 | + static::valueToString($value) |
|
| 124 | + )); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @psalm-pure |
|
| 130 | + * @psalm-assert float $value |
|
| 131 | + * |
|
| 132 | + * @param mixed $value |
|
| 133 | + * @param string $message |
|
| 134 | + * |
|
| 135 | + * @throws InvalidArgumentException |
|
| 136 | + */ |
|
| 137 | + public static function float($value, $message = '') |
|
| 138 | + { |
|
| 139 | + if (!\is_float($value)) { |
|
| 140 | + static::reportInvalidArgument(\sprintf( |
|
| 141 | + $message ?: 'Expected a float. Got: %s', |
|
| 142 | + static::typeToString($value) |
|
| 143 | + )); |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * @psalm-pure |
|
| 149 | + * @psalm-assert numeric $value |
|
| 150 | + * |
|
| 151 | + * @param mixed $value |
|
| 152 | + * @param string $message |
|
| 153 | + * |
|
| 154 | + * @throws InvalidArgumentException |
|
| 155 | + */ |
|
| 156 | + public static function numeric($value, $message = '') |
|
| 157 | + { |
|
| 158 | + if (!\is_numeric($value)) { |
|
| 159 | + static::reportInvalidArgument(\sprintf( |
|
| 160 | + $message ?: 'Expected a numeric. Got: %s', |
|
| 161 | + static::typeToString($value) |
|
| 162 | + )); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * @psalm-pure |
|
| 168 | + * @psalm-assert positive-int|0 $value |
|
| 169 | + * |
|
| 170 | + * @param mixed $value |
|
| 171 | + * @param string $message |
|
| 172 | + * |
|
| 173 | + * @throws InvalidArgumentException |
|
| 174 | + */ |
|
| 175 | + public static function natural($value, $message = '') |
|
| 176 | + { |
|
| 177 | + if (!\is_int($value) || $value < 0) { |
|
| 178 | + static::reportInvalidArgument(\sprintf( |
|
| 179 | + $message ?: 'Expected a non-negative integer. Got: %s', |
|
| 180 | + static::valueToString($value) |
|
| 181 | + )); |
|
| 182 | + } |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * @psalm-pure |
|
| 187 | + * @psalm-assert bool $value |
|
| 188 | + * |
|
| 189 | + * @param mixed $value |
|
| 190 | + * @param string $message |
|
| 191 | + * |
|
| 192 | + * @throws InvalidArgumentException |
|
| 193 | + */ |
|
| 194 | + public static function boolean($value, $message = '') |
|
| 195 | + { |
|
| 196 | + if (!\is_bool($value)) { |
|
| 197 | + static::reportInvalidArgument(\sprintf( |
|
| 198 | + $message ?: 'Expected a boolean. Got: %s', |
|
| 199 | + static::typeToString($value) |
|
| 200 | + )); |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * @psalm-pure |
|
| 206 | + * @psalm-assert scalar $value |
|
| 207 | + * |
|
| 208 | + * @param mixed $value |
|
| 209 | + * @param string $message |
|
| 210 | + * |
|
| 211 | + * @throws InvalidArgumentException |
|
| 212 | + */ |
|
| 213 | + public static function scalar($value, $message = '') |
|
| 214 | + { |
|
| 215 | + if (!\is_scalar($value)) { |
|
| 216 | + static::reportInvalidArgument(\sprintf( |
|
| 217 | + $message ?: 'Expected a scalar. Got: %s', |
|
| 218 | + static::typeToString($value) |
|
| 219 | + )); |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * @psalm-pure |
|
| 225 | + * @psalm-assert object $value |
|
| 226 | + * |
|
| 227 | + * @param mixed $value |
|
| 228 | + * @param string $message |
|
| 229 | + * |
|
| 230 | + * @throws InvalidArgumentException |
|
| 231 | + */ |
|
| 232 | + public static function object($value, $message = '') |
|
| 233 | + { |
|
| 234 | + if (!\is_object($value)) { |
|
| 235 | + static::reportInvalidArgument(\sprintf( |
|
| 236 | + $message ?: 'Expected an object. Got: %s', |
|
| 237 | + static::typeToString($value) |
|
| 238 | + )); |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * @psalm-pure |
|
| 244 | + * @psalm-assert resource $value |
|
| 245 | + * |
|
| 246 | + * @param mixed $value |
|
| 247 | + * @param string|null $type type of resource this should be. @see https://www.php.net/manual/en/function.get-resource-type.php |
|
| 248 | + * @param string $message |
|
| 249 | + * |
|
| 250 | + * @throws InvalidArgumentException |
|
| 251 | + */ |
|
| 252 | + public static function resource($value, $type = null, $message = '') |
|
| 253 | + { |
|
| 254 | + if (!\is_resource($value)) { |
|
| 255 | + static::reportInvalidArgument(\sprintf( |
|
| 256 | + $message ?: 'Expected a resource. Got: %s', |
|
| 257 | + static::typeToString($value) |
|
| 258 | + )); |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + if ($type && $type !== \get_resource_type($value)) { |
|
| 262 | + static::reportInvalidArgument(\sprintf( |
|
| 263 | + $message ?: 'Expected a resource of type %2$s. Got: %s', |
|
| 264 | + static::typeToString($value), |
|
| 265 | + $type |
|
| 266 | + )); |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * @psalm-pure |
|
| 272 | + * @psalm-assert callable $value |
|
| 273 | + * |
|
| 274 | + * @param mixed $value |
|
| 275 | + * @param string $message |
|
| 276 | + * |
|
| 277 | + * @throws InvalidArgumentException |
|
| 278 | + */ |
|
| 279 | + public static function isCallable($value, $message = '') |
|
| 280 | + { |
|
| 281 | + if (!\is_callable($value)) { |
|
| 282 | + static::reportInvalidArgument(\sprintf( |
|
| 283 | + $message ?: 'Expected a callable. Got: %s', |
|
| 284 | + static::typeToString($value) |
|
| 285 | + )); |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * @psalm-pure |
|
| 291 | + * @psalm-assert array $value |
|
| 292 | + * |
|
| 293 | + * @param mixed $value |
|
| 294 | + * @param string $message |
|
| 295 | + * |
|
| 296 | + * @throws InvalidArgumentException |
|
| 297 | + */ |
|
| 298 | + public static function isArray($value, $message = '') |
|
| 299 | + { |
|
| 300 | + if (!\is_array($value)) { |
|
| 301 | + static::reportInvalidArgument(\sprintf( |
|
| 302 | + $message ?: 'Expected an array. Got: %s', |
|
| 303 | + static::typeToString($value) |
|
| 304 | + )); |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + /** |
|
| 309 | + * @psalm-pure |
|
| 310 | + * @psalm-assert iterable $value |
|
| 311 | + * |
|
| 312 | + * @deprecated use "isIterable" or "isInstanceOf" instead |
|
| 313 | + * |
|
| 314 | + * @param mixed $value |
|
| 315 | + * @param string $message |
|
| 316 | + * |
|
| 317 | + * @throws InvalidArgumentException |
|
| 318 | + */ |
|
| 319 | + public static function isTraversable($value, $message = '') |
|
| 320 | + { |
|
| 321 | + @\trigger_error( |
|
| 322 | + \sprintf( |
|
| 323 | + 'The "%s" assertion is deprecated. You should stop using it, as it will soon be removed in 2.0 version. Use "isIterable" or "isInstanceOf" instead.', |
|
| 324 | + __METHOD__ |
|
| 325 | + ), |
|
| 326 | + \E_USER_DEPRECATED |
|
| 327 | + ); |
|
| 328 | + |
|
| 329 | + if (!\is_array($value) && !($value instanceof Traversable)) { |
|
| 330 | + static::reportInvalidArgument(\sprintf( |
|
| 331 | + $message ?: 'Expected a traversable. Got: %s', |
|
| 332 | + static::typeToString($value) |
|
| 333 | + )); |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + /** |
|
| 338 | + * @psalm-pure |
|
| 339 | + * @psalm-assert array|ArrayAccess $value |
|
| 340 | + * |
|
| 341 | + * @param mixed $value |
|
| 342 | + * @param string $message |
|
| 343 | + * |
|
| 344 | + * @throws InvalidArgumentException |
|
| 345 | + */ |
|
| 346 | + public static function isArrayAccessible($value, $message = '') |
|
| 347 | + { |
|
| 348 | + if (!\is_array($value) && !($value instanceof ArrayAccess)) { |
|
| 349 | + static::reportInvalidArgument(\sprintf( |
|
| 350 | + $message ?: 'Expected an array accessible. Got: %s', |
|
| 351 | + static::typeToString($value) |
|
| 352 | + )); |
|
| 353 | + } |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * @psalm-pure |
|
| 358 | + * @psalm-assert countable $value |
|
| 359 | + * |
|
| 360 | + * @param mixed $value |
|
| 361 | + * @param string $message |
|
| 362 | + * |
|
| 363 | + * @throws InvalidArgumentException |
|
| 364 | + */ |
|
| 365 | + public static function isCountable($value, $message = '') |
|
| 366 | + { |
|
| 367 | + if ( |
|
| 368 | + !\is_array($value) |
|
| 369 | + && !($value instanceof Countable) |
|
| 370 | + && !($value instanceof ResourceBundle) |
|
| 371 | + && !($value instanceof SimpleXMLElement) |
|
| 372 | + ) { |
|
| 373 | + static::reportInvalidArgument(\sprintf( |
|
| 374 | + $message ?: 'Expected a countable. Got: %s', |
|
| 375 | + static::typeToString($value) |
|
| 376 | + )); |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * @psalm-pure |
|
| 382 | + * @psalm-assert iterable $value |
|
| 383 | + * |
|
| 384 | + * @param mixed $value |
|
| 385 | + * @param string $message |
|
| 386 | + * |
|
| 387 | + * @throws InvalidArgumentException |
|
| 388 | + */ |
|
| 389 | + public static function isIterable($value, $message = '') |
|
| 390 | + { |
|
| 391 | + if (!\is_array($value) && !($value instanceof Traversable)) { |
|
| 392 | + static::reportInvalidArgument(\sprintf( |
|
| 393 | + $message ?: 'Expected an iterable. Got: %s', |
|
| 394 | + static::typeToString($value) |
|
| 395 | + )); |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + /** |
|
| 400 | + * @psalm-pure |
|
| 401 | + * @psalm-template ExpectedType of object |
|
| 402 | + * @psalm-param class-string<ExpectedType> $class |
|
| 403 | + * @psalm-assert ExpectedType $value |
|
| 404 | + * |
|
| 405 | + * @param mixed $value |
|
| 406 | + * @param string|object $class |
|
| 407 | + * @param string $message |
|
| 408 | + * |
|
| 409 | + * @throws InvalidArgumentException |
|
| 410 | + */ |
|
| 411 | + public static function isInstanceOf($value, $class, $message = '') |
|
| 412 | + { |
|
| 413 | + if (!($value instanceof $class)) { |
|
| 414 | + static::reportInvalidArgument(\sprintf( |
|
| 415 | + $message ?: 'Expected an instance of %2$s. Got: %s', |
|
| 416 | + static::typeToString($value), |
|
| 417 | + $class |
|
| 418 | + )); |
|
| 419 | + } |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + /** |
|
| 423 | + * @psalm-pure |
|
| 424 | + * @psalm-template ExpectedType of object |
|
| 425 | + * @psalm-param class-string<ExpectedType> $class |
|
| 426 | + * @psalm-assert !ExpectedType $value |
|
| 427 | + * |
|
| 428 | + * @param mixed $value |
|
| 429 | + * @param string|object $class |
|
| 430 | + * @param string $message |
|
| 431 | + * |
|
| 432 | + * @throws InvalidArgumentException |
|
| 433 | + */ |
|
| 434 | + public static function notInstanceOf($value, $class, $message = '') |
|
| 435 | + { |
|
| 436 | + if ($value instanceof $class) { |
|
| 437 | + static::reportInvalidArgument(\sprintf( |
|
| 438 | + $message ?: 'Expected an instance other than %2$s. Got: %s', |
|
| 439 | + static::typeToString($value), |
|
| 440 | + $class |
|
| 441 | + )); |
|
| 442 | + } |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + /** |
|
| 446 | + * @psalm-pure |
|
| 447 | + * @psalm-param array<class-string> $classes |
|
| 448 | + * |
|
| 449 | + * @param mixed $value |
|
| 450 | + * @param array<object|string> $classes |
|
| 451 | + * @param string $message |
|
| 452 | + * |
|
| 453 | + * @throws InvalidArgumentException |
|
| 454 | + */ |
|
| 455 | + public static function isInstanceOfAny($value, array $classes, $message = '') |
|
| 456 | + { |
|
| 457 | + foreach ($classes as $class) { |
|
| 458 | + if ($value instanceof $class) { |
|
| 459 | + return; |
|
| 460 | + } |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + static::reportInvalidArgument(\sprintf( |
|
| 464 | + $message ?: 'Expected an instance of any of %2$s. Got: %s', |
|
| 465 | + static::typeToString($value), |
|
| 466 | + \implode(', ', \array_map(array(static::class, 'valueToString'), $classes)) |
|
| 467 | + )); |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + /** |
|
| 471 | + * @psalm-pure |
|
| 472 | + * @psalm-template ExpectedType of object |
|
| 473 | + * @psalm-param class-string<ExpectedType> $class |
|
| 474 | + * @psalm-assert ExpectedType|class-string<ExpectedType> $value |
|
| 475 | + * |
|
| 476 | + * @param object|string $value |
|
| 477 | + * @param string $class |
|
| 478 | + * @param string $message |
|
| 479 | + * |
|
| 480 | + * @throws InvalidArgumentException |
|
| 481 | + */ |
|
| 482 | + public static function isAOf($value, $class, $message = '') |
|
| 483 | + { |
|
| 484 | + static::string($class, 'Expected class as a string. Got: %s'); |
|
| 485 | + |
|
| 486 | + if (!\is_a($value, $class, \is_string($value))) { |
|
| 487 | + static::reportInvalidArgument(sprintf( |
|
| 488 | + $message ?: 'Expected an instance of this class or to this class among its parents "%2$s". Got: %s', |
|
| 489 | + static::valueToString($value), |
|
| 490 | + $class |
|
| 491 | + )); |
|
| 492 | + } |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + /** |
|
| 496 | + * @psalm-pure |
|
| 497 | + * @psalm-template UnexpectedType of object |
|
| 498 | + * @psalm-param class-string<UnexpectedType> $class |
|
| 499 | + * @psalm-assert !UnexpectedType $value |
|
| 500 | + * @psalm-assert !class-string<UnexpectedType> $value |
|
| 501 | + * |
|
| 502 | + * @param object|string $value |
|
| 503 | + * @param string $class |
|
| 504 | + * @param string $message |
|
| 505 | + * |
|
| 506 | + * @throws InvalidArgumentException |
|
| 507 | + */ |
|
| 508 | + public static function isNotA($value, $class, $message = '') |
|
| 509 | + { |
|
| 510 | + static::string($class, 'Expected class as a string. Got: %s'); |
|
| 511 | + |
|
| 512 | + if (\is_a($value, $class, \is_string($value))) { |
|
| 513 | + static::reportInvalidArgument(sprintf( |
|
| 514 | + $message ?: 'Expected an instance of this class or to this class among its parents other than "%2$s". Got: %s', |
|
| 515 | + static::valueToString($value), |
|
| 516 | + $class |
|
| 517 | + )); |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | + |
|
| 521 | + /** |
|
| 522 | + * @psalm-pure |
|
| 523 | + * @psalm-param array<class-string> $classes |
|
| 524 | + * |
|
| 525 | + * @param object|string $value |
|
| 526 | + * @param string[] $classes |
|
| 527 | + * @param string $message |
|
| 528 | + * |
|
| 529 | + * @throws InvalidArgumentException |
|
| 530 | + */ |
|
| 531 | + public static function isAnyOf($value, array $classes, $message = '') |
|
| 532 | + { |
|
| 533 | + foreach ($classes as $class) { |
|
| 534 | + static::string($class, 'Expected class as a string. Got: %s'); |
|
| 535 | + |
|
| 536 | + if (\is_a($value, $class, \is_string($value))) { |
|
| 537 | + return; |
|
| 538 | + } |
|
| 539 | + } |
|
| 540 | + |
|
| 541 | + static::reportInvalidArgument(sprintf( |
|
| 542 | + $message ?: 'Expected an instance of any of this classes or any of those classes among their parents "%2$s". Got: %s', |
|
| 543 | + static::valueToString($value), |
|
| 544 | + \implode(', ', $classes) |
|
| 545 | + )); |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + /** |
|
| 549 | + * @psalm-pure |
|
| 550 | + * @psalm-assert empty $value |
|
| 551 | + * |
|
| 552 | + * @param mixed $value |
|
| 553 | + * @param string $message |
|
| 554 | + * |
|
| 555 | + * @throws InvalidArgumentException |
|
| 556 | + */ |
|
| 557 | + public static function isEmpty($value, $message = '') |
|
| 558 | + { |
|
| 559 | + if (!empty($value)) { |
|
| 560 | + static::reportInvalidArgument(\sprintf( |
|
| 561 | + $message ?: 'Expected an empty value. Got: %s', |
|
| 562 | + static::valueToString($value) |
|
| 563 | + )); |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + /** |
|
| 568 | + * @psalm-pure |
|
| 569 | + * @psalm-assert !empty $value |
|
| 570 | + * |
|
| 571 | + * @param mixed $value |
|
| 572 | + * @param string $message |
|
| 573 | + * |
|
| 574 | + * @throws InvalidArgumentException |
|
| 575 | + */ |
|
| 576 | + public static function notEmpty($value, $message = '') |
|
| 577 | + { |
|
| 578 | + if (empty($value)) { |
|
| 579 | + static::reportInvalidArgument(\sprintf( |
|
| 580 | + $message ?: 'Expected a non-empty value. Got: %s', |
|
| 581 | + static::valueToString($value) |
|
| 582 | + )); |
|
| 583 | + } |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + /** |
|
| 587 | + * @psalm-pure |
|
| 588 | + * @psalm-assert null $value |
|
| 589 | + * |
|
| 590 | + * @param mixed $value |
|
| 591 | + * @param string $message |
|
| 592 | + * |
|
| 593 | + * @throws InvalidArgumentException |
|
| 594 | + */ |
|
| 595 | + public static function null($value, $message = '') |
|
| 596 | + { |
|
| 597 | + if (null !== $value) { |
|
| 598 | + static::reportInvalidArgument(\sprintf( |
|
| 599 | + $message ?: 'Expected null. Got: %s', |
|
| 600 | + static::valueToString($value) |
|
| 601 | + )); |
|
| 602 | + } |
|
| 603 | + } |
|
| 604 | + |
|
| 605 | + /** |
|
| 606 | + * @psalm-pure |
|
| 607 | + * @psalm-assert !null $value |
|
| 608 | + * |
|
| 609 | + * @param mixed $value |
|
| 610 | + * @param string $message |
|
| 611 | + * |
|
| 612 | + * @throws InvalidArgumentException |
|
| 613 | + */ |
|
| 614 | + public static function notNull($value, $message = '') |
|
| 615 | + { |
|
| 616 | + if (null === $value) { |
|
| 617 | + static::reportInvalidArgument( |
|
| 618 | + $message ?: 'Expected a value other than null.' |
|
| 619 | + ); |
|
| 620 | + } |
|
| 621 | + } |
|
| 622 | + |
|
| 623 | + /** |
|
| 624 | + * @psalm-pure |
|
| 625 | + * @psalm-assert true $value |
|
| 626 | + * |
|
| 627 | + * @param mixed $value |
|
| 628 | + * @param string $message |
|
| 629 | + * |
|
| 630 | + * @throws InvalidArgumentException |
|
| 631 | + */ |
|
| 632 | + public static function true($value, $message = '') |
|
| 633 | + { |
|
| 634 | + if (true !== $value) { |
|
| 635 | + static::reportInvalidArgument(\sprintf( |
|
| 636 | + $message ?: 'Expected a value to be true. Got: %s', |
|
| 637 | + static::valueToString($value) |
|
| 638 | + )); |
|
| 639 | + } |
|
| 640 | + } |
|
| 641 | + |
|
| 642 | + /** |
|
| 643 | + * @psalm-pure |
|
| 644 | + * @psalm-assert false $value |
|
| 645 | + * |
|
| 646 | + * @param mixed $value |
|
| 647 | + * @param string $message |
|
| 648 | + * |
|
| 649 | + * @throws InvalidArgumentException |
|
| 650 | + */ |
|
| 651 | + public static function false($value, $message = '') |
|
| 652 | + { |
|
| 653 | + if (false !== $value) { |
|
| 654 | + static::reportInvalidArgument(\sprintf( |
|
| 655 | + $message ?: 'Expected a value to be false. Got: %s', |
|
| 656 | + static::valueToString($value) |
|
| 657 | + )); |
|
| 658 | + } |
|
| 659 | + } |
|
| 660 | + |
|
| 661 | + /** |
|
| 662 | + * @psalm-pure |
|
| 663 | + * @psalm-assert !false $value |
|
| 664 | + * |
|
| 665 | + * @param mixed $value |
|
| 666 | + * @param string $message |
|
| 667 | + * |
|
| 668 | + * @throws InvalidArgumentException |
|
| 669 | + */ |
|
| 670 | + public static function notFalse($value, $message = '') |
|
| 671 | + { |
|
| 672 | + if (false === $value) { |
|
| 673 | + static::reportInvalidArgument( |
|
| 674 | + $message ?: 'Expected a value other than false.' |
|
| 675 | + ); |
|
| 676 | + } |
|
| 677 | + } |
|
| 678 | + |
|
| 679 | + /** |
|
| 680 | + * @param mixed $value |
|
| 681 | + * @param string $message |
|
| 682 | + * |
|
| 683 | + * @throws InvalidArgumentException |
|
| 684 | + */ |
|
| 685 | + public static function ip($value, $message = '') |
|
| 686 | + { |
|
| 687 | + if (false === \filter_var($value, \FILTER_VALIDATE_IP)) { |
|
| 688 | + static::reportInvalidArgument(\sprintf( |
|
| 689 | + $message ?: 'Expected a value to be an IP. Got: %s', |
|
| 690 | + static::valueToString($value) |
|
| 691 | + )); |
|
| 692 | + } |
|
| 693 | + } |
|
| 694 | + |
|
| 695 | + /** |
|
| 696 | + * @param mixed $value |
|
| 697 | + * @param string $message |
|
| 698 | + * |
|
| 699 | + * @throws InvalidArgumentException |
|
| 700 | + */ |
|
| 701 | + public static function ipv4($value, $message = '') |
|
| 702 | + { |
|
| 703 | + if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) { |
|
| 704 | + static::reportInvalidArgument(\sprintf( |
|
| 705 | + $message ?: 'Expected a value to be an IPv4. Got: %s', |
|
| 706 | + static::valueToString($value) |
|
| 707 | + )); |
|
| 708 | + } |
|
| 709 | + } |
|
| 710 | + |
|
| 711 | + /** |
|
| 712 | + * @param mixed $value |
|
| 713 | + * @param string $message |
|
| 714 | + * |
|
| 715 | + * @throws InvalidArgumentException |
|
| 716 | + */ |
|
| 717 | + public static function ipv6($value, $message = '') |
|
| 718 | + { |
|
| 719 | + if (false === \filter_var($value, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) { |
|
| 720 | + static::reportInvalidArgument(\sprintf( |
|
| 721 | + $message ?: 'Expected a value to be an IPv6. Got: %s', |
|
| 722 | + static::valueToString($value) |
|
| 723 | + )); |
|
| 724 | + } |
|
| 725 | + } |
|
| 726 | + |
|
| 727 | + /** |
|
| 728 | + * @param mixed $value |
|
| 729 | + * @param string $message |
|
| 730 | + * |
|
| 731 | + * @throws InvalidArgumentException |
|
| 732 | + */ |
|
| 733 | + public static function email($value, $message = '') |
|
| 734 | + { |
|
| 735 | + if (false === \filter_var($value, FILTER_VALIDATE_EMAIL)) { |
|
| 736 | + static::reportInvalidArgument(\sprintf( |
|
| 737 | + $message ?: 'Expected a value to be a valid e-mail address. Got: %s', |
|
| 738 | + static::valueToString($value) |
|
| 739 | + )); |
|
| 740 | + } |
|
| 741 | + } |
|
| 742 | + |
|
| 743 | + /** |
|
| 744 | + * Does non strict comparisons on the items, so ['3', 3] will not pass the assertion. |
|
| 745 | + * |
|
| 746 | + * @param array $values |
|
| 747 | + * @param string $message |
|
| 748 | + * |
|
| 749 | + * @throws InvalidArgumentException |
|
| 750 | + */ |
|
| 751 | + public static function uniqueValues(array $values, $message = '') |
|
| 752 | + { |
|
| 753 | + $allValues = \count($values); |
|
| 754 | + $uniqueValues = \count(\array_unique($values)); |
|
| 755 | + |
|
| 756 | + if ($allValues !== $uniqueValues) { |
|
| 757 | + $difference = $allValues - $uniqueValues; |
|
| 758 | + |
|
| 759 | + static::reportInvalidArgument(\sprintf( |
|
| 760 | + $message ?: 'Expected an array of unique values, but %s of them %s duplicated', |
|
| 761 | + $difference, |
|
| 762 | + (1 === $difference ? 'is' : 'are') |
|
| 763 | + )); |
|
| 764 | + } |
|
| 765 | + } |
|
| 766 | + |
|
| 767 | + /** |
|
| 768 | + * @param mixed $value |
|
| 769 | + * @param mixed $expect |
|
| 770 | + * @param string $message |
|
| 771 | + * |
|
| 772 | + * @throws InvalidArgumentException |
|
| 773 | + */ |
|
| 774 | + public static function eq($value, $expect, $message = '') |
|
| 775 | + { |
|
| 776 | + if ($expect != $value) { |
|
| 777 | + static::reportInvalidArgument(\sprintf( |
|
| 778 | + $message ?: 'Expected a value equal to %2$s. Got: %s', |
|
| 779 | + static::valueToString($value), |
|
| 780 | + static::valueToString($expect) |
|
| 781 | + )); |
|
| 782 | + } |
|
| 783 | + } |
|
| 784 | + |
|
| 785 | + /** |
|
| 786 | + * @param mixed $value |
|
| 787 | + * @param mixed $expect |
|
| 788 | + * @param string $message |
|
| 789 | + * |
|
| 790 | + * @throws InvalidArgumentException |
|
| 791 | + */ |
|
| 792 | + public static function notEq($value, $expect, $message = '') |
|
| 793 | + { |
|
| 794 | + if ($expect == $value) { |
|
| 795 | + static::reportInvalidArgument(\sprintf( |
|
| 796 | + $message ?: 'Expected a different value than %s.', |
|
| 797 | + static::valueToString($expect) |
|
| 798 | + )); |
|
| 799 | + } |
|
| 800 | + } |
|
| 801 | + |
|
| 802 | + /** |
|
| 803 | + * @psalm-pure |
|
| 804 | + * |
|
| 805 | + * @param mixed $value |
|
| 806 | + * @param mixed $expect |
|
| 807 | + * @param string $message |
|
| 808 | + * |
|
| 809 | + * @throws InvalidArgumentException |
|
| 810 | + */ |
|
| 811 | + public static function same($value, $expect, $message = '') |
|
| 812 | + { |
|
| 813 | + if ($expect !== $value) { |
|
| 814 | + static::reportInvalidArgument(\sprintf( |
|
| 815 | + $message ?: 'Expected a value identical to %2$s. Got: %s', |
|
| 816 | + static::valueToString($value), |
|
| 817 | + static::valueToString($expect) |
|
| 818 | + )); |
|
| 819 | + } |
|
| 820 | + } |
|
| 821 | + |
|
| 822 | + /** |
|
| 823 | + * @psalm-pure |
|
| 824 | + * |
|
| 825 | + * @param mixed $value |
|
| 826 | + * @param mixed $expect |
|
| 827 | + * @param string $message |
|
| 828 | + * |
|
| 829 | + * @throws InvalidArgumentException |
|
| 830 | + */ |
|
| 831 | + public static function notSame($value, $expect, $message = '') |
|
| 832 | + { |
|
| 833 | + if ($expect === $value) { |
|
| 834 | + static::reportInvalidArgument(\sprintf( |
|
| 835 | + $message ?: 'Expected a value not identical to %s.', |
|
| 836 | + static::valueToString($expect) |
|
| 837 | + )); |
|
| 838 | + } |
|
| 839 | + } |
|
| 840 | + |
|
| 841 | + /** |
|
| 842 | + * @psalm-pure |
|
| 843 | + * |
|
| 844 | + * @param mixed $value |
|
| 845 | + * @param mixed $limit |
|
| 846 | + * @param string $message |
|
| 847 | + * |
|
| 848 | + * @throws InvalidArgumentException |
|
| 849 | + */ |
|
| 850 | + public static function greaterThan($value, $limit, $message = '') |
|
| 851 | + { |
|
| 852 | + if ($value <= $limit) { |
|
| 853 | + static::reportInvalidArgument(\sprintf( |
|
| 854 | + $message ?: 'Expected a value greater than %2$s. Got: %s', |
|
| 855 | + static::valueToString($value), |
|
| 856 | + static::valueToString($limit) |
|
| 857 | + )); |
|
| 858 | + } |
|
| 859 | + } |
|
| 860 | + |
|
| 861 | + /** |
|
| 862 | + * @psalm-pure |
|
| 863 | + * |
|
| 864 | + * @param mixed $value |
|
| 865 | + * @param mixed $limit |
|
| 866 | + * @param string $message |
|
| 867 | + * |
|
| 868 | + * @throws InvalidArgumentException |
|
| 869 | + */ |
|
| 870 | + public static function greaterThanEq($value, $limit, $message = '') |
|
| 871 | + { |
|
| 872 | + if ($value < $limit) { |
|
| 873 | + static::reportInvalidArgument(\sprintf( |
|
| 874 | + $message ?: 'Expected a value greater than or equal to %2$s. Got: %s', |
|
| 875 | + static::valueToString($value), |
|
| 876 | + static::valueToString($limit) |
|
| 877 | + )); |
|
| 878 | + } |
|
| 879 | + } |
|
| 880 | + |
|
| 881 | + /** |
|
| 882 | + * @psalm-pure |
|
| 883 | + * |
|
| 884 | + * @param mixed $value |
|
| 885 | + * @param mixed $limit |
|
| 886 | + * @param string $message |
|
| 887 | + * |
|
| 888 | + * @throws InvalidArgumentException |
|
| 889 | + */ |
|
| 890 | + public static function lessThan($value, $limit, $message = '') |
|
| 891 | + { |
|
| 892 | + if ($value >= $limit) { |
|
| 893 | + static::reportInvalidArgument(\sprintf( |
|
| 894 | + $message ?: 'Expected a value less than %2$s. Got: %s', |
|
| 895 | + static::valueToString($value), |
|
| 896 | + static::valueToString($limit) |
|
| 897 | + )); |
|
| 898 | + } |
|
| 899 | + } |
|
| 900 | + |
|
| 901 | + /** |
|
| 902 | + * @psalm-pure |
|
| 903 | + * |
|
| 904 | + * @param mixed $value |
|
| 905 | + * @param mixed $limit |
|
| 906 | + * @param string $message |
|
| 907 | + * |
|
| 908 | + * @throws InvalidArgumentException |
|
| 909 | + */ |
|
| 910 | + public static function lessThanEq($value, $limit, $message = '') |
|
| 911 | + { |
|
| 912 | + if ($value > $limit) { |
|
| 913 | + static::reportInvalidArgument(\sprintf( |
|
| 914 | + $message ?: 'Expected a value less than or equal to %2$s. Got: %s', |
|
| 915 | + static::valueToString($value), |
|
| 916 | + static::valueToString($limit) |
|
| 917 | + )); |
|
| 918 | + } |
|
| 919 | + } |
|
| 920 | + |
|
| 921 | + /** |
|
| 922 | + * Inclusive range, so Assert::(3, 3, 5) passes. |
|
| 923 | + * |
|
| 924 | + * @psalm-pure |
|
| 925 | + * |
|
| 926 | + * @param mixed $value |
|
| 927 | + * @param mixed $min |
|
| 928 | + * @param mixed $max |
|
| 929 | + * @param string $message |
|
| 930 | + * |
|
| 931 | + * @throws InvalidArgumentException |
|
| 932 | + */ |
|
| 933 | + public static function range($value, $min, $max, $message = '') |
|
| 934 | + { |
|
| 935 | + if ($value < $min || $value > $max) { |
|
| 936 | + static::reportInvalidArgument(\sprintf( |
|
| 937 | + $message ?: 'Expected a value between %2$s and %3$s. Got: %s', |
|
| 938 | + static::valueToString($value), |
|
| 939 | + static::valueToString($min), |
|
| 940 | + static::valueToString($max) |
|
| 941 | + )); |
|
| 942 | + } |
|
| 943 | + } |
|
| 944 | + |
|
| 945 | + /** |
|
| 946 | + * A more human-readable alias of Assert::inArray(). |
|
| 947 | + * |
|
| 948 | + * @psalm-pure |
|
| 949 | + * |
|
| 950 | + * @param mixed $value |
|
| 951 | + * @param array $values |
|
| 952 | + * @param string $message |
|
| 953 | + * |
|
| 954 | + * @throws InvalidArgumentException |
|
| 955 | + */ |
|
| 956 | + public static function oneOf($value, array $values, $message = '') |
|
| 957 | + { |
|
| 958 | + static::inArray($value, $values, $message); |
|
| 959 | + } |
|
| 960 | + |
|
| 961 | + /** |
|
| 962 | + * Does strict comparison, so Assert::inArray(3, ['3']) does not pass the assertion. |
|
| 963 | + * |
|
| 964 | + * @psalm-pure |
|
| 965 | + * |
|
| 966 | + * @param mixed $value |
|
| 967 | + * @param array $values |
|
| 968 | + * @param string $message |
|
| 969 | + * |
|
| 970 | + * @throws InvalidArgumentException |
|
| 971 | + */ |
|
| 972 | + public static function inArray($value, array $values, $message = '') |
|
| 973 | + { |
|
| 974 | + if (!\in_array($value, $values, true)) { |
|
| 975 | + static::reportInvalidArgument(\sprintf( |
|
| 976 | + $message ?: 'Expected one of: %2$s. Got: %s', |
|
| 977 | + static::valueToString($value), |
|
| 978 | + \implode(', ', \array_map(array(static::class, 'valueToString'), $values)) |
|
| 979 | + )); |
|
| 980 | + } |
|
| 981 | + } |
|
| 982 | + |
|
| 983 | + /** |
|
| 984 | + * @psalm-pure |
|
| 985 | + * |
|
| 986 | + * @param string $value |
|
| 987 | + * @param string $subString |
|
| 988 | + * @param string $message |
|
| 989 | + * |
|
| 990 | + * @throws InvalidArgumentException |
|
| 991 | + */ |
|
| 992 | + public static function contains($value, $subString, $message = '') |
|
| 993 | + { |
|
| 994 | + if (false === \strpos($value, $subString)) { |
|
| 995 | + static::reportInvalidArgument(\sprintf( |
|
| 996 | + $message ?: 'Expected a value to contain %2$s. Got: %s', |
|
| 997 | + static::valueToString($value), |
|
| 998 | + static::valueToString($subString) |
|
| 999 | + )); |
|
| 1000 | + } |
|
| 1001 | + } |
|
| 1002 | + |
|
| 1003 | + /** |
|
| 1004 | + * @psalm-pure |
|
| 1005 | + * |
|
| 1006 | + * @param string $value |
|
| 1007 | + * @param string $subString |
|
| 1008 | + * @param string $message |
|
| 1009 | + * |
|
| 1010 | + * @throws InvalidArgumentException |
|
| 1011 | + */ |
|
| 1012 | + public static function notContains($value, $subString, $message = '') |
|
| 1013 | + { |
|
| 1014 | + if (false !== \strpos($value, $subString)) { |
|
| 1015 | + static::reportInvalidArgument(\sprintf( |
|
| 1016 | + $message ?: '%2$s was not expected to be contained in a value. Got: %s', |
|
| 1017 | + static::valueToString($value), |
|
| 1018 | + static::valueToString($subString) |
|
| 1019 | + )); |
|
| 1020 | + } |
|
| 1021 | + } |
|
| 1022 | + |
|
| 1023 | + /** |
|
| 1024 | + * @psalm-pure |
|
| 1025 | + * |
|
| 1026 | + * @param string $value |
|
| 1027 | + * @param string $message |
|
| 1028 | + * |
|
| 1029 | + * @throws InvalidArgumentException |
|
| 1030 | + */ |
|
| 1031 | + public static function notWhitespaceOnly($value, $message = '') |
|
| 1032 | + { |
|
| 1033 | + if (\preg_match('/^\s*$/', $value)) { |
|
| 1034 | + static::reportInvalidArgument(\sprintf( |
|
| 1035 | + $message ?: 'Expected a non-whitespace string. Got: %s', |
|
| 1036 | + static::valueToString($value) |
|
| 1037 | + )); |
|
| 1038 | + } |
|
| 1039 | + } |
|
| 1040 | + |
|
| 1041 | + /** |
|
| 1042 | + * @psalm-pure |
|
| 1043 | + * |
|
| 1044 | + * @param string $value |
|
| 1045 | + * @param string $prefix |
|
| 1046 | + * @param string $message |
|
| 1047 | + * |
|
| 1048 | + * @throws InvalidArgumentException |
|
| 1049 | + */ |
|
| 1050 | + public static function startsWith($value, $prefix, $message = '') |
|
| 1051 | + { |
|
| 1052 | + if (0 !== \strpos($value, $prefix)) { |
|
| 1053 | + static::reportInvalidArgument(\sprintf( |
|
| 1054 | + $message ?: 'Expected a value to start with %2$s. Got: %s', |
|
| 1055 | + static::valueToString($value), |
|
| 1056 | + static::valueToString($prefix) |
|
| 1057 | + )); |
|
| 1058 | + } |
|
| 1059 | + } |
|
| 1060 | + |
|
| 1061 | + /** |
|
| 1062 | + * @psalm-pure |
|
| 1063 | + * |
|
| 1064 | + * @param string $value |
|
| 1065 | + * @param string $prefix |
|
| 1066 | + * @param string $message |
|
| 1067 | + * |
|
| 1068 | + * @throws InvalidArgumentException |
|
| 1069 | + */ |
|
| 1070 | + public static function notStartsWith($value, $prefix, $message = '') |
|
| 1071 | + { |
|
| 1072 | + if (0 === \strpos($value, $prefix)) { |
|
| 1073 | + static::reportInvalidArgument(\sprintf( |
|
| 1074 | + $message ?: 'Expected a value not to start with %2$s. Got: %s', |
|
| 1075 | + static::valueToString($value), |
|
| 1076 | + static::valueToString($prefix) |
|
| 1077 | + )); |
|
| 1078 | + } |
|
| 1079 | + } |
|
| 1080 | + |
|
| 1081 | + /** |
|
| 1082 | + * @psalm-pure |
|
| 1083 | + * |
|
| 1084 | + * @param mixed $value |
|
| 1085 | + * @param string $message |
|
| 1086 | + * |
|
| 1087 | + * @throws InvalidArgumentException |
|
| 1088 | + */ |
|
| 1089 | + public static function startsWithLetter($value, $message = '') |
|
| 1090 | + { |
|
| 1091 | + static::string($value); |
|
| 1092 | + |
|
| 1093 | + $valid = isset($value[0]); |
|
| 1094 | + |
|
| 1095 | + if ($valid) { |
|
| 1096 | + $locale = \setlocale(LC_CTYPE, 0); |
|
| 1097 | + \setlocale(LC_CTYPE, 'C'); |
|
| 1098 | + $valid = \ctype_alpha($value[0]); |
|
| 1099 | + \setlocale(LC_CTYPE, $locale); |
|
| 1100 | + } |
|
| 1101 | + |
|
| 1102 | + if (!$valid) { |
|
| 1103 | + static::reportInvalidArgument(\sprintf( |
|
| 1104 | + $message ?: 'Expected a value to start with a letter. Got: %s', |
|
| 1105 | + static::valueToString($value) |
|
| 1106 | + )); |
|
| 1107 | + } |
|
| 1108 | + } |
|
| 1109 | + |
|
| 1110 | + /** |
|
| 1111 | + * @psalm-pure |
|
| 1112 | + * |
|
| 1113 | + * @param string $value |
|
| 1114 | + * @param string $suffix |
|
| 1115 | + * @param string $message |
|
| 1116 | + * |
|
| 1117 | + * @throws InvalidArgumentException |
|
| 1118 | + */ |
|
| 1119 | + public static function endsWith($value, $suffix, $message = '') |
|
| 1120 | + { |
|
| 1121 | + if ($suffix !== \substr($value, -\strlen($suffix))) { |
|
| 1122 | + static::reportInvalidArgument(\sprintf( |
|
| 1123 | + $message ?: 'Expected a value to end with %2$s. Got: %s', |
|
| 1124 | + static::valueToString($value), |
|
| 1125 | + static::valueToString($suffix) |
|
| 1126 | + )); |
|
| 1127 | + } |
|
| 1128 | + } |
|
| 1129 | + |
|
| 1130 | + /** |
|
| 1131 | + * @psalm-pure |
|
| 1132 | + * |
|
| 1133 | + * @param string $value |
|
| 1134 | + * @param string $suffix |
|
| 1135 | + * @param string $message |
|
| 1136 | + * |
|
| 1137 | + * @throws InvalidArgumentException |
|
| 1138 | + */ |
|
| 1139 | + public static function notEndsWith($value, $suffix, $message = '') |
|
| 1140 | + { |
|
| 1141 | + if ($suffix === \substr($value, -\strlen($suffix))) { |
|
| 1142 | + static::reportInvalidArgument(\sprintf( |
|
| 1143 | + $message ?: 'Expected a value not to end with %2$s. Got: %s', |
|
| 1144 | + static::valueToString($value), |
|
| 1145 | + static::valueToString($suffix) |
|
| 1146 | + )); |
|
| 1147 | + } |
|
| 1148 | + } |
|
| 1149 | + |
|
| 1150 | + /** |
|
| 1151 | + * @psalm-pure |
|
| 1152 | + * |
|
| 1153 | + * @param string $value |
|
| 1154 | + * @param string $pattern |
|
| 1155 | + * @param string $message |
|
| 1156 | + * |
|
| 1157 | + * @throws InvalidArgumentException |
|
| 1158 | + */ |
|
| 1159 | + public static function regex($value, $pattern, $message = '') |
|
| 1160 | + { |
|
| 1161 | + if (!\preg_match($pattern, $value)) { |
|
| 1162 | + static::reportInvalidArgument(\sprintf( |
|
| 1163 | + $message ?: 'The value %s does not match the expected pattern.', |
|
| 1164 | + static::valueToString($value) |
|
| 1165 | + )); |
|
| 1166 | + } |
|
| 1167 | + } |
|
| 1168 | + |
|
| 1169 | + /** |
|
| 1170 | + * @psalm-pure |
|
| 1171 | + * |
|
| 1172 | + * @param string $value |
|
| 1173 | + * @param string $pattern |
|
| 1174 | + * @param string $message |
|
| 1175 | + * |
|
| 1176 | + * @throws InvalidArgumentException |
|
| 1177 | + */ |
|
| 1178 | + public static function notRegex($value, $pattern, $message = '') |
|
| 1179 | + { |
|
| 1180 | + if (\preg_match($pattern, $value, $matches, PREG_OFFSET_CAPTURE)) { |
|
| 1181 | + static::reportInvalidArgument(\sprintf( |
|
| 1182 | + $message ?: 'The value %s matches the pattern %s (at offset %d).', |
|
| 1183 | + static::valueToString($value), |
|
| 1184 | + static::valueToString($pattern), |
|
| 1185 | + $matches[0][1] |
|
| 1186 | + )); |
|
| 1187 | + } |
|
| 1188 | + } |
|
| 1189 | + |
|
| 1190 | + /** |
|
| 1191 | + * @psalm-pure |
|
| 1192 | + * |
|
| 1193 | + * @param mixed $value |
|
| 1194 | + * @param string $message |
|
| 1195 | + * |
|
| 1196 | + * @throws InvalidArgumentException |
|
| 1197 | + */ |
|
| 1198 | + public static function unicodeLetters($value, $message = '') |
|
| 1199 | + { |
|
| 1200 | + static::string($value); |
|
| 1201 | + |
|
| 1202 | + if (!\preg_match('/^\p{L}+$/u', $value)) { |
|
| 1203 | + static::reportInvalidArgument(\sprintf( |
|
| 1204 | + $message ?: 'Expected a value to contain only Unicode letters. Got: %s', |
|
| 1205 | + static::valueToString($value) |
|
| 1206 | + )); |
|
| 1207 | + } |
|
| 1208 | + } |
|
| 1209 | + |
|
| 1210 | + /** |
|
| 1211 | + * @psalm-pure |
|
| 1212 | + * |
|
| 1213 | + * @param mixed $value |
|
| 1214 | + * @param string $message |
|
| 1215 | + * |
|
| 1216 | + * @throws InvalidArgumentException |
|
| 1217 | + */ |
|
| 1218 | + public static function alpha($value, $message = '') |
|
| 1219 | + { |
|
| 1220 | + static::string($value); |
|
| 1221 | + |
|
| 1222 | + $locale = \setlocale(LC_CTYPE, 0); |
|
| 1223 | + \setlocale(LC_CTYPE, 'C'); |
|
| 1224 | + $valid = !\ctype_alpha($value); |
|
| 1225 | + \setlocale(LC_CTYPE, $locale); |
|
| 1226 | + |
|
| 1227 | + if ($valid) { |
|
| 1228 | + static::reportInvalidArgument(\sprintf( |
|
| 1229 | + $message ?: 'Expected a value to contain only letters. Got: %s', |
|
| 1230 | + static::valueToString($value) |
|
| 1231 | + )); |
|
| 1232 | + } |
|
| 1233 | + } |
|
| 1234 | + |
|
| 1235 | + /** |
|
| 1236 | + * @psalm-pure |
|
| 1237 | + * |
|
| 1238 | + * @param string $value |
|
| 1239 | + * @param string $message |
|
| 1240 | + * |
|
| 1241 | + * @throws InvalidArgumentException |
|
| 1242 | + */ |
|
| 1243 | + public static function digits($value, $message = '') |
|
| 1244 | + { |
|
| 1245 | + $locale = \setlocale(LC_CTYPE, 0); |
|
| 1246 | + \setlocale(LC_CTYPE, 'C'); |
|
| 1247 | + $valid = !\ctype_digit($value); |
|
| 1248 | + \setlocale(LC_CTYPE, $locale); |
|
| 1249 | + |
|
| 1250 | + if ($valid) { |
|
| 1251 | + static::reportInvalidArgument(\sprintf( |
|
| 1252 | + $message ?: 'Expected a value to contain digits only. Got: %s', |
|
| 1253 | + static::valueToString($value) |
|
| 1254 | + )); |
|
| 1255 | + } |
|
| 1256 | + } |
|
| 1257 | + |
|
| 1258 | + /** |
|
| 1259 | + * @psalm-pure |
|
| 1260 | + * |
|
| 1261 | + * @param string $value |
|
| 1262 | + * @param string $message |
|
| 1263 | + * |
|
| 1264 | + * @throws InvalidArgumentException |
|
| 1265 | + */ |
|
| 1266 | + public static function alnum($value, $message = '') |
|
| 1267 | + { |
|
| 1268 | + $locale = \setlocale(LC_CTYPE, 0); |
|
| 1269 | + \setlocale(LC_CTYPE, 'C'); |
|
| 1270 | + $valid = !\ctype_alnum($value); |
|
| 1271 | + \setlocale(LC_CTYPE, $locale); |
|
| 1272 | + |
|
| 1273 | + if ($valid) { |
|
| 1274 | + static::reportInvalidArgument(\sprintf( |
|
| 1275 | + $message ?: 'Expected a value to contain letters and digits only. Got: %s', |
|
| 1276 | + static::valueToString($value) |
|
| 1277 | + )); |
|
| 1278 | + } |
|
| 1279 | + } |
|
| 1280 | + |
|
| 1281 | + /** |
|
| 1282 | + * @psalm-pure |
|
| 1283 | + * @psalm-assert lowercase-string $value |
|
| 1284 | + * |
|
| 1285 | + * @param string $value |
|
| 1286 | + * @param string $message |
|
| 1287 | + * |
|
| 1288 | + * @throws InvalidArgumentException |
|
| 1289 | + */ |
|
| 1290 | + public static function lower($value, $message = '') |
|
| 1291 | + { |
|
| 1292 | + $locale = \setlocale(LC_CTYPE, 0); |
|
| 1293 | + \setlocale(LC_CTYPE, 'C'); |
|
| 1294 | + $valid = !\ctype_lower($value); |
|
| 1295 | + \setlocale(LC_CTYPE, $locale); |
|
| 1296 | + |
|
| 1297 | + if ($valid) { |
|
| 1298 | + static::reportInvalidArgument(\sprintf( |
|
| 1299 | + $message ?: 'Expected a value to contain lowercase characters only. Got: %s', |
|
| 1300 | + static::valueToString($value) |
|
| 1301 | + )); |
|
| 1302 | + } |
|
| 1303 | + } |
|
| 1304 | + |
|
| 1305 | + /** |
|
| 1306 | + * @psalm-pure |
|
| 1307 | + * @psalm-assert !lowercase-string $value |
|
| 1308 | + * |
|
| 1309 | + * @param string $value |
|
| 1310 | + * @param string $message |
|
| 1311 | + * |
|
| 1312 | + * @throws InvalidArgumentException |
|
| 1313 | + */ |
|
| 1314 | + public static function upper($value, $message = '') |
|
| 1315 | + { |
|
| 1316 | + $locale = \setlocale(LC_CTYPE, 0); |
|
| 1317 | + \setlocale(LC_CTYPE, 'C'); |
|
| 1318 | + $valid = !\ctype_upper($value); |
|
| 1319 | + \setlocale(LC_CTYPE, $locale); |
|
| 1320 | + |
|
| 1321 | + if ($valid) { |
|
| 1322 | + static::reportInvalidArgument(\sprintf( |
|
| 1323 | + $message ?: 'Expected a value to contain uppercase characters only. Got: %s', |
|
| 1324 | + static::valueToString($value) |
|
| 1325 | + )); |
|
| 1326 | + } |
|
| 1327 | + } |
|
| 1328 | + |
|
| 1329 | + /** |
|
| 1330 | + * @psalm-pure |
|
| 1331 | + * |
|
| 1332 | + * @param string $value |
|
| 1333 | + * @param int $length |
|
| 1334 | + * @param string $message |
|
| 1335 | + * |
|
| 1336 | + * @throws InvalidArgumentException |
|
| 1337 | + */ |
|
| 1338 | + public static function length($value, $length, $message = '') |
|
| 1339 | + { |
|
| 1340 | + if ($length !== static::strlen($value)) { |
|
| 1341 | + static::reportInvalidArgument(\sprintf( |
|
| 1342 | + $message ?: 'Expected a value to contain %2$s characters. Got: %s', |
|
| 1343 | + static::valueToString($value), |
|
| 1344 | + $length |
|
| 1345 | + )); |
|
| 1346 | + } |
|
| 1347 | + } |
|
| 1348 | + |
|
| 1349 | + /** |
|
| 1350 | + * Inclusive min. |
|
| 1351 | + * |
|
| 1352 | + * @psalm-pure |
|
| 1353 | + * |
|
| 1354 | + * @param string $value |
|
| 1355 | + * @param int|float $min |
|
| 1356 | + * @param string $message |
|
| 1357 | + * |
|
| 1358 | + * @throws InvalidArgumentException |
|
| 1359 | + */ |
|
| 1360 | + public static function minLength($value, $min, $message = '') |
|
| 1361 | + { |
|
| 1362 | + if (static::strlen($value) < $min) { |
|
| 1363 | + static::reportInvalidArgument(\sprintf( |
|
| 1364 | + $message ?: 'Expected a value to contain at least %2$s characters. Got: %s', |
|
| 1365 | + static::valueToString($value), |
|
| 1366 | + $min |
|
| 1367 | + )); |
|
| 1368 | + } |
|
| 1369 | + } |
|
| 1370 | + |
|
| 1371 | + /** |
|
| 1372 | + * Inclusive max. |
|
| 1373 | + * |
|
| 1374 | + * @psalm-pure |
|
| 1375 | + * |
|
| 1376 | + * @param string $value |
|
| 1377 | + * @param int|float $max |
|
| 1378 | + * @param string $message |
|
| 1379 | + * |
|
| 1380 | + * @throws InvalidArgumentException |
|
| 1381 | + */ |
|
| 1382 | + public static function maxLength($value, $max, $message = '') |
|
| 1383 | + { |
|
| 1384 | + if (static::strlen($value) > $max) { |
|
| 1385 | + static::reportInvalidArgument(\sprintf( |
|
| 1386 | + $message ?: 'Expected a value to contain at most %2$s characters. Got: %s', |
|
| 1387 | + static::valueToString($value), |
|
| 1388 | + $max |
|
| 1389 | + )); |
|
| 1390 | + } |
|
| 1391 | + } |
|
| 1392 | + |
|
| 1393 | + /** |
|
| 1394 | + * Inclusive , so Assert::lengthBetween('asd', 3, 5); passes the assertion. |
|
| 1395 | + * |
|
| 1396 | + * @psalm-pure |
|
| 1397 | + * |
|
| 1398 | + * @param string $value |
|
| 1399 | + * @param int|float $min |
|
| 1400 | + * @param int|float $max |
|
| 1401 | + * @param string $message |
|
| 1402 | + * |
|
| 1403 | + * @throws InvalidArgumentException |
|
| 1404 | + */ |
|
| 1405 | + public static function lengthBetween($value, $min, $max, $message = '') |
|
| 1406 | + { |
|
| 1407 | + $length = static::strlen($value); |
|
| 1408 | + |
|
| 1409 | + if ($length < $min || $length > $max) { |
|
| 1410 | + static::reportInvalidArgument(\sprintf( |
|
| 1411 | + $message ?: 'Expected a value to contain between %2$s and %3$s characters. Got: %s', |
|
| 1412 | + static::valueToString($value), |
|
| 1413 | + $min, |
|
| 1414 | + $max |
|
| 1415 | + )); |
|
| 1416 | + } |
|
| 1417 | + } |
|
| 1418 | + |
|
| 1419 | + /** |
|
| 1420 | + * Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file. |
|
| 1421 | + * |
|
| 1422 | + * @param mixed $value |
|
| 1423 | + * @param string $message |
|
| 1424 | + * |
|
| 1425 | + * @throws InvalidArgumentException |
|
| 1426 | + */ |
|
| 1427 | + public static function fileExists($value, $message = '') |
|
| 1428 | + { |
|
| 1429 | + static::string($value); |
|
| 1430 | + |
|
| 1431 | + if (!\file_exists($value)) { |
|
| 1432 | + static::reportInvalidArgument(\sprintf( |
|
| 1433 | + $message ?: 'The file %s does not exist.', |
|
| 1434 | + static::valueToString($value) |
|
| 1435 | + )); |
|
| 1436 | + } |
|
| 1437 | + } |
|
| 1438 | + |
|
| 1439 | + /** |
|
| 1440 | + * @param mixed $value |
|
| 1441 | + * @param string $message |
|
| 1442 | + * |
|
| 1443 | + * @throws InvalidArgumentException |
|
| 1444 | + */ |
|
| 1445 | + public static function file($value, $message = '') |
|
| 1446 | + { |
|
| 1447 | + static::fileExists($value, $message); |
|
| 1448 | + |
|
| 1449 | + if (!\is_file($value)) { |
|
| 1450 | + static::reportInvalidArgument(\sprintf( |
|
| 1451 | + $message ?: 'The path %s is not a file.', |
|
| 1452 | + static::valueToString($value) |
|
| 1453 | + )); |
|
| 1454 | + } |
|
| 1455 | + } |
|
| 1456 | + |
|
| 1457 | + /** |
|
| 1458 | + * @param mixed $value |
|
| 1459 | + * @param string $message |
|
| 1460 | + * |
|
| 1461 | + * @throws InvalidArgumentException |
|
| 1462 | + */ |
|
| 1463 | + public static function directory($value, $message = '') |
|
| 1464 | + { |
|
| 1465 | + static::fileExists($value, $message); |
|
| 1466 | + |
|
| 1467 | + if (!\is_dir($value)) { |
|
| 1468 | + static::reportInvalidArgument(\sprintf( |
|
| 1469 | + $message ?: 'The path %s is no directory.', |
|
| 1470 | + static::valueToString($value) |
|
| 1471 | + )); |
|
| 1472 | + } |
|
| 1473 | + } |
|
| 1474 | + |
|
| 1475 | + /** |
|
| 1476 | + * @param string $value |
|
| 1477 | + * @param string $message |
|
| 1478 | + * |
|
| 1479 | + * @throws InvalidArgumentException |
|
| 1480 | + */ |
|
| 1481 | + public static function readable($value, $message = '') |
|
| 1482 | + { |
|
| 1483 | + if (!\is_readable($value)) { |
|
| 1484 | + static::reportInvalidArgument(\sprintf( |
|
| 1485 | + $message ?: 'The path %s is not readable.', |
|
| 1486 | + static::valueToString($value) |
|
| 1487 | + )); |
|
| 1488 | + } |
|
| 1489 | + } |
|
| 1490 | + |
|
| 1491 | + /** |
|
| 1492 | + * @param string $value |
|
| 1493 | + * @param string $message |
|
| 1494 | + * |
|
| 1495 | + * @throws InvalidArgumentException |
|
| 1496 | + */ |
|
| 1497 | + public static function writable($value, $message = '') |
|
| 1498 | + { |
|
| 1499 | + if (!\is_writable($value)) { |
|
| 1500 | + static::reportInvalidArgument(\sprintf( |
|
| 1501 | + $message ?: 'The path %s is not writable.', |
|
| 1502 | + static::valueToString($value) |
|
| 1503 | + )); |
|
| 1504 | + } |
|
| 1505 | + } |
|
| 1506 | + |
|
| 1507 | + /** |
|
| 1508 | + * @psalm-assert class-string $value |
|
| 1509 | + * |
|
| 1510 | + * @param mixed $value |
|
| 1511 | + * @param string $message |
|
| 1512 | + * |
|
| 1513 | + * @throws InvalidArgumentException |
|
| 1514 | + */ |
|
| 1515 | + public static function classExists($value, $message = '') |
|
| 1516 | + { |
|
| 1517 | + if (!\class_exists($value)) { |
|
| 1518 | + static::reportInvalidArgument(\sprintf( |
|
| 1519 | + $message ?: 'Expected an existing class name. Got: %s', |
|
| 1520 | + static::valueToString($value) |
|
| 1521 | + )); |
|
| 1522 | + } |
|
| 1523 | + } |
|
| 1524 | + |
|
| 1525 | + /** |
|
| 1526 | + * @psalm-pure |
|
| 1527 | + * @psalm-template ExpectedType of object |
|
| 1528 | + * @psalm-param class-string<ExpectedType> $class |
|
| 1529 | + * @psalm-assert class-string<ExpectedType>|ExpectedType $value |
|
| 1530 | + * |
|
| 1531 | + * @param mixed $value |
|
| 1532 | + * @param string|object $class |
|
| 1533 | + * @param string $message |
|
| 1534 | + * |
|
| 1535 | + * @throws InvalidArgumentException |
|
| 1536 | + */ |
|
| 1537 | + public static function subclassOf($value, $class, $message = '') |
|
| 1538 | + { |
|
| 1539 | + if (!\is_subclass_of($value, $class)) { |
|
| 1540 | + static::reportInvalidArgument(\sprintf( |
|
| 1541 | + $message ?: 'Expected a sub-class of %2$s. Got: %s', |
|
| 1542 | + static::valueToString($value), |
|
| 1543 | + static::valueToString($class) |
|
| 1544 | + )); |
|
| 1545 | + } |
|
| 1546 | + } |
|
| 1547 | + |
|
| 1548 | + /** |
|
| 1549 | + * @psalm-assert class-string $value |
|
| 1550 | + * |
|
| 1551 | + * @param mixed $value |
|
| 1552 | + * @param string $message |
|
| 1553 | + * |
|
| 1554 | + * @throws InvalidArgumentException |
|
| 1555 | + */ |
|
| 1556 | + public static function interfaceExists($value, $message = '') |
|
| 1557 | + { |
|
| 1558 | + if (!\interface_exists($value)) { |
|
| 1559 | + static::reportInvalidArgument(\sprintf( |
|
| 1560 | + $message ?: 'Expected an existing interface name. got %s', |
|
| 1561 | + static::valueToString($value) |
|
| 1562 | + )); |
|
| 1563 | + } |
|
| 1564 | + } |
|
| 1565 | + |
|
| 1566 | + /** |
|
| 1567 | + * @psalm-pure |
|
| 1568 | + * @psalm-template ExpectedType of object |
|
| 1569 | + * @psalm-param class-string<ExpectedType> $interface |
|
| 1570 | + * @psalm-assert class-string<ExpectedType> $value |
|
| 1571 | + * |
|
| 1572 | + * @param mixed $value |
|
| 1573 | + * @param mixed $interface |
|
| 1574 | + * @param string $message |
|
| 1575 | + * |
|
| 1576 | + * @throws InvalidArgumentException |
|
| 1577 | + */ |
|
| 1578 | + public static function implementsInterface($value, $interface, $message = '') |
|
| 1579 | + { |
|
| 1580 | + if (!\in_array($interface, \class_implements($value))) { |
|
| 1581 | + static::reportInvalidArgument(\sprintf( |
|
| 1582 | + $message ?: 'Expected an implementation of %2$s. Got: %s', |
|
| 1583 | + static::valueToString($value), |
|
| 1584 | + static::valueToString($interface) |
|
| 1585 | + )); |
|
| 1586 | + } |
|
| 1587 | + } |
|
| 1588 | + |
|
| 1589 | + /** |
|
| 1590 | + * @psalm-pure |
|
| 1591 | + * @psalm-param class-string|object $classOrObject |
|
| 1592 | + * |
|
| 1593 | + * @param string|object $classOrObject |
|
| 1594 | + * @param mixed $property |
|
| 1595 | + * @param string $message |
|
| 1596 | + * |
|
| 1597 | + * @throws InvalidArgumentException |
|
| 1598 | + */ |
|
| 1599 | + public static function propertyExists($classOrObject, $property, $message = '') |
|
| 1600 | + { |
|
| 1601 | + if (!\property_exists($classOrObject, $property)) { |
|
| 1602 | + static::reportInvalidArgument(\sprintf( |
|
| 1603 | + $message ?: 'Expected the property %s to exist.', |
|
| 1604 | + static::valueToString($property) |
|
| 1605 | + )); |
|
| 1606 | + } |
|
| 1607 | + } |
|
| 1608 | + |
|
| 1609 | + /** |
|
| 1610 | + * @psalm-pure |
|
| 1611 | + * @psalm-param class-string|object $classOrObject |
|
| 1612 | + * |
|
| 1613 | + * @param string|object $classOrObject |
|
| 1614 | + * @param mixed $property |
|
| 1615 | + * @param string $message |
|
| 1616 | + * |
|
| 1617 | + * @throws InvalidArgumentException |
|
| 1618 | + */ |
|
| 1619 | + public static function propertyNotExists($classOrObject, $property, $message = '') |
|
| 1620 | + { |
|
| 1621 | + if (\property_exists($classOrObject, $property)) { |
|
| 1622 | + static::reportInvalidArgument(\sprintf( |
|
| 1623 | + $message ?: 'Expected the property %s to not exist.', |
|
| 1624 | + static::valueToString($property) |
|
| 1625 | + )); |
|
| 1626 | + } |
|
| 1627 | + } |
|
| 1628 | + |
|
| 1629 | + /** |
|
| 1630 | + * @psalm-pure |
|
| 1631 | + * @psalm-param class-string|object $classOrObject |
|
| 1632 | + * |
|
| 1633 | + * @param string|object $classOrObject |
|
| 1634 | + * @param mixed $method |
|
| 1635 | + * @param string $message |
|
| 1636 | + * |
|
| 1637 | + * @throws InvalidArgumentException |
|
| 1638 | + */ |
|
| 1639 | + public static function methodExists($classOrObject, $method, $message = '') |
|
| 1640 | + { |
|
| 1641 | + if (!(\is_string($classOrObject) || \is_object($classOrObject)) || !\method_exists($classOrObject, $method)) { |
|
| 1642 | + static::reportInvalidArgument(\sprintf( |
|
| 1643 | + $message ?: 'Expected the method %s to exist.', |
|
| 1644 | + static::valueToString($method) |
|
| 1645 | + )); |
|
| 1646 | + } |
|
| 1647 | + } |
|
| 1648 | + |
|
| 1649 | + /** |
|
| 1650 | + * @psalm-pure |
|
| 1651 | + * @psalm-param class-string|object $classOrObject |
|
| 1652 | + * |
|
| 1653 | + * @param string|object $classOrObject |
|
| 1654 | + * @param mixed $method |
|
| 1655 | + * @param string $message |
|
| 1656 | + * |
|
| 1657 | + * @throws InvalidArgumentException |
|
| 1658 | + */ |
|
| 1659 | + public static function methodNotExists($classOrObject, $method, $message = '') |
|
| 1660 | + { |
|
| 1661 | + if ((\is_string($classOrObject) || \is_object($classOrObject)) && \method_exists($classOrObject, $method)) { |
|
| 1662 | + static::reportInvalidArgument(\sprintf( |
|
| 1663 | + $message ?: 'Expected the method %s to not exist.', |
|
| 1664 | + static::valueToString($method) |
|
| 1665 | + )); |
|
| 1666 | + } |
|
| 1667 | + } |
|
| 1668 | + |
|
| 1669 | + /** |
|
| 1670 | + * @psalm-pure |
|
| 1671 | + * |
|
| 1672 | + * @param array $array |
|
| 1673 | + * @param string|int $key |
|
| 1674 | + * @param string $message |
|
| 1675 | + * |
|
| 1676 | + * @throws InvalidArgumentException |
|
| 1677 | + */ |
|
| 1678 | + public static function keyExists($array, $key, $message = '') |
|
| 1679 | + { |
|
| 1680 | + if (!(isset($array[$key]) || \array_key_exists($key, $array))) { |
|
| 1681 | + static::reportInvalidArgument(\sprintf( |
|
| 1682 | + $message ?: 'Expected the key %s to exist.', |
|
| 1683 | + static::valueToString($key) |
|
| 1684 | + )); |
|
| 1685 | + } |
|
| 1686 | + } |
|
| 1687 | + |
|
| 1688 | + /** |
|
| 1689 | + * @psalm-pure |
|
| 1690 | + * |
|
| 1691 | + * @param array $array |
|
| 1692 | + * @param string|int $key |
|
| 1693 | + * @param string $message |
|
| 1694 | + * |
|
| 1695 | + * @throws InvalidArgumentException |
|
| 1696 | + */ |
|
| 1697 | + public static function keyNotExists($array, $key, $message = '') |
|
| 1698 | + { |
|
| 1699 | + if (isset($array[$key]) || \array_key_exists($key, $array)) { |
|
| 1700 | + static::reportInvalidArgument(\sprintf( |
|
| 1701 | + $message ?: 'Expected the key %s to not exist.', |
|
| 1702 | + static::valueToString($key) |
|
| 1703 | + )); |
|
| 1704 | + } |
|
| 1705 | + } |
|
| 1706 | + |
|
| 1707 | + /** |
|
| 1708 | + * Checks if a value is a valid array key (int or string). |
|
| 1709 | + * |
|
| 1710 | + * @psalm-pure |
|
| 1711 | + * @psalm-assert array-key $value |
|
| 1712 | + * |
|
| 1713 | + * @param mixed $value |
|
| 1714 | + * @param string $message |
|
| 1715 | + * |
|
| 1716 | + * @throws InvalidArgumentException |
|
| 1717 | + */ |
|
| 1718 | + public static function validArrayKey($value, $message = '') |
|
| 1719 | + { |
|
| 1720 | + if (!(\is_int($value) || \is_string($value))) { |
|
| 1721 | + static::reportInvalidArgument(\sprintf( |
|
| 1722 | + $message ?: 'Expected string or integer. Got: %s', |
|
| 1723 | + static::typeToString($value) |
|
| 1724 | + )); |
|
| 1725 | + } |
|
| 1726 | + } |
|
| 1727 | + |
|
| 1728 | + /** |
|
| 1729 | + * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| 1730 | + * |
|
| 1731 | + * @param Countable|array $array |
|
| 1732 | + * @param int $number |
|
| 1733 | + * @param string $message |
|
| 1734 | + * |
|
| 1735 | + * @throws InvalidArgumentException |
|
| 1736 | + */ |
|
| 1737 | + public static function count($array, $number, $message = '') |
|
| 1738 | + { |
|
| 1739 | + static::eq( |
|
| 1740 | + \count($array), |
|
| 1741 | + $number, |
|
| 1742 | + \sprintf( |
|
| 1743 | + $message ?: 'Expected an array to contain %d elements. Got: %d.', |
|
| 1744 | + $number, |
|
| 1745 | + \count($array) |
|
| 1746 | + ) |
|
| 1747 | + ); |
|
| 1748 | + } |
|
| 1749 | + |
|
| 1750 | + /** |
|
| 1751 | + * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| 1752 | + * |
|
| 1753 | + * @param Countable|array $array |
|
| 1754 | + * @param int|float $min |
|
| 1755 | + * @param string $message |
|
| 1756 | + * |
|
| 1757 | + * @throws InvalidArgumentException |
|
| 1758 | + */ |
|
| 1759 | + public static function minCount($array, $min, $message = '') |
|
| 1760 | + { |
|
| 1761 | + if (\count($array) < $min) { |
|
| 1762 | + static::reportInvalidArgument(\sprintf( |
|
| 1763 | + $message ?: 'Expected an array to contain at least %2$d elements. Got: %d', |
|
| 1764 | + \count($array), |
|
| 1765 | + $min |
|
| 1766 | + )); |
|
| 1767 | + } |
|
| 1768 | + } |
|
| 1769 | + |
|
| 1770 | + /** |
|
| 1771 | + * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| 1772 | + * |
|
| 1773 | + * @param Countable|array $array |
|
| 1774 | + * @param int|float $max |
|
| 1775 | + * @param string $message |
|
| 1776 | + * |
|
| 1777 | + * @throws InvalidArgumentException |
|
| 1778 | + */ |
|
| 1779 | + public static function maxCount($array, $max, $message = '') |
|
| 1780 | + { |
|
| 1781 | + if (\count($array) > $max) { |
|
| 1782 | + static::reportInvalidArgument(\sprintf( |
|
| 1783 | + $message ?: 'Expected an array to contain at most %2$d elements. Got: %d', |
|
| 1784 | + \count($array), |
|
| 1785 | + $max |
|
| 1786 | + )); |
|
| 1787 | + } |
|
| 1788 | + } |
|
| 1789 | + |
|
| 1790 | + /** |
|
| 1791 | + * Does not check if $array is countable, this can generate a warning on php versions after 7.2. |
|
| 1792 | + * |
|
| 1793 | + * @param Countable|array $array |
|
| 1794 | + * @param int|float $min |
|
| 1795 | + * @param int|float $max |
|
| 1796 | + * @param string $message |
|
| 1797 | + * |
|
| 1798 | + * @throws InvalidArgumentException |
|
| 1799 | + */ |
|
| 1800 | + public static function countBetween($array, $min, $max, $message = '') |
|
| 1801 | + { |
|
| 1802 | + $count = \count($array); |
|
| 1803 | + |
|
| 1804 | + if ($count < $min || $count > $max) { |
|
| 1805 | + static::reportInvalidArgument(\sprintf( |
|
| 1806 | + $message ?: 'Expected an array to contain between %2$d and %3$d elements. Got: %d', |
|
| 1807 | + $count, |
|
| 1808 | + $min, |
|
| 1809 | + $max |
|
| 1810 | + )); |
|
| 1811 | + } |
|
| 1812 | + } |
|
| 1813 | + |
|
| 1814 | + /** |
|
| 1815 | + * @psalm-pure |
|
| 1816 | + * @psalm-assert list $array |
|
| 1817 | + * |
|
| 1818 | + * @param mixed $array |
|
| 1819 | + * @param string $message |
|
| 1820 | + * |
|
| 1821 | + * @throws InvalidArgumentException |
|
| 1822 | + */ |
|
| 1823 | + public static function isList($array, $message = '') |
|
| 1824 | + { |
|
| 1825 | + if (!\is_array($array)) { |
|
| 1826 | + static::reportInvalidArgument( |
|
| 1827 | + $message ?: 'Expected list - non-associative array.' |
|
| 1828 | + ); |
|
| 1829 | + } |
|
| 1830 | + |
|
| 1831 | + if ($array === \array_values($array)) { |
|
| 1832 | + return; |
|
| 1833 | + } |
|
| 1834 | + |
|
| 1835 | + $nextKey = -1; |
|
| 1836 | + foreach ($array as $k => $v) { |
|
| 1837 | + if ($k !== ++$nextKey) { |
|
| 1838 | + static::reportInvalidArgument( |
|
| 1839 | + $message ?: 'Expected list - non-associative array.' |
|
| 1840 | + ); |
|
| 1841 | + } |
|
| 1842 | + } |
|
| 1843 | + } |
|
| 1844 | + |
|
| 1845 | + /** |
|
| 1846 | + * @psalm-pure |
|
| 1847 | + * @psalm-assert non-empty-list $array |
|
| 1848 | + * |
|
| 1849 | + * @param mixed $array |
|
| 1850 | + * @param string $message |
|
| 1851 | + * |
|
| 1852 | + * @throws InvalidArgumentException |
|
| 1853 | + */ |
|
| 1854 | + public static function isNonEmptyList($array, $message = '') |
|
| 1855 | + { |
|
| 1856 | + static::isList($array, $message); |
|
| 1857 | + static::notEmpty($array, $message); |
|
| 1858 | + } |
|
| 1859 | + |
|
| 1860 | + /** |
|
| 1861 | + * @psalm-pure |
|
| 1862 | + * @psalm-template T |
|
| 1863 | + * @psalm-param mixed|array<T> $array |
|
| 1864 | + * @psalm-assert array<string, T> $array |
|
| 1865 | + * |
|
| 1866 | + * @param mixed $array |
|
| 1867 | + * @param string $message |
|
| 1868 | + * |
|
| 1869 | + * @throws InvalidArgumentException |
|
| 1870 | + */ |
|
| 1871 | + public static function isMap($array, $message = '') |
|
| 1872 | + { |
|
| 1873 | + if ( |
|
| 1874 | + !\is_array($array) || |
|
| 1875 | + \array_keys($array) !== \array_filter(\array_keys($array), '\is_string') |
|
| 1876 | + ) { |
|
| 1877 | + static::reportInvalidArgument( |
|
| 1878 | + $message ?: 'Expected map - associative array with string keys.' |
|
| 1879 | + ); |
|
| 1880 | + } |
|
| 1881 | + } |
|
| 1882 | + |
|
| 1883 | + /** |
|
| 1884 | + * @psalm-pure |
|
| 1885 | + * @psalm-template T |
|
| 1886 | + * @psalm-param mixed|array<T> $array |
|
| 1887 | + * @psalm-assert array<string, T> $array |
|
| 1888 | + * @psalm-assert !empty $array |
|
| 1889 | + * |
|
| 1890 | + * @param mixed $array |
|
| 1891 | + * @param string $message |
|
| 1892 | + * |
|
| 1893 | + * @throws InvalidArgumentException |
|
| 1894 | + */ |
|
| 1895 | + public static function isNonEmptyMap($array, $message = '') |
|
| 1896 | + { |
|
| 1897 | + static::isMap($array, $message); |
|
| 1898 | + static::notEmpty($array, $message); |
|
| 1899 | + } |
|
| 1900 | + |
|
| 1901 | + /** |
|
| 1902 | + * @psalm-pure |
|
| 1903 | + * |
|
| 1904 | + * @param string $value |
|
| 1905 | + * @param string $message |
|
| 1906 | + * |
|
| 1907 | + * @throws InvalidArgumentException |
|
| 1908 | + */ |
|
| 1909 | + public static function uuid($value, $message = '') |
|
| 1910 | + { |
|
| 1911 | + $value = \str_replace(array('urn:', 'uuid:', '{', '}'), '', $value); |
|
| 1912 | + |
|
| 1913 | + // The nil UUID is special form of UUID that is specified to have all |
|
| 1914 | + // 128 bits set to zero. |
|
| 1915 | + if ('00000000-0000-0000-0000-000000000000' === $value) { |
|
| 1916 | + return; |
|
| 1917 | + } |
|
| 1918 | + |
|
| 1919 | + if (!\preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) { |
|
| 1920 | + static::reportInvalidArgument(\sprintf( |
|
| 1921 | + $message ?: 'Value %s is not a valid UUID.', |
|
| 1922 | + static::valueToString($value) |
|
| 1923 | + )); |
|
| 1924 | + } |
|
| 1925 | + } |
|
| 1926 | + |
|
| 1927 | + /** |
|
| 1928 | + * @psalm-param class-string<Throwable> $class |
|
| 1929 | + * |
|
| 1930 | + * @param Closure $expression |
|
| 1931 | + * @param string $class |
|
| 1932 | + * @param string $message |
|
| 1933 | + * |
|
| 1934 | + * @throws InvalidArgumentException |
|
| 1935 | + */ |
|
| 1936 | + public static function throws(Closure $expression, $class = 'Exception', $message = '') |
|
| 1937 | + { |
|
| 1938 | + static::string($class); |
|
| 1939 | + |
|
| 1940 | + $actual = 'none'; |
|
| 1941 | + |
|
| 1942 | + try { |
|
| 1943 | + $expression(); |
|
| 1944 | + } catch (Exception $e) { |
|
| 1945 | + $actual = \get_class($e); |
|
| 1946 | + if ($e instanceof $class) { |
|
| 1947 | + return; |
|
| 1948 | + } |
|
| 1949 | + } catch (Throwable $e) { |
|
| 1950 | + $actual = \get_class($e); |
|
| 1951 | + if ($e instanceof $class) { |
|
| 1952 | + return; |
|
| 1953 | + } |
|
| 1954 | + } |
|
| 1955 | + |
|
| 1956 | + static::reportInvalidArgument($message ?: \sprintf( |
|
| 1957 | + 'Expected to throw "%s", got "%s"', |
|
| 1958 | + $class, |
|
| 1959 | + $actual |
|
| 1960 | + )); |
|
| 1961 | + } |
|
| 1962 | + |
|
| 1963 | + /** |
|
| 1964 | + * @throws BadMethodCallException |
|
| 1965 | + */ |
|
| 1966 | + public static function __callStatic($name, $arguments) |
|
| 1967 | + { |
|
| 1968 | + if ('nullOr' === \substr($name, 0, 6)) { |
|
| 1969 | + if (null !== $arguments[0]) { |
|
| 1970 | + $method = \lcfirst(\substr($name, 6)); |
|
| 1971 | + \call_user_func_array(array(static::class, $method), $arguments); |
|
| 1972 | + } |
|
| 1973 | + |
|
| 1974 | + return; |
|
| 1975 | + } |
|
| 1976 | + |
|
| 1977 | + if ('all' === \substr($name, 0, 3)) { |
|
| 1978 | + static::isIterable($arguments[0]); |
|
| 1979 | + |
|
| 1980 | + $method = \lcfirst(\substr($name, 3)); |
|
| 1981 | + $args = $arguments; |
|
| 1982 | + |
|
| 1983 | + foreach ($arguments[0] as $entry) { |
|
| 1984 | + $args[0] = $entry; |
|
| 1985 | + |
|
| 1986 | + \call_user_func_array(array(static::class, $method), $args); |
|
| 1987 | + } |
|
| 1988 | + |
|
| 1989 | + return; |
|
| 1990 | + } |
|
| 1991 | + |
|
| 1992 | + throw new BadMethodCallException('No such method: '.$name); |
|
| 1993 | + } |
|
| 1994 | + |
|
| 1995 | + /** |
|
| 1996 | + * @param mixed $value |
|
| 1997 | + * |
|
| 1998 | + * @return string |
|
| 1999 | + */ |
|
| 2000 | + protected static function valueToString($value) |
|
| 2001 | + { |
|
| 2002 | + if (null === $value) { |
|
| 2003 | + return 'null'; |
|
| 2004 | + } |
|
| 2005 | + |
|
| 2006 | + if (true === $value) { |
|
| 2007 | + return 'true'; |
|
| 2008 | + } |
|
| 2009 | + |
|
| 2010 | + if (false === $value) { |
|
| 2011 | + return 'false'; |
|
| 2012 | + } |
|
| 2013 | + |
|
| 2014 | + if (\is_array($value)) { |
|
| 2015 | + return 'array'; |
|
| 2016 | + } |
|
| 2017 | + |
|
| 2018 | + if (\is_object($value)) { |
|
| 2019 | + if (\method_exists($value, '__toString')) { |
|
| 2020 | + return \get_class($value).': '.self::valueToString($value->__toString()); |
|
| 2021 | + } |
|
| 2022 | + |
|
| 2023 | + if ($value instanceof DateTime || $value instanceof DateTimeImmutable) { |
|
| 2024 | + return \get_class($value).': '.self::valueToString($value->format('c')); |
|
| 2025 | + } |
|
| 2026 | + |
|
| 2027 | + return \get_class($value); |
|
| 2028 | + } |
|
| 2029 | + |
|
| 2030 | + if (\is_resource($value)) { |
|
| 2031 | + return 'resource'; |
|
| 2032 | + } |
|
| 2033 | + |
|
| 2034 | + if (\is_string($value)) { |
|
| 2035 | + return '"'.$value.'"'; |
|
| 2036 | + } |
|
| 2037 | + |
|
| 2038 | + return (string) $value; |
|
| 2039 | + } |
|
| 2040 | + |
|
| 2041 | + /** |
|
| 2042 | + * @param mixed $value |
|
| 2043 | + * |
|
| 2044 | + * @return string |
|
| 2045 | + */ |
|
| 2046 | + protected static function typeToString($value) |
|
| 2047 | + { |
|
| 2048 | + return \is_object($value) ? \get_class($value) : \gettype($value); |
|
| 2049 | + } |
|
| 2050 | + |
|
| 2051 | + protected static function strlen($value) |
|
| 2052 | + { |
|
| 2053 | + if (!\function_exists('mb_detect_encoding')) { |
|
| 2054 | + return \strlen($value); |
|
| 2055 | + } |
|
| 2056 | + |
|
| 2057 | + if (false === $encoding = \mb_detect_encoding($value)) { |
|
| 2058 | + return \strlen($value); |
|
| 2059 | + } |
|
| 2060 | + |
|
| 2061 | + return \mb_strlen($value, $encoding); |
|
| 2062 | + } |
|
| 2063 | + |
|
| 2064 | + /** |
|
| 2065 | + * @param string $message |
|
| 2066 | + * |
|
| 2067 | + * @throws InvalidArgumentException |
|
| 2068 | + * |
|
| 2069 | + * @psalm-pure this method is not supposed to perform side-effects |
|
| 2070 | + * @psalm-return never |
|
| 2071 | + */ |
|
| 2072 | + protected static function reportInvalidArgument($message) |
|
| 2073 | + { |
|
| 2074 | + throw new InvalidArgumentException($message); |
|
| 2075 | + } |
|
| 2076 | + |
|
| 2077 | + private function __construct() |
|
| 2078 | + { |
|
| 2079 | + } |
|
| 2080 | 2080 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public static function integerish($value, $message = '') |
| 100 | 100 | { |
| 101 | - if (!\is_numeric($value) || $value != (int) $value) { |
|
| 101 | + if (!\is_numeric($value) || $value != (int)$value) { |
|
| 102 | 102 | static::reportInvalidArgument(\sprintf( |
| 103 | 103 | $message ?: 'Expected an integerish value. Got: %s', |
| 104 | 104 | static::typeToString($value) |
@@ -2035,7 +2035,7 @@ discard block |
||
| 2035 | 2035 | return '"'.$value.'"'; |
| 2036 | 2036 | } |
| 2037 | 2037 | |
| 2038 | - return (string) $value; |
|
| 2038 | + return (string)$value; |
|
| 2039 | 2039 | } |
| 2040 | 2040 | |
| 2041 | 2041 | /** |
@@ -30,8 +30,7 @@ |
||
| 30 | 30 | * |
| 31 | 31 | * @author Bernhard Schussek <[email protected]> |
| 32 | 32 | */ |
| 33 | -class Assert |
|
| 34 | -{ |
|
| 33 | +class Assert { |
|
| 35 | 34 | use Mixin; |
| 36 | 35 | |
| 37 | 36 | /** |
@@ -15,10 +15,10 @@ |
||
| 15 | 15 | |
| 16 | 16 | final class StatefulService |
| 17 | 17 | { |
| 18 | - public bool $called = false; |
|
| 18 | + public bool $called = false; |
|
| 19 | 19 | |
| 20 | - public function call(): void |
|
| 21 | - { |
|
| 22 | - $this->called = true; |
|
| 23 | - } |
|
| 20 | + public function call(): void |
|
| 21 | + { |
|
| 22 | + $this->called = true; |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -13,8 +13,7 @@ |
||
| 13 | 13 | |
| 14 | 14 | namespace Fidry\Console\Tests; |
| 15 | 15 | |
| 16 | -final class StatefulService |
|
| 17 | -{ |
|
| 16 | +final class StatefulService { |
|
| 18 | 17 | public bool $called = false; |
| 19 | 18 | |
| 20 | 19 | public function call(): void |