Debian Codegraph @

lib/3rdParty/composer/webmozart/assert/src/Mixin.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Webmozart\Assert;
6
7 use ArrayAccess;
8 use Closure;
9 use Countable;
10 use Throwable;
11
12 /**
13 * This trait provides nullOr*, all* and allNullOr* variants of assertion base methods.
14 * Do not use this trait directly: it will change, and is not designed for reuse.
15 */
16 trait Mixin
17 {
18 /**
19 * @psalm-pure
20 *
21 * @psalm-assert string|null $value
22 *
23 * @param string|callable():string $message
24 *
25 * @return string|null
26 *
27 * @throws InvalidArgumentException
28 */
29 public static function nullOrString(mixed $value, callable|string $message = ''): ?string
30 {
31 null === $value || static::string($value, $message);
32
33 return $value;
34 }
35
36 /**
37 * @psalm-pure
38 *
39 * @psalm-assert iterable<string> $value
40 *
41 * @param string|callable():string $message
42 *
43 * @return iterable<string>
44 *
45 * @throws InvalidArgumentException
46 */
47 public static function allString(mixed $value, callable|string $message = ''): iterable
48 {
49 static::isIterable($value);
50
51 foreach ($value as $entry) {
52 static::string($entry, $message);
53 }
54
55 return $value;
56 }
57
58 /**
59 * @psalm-pure
60 *
61 * @psalm-assert iterable<string|null> $value
62 *
63 * @param string|callable():string $message
64 *
65 * @return iterable<string|null>
66 *
67 * @throws InvalidArgumentException
68 */
69 public static function allNullOrString(mixed $value, callable|string $message = ''): iterable
70 {
71 static::isIterable($value);
72
73 foreach ($value as $entry) {
74 null === $entry || static::string($entry, $message);
75 }
76
77 return $value;
78 }
79
80 /**
81 * @psalm-pure
82 *
83 * @psalm-assert non-empty-string|null $value
84 *
85 * @param string|callable():string $message
86 *
87 * @return non-empty-string|null
88 *
89 * @throws InvalidArgumentException
90 */
91 public static function nullOrStringNotEmpty(mixed $value, callable|string $message = ''): ?string
92 {
93 null === $value || static::stringNotEmpty($value, $message);
94
95 return $value;
96 }
97
98 /**
99 * @psalm-pure
100 *
101 * @psalm-assert iterable<non-empty-string> $value
102 *
103 * @param string|callable():string $message
104 *
105 * @return iterable<non-empty-string>
106 *
107 * @throws InvalidArgumentException
108 */
109 public static function allStringNotEmpty(mixed $value, callable|string $message = ''): iterable
110 {
111 static::isIterable($value);
112
113 foreach ($value as $entry) {
114 static::stringNotEmpty($entry, $message);
115 }
116
117 return $value;
118 }
119
120 /**
121 * @psalm-pure
122 *
123 * @psalm-assert iterable<non-empty-string|null> $value
124 *
125 * @param string|callable():string $message
126 *
127 * @return iterable<non-empty-string|null>
128 *
129 * @throws InvalidArgumentException
130 */
131 public static function allNullOrStringNotEmpty(mixed $value, callable|string $message = ''): iterable
132 {
133 static::isIterable($value);
134
135 foreach ($value as $entry) {
136 null === $entry || static::stringNotEmpty($entry, $message);
137 }
138
139 return $value;
140 }
141
142 /**
143 * @psalm-pure
144 *
145 * @psalm-assert int|null $value
146 *
147 * @param string|callable():string $message
148 *
149 * @return int|null
150 *
151 * @throws InvalidArgumentException
152 */
153 public static function nullOrInteger(mixed $value, callable|string $message = ''): ?int
154 {
155 null === $value || static::integer($value, $message);
156
157 return $value;
158 }
159
160 /**
161 * @psalm-pure
162 *
163 * @psalm-assert iterable<int> $value
164 *
165 * @param string|callable():string $message
166 *
167 * @return iterable<int>
168 *
169 * @throws InvalidArgumentException
170 */
171 public static function allInteger(mixed $value, callable|string $message = ''): iterable
172 {
173 static::isIterable($value);
174
175 foreach ($value as $entry) {
176 static::integer($entry, $message);
177 }
178
179 return $value;
180 }
181
182 /**
183 * @psalm-pure
184 *
185 * @psalm-assert iterable<int|null> $value
186 *
187 * @param string|callable():string $message
188 *
189 * @return iterable<int|null>
190 *
191 * @throws InvalidArgumentException
192 */
193 public static function allNullOrInteger(mixed $value, callable|string $message = ''): iterable
194 {
195 static::isIterable($value);
196
197 foreach ($value as $entry) {
198 null === $entry || static::integer($entry, $message);
199 }
200
201 return $value;
202 }
203
204 /**
205 * @psalm-pure
206 *
207 * @psalm-assert numeric|null $value
208 *
209 * @param string|callable():string $message
210 *
211 * @return numeric|null
212 *
213 * @throws InvalidArgumentException
214 */
215 public static function nullOrIntegerish(mixed $value, callable|string $message = ''): string|int|float|null
216 {
217 null === $value || static::integerish($value, $message);
218
219 return $value;
220 }
221
222 /**
223 * @psalm-pure
224 *
225 * @psalm-assert iterable<numeric> $value
226 *
227 * @param string|callable():string $message
228 *
229 * @return iterable<numeric>
230 *
231 * @throws InvalidArgumentException
232 */
233 public static function allIntegerish(mixed $value, callable|string $message = ''): iterable
234 {
235 static::isIterable($value);
236
237 foreach ($value as $entry) {
238 static::integerish($entry, $message);
239 }
240
241 return $value;
242 }
243
244 /**
245 * @psalm-pure
246 *
247 * @psalm-assert iterable<numeric|null> $value
248 *
249 * @param string|callable():string $message
250 *
251 * @return iterable<numeric|null>
252 *
253 * @throws InvalidArgumentException
254 */
255 public static function allNullOrIntegerish(mixed $value, callable|string $message = ''): iterable
256 {
257 static::isIterable($value);
258
259 foreach ($value as $entry) {
260 null === $entry || static::integerish($entry, $message);
261 }
262
263 return $value;
264 }
265
266 /**
267 * @psalm-pure
268 *
269 * @psalm-assert positive-int|null $value
270 *
271 * @param string|callable():string $message
272 *
273 * @return positive-int|null
274 *
275 * @throws InvalidArgumentException
276 */
277 public static function nullOrPositiveInteger(mixed $value, callable|string $message = ''): ?int
278 {
279 null === $value || static::positiveInteger($value, $message);
280
281 return $value;
282 }
283
284 /**
285 * @psalm-pure
286 *
287 * @psalm-assert iterable<positive-int> $value
288 *
289 * @param string|callable():string $message
290 *
291 * @return iterable<positive-int>
292 *
293 * @throws InvalidArgumentException
294 */
295 public static function allPositiveInteger(mixed $value, callable|string $message = ''): iterable
296 {
297 static::isIterable($value);
298
299 foreach ($value as $entry) {
300 static::positiveInteger($entry, $message);
301 }
302
303 return $value;
304 }
305
306 /**
307 * @psalm-pure
308 *
309 * @psalm-assert iterable<positive-int|null> $value
310 *
311 * @param string|callable():string $message
312 *
313 * @return iterable<positive-int|null>
314 *
315 * @throws InvalidArgumentException
316 */
317 public static function allNullOrPositiveInteger(mixed $value, callable|string $message = ''): iterable
318 {
319 static::isIterable($value);
320
321 foreach ($value as $entry) {
322 null === $entry || static::positiveInteger($entry, $message);
323 }
324
325 return $value;
326 }
327
328 /**
329 * @psalm-pure
330 *
331 * @psalm-assert non-negative-int|null $value
332 *
333 * @param string|callable():string $message
334 *
335 * @return non-negative-int|null
336 *
337 * @throws InvalidArgumentException
338 */
339 public static function nullOrNotNegativeInteger(mixed $value, callable|string $message = ''): ?int
340 {
341 null === $value || static::notNegativeInteger($value, $message);
342
343 return $value;
344 }
345
346 /**
347 * @psalm-pure
348 *
349 * @psalm-assert iterable<non-negative-int> $value
350 *
351 * @param string|callable():string $message
352 *
353 * @return iterable<non-negative-int>
354 *
355 * @throws InvalidArgumentException
356 */
357 public static function allNotNegativeInteger(mixed $value, callable|string $message = ''): iterable
358 {
359 static::isIterable($value);
360
361 foreach ($value as $entry) {
362 static::notNegativeInteger($entry, $message);
363 }
364
365 return $value;
366 }
367
368 /**
369 * @psalm-pure
370 *
371 * @psalm-assert iterable<non-negative-int|null> $value
372 *
373 * @param string|callable():string $message
374 *
375 * @return iterable<non-negative-int|null>
376 *
377 * @throws InvalidArgumentException
378 */
379 public static function allNullOrNotNegativeInteger(mixed $value, callable|string $message = ''): iterable
380 {
381 static::isIterable($value);
382
383 foreach ($value as $entry) {
384 null === $entry || static::notNegativeInteger($entry, $message);
385 }
386
387 return $value;
388 }
389
390 /**
391 * @psalm-pure
392 *
393 * @psalm-assert negative-int|null $value
394 *
395 * @param string|callable():string $message
396 *
397 * @return negative-int|null
398 *
399 * @throws InvalidArgumentException
400 */
401 public static function nullOrNegativeInteger(mixed $value, callable|string $message = ''): ?int
402 {
403 null === $value || static::negativeInteger($value, $message);
404
405 return $value;
406 }
407
408 /**
409 * @psalm-pure
410 *
411 * @psalm-assert iterable<negative-int> $value
412 *
413 * @param string|callable():string $message
414 *
415 * @return iterable<negative-int>
416 *
417 * @throws InvalidArgumentException
418 */
419 public static function allNegativeInteger(mixed $value, callable|string $message = ''): iterable
420 {
421 static::isIterable($value);
422
423 foreach ($value as $entry) {
424 static::negativeInteger($entry, $message);
425 }
426
427 return $value;
428 }
429
430 /**
431 * @psalm-pure
432 *
433 * @psalm-assert iterable<negative-int|null> $value
434 *
435 * @param string|callable():string $message
436 *
437 * @return iterable<negative-int|null>
438 *
439 * @throws InvalidArgumentException
440 */
441 public static function allNullOrNegativeInteger(mixed $value, callable|string $message = ''): iterable
442 {
443 static::isIterable($value);
444
445 foreach ($value as $entry) {
446 null === $entry || static::negativeInteger($entry, $message);
447 }
448
449 return $value;
450 }
451
452 /**
453 * @psalm-pure
454 *
455 * @psalm-assert float|null $value
456 *
457 * @param string|callable():string $message
458 *
459 * @return float|null
460 *
461 * @throws InvalidArgumentException
462 */
463 public static function nullOrFloat(mixed $value, callable|string $message = ''): ?float
464 {
465 null === $value || static::float($value, $message);
466
467 return $value;
468 }
469
470 /**
471 * @psalm-pure
472 *
473 * @psalm-assert iterable<float> $value
474 *
475 * @param string|callable():string $message
476 *
477 * @return iterable<float>
478 *
479 * @throws InvalidArgumentException
480 */
481 public static function allFloat(mixed $value, callable|string $message = ''): iterable
482 {
483 static::isIterable($value);
484
485 foreach ($value as $entry) {
486 static::float($entry, $message);
487 }
488
489 return $value;
490 }
491
492 /**
493 * @psalm-pure
494 *
495 * @psalm-assert iterable<float|null> $value
496 *
497 * @param string|callable():string $message
498 *
499 * @return iterable<float|null>
500 *
501 * @throws InvalidArgumentException
502 */
503 public static function allNullOrFloat(mixed $value, callable|string $message = ''): iterable
504 {
505 static::isIterable($value);
506
507 foreach ($value as $entry) {
508 null === $entry || static::float($entry, $message);
509 }
510
511 return $value;
512 }
513
514 /**
515 * @psalm-pure
516 *
517 * @psalm-assert numeric|null $value
518 *
519 * @param string|callable():string $message
520 *
521 * @return numeric|null
522 *
523 * @throws InvalidArgumentException
524 */
525 public static function nullOrNumeric(mixed $value, callable|string $message = ''): string|int|float|null
526 {
527 null === $value || static::numeric($value, $message);
528
529 return $value;
530 }
531
532 /**
533 * @psalm-pure
534 *
535 * @psalm-assert iterable<numeric> $value
536 *
537 * @param string|callable():string $message
538 *
539 * @return iterable<numeric>
540 *
541 * @throws InvalidArgumentException
542 */
543 public static function allNumeric(mixed $value, callable|string $message = ''): iterable
544 {
545 static::isIterable($value);
546
547 foreach ($value as $entry) {
548 static::numeric($entry, $message);
549 }
550
551 return $value;
552 }
553
554 /**
555 * @psalm-pure
556 *
557 * @psalm-assert iterable<numeric|null> $value
558 *
559 * @param string|callable():string $message
560 *
561 * @return iterable<numeric|null>
562 *
563 * @throws InvalidArgumentException
564 */
565 public static function allNullOrNumeric(mixed $value, callable|string $message = ''): iterable
566 {
567 static::isIterable($value);
568
569 foreach ($value as $entry) {
570 null === $entry || static::numeric($entry, $message);
571 }
572
573 return $value;
574 }
575
576 /**
577 * @psalm-pure
578 *
579 * @psalm-assert positive-int|0|null $value
580 *
581 * @param string|callable():string $message
582 *
583 * @return positive-int|0|null
584 *
585 * @throws InvalidArgumentException
586 */
587 public static function nullOrNatural(mixed $value, callable|string $message = ''): ?int
588 {
589 null === $value || static::natural($value, $message);
590
591 return $value;
592 }
593
594 /**
595 * @psalm-pure
596 *
597 * @psalm-assert iterable<positive-int|0> $value
598 *
599 * @param string|callable():string $message
600 *
601 * @return iterable<positive-int|0>
602 *
603 * @throws InvalidArgumentException
604 */
605 public static function allNatural(mixed $value, callable|string $message = ''): iterable
606 {
607 static::isIterable($value);
608
609 foreach ($value as $entry) {
610 static::natural($entry, $message);
611 }
612
613 return $value;
614 }
615
616 /**
617 * @psalm-pure
618 *
619 * @psalm-assert iterable<positive-int|0|null> $value
620 *
621 * @param string|callable():string $message
622 *
623 * @return iterable<positive-int|0|null>
624 *
625 * @throws InvalidArgumentException
626 */
627 public static function allNullOrNatural(mixed $value, callable|string $message = ''): iterable
628 {
629 static::isIterable($value);
630
631 foreach ($value as $entry) {
632 null === $entry || static::natural($entry, $message);
633 }
634
635 return $value;
636 }
637
638 /**
639 * @psalm-pure
640 *
641 * @psalm-assert bool|null $value
642 *
643 * @param string|callable():string $message
644 *
645 * @return bool|null
646 *
647 * @throws InvalidArgumentException
648 */
649 public static function nullOrBoolean(mixed $value, callable|string $message = ''): ?bool
650 {
651 null === $value || static::boolean($value, $message);
652
653 return $value;
654 }
655
656 /**
657 * @psalm-pure
658 *
659 * @psalm-assert iterable<bool> $value
660 *
661 * @param string|callable():string $message
662 *
663 * @return iterable<bool>
664 *
665 * @throws InvalidArgumentException
666 */
667 public static function allBoolean(mixed $value, callable|string $message = ''): iterable
668 {
669 static::isIterable($value);
670
671 foreach ($value as $entry) {
672 static::boolean($entry, $message);
673 }
674
675 return $value;
676 }
677
678 /**
679 * @psalm-pure
680 *
681 * @psalm-assert iterable<bool|null> $value
682 *
683 * @param string|callable():string $message
684 *
685 * @return iterable<bool|null>
686 *
687 * @throws InvalidArgumentException
688 */
689 public static function allNullOrBoolean(mixed $value, callable|string $message = ''): iterable
690 {
691 static::isIterable($value);
692
693 foreach ($value as $entry) {
694 null === $entry || static::boolean($entry, $message);
695 }
696
697 return $value;
698 }
699
700 /**
701 * @psalm-pure
702 *
703 * @psalm-assert scalar|null $value
704 *
705 * @param string|callable():string $message
706 *
707 * @return scalar|null
708 *
709 * @throws InvalidArgumentException
710 */
711 public static function nullOrScalar(mixed $value, callable|string $message = ''): string|int|float|bool|null
712 {
713 null === $value || static::scalar($value, $message);
714
715 return $value;
716 }
717
718 /**
719 * @psalm-pure
720 *
721 * @psalm-assert iterable<scalar> $value
722 *
723 * @param string|callable():string $message
724 *
725 * @return iterable<scalar>
726 *
727 * @throws InvalidArgumentException
728 */
729 public static function allScalar(mixed $value, callable|string $message = ''): iterable
730 {
731 static::isIterable($value);
732
733 foreach ($value as $entry) {
734 static::scalar($entry, $message);
735 }
736
737 return $value;
738 }
739
740 /**
741 * @psalm-pure
742 *
743 * @psalm-assert iterable<scalar|null> $value
744 *
745 * @param string|callable():string $message
746 *
747 * @return iterable<scalar|null>
748 *
749 * @throws InvalidArgumentException
750 */
751 public static function allNullOrScalar(mixed $value, callable|string $message = ''): iterable
752 {
753 static::isIterable($value);
754
755 foreach ($value as $entry) {
756 null === $entry || static::scalar($entry, $message);
757 }
758
759 return $value;
760 }
761
762 /**
763 * @psalm-pure
764 *
765 * @psalm-assert object|null $value
766 *
767 * @param string|callable():string $message
768 *
769 * @return object|null
770 *
771 * @throws InvalidArgumentException
772 */
773 public static function nullOrObject(mixed $value, callable|string $message = ''): ?object
774 {
775 null === $value || static::object($value, $message);
776
777 return $value;
778 }
779
780 /**
781 * @psalm-pure
782 *
783 * @psalm-assert iterable<object> $value
784 *
785 * @param string|callable():string $message
786 *
787 * @return iterable<object>
788 *
789 * @throws InvalidArgumentException
790 */
791 public static function allObject(mixed $value, callable|string $message = ''): iterable
792 {
793 static::isIterable($value);
794
795 foreach ($value as $entry) {
796 static::object($entry, $message);
797 }
798
799 return $value;
800 }
801
802 /**
803 * @psalm-pure
804 *
805 * @psalm-assert iterable<object|null> $value
806 *
807 * @param string|callable():string $message
808 *
809 * @return iterable<object|null>
810 *
811 * @throws InvalidArgumentException
812 */
813 public static function allNullOrObject(mixed $value, callable|string $message = ''): iterable
814 {
815 static::isIterable($value);
816
817 foreach ($value as $entry) {
818 null === $entry || static::object($entry, $message);
819 }
820
821 return $value;
822 }
823
824 /**
825 * @psalm-pure
826 *
827 * @psalm-assert object|class-string|null $value
828 *
829 * @param string|callable():string $message
830 *
831 * @return object|class-string|null
832 *
833 * @throws InvalidArgumentException
834 */
835 public static function nullOrObjectish(mixed $value, callable|string $message = ''): object|string|null
836 {
837 null === $value || static::objectish($value, $message);
838
839 return $value;
840 }
841
842 /**
843 * @psalm-pure
844 *
845 * @psalm-assert iterable<object|class-string> $value
846 *
847 * @param string|callable():string $message
848 *
849 * @return iterable<object|class-string>
850 *
851 * @throws InvalidArgumentException
852 */
853 public static function allObjectish(mixed $value, callable|string $message = ''): iterable
854 {
855 static::isIterable($value);
856
857 foreach ($value as $entry) {
858 static::objectish($entry, $message);
859 }
860
861 return $value;
862 }
863
864 /**
865 * @psalm-pure
866 *
867 * @psalm-assert iterable<object|class-string|null> $value
868 *
869 * @param string|callable():string $message
870 *
871 * @return iterable<object|class-string|null>
872 *
873 * @throws InvalidArgumentException
874 */
875 public static function allNullOrObjectish(mixed $value, callable|string $message = ''): iterable
876 {
877 static::isIterable($value);
878
879 foreach ($value as $entry) {
880 null === $entry || static::objectish($entry, $message);
881 }
882
883 return $value;
884 }
885
886 /**
887 * @psalm-pure
888 *
889 * @psalm-assert resource|null $value
890 *
891 * @param string|callable():string $message
892 *
893 * @see https://www.php.net/manual/en/function.get-resource-type.php
894 *
895 * @return resource|null
896 *
897 * @throws InvalidArgumentException
898 */
899 public static function nullOrResource(mixed $value, ?string $type = null, callable|string $message = ''): mixed
900 {
901 null === $value || static::resource($value, $type, $message);
902
903 return $value;
904 }
905
906 /**
907 * @psalm-pure
908 *
909 * @psalm-assert iterable<resource> $value
910 *
911 * @param string|callable():string $message
912 *
913 * @see https://www.php.net/manual/en/function.get-resource-type.php
914 *
915 * @return iterable<resource>
916 *
917 * @throws InvalidArgumentException
918 */
919 public static function allResource(mixed $value, ?string $type = null, callable|string $message = ''): iterable
920 {
921 static::isIterable($value);
922
923 foreach ($value as $entry) {
924 static::resource($entry, $type, $message);
925 }
926
927 return $value;
928 }
929
930 /**
931 * @psalm-pure
932 *
933 * @psalm-assert iterable<resource|null> $value
934 *
935 * @param string|callable():string $message
936 *
937 * @see https://www.php.net/manual/en/function.get-resource-type.php
938 *
939 * @return iterable<resource|null>
940 *
941 * @throws InvalidArgumentException
942 */
943 public static function allNullOrResource(mixed $value, ?string $type = null, callable|string $message = ''): iterable
944 {
945 static::isIterable($value);
946
947 foreach ($value as $entry) {
948 null === $entry || static::resource($entry, $type, $message);
949 }
950
951 return $value;
952 }
953
954 /**
955 * @psalm-pure
956 *
957 * @psalm-assert callable|null $value
958 *
959 * @param string|callable():string $message
960 *
961 * @return callable|null
962 *
963 * @throws InvalidArgumentException
964 */
965 public static function nullOrIsCallable(mixed $value, callable|string $message = ''): ?callable
966 {
967 null === $value || static::isCallable($value, $message);
968
969 return $value;
970 }
971
972 /**
973 * @psalm-pure
974 *
975 * @psalm-assert iterable<callable> $value
976 *
977 * @param string|callable():string $message
978 *
979 * @return iterable<callable>
980 *
981 * @throws InvalidArgumentException
982 */
983 public static function allIsCallable(mixed $value, callable|string $message = ''): iterable
984 {
985 static::isIterable($value);
986
987 foreach ($value as $entry) {
988 static::isCallable($entry, $message);
989 }
990
991 return $value;
992 }
993
994 /**
995 * @psalm-pure
996 *
997 * @psalm-assert iterable<callable|null> $value
998 *
999 * @param string|callable():string $message
1000 *
1001 * @return iterable<callable|null>
1002 *
1003 * @throws InvalidArgumentException
1004 */
1005 public static function allNullOrIsCallable(mixed $value, callable|string $message = ''): iterable
1006 {
1007 static::isIterable($value);
1008
1009 foreach ($value as $entry) {
1010 null === $entry || static::isCallable($entry, $message);
1011 }
1012
1013 return $value;
1014 }
1015
1016 /**
1017 * @psalm-pure
1018 *
1019 * @psalm-assert array|null $value
1020 *
1021 * @param string|callable():string $message
1022 *
1023 * @return array|null
1024 *
1025 * @throws InvalidArgumentException
1026 */
1027 public static function nullOrIsArray(mixed $value, callable|string $message = ''): ?array
1028 {
1029 null === $value || static::isArray($value, $message);
1030
1031 return $value;
1032 }
1033
1034 /**
1035 * @psalm-pure
1036 *
1037 * @psalm-assert iterable<array> $value
1038 *
1039 * @param string|callable():string $message
1040 *
1041 * @return iterable<array>
1042 *
1043 * @throws InvalidArgumentException
1044 */
1045 public static function allIsArray(mixed $value, callable|string $message = ''): iterable
1046 {
1047 static::isIterable($value);
1048
1049 foreach ($value as $entry) {
1050 static::isArray($entry, $message);
1051 }
1052
1053 return $value;
1054 }
1055
1056 /**
1057 * @psalm-pure
1058 *
1059 * @psalm-assert iterable<array|null> $value
1060 *
1061 * @param string|callable():string $message
1062 *
1063 * @return iterable<array|null>
1064 *
1065 * @throws InvalidArgumentException
1066 */
1067 public static function allNullOrIsArray(mixed $value, callable|string $message = ''): iterable
1068 {
1069 static::isIterable($value);
1070
1071 foreach ($value as $entry) {
1072 null === $entry || static::isArray($entry, $message);
1073 }
1074
1075 return $value;
1076 }
1077
1078 /**
1079 * @psalm-pure
1080 *
1081 * @psalm-assert array|ArrayAccess|null $value
1082 *
1083 * @param string|callable():string $message
1084 *
1085 * @return array|ArrayAccess|null
1086 *
1087 * @throws InvalidArgumentException
1088 */
1089 public static function nullOrIsArrayAccessible(mixed $value, callable|string $message = ''): ArrayAccess|array|null
1090 {
1091 null === $value || static::isArrayAccessible($value, $message);
1092
1093 return $value;
1094 }
1095
1096 /**
1097 * @psalm-pure
1098 *
1099 * @psalm-assert iterable<array|ArrayAccess> $value
1100 *
1101 * @param string|callable():string $message
1102 *
1103 * @return iterable<array|ArrayAccess>
1104 *
1105 * @throws InvalidArgumentException
1106 */
1107 public static function allIsArrayAccessible(mixed $value, callable|string $message = ''): iterable
1108 {
1109 static::isIterable($value);
1110
1111 foreach ($value as $entry) {
1112 static::isArrayAccessible($entry, $message);
1113 }
1114
1115 return $value;
1116 }
1117
1118 /**
1119 * @psalm-pure
1120 *
1121 * @psalm-assert iterable<array|ArrayAccess|null> $value
1122 *
1123 * @param string|callable():string $message
1124 *
1125 * @return iterable<array|ArrayAccess|null>
1126 *
1127 * @throws InvalidArgumentException
1128 */
1129 public static function allNullOrIsArrayAccessible(mixed $value, callable|string $message = ''): iterable
1130 {
1131 static::isIterable($value);
1132
1133 foreach ($value as $entry) {
1134 null === $entry || static::isArrayAccessible($entry, $message);
1135 }
1136
1137 return $value;
1138 }
1139
1140 /**
1141 * @psalm-pure
1142 *
1143 * @psalm-assert countable|null $value
1144 *
1145 * @param string|callable():string $message
1146 *
1147 * @return countable|null
1148 *
1149 * @throws InvalidArgumentException
1150 */
1151 public static function nullOrIsCountable(mixed $value, callable|string $message = ''): Countable|array|null
1152 {
1153 null === $value || static::isCountable($value, $message);
1154
1155 return $value;
1156 }
1157
1158 /**
1159 * @psalm-pure
1160 *
1161 * @psalm-assert iterable<countable> $value
1162 *
1163 * @param string|callable():string $message
1164 *
1165 * @return iterable<countable>
1166 *
1167 * @throws InvalidArgumentException
1168 */
1169 public static function allIsCountable(mixed $value, callable|string $message = ''): iterable
1170 {
1171 static::isIterable($value);
1172
1173 foreach ($value as $entry) {
1174 static::isCountable($entry, $message);
1175 }
1176
1177 return $value;
1178 }
1179
1180 /**
1181 * @psalm-pure
1182 *
1183 * @psalm-assert iterable<countable|null> $value
1184 *
1185 * @param string|callable():string $message
1186 *
1187 * @return iterable<countable|null>
1188 *
1189 * @throws InvalidArgumentException
1190 */
1191 public static function allNullOrIsCountable(mixed $value, callable|string $message = ''): iterable
1192 {
1193 static::isIterable($value);
1194
1195 foreach ($value as $entry) {
1196 null === $entry || static::isCountable($entry, $message);
1197 }
1198
1199 return $value;
1200 }
1201
1202 /**
1203 * @psalm-pure
1204 *
1205 * @psalm-assert iterable|null $value
1206 *
1207 * @param string|callable():string $message
1208 *
1209 * @return iterable|null
1210 *
1211 * @throws InvalidArgumentException
1212 */
1213 public static function nullOrIsIterable(mixed $value, callable|string $message = ''): ?iterable
1214 {
1215 null === $value || static::isIterable($value, $message);
1216
1217 return $value;
1218 }
1219
1220 /**
1221 * @psalm-pure
1222 *
1223 * @psalm-assert iterable<iterable> $value
1224 *
1225 * @param string|callable():string $message
1226 *
1227 * @return iterable<iterable>
1228 *
1229 * @throws InvalidArgumentException
1230 */
1231 public static function allIsIterable(mixed $value, callable|string $message = ''): iterable
1232 {
1233 static::isIterable($value);
1234
1235 foreach ($value as $entry) {
1236 static::isIterable($entry, $message);
1237 }
1238
1239 return $value;
1240 }
1241
1242 /**
1243 * @psalm-pure
1244 *
1245 * @psalm-assert iterable<iterable|null> $value
1246 *
1247 * @param string|callable():string $message
1248 *
1249 * @return iterable<iterable|null>
1250 *
1251 * @throws InvalidArgumentException
1252 */
1253 public static function allNullOrIsIterable(mixed $value, callable|string $message = ''): iterable
1254 {
1255 static::isIterable($value);
1256
1257 foreach ($value as $entry) {
1258 null === $entry || static::isIterable($entry, $message);
1259 }
1260
1261 return $value;
1262 }
1263
1264 /**
1265 * @psalm-pure
1266 *
1267 * @template T of object
1268 * @psalm-assert T|null $value
1269 *
1270 * @param class-string<T> $class
1271 * @param string|callable():string $message
1272 *
1273 * @return T|null
1274 *
1275 * @throws InvalidArgumentException
1276 */
1277 public static function nullOrIsInstanceOf(mixed $value, mixed $class, callable|string $message = ''): ?object
1278 {
1279 null === $value || static::isInstanceOf($value, $class, $message);
1280
1281 return $value;
1282 }
1283
1284 /**
1285 * @psalm-pure
1286 *
1287 * @template T of object
1288 * @psalm-assert iterable<T> $value
1289 *
1290 * @param class-string<T> $class
1291 * @param string|callable():string $message
1292 *
1293 * @return iterable<T>
1294 *
1295 * @throws InvalidArgumentException
1296 */
1297 public static function allIsInstanceOf(mixed $value, mixed $class, callable|string $message = ''): iterable
1298 {
1299 static::isIterable($value);
1300
1301 foreach ($value as $entry) {
1302 static::isInstanceOf($entry, $class, $message);
1303 }
1304
1305 return $value;
1306 }
1307
1308 /**
1309 * @psalm-pure
1310 *
1311 * @template T of object|null
1312 * @psalm-assert iterable<T> $value
1313 *
1314 * @param class-string<T> $class
1315 * @param string|callable():string $message
1316 *
1317 * @return iterable<T>
1318 *
1319 * @throws InvalidArgumentException
1320 */
1321 public static function allNullOrIsInstanceOf(mixed $value, mixed $class, callable|string $message = ''): iterable
1322 {
1323 static::isIterable($value);
1324
1325 foreach ($value as $entry) {
1326 null === $entry || static::isInstanceOf($entry, $class, $message);
1327 }
1328
1329 return $value;
1330 }
1331
1332 /**
1333 * @template T of object
1334 *
1335 * @param class-string<T> $class
1336 * @param string|callable():string $message
1337 *
1338 * @return object|null
1339 *
1340 * @throws InvalidArgumentException
1341 */
1342 public static function nullOrNotInstanceOf(mixed $value, mixed $class, callable|string $message = ''): ?object
1343 {
1344 null === $value || static::notInstanceOf($value, $class, $message);
1345
1346 return $value;
1347 }
1348
1349 /**
1350 * @template T of object
1351 *
1352 * @param class-string<T> $class
1353 * @param string|callable():string $message
1354 *
1355 * @return iterable<object>
1356 *
1357 * @throws InvalidArgumentException
1358 */
1359 public static function allNotInstanceOf(mixed $value, mixed $class, callable|string $message = ''): iterable
1360 {
1361 static::isIterable($value);
1362
1363 foreach ($value as $entry) {
1364 static::notInstanceOf($entry, $class, $message);
1365 }
1366
1367 return $value;
1368 }
1369
1370 /**
1371 * @template T of object|null
1372 * @psalm-assert iterable<object|null> $value
1373 *
1374 * @param class-string<T> $class
1375 * @param string|callable():string $message
1376 *
1377 * @return iterable<object|null>
1378 *
1379 * @throws InvalidArgumentException
1380 */
1381 public static function allNullOrNotInstanceOf(mixed $value, mixed $class, callable|string $message = ''): iterable
1382 {
1383 static::isIterable($value);
1384
1385 foreach ($value as $entry) {
1386 null === $entry || static::notInstanceOf($entry, $class, $message);
1387 }
1388
1389 return $value;
1390 }
1391
1392 /**
1393 * @template T of object
1394 * @psalm-assert T|null $value
1395 *
1396 * @param iterable<class-string<T>> $classes
1397 * @param string|callable():string $message
1398 *
1399 * @return T|null
1400 *
1401 * @throws InvalidArgumentException
1402 */
1403 public static function nullOrIsInstanceOfAny(mixed $value, mixed $classes, callable|string $message = ''): ?object
1404 {
1405 null === $value || static::isInstanceOfAny($value, $classes, $message);
1406
1407 return $value;
1408 }
1409
1410 /**
1411 * @template T of object
1412 * @psalm-assert iterable<T> $value
1413 *
1414 * @param iterable<class-string<T>> $classes
1415 * @param string|callable():string $message
1416 *
1417 * @return iterable<T>
1418 *
1419 * @throws InvalidArgumentException
1420 */
1421 public static function allIsInstanceOfAny(mixed $value, mixed $classes, callable|string $message = ''): iterable
1422 {
1423 static::isIterable($value);
1424
1425 foreach ($value as $entry) {
1426 static::isInstanceOfAny($entry, $classes, $message);
1427 }
1428
1429 return $value;
1430 }
1431
1432 /**
1433 * @template T of object|null
1434 * @psalm-assert iterable<T> $value
1435 *
1436 * @param iterable<class-string<T>> $classes
1437 * @param string|callable():string $message
1438 *
1439 * @return iterable<T>
1440 *
1441 * @throws InvalidArgumentException
1442 */
1443 public static function allNullOrIsInstanceOfAny(mixed $value, mixed $classes, callable|string $message = ''): iterable
1444 {
1445 static::isIterable($value);
1446
1447 foreach ($value as $entry) {
1448 null === $entry || static::isInstanceOfAny($entry, $classes, $message);
1449 }
1450
1451 return $value;
1452 }
1453
1454 /**
1455 * @template T
1456 * @psalm-assert object|class-string|null $value
1457 *
1458 * @param T|null $value
1459 * @param string|callable():string $message
1460 *
1461 * @return T|null
1462 *
1463 * @throws InvalidArgumentException
1464 */
1465 public static function nullOrIsNotInstanceOfAny(mixed $value, mixed $classes, callable|string $message = ''): mixed
1466 {
1467 null === $value || static::isNotInstanceOfAny($value, $classes, $message);
1468
1469 return $value;
1470 }
1471
1472 /**
1473 * @template T
1474 * @psalm-assert iterable<object|class-string> $value
1475 *
1476 * @param iterable<T> $value
1477 * @param string|callable():string $message
1478 *
1479 * @return iterable<T>
1480 *
1481 * @throws InvalidArgumentException
1482 */
1483 public static function allIsNotInstanceOfAny(mixed $value, mixed $classes, callable|string $message = ''): iterable
1484 {
1485 static::isIterable($value);
1486
1487 foreach ($value as $entry) {
1488 static::isNotInstanceOfAny($entry, $classes, $message);
1489 }
1490
1491 return $value;
1492 }
1493
1494 /**
1495 * @template T
1496 * @psalm-assert iterable<object|class-string|null> $value
1497 *
1498 * @param iterable<T> $value
1499 * @param string|callable():string $message
1500 *
1501 * @return iterable<T>
1502 *
1503 * @throws InvalidArgumentException
1504 */
1505 public static function allNullOrIsNotInstanceOfAny(mixed $value, mixed $classes, callable|string $message = ''): iterable
1506 {
1507 static::isIterable($value);
1508
1509 foreach ($value as $entry) {
1510 null === $entry || static::isNotInstanceOfAny($entry, $classes, $message);
1511 }
1512
1513 return $value;
1514 }
1515
1516 /**
1517 * @psalm-pure
1518 *
1519 * @template T of object
1520 * @psalm-assert T|class-string<T>|null $value
1521 *
1522 * @param class-string<T> $class
1523 * @param string|callable():string $message
1524 *
1525 * @return T|class-string<T>|null
1526 *
1527 * @throws InvalidArgumentException
1528 */
1529 public static function nullOrIsAOf(mixed $value, mixed $class, callable|string $message = ''): object|string|null
1530 {
1531 null === $value || static::isAOf($value, $class, $message);
1532
1533 return $value;
1534 }
1535
1536 /**
1537 * @psalm-pure
1538 *
1539 * @template T of object
1540 * @psalm-assert iterable<T|class-string<T>> $value
1541 *
1542 * @param class-string<T> $class
1543 * @param string|callable():string $message
1544 *
1545 * @return iterable<T|class-string<T>>
1546 *
1547 * @throws InvalidArgumentException
1548 */
1549 public static function allIsAOf(mixed $value, mixed $class, callable|string $message = ''): iterable
1550 {
1551 static::isIterable($value);
1552
1553 foreach ($value as $entry) {
1554 static::isAOf($entry, $class, $message);
1555 }
1556
1557 return $value;
1558 }
1559
1560 /**
1561 * @psalm-pure
1562 *
1563 * @template T of object|null
1564 * @psalm-assert iterable<T|class-string<T>|null> $value
1565 *
1566 * @param class-string<T> $class
1567 * @param string|callable():string $message
1568 *
1569 * @return iterable<T|class-string<T>|null>
1570 *
1571 * @throws InvalidArgumentException
1572 */
1573 public static function allNullOrIsAOf(mixed $value, mixed $class, callable|string $message = ''): iterable
1574 {
1575 static::isIterable($value);
1576
1577 foreach ($value as $entry) {
1578 null === $entry || static::isAOf($entry, $class, $message);
1579 }
1580
1581 return $value;
1582 }
1583
1584 /**
1585 * @psalm-pure
1586 *
1587 * @template T
1588 *
1589 * @param T|null $value
1590 * @param string|callable():string $message
1591 *
1592 * @return object|class-string|null
1593 *
1594 * @throws InvalidArgumentException
1595 */
1596 public static function nullOrIsNotA(mixed $value, mixed $class, callable|string $message = ''): object|string|null
1597 {
1598 null === $value || static::isNotA($value, $class, $message);
1599
1600 return $value;
1601 }
1602
1603 /**
1604 * @psalm-pure
1605 *
1606 * @template T
1607 *
1608 * @param iterable<T> $value
1609 * @param string|callable():string $message
1610 *
1611 * @return iterable<object|class-string>
1612 *
1613 * @throws InvalidArgumentException
1614 */
1615 public static function allIsNotA(mixed $value, mixed $class, callable|string $message = ''): iterable
1616 {
1617 static::isIterable($value);
1618
1619 foreach ($value as $entry) {
1620 static::isNotA($entry, $class, $message);
1621 }
1622
1623 return $value;
1624 }
1625
1626 /**
1627 * @psalm-pure
1628 *
1629 * @template T
1630 * @psalm-assert iterable<object|class-string|null> $value
1631 *
1632 * @param iterable<T> $value
1633 * @param string|callable():string $message
1634 *
1635 * @return iterable<object|class-string|null>
1636 *
1637 * @throws InvalidArgumentException
1638 */
1639 public static function allNullOrIsNotA(mixed $value, mixed $class, callable|string $message = ''): iterable
1640 {
1641 static::isIterable($value);
1642
1643 foreach ($value as $entry) {
1644 null === $entry || static::isNotA($entry, $class, $message);
1645 }
1646
1647 return $value;
1648 }
1649
1650 /**
1651 * @psalm-pure
1652 *
1653 * @psalm-assert T|null $value
1654 *
1655 * @template T as object
1656 *
1657 * @param array<class-string<T>> $classes
1658 * @param string|callable():string $message
1659 *
1660 * @return T|null
1661 *
1662 * @throws InvalidArgumentException
1663 */
1664 public static function nullOrIsAnyOf(mixed $value, mixed $classes, callable|string $message = ''): object|string|null
1665 {
1666 null === $value || static::isAnyOf($value, $classes, $message);
1667
1668 return $value;
1669 }
1670
1671 /**
1672 * @psalm-pure
1673 *
1674 * @psalm-assert iterable<T> $value
1675 *
1676 * @template T as object
1677 *
1678 * @param array<class-string<T>> $classes
1679 * @param string|callable():string $message
1680 *
1681 * @return iterable<T>
1682 *
1683 * @throws InvalidArgumentException
1684 */
1685 public static function allIsAnyOf(mixed $value, mixed $classes, callable|string $message = ''): iterable
1686 {
1687 static::isIterable($value);
1688
1689 foreach ($value as $entry) {
1690 static::isAnyOf($entry, $classes, $message);
1691 }
1692
1693 return $value;
1694 }
1695
1696 /**
1697 * @psalm-pure
1698 *
1699 * @psalm-assert iterable<T> $value
1700 *
1701 * @template T as object|null
1702 *
1703 * @param array<class-string<T>> $classes
1704 * @param string|callable():string $message
1705 *
1706 * @return iterable<T>
1707 *
1708 * @throws InvalidArgumentException
1709 */
1710 public static function allNullOrIsAnyOf(mixed $value, mixed $classes, callable|string $message = ''): iterable
1711 {
1712 static::isIterable($value);
1713
1714 foreach ($value as $entry) {
1715 null === $entry || static::isAnyOf($entry, $classes, $message);
1716 }
1717
1718 return $value;
1719 }
1720
1721 /**
1722 * @psalm-pure
1723 *
1724 * @psalm-assert empty $value
1725 *
1726 * @param string|callable():string $message
1727 *
1728 * @return empty
1729 *
1730 * @throws InvalidArgumentException
1731 */
1732 public static function nullOrIsEmpty(mixed $value, callable|string $message = ''): mixed
1733 {
1734 null === $value || static::isEmpty($value, $message);
1735
1736 return $value;
1737 }
1738
1739 /**
1740 * @psalm-pure
1741 *
1742 * @psalm-assert iterable<empty> $value
1743 *
1744 * @param string|callable():string $message
1745 *
1746 * @return iterable<empty>
1747 *
1748 * @throws InvalidArgumentException
1749 */
1750 public static function allIsEmpty(mixed $value, callable|string $message = ''): iterable
1751 {
1752 static::isIterable($value);
1753
1754 foreach ($value as $entry) {
1755 static::isEmpty($entry, $message);
1756 }
1757
1758 return $value;
1759 }
1760
1761 /**
1762 * @psalm-pure
1763 *
1764 * @psalm-assert iterable<empty|null> $value
1765 *
1766 * @param string|callable():string $message
1767 *
1768 * @return iterable<empty|null>
1769 *
1770 * @throws InvalidArgumentException
1771 */
1772 public static function allNullOrIsEmpty(mixed $value, callable|string $message = ''): iterable
1773 {
1774 static::isIterable($value);
1775
1776 foreach ($value as $entry) {
1777 null === $entry || static::isEmpty($entry, $message);
1778 }
1779
1780 return $value;
1781 }
1782
1783 /**
1784 * @psalm-pure
1785 *
1786 * @param string|callable():string $message
1787 *
1788 * @return mixed
1789 *
1790 * @throws InvalidArgumentException
1791 */
1792 public static function nullOrNotEmpty(mixed $value, callable|string $message = ''): mixed
1793 {
1794 null === $value || static::notEmpty($value, $message);
1795
1796 return $value;
1797 }
1798
1799 /**
1800 * @psalm-pure
1801 *
1802 * @param string|callable():string $message
1803 *
1804 * @return iterable
1805 *
1806 * @throws InvalidArgumentException
1807 */
1808 public static function allNotEmpty(mixed $value, callable|string $message = ''): iterable
1809 {
1810 static::isIterable($value);
1811
1812 foreach ($value as $entry) {
1813 static::notEmpty($entry, $message);
1814 }
1815
1816 return $value;
1817 }
1818
1819 /**
1820 * @psalm-pure
1821 *
1822 * @psalm-assert iterable<!empty|null> $value
1823 *
1824 * @param string|callable():string $message
1825 *
1826 * @return iterable<!empty|null>
1827 *
1828 * @throws InvalidArgumentException
1829 */
1830 public static function allNullOrNotEmpty(mixed $value, callable|string $message = ''): iterable
1831 {
1832 static::isIterable($value);
1833
1834 foreach ($value as $entry) {
1835 null === $entry || static::notEmpty($entry, $message);
1836 }
1837
1838 return $value;
1839 }
1840
1841 /**
1842 * @psalm-pure
1843 *
1844 * @psalm-assert iterable<null> $value
1845 *
1846 * @param string|callable():string $message
1847 *
1848 * @return iterable<null>
1849 *
1850 * @throws InvalidArgumentException
1851 */
1852 public static function allNull(mixed $value, callable|string $message = ''): iterable
1853 {
1854 static::isIterable($value);
1855
1856 foreach ($value as $entry) {
1857 static::null($entry, $message);
1858 }
1859
1860 return $value;
1861 }
1862
1863 /**
1864 * @psalm-pure
1865 *
1866 * @template T
1867 *
1868 * @param iterable<T|null> $value
1869 * @param string|callable():string $message
1870 *
1871 * @return iterable<T>
1872 *
1873 * @throws InvalidArgumentException
1874 */
1875 public static function allNotNull(mixed $value, callable|string $message = ''): iterable
1876 {
1877 static::isIterable($value);
1878
1879 foreach ($value as $entry) {
1880 static::notNull($entry, $message);
1881 }
1882
1883 return $value;
1884 }
1885
1886 /**
1887 * @psalm-pure
1888 *
1889 * @psalm-assert true|null $value
1890 *
1891 * @param string|callable():string $message
1892 *
1893 * @return true|null
1894 *
1895 * @throws InvalidArgumentException
1896 */
1897 public static function nullOrTrue(mixed $value, callable|string $message = ''): ?true
1898 {
1899 null === $value || static::true($value, $message);
1900
1901 return $value;
1902 }
1903
1904 /**
1905 * @psalm-pure
1906 *
1907 * @psalm-assert iterable<true> $value
1908 *
1909 * @param string|callable():string $message
1910 *
1911 * @return iterable<true>
1912 *
1913 * @throws InvalidArgumentException
1914 */
1915 public static function allTrue(mixed $value, callable|string $message = ''): iterable
1916 {
1917 static::isIterable($value);
1918
1919 foreach ($value as $entry) {
1920 static::true($entry, $message);
1921 }
1922
1923 return $value;
1924 }
1925
1926 /**
1927 * @psalm-pure
1928 *
1929 * @psalm-assert iterable<true|null> $value
1930 *
1931 * @param string|callable():string $message
1932 *
1933 * @return iterable<true|null>
1934 *
1935 * @throws InvalidArgumentException
1936 */
1937 public static function allNullOrTrue(mixed $value, callable|string $message = ''): iterable
1938 {
1939 static::isIterable($value);
1940
1941 foreach ($value as $entry) {
1942 null === $entry || static::true($entry, $message);
1943 }
1944
1945 return $value;
1946 }
1947
1948 /**
1949 * @psalm-pure
1950 *
1951 * @psalm-assert false|null $value
1952 *
1953 * @param string|callable():string $message
1954 *
1955 * @return false|null
1956 *
1957 * @throws InvalidArgumentException
1958 */
1959 public static function nullOrFalse(mixed $value, callable|string $message = ''): ?false
1960 {
1961 null === $value || static::false($value, $message);
1962
1963 return $value;
1964 }
1965
1966 /**
1967 * @psalm-pure
1968 *
1969 * @psalm-assert iterable<false> $value
1970 *
1971 * @param string|callable():string $message
1972 *
1973 * @return iterable<false>
1974 *
1975 * @throws InvalidArgumentException
1976 */
1977 public static function allFalse(mixed $value, callable|string $message = ''): iterable
1978 {
1979 static::isIterable($value);
1980
1981 foreach ($value as $entry) {
1982 static::false($entry, $message);
1983 }
1984
1985 return $value;
1986 }
1987
1988 /**
1989 * @psalm-pure
1990 *
1991 * @psalm-assert iterable<false|null> $value
1992 *
1993 * @param string|callable():string $message
1994 *
1995 * @return iterable<false|null>
1996 *
1997 * @throws InvalidArgumentException
1998 */
1999 public static function allNullOrFalse(mixed $value, callable|string $message = ''): iterable
2000 {
2001 static::isIterable($value);
2002
2003 foreach ($value as $entry) {
2004 null === $entry || static::false($entry, $message);
2005 }
2006
2007 return $value;
2008 }
2009
2010 /**
2011 * @psalm-pure
2012 *
2013 * @template T
2014 *
2015 * @param T|false|null $value
2016 * @param string|callable():string $message
2017 *
2018 * @return T|null
2019 *
2020 * @throws InvalidArgumentException
2021 */
2022 public static function nullOrNotFalse(mixed $value, callable|string $message = ''): mixed
2023 {
2024 null === $value || static::notFalse($value, $message);
2025
2026 return $value;
2027 }
2028
2029 /**
2030 * @psalm-pure
2031 *
2032 * @template T
2033 *
2034 * @param iterable<T|false> $value
2035 * @param string|callable():string $message
2036 *
2037 * @return iterable<T>
2038 *
2039 * @throws InvalidArgumentException
2040 */
2041 public static function allNotFalse(mixed $value, callable|string $message = ''): iterable
2042 {
2043 static::isIterable($value);
2044
2045 foreach ($value as $entry) {
2046 static::notFalse($entry, $message);
2047 }
2048
2049 return $value;
2050 }
2051
2052 /**
2053 * @psalm-pure
2054 *
2055 * @psalm-assert iterable<!false|null> $value
2056 *
2057 * @template T
2058 *
2059 * @param iterable<T|false|null> $value
2060 * @param string|callable():string $message
2061 *
2062 * @return iterable<T>
2063 *
2064 * @throws InvalidArgumentException
2065 */
2066 public static function allNullOrNotFalse(mixed $value, callable|string $message = ''): iterable
2067 {
2068 static::isIterable($value);
2069
2070 foreach ($value as $entry) {
2071 null === $entry || static::notFalse($entry, $message);
2072 }
2073
2074 return $value;
2075 }
2076
2077 /**
2078 * @psalm-pure
2079 *
2080 * @param string|null $value
2081 * @param string|callable():string $message
2082 *
2083 * @return string|null
2084 *
2085 * @throws InvalidArgumentException
2086 */
2087 public static function nullOrIp(mixed $value, callable|string $message = ''): ?string
2088 {
2089 null === $value || static::ip($value, $message);
2090
2091 return $value;
2092 }
2093
2094 /**
2095 * @psalm-pure
2096 *
2097 * @param iterable<string> $value
2098 * @param string|callable():string $message
2099 *
2100 * @return iterable<string>
2101 *
2102 * @throws InvalidArgumentException
2103 */
2104 public static function allIp(mixed $value, callable|string $message = ''): iterable
2105 {
2106 static::isIterable($value);
2107
2108 foreach ($value as $entry) {
2109 static::ip($entry, $message);
2110 }
2111
2112 return $value;
2113 }
2114
2115 /**
2116 * @psalm-pure
2117 *
2118 * @param iterable<string|null> $value
2119 * @param string|callable():string $message
2120 *
2121 * @return iterable<string|null>
2122 *
2123 * @throws InvalidArgumentException
2124 */
2125 public static function allNullOrIp(mixed $value, callable|string $message = ''): iterable
2126 {
2127 static::isIterable($value);
2128
2129 foreach ($value as $entry) {
2130 null === $entry || static::ip($entry, $message);
2131 }
2132
2133 return $value;
2134 }
2135
2136 /**
2137 * @psalm-pure
2138 *
2139 * @param string|null $value
2140 * @param string|callable():string $message
2141 *
2142 * @return string|null
2143 *
2144 * @throws InvalidArgumentException
2145 */
2146 public static function nullOrIpv4(mixed $value, callable|string $message = ''): ?string
2147 {
2148 null === $value || static::ipv4($value, $message);
2149
2150 return $value;
2151 }
2152
2153 /**
2154 * @psalm-pure
2155 *
2156 * @param iterable<string> $value
2157 * @param string|callable():string $message
2158 *
2159 * @return iterable<string>
2160 *
2161 * @throws InvalidArgumentException
2162 */
2163 public static function allIpv4(mixed $value, callable|string $message = ''): iterable
2164 {
2165 static::isIterable($value);
2166
2167 foreach ($value as $entry) {
2168 static::ipv4($entry, $message);
2169 }
2170
2171 return $value;
2172 }
2173
2174 /**
2175 * @psalm-pure
2176 *
2177 * @param iterable<string|null> $value
2178 * @param string|callable():string $message
2179 *
2180 * @return iterable<string|null>
2181 *
2182 * @throws InvalidArgumentException
2183 */
2184 public static function allNullOrIpv4(mixed $value, callable|string $message = ''): iterable
2185 {
2186 static::isIterable($value);
2187
2188 foreach ($value as $entry) {
2189 null === $entry || static::ipv4($entry, $message);
2190 }
2191
2192 return $value;
2193 }
2194
2195 /**
2196 * @psalm-pure
2197 *
2198 * @param string|null $value
2199 * @param string|callable():string $message
2200 *
2201 * @return string|null
2202 *
2203 * @throws InvalidArgumentException
2204 */
2205 public static function nullOrIpv6(mixed $value, callable|string $message = ''): ?string
2206 {
2207 null === $value || static::ipv6($value, $message);
2208
2209 return $value;
2210 }
2211
2212 /**
2213 * @psalm-pure
2214 *
2215 * @param iterable<string> $value
2216 * @param string|callable():string $message
2217 *
2218 * @return iterable<string>
2219 *
2220 * @throws InvalidArgumentException
2221 */
2222 public static function allIpv6(mixed $value, callable|string $message = ''): iterable
2223 {
2224 static::isIterable($value);
2225
2226 foreach ($value as $entry) {
2227 static::ipv6($entry, $message);
2228 }
2229
2230 return $value;
2231 }
2232
2233 /**
2234 * @psalm-pure
2235 *
2236 * @param iterable<string|null> $value
2237 * @param string|callable():string $message
2238 *
2239 * @return iterable<string|null>
2240 *
2241 * @throws InvalidArgumentException
2242 */
2243 public static function allNullOrIpv6(mixed $value, callable|string $message = ''): iterable
2244 {
2245 static::isIterable($value);
2246
2247 foreach ($value as $entry) {
2248 null === $entry || static::ipv6($entry, $message);
2249 }
2250
2251 return $value;
2252 }
2253
2254 /**
2255 * @psalm-pure
2256 *
2257 * @param string|null $value
2258 * @param string|callable():string $message
2259 *
2260 * @return string|null
2261 *
2262 * @throws InvalidArgumentException
2263 */
2264 public static function nullOrEmail(mixed $value, callable|string $message = ''): ?string
2265 {
2266 null === $value || static::email($value, $message);
2267
2268 return $value;
2269 }
2270
2271 /**
2272 * @psalm-pure
2273 *
2274 * @param iterable<string> $value
2275 * @param string|callable():string $message
2276 *
2277 * @return iterable<string>
2278 *
2279 * @throws InvalidArgumentException
2280 */
2281 public static function allEmail(mixed $value, callable|string $message = ''): iterable
2282 {
2283 static::isIterable($value);
2284
2285 foreach ($value as $entry) {
2286 static::email($entry, $message);
2287 }
2288
2289 return $value;
2290 }
2291
2292 /**
2293 * @psalm-pure
2294 *
2295 * @param iterable<string|null> $value
2296 * @param string|callable():string $message
2297 *
2298 * @return iterable<string|null>
2299 *
2300 * @throws InvalidArgumentException
2301 */
2302 public static function allNullOrEmail(mixed $value, callable|string $message = ''): iterable
2303 {
2304 static::isIterable($value);
2305
2306 foreach ($value as $entry) {
2307 null === $entry || static::email($entry, $message);
2308 }
2309
2310 return $value;
2311 }
2312
2313 /**
2314 * @psalm-assert array|null $values
2315 *
2316 * @param string|callable():string $message
2317 *
2318 * @return array|null
2319 *
2320 * @throws InvalidArgumentException
2321 */
2322 public static function nullOrUniqueValues(mixed $values, callable|string $message = ''): ?array
2323 {
2324 null === $values || static::uniqueValues($values, $message);
2325
2326 return $values;
2327 }
2328
2329 /**
2330 * @psalm-assert iterable<array> $values
2331 *
2332 * @param string|callable():string $message
2333 *
2334 * @return iterable<array>
2335 *
2336 * @throws InvalidArgumentException
2337 */
2338 public static function allUniqueValues(mixed $values, callable|string $message = ''): iterable
2339 {
2340 static::isIterable($values);
2341
2342 foreach ($values as $entry) {
2343 static::uniqueValues($entry, $message);
2344 }
2345
2346 return $values;
2347 }
2348
2349 /**
2350 * @psalm-assert iterable<array|null> $values
2351 *
2352 * @param string|callable():string $message
2353 *
2354 * @return iterable<array|null>
2355 *
2356 * @throws InvalidArgumentException
2357 */
2358 public static function allNullOrUniqueValues(mixed $values, callable|string $message = ''): iterable
2359 {
2360 static::isIterable($values);
2361
2362 foreach ($values as $entry) {
2363 null === $entry || static::uniqueValues($entry, $message);
2364 }
2365
2366 return $values;
2367 }
2368
2369 /**
2370 * @param string|callable():string $message
2371 *
2372 * @return mixed
2373 *
2374 * @throws InvalidArgumentException
2375 */
2376 public static function nullOrEq(mixed $value, mixed $expect, callable|string $message = ''): mixed
2377 {
2378 null === $value || static::eq($value, $expect, $message);
2379
2380 return $value;
2381 }
2382
2383 /**
2384 * @param string|callable():string $message
2385 *
2386 * @return iterable
2387 *
2388 * @throws InvalidArgumentException
2389 */
2390 public static function allEq(mixed $value, mixed $expect, callable|string $message = ''): iterable
2391 {
2392 static::isIterable($value);
2393
2394 foreach ($value as $entry) {
2395 static::eq($entry, $expect, $message);
2396 }
2397
2398 return $value;
2399 }
2400
2401 /**
2402 * @param string|callable():string $message
2403 *
2404 * @return iterable
2405 *
2406 * @throws InvalidArgumentException
2407 */
2408 public static function allNullOrEq(mixed $value, mixed $expect, callable|string $message = ''): iterable
2409 {
2410 static::isIterable($value);
2411
2412 foreach ($value as $entry) {
2413 null === $entry || static::eq($entry, $expect, $message);
2414 }
2415
2416 return $value;
2417 }
2418
2419 /**
2420 * @param string|callable():string $message
2421 *
2422 * @return mixed
2423 *
2424 * @throws InvalidArgumentException
2425 */
2426 public static function nullOrNotEq(mixed $value, mixed $expect, callable|string $message = ''): mixed
2427 {
2428 null === $value || static::notEq($value, $expect, $message);
2429
2430 return $value;
2431 }
2432
2433 /**
2434 * @param string|callable():string $message
2435 *
2436 * @return iterable
2437 *
2438 * @throws InvalidArgumentException
2439 */
2440 public static function allNotEq(mixed $value, mixed $expect, callable|string $message = ''): iterable
2441 {
2442 static::isIterable($value);
2443
2444 foreach ($value as $entry) {
2445 static::notEq($entry, $expect, $message);
2446 }
2447
2448 return $value;
2449 }
2450
2451 /**
2452 * @param string|callable():string $message
2453 *
2454 * @return iterable
2455 *
2456 * @throws InvalidArgumentException
2457 */
2458 public static function allNullOrNotEq(mixed $value, mixed $expect, callable|string $message = ''): iterable
2459 {
2460 static::isIterable($value);
2461
2462 foreach ($value as $entry) {
2463 null === $entry || static::notEq($entry, $expect, $message);
2464 }
2465
2466 return $value;
2467 }
2468
2469 /**
2470 * @psalm-pure
2471 *
2472 * @param string|callable():string $message
2473 *
2474 * @return mixed
2475 *
2476 * @throws InvalidArgumentException
2477 */
2478 public static function nullOrSame(mixed $value, mixed $expect, callable|string $message = ''): mixed
2479 {
2480 null === $value || static::same($value, $expect, $message);
2481
2482 return $value;
2483 }
2484
2485 /**
2486 * @psalm-pure
2487 *
2488 * @param string|callable():string $message
2489 *
2490 * @return iterable
2491 *
2492 * @throws InvalidArgumentException
2493 */
2494 public static function allSame(mixed $value, mixed $expect, callable|string $message = ''): iterable
2495 {
2496 static::isIterable($value);
2497
2498 foreach ($value as $entry) {
2499 static::same($entry, $expect, $message);
2500 }
2501
2502 return $value;
2503 }
2504
2505 /**
2506 * @psalm-pure
2507 *
2508 * @param string|callable():string $message
2509 *
2510 * @return iterable
2511 *
2512 * @throws InvalidArgumentException
2513 */
2514 public static function allNullOrSame(mixed $value, mixed $expect, callable|string $message = ''): iterable
2515 {
2516 static::isIterable($value);
2517
2518 foreach ($value as $entry) {
2519 null === $entry || static::same($entry, $expect, $message);
2520 }
2521
2522 return $value;
2523 }
2524
2525 /**
2526 * @psalm-pure
2527 *
2528 * @param string|callable():string $message
2529 *
2530 * @return mixed
2531 *
2532 * @throws InvalidArgumentException
2533 */
2534 public static function nullOrNotSame(mixed $value, mixed $expect, callable|string $message = ''): mixed
2535 {
2536 null === $value || static::notSame($value, $expect, $message);
2537
2538 return $value;
2539 }
2540
2541 /**
2542 * @psalm-pure
2543 *
2544 * @param string|callable():string $message
2545 *
2546 * @return iterable
2547 *
2548 * @throws InvalidArgumentException
2549 */
2550 public static function allNotSame(mixed $value, mixed $expect, callable|string $message = ''): iterable
2551 {
2552 static::isIterable($value);
2553
2554 foreach ($value as $entry) {
2555 static::notSame($entry, $expect, $message);
2556 }
2557
2558 return $value;
2559 }
2560
2561 /**
2562 * @psalm-pure
2563 *
2564 * @param string|callable():string $message
2565 *
2566 * @return iterable
2567 *
2568 * @throws InvalidArgumentException
2569 */
2570 public static function allNullOrNotSame(mixed $value, mixed $expect, callable|string $message = ''): iterable
2571 {
2572 static::isIterable($value);
2573
2574 foreach ($value as $entry) {
2575 null === $entry || static::notSame($entry, $expect, $message);
2576 }
2577
2578 return $value;
2579 }
2580
2581 /**
2582 * @psalm-pure
2583 *
2584 * @param string|callable():string $message
2585 *
2586 * @return mixed
2587 *
2588 * @throws InvalidArgumentException
2589 */
2590 public static function nullOrGreaterThan(mixed $value, mixed $limit, callable|string $message = ''): mixed
2591 {
2592 null === $value || static::greaterThan($value, $limit, $message);
2593
2594 return $value;
2595 }
2596
2597 /**
2598 * @psalm-pure
2599 *
2600 * @param string|callable():string $message
2601 *
2602 * @return iterable
2603 *
2604 * @throws InvalidArgumentException
2605 */
2606 public static function allGreaterThan(mixed $value, mixed $limit, callable|string $message = ''): iterable
2607 {
2608 static::isIterable($value);
2609
2610 foreach ($value as $entry) {
2611 static::greaterThan($entry, $limit, $message);
2612 }
2613
2614 return $value;
2615 }
2616
2617 /**
2618 * @psalm-pure
2619 *
2620 * @param string|callable():string $message
2621 *
2622 * @return iterable
2623 *
2624 * @throws InvalidArgumentException
2625 */
2626 public static function allNullOrGreaterThan(mixed $value, mixed $limit, callable|string $message = ''): iterable
2627 {
2628 static::isIterable($value);
2629
2630 foreach ($value as $entry) {
2631 null === $entry || static::greaterThan($entry, $limit, $message);
2632 }
2633
2634 return $value;
2635 }
2636
2637 /**
2638 * @psalm-pure
2639 *
2640 * @param string|callable():string $message
2641 *
2642 * @return mixed
2643 *
2644 * @throws InvalidArgumentException
2645 */
2646 public static function nullOrGreaterThanEq(mixed $value, mixed $limit, callable|string $message = ''): mixed
2647 {
2648 null === $value || static::greaterThanEq($value, $limit, $message);
2649
2650 return $value;
2651 }
2652
2653 /**
2654 * @psalm-pure
2655 *
2656 * @param string|callable():string $message
2657 *
2658 * @return iterable
2659 *
2660 * @throws InvalidArgumentException
2661 */
2662 public static function allGreaterThanEq(mixed $value, mixed $limit, callable|string $message = ''): iterable
2663 {
2664 static::isIterable($value);
2665
2666 foreach ($value as $entry) {
2667 static::greaterThanEq($entry, $limit, $message);
2668 }
2669
2670 return $value;
2671 }
2672
2673 /**
2674 * @psalm-pure
2675 *
2676 * @param string|callable():string $message
2677 *
2678 * @return iterable
2679 *
2680 * @throws InvalidArgumentException
2681 */
2682 public static function allNullOrGreaterThanEq(mixed $value, mixed $limit, callable|string $message = ''): iterable
2683 {
2684 static::isIterable($value);
2685
2686 foreach ($value as $entry) {
2687 null === $entry || static::greaterThanEq($entry, $limit, $message);
2688 }
2689
2690 return $value;
2691 }
2692
2693 /**
2694 * @psalm-pure
2695 *
2696 * @param string|callable():string $message
2697 *
2698 * @return mixed
2699 *
2700 * @throws InvalidArgumentException
2701 */
2702 public static function nullOrLessThan(mixed $value, mixed $limit, callable|string $message = ''): mixed
2703 {
2704 null === $value || static::lessThan($value, $limit, $message);
2705
2706 return $value;
2707 }
2708
2709 /**
2710 * @psalm-pure
2711 *
2712 * @param string|callable():string $message
2713 *
2714 * @return iterable
2715 *
2716 * @throws InvalidArgumentException
2717 */
2718 public static function allLessThan(mixed $value, mixed $limit, callable|string $message = ''): iterable
2719 {
2720 static::isIterable($value);
2721
2722 foreach ($value as $entry) {
2723 static::lessThan($entry, $limit, $message);
2724 }
2725
2726 return $value;
2727 }
2728
2729 /**
2730 * @psalm-pure
2731 *
2732 * @param string|callable():string $message
2733 *
2734 * @return iterable
2735 *
2736 * @throws InvalidArgumentException
2737 */
2738 public static function allNullOrLessThan(mixed $value, mixed $limit, callable|string $message = ''): iterable
2739 {
2740 static::isIterable($value);
2741
2742 foreach ($value as $entry) {
2743 null === $entry || static::lessThan($entry, $limit, $message);
2744 }
2745
2746 return $value;
2747 }
2748
2749 /**
2750 * @psalm-pure
2751 *
2752 * @param string|callable():string $message
2753 *
2754 * @return mixed
2755 *
2756 * @throws InvalidArgumentException
2757 */
2758 public static function nullOrLessThanEq(mixed $value, mixed $limit, callable|string $message = ''): mixed
2759 {
2760 null === $value || static::lessThanEq($value, $limit, $message);
2761
2762 return $value;
2763 }
2764
2765 /**
2766 * @psalm-pure
2767 *
2768 * @param string|callable():string $message
2769 *
2770 * @return iterable
2771 *
2772 * @throws InvalidArgumentException
2773 */
2774 public static function allLessThanEq(mixed $value, mixed $limit, callable|string $message = ''): iterable
2775 {
2776 static::isIterable($value);
2777
2778 foreach ($value as $entry) {
2779 static::lessThanEq($entry, $limit, $message);
2780 }
2781
2782 return $value;
2783 }
2784
2785 /**
2786 * @psalm-pure
2787 *
2788 * @param string|callable():string $message
2789 *
2790 * @return iterable
2791 *
2792 * @throws InvalidArgumentException
2793 */
2794 public static function allNullOrLessThanEq(mixed $value, mixed $limit, callable|string $message = ''): iterable
2795 {
2796 static::isIterable($value);
2797
2798 foreach ($value as $entry) {
2799 null === $entry || static::lessThanEq($entry, $limit, $message);
2800 }
2801
2802 return $value;
2803 }
2804
2805 /**
2806 * @psalm-pure
2807 *
2808 * @param string|callable():string $message
2809 *
2810 * @return mixed
2811 *
2812 * @throws InvalidArgumentException
2813 */
2814 public static function nullOrRange(mixed $value, mixed $min, mixed $max, callable|string $message = ''): mixed
2815 {
2816 null === $value || static::range($value, $min, $max, $message);
2817
2818 return $value;
2819 }
2820
2821 /**
2822 * @psalm-pure
2823 *
2824 * @param string|callable():string $message
2825 *
2826 * @return iterable
2827 *
2828 * @throws InvalidArgumentException
2829 */
2830 public static function allRange(mixed $value, mixed $min, mixed $max, callable|string $message = ''): iterable
2831 {
2832 static::isIterable($value);
2833
2834 foreach ($value as $entry) {
2835 static::range($entry, $min, $max, $message);
2836 }
2837
2838 return $value;
2839 }
2840
2841 /**
2842 * @psalm-pure
2843 *
2844 * @param string|callable():string $message
2845 *
2846 * @return iterable
2847 *
2848 * @throws InvalidArgumentException
2849 */
2850 public static function allNullOrRange(mixed $value, mixed $min, mixed $max, callable|string $message = ''): iterable
2851 {
2852 static::isIterable($value);
2853
2854 foreach ($value as $entry) {
2855 null === $entry || static::range($entry, $min, $max, $message);
2856 }
2857
2858 return $value;
2859 }
2860
2861 /**
2862 * @psalm-pure
2863 *
2864 * @param string|callable():string $message
2865 *
2866 * @return mixed
2867 *
2868 * @throws InvalidArgumentException
2869 */
2870 public static function nullOrOneOf(mixed $value, mixed $values, callable|string $message = ''): mixed
2871 {
2872 null === $value || static::oneOf($value, $values, $message);
2873
2874 return $value;
2875 }
2876
2877 /**
2878 * @psalm-pure
2879 *
2880 * @param string|callable():string $message
2881 *
2882 * @return iterable
2883 *
2884 * @throws InvalidArgumentException
2885 */
2886 public static function allOneOf(mixed $value, mixed $values, callable|string $message = ''): iterable
2887 {
2888 static::isIterable($value);
2889
2890 foreach ($value as $entry) {
2891 static::oneOf($entry, $values, $message);
2892 }
2893
2894 return $value;
2895 }
2896
2897 /**
2898 * @psalm-pure
2899 *
2900 * @param string|callable():string $message
2901 *
2902 * @return iterable
2903 *
2904 * @throws InvalidArgumentException
2905 */
2906 public static function allNullOrOneOf(mixed $value, mixed $values, callable|string $message = ''): iterable
2907 {
2908 static::isIterable($value);
2909
2910 foreach ($value as $entry) {
2911 null === $entry || static::oneOf($entry, $values, $message);
2912 }
2913
2914 return $value;
2915 }
2916
2917 /**
2918 * @psalm-pure
2919 *
2920 * @param string|callable():string $message
2921 *
2922 * @return mixed
2923 *
2924 * @throws InvalidArgumentException
2925 */
2926 public static function nullOrInArray(mixed $value, mixed $values, callable|string $message = ''): mixed
2927 {
2928 null === $value || static::inArray($value, $values, $message);
2929
2930 return $value;
2931 }
2932
2933 /**
2934 * @psalm-pure
2935 *
2936 * @param string|callable():string $message
2937 *
2938 * @return iterable
2939 *
2940 * @throws InvalidArgumentException
2941 */
2942 public static function allInArray(mixed $value, mixed $values, callable|string $message = ''): iterable
2943 {
2944 static::isIterable($value);
2945
2946 foreach ($value as $entry) {
2947 static::inArray($entry, $values, $message);
2948 }
2949
2950 return $value;
2951 }
2952
2953 /**
2954 * @psalm-pure
2955 *
2956 * @param string|callable():string $message
2957 *
2958 * @return iterable
2959 *
2960 * @throws InvalidArgumentException
2961 */
2962 public static function allNullOrInArray(mixed $value, mixed $values, callable|string $message = ''): iterable
2963 {
2964 static::isIterable($value);
2965
2966 foreach ($value as $entry) {
2967 null === $entry || static::inArray($entry, $values, $message);
2968 }
2969
2970 return $value;
2971 }
2972
2973 /**
2974 * @psalm-pure
2975 *
2976 * @param string|callable():string $message
2977 *
2978 * @return mixed
2979 *
2980 * @throws InvalidArgumentException
2981 */
2982 public static function nullOrNotOneOf(mixed $value, mixed $values, callable|string $message = ''): mixed
2983 {
2984 null === $value || static::notOneOf($value, $values, $message);
2985
2986 return $value;
2987 }
2988
2989 /**
2990 * @psalm-pure
2991 *
2992 * @param string|callable():string $message
2993 *
2994 * @return iterable
2995 *
2996 * @throws InvalidArgumentException
2997 */
2998 public static function allNotOneOf(mixed $value, mixed $values, callable|string $message = ''): iterable
2999 {
3000 static::isIterable($value);
3001
3002 foreach ($value as $entry) {
3003 static::notOneOf($entry, $values, $message);
3004 }
3005
3006 return $value;
3007 }
3008
3009 /**
3010 * @psalm-pure
3011 *
3012 * @param string|callable():string $message
3013 *
3014 * @return iterable
3015 *
3016 * @throws InvalidArgumentException
3017 */
3018 public static function allNullOrNotOneOf(mixed $value, mixed $values, callable|string $message = ''): iterable
3019 {
3020 static::isIterable($value);
3021
3022 foreach ($value as $entry) {
3023 null === $entry || static::notOneOf($entry, $values, $message);
3024 }
3025
3026 return $value;
3027 }
3028
3029 /**
3030 * @psalm-pure
3031 *
3032 * @param string|callable():string $message
3033 *
3034 * @return mixed
3035 *
3036 * @throws InvalidArgumentException
3037 */
3038 public static function nullOrNotInArray(mixed $value, mixed $values, callable|string $message = ''): mixed
3039 {
3040 null === $value || static::notInArray($value, $values, $message);
3041
3042 return $value;
3043 }
3044
3045 /**
3046 * @psalm-pure
3047 *
3048 * @param string|callable():string $message
3049 *
3050 * @return iterable
3051 *
3052 * @throws InvalidArgumentException
3053 */
3054 public static function allNotInArray(mixed $value, mixed $values, callable|string $message = ''): iterable
3055 {
3056 static::isIterable($value);
3057
3058 foreach ($value as $entry) {
3059 static::notInArray($entry, $values, $message);
3060 }
3061
3062 return $value;
3063 }
3064
3065 /**
3066 * @psalm-pure
3067 *
3068 * @param string|callable():string $message
3069 *
3070 * @return iterable
3071 *
3072 * @throws InvalidArgumentException
3073 */
3074 public static function allNullOrNotInArray(mixed $value, mixed $values, callable|string $message = ''): iterable
3075 {
3076 static::isIterable($value);
3077
3078 foreach ($value as $entry) {
3079 null === $entry || static::notInArray($entry, $values, $message);
3080 }
3081
3082 return $value;
3083 }
3084
3085 /**
3086 * @psalm-pure
3087 *
3088 * @param string|callable():string $message
3089 *
3090 * @return string|null
3091 *
3092 * @throws InvalidArgumentException
3093 */
3094 public static function nullOrContains(mixed $value, mixed $subString, callable|string $message = ''): ?string
3095 {
3096 null === $value || static::contains($value, $subString, $message);
3097
3098 return $value;
3099 }
3100
3101 /**
3102 * @psalm-pure
3103 *
3104 * @param string|callable():string $message
3105 *
3106 * @return iterable<string>
3107 *
3108 * @throws InvalidArgumentException
3109 */
3110 public static function allContains(mixed $value, mixed $subString, callable|string $message = ''): iterable
3111 {
3112 static::isIterable($value);
3113
3114 foreach ($value as $entry) {
3115 static::contains($entry, $subString, $message);
3116 }
3117
3118 return $value;
3119 }
3120
3121 /**
3122 * @psalm-pure
3123 *
3124 * @param string|callable():string $message
3125 *
3126 * @return iterable<string|null>
3127 *
3128 * @throws InvalidArgumentException
3129 */
3130 public static function allNullOrContains(mixed $value, mixed $subString, callable|string $message = ''): iterable
3131 {
3132 static::isIterable($value);
3133
3134 foreach ($value as $entry) {
3135 null === $entry || static::contains($entry, $subString, $message);
3136 }
3137
3138 return $value;
3139 }
3140
3141 /**
3142 * @psalm-pure
3143 *
3144 * @param string|callable():string $message
3145 *
3146 * @return string|null
3147 *
3148 * @throws InvalidArgumentException
3149 */
3150 public static function nullOrNotContains(mixed $value, mixed $subString, callable|string $message = ''): ?string
3151 {
3152 null === $value || static::notContains($value, $subString, $message);
3153
3154 return $value;
3155 }
3156
3157 /**
3158 * @psalm-pure
3159 *
3160 * @param string|callable():string $message
3161 *
3162 * @return iterable<string>
3163 *
3164 * @throws InvalidArgumentException
3165 */
3166 public static function allNotContains(mixed $value, mixed $subString, callable|string $message = ''): iterable
3167 {
3168 static::isIterable($value);
3169
3170 foreach ($value as $entry) {
3171 static::notContains($entry, $subString, $message);
3172 }
3173
3174 return $value;
3175 }
3176
3177 /**
3178 * @psalm-pure
3179 *
3180 * @param string|callable():string $message
3181 *
3182 * @return iterable<string|null>
3183 *
3184 * @throws InvalidArgumentException
3185 */
3186 public static function allNullOrNotContains(mixed $value, mixed $subString, callable|string $message = ''): iterable
3187 {
3188 static::isIterable($value);
3189
3190 foreach ($value as $entry) {
3191 null === $entry || static::notContains($entry, $subString, $message);
3192 }
3193
3194 return $value;
3195 }
3196
3197 /**
3198 * @psalm-pure
3199 *
3200 * @param string|callable():string $message
3201 *
3202 * @return string|null
3203 *
3204 * @throws InvalidArgumentException
3205 */
3206 public static function nullOrNotWhitespaceOnly(mixed $value, callable|string $message = ''): ?string
3207 {
3208 null === $value || static::notWhitespaceOnly($value, $message);
3209
3210 return $value;
3211 }
3212
3213 /**
3214 * @psalm-pure
3215 *
3216 * @param string|callable():string $message
3217 *
3218 * @return iterable<string>
3219 *
3220 * @throws InvalidArgumentException
3221 */
3222 public static function allNotWhitespaceOnly(mixed $value, callable|string $message = ''): iterable
3223 {
3224 static::isIterable($value);
3225
3226 foreach ($value as $entry) {
3227 static::notWhitespaceOnly($entry, $message);
3228 }
3229
3230 return $value;
3231 }
3232
3233 /**
3234 * @psalm-pure
3235 *
3236 * @param string|callable():string $message
3237 *
3238 * @return iterable<string|null>
3239 *
3240 * @throws InvalidArgumentException
3241 */
3242 public static function allNullOrNotWhitespaceOnly(mixed $value, callable|string $message = ''): iterable
3243 {
3244 static::isIterable($value);
3245
3246 foreach ($value as $entry) {
3247 null === $entry || static::notWhitespaceOnly($entry, $message);
3248 }
3249
3250 return $value;
3251 }
3252
3253 /**
3254 * @psalm-pure
3255 *
3256 * @param string|callable():string $message
3257 *
3258 * @return string|null
3259 *
3260 * @throws InvalidArgumentException
3261 */
3262 public static function nullOrStartsWith(mixed $value, mixed $prefix, callable|string $message = ''): ?string
3263 {
3264 null === $value || static::startsWith($value, $prefix, $message);
3265
3266 return $value;
3267 }
3268
3269 /**
3270 * @psalm-pure
3271 *
3272 * @param string|callable():string $message
3273 *
3274 * @return iterable<string>
3275 *
3276 * @throws InvalidArgumentException
3277 */
3278 public static function allStartsWith(mixed $value, mixed $prefix, callable|string $message = ''): iterable
3279 {
3280 static::isIterable($value);
3281
3282 foreach ($value as $entry) {
3283 static::startsWith($entry, $prefix, $message);
3284 }
3285
3286 return $value;
3287 }
3288
3289 /**
3290 * @psalm-pure
3291 *
3292 * @param string|callable():string $message
3293 *
3294 * @return iterable<string|null>
3295 *
3296 * @throws InvalidArgumentException
3297 */
3298 public static function allNullOrStartsWith(mixed $value, mixed $prefix, callable|string $message = ''): iterable
3299 {
3300 static::isIterable($value);
3301
3302 foreach ($value as $entry) {
3303 null === $entry || static::startsWith($entry, $prefix, $message);
3304 }
3305
3306 return $value;
3307 }
3308
3309 /**
3310 * @psalm-pure
3311 *
3312 * @param string|callable():string $message
3313 *
3314 * @return string|null
3315 *
3316 * @throws InvalidArgumentException
3317 */
3318 public static function nullOrNotStartsWith(mixed $value, mixed $prefix, callable|string $message = ''): ?string
3319 {
3320 null === $value || static::notStartsWith($value, $prefix, $message);
3321
3322 return $value;
3323 }
3324
3325 /**
3326 * @psalm-pure
3327 *
3328 * @param string|callable():string $message
3329 *
3330 * @return iterable<string>
3331 *
3332 * @throws InvalidArgumentException
3333 */
3334 public static function allNotStartsWith(mixed $value, mixed $prefix, callable|string $message = ''): iterable
3335 {
3336 static::isIterable($value);
3337
3338 foreach ($value as $entry) {
3339 static::notStartsWith($entry, $prefix, $message);
3340 }
3341
3342 return $value;
3343 }
3344
3345 /**
3346 * @psalm-pure
3347 *
3348 * @param string|callable():string $message
3349 *
3350 * @return iterable<string|null>
3351 *
3352 * @throws InvalidArgumentException
3353 */
3354 public static function allNullOrNotStartsWith(mixed $value, mixed $prefix, callable|string $message = ''): iterable
3355 {
3356 static::isIterable($value);
3357
3358 foreach ($value as $entry) {
3359 null === $entry || static::notStartsWith($entry, $prefix, $message);
3360 }
3361
3362 return $value;
3363 }
3364
3365 /**
3366 * @psalm-pure
3367 *
3368 * @param string|callable():string $message
3369 *
3370 * @return string|null
3371 *
3372 * @throws InvalidArgumentException
3373 */
3374 public static function nullOrStartsWithLetter(mixed $value, callable|string $message = ''): ?string
3375 {
3376 null === $value || static::startsWithLetter($value, $message);
3377
3378 return $value;
3379 }
3380
3381 /**
3382 * @psalm-pure
3383 *
3384 * @param string|callable():string $message
3385 *
3386 * @return iterable<string>
3387 *
3388 * @throws InvalidArgumentException
3389 */
3390 public static function allStartsWithLetter(mixed $value, callable|string $message = ''): iterable
3391 {
3392 static::isIterable($value);
3393
3394 foreach ($value as $entry) {
3395 static::startsWithLetter($entry, $message);
3396 }
3397
3398 return $value;
3399 }
3400
3401 /**
3402 * @psalm-pure
3403 *
3404 * @param string|callable():string $message
3405 *
3406 * @return iterable<string|null>
3407 *
3408 * @throws InvalidArgumentException
3409 */
3410 public static function allNullOrStartsWithLetter(mixed $value, callable|string $message = ''): iterable
3411 {
3412 static::isIterable($value);
3413
3414 foreach ($value as $entry) {
3415 null === $entry || static::startsWithLetter($entry, $message);
3416 }
3417
3418 return $value;
3419 }
3420
3421 /**
3422 * @psalm-pure
3423 *
3424 * @param string|callable():string $message
3425 *
3426 * @return string|null
3427 *
3428 * @throws InvalidArgumentException
3429 */
3430 public static function nullOrEndsWith(mixed $value, mixed $suffix, callable|string $message = ''): ?string
3431 {
3432 null === $value || static::endsWith($value, $suffix, $message);
3433
3434 return $value;
3435 }
3436
3437 /**
3438 * @psalm-pure
3439 *
3440 * @param string|callable():string $message
3441 *
3442 * @return iterable<string>
3443 *
3444 * @throws InvalidArgumentException
3445 */
3446 public static function allEndsWith(mixed $value, mixed $suffix, callable|string $message = ''): iterable
3447 {
3448 static::isIterable($value);
3449
3450 foreach ($value as $entry) {
3451 static::endsWith($entry, $suffix, $message);
3452 }
3453
3454 return $value;
3455 }
3456
3457 /**
3458 * @psalm-pure
3459 *
3460 * @param string|callable():string $message
3461 *
3462 * @return iterable<string|null>
3463 *
3464 * @throws InvalidArgumentException
3465 */
3466 public static function allNullOrEndsWith(mixed $value, mixed $suffix, callable|string $message = ''): iterable
3467 {
3468 static::isIterable($value);
3469
3470 foreach ($value as $entry) {
3471 null === $entry || static::endsWith($entry, $suffix, $message);
3472 }
3473
3474 return $value;
3475 }
3476
3477 /**
3478 * @psalm-pure
3479 *
3480 * @param string|callable():string $message
3481 *
3482 * @return string|null
3483 *
3484 * @throws InvalidArgumentException
3485 */
3486 public static function nullOrNotEndsWith(mixed $value, mixed $suffix, callable|string $message = ''): ?string
3487 {
3488 null === $value || static::notEndsWith($value, $suffix, $message);
3489
3490 return $value;
3491 }
3492
3493 /**
3494 * @psalm-pure
3495 *
3496 * @param string|callable():string $message
3497 *
3498 * @return iterable<string>
3499 *
3500 * @throws InvalidArgumentException
3501 */
3502 public static function allNotEndsWith(mixed $value, mixed $suffix, callable|string $message = ''): iterable
3503 {
3504 static::isIterable($value);
3505
3506 foreach ($value as $entry) {
3507 static::notEndsWith($entry, $suffix, $message);
3508 }
3509
3510 return $value;
3511 }
3512
3513 /**
3514 * @psalm-pure
3515 *
3516 * @param string|callable():string $message
3517 *
3518 * @return iterable<string|null>
3519 *
3520 * @throws InvalidArgumentException
3521 */
3522 public static function allNullOrNotEndsWith(mixed $value, mixed $suffix, callable|string $message = ''): iterable
3523 {
3524 static::isIterable($value);
3525
3526 foreach ($value as $entry) {
3527 null === $entry || static::notEndsWith($entry, $suffix, $message);
3528 }
3529
3530 return $value;
3531 }
3532
3533 /**
3534 * @psalm-pure
3535 *
3536 * @param string|callable():string $message
3537 *
3538 * @return string|null
3539 *
3540 * @throws InvalidArgumentException
3541 */
3542 public static function nullOrRegex(mixed $value, mixed $pattern, callable|string $message = ''): ?string
3543 {
3544 null === $value || static::regex($value, $pattern, $message);
3545
3546 return $value;
3547 }
3548
3549 /**
3550 * @psalm-pure
3551 *
3552 * @param string|callable():string $message
3553 *
3554 * @return iterable<string>
3555 *
3556 * @throws InvalidArgumentException
3557 */
3558 public static function allRegex(mixed $value, mixed $pattern, callable|string $message = ''): iterable
3559 {
3560 static::isIterable($value);
3561
3562 foreach ($value as $entry) {
3563 static::regex($entry, $pattern, $message);
3564 }
3565
3566 return $value;
3567 }
3568
3569 /**
3570 * @psalm-pure
3571 *
3572 * @param string|callable():string $message
3573 *
3574 * @return iterable<string|null>
3575 *
3576 * @throws InvalidArgumentException
3577 */
3578 public static function allNullOrRegex(mixed $value, mixed $pattern, callable|string $message = ''): iterable
3579 {
3580 static::isIterable($value);
3581
3582 foreach ($value as $entry) {
3583 null === $entry || static::regex($entry, $pattern, $message);
3584 }
3585
3586 return $value;
3587 }
3588
3589 /**
3590 * @psalm-pure
3591 *
3592 * @param string|callable():string $message
3593 *
3594 * @return string|null
3595 *
3596 * @throws InvalidArgumentException
3597 */
3598 public static function nullOrNotRegex(mixed $value, mixed $pattern, callable|string $message = ''): ?string
3599 {
3600 null === $value || static::notRegex($value, $pattern, $message);
3601
3602 return $value;
3603 }
3604
3605 /**
3606 * @psalm-pure
3607 *
3608 * @param string|callable():string $message
3609 *
3610 * @return iterable<string>
3611 *
3612 * @throws InvalidArgumentException
3613 */
3614 public static function allNotRegex(mixed $value, mixed $pattern, callable|string $message = ''): iterable
3615 {
3616 static::isIterable($value);
3617
3618 foreach ($value as $entry) {
3619 static::notRegex($entry, $pattern, $message);
3620 }
3621
3622 return $value;
3623 }
3624
3625 /**
3626 * @psalm-pure
3627 *
3628 * @param string|callable():string $message
3629 *
3630 * @return iterable<string|null>
3631 *
3632 * @throws InvalidArgumentException
3633 */
3634 public static function allNullOrNotRegex(mixed $value, mixed $pattern, callable|string $message = ''): iterable
3635 {
3636 static::isIterable($value);
3637
3638 foreach ($value as $entry) {
3639 null === $entry || static::notRegex($entry, $pattern, $message);
3640 }
3641
3642 return $value;
3643 }
3644
3645 /**
3646 * @psalm-pure
3647 *
3648 * @param string|callable():string $message
3649 *
3650 * @return string|null
3651 *
3652 * @throws InvalidArgumentException
3653 */
3654 public static function nullOrUnicodeLetters(mixed $value, callable|string $message = ''): ?string
3655 {
3656 null === $value || static::unicodeLetters($value, $message);
3657
3658 return $value;
3659 }
3660
3661 /**
3662 * @psalm-pure
3663 *
3664 * @param string|callable():string $message
3665 *
3666 * @return iterable<string>
3667 *
3668 * @throws InvalidArgumentException
3669 */
3670 public static function allUnicodeLetters(mixed $value, callable|string $message = ''): iterable
3671 {
3672 static::isIterable($value);
3673
3674 foreach ($value as $entry) {
3675 static::unicodeLetters($entry, $message);
3676 }
3677
3678 return $value;
3679 }
3680
3681 /**
3682 * @psalm-pure
3683 *
3684 * @param string|callable():string $message
3685 *
3686 * @return iterable<string|null>
3687 *
3688 * @throws InvalidArgumentException
3689 */
3690 public static function allNullOrUnicodeLetters(mixed $value, callable|string $message = ''): iterable
3691 {
3692 static::isIterable($value);
3693
3694 foreach ($value as $entry) {
3695 null === $entry || static::unicodeLetters($entry, $message);
3696 }
3697
3698 return $value;
3699 }
3700
3701 /**
3702 * @psalm-pure
3703 *
3704 * @param string|callable():string $message
3705 *
3706 * @return string|null
3707 *
3708 * @throws InvalidArgumentException
3709 */
3710 public static function nullOrAlpha(mixed $value, callable|string $message = ''): ?string
3711 {
3712 null === $value || static::alpha($value, $message);
3713
3714 return $value;
3715 }
3716
3717 /**
3718 * @psalm-pure
3719 *
3720 * @param string|callable():string $message
3721 *
3722 * @return iterable<string>
3723 *
3724 * @throws InvalidArgumentException
3725 */
3726 public static function allAlpha(mixed $value, callable|string $message = ''): iterable
3727 {
3728 static::isIterable($value);
3729
3730 foreach ($value as $entry) {
3731 static::alpha($entry, $message);
3732 }
3733
3734 return $value;
3735 }
3736
3737 /**
3738 * @psalm-pure
3739 *
3740 * @param string|callable():string $message
3741 *
3742 * @return iterable<string|null>
3743 *
3744 * @throws InvalidArgumentException
3745 */
3746 public static function allNullOrAlpha(mixed $value, callable|string $message = ''): iterable
3747 {
3748 static::isIterable($value);
3749
3750 foreach ($value as $entry) {
3751 null === $entry || static::alpha($entry, $message);
3752 }
3753
3754 return $value;
3755 }
3756
3757 /**
3758 * @psalm-pure
3759 *
3760 * @param string|callable():string $message
3761 *
3762 * @return string|null
3763 *
3764 * @throws InvalidArgumentException
3765 */
3766 public static function nullOrDigits(mixed $value, callable|string $message = ''): ?string
3767 {
3768 null === $value || static::digits($value, $message);
3769
3770 return $value;
3771 }
3772
3773 /**
3774 * @psalm-pure
3775 *
3776 * @param string|callable():string $message
3777 *
3778 * @return iterable<string>
3779 *
3780 * @throws InvalidArgumentException
3781 */
3782 public static function allDigits(mixed $value, callable|string $message = ''): iterable
3783 {
3784 static::isIterable($value);
3785
3786 foreach ($value as $entry) {
3787 static::digits($entry, $message);
3788 }
3789
3790 return $value;
3791 }
3792
3793 /**
3794 * @psalm-pure
3795 *
3796 * @param string|callable():string $message
3797 *
3798 * @return iterable<string|null>
3799 *
3800 * @throws InvalidArgumentException
3801 */
3802 public static function allNullOrDigits(mixed $value, callable|string $message = ''): iterable
3803 {
3804 static::isIterable($value);
3805
3806 foreach ($value as $entry) {
3807 null === $entry || static::digits($entry, $message);
3808 }
3809
3810 return $value;
3811 }
3812
3813 /**
3814 * @psalm-pure
3815 *
3816 * @param string|callable():string $message
3817 *
3818 * @return string|null
3819 *
3820 * @throws InvalidArgumentException
3821 */
3822 public static function nullOrAlnum(mixed $value, callable|string $message = ''): ?string
3823 {
3824 null === $value || static::alnum($value, $message);
3825
3826 return $value;
3827 }
3828
3829 /**
3830 * @psalm-pure
3831 *
3832 * @param string|callable():string $message
3833 *
3834 * @return iterable<string>
3835 *
3836 * @throws InvalidArgumentException
3837 */
3838 public static function allAlnum(mixed $value, callable|string $message = ''): iterable
3839 {
3840 static::isIterable($value);
3841
3842 foreach ($value as $entry) {
3843 static::alnum($entry, $message);
3844 }
3845
3846 return $value;
3847 }
3848
3849 /**
3850 * @psalm-pure
3851 *
3852 * @param string|callable():string $message
3853 *
3854 * @return iterable<string|null>
3855 *
3856 * @throws InvalidArgumentException
3857 */
3858 public static function allNullOrAlnum(mixed $value, callable|string $message = ''): iterable
3859 {
3860 static::isIterable($value);
3861
3862 foreach ($value as $entry) {
3863 null === $entry || static::alnum($entry, $message);
3864 }
3865
3866 return $value;
3867 }
3868
3869 /**
3870 * @psalm-pure
3871 *
3872 * @psalm-assert lowercase-string|null $value
3873 *
3874 * @param string|callable():string $message
3875 *
3876 * @return lowercase-string|null
3877 *
3878 * @throws InvalidArgumentException
3879 */
3880 public static function nullOrLower(mixed $value, callable|string $message = ''): ?string
3881 {
3882 null === $value || static::lower($value, $message);
3883
3884 return $value;
3885 }
3886
3887 /**
3888 * @psalm-pure
3889 *
3890 * @psalm-assert iterable<lowercase-string> $value
3891 *
3892 * @param string|callable():string $message
3893 *
3894 * @return iterable<lowercase-string>
3895 *
3896 * @throws InvalidArgumentException
3897 */
3898 public static function allLower(mixed $value, callable|string $message = ''): iterable
3899 {
3900 static::isIterable($value);
3901
3902 foreach ($value as $entry) {
3903 static::lower($entry, $message);
3904 }
3905
3906 return $value;
3907 }
3908
3909 /**
3910 * @psalm-pure
3911 *
3912 * @psalm-assert iterable<lowercase-string|null> $value
3913 *
3914 * @param string|callable():string $message
3915 *
3916 * @return iterable<lowercase-string|null>
3917 *
3918 * @throws InvalidArgumentException
3919 */
3920 public static function allNullOrLower(mixed $value, callable|string $message = ''): iterable
3921 {
3922 static::isIterable($value);
3923
3924 foreach ($value as $entry) {
3925 null === $entry || static::lower($entry, $message);
3926 }
3927
3928 return $value;
3929 }
3930
3931 /**
3932 * @psalm-pure
3933 *
3934 * @param string|callable():string $message
3935 *
3936 * @return string|null
3937 *
3938 * @throws InvalidArgumentException
3939 */
3940 public static function nullOrUpper(mixed $value, callable|string $message = ''): ?string
3941 {
3942 null === $value || static::upper($value, $message);
3943
3944 return $value;
3945 }
3946
3947 /**
3948 * @psalm-pure
3949 *
3950 * @param string|callable():string $message
3951 *
3952 * @return iterable<string>
3953 *
3954 * @throws InvalidArgumentException
3955 */
3956 public static function allUpper(mixed $value, callable|string $message = ''): iterable
3957 {
3958 static::isIterable($value);
3959
3960 foreach ($value as $entry) {
3961 static::upper($entry, $message);
3962 }
3963
3964 return $value;
3965 }
3966
3967 /**
3968 * @psalm-pure
3969 *
3970 * @psalm-assert iterable<string|null> $value
3971 *
3972 * @param string|callable():string $message
3973 *
3974 * @return iterable<string|null>
3975 *
3976 * @throws InvalidArgumentException
3977 */
3978 public static function allNullOrUpper(mixed $value, callable|string $message = ''): iterable
3979 {
3980 static::isIterable($value);
3981
3982 foreach ($value as $entry) {
3983 null === $entry || static::upper($entry, $message);
3984 }
3985
3986 return $value;
3987 }
3988
3989 /**
3990 * @psalm-pure
3991 *
3992 * @param string|callable():string $message
3993 *
3994 * @return string|null
3995 *
3996 * @throws InvalidArgumentException
3997 */
3998 public static function nullOrLength(mixed $value, mixed $length, callable|string $message = ''): ?string
3999 {
4000 null === $value || static::length($value, $length, $message);
4001
4002 return $value;
4003 }
4004
4005 /**
4006 * @psalm-pure
4007 *
4008 * @param string|callable():string $message
4009 *
4010 * @return iterable<string>
4011 *
4012 * @throws InvalidArgumentException
4013 */
4014 public static function allLength(mixed $value, mixed $length, callable|string $message = ''): iterable
4015 {
4016 static::isIterable($value);
4017
4018 foreach ($value as $entry) {
4019 static::length($entry, $length, $message);
4020 }
4021
4022 return $value;
4023 }
4024
4025 /**
4026 * @psalm-pure
4027 *
4028 * @param string|callable():string $message
4029 *
4030 * @return iterable<string|null>
4031 *
4032 * @throws InvalidArgumentException
4033 */
4034 public static function allNullOrLength(mixed $value, mixed $length, callable|string $message = ''): iterable
4035 {
4036 static::isIterable($value);
4037
4038 foreach ($value as $entry) {
4039 null === $entry || static::length($entry, $length, $message);
4040 }
4041
4042 return $value;
4043 }
4044
4045 /**
4046 * @psalm-pure
4047 *
4048 * @param string|callable():string $message
4049 *
4050 * @return string|null
4051 *
4052 * @throws InvalidArgumentException
4053 */
4054 public static function nullOrMinLength(mixed $value, mixed $min, callable|string $message = ''): ?string
4055 {
4056 null === $value || static::minLength($value, $min, $message);
4057
4058 return $value;
4059 }
4060
4061 /**
4062 * @psalm-pure
4063 *
4064 * @param string|callable():string $message
4065 *
4066 * @return iterable<string>
4067 *
4068 * @throws InvalidArgumentException
4069 */
4070 public static function allMinLength(mixed $value, mixed $min, callable|string $message = ''): iterable
4071 {
4072 static::isIterable($value);
4073
4074 foreach ($value as $entry) {
4075 static::minLength($entry, $min, $message);
4076 }
4077
4078 return $value;
4079 }
4080
4081 /**
4082 * @psalm-pure
4083 *
4084 * @param string|callable():string $message
4085 *
4086 * @return iterable<string|null>
4087 *
4088 * @throws InvalidArgumentException
4089 */
4090 public static function allNullOrMinLength(mixed $value, mixed $min, callable|string $message = ''): iterable
4091 {
4092 static::isIterable($value);
4093
4094 foreach ($value as $entry) {
4095 null === $entry || static::minLength($entry, $min, $message);
4096 }
4097
4098 return $value;
4099 }
4100
4101 /**
4102 * @psalm-pure
4103 *
4104 * @param string|callable():string $message
4105 *
4106 * @return string|null
4107 *
4108 * @throws InvalidArgumentException
4109 */
4110 public static function nullOrMaxLength(mixed $value, mixed $max, callable|string $message = ''): ?string
4111 {
4112 null === $value || static::maxLength($value, $max, $message);
4113
4114 return $value;
4115 }
4116
4117 /**
4118 * @psalm-pure
4119 *
4120 * @param string|callable():string $message
4121 *
4122 * @return iterable<string>
4123 *
4124 * @throws InvalidArgumentException
4125 */
4126 public static function allMaxLength(mixed $value, mixed $max, callable|string $message = ''): iterable
4127 {
4128 static::isIterable($value);
4129
4130 foreach ($value as $entry) {
4131 static::maxLength($entry, $max, $message);
4132 }
4133
4134 return $value;
4135 }
4136
4137 /**
4138 * @psalm-pure
4139 *
4140 * @param string|callable():string $message
4141 *
4142 * @return iterable<string|null>
4143 *
4144 * @throws InvalidArgumentException
4145 */
4146 public static function allNullOrMaxLength(mixed $value, mixed $max, callable|string $message = ''): iterable
4147 {
4148 static::isIterable($value);
4149
4150 foreach ($value as $entry) {
4151 null === $entry || static::maxLength($entry, $max, $message);
4152 }
4153
4154 return $value;
4155 }
4156
4157 /**
4158 * @psalm-pure
4159 *
4160 * @param string|callable():string $message
4161 *
4162 * @return string|null
4163 *
4164 * @throws InvalidArgumentException
4165 */
4166 public static function nullOrLengthBetween(mixed $value, mixed $min, mixed $max, callable|string $message = ''): ?string
4167 {
4168 null === $value || static::lengthBetween($value, $min, $max, $message);
4169
4170 return $value;
4171 }
4172
4173 /**
4174 * @psalm-pure
4175 *
4176 * @param string|callable():string $message
4177 *
4178 * @return iterable<string>
4179 *
4180 * @throws InvalidArgumentException
4181 */
4182 public static function allLengthBetween(mixed $value, mixed $min, mixed $max, callable|string $message = ''): iterable
4183 {
4184 static::isIterable($value);
4185
4186 foreach ($value as $entry) {
4187 static::lengthBetween($entry, $min, $max, $message);
4188 }
4189
4190 return $value;
4191 }
4192
4193 /**
4194 * @psalm-pure
4195 *
4196 * @param string|callable():string $message
4197 *
4198 * @return iterable<string|null>
4199 *
4200 * @throws InvalidArgumentException
4201 */
4202 public static function allNullOrLengthBetween(mixed $value, mixed $min, mixed $max, callable|string $message = ''): iterable
4203 {
4204 static::isIterable($value);
4205
4206 foreach ($value as $entry) {
4207 null === $entry || static::lengthBetween($entry, $min, $max, $message);
4208 }
4209
4210 return $value;
4211 }
4212
4213 /**
4214 * @param string|callable():string $message
4215 *
4216 * @return string|null
4217 *
4218 * @throws InvalidArgumentException
4219 */
4220 public static function nullOrFileExists(mixed $value, callable|string $message = ''): ?string
4221 {
4222 null === $value || static::fileExists($value, $message);
4223
4224 return $value;
4225 }
4226
4227 /**
4228 * @param string|callable():string $message
4229 *
4230 * @return iterable<string>
4231 *
4232 * @throws InvalidArgumentException
4233 */
4234 public static function allFileExists(mixed $value, callable|string $message = ''): iterable
4235 {
4236 static::isIterable($value);
4237
4238 foreach ($value as $entry) {
4239 static::fileExists($entry, $message);
4240 }
4241
4242 return $value;
4243 }
4244
4245 /**
4246 * @param string|callable():string $message
4247 *
4248 * @return iterable<string|null>
4249 *
4250 * @throws InvalidArgumentException
4251 */
4252 public static function allNullOrFileExists(mixed $value, callable|string $message = ''): iterable
4253 {
4254 static::isIterable($value);
4255
4256 foreach ($value as $entry) {
4257 null === $entry || static::fileExists($entry, $message);
4258 }
4259
4260 return $value;
4261 }
4262
4263 /**
4264 * @param string|callable():string $message
4265 *
4266 * @return string|null
4267 *
4268 * @throws InvalidArgumentException
4269 */
4270 public static function nullOrFile(mixed $value, callable|string $message = ''): ?string
4271 {
4272 null === $value || static::file($value, $message);
4273
4274 return $value;
4275 }
4276
4277 /**
4278 * @param string|callable():string $message
4279 *
4280 * @return iterable<string>
4281 *
4282 * @throws InvalidArgumentException
4283 */
4284 public static function allFile(mixed $value, callable|string $message = ''): iterable
4285 {
4286 static::isIterable($value);
4287
4288 foreach ($value as $entry) {
4289 static::file($entry, $message);
4290 }
4291
4292 return $value;
4293 }
4294
4295 /**
4296 * @param string|callable():string $message
4297 *
4298 * @return iterable<string|null>
4299 *
4300 * @throws InvalidArgumentException
4301 */
4302 public static function allNullOrFile(mixed $value, callable|string $message = ''): iterable
4303 {
4304 static::isIterable($value);
4305
4306 foreach ($value as $entry) {
4307 null === $entry || static::file($entry, $message);
4308 }
4309
4310 return $value;
4311 }
4312
4313 /**
4314 * @param string|callable():string $message
4315 *
4316 * @return string|null
4317 *
4318 * @throws InvalidArgumentException
4319 */
4320 public static function nullOrDirectory(mixed $value, callable|string $message = ''): ?string
4321 {
4322 null === $value || static::directory($value, $message);
4323
4324 return $value;
4325 }
4326
4327 /**
4328 * @param string|callable():string $message
4329 *
4330 * @return iterable<string>
4331 *
4332 * @throws InvalidArgumentException
4333 */
4334 public static function allDirectory(mixed $value, callable|string $message = ''): iterable
4335 {
4336 static::isIterable($value);
4337
4338 foreach ($value as $entry) {
4339 static::directory($entry, $message);
4340 }
4341
4342 return $value;
4343 }
4344
4345 /**
4346 * @param string|callable():string $message
4347 *
4348 * @return iterable<string|null>
4349 *
4350 * @throws InvalidArgumentException
4351 */
4352 public static function allNullOrDirectory(mixed $value, callable|string $message = ''): iterable
4353 {
4354 static::isIterable($value);
4355
4356 foreach ($value as $entry) {
4357 null === $entry || static::directory($entry, $message);
4358 }
4359
4360 return $value;
4361 }
4362
4363 /**
4364 * @param string|callable():string $message
4365 *
4366 * @return string|null
4367 *
4368 * @throws InvalidArgumentException
4369 */
4370 public static function nullOrReadable(mixed $value, callable|string $message = ''): ?string
4371 {
4372 null === $value || static::readable($value, $message);
4373
4374 return $value;
4375 }
4376
4377 /**
4378 * @param string|callable():string $message
4379 *
4380 * @return iterable<string>
4381 *
4382 * @throws InvalidArgumentException
4383 */
4384 public static function allReadable(mixed $value, callable|string $message = ''): iterable
4385 {
4386 static::isIterable($value);
4387
4388 foreach ($value as $entry) {
4389 static::readable($entry, $message);
4390 }
4391
4392 return $value;
4393 }
4394
4395 /**
4396 * @param string|callable():string $message
4397 *
4398 * @return iterable<string|null>
4399 *
4400 * @throws InvalidArgumentException
4401 */
4402 public static function allNullOrReadable(mixed $value, callable|string $message = ''): iterable
4403 {
4404 static::isIterable($value);
4405
4406 foreach ($value as $entry) {
4407 null === $entry || static::readable($entry, $message);
4408 }
4409
4410 return $value;
4411 }
4412
4413 /**
4414 * @param string|callable():string $message
4415 *
4416 * @return string|null
4417 *
4418 * @throws InvalidArgumentException
4419 */
4420 public static function nullOrWritable(mixed $value, callable|string $message = ''): ?string
4421 {
4422 null === $value || static::writable($value, $message);
4423
4424 return $value;
4425 }
4426
4427 /**
4428 * @param string|callable():string $message
4429 *
4430 * @return iterable<string>
4431 *
4432 * @throws InvalidArgumentException
4433 */
4434 public static function allWritable(mixed $value, callable|string $message = ''): iterable
4435 {
4436 static::isIterable($value);
4437
4438 foreach ($value as $entry) {
4439 static::writable($entry, $message);
4440 }
4441
4442 return $value;
4443 }
4444
4445 /**
4446 * @param string|callable():string $message
4447 *
4448 * @return iterable<string|null>
4449 *
4450 * @throws InvalidArgumentException
4451 */
4452 public static function allNullOrWritable(mixed $value, callable|string $message = ''): iterable
4453 {
4454 static::isIterable($value);
4455
4456 foreach ($value as $entry) {
4457 null === $entry || static::writable($entry, $message);
4458 }
4459
4460 return $value;
4461 }
4462
4463 /**
4464 * @psalm-assert class-string|null $value
4465 *
4466 * @param string|callable():string $message
4467 *
4468 * @return class-string|null
4469 *
4470 * @throws InvalidArgumentException
4471 */
4472 public static function nullOrClassExists(mixed $value, callable|string $message = ''): ?string
4473 {
4474 null === $value || static::classExists($value, $message);
4475
4476 return $value;
4477 }
4478
4479 /**
4480 * @psalm-assert iterable<class-string> $value
4481 *
4482 * @param string|callable():string $message
4483 *
4484 * @return iterable<class-string>
4485 *
4486 * @throws InvalidArgumentException
4487 */
4488 public static function allClassExists(mixed $value, callable|string $message = ''): iterable
4489 {
4490 static::isIterable($value);
4491
4492 foreach ($value as $entry) {
4493 static::classExists($entry, $message);
4494 }
4495
4496 return $value;
4497 }
4498
4499 /**
4500 * @psalm-assert iterable<class-string|null> $value
4501 *
4502 * @param string|callable():string $message
4503 *
4504 * @return iterable<class-string|null>
4505 *
4506 * @throws InvalidArgumentException
4507 */
4508 public static function allNullOrClassExists(mixed $value, callable|string $message = ''): iterable
4509 {
4510 static::isIterable($value);
4511
4512 foreach ($value as $entry) {
4513 null === $entry || static::classExists($entry, $message);
4514 }
4515
4516 return $value;
4517 }
4518
4519 /**
4520 * @psalm-pure
4521 *
4522 * @template ExpectedType of object
4523 * @psalm-assert class-string<ExpectedType>|null $value
4524 *
4525 * @param class-string<ExpectedType> $class
4526 * @param string|callable():string $message
4527 *
4528 * @return class-string<ExpectedType>|null
4529 *
4530 * @throws InvalidArgumentException
4531 */
4532 public static function nullOrSubclassOf(mixed $value, mixed $class, callable|string $message = ''): ?string
4533 {
4534 null === $value || static::subclassOf($value, $class, $message);
4535
4536 return $value;
4537 }
4538
4539 /**
4540 * @psalm-pure
4541 *
4542 * @template ExpectedType of object
4543 * @psalm-assert iterable<class-string<ExpectedType>> $value
4544 *
4545 * @param class-string<ExpectedType> $class
4546 * @param string|callable():string $message
4547 *
4548 * @return iterable<class-string<ExpectedType>>
4549 *
4550 * @throws InvalidArgumentException
4551 */
4552 public static function allSubclassOf(mixed $value, mixed $class, callable|string $message = ''): iterable
4553 {
4554 static::isIterable($value);
4555
4556 foreach ($value as $entry) {
4557 static::subclassOf($entry, $class, $message);
4558 }
4559
4560 return $value;
4561 }
4562
4563 /**
4564 * @psalm-pure
4565 *
4566 * @template ExpectedType of object|null
4567 * @psalm-assert iterable<class-string<ExpectedType>|null> $value
4568 *
4569 * @param class-string<ExpectedType> $class
4570 * @param string|callable():string $message
4571 *
4572 * @return iterable<class-string<ExpectedType>|null>
4573 *
4574 * @throws InvalidArgumentException
4575 */
4576 public static function allNullOrSubclassOf(mixed $value, mixed $class, callable|string $message = ''): iterable
4577 {
4578 static::isIterable($value);
4579
4580 foreach ($value as $entry) {
4581 null === $entry || static::subclassOf($entry, $class, $message);
4582 }
4583
4584 return $value;
4585 }
4586
4587 /**
4588 * @psalm-assert class-string|null $value
4589 *
4590 * @param string|callable():string $message
4591 *
4592 * @return class-string|null
4593 *
4594 * @throws InvalidArgumentException
4595 */
4596 public static function nullOrInterfaceExists(mixed $value, callable|string $message = ''): ?string
4597 {
4598 null === $value || static::interfaceExists($value, $message);
4599
4600 return $value;
4601 }
4602
4603 /**
4604 * @psalm-assert iterable<class-string> $value
4605 *
4606 * @param string|callable():string $message
4607 *
4608 * @return iterable<class-string>
4609 *
4610 * @throws InvalidArgumentException
4611 */
4612 public static function allInterfaceExists(mixed $value, callable|string $message = ''): iterable
4613 {
4614 static::isIterable($value);
4615
4616 foreach ($value as $entry) {
4617 static::interfaceExists($entry, $message);
4618 }
4619
4620 return $value;
4621 }
4622
4623 /**
4624 * @psalm-assert iterable<class-string|null> $value
4625 *
4626 * @param string|callable():string $message
4627 *
4628 * @return iterable<class-string|null>
4629 *
4630 * @throws InvalidArgumentException
4631 */
4632 public static function allNullOrInterfaceExists(mixed $value, callable|string $message = ''): iterable
4633 {
4634 static::isIterable($value);
4635
4636 foreach ($value as $entry) {
4637 null === $entry || static::interfaceExists($entry, $message);
4638 }
4639
4640 return $value;
4641 }
4642
4643 /**
4644 * @psalm-pure
4645 *
4646 * @template ExpectedType of object
4647 * @psalm-assert class-string<ExpectedType>|ExpectedType|null $value
4648 *
4649 * @param class-string<ExpectedType> $interface
4650 * @param string|callable():string $message
4651 *
4652 * @return class-string<ExpectedType>|ExpectedType|null
4653 *
4654 * @throws InvalidArgumentException
4655 */
4656 public static function nullOrImplementsInterface(mixed $value, mixed $interface, callable|string $message = ''): object|string|null
4657 {
4658 null === $value || static::implementsInterface($value, $interface, $message);
4659
4660 return $value;
4661 }
4662
4663 /**
4664 * @psalm-pure
4665 *
4666 * @template ExpectedType of object
4667 * @psalm-assert iterable<class-string<ExpectedType>|ExpectedType> $value
4668 *
4669 * @param class-string<ExpectedType> $interface
4670 * @param string|callable():string $message
4671 *
4672 * @return iterable<class-string<ExpectedType>|ExpectedType>
4673 *
4674 * @throws InvalidArgumentException
4675 */
4676 public static function allImplementsInterface(mixed $value, mixed $interface, callable|string $message = ''): iterable
4677 {
4678 static::isIterable($value);
4679
4680 foreach ($value as $entry) {
4681 static::implementsInterface($entry, $interface, $message);
4682 }
4683
4684 return $value;
4685 }
4686
4687 /**
4688 * @psalm-pure
4689 *
4690 * @template ExpectedType of object|null
4691 * @psalm-assert iterable<class-string<ExpectedType>|ExpectedType|null> $value
4692 *
4693 * @param class-string<ExpectedType> $interface
4694 * @param string|callable():string $message
4695 *
4696 * @return iterable<class-string<ExpectedType>|ExpectedType|null>
4697 *
4698 * @throws InvalidArgumentException
4699 */
4700 public static function allNullOrImplementsInterface(mixed $value, mixed $interface, callable|string $message = ''): iterable
4701 {
4702 static::isIterable($value);
4703
4704 foreach ($value as $entry) {
4705 null === $entry || static::implementsInterface($entry, $interface, $message);
4706 }
4707
4708 return $value;
4709 }
4710
4711 /**
4712 * @psalm-pure
4713 *
4714 * @param string|object|null $classOrObject
4715 * @param string|callable():string $message
4716 *
4717 * @return string|object|null
4718 *
4719 * @throws InvalidArgumentException
4720 */
4721 public static function nullOrPropertyExists(mixed $classOrObject, mixed $property, callable|string $message = ''): object|string|null
4722 {
4723 null === $classOrObject || static::propertyExists($classOrObject, $property, $message);
4724
4725 return $classOrObject;
4726 }
4727
4728 /**
4729 * @psalm-pure
4730 *
4731 * @param iterable<string|object> $classOrObject
4732 * @param string|callable():string $message
4733 *
4734 * @return iterable<string|object>
4735 *
4736 * @throws InvalidArgumentException
4737 */
4738 public static function allPropertyExists(mixed $classOrObject, mixed $property, callable|string $message = ''): iterable
4739 {
4740 static::isIterable($classOrObject);
4741
4742 foreach ($classOrObject as $entry) {
4743 static::propertyExists($entry, $property, $message);
4744 }
4745
4746 return $classOrObject;
4747 }
4748
4749 /**
4750 * @psalm-pure
4751 *
4752 * @param iterable<string|object|null> $classOrObject
4753 * @param string|callable():string $message
4754 *
4755 * @return iterable<string|object|null>
4756 *
4757 * @throws InvalidArgumentException
4758 */
4759 public static function allNullOrPropertyExists(mixed $classOrObject, mixed $property, callable|string $message = ''): iterable
4760 {
4761 static::isIterable($classOrObject);
4762
4763 foreach ($classOrObject as $entry) {
4764 null === $entry || static::propertyExists($entry, $property, $message);
4765 }
4766
4767 return $classOrObject;
4768 }
4769
4770 /**
4771 * @psalm-pure
4772 *
4773 * @template T as class-string|object
4774 *
4775 * @param T|null $classOrObject
4776 * @param string|callable():string $message
4777 *
4778 * @return T|null
4779 *
4780 * @throws InvalidArgumentException
4781 */
4782 public static function nullOrPropertyNotExists(mixed $classOrObject, mixed $property, callable|string $message = ''): mixed
4783 {
4784 null === $classOrObject || static::propertyNotExists($classOrObject, $property, $message);
4785
4786 return $classOrObject;
4787 }
4788
4789 /**
4790 * @psalm-pure
4791 *
4792 * @template T as class-string|object
4793 *
4794 * @param iterable<T> $classOrObject
4795 * @param string|callable():string $message
4796 *
4797 * @return iterable<T>
4798 *
4799 * @throws InvalidArgumentException
4800 */
4801 public static function allPropertyNotExists(mixed $classOrObject, mixed $property, callable|string $message = ''): iterable
4802 {
4803 static::isIterable($classOrObject);
4804
4805 foreach ($classOrObject as $entry) {
4806 static::propertyNotExists($entry, $property, $message);
4807 }
4808
4809 return $classOrObject;
4810 }
4811
4812 /**
4813 * @psalm-pure
4814 *
4815 * @template T as class-string|object|null
4816 *
4817 * @param iterable<T> $classOrObject
4818 * @param string|callable():string $message
4819 *
4820 * @return iterable<T>
4821 *
4822 * @throws InvalidArgumentException
4823 */
4824 public static function allNullOrPropertyNotExists(mixed $classOrObject, mixed $property, callable|string $message = ''): iterable
4825 {
4826 static::isIterable($classOrObject);
4827
4828 foreach ($classOrObject as $entry) {
4829 null === $entry || static::propertyNotExists($entry, $property, $message);
4830 }
4831
4832 return $classOrObject;
4833 }
4834
4835 /**
4836 * @psalm-pure
4837 *
4838 * @template T as class-string|object
4839 *
4840 * @param T|null $classOrObject
4841 * @param string|callable():string $message
4842 *
4843 * @return T|null
4844 *
4845 * @throws InvalidArgumentException
4846 */
4847 public static function nullOrMethodExists(mixed $classOrObject, mixed $method, callable|string $message = ''): object|string|null
4848 {
4849 null === $classOrObject || static::methodExists($classOrObject, $method, $message);
4850
4851 return $classOrObject;
4852 }
4853
4854 /**
4855 * @psalm-pure
4856 *
4857 * @template T as class-string|object
4858 *
4859 * @param iterable<T> $classOrObject
4860 * @param string|callable():string $message
4861 *
4862 * @return iterable<T>
4863 *
4864 * @throws InvalidArgumentException
4865 */
4866 public static function allMethodExists(mixed $classOrObject, mixed $method, callable|string $message = ''): iterable
4867 {
4868 static::isIterable($classOrObject);
4869
4870 foreach ($classOrObject as $entry) {
4871 static::methodExists($entry, $method, $message);
4872 }
4873
4874 return $classOrObject;
4875 }
4876
4877 /**
4878 * @psalm-pure
4879 *
4880 * @template T as class-string|object|null
4881 *
4882 * @param iterable<T> $classOrObject
4883 * @param string|callable():string $message
4884 *
4885 * @return iterable<T>
4886 *
4887 * @throws InvalidArgumentException
4888 */
4889 public static function allNullOrMethodExists(mixed $classOrObject, mixed $method, callable|string $message = ''): iterable
4890 {
4891 static::isIterable($classOrObject);
4892
4893 foreach ($classOrObject as $entry) {
4894 null === $entry || static::methodExists($entry, $method, $message);
4895 }
4896
4897 return $classOrObject;
4898 }
4899
4900 /**
4901 * @psalm-pure
4902 *
4903 * @template T as class-string|object
4904 *
4905 * @param T|null $classOrObject
4906 * @param string|callable():string $message
4907 *
4908 * @return T|null
4909 *
4910 * @throws InvalidArgumentException
4911 */
4912 public static function nullOrMethodNotExists(mixed $classOrObject, mixed $method, callable|string $message = ''): mixed
4913 {
4914 null === $classOrObject || static::methodNotExists($classOrObject, $method, $message);
4915
4916 return $classOrObject;
4917 }
4918
4919 /**
4920 * @psalm-pure
4921 *
4922 * @template T as class-string|object
4923 *
4924 * @param iterable<T> $classOrObject
4925 * @param string|callable():string $message
4926 *
4927 * @return iterable<T>
4928 *
4929 * @throws InvalidArgumentException
4930 */
4931 public static function allMethodNotExists(mixed $classOrObject, mixed $method, callable|string $message = ''): iterable
4932 {
4933 static::isIterable($classOrObject);
4934
4935 foreach ($classOrObject as $entry) {
4936 static::methodNotExists($entry, $method, $message);
4937 }
4938
4939 return $classOrObject;
4940 }
4941
4942 /**
4943 * @psalm-pure
4944 *
4945 * @template T as class-string|object|null
4946 *
4947 * @param iterable<T> $classOrObject
4948 * @param string|callable():string $message
4949 *
4950 * @return iterable<T>
4951 *
4952 * @throws InvalidArgumentException
4953 */
4954 public static function allNullOrMethodNotExists(mixed $classOrObject, mixed $method, callable|string $message = ''): iterable
4955 {
4956 static::isIterable($classOrObject);
4957
4958 foreach ($classOrObject as $entry) {
4959 null === $entry || static::methodNotExists($entry, $method, $message);
4960 }
4961
4962 return $classOrObject;
4963 }
4964
4965 /**
4966 * @psalm-pure
4967 *
4968 * @param string|int $key
4969 * @param string|callable():string $message
4970 *
4971 * @return array|null
4972 *
4973 * @throws InvalidArgumentException
4974 */
4975 public static function nullOrKeyExists(mixed $array, string|int $key, callable|string $message = ''): ?array
4976 {
4977 null === $array || static::keyExists($array, $key, $message);
4978
4979 return $array;
4980 }
4981
4982 /**
4983 * @psalm-pure
4984 *
4985 * @param string|int $key
4986 * @param string|callable():string $message
4987 *
4988 * @return iterable<array>
4989 *
4990 * @throws InvalidArgumentException
4991 */
4992 public static function allKeyExists(mixed $array, string|int $key, callable|string $message = ''): iterable
4993 {
4994 static::isIterable($array);
4995
4996 foreach ($array as $entry) {
4997 static::keyExists($entry, $key, $message);
4998 }
4999
5000 return $array;
5001 }
5002
5003 /**
5004 * @psalm-pure
5005 *
5006 * @param string|int $key
5007 * @param string|callable():string $message
5008 *
5009 * @return iterable<array|null>
5010 *
5011 * @throws InvalidArgumentException
5012 */
5013 public static function allNullOrKeyExists(mixed $array, string|int $key, callable|string $message = ''): iterable
5014 {
5015 static::isIterable($array);
5016
5017 foreach ($array as $entry) {
5018 null === $entry || static::keyExists($entry, $key, $message);
5019 }
5020
5021 return $array;
5022 }
5023
5024 /**
5025 * @psalm-pure
5026 *
5027 * @param string|int $key
5028 * @param string|callable():string $message
5029 *
5030 * @return array|null
5031 *
5032 * @throws InvalidArgumentException
5033 */
5034 public static function nullOrKeyNotExists(mixed $array, string|int $key, callable|string $message = ''): ?array
5035 {
5036 null === $array || static::keyNotExists($array, $key, $message);
5037
5038 return $array;
5039 }
5040
5041 /**
5042 * @psalm-pure
5043 *
5044 * @param string|int $key
5045 * @param string|callable():string $message
5046 *
5047 * @return iterable<array>
5048 *
5049 * @throws InvalidArgumentException
5050 */
5051 public static function allKeyNotExists(mixed $array, string|int $key, callable|string $message = ''): iterable
5052 {
5053 static::isIterable($array);
5054
5055 foreach ($array as $entry) {
5056 static::keyNotExists($entry, $key, $message);
5057 }
5058
5059 return $array;
5060 }
5061
5062 /**
5063 * @psalm-pure
5064 *
5065 * @param string|int $key
5066 * @param string|callable():string $message
5067 *
5068 * @return iterable<array|null>
5069 *
5070 * @throws InvalidArgumentException
5071 */
5072 public static function allNullOrKeyNotExists(mixed $array, string|int $key, callable|string $message = ''): iterable
5073 {
5074 static::isIterable($array);
5075
5076 foreach ($array as $entry) {
5077 null === $entry || static::keyNotExists($entry, $key, $message);
5078 }
5079
5080 return $array;
5081 }
5082
5083 /**
5084 * @psalm-pure
5085 *
5086 * @psalm-assert array-key|null $value
5087 *
5088 * @param string|callable():string $message
5089 *
5090 * @return array-key|null
5091 *
5092 * @throws InvalidArgumentException
5093 */
5094 public static function nullOrValidArrayKey(mixed $value, callable|string $message = ''): string|int|null
5095 {
5096 null === $value || static::validArrayKey($value, $message);
5097
5098 return $value;
5099 }
5100
5101 /**
5102 * @psalm-pure
5103 *
5104 * @psalm-assert iterable<array-key> $value
5105 *
5106 * @param string|callable():string $message
5107 *
5108 * @return iterable<array-key>
5109 *
5110 * @throws InvalidArgumentException
5111 */
5112 public static function allValidArrayKey(mixed $value, callable|string $message = ''): iterable
5113 {
5114 static::isIterable($value);
5115
5116 foreach ($value as $entry) {
5117 static::validArrayKey($entry, $message);
5118 }
5119
5120 return $value;
5121 }
5122
5123 /**
5124 * @psalm-pure
5125 *
5126 * @psalm-assert iterable<array-key|null> $value
5127 *
5128 * @param string|callable():string $message
5129 *
5130 * @return iterable<array-key|null>
5131 *
5132 * @throws InvalidArgumentException
5133 */
5134 public static function allNullOrValidArrayKey(mixed $value, callable|string $message = ''): iterable
5135 {
5136 static::isIterable($value);
5137
5138 foreach ($value as $entry) {
5139 null === $entry || static::validArrayKey($entry, $message);
5140 }
5141
5142 return $value;
5143 }
5144
5145 /**
5146 * @param string|callable():string $message
5147 *
5148 * @return Countable|array|null
5149 *
5150 * @throws InvalidArgumentException
5151 */
5152 public static function nullOrCount(mixed $array, mixed $number, callable|string $message = ''): Countable|array|null
5153 {
5154 null === $array || static::count($array, $number, $message);
5155
5156 return $array;
5157 }
5158
5159 /**
5160 * @param string|callable():string $message
5161 *
5162 * @return iterable<Countable|array>
5163 *
5164 * @throws InvalidArgumentException
5165 */
5166 public static function allCount(mixed $array, mixed $number, callable|string $message = ''): iterable
5167 {
5168 static::isIterable($array);
5169
5170 foreach ($array as $entry) {
5171 static::count($entry, $number, $message);
5172 }
5173
5174 return $array;
5175 }
5176
5177 /**
5178 * @param string|callable():string $message
5179 *
5180 * @return iterable<Countable|array|null>
5181 *
5182 * @throws InvalidArgumentException
5183 */
5184 public static function allNullOrCount(mixed $array, mixed $number, callable|string $message = ''): iterable
5185 {
5186 static::isIterable($array);
5187
5188 foreach ($array as $entry) {
5189 null === $entry || static::count($entry, $number, $message);
5190 }
5191
5192 return $array;
5193 }
5194
5195 /**
5196 * @param string|callable():string $message
5197 *
5198 * @return Countable|array|null
5199 *
5200 * @throws InvalidArgumentException
5201 */
5202 public static function nullOrMinCount(mixed $array, mixed $min, callable|string $message = ''): Countable|array|null
5203 {
5204 null === $array || static::minCount($array, $min, $message);
5205
5206 return $array;
5207 }
5208
5209 /**
5210 * @param string|callable():string $message
5211 *
5212 * @return iterable<Countable|array>
5213 *
5214 * @throws InvalidArgumentException
5215 */
5216 public static function allMinCount(mixed $array, mixed $min, callable|string $message = ''): iterable
5217 {
5218 static::isIterable($array);
5219
5220 foreach ($array as $entry) {
5221 static::minCount($entry, $min, $message);
5222 }
5223
5224 return $array;
5225 }
5226
5227 /**
5228 * @param string|callable():string $message
5229 *
5230 * @return iterable<Countable|array|null>
5231 *
5232 * @throws InvalidArgumentException
5233 */
5234 public static function allNullOrMinCount(mixed $array, mixed $min, callable|string $message = ''): iterable
5235 {
5236 static::isIterable($array);
5237
5238 foreach ($array as $entry) {
5239 null === $entry || static::minCount($entry, $min, $message);
5240 }
5241
5242 return $array;
5243 }
5244
5245 /**
5246 * @param string|callable():string $message
5247 *
5248 * @return Countable|array|null
5249 *
5250 * @throws InvalidArgumentException
5251 */
5252 public static function nullOrMaxCount(mixed $array, mixed $max, callable|string $message = ''): Countable|array|null
5253 {
5254 null === $array || static::maxCount($array, $max, $message);
5255
5256 return $array;
5257 }
5258
5259 /**
5260 * @param string|callable():string $message
5261 *
5262 * @return iterable<Countable|array>
5263 *
5264 * @throws InvalidArgumentException
5265 */
5266 public static function allMaxCount(mixed $array, mixed $max, callable|string $message = ''): iterable
5267 {
5268 static::isIterable($array);
5269
5270 foreach ($array as $entry) {
5271 static::maxCount($entry, $max, $message);
5272 }
5273
5274 return $array;
5275 }
5276
5277 /**
5278 * @param string|callable():string $message
5279 *
5280 * @return iterable<Countable|array|null>
5281 *
5282 * @throws InvalidArgumentException
5283 */
5284 public static function allNullOrMaxCount(mixed $array, mixed $max, callable|string $message = ''): iterable
5285 {
5286 static::isIterable($array);
5287
5288 foreach ($array as $entry) {
5289 null === $entry || static::maxCount($entry, $max, $message);
5290 }
5291
5292 return $array;
5293 }
5294
5295 /**
5296 * @param string|callable():string $message
5297 *
5298 * @return Countable|array|null
5299 *
5300 * @throws InvalidArgumentException
5301 */
5302 public static function nullOrCountBetween(mixed $array, mixed $min, mixed $max, callable|string $message = ''): Countable|array|null
5303 {
5304 null === $array || static::countBetween($array, $min, $max, $message);
5305
5306 return $array;
5307 }
5308
5309 /**
5310 * @param string|callable():string $message
5311 *
5312 * @return iterable<Countable|array>
5313 *
5314 * @throws InvalidArgumentException
5315 */
5316 public static function allCountBetween(mixed $array, mixed $min, mixed $max, callable|string $message = ''): iterable
5317 {
5318 static::isIterable($array);
5319
5320 foreach ($array as $entry) {
5321 static::countBetween($entry, $min, $max, $message);
5322 }
5323
5324 return $array;
5325 }
5326
5327 /**
5328 * @param string|callable():string $message
5329 *
5330 * @return iterable<Countable|array|null>
5331 *
5332 * @throws InvalidArgumentException
5333 */
5334 public static function allNullOrCountBetween(mixed $array, mixed $min, mixed $max, callable|string $message = ''): iterable
5335 {
5336 static::isIterable($array);
5337
5338 foreach ($array as $entry) {
5339 null === $entry || static::countBetween($entry, $min, $max, $message);
5340 }
5341
5342 return $array;
5343 }
5344
5345 /**
5346 * @psalm-pure
5347 *
5348 * @psalm-assert list<mixed>|null $array
5349 *
5350 * @param string|callable():string $message
5351 *
5352 * @return list<mixed>|null
5353 *
5354 * @throws InvalidArgumentException
5355 */
5356 public static function nullOrIsList(mixed $array, callable|string $message = ''): ?array
5357 {
5358 null === $array || static::isList($array, $message);
5359
5360 return $array;
5361 }
5362
5363 /**
5364 * @psalm-pure
5365 *
5366 * @psalm-assert iterable<list<mixed>> $array
5367 *
5368 * @param string|callable():string $message
5369 *
5370 * @return iterable<list<mixed>>
5371 *
5372 * @throws InvalidArgumentException
5373 */
5374 public static function allIsList(mixed $array, callable|string $message = ''): iterable
5375 {
5376 static::isIterable($array);
5377
5378 foreach ($array as $entry) {
5379 static::isList($entry, $message);
5380 }
5381
5382 return $array;
5383 }
5384
5385 /**
5386 * @psalm-pure
5387 *
5388 * @psalm-assert iterable<list<mixed>|null> $array
5389 *
5390 * @param string|callable():string $message
5391 *
5392 * @return iterable<list<mixed>|null>
5393 *
5394 * @throws InvalidArgumentException
5395 */
5396 public static function allNullOrIsList(mixed $array, callable|string $message = ''): iterable
5397 {
5398 static::isIterable($array);
5399
5400 foreach ($array as $entry) {
5401 null === $entry || static::isList($entry, $message);
5402 }
5403
5404 return $array;
5405 }
5406
5407 /**
5408 * @psalm-pure
5409 *
5410 * @psalm-assert non-empty-list<mixed>|null $array
5411 *
5412 * @param string|callable():string $message
5413 *
5414 * @return non-empty-list<mixed>|null
5415 *
5416 * @throws InvalidArgumentException
5417 */
5418 public static function nullOrIsNonEmptyList(mixed $array, callable|string $message = ''): ?array
5419 {
5420 null === $array || static::isNonEmptyList($array, $message);
5421
5422 return $array;
5423 }
5424
5425 /**
5426 * @psalm-pure
5427 *
5428 * @psalm-assert iterable<non-empty-list<mixed>> $array
5429 *
5430 * @param string|callable():string $message
5431 *
5432 * @return iterable<non-empty-list<mixed>>
5433 *
5434 * @throws InvalidArgumentException
5435 */
5436 public static function allIsNonEmptyList(mixed $array, callable|string $message = ''): iterable
5437 {
5438 static::isIterable($array);
5439
5440 foreach ($array as $entry) {
5441 static::isNonEmptyList($entry, $message);
5442 }
5443
5444 return $array;
5445 }
5446
5447 /**
5448 * @psalm-pure
5449 *
5450 * @psalm-assert iterable<non-empty-list<mixed>|null> $array
5451 *
5452 * @param string|callable():string $message
5453 *
5454 * @return iterable<non-empty-list<mixed>|null>
5455 *
5456 * @throws InvalidArgumentException
5457 */
5458 public static function allNullOrIsNonEmptyList(mixed $array, callable|string $message = ''): iterable
5459 {
5460 static::isIterable($array);
5461
5462 foreach ($array as $entry) {
5463 null === $entry || static::isNonEmptyList($entry, $message);
5464 }
5465
5466 return $array;
5467 }
5468
5469 /**
5470 * @psalm-pure
5471 *
5472 * @template T
5473 * @psalm-assert array<string, T>|null $array
5474 *
5475 * @param mixed|array<array-key, T>|null $array
5476 * @param string|callable():string $message
5477 *
5478 * @return array<string, T>|null
5479 *
5480 * @throws InvalidArgumentException
5481 */
5482 public static function nullOrIsMap(mixed $array, callable|string $message = ''): ?array
5483 {
5484 null === $array || static::isMap($array, $message);
5485
5486 return $array;
5487 }
5488
5489 /**
5490 * @psalm-pure
5491 *
5492 * @template T
5493 * @psalm-assert iterable<array<string, T>> $array
5494 *
5495 * @param iterable<mixed|array<array-key, T>> $array
5496 * @param string|callable():string $message
5497 *
5498 * @return iterable<array<string, T>>
5499 *
5500 * @throws InvalidArgumentException
5501 */
5502 public static function allIsMap(mixed $array, callable|string $message = ''): iterable
5503 {
5504 static::isIterable($array);
5505
5506 foreach ($array as $entry) {
5507 static::isMap($entry, $message);
5508 }
5509
5510 return $array;
5511 }
5512
5513 /**
5514 * @psalm-pure
5515 *
5516 * @template T
5517 * @psalm-assert iterable<array<string, T>|null> $array
5518 *
5519 * @param iterable<mixed|array<array-key, T>|null> $array
5520 * @param string|callable():string $message
5521 *
5522 * @return iterable<array<string, T>|null>
5523 *
5524 * @throws InvalidArgumentException
5525 */
5526 public static function allNullOrIsMap(mixed $array, callable|string $message = ''): iterable
5527 {
5528 static::isIterable($array);
5529
5530 foreach ($array as $entry) {
5531 null === $entry || static::isMap($entry, $message);
5532 }
5533
5534 return $array;
5535 }
5536
5537 /**
5538 * @param callable|null $callable
5539 * @param string|callable():string $message
5540 *
5541 * @return Closure|callable-string|null
5542 *
5543 * @throws InvalidArgumentException
5544 */
5545 public static function nullOrIsStatic(mixed $callable, callable|string $message = ''): Closure|string|null
5546 {
5547 null === $callable || static::isStatic($callable, $message);
5548
5549 return $callable;
5550 }
5551
5552 /**
5553 * @param iterable<callable> $callable
5554 * @param string|callable():string $message
5555 *
5556 * @return iterable<Closure|callable-string>
5557 *
5558 * @throws InvalidArgumentException
5559 */
5560 public static function allIsStatic(mixed $callable, callable|string $message = ''): iterable
5561 {
5562 static::isIterable($callable);
5563
5564 foreach ($callable as $entry) {
5565 static::isStatic($entry, $message);
5566 }
5567
5568 return $callable;
5569 }
5570
5571 /**
5572 * @param iterable<callable|null> $callable
5573 * @param string|callable():string $message
5574 *
5575 * @return iterable<Closure|callable-string|null>
5576 *
5577 * @throws InvalidArgumentException
5578 */
5579 public static function allNullOrIsStatic(mixed $callable, callable|string $message = ''): iterable
5580 {
5581 static::isIterable($callable);
5582
5583 foreach ($callable as $entry) {
5584 null === $entry || static::isStatic($entry, $message);
5585 }
5586
5587 return $callable;
5588 }
5589
5590 /**
5591 * @param callable|null $callable
5592 * @param string|callable():string $message
5593 *
5594 * @return Closure|callable-string|null
5595 *
5596 * @throws InvalidArgumentException
5597 */
5598 public static function nullOrNotStatic(mixed $callable, callable|string $message = ''): Closure|string|null
5599 {
5600 null === $callable || static::notStatic($callable, $message);
5601
5602 return $callable;
5603 }
5604
5605 /**
5606 * @param iterable<callable> $callable
5607 * @param string|callable():string $message
5608 *
5609 * @return iterable<Closure|callable-string>
5610 *
5611 * @throws InvalidArgumentException
5612 */
5613 public static function allNotStatic(mixed $callable, callable|string $message = ''): iterable
5614 {
5615 static::isIterable($callable);
5616
5617 foreach ($callable as $entry) {
5618 static::notStatic($entry, $message);
5619 }
5620
5621 return $callable;
5622 }
5623
5624 /**
5625 * @param iterable<callable|null> $callable
5626 * @param string|callable():string $message
5627 *
5628 * @return iterable<Closure|callable-string|null>
5629 *
5630 * @throws InvalidArgumentException
5631 */
5632 public static function allNullOrNotStatic(mixed $callable, callable|string $message = ''): iterable
5633 {
5634 static::isIterable($callable);
5635
5636 foreach ($callable as $entry) {
5637 null === $entry || static::notStatic($entry, $message);
5638 }
5639
5640 return $callable;
5641 }
5642
5643 /**
5644 * @psalm-pure
5645 *
5646 * @template T
5647 *
5648 * @param array<string, T>|null $array
5649 * @param string|callable():string $message
5650 *
5651 * @return non-empty-array<string, T>|null
5652 *
5653 * @throws InvalidArgumentException
5654 */
5655 public static function nullOrIsNonEmptyMap(mixed $array, callable|string $message = ''): ?array
5656 {
5657 null === $array || static::isNonEmptyMap($array, $message);
5658
5659 return $array;
5660 }
5661
5662 /**
5663 * @psalm-pure
5664 *
5665 * @template T
5666 *
5667 * @param iterable<array<string, T>> $array
5668 * @param string|callable():string $message
5669 *
5670 * @return iterable<non-empty-array<string, T>>
5671 *
5672 * @throws InvalidArgumentException
5673 */
5674 public static function allIsNonEmptyMap(mixed $array, callable|string $message = ''): iterable
5675 {
5676 static::isIterable($array);
5677
5678 foreach ($array as $entry) {
5679 static::isNonEmptyMap($entry, $message);
5680 }
5681
5682 return $array;
5683 }
5684
5685 /**
5686 * @psalm-pure
5687 *
5688 * @template T
5689 * @psalm-assert iterable<array<string, T>|null> $array
5690 * @psalm-assert iterable<!empty|null> $array
5691 *
5692 * @param iterable<array<string, T>|null> $array
5693 * @param string|callable():string $message
5694 *
5695 * @return iterable<non-empty-array<string, T>|null>
5696 *
5697 * @throws InvalidArgumentException
5698 */
5699 public static function allNullOrIsNonEmptyMap(mixed $array, callable|string $message = ''): iterable
5700 {
5701 static::isIterable($array);
5702
5703 foreach ($array as $entry) {
5704 null === $entry || static::isNonEmptyMap($entry, $message);
5705 }
5706
5707 return $array;
5708 }
5709
5710 /**
5711 * @psalm-pure
5712 *
5713 * @param string|callable():string $message
5714 *
5715 * @return string|null
5716 *
5717 * @throws InvalidArgumentException
5718 */
5719 public static function nullOrUuid(mixed $value, callable|string $message = ''): ?string
5720 {
5721 null === $value || static::uuid($value, $message);
5722
5723 return $value;
5724 }
5725
5726 /**
5727 * @psalm-pure
5728 *
5729 * @param string|callable():string $message
5730 *
5731 * @return iterable<string>
5732 *
5733 * @throws InvalidArgumentException
5734 */
5735 public static function allUuid(mixed $value, callable|string $message = ''): iterable
5736 {
5737 static::isIterable($value);
5738
5739 foreach ($value as $entry) {
5740 static::uuid($entry, $message);
5741 }
5742
5743 return $value;
5744 }
5745
5746 /**
5747 * @psalm-pure
5748 *
5749 * @param string|callable():string $message
5750 *
5751 * @return iterable<string|null>
5752 *
5753 * @throws InvalidArgumentException
5754 */
5755 public static function allNullOrUuid(mixed $value, callable|string $message = ''): iterable
5756 {
5757 static::isIterable($value);
5758
5759 foreach ($value as $entry) {
5760 null === $entry || static::uuid($entry, $message);
5761 }
5762
5763 return $value;
5764 }
5765
5766 /**
5767 * @template T as callable
5768 *
5769 * @param T|null $expression
5770 * @param class-string<Throwable> $class
5771 * @param string|callable():string $message
5772 *
5773 * @return T|null
5774 *
5775 * @throws InvalidArgumentException
5776 */
5777 public static function nullOrThrows(mixed $expression, string $class = 'Throwable', callable|string $message = ''): ?callable
5778 {
5779 null === $expression || static::throws($expression, $class, $message);
5780
5781 return $expression;
5782 }
5783
5784 /**
5785 * @template T as callable
5786 *
5787 * @param iterable<T> $expression
5788 * @param class-string<Throwable> $class
5789 * @param string|callable():string $message
5790 *
5791 * @return iterable<T>
5792 *
5793 * @throws InvalidArgumentException
5794 */
5795 public static function allThrows(mixed $expression, string $class = 'Throwable', callable|string $message = ''): iterable
5796 {
5797 static::isIterable($expression);
5798
5799 foreach ($expression as $entry) {
5800 static::throws($entry, $class, $message);
5801 }
5802
5803 return $expression;
5804 }
5805
5806 /**
5807 * @template T as callable|null
5808 *
5809 * @param iterable<T> $expression
5810 * @param class-string<Throwable> $class
5811 * @param string|callable():string $message
5812 *
5813 * @return iterable<T>
5814 *
5815 * @throws InvalidArgumentException
5816 */
5817 public static function allNullOrThrows(mixed $expression, string $class = 'Throwable', callable|string $message = ''): iterable
5818 {
5819 static::isIterable($expression);
5820
5821 foreach ($expression as $entry) {
5822 null === $entry || static::throws($entry, $class, $message);
5823 }
5824
5825 return $expression;
5826 }
5827 }