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