| Conditions | 1 |
| Paths | 1 |
| Total Lines | 63 |
| 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 |
||
| 39 | public function join_with_equal_sign_data_provider() { |
||
| 40 | return array( |
||
| 41 | 'string_value' => |
||
| 42 | array( |
||
| 43 | 'name' => 'street', |
||
| 44 | 'value' => '1600 Pennsylvania Ave', |
||
| 45 | 'expected_output' => 'street=1600 Pennsylvania Ave', |
||
| 46 | ), |
||
| 47 | 'array_value' => |
||
| 48 | array( |
||
| 49 | 'name' => 'first_names', |
||
| 50 | 'value' => array( 'Michael', 'Jim', 'Pam' ), |
||
| 51 | 'expected_output' => array( 'first_names[0]=Michael', 'first_names[1]=Jim', 'first_names[2]=Pam' ), |
||
| 52 | ), |
||
| 53 | 'associative_array_value' => |
||
| 54 | array( |
||
| 55 | 'name' => 'numbers', |
||
| 56 | 'value' => array( |
||
| 57 | 'one' => 1, |
||
| 58 | 'two' => 2, |
||
| 59 | ), |
||
| 60 | 'expected_output' => array( 'numbers[one]=1', 'numbers[two]=2' ), |
||
| 61 | ), |
||
| 62 | 'nested_array_value' => |
||
| 63 | array( |
||
| 64 | 'name' => 'numbers', |
||
| 65 | 'value' => array( array( 0, 1 ), array( 2, 3 ), array( 4, 5 ) ), |
||
| 66 | 'expected_output' => array( |
||
| 67 | 'numbers[0][0]=0', |
||
| 68 | 'numbers[0][1]=1', |
||
| 69 | 'numbers[1][0]=2', |
||
| 70 | 'numbers[1][1]=3', |
||
| 71 | 'numbers[2][0]=4', |
||
| 72 | 'numbers[2][1]=5', |
||
| 73 | ), |
||
| 74 | ), |
||
| 75 | 'nested_associative_array_value' => |
||
| 76 | array( |
||
| 77 | 'name' => 'people', |
||
| 78 | 'value' => array( |
||
| 79 | array( |
||
| 80 | 'last_name' => 'Scott', |
||
| 81 | 'first_name' => 'Michael', |
||
| 82 | 'city' => 'Boulder', |
||
| 83 | ), |
||
| 84 | array( |
||
| 85 | 'first_name' => 'Jim', |
||
| 86 | 'state' => 'Texas', |
||
| 87 | 'last_name' => 'Halpert', |
||
| 88 | ), |
||
| 89 | ), |
||
| 90 | // Note: Expected output is sorted. |
||
| 91 | 'expected_output' => array( |
||
| 92 | 'people[0][city]=Boulder', |
||
| 93 | 'people[0][first_name]=Michael', |
||
| 94 | 'people[0][last_name]=Scott', |
||
| 95 | 'people[1][first_name]=Jim', |
||
| 96 | 'people[1][last_name]=Halpert', |
||
| 97 | 'people[1][state]=Texas', |
||
| 98 | ), |
||
| 99 | ), |
||
| 100 | ); |
||
| 101 | } |
||
| 102 | |||
| 159 |
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: