| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 70 | 
| 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 //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName | ||
| 86 | 	public function rule_provider() { | ||
| 87 | /** | ||
| 88 | * Data format. | ||
| 89 | * | ||
| 90 | * Param 1 -> section | ||
| 91 | * Param 2 -> rule | ||
| 92 | * Param 3 -> password | ||
| 93 | * Param 4 -> expected_result | ||
| 94 | * Param 5 -> output_message | ||
| 95 | */ | ||
| 96 | |||
| 97 | return array( | ||
| 98 | 'no_backslashes' => array( | ||
| 99 | 'preg_match', | ||
| 100 | 'no_backslashes', | ||
| 101 | 'abc123', | ||
| 102 | true, | ||
| 103 | 'Passwords may not contain the character "\".', | ||
| 104 | ), | ||
| 105 | 'minimum_length' => array( | ||
| 106 | 'preg_match', | ||
| 107 | 'minimum_length', | ||
| 108 | 'abc123', | ||
| 109 | true, | ||
| 110 | 'Password must be at least 6 characters.', | ||
| 111 | ), | ||
| 112 | 'has_mixed_case' => array( | ||
| 113 | 'preg_match', | ||
| 114 | 'has_mixed_case', | ||
| 115 | 'Abc123', | ||
| 116 | true, | ||
| 117 | 'Password must have mixed case characters.', | ||
| 118 | ), | ||
| 119 | 'has_digit' => array( | ||
| 120 | 'preg_match', | ||
| 121 | 'has_digit', | ||
| 122 | 'abc123', | ||
| 123 | true, | ||
| 124 | 'Password must have digits.', | ||
| 125 | ), | ||
| 126 | 'has_special_char' => array( | ||
| 127 | 'preg_match', | ||
| 128 | 'has_special_char', | ||
| 129 | 'abc!def', | ||
| 130 | true, | ||
| 131 | 'Password must have special characters.', | ||
| 132 | ), | ||
| 133 | 'compare_to_list_1' => array( | ||
| 134 | 'compare_to_list', | ||
| 135 | 'not_a_common_password', | ||
| 136 | 'password', | ||
| 137 | false, | ||
| 138 | 'Common passwords that should not be used.', | ||
| 139 | ), | ||
| 140 | 'compare_to_list_2' => array( | ||
| 141 | 'compare_to_list', | ||
| 142 | 'not_a_common_password', | ||
| 143 | 'hunter2', | ||
| 144 | true, | ||
| 145 | 'Common passwords that should not be used.', | ||
| 146 | ), | ||
| 147 | 'compare_to_list_3' => array( | ||
| 148 | 'compare_to_list', | ||
| 149 | 'not_same_as_other_user_data', | ||
| 150 | 'test-user', | ||
| 151 | false, | ||
| 152 | 'Password contains user data.', | ||
| 153 | ), | ||
| 154 | ); | ||
| 155 | } | ||
| 156 | } | ||
| 157 | 
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: