@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | public static function getDefaultInstance() { |
154 | 154 | static $instance = null; |
155 | 155 | |
156 | - if ( $instance === null ) { |
|
156 | + if ($instance === null) { |
|
157 | 157 | $wikibaseRepo = WikibaseRepo::getDefaultInstance(); |
158 | 158 | $entityIdFormatter = $wikibaseRepo->getEntityIdHtmlLinkFormatterFactory()->getEntityIdFormatter( |
159 | 159 | $wikibaseRepo->getLanguageFallbackLabelDescriptionLookupFactory()->newLabelDescriptionLookup( |
@@ -234,21 +234,21 @@ discard block |
||
234 | 234 | * @return DelegatingConstraintChecker |
235 | 235 | */ |
236 | 236 | public function getConstraintChecker() { |
237 | - if ( $this->delegatingConstraintChecker === null ) { |
|
237 | + if ($this->delegatingConstraintChecker === null) { |
|
238 | 238 | $this->delegatingConstraintChecker = new DelegatingConstraintChecker( |
239 | 239 | $this->lookup, |
240 | 240 | $this->getConstraintCheckerMap(), |
241 | - new CachingConstraintLookup( $this->getConstraintRepository() ), |
|
241 | + new CachingConstraintLookup($this->getConstraintRepository()), |
|
242 | 242 | $this->constraintParameterParser, |
243 | 243 | $this->statementGuidParser, |
244 | 244 | new LoggingHelper( |
245 | 245 | $this->dataFactory, |
246 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
246 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
247 | 247 | $this->config |
248 | 248 | ), |
249 | - $this->config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
250 | - $this->config->get( 'WBQualityConstraintsCheckReferences' ), |
|
251 | - $this->config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
249 | + $this->config->get('WBQualityConstraintsCheckQualifiers'), |
|
250 | + $this->config->get('WBQualityConstraintsCheckReferences'), |
|
251 | + $this->config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
252 | 252 | ); |
253 | 253 | } |
254 | 254 | |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | * @return ConstraintChecker[] |
260 | 260 | */ |
261 | 261 | private function getConstraintCheckerMap() { |
262 | - if ( $this->constraintCheckerMap === null ) { |
|
262 | + if ($this->constraintCheckerMap === null) { |
|
263 | 263 | $connectionCheckerHelper = new ConnectionCheckerHelper(); |
264 | - $rangeCheckerHelper = new RangeCheckerHelper( $this->config, $this->unitConverter ); |
|
265 | - if ( $this->config->get( 'WBQualityConstraintsSparqlEndpoint' ) !== '' ) { |
|
264 | + $rangeCheckerHelper = new RangeCheckerHelper($this->config, $this->unitConverter); |
|
265 | + if ($this->config->get('WBQualityConstraintsSparqlEndpoint') !== '') { |
|
266 | 266 | $sparqlHelper = new SparqlHelper( |
267 | 267 | $this->config, |
268 | 268 | $this->rdfVocabulary, |
@@ -285,74 +285,74 @@ discard block |
||
285 | 285 | ); |
286 | 286 | |
287 | 287 | $this->constraintCheckerMap = [ |
288 | - $this->config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
288 | + $this->config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
289 | 289 | => new ConflictsWithChecker( |
290 | 290 | $this->lookup, |
291 | 291 | $this->constraintParameterParser, |
292 | 292 | $connectionCheckerHelper, |
293 | 293 | $this->constraintParameterRenderer |
294 | 294 | ), |
295 | - $this->config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
295 | + $this->config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
296 | 296 | => new ItemChecker( |
297 | 297 | $this->lookup, |
298 | 298 | $this->constraintParameterParser, |
299 | 299 | $connectionCheckerHelper, |
300 | 300 | $this->constraintParameterRenderer |
301 | 301 | ), |
302 | - $this->config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
302 | + $this->config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
303 | 303 | => new TargetRequiredClaimChecker( |
304 | 304 | $this->lookup, |
305 | 305 | $this->constraintParameterParser, |
306 | 306 | $connectionCheckerHelper, |
307 | 307 | $this->constraintParameterRenderer |
308 | 308 | ), |
309 | - $this->config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
309 | + $this->config->get('WBQualityConstraintsSymmetricConstraintId') |
|
310 | 310 | => new SymmetricChecker( |
311 | 311 | $this->lookup, |
312 | 312 | $connectionCheckerHelper, |
313 | 313 | $this->constraintParameterRenderer |
314 | 314 | ), |
315 | - $this->config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
315 | + $this->config->get('WBQualityConstraintsInverseConstraintId') |
|
316 | 316 | => new InverseChecker( |
317 | 317 | $this->lookup, |
318 | 318 | $this->constraintParameterParser, |
319 | 319 | $connectionCheckerHelper, |
320 | 320 | $this->constraintParameterRenderer |
321 | 321 | ), |
322 | - $this->config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
322 | + $this->config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
323 | 323 | => new QualifierChecker(), |
324 | - $this->config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
324 | + $this->config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
325 | 325 | => new QualifiersChecker( |
326 | 326 | $this->constraintParameterParser, |
327 | 327 | $this->constraintParameterRenderer |
328 | 328 | ), |
329 | - $this->config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
329 | + $this->config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
330 | 330 | => new MandatoryQualifiersChecker( |
331 | 331 | $this->constraintParameterParser, |
332 | 332 | $this->constraintParameterRenderer |
333 | 333 | ), |
334 | - $this->config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
334 | + $this->config->get('WBQualityConstraintsRangeConstraintId') |
|
335 | 335 | => new RangeChecker( |
336 | 336 | $this->propertyDataTypeLookup, |
337 | 337 | $this->constraintParameterParser, |
338 | 338 | $rangeCheckerHelper, |
339 | 339 | $this->constraintParameterRenderer |
340 | 340 | ), |
341 | - $this->config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
341 | + $this->config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
342 | 342 | => new DiffWithinRangeChecker( |
343 | 343 | $this->constraintParameterParser, |
344 | 344 | $rangeCheckerHelper, |
345 | 345 | $this->constraintParameterRenderer, |
346 | 346 | $this->config |
347 | 347 | ), |
348 | - $this->config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
348 | + $this->config->get('WBQualityConstraintsTypeConstraintId') |
|
349 | 349 | => new TypeChecker( |
350 | 350 | $this->lookup, |
351 | 351 | $this->constraintParameterParser, |
352 | 352 | $typeCheckerHelper, |
353 | 353 | $this->config |
354 | 354 | ), |
355 | - $this->config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
355 | + $this->config->get('WBQualityConstraintsValueTypeConstraintId') |
|
356 | 356 | => new ValueTypeChecker( |
357 | 357 | $this->lookup, |
358 | 358 | $this->constraintParameterParser, |
@@ -360,45 +360,45 @@ discard block |
||
360 | 360 | $typeCheckerHelper, |
361 | 361 | $this->config |
362 | 362 | ), |
363 | - $this->config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
363 | + $this->config->get('WBQualityConstraintsSingleValueConstraintId') |
|
364 | 364 | => new SingleValueChecker(), |
365 | - $this->config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
365 | + $this->config->get('WBQualityConstraintsMultiValueConstraintId') |
|
366 | 366 | => new MultiValueChecker(), |
367 | - $this->config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
367 | + $this->config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
368 | 368 | => new UniqueValueChecker( |
369 | 369 | $this->constraintParameterRenderer, |
370 | 370 | $sparqlHelper |
371 | 371 | ), |
372 | - $this->config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
372 | + $this->config->get('WBQualityConstraintsFormatConstraintId') |
|
373 | 373 | => new FormatChecker( |
374 | 374 | $this->constraintParameterParser, |
375 | 375 | $this->constraintParameterRenderer, |
376 | 376 | $this->config, |
377 | 377 | $sparqlHelper |
378 | 378 | ), |
379 | - $this->config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
379 | + $this->config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
380 | 380 | => new CommonsLinkChecker( |
381 | 381 | $this->constraintParameterParser, |
382 | 382 | $this->constraintParameterRenderer, |
383 | 383 | $this->titleParser |
384 | 384 | ), |
385 | - $this->config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
385 | + $this->config->get('WBQualityConstraintsOneOfConstraintId') |
|
386 | 386 | => new OneOfChecker( |
387 | 387 | $this->constraintParameterParser, |
388 | 388 | $this->constraintParameterRenderer |
389 | 389 | ), |
390 | - $this->config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
390 | + $this->config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
391 | 391 | => new ValueOnlyChecker(), |
392 | - $this->config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
392 | + $this->config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
393 | 393 | => new ReferenceChecker(), |
394 | - $this->config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
394 | + $this->config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
395 | 395 | => new NoBoundsChecker(), |
396 | - $this->config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
396 | + $this->config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
397 | 397 | => new AllowedUnitsChecker( |
398 | 398 | $this->constraintParameterParser, |
399 | 399 | $this->unitConverter |
400 | 400 | ), |
401 | - $this->config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
401 | + $this->config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
402 | 402 | => new SingleBestValueChecker(), |
403 | 403 | ]; |
404 | 404 | } |
@@ -410,26 +410,26 @@ discard block |
||
410 | 410 | * @return array[] |
411 | 411 | */ |
412 | 412 | public function getConstraintParameterMap() { |
413 | - if ( $this->constraintParameterMap === null ) { |
|
413 | + if ($this->constraintParameterMap === null) { |
|
414 | 414 | $this->constraintParameterMap = [ |
415 | - 'Commons link' => [ 'namespace' ], |
|
416 | - 'Conflicts with' => [ 'property', 'item' ], |
|
417 | - 'Diff within range' => [ 'property', 'minimum_quantity', 'maximum_quantity' ], |
|
418 | - 'Format' => [ 'pattern' ], |
|
419 | - 'Inverse' => [ 'property' ], |
|
420 | - 'Item' => [ 'property', 'item' ], |
|
421 | - 'Mandatory qualifiers' => [ 'property' ], |
|
415 | + 'Commons link' => ['namespace'], |
|
416 | + 'Conflicts with' => ['property', 'item'], |
|
417 | + 'Diff within range' => ['property', 'minimum_quantity', 'maximum_quantity'], |
|
418 | + 'Format' => ['pattern'], |
|
419 | + 'Inverse' => ['property'], |
|
420 | + 'Item' => ['property', 'item'], |
|
421 | + 'Mandatory qualifiers' => ['property'], |
|
422 | 422 | 'Multi value' => [], |
423 | - 'One of' => [ 'item' ], |
|
423 | + 'One of' => ['item'], |
|
424 | 424 | 'Qualifier' => [], |
425 | - 'Qualifiers' => [ 'property' ], |
|
426 | - 'Range' => [ 'minimum_quantity', 'maximum_quantity', 'minimum_date', 'maximum_date' ], |
|
425 | + 'Qualifiers' => ['property'], |
|
426 | + 'Range' => ['minimum_quantity', 'maximum_quantity', 'minimum_date', 'maximum_date'], |
|
427 | 427 | 'Single value' => [], |
428 | 428 | 'Symmetric' => [], |
429 | - 'Target required claim' => [ 'property', 'item' ], |
|
430 | - 'Type' => [ 'class', 'relation' ], |
|
429 | + 'Target required claim' => ['property', 'item'], |
|
430 | + 'Type' => ['class', 'relation'], |
|
431 | 431 | 'Unique value' => [], |
432 | - 'Value type' => [ 'class', 'relation' ] |
|
432 | + 'Value type' => ['class', 'relation'] |
|
433 | 433 | ]; |
434 | 434 | } |
435 | 435 | |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @return ConstraintRepository |
441 | 441 | */ |
442 | 442 | public function getConstraintRepository() { |
443 | - if ( $this->constraintRepository === null ) { |
|
443 | + if ($this->constraintRepository === null) { |
|
444 | 444 | $this->constraintRepository = new ConstraintRepository(); |
445 | 445 | } |
446 | 446 |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return CheckResult |
57 | 57 | */ |
58 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
59 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
60 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
58 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
59 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
60 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $propertyId = $context->getSnak()->getPropertyId(); |
@@ -65,31 +65,31 @@ discard block |
||
65 | 65 | $parameters = []; |
66 | 66 | |
67 | 67 | $bestRankCount = $this->valueCountCheckerHelper->getPropertyCount( |
68 | - $context->getSnakGroup( Context::GROUP_BEST_RANK ), |
|
68 | + $context->getSnakGroup(Context::GROUP_BEST_RANK), |
|
69 | 69 | $propertyId |
70 | 70 | ); |
71 | 71 | |
72 | - if ( $bestRankCount > 1 ) { |
|
72 | + if ($bestRankCount > 1) { |
|
73 | 73 | $nonDeprecatedCount = $this->valueCountCheckerHelper->getPropertyCount( |
74 | - $context->getSnakGroup( Context::GROUP_NON_DEPRECATED ), |
|
74 | + $context->getSnakGroup(Context::GROUP_NON_DEPRECATED), |
|
75 | 75 | $propertyId |
76 | 76 | ); |
77 | - if ( $bestRankCount === $nonDeprecatedCount ) { |
|
77 | + if ($bestRankCount === $nonDeprecatedCount) { |
|
78 | 78 | $messageKey = 'wbqc-violation-message-single-best-value-no-preferred'; |
79 | 79 | } else { |
80 | 80 | $messageKey = 'wbqc-violation-message-single-best-value-multi-preferred'; |
81 | 81 | } |
82 | - $message = new ViolationMessage( $messageKey ); |
|
82 | + $message = new ViolationMessage($messageKey); |
|
83 | 83 | $status = CheckResult::STATUS_VIOLATION; |
84 | 84 | } else { |
85 | 85 | $message = null; |
86 | 86 | $status = CheckResult::STATUS_COMPLIANCE; |
87 | 87 | } |
88 | 88 | |
89 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
89 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
90 | 90 | } |
91 | 91 | |
92 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
92 | + public function checkConstraintParameters(Constraint $constraint) { |
|
93 | 93 | // no parameters |
94 | 94 | return []; |
95 | 95 | } |