Conditions | 1 |
Paths | 1 |
Total Lines | 136 |
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 |
||
103 | public function deserializationProvider() { |
||
104 | $serializations = []; |
||
105 | |||
106 | $serializations[] = [ |
||
107 | new Statement( new PropertyNoValueSnak( 42 ) ), |
||
108 | [ |
||
109 | 'mainsnak' => [ |
||
110 | 'snaktype' => 'novalue', |
||
111 | 'property' => 'P42' |
||
112 | ], |
||
113 | 'type' => 'claim' |
||
114 | ] |
||
115 | ]; |
||
116 | |||
117 | $serializations[] = [ |
||
118 | new Statement( new PropertyNoValueSnak( 42 ) ), |
||
119 | [ |
||
120 | 'mainsnak' => [ |
||
121 | 'snaktype' => 'novalue', |
||
122 | 'property' => 'P42' |
||
123 | ], |
||
124 | 'type' => 'statement' |
||
125 | ] |
||
126 | ]; |
||
127 | |||
128 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
129 | $statement->setGuid( 'q42' ); |
||
130 | $serializations[] = [ |
||
131 | $statement, |
||
132 | [ |
||
133 | 'id' => 'q42', |
||
134 | 'mainsnak' => [ |
||
135 | 'snaktype' => 'novalue', |
||
136 | 'property' => 'P42' |
||
137 | ], |
||
138 | 'type' => 'claim' |
||
139 | ] |
||
140 | ]; |
||
141 | |||
142 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
143 | $statement->setRank( Statement::RANK_PREFERRED ); |
||
144 | $serializations[] = [ |
||
145 | $statement, |
||
146 | [ |
||
147 | 'mainsnak' => [ |
||
148 | 'snaktype' => 'novalue', |
||
149 | 'property' => 'P42' |
||
150 | ], |
||
151 | 'type' => 'statement', |
||
152 | 'rank' => 'preferred' |
||
153 | ] |
||
154 | ]; |
||
155 | |||
156 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
157 | $statement->setRank( Statement::RANK_NORMAL ); |
||
158 | $serializations[] = [ |
||
159 | $statement, |
||
160 | [ |
||
161 | 'mainsnak' => [ |
||
162 | 'snaktype' => 'novalue', |
||
163 | 'property' => 'P42' |
||
164 | ], |
||
165 | 'type' => 'statement', |
||
166 | 'rank' => 'normal' |
||
167 | ] |
||
168 | ]; |
||
169 | |||
170 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
171 | $statement->setRank( Statement::RANK_DEPRECATED ); |
||
172 | $serializations[] = [ |
||
173 | $statement, |
||
174 | [ |
||
175 | 'mainsnak' => [ |
||
176 | 'snaktype' => 'novalue', |
||
177 | 'property' => 'P42' |
||
178 | ], |
||
179 | 'type' => 'statement', |
||
180 | 'rank' => 'deprecated' |
||
181 | ] |
||
182 | ]; |
||
183 | |||
184 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
185 | $statement->setQualifiers( new SnakList( [] ) ); |
||
186 | $serializations[] = [ |
||
187 | $statement, |
||
188 | [ |
||
189 | 'mainsnak' => [ |
||
190 | 'snaktype' => 'novalue', |
||
191 | 'property' => 'P42' |
||
192 | ], |
||
193 | 'type' => 'statement', |
||
194 | 'rank' => 'normal' |
||
195 | ] |
||
196 | ]; |
||
197 | |||
198 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
199 | $statement->setQualifiers( new SnakList( [ |
||
200 | new PropertyNoValueSnak( 42 ) |
||
201 | ] ) ); |
||
202 | $serializations[] = [ |
||
203 | $statement, |
||
204 | [ |
||
205 | 'mainsnak' => [ |
||
206 | 'snaktype' => 'novalue', |
||
207 | 'property' => 'P42' |
||
208 | ], |
||
209 | 'qualifiers' => [ |
||
210 | 'P42' => [ |
||
211 | [ |
||
212 | 'snaktype' => 'novalue', |
||
213 | 'property' => 'P42' |
||
214 | ] |
||
215 | ] |
||
216 | ], |
||
217 | 'type' => 'statement', |
||
218 | 'rank' => 'normal' |
||
219 | ] |
||
220 | ]; |
||
221 | |||
222 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
223 | $statement->setReferences( new ReferenceList() ); |
||
224 | $serializations[] = [ |
||
225 | $statement, |
||
226 | [ |
||
227 | 'mainsnak' => [ |
||
228 | 'snaktype' => 'novalue', |
||
229 | 'property' => "P42" |
||
230 | ], |
||
231 | 'references' => [], |
||
232 | 'type' => 'statement', |
||
233 | 'rank' => 'normal' |
||
234 | ] |
||
235 | ]; |
||
236 | |||
237 | return $serializations; |
||
238 | } |
||
239 | |||
391 |
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: