| Conditions | 1 |
| Paths | 1 |
| Total Lines | 123 |
| 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 |
||
| 83 | public function serializationProvider() { |
||
| 84 | $serializations = []; |
||
| 85 | |||
| 86 | $serializations[] = [ |
||
| 87 | [ |
||
| 88 | 'mainsnak' => [ |
||
| 89 | 'snaktype' => 'novalue', |
||
| 90 | 'property' => 'P42' |
||
| 91 | ], |
||
| 92 | 'type' => 'statement', |
||
| 93 | 'rank' => 'normal' |
||
| 94 | ], |
||
| 95 | new Statement( new PropertyNoValueSnak( 42 ) ) |
||
| 96 | ]; |
||
| 97 | |||
| 98 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
| 99 | $statement->setGuid( 'q42' ); |
||
| 100 | $serializations[] = [ |
||
| 101 | [ |
||
| 102 | 'mainsnak' => [ |
||
| 103 | 'snaktype' => 'novalue', |
||
| 104 | 'property' => 'P42' |
||
| 105 | ], |
||
| 106 | 'type' => 'statement', |
||
| 107 | 'id' => 'q42', |
||
| 108 | 'rank' => 'normal' |
||
| 109 | ], |
||
| 110 | $statement |
||
| 111 | ]; |
||
| 112 | |||
| 113 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
| 114 | $statement->setRank( Statement::RANK_PREFERRED ); |
||
| 115 | $serializations[] = [ |
||
| 116 | [ |
||
| 117 | 'mainsnak' => [ |
||
| 118 | 'snaktype' => 'novalue', |
||
| 119 | 'property' => 'P42' |
||
| 120 | ], |
||
| 121 | 'type' => 'statement', |
||
| 122 | 'rank' => 'preferred' |
||
| 123 | ], |
||
| 124 | $statement |
||
| 125 | ]; |
||
| 126 | |||
| 127 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
| 128 | $statement->setRank( Statement::RANK_DEPRECATED ); |
||
| 129 | $serializations[] = [ |
||
| 130 | [ |
||
| 131 | 'mainsnak' => [ |
||
| 132 | 'snaktype' => 'novalue', |
||
| 133 | 'property' => 'P42' |
||
| 134 | ], |
||
| 135 | 'type' => 'statement', |
||
| 136 | 'rank' => 'deprecated' |
||
| 137 | ], |
||
| 138 | $statement |
||
| 139 | ]; |
||
| 140 | |||
| 141 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
| 142 | $statement->setQualifiers( new SnakList( [] ) ); |
||
| 143 | $serializations[] = [ |
||
| 144 | [ |
||
| 145 | 'mainsnak' => [ |
||
| 146 | 'snaktype' => 'novalue', |
||
| 147 | 'property' => "P42" |
||
| 148 | ], |
||
| 149 | 'type' => 'statement', |
||
| 150 | 'rank' => 'normal' |
||
| 151 | ], |
||
| 152 | $statement |
||
| 153 | ]; |
||
| 154 | |||
| 155 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
| 156 | $statement->setQualifiers( new SnakList( [ |
||
| 157 | new PropertyNoValueSnak( 42 ) |
||
| 158 | ] ) ); |
||
| 159 | $serializations[] = [ |
||
| 160 | [ |
||
| 161 | 'mainsnak' => [ |
||
| 162 | 'snaktype' => 'novalue', |
||
| 163 | 'property' => "P42" |
||
| 164 | ], |
||
| 165 | 'type' => 'statement', |
||
| 166 | 'qualifiers' => [ |
||
| 167 | 'P42' => [ |
||
| 168 | [ |
||
| 169 | 'snaktype' => 'novalue', |
||
| 170 | 'property' => 'P42' |
||
| 171 | ] |
||
| 172 | ] |
||
| 173 | ], |
||
| 174 | 'qualifiers-order' => [ |
||
| 175 | 'P42' |
||
| 176 | ], |
||
| 177 | 'rank' => 'normal' |
||
| 178 | ], |
||
| 179 | $statement |
||
| 180 | ]; |
||
| 181 | |||
| 182 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
| 183 | $statement->setReferences( new ReferenceList( [ |
||
| 184 | new Reference( [ new PropertyNoValueSnak( 1 ) ] ) |
||
| 185 | ] ) ); |
||
| 186 | $serializations[] = [ |
||
| 187 | [ |
||
| 188 | 'mainsnak' => [ |
||
| 189 | 'snaktype' => 'novalue', |
||
| 190 | 'property' => "P42" |
||
| 191 | ], |
||
| 192 | 'type' => 'statement', |
||
| 193 | 'rank' => 'normal', |
||
| 194 | 'references' => [ |
||
| 195 | [ |
||
| 196 | 'hash' => 'da39a3ee5e6b4b0d3255bfef95601890afd80709', |
||
| 197 | 'snaks' => [] |
||
| 198 | ] |
||
| 199 | ], |
||
| 200 | ], |
||
| 201 | $statement |
||
| 202 | ]; |
||
| 203 | |||
| 204 | return $serializations; |
||
| 205 | } |
||
| 206 | |||
| 253 |
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: