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