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