@@ -68,15 +68,15 @@ discard block |
||
68 | 68 | * @throws ConstraintParameterException |
69 | 69 | * @return CheckResult |
70 | 70 | */ |
71 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
72 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
73 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
71 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
72 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
73 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $parameters = []; |
77 | 77 | $constraintParameters = $constraint->getConstraintParameters(); |
78 | 78 | |
79 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true ); |
|
79 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true); |
|
80 | 80 | $parameters['item'] = $items; |
81 | 81 | |
82 | 82 | $snak = $context->getSnak(); |
@@ -84,25 +84,25 @@ discard block |
||
84 | 84 | $message = null; |
85 | 85 | $status = CheckResult::STATUS_COMPLIANCE; |
86 | 86 | |
87 | - foreach ( $items as $item ) { |
|
88 | - if ( $item->matchesSnak( $snak ) ) { |
|
89 | - $message = ( new ViolationMessage( 'wbqc-violation-message-none-of' ) ) |
|
90 | - ->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) |
|
91 | - ->withItemIdSnakValueList( $items, Role::OBJECT ); |
|
87 | + foreach ($items as $item) { |
|
88 | + if ($item->matchesSnak($snak)) { |
|
89 | + $message = (new ViolationMessage('wbqc-violation-message-none-of')) |
|
90 | + ->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE) |
|
91 | + ->withItemIdSnakValueList($items, Role::OBJECT); |
|
92 | 92 | $status = CheckResult::STATUS_VIOLATION; |
93 | 93 | break; |
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
97 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
98 | 98 | } |
99 | 99 | |
100 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
100 | + public function checkConstraintParameters(Constraint $constraint) { |
|
101 | 101 | $constraintParameters = $constraint->getConstraintParameters(); |
102 | 102 | $exceptions = []; |
103 | 103 | try { |
104 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true ); |
|
105 | - } catch ( ConstraintParameterException $e ) { |
|
104 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true); |
|
105 | + } catch (ConstraintParameterException $e) { |
|
106 | 106 | $exceptions[] = $e; |
107 | 107 | } |
108 | 108 | return $exceptions; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | public static function getDefaultInstance() { |
156 | 156 | static $instance = null; |
157 | 157 | |
158 | - if ( $instance === null ) { |
|
158 | + if ($instance === null) { |
|
159 | 159 | $wikibaseRepo = WikibaseRepo::getDefaultInstance(); |
160 | 160 | $entityIdFormatter = $wikibaseRepo->getEntityIdHtmlLinkFormatterFactory()->getEntityIdFormatter( |
161 | 161 | $wikibaseRepo->getLanguageFallbackLabelDescriptionLookupFactory()->newLabelDescriptionLookup( |
@@ -236,21 +236,21 @@ discard block |
||
236 | 236 | * @return DelegatingConstraintChecker |
237 | 237 | */ |
238 | 238 | public function getConstraintChecker() { |
239 | - if ( $this->delegatingConstraintChecker === null ) { |
|
239 | + if ($this->delegatingConstraintChecker === null) { |
|
240 | 240 | $this->delegatingConstraintChecker = new DelegatingConstraintChecker( |
241 | 241 | $this->lookup, |
242 | 242 | $this->getConstraintCheckerMap(), |
243 | - new CachingConstraintLookup( $this->getConstraintRepository() ), |
|
243 | + new CachingConstraintLookup($this->getConstraintRepository()), |
|
244 | 244 | $this->constraintParameterParser, |
245 | 245 | $this->statementGuidParser, |
246 | 246 | new LoggingHelper( |
247 | 247 | $this->dataFactory, |
248 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
248 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
249 | 249 | $this->config |
250 | 250 | ), |
251 | - $this->config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
252 | - $this->config->get( 'WBQualityConstraintsCheckReferences' ), |
|
253 | - $this->config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
251 | + $this->config->get('WBQualityConstraintsCheckQualifiers'), |
|
252 | + $this->config->get('WBQualityConstraintsCheckReferences'), |
|
253 | + $this->config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
254 | 254 | ); |
255 | 255 | } |
256 | 256 | |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | * @return ConstraintChecker[] |
262 | 262 | */ |
263 | 263 | private function getConstraintCheckerMap() { |
264 | - if ( $this->constraintCheckerMap === null ) { |
|
264 | + if ($this->constraintCheckerMap === null) { |
|
265 | 265 | $connectionCheckerHelper = new ConnectionCheckerHelper(); |
266 | - $rangeCheckerHelper = new RangeCheckerHelper( $this->config, $this->unitConverter ); |
|
267 | - if ( $this->config->get( 'WBQualityConstraintsSparqlEndpoint' ) !== '' ) { |
|
266 | + $rangeCheckerHelper = new RangeCheckerHelper($this->config, $this->unitConverter); |
|
267 | + if ($this->config->get('WBQualityConstraintsSparqlEndpoint') !== '') { |
|
268 | 268 | $sparqlHelper = new SparqlHelper( |
269 | 269 | $this->config, |
270 | 270 | $this->rdfVocabulary, |
@@ -287,74 +287,74 @@ discard block |
||
287 | 287 | ); |
288 | 288 | |
289 | 289 | $this->constraintCheckerMap = [ |
290 | - $this->config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
290 | + $this->config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
291 | 291 | => new ConflictsWithChecker( |
292 | 292 | $this->lookup, |
293 | 293 | $this->constraintParameterParser, |
294 | 294 | $connectionCheckerHelper, |
295 | 295 | $this->constraintParameterRenderer |
296 | 296 | ), |
297 | - $this->config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
297 | + $this->config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
298 | 298 | => new ItemChecker( |
299 | 299 | $this->lookup, |
300 | 300 | $this->constraintParameterParser, |
301 | 301 | $connectionCheckerHelper, |
302 | 302 | $this->constraintParameterRenderer |
303 | 303 | ), |
304 | - $this->config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
304 | + $this->config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
305 | 305 | => new TargetRequiredClaimChecker( |
306 | 306 | $this->lookup, |
307 | 307 | $this->constraintParameterParser, |
308 | 308 | $connectionCheckerHelper, |
309 | 309 | $this->constraintParameterRenderer |
310 | 310 | ), |
311 | - $this->config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
311 | + $this->config->get('WBQualityConstraintsSymmetricConstraintId') |
|
312 | 312 | => new SymmetricChecker( |
313 | 313 | $this->lookup, |
314 | 314 | $connectionCheckerHelper, |
315 | 315 | $this->constraintParameterRenderer |
316 | 316 | ), |
317 | - $this->config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
317 | + $this->config->get('WBQualityConstraintsInverseConstraintId') |
|
318 | 318 | => new InverseChecker( |
319 | 319 | $this->lookup, |
320 | 320 | $this->constraintParameterParser, |
321 | 321 | $connectionCheckerHelper, |
322 | 322 | $this->constraintParameterRenderer |
323 | 323 | ), |
324 | - $this->config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
324 | + $this->config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
325 | 325 | => new QualifierChecker(), |
326 | - $this->config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
326 | + $this->config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
327 | 327 | => new QualifiersChecker( |
328 | 328 | $this->constraintParameterParser, |
329 | 329 | $this->constraintParameterRenderer |
330 | 330 | ), |
331 | - $this->config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
331 | + $this->config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
332 | 332 | => new MandatoryQualifiersChecker( |
333 | 333 | $this->constraintParameterParser, |
334 | 334 | $this->constraintParameterRenderer |
335 | 335 | ), |
336 | - $this->config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
336 | + $this->config->get('WBQualityConstraintsRangeConstraintId') |
|
337 | 337 | => new RangeChecker( |
338 | 338 | $this->propertyDataTypeLookup, |
339 | 339 | $this->constraintParameterParser, |
340 | 340 | $rangeCheckerHelper, |
341 | 341 | $this->constraintParameterRenderer |
342 | 342 | ), |
343 | - $this->config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
343 | + $this->config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
344 | 344 | => new DiffWithinRangeChecker( |
345 | 345 | $this->constraintParameterParser, |
346 | 346 | $rangeCheckerHelper, |
347 | 347 | $this->constraintParameterRenderer, |
348 | 348 | $this->config |
349 | 349 | ), |
350 | - $this->config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
350 | + $this->config->get('WBQualityConstraintsTypeConstraintId') |
|
351 | 351 | => new TypeChecker( |
352 | 352 | $this->lookup, |
353 | 353 | $this->constraintParameterParser, |
354 | 354 | $typeCheckerHelper, |
355 | 355 | $this->config |
356 | 356 | ), |
357 | - $this->config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
357 | + $this->config->get('WBQualityConstraintsValueTypeConstraintId') |
|
358 | 358 | => new ValueTypeChecker( |
359 | 359 | $this->lookup, |
360 | 360 | $this->constraintParameterParser, |
@@ -362,52 +362,52 @@ discard block |
||
362 | 362 | $typeCheckerHelper, |
363 | 363 | $this->config |
364 | 364 | ), |
365 | - $this->config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
365 | + $this->config->get('WBQualityConstraintsSingleValueConstraintId') |
|
366 | 366 | => new SingleValueChecker(), |
367 | - $this->config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
367 | + $this->config->get('WBQualityConstraintsMultiValueConstraintId') |
|
368 | 368 | => new MultiValueChecker(), |
369 | - $this->config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
369 | + $this->config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
370 | 370 | => new UniqueValueChecker( |
371 | 371 | $this->constraintParameterRenderer, |
372 | 372 | $sparqlHelper |
373 | 373 | ), |
374 | - $this->config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
374 | + $this->config->get('WBQualityConstraintsFormatConstraintId') |
|
375 | 375 | => new FormatChecker( |
376 | 376 | $this->constraintParameterParser, |
377 | 377 | $this->constraintParameterRenderer, |
378 | 378 | $this->config, |
379 | 379 | $sparqlHelper |
380 | 380 | ), |
381 | - $this->config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
381 | + $this->config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
382 | 382 | => new CommonsLinkChecker( |
383 | 383 | $this->constraintParameterParser, |
384 | 384 | $this->constraintParameterRenderer, |
385 | 385 | $this->titleParser |
386 | 386 | ), |
387 | - $this->config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
387 | + $this->config->get('WBQualityConstraintsOneOfConstraintId') |
|
388 | 388 | => new OneOfChecker( |
389 | 389 | $this->constraintParameterParser, |
390 | 390 | $this->constraintParameterRenderer |
391 | 391 | ), |
392 | - $this->config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
392 | + $this->config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
393 | 393 | => new ValueOnlyChecker(), |
394 | - $this->config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
394 | + $this->config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
395 | 395 | => new ReferenceChecker(), |
396 | - $this->config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
396 | + $this->config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
397 | 397 | => new NoBoundsChecker(), |
398 | - $this->config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
398 | + $this->config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
399 | 399 | => new AllowedUnitsChecker( |
400 | 400 | $this->constraintParameterParser, |
401 | 401 | $this->unitConverter |
402 | 402 | ), |
403 | - $this->config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
403 | + $this->config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
404 | 404 | => new SingleBestValueChecker(), |
405 | - $this->config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
405 | + $this->config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
406 | 406 | => new EntityTypeChecker( |
407 | 407 | $this->constraintParameterParser, |
408 | 408 | $this->constraintParameterRenderer |
409 | 409 | ), |
410 | - $this->config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
410 | + $this->config->get('WBQualityConstraintsNoneOfConstraintId') |
|
411 | 411 | => new NoneOfChecker( |
412 | 412 | $this->constraintParameterParser, |
413 | 413 | $this->constraintParameterRenderer |
@@ -422,26 +422,26 @@ discard block |
||
422 | 422 | * @return array[] |
423 | 423 | */ |
424 | 424 | public function getConstraintParameterMap() { |
425 | - if ( $this->constraintParameterMap === null ) { |
|
425 | + if ($this->constraintParameterMap === null) { |
|
426 | 426 | $this->constraintParameterMap = [ |
427 | - 'Commons link' => [ 'namespace' ], |
|
428 | - 'Conflicts with' => [ 'property', 'item' ], |
|
429 | - 'Diff within range' => [ 'property', 'minimum_quantity', 'maximum_quantity' ], |
|
430 | - 'Format' => [ 'pattern' ], |
|
431 | - 'Inverse' => [ 'property' ], |
|
432 | - 'Item' => [ 'property', 'item' ], |
|
433 | - 'Mandatory qualifiers' => [ 'property' ], |
|
427 | + 'Commons link' => ['namespace'], |
|
428 | + 'Conflicts with' => ['property', 'item'], |
|
429 | + 'Diff within range' => ['property', 'minimum_quantity', 'maximum_quantity'], |
|
430 | + 'Format' => ['pattern'], |
|
431 | + 'Inverse' => ['property'], |
|
432 | + 'Item' => ['property', 'item'], |
|
433 | + 'Mandatory qualifiers' => ['property'], |
|
434 | 434 | 'Multi value' => [], |
435 | - 'One of' => [ 'item' ], |
|
435 | + 'One of' => ['item'], |
|
436 | 436 | 'Qualifier' => [], |
437 | - 'Qualifiers' => [ 'property' ], |
|
438 | - 'Range' => [ 'minimum_quantity', 'maximum_quantity', 'minimum_date', 'maximum_date' ], |
|
437 | + 'Qualifiers' => ['property'], |
|
438 | + 'Range' => ['minimum_quantity', 'maximum_quantity', 'minimum_date', 'maximum_date'], |
|
439 | 439 | 'Single value' => [], |
440 | 440 | 'Symmetric' => [], |
441 | - 'Target required claim' => [ 'property', 'item' ], |
|
442 | - 'Type' => [ 'class', 'relation' ], |
|
441 | + 'Target required claim' => ['property', 'item'], |
|
442 | + 'Type' => ['class', 'relation'], |
|
443 | 443 | 'Unique value' => [], |
444 | - 'Value type' => [ 'class', 'relation' ] |
|
444 | + 'Value type' => ['class', 'relation'] |
|
445 | 445 | ]; |
446 | 446 | } |
447 | 447 | |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | * @return ConstraintRepository |
453 | 453 | */ |
454 | 454 | public function getConstraintRepository() { |
455 | - if ( $this->constraintRepository === null ) { |
|
455 | + if ($this->constraintRepository === null) { |
|
456 | 456 | $this->constraintRepository = new ConstraintRepository(); |
457 | 457 | } |
458 | 458 |