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