Conditions | 3 |
Paths | 3 |
Total Lines | 144 |
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 |
||
226 | private function getConstraintCheckerMap() { |
||
227 | if ( $this->constraintCheckerMap === null ) { |
||
228 | $connectionCheckerHelper = new ConnectionCheckerHelper(); |
||
229 | $rangeCheckerHelper = new RangeCheckerHelper( $this->config, $this->unitConverter ); |
||
230 | if ( $this->config->get( 'WBQualityConstraintsSparqlEndpoint' ) !== '' ) { |
||
231 | $sparqlHelper = new SparqlHelper( |
||
232 | $this->config, |
||
233 | $this->rdfVocabulary, |
||
234 | $this->entityIdParser, |
||
235 | $this->propertyDataTypeLookup, |
||
236 | MediaWikiServices::getInstance()->getMainWANObjectCache(), |
||
237 | ConstraintsServices::getViolationMessageSerializer(), |
||
238 | ConstraintsServices::getViolationMessageDeserializer(), |
||
239 | $this->dataFactory |
||
240 | ); |
||
241 | } else { |
||
242 | $sparqlHelper = null; |
||
243 | } |
||
244 | $typeCheckerHelper = new TypeCheckerHelper( |
||
245 | $this->lookup, |
||
246 | $this->config, |
||
247 | $sparqlHelper, |
||
248 | $this->dataFactory |
||
249 | ); |
||
250 | |||
251 | $this->constraintCheckerMap = [ |
||
252 | $this->config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
||
253 | => new ConflictsWithChecker( |
||
254 | $this->lookup, |
||
255 | ConstraintsServices::getConstraintParameterParser(), |
||
256 | $connectionCheckerHelper |
||
257 | ), |
||
258 | $this->config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
||
259 | => new ItemChecker( |
||
260 | $this->lookup, |
||
261 | ConstraintsServices::getConstraintParameterParser(), |
||
262 | $connectionCheckerHelper |
||
263 | ), |
||
264 | $this->config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
||
265 | => new TargetRequiredClaimChecker( |
||
266 | $this->lookup, |
||
267 | ConstraintsServices::getConstraintParameterParser(), |
||
268 | $connectionCheckerHelper |
||
269 | ), |
||
270 | $this->config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
||
271 | => new SymmetricChecker( |
||
272 | $this->lookup, |
||
273 | $connectionCheckerHelper |
||
274 | ), |
||
275 | $this->config->get( 'WBQualityConstraintsInverseConstraintId' ) |
||
276 | => new InverseChecker( |
||
277 | $this->lookup, |
||
278 | ConstraintsServices::getConstraintParameterParser(), |
||
279 | $connectionCheckerHelper |
||
280 | ), |
||
281 | $this->config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
||
282 | => new QualifierChecker(), |
||
283 | $this->config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
||
284 | => new QualifiersChecker( |
||
285 | ConstraintsServices::getConstraintParameterParser() |
||
286 | ), |
||
287 | $this->config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
||
288 | => new MandatoryQualifiersChecker( |
||
289 | ConstraintsServices::getConstraintParameterParser() |
||
290 | ), |
||
291 | $this->config->get( 'WBQualityConstraintsRangeConstraintId' ) |
||
292 | => new RangeChecker( |
||
293 | $this->propertyDataTypeLookup, |
||
294 | ConstraintsServices::getConstraintParameterParser(), |
||
295 | $rangeCheckerHelper |
||
296 | ), |
||
297 | $this->config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
||
298 | => new DiffWithinRangeChecker( |
||
299 | ConstraintsServices::getConstraintParameterParser(), |
||
300 | $rangeCheckerHelper, |
||
301 | $this->config |
||
302 | ), |
||
303 | $this->config->get( 'WBQualityConstraintsTypeConstraintId' ) |
||
304 | => new TypeChecker( |
||
305 | $this->lookup, |
||
306 | ConstraintsServices::getConstraintParameterParser(), |
||
307 | $typeCheckerHelper, |
||
308 | $this->config |
||
309 | ), |
||
310 | $this->config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
||
311 | => new ValueTypeChecker( |
||
312 | $this->lookup, |
||
313 | ConstraintsServices::getConstraintParameterParser(), |
||
314 | $typeCheckerHelper, |
||
315 | $this->config |
||
316 | ), |
||
317 | $this->config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
||
318 | => new SingleValueChecker( ConstraintsServices::getConstraintParameterParser() ), |
||
319 | $this->config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
||
320 | => new MultiValueChecker( ConstraintsServices::getConstraintParameterParser() ), |
||
321 | $this->config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
||
322 | => new UniqueValueChecker( |
||
323 | $sparqlHelper |
||
324 | ), |
||
325 | $this->config->get( 'WBQualityConstraintsFormatConstraintId' ) |
||
326 | => new FormatChecker( |
||
327 | ConstraintsServices::getConstraintParameterParser(), |
||
328 | $this->config, |
||
329 | $sparqlHelper |
||
330 | ), |
||
331 | $this->config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
||
332 | => new CommonsLinkChecker( |
||
333 | ConstraintsServices::getConstraintParameterParser(), |
||
334 | $this->titleParser |
||
335 | ), |
||
336 | $this->config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
||
337 | => new OneOfChecker( |
||
338 | ConstraintsServices::getConstraintParameterParser() |
||
339 | ), |
||
340 | $this->config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
||
341 | => new ValueOnlyChecker(), |
||
342 | $this->config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
||
343 | => new ReferenceChecker(), |
||
344 | $this->config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
||
345 | => new NoBoundsChecker(), |
||
346 | $this->config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
||
347 | => new AllowedUnitsChecker( |
||
348 | ConstraintsServices::getConstraintParameterParser(), |
||
349 | $this->unitConverter |
||
350 | ), |
||
351 | $this->config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
||
352 | => new SingleBestValueChecker( ConstraintsServices::getConstraintParameterParser() ), |
||
353 | $this->config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
||
354 | => new EntityTypeChecker( |
||
355 | ConstraintsServices::getConstraintParameterParser() |
||
356 | ), |
||
357 | $this->config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
||
358 | => new NoneOfChecker( |
||
359 | ConstraintsServices::getConstraintParameterParser() |
||
360 | ), |
||
361 | $this->config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
||
362 | => new IntegerChecker(), |
||
363 | $this->config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
||
364 | => new CitationNeededChecker(), |
||
365 | ]; |
||
366 | } |
||
367 | |||
368 | return $this->constraintCheckerMap; |
||
369 | } |
||
370 | |||
425 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..