| Conditions | 1 |
| Total Lines | 554 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 510 | public function skipOnEmptyDataProvider(): array |
||
| 511 | { |
||
| 512 | $validator = new Validator(); |
||
| 513 | $rules = [ |
||
| 514 | 'name' => [new Length(min: 8)], |
||
| 515 | 'age' => [new Integer(min: 18)], |
||
| 516 | ]; |
||
| 517 | $stringLessThanMinMessage = 'This value must contain at least 8 characters.'; |
||
| 518 | $incorrectNumberMessage = 'The allowed types are integer, float and string.'; |
||
| 519 | $intMessage = 'Value must be an integer.'; |
||
| 520 | $intLessThanMinMessage = 'Value must be no less than 18.'; |
||
| 521 | |||
| 522 | return [ |
||
| 523 | 'rule / validator, skipOnEmpty: false, value not passed' => [ |
||
| 524 | $validator, |
||
| 525 | new ArrayDataSet([ |
||
| 526 | 'name' => 'Dmitriy', |
||
| 527 | ]), |
||
| 528 | $rules, |
||
| 529 | [ |
||
| 530 | new Error($stringLessThanMinMessage, [ |
||
| 531 | 'min' => 8, |
||
| 532 | 'attribute' => 'name', |
||
| 533 | 'number' => 7, |
||
| 534 | ], ['name']), |
||
| 535 | new Error($incorrectNumberMessage, [ |
||
| 536 | 'attribute' => 'age', |
||
| 537 | 'type' => 'null', |
||
| 538 | ], ['age']), |
||
| 539 | ], |
||
| 540 | ], |
||
| 541 | 'rule / validator, skipOnEmpty: false, value is empty' => [ |
||
| 542 | $validator, |
||
| 543 | new ArrayDataSet([ |
||
| 544 | 'name' => 'Dmitriy', |
||
| 545 | 'age' => null, |
||
| 546 | ]), |
||
| 547 | $rules, |
||
| 548 | [ |
||
| 549 | new Error($stringLessThanMinMessage, [ |
||
| 550 | 'min' => 8, |
||
| 551 | 'attribute' => 'name', |
||
| 552 | 'number' => 7, |
||
| 553 | ], ['name']), |
||
| 554 | new Error($incorrectNumberMessage, [ |
||
| 555 | 'attribute' => 'age', |
||
| 556 | 'type' => 'null', |
||
| 557 | ], ['age']), |
||
| 558 | ], |
||
| 559 | ], |
||
| 560 | 'rule / validator, skipOnEmpty: false, value is not empty' => [ |
||
| 561 | $validator, |
||
| 562 | new ArrayDataSet([ |
||
| 563 | 'name' => 'Dmitriy', |
||
| 564 | 'age' => 17, |
||
| 565 | ]), |
||
| 566 | $rules, |
||
| 567 | [ |
||
| 568 | new Error($stringLessThanMinMessage, [ |
||
| 569 | 'min' => 8, |
||
| 570 | 'attribute' => 'name', |
||
| 571 | 'number' => 7, |
||
| 572 | ], ['name']), |
||
| 573 | new Error($intLessThanMinMessage, [ |
||
| 574 | 'min' => 18, |
||
| 575 | 'attribute' => 'age', |
||
| 576 | 'value' => 17, |
||
| 577 | ], ['age']), |
||
| 578 | ], |
||
| 579 | ], |
||
| 580 | |||
| 581 | 'rule, skipOnEmpty: true, value not passed' => [ |
||
| 582 | $validator, |
||
| 583 | new ArrayDataSet([ |
||
| 584 | 'name' => 'Dmitriy', |
||
| 585 | ]), |
||
| 586 | [ |
||
| 587 | 'name' => [new Length(min: 8)], |
||
| 588 | 'age' => [new Integer(min: 18, skipOnEmpty: true)], |
||
| 589 | ], |
||
| 590 | [ |
||
| 591 | new Error($stringLessThanMinMessage, [ |
||
| 592 | 'min' => 8, |
||
| 593 | 'attribute' => 'name', |
||
| 594 | 'number' => 7, |
||
| 595 | ], ['name']), |
||
| 596 | ], |
||
| 597 | ], |
||
| 598 | 'rule, skipOnEmpty: true, value is empty (null)' => [ |
||
| 599 | $validator, |
||
| 600 | new ArrayDataSet([ |
||
| 601 | 'name' => 'Dmitriy', |
||
| 602 | 'age' => null, |
||
| 603 | ]), |
||
| 604 | [ |
||
| 605 | 'name' => [new Length(min: 8)], |
||
| 606 | 'age' => [new Integer(min: 18, skipOnEmpty: true)], |
||
| 607 | ], |
||
| 608 | [ |
||
| 609 | new Error($stringLessThanMinMessage, [ |
||
| 610 | 'min' => 8, |
||
| 611 | 'attribute' => 'name', |
||
| 612 | 'number' => 7, |
||
| 613 | ], ['name']), |
||
| 614 | ], |
||
| 615 | ], |
||
| 616 | 'rule, skipOnEmpty: true, value is empty (empty string after trimming), trimString is false' => [ |
||
| 617 | $validator, |
||
| 618 | new ArrayDataSet([ |
||
| 619 | 'name' => ' ', |
||
| 620 | 'age' => 17, |
||
| 621 | ]), |
||
| 622 | [ |
||
| 623 | 'name' => [new Length(min: 8, skipOnEmpty: true)], |
||
| 624 | 'age' => [new Integer(min: 18)], |
||
| 625 | ], |
||
| 626 | [ |
||
| 627 | new Error($stringLessThanMinMessage, [ |
||
| 628 | 'min' => 8, |
||
| 629 | 'attribute' => 'name', |
||
| 630 | 'number' => 1, |
||
| 631 | ], ['name']), |
||
| 632 | new Error($intLessThanMinMessage, [ |
||
| 633 | 'min' => 18, |
||
| 634 | 'attribute' => 'age', |
||
| 635 | 'value' => 17, |
||
| 636 | ], ['age']), |
||
| 637 | ], |
||
| 638 | ], |
||
| 639 | 'rule, skipOnEmpty: SkipOnEmpty, value is empty (empty string after trimming), trimString is true' => [ |
||
| 640 | $validator, |
||
| 641 | new ArrayDataSet([ |
||
| 642 | 'name' => ' ', |
||
| 643 | 'age' => 17, |
||
| 644 | ]), |
||
| 645 | [ |
||
| 646 | 'name' => [new Length(min: 8, skipOnEmpty: new WhenEmpty(trimString: true))], |
||
| 647 | 'age' => [new Integer(min: 18)], |
||
| 648 | ], |
||
| 649 | [ |
||
| 650 | new Error($intLessThanMinMessage, [ |
||
| 651 | 'min' => 18, |
||
| 652 | 'attribute' => 'age', |
||
| 653 | 'value' => 17, |
||
| 654 | ], ['age']), |
||
| 655 | ], |
||
| 656 | ], |
||
| 657 | 'rule, skipOnEmpty: true, value is not empty' => [ |
||
| 658 | $validator, |
||
| 659 | new ArrayDataSet([ |
||
| 660 | 'name' => 'Dmitriy', |
||
| 661 | 'age' => 17, |
||
| 662 | ]), |
||
| 663 | [ |
||
| 664 | 'name' => [new Length(min: 8)], |
||
| 665 | 'age' => [new Integer(min: 18, skipOnEmpty: true)], |
||
| 666 | ], |
||
| 667 | [ |
||
| 668 | new Error($stringLessThanMinMessage, [ |
||
| 669 | 'min' => 8, |
||
| 670 | 'attribute' => 'name', |
||
| 671 | 'number' => 7, |
||
| 672 | ], ['name']), |
||
| 673 | new Error($intLessThanMinMessage, [ |
||
| 674 | 'min' => 18, |
||
| 675 | 'attribute' => 'age', |
||
| 676 | 'value' => 17, |
||
| 677 | ], ['age']), |
||
| 678 | ], |
||
| 679 | ], |
||
| 680 | |||
| 681 | 'rule, skipOnEmpty: SkipOnNull, value not passed' => [ |
||
| 682 | $validator, |
||
| 683 | new ArrayDataSet([ |
||
| 684 | 'name' => 'Dmitriy', |
||
| 685 | ]), |
||
| 686 | [ |
||
| 687 | 'name' => [new Length(min: 8)], |
||
| 688 | 'age' => [new Integer(min: 18, skipOnEmpty: new WhenNull())], |
||
| 689 | ], |
||
| 690 | [ |
||
| 691 | new Error($stringLessThanMinMessage, [ |
||
| 692 | 'min' => 8, |
||
| 693 | 'attribute' => 'name', |
||
| 694 | 'number' => 7, |
||
| 695 | ], ['name']), |
||
| 696 | ], |
||
| 697 | ], |
||
| 698 | 'rule, skipOnEmpty: SkipOnNull, value is empty' => [ |
||
| 699 | $validator, |
||
| 700 | new ArrayDataSet([ |
||
| 701 | 'name' => 'Dmitriy', |
||
| 702 | 'age' => null, |
||
| 703 | ]), |
||
| 704 | [ |
||
| 705 | 'name' => [new Length(min: 8)], |
||
| 706 | 'age' => [new Integer(min: 18, skipOnEmpty: new WhenNull())], |
||
| 707 | ], |
||
| 708 | [ |
||
| 709 | new Error($stringLessThanMinMessage, [ |
||
| 710 | 'min' => 8, |
||
| 711 | 'attribute' => 'name', |
||
| 712 | 'number' => 7, |
||
| 713 | ], ['name']), |
||
| 714 | ], |
||
| 715 | ], |
||
| 716 | 'rule, skipOnEmpty: SkipOnNull, value is not empty' => [ |
||
| 717 | $validator, |
||
| 718 | new ArrayDataSet([ |
||
| 719 | 'name' => 'Dmitriy', |
||
| 720 | 'age' => 17, |
||
| 721 | ]), |
||
| 722 | [ |
||
| 723 | 'name' => [new Length(min: 8)], |
||
| 724 | 'age' => [new Integer(min: 18, skipOnEmpty: new WhenNull())], |
||
| 725 | ], |
||
| 726 | [ |
||
| 727 | new Error($stringLessThanMinMessage, [ |
||
| 728 | 'min' => 8, |
||
| 729 | 'attribute' => 'name', |
||
| 730 | 'number' => 7, |
||
| 731 | ], ['name']), |
||
| 732 | new Error($intLessThanMinMessage, [ |
||
| 733 | 'min' => 18, |
||
| 734 | 'attribute' => 'age', |
||
| 735 | 'value' => 17, |
||
| 736 | ], ['age']), |
||
| 737 | ], |
||
| 738 | ], |
||
| 739 | 'rule, skipOnEmpty: SkipOnNull, value is not empty (empty string)' => [ |
||
| 740 | $validator, |
||
| 741 | new ArrayDataSet([ |
||
| 742 | 'name' => 'Dmitriy', |
||
| 743 | 'age' => '', |
||
| 744 | ]), |
||
| 745 | [ |
||
| 746 | 'name' => [new Length(min: 8)], |
||
| 747 | 'age' => [new Integer(min: 18, skipOnEmpty: new WhenNull())], |
||
| 748 | ], |
||
| 749 | [ |
||
| 750 | new Error($stringLessThanMinMessage, [ |
||
| 751 | 'min' => 8, |
||
| 752 | 'attribute' => 'name', |
||
| 753 | 'number' => 7, |
||
| 754 | ], ['name']), |
||
| 755 | new Error($intMessage, [ |
||
| 756 | 'attribute' => 'age', |
||
| 757 | 'value' => '', |
||
| 758 | ], ['age']), |
||
| 759 | ], |
||
| 760 | ], |
||
| 761 | |||
| 762 | 'rule, skipOnEmpty: custom callback, value not passed' => [ |
||
| 763 | $validator, |
||
| 764 | new ArrayDataSet([ |
||
| 765 | 'name' => 'Dmitriy', |
||
| 766 | ]), |
||
| 767 | [ |
||
| 768 | 'name' => [new Length(min: 8)], |
||
| 769 | 'age' => [ |
||
| 770 | new Integer( |
||
| 771 | min: 18, |
||
| 772 | skipOnEmpty: static fn (mixed $value, bool $isAttributeMissing): bool => $value === 0 |
||
| 773 | ), |
||
| 774 | ], |
||
| 775 | ], |
||
| 776 | [ |
||
| 777 | new Error($stringLessThanMinMessage, [ |
||
| 778 | 'min' => 8, |
||
| 779 | 'attribute' => 'name', |
||
| 780 | 'number' => 7, |
||
| 781 | ], ['name']), |
||
| 782 | new Error($incorrectNumberMessage, [ |
||
| 783 | 'attribute' => 'age', |
||
| 784 | 'type' => 'null', |
||
| 785 | ], ['age']), |
||
| 786 | ], |
||
| 787 | ], |
||
| 788 | 'rule, skipOnEmpty: custom callback, value is empty' => [ |
||
| 789 | $validator, |
||
| 790 | new ArrayDataSet([ |
||
| 791 | 'name' => 'Dmitriy', |
||
| 792 | 'age' => 0, |
||
| 793 | ]), |
||
| 794 | [ |
||
| 795 | 'name' => [new Length(min: 8)], |
||
| 796 | 'age' => [ |
||
| 797 | new Integer( |
||
| 798 | min: 18, |
||
| 799 | skipOnEmpty: static fn (mixed $value, bool $isAttributeMissing): bool => $value === 0 |
||
| 800 | ), |
||
| 801 | ], |
||
| 802 | ], |
||
| 803 | [ |
||
| 804 | new Error($stringLessThanMinMessage, [ |
||
| 805 | 'min' => 8, |
||
| 806 | 'attribute' => 'name', |
||
| 807 | 'number' => 7, |
||
| 808 | ], ['name']), |
||
| 809 | ], |
||
| 810 | ], |
||
| 811 | 'rule, skipOnEmpty, custom callback, value is not empty' => [ |
||
| 812 | $validator, |
||
| 813 | new ArrayDataSet([ |
||
| 814 | 'name' => 'Dmitriy', |
||
| 815 | 'age' => 17, |
||
| 816 | ]), |
||
| 817 | [ |
||
| 818 | 'name' => [new Length(min: 8)], |
||
| 819 | 'age' => [ |
||
| 820 | new Integer( |
||
| 821 | min: 18, |
||
| 822 | skipOnEmpty: static fn (mixed $value, bool $isAttributeMissing): bool => $value === 0 |
||
| 823 | ), |
||
| 824 | ], |
||
| 825 | ], |
||
| 826 | [ |
||
| 827 | new Error($stringLessThanMinMessage, [ |
||
| 828 | 'min' => 8, |
||
| 829 | 'attribute' => 'name', |
||
| 830 | 'number' => 7, |
||
| 831 | ], ['name']), |
||
| 832 | new Error($intLessThanMinMessage, [ |
||
| 833 | 'min' => 18, |
||
| 834 | 'attribute' => 'age', |
||
| 835 | 'value' => 17, |
||
| 836 | ], ['age']), |
||
| 837 | ], |
||
| 838 | ], |
||
| 839 | 'rule, skipOnEmpty, custom callback, value is not empty (null)' => [ |
||
| 840 | $validator, |
||
| 841 | new ArrayDataSet([ |
||
| 842 | 'name' => 'Dmitriy', |
||
| 843 | 'age' => null, |
||
| 844 | ]), |
||
| 845 | [ |
||
| 846 | 'name' => [new Length(min: 8)], |
||
| 847 | 'age' => [ |
||
| 848 | new Integer( |
||
| 849 | min: 18, |
||
| 850 | skipOnEmpty: static fn (mixed $value, bool $isAttributeMissing): bool => $value === 0 |
||
| 851 | ), |
||
| 852 | ], |
||
| 853 | ], |
||
| 854 | [ |
||
| 855 | new Error($stringLessThanMinMessage, [ |
||
| 856 | 'min' => 8, |
||
| 857 | 'attribute' => 'name', |
||
| 858 | 'number' => 7, |
||
| 859 | ], ['name']), |
||
| 860 | new Error($incorrectNumberMessage, [ |
||
| 861 | 'attribute' => 'age', |
||
| 862 | 'type' => 'null', |
||
| 863 | ], ['age']), |
||
| 864 | ], |
||
| 865 | ], |
||
| 866 | |||
| 867 | 'validator, skipOnEmpty: true, value not passed' => [ |
||
| 868 | new Validator(defaultSkipOnEmpty: true), |
||
| 869 | new ArrayDataSet([ |
||
| 870 | 'name' => 'Dmitriy', |
||
| 871 | ]), |
||
| 872 | $rules, |
||
| 873 | [ |
||
| 874 | new Error($stringLessThanMinMessage, [ |
||
| 875 | 'min' => 8, |
||
| 876 | 'attribute' => 'name', |
||
| 877 | 'number' => 7, |
||
| 878 | ], ['name']), |
||
| 879 | ], |
||
| 880 | ], |
||
| 881 | 'validator, skipOnEmpty: true, value is empty' => [ |
||
| 882 | new Validator(defaultSkipOnEmpty: true), |
||
| 883 | new ArrayDataSet([ |
||
| 884 | 'name' => 'Dmitriy', |
||
| 885 | 'age' => null, |
||
| 886 | ]), |
||
| 887 | $rules, |
||
| 888 | [ |
||
| 889 | new Error($stringLessThanMinMessage, [ |
||
| 890 | 'min' => 8, |
||
| 891 | 'attribute' => 'name', |
||
| 892 | 'number' => 7, |
||
| 893 | ], ['name']), |
||
| 894 | ], |
||
| 895 | ], |
||
| 896 | 'validator, skipOnEmpty: true, value is not empty' => [ |
||
| 897 | new Validator(defaultSkipOnEmpty: true), |
||
| 898 | new ArrayDataSet([ |
||
| 899 | 'name' => 'Dmitriy', |
||
| 900 | 'age' => 17, |
||
| 901 | ]), |
||
| 902 | $rules, |
||
| 903 | [ |
||
| 904 | new Error($stringLessThanMinMessage, [ |
||
| 905 | 'min' => 8, |
||
| 906 | 'attribute' => 'name', |
||
| 907 | 'number' => 7, |
||
| 908 | ], ['name']), |
||
| 909 | new Error($intLessThanMinMessage, [ |
||
| 910 | 'min' => 18, |
||
| 911 | 'attribute' => 'age', |
||
| 912 | 'value' => 17, |
||
| 913 | ], ['age']), |
||
| 914 | ], |
||
| 915 | ], |
||
| 916 | |||
| 917 | 'validator, skipOnEmpty: SkipOnNull, value not passed' => [ |
||
| 918 | new Validator(defaultSkipOnEmpty: new WhenNull()), |
||
| 919 | new ArrayDataSet([ |
||
| 920 | 'name' => 'Dmitriy', |
||
| 921 | ]), |
||
| 922 | $rules, |
||
| 923 | [ |
||
| 924 | new Error($stringLessThanMinMessage, [ |
||
| 925 | 'min' => 8, |
||
| 926 | 'attribute' => 'name', |
||
| 927 | 'number' => 7, |
||
| 928 | ], ['name']), |
||
| 929 | ], |
||
| 930 | ], |
||
| 931 | 'validator, skipOnEmpty: SkipOnNull, value is empty' => [ |
||
| 932 | new Validator(defaultSkipOnEmpty: new WhenNull()), |
||
| 933 | new ArrayDataSet([ |
||
| 934 | 'name' => 'Dmitriy', |
||
| 935 | 'age' => null, |
||
| 936 | ]), |
||
| 937 | $rules, |
||
| 938 | [ |
||
| 939 | new Error($stringLessThanMinMessage, [ |
||
| 940 | 'min' => 8, |
||
| 941 | 'attribute' => 'name', |
||
| 942 | 'number' => 7, |
||
| 943 | ], ['name']), |
||
| 944 | ], |
||
| 945 | ], |
||
| 946 | 'validator, skipOnEmpty: SkipOnNull, value is not empty' => [ |
||
| 947 | new Validator(defaultSkipOnEmpty: new WhenNull()), |
||
| 948 | new ArrayDataSet([ |
||
| 949 | 'name' => 'Dmitriy', |
||
| 950 | 'age' => 17, |
||
| 951 | ]), |
||
| 952 | $rules, |
||
| 953 | [ |
||
| 954 | new Error($stringLessThanMinMessage, [ |
||
| 955 | 'min' => 8, |
||
| 956 | 'attribute' => 'name', |
||
| 957 | 'number' => 7, |
||
| 958 | ], ['name']), |
||
| 959 | new Error($intLessThanMinMessage, [ |
||
| 960 | 'min' => 18, |
||
| 961 | 'attribute' => 'age', |
||
| 962 | 'value' => 17, |
||
| 963 | ], ['age']), |
||
| 964 | ], |
||
| 965 | ], |
||
| 966 | 'validator, skipOnEmpty: SkipOnNull, value is not empty (empty string)' => [ |
||
| 967 | new Validator(defaultSkipOnEmpty: new WhenNull()), |
||
| 968 | new ArrayDataSet([ |
||
| 969 | 'name' => 'Dmitriy', |
||
| 970 | 'age' => '', |
||
| 971 | ]), |
||
| 972 | $rules, |
||
| 973 | [ |
||
| 974 | new Error($stringLessThanMinMessage, [ |
||
| 975 | 'min' => 8, |
||
| 976 | 'attribute' => 'name', |
||
| 977 | 'number' => 7, |
||
| 978 | ], ['name']), |
||
| 979 | new Error($intMessage, [ |
||
| 980 | 'attribute' => 'age', |
||
| 981 | 'value' => '', |
||
| 982 | ], ['age']), |
||
| 983 | ], |
||
| 984 | ], |
||
| 985 | |||
| 986 | 'validator, skipOnEmpty: custom callback, value not passed' => [ |
||
| 987 | new Validator( |
||
| 988 | defaultSkipOnEmpty: static fn (mixed $value, bool $isAttributeMissing): bool => $value === 0 |
||
| 989 | ), |
||
| 990 | new ArrayDataSet([ |
||
| 991 | 'name' => 'Dmitriy', |
||
| 992 | ]), |
||
| 993 | $rules, |
||
| 994 | [ |
||
| 995 | new Error($stringLessThanMinMessage, [ |
||
| 996 | 'min' => 8, |
||
| 997 | 'attribute' => 'name', |
||
| 998 | 'number' => 7, |
||
| 999 | ], ['name']), |
||
| 1000 | new Error($incorrectNumberMessage, [ |
||
| 1001 | 'attribute' => 'age', |
||
| 1002 | 'type' => 'null', |
||
| 1003 | ], ['age']), |
||
| 1004 | ], |
||
| 1005 | ], |
||
| 1006 | 'validator, skipOnEmpty: custom callback, value is empty' => [ |
||
| 1007 | new Validator( |
||
| 1008 | defaultSkipOnEmpty: static fn (mixed $value, bool $isAttributeMissing): bool => $value === 0 |
||
| 1009 | ), |
||
| 1010 | new ArrayDataSet([ |
||
| 1011 | 'name' => 'Dmitriy', |
||
| 1012 | 'age' => 0, |
||
| 1013 | ]), |
||
| 1014 | $rules, |
||
| 1015 | [ |
||
| 1016 | new Error($stringLessThanMinMessage, [ |
||
| 1017 | 'min' => 8, |
||
| 1018 | 'attribute' => 'name', |
||
| 1019 | 'number' => 7, |
||
| 1020 | ], ['name']), |
||
| 1021 | ], |
||
| 1022 | ], |
||
| 1023 | 'validator, skipOnEmpty: custom callback, value is not empty' => [ |
||
| 1024 | new Validator( |
||
| 1025 | defaultSkipOnEmpty: static fn (mixed $value, bool $isAttributeMissing): bool => $value === 0 |
||
| 1026 | ), |
||
| 1027 | new ArrayDataSet([ |
||
| 1028 | 'name' => 'Dmitriy', |
||
| 1029 | 'age' => 17, |
||
| 1030 | ]), |
||
| 1031 | $rules, |
||
| 1032 | [ |
||
| 1033 | new Error($stringLessThanMinMessage, [ |
||
| 1034 | 'min' => 8, |
||
| 1035 | 'attribute' => 'name', |
||
| 1036 | 'number' => 7, |
||
| 1037 | ], ['name']), |
||
| 1038 | new Error($intLessThanMinMessage, [ |
||
| 1039 | 'min' => 18, |
||
| 1040 | 'attribute' => 'age', |
||
| 1041 | 'value' => 17, |
||
| 1042 | ], ['age']), |
||
| 1043 | ], |
||
| 1044 | ], |
||
| 1045 | 'validator, skipOnEmpty: custom callback, value is not empty (null)' => [ |
||
| 1046 | new Validator( |
||
| 1047 | defaultSkipOnEmpty: static fn (mixed $value, bool $isAttributeMissing): bool => $value === 0 |
||
| 1048 | ), |
||
| 1049 | new ArrayDataSet([ |
||
| 1050 | 'name' => 'Dmitriy', |
||
| 1051 | 'age' => null, |
||
| 1052 | ]), |
||
| 1053 | $rules, |
||
| 1054 | [ |
||
| 1055 | new Error($stringLessThanMinMessage, [ |
||
| 1056 | 'min' => 8, |
||
| 1057 | 'attribute' => 'name', |
||
| 1058 | 'number' => 7, |
||
| 1059 | ], ['name']), |
||
| 1060 | new Error($incorrectNumberMessage, [ |
||
| 1061 | 'attribute' => 'age', |
||
| 1062 | 'type' => 'null', |
||
| 1063 | ], ['age']), |
||
| 1064 | ], |
||
| 1412 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.