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