Completed
Push — master ( 5f7797...bae75b )
by
unknown
01:07 queued 11s
created
src/ConstraintCheck/DelegatingConstraintChecker.php 1 patch
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 		callable $defaultResultsPerEntity = null
144 144
 	) {
145 145
 		$checkResults = [];
146
-		$entity = $this->entityLookup->getEntity( $entityId );
146
+		$entity = $this->entityLookup->getEntity($entityId);
147 147
 
148
-		if ( $entity instanceof StatementListProvidingEntity ) {
149
-			$startTime = microtime( true );
148
+		if ($entity instanceof StatementListProvidingEntity) {
149
+			$startTime = microtime(true);
150 150
 
151 151
 			$checkResults = $this->checkEveryStatement(
152 152
 				$entity,
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
 				$defaultResultsPerContext
155 155
 			);
156 156
 
157
-			$endTime = microtime( true );
157
+			$endTime = microtime(true);
158 158
 
159
-			if ( $constraintIds === null ) { // only log full constraint checks
159
+			if ($constraintIds === null) { // only log full constraint checks
160 160
 				$this->loggingHelper->logConstraintCheckOnEntity(
161 161
 					$entityId,
162 162
 					$checkResults,
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
 			}
167 167
 		}
168 168
 
169
-		if ( $defaultResultsPerEntity !== null ) {
170
-			$checkResults = array_merge( $defaultResultsPerEntity( $entityId ), $checkResults );
169
+		if ($defaultResultsPerEntity !== null) {
170
+			$checkResults = array_merge($defaultResultsPerEntity($entityId), $checkResults);
171 171
 		}
172 172
 
173
-		return $this->sortResult( $checkResults );
173
+		return $this->sortResult($checkResults);
174 174
 	}
175 175
 
176 176
 	/**
@@ -192,19 +192,19 @@  discard block
 block discarded – undo
192 192
 		callable $defaultResults = null
193 193
 	) {
194 194
 
195
-		$parsedGuid = $this->statementGuidParser->parse( $guid );
195
+		$parsedGuid = $this->statementGuidParser->parse($guid);
196 196
 		$entityId = $parsedGuid->getEntityId();
197
-		$entity = $this->entityLookup->getEntity( $entityId );
198
-		if ( $entity instanceof StatementListProvidingEntity ) {
199
-			$statement = $entity->getStatements()->getFirstStatementWithGuid( $guid );
200
-			if ( $statement ) {
197
+		$entity = $this->entityLookup->getEntity($entityId);
198
+		if ($entity instanceof StatementListProvidingEntity) {
199
+			$statement = $entity->getStatements()->getFirstStatementWithGuid($guid);
200
+			if ($statement) {
201 201
 				$result = $this->checkStatement(
202 202
 					$entity,
203 203
 					$statement,
204 204
 					$constraintIds,
205 205
 					$defaultResults
206 206
 				);
207
-				$output = $this->sortResult( $result );
207
+				$output = $this->sortResult($result);
208 208
 				return $output;
209 209
 			}
210 210
 		}
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 		return [];
213 213
 	}
214 214
 
215
-	private function getAllowedContextTypes( Constraint $constraint ) {
216
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
215
+	private function getAllowedContextTypes(Constraint $constraint) {
216
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
217 217
 			return [
218 218
 				Context::TYPE_STATEMENT,
219 219
 				Context::TYPE_QUALIFIER,
@@ -221,25 +221,25 @@  discard block
 block discarded – undo
221 221
 			];
222 222
 		}
223 223
 
224
-		return array_keys( array_filter(
224
+		return array_keys(array_filter(
225 225
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedContextTypes(),
226
-			static function ( $resultStatus ) {
226
+			static function($resultStatus) {
227 227
 				return $resultStatus !== CheckResult::STATUS_NOT_IN_SCOPE;
228 228
 			}
229
-		) );
229
+		));
230 230
 	}
231 231
 
232
-	private function getAllowedEntityTypes( Constraint $constraint ) {
233
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
234
-			return array_keys( ConstraintChecker::ALL_ENTITY_TYPES_SUPPORTED );
232
+	private function getAllowedEntityTypes(Constraint $constraint) {
233
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
234
+			return array_keys(ConstraintChecker::ALL_ENTITY_TYPES_SUPPORTED);
235 235
 		}
236 236
 
237
-		return array_keys( array_filter(
237
+		return array_keys(array_filter(
238 238
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedEntityTypes(),
239
-			static function ( $resultStatus ) {
239
+			static function($resultStatus) {
240 240
 				return $resultStatus !== CheckResult::STATUS_NOT_IN_SCOPE;
241 241
 			}
242
-		) );
242
+		));
243 243
 	}
244 244
 
245 245
 	/**
@@ -250,33 +250,33 @@  discard block
 block discarded – undo
250 250
 	 *
251 251
 	 * @return ConstraintParameterException[]
252 252
 	 */
253
-	private function checkCommonConstraintParameters( Constraint $constraint ) {
253
+	private function checkCommonConstraintParameters(Constraint $constraint) {
254 254
 		$constraintParameters = $constraint->getConstraintParameters();
255 255
 		try {
256
-			$this->constraintParameterParser->checkError( $constraintParameters );
257
-		} catch ( ConstraintParameterException $e ) {
258
-			return [ $e ];
256
+			$this->constraintParameterParser->checkError($constraintParameters);
257
+		} catch (ConstraintParameterException $e) {
258
+			return [$e];
259 259
 		}
260 260
 
261 261
 		$problems = [];
262 262
 		try {
263
-			$this->constraintParameterParser->parseExceptionParameter( $constraintParameters );
264
-		} catch ( ConstraintParameterException $e ) {
263
+			$this->constraintParameterParser->parseExceptionParameter($constraintParameters);
264
+		} catch (ConstraintParameterException $e) {
265 265
 			$problems[] = $e;
266 266
 		}
267 267
 		try {
268
-			$this->constraintParameterParser->parseConstraintStatusParameter( $constraintParameters );
269
-		} catch ( ConstraintParameterException $e ) {
268
+			$this->constraintParameterParser->parseConstraintStatusParameter($constraintParameters);
269
+		} catch (ConstraintParameterException $e) {
270 270
 			$problems[] = $e;
271 271
 		}
272 272
 		try {
273 273
 			$this->constraintParameterParser->parseConstraintScopeParameters(
274 274
 				$constraintParameters,
275 275
 				$constraint->getConstraintTypeItemId(),
276
-				$this->getAllowedContextTypes( $constraint ),
277
-				$this->getAllowedEntityTypes( $constraint )
276
+				$this->getAllowedContextTypes($constraint),
277
+				$this->getAllowedEntityTypes($constraint)
278 278
 			);
279
-		} catch ( ConstraintParameterException $e ) {
279
+		} catch (ConstraintParameterException $e) {
280 280
 			$problems[] = $e;
281 281
 		}
282 282
 		return $problems;
@@ -289,16 +289,16 @@  discard block
 block discarded – undo
289 289
 	 * @return ConstraintParameterException[][] first level indexed by constraint ID,
290 290
 	 * second level like checkConstraintParametersOnConstraintId (but without possibility of null)
291 291
 	 */
292
-	public function checkConstraintParametersOnPropertyId( PropertyId $propertyId ) {
293
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
292
+	public function checkConstraintParametersOnPropertyId(PropertyId $propertyId) {
293
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
294 294
 		$result = [];
295 295
 
296
-		foreach ( $constraints as $constraint ) {
297
-			$problems = $this->checkCommonConstraintParameters( $constraint );
296
+		foreach ($constraints as $constraint) {
297
+			$problems = $this->checkCommonConstraintParameters($constraint);
298 298
 
299
-			if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
299
+			if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
300 300
 				$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
301
-				$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
301
+				$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
302 302
 			}
303 303
 
304 304
 			$result[$constraint->getConstraintId()] = $problems;
@@ -315,18 +315,18 @@  discard block
 block discarded – undo
315 315
 	 * @return ConstraintParameterException[]|null list of constraint parameter exceptions
316 316
 	 * (empty means all parameters okay), or null if constraint is not found
317 317
 	 */
318
-	public function checkConstraintParametersOnConstraintId( $constraintId ) {
319
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
318
+	public function checkConstraintParametersOnConstraintId($constraintId) {
319
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
320 320
 		'@phan-var PropertyId $propertyId';
321
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
321
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
322 322
 
323
-		foreach ( $constraints as $constraint ) {
324
-			if ( $constraint->getConstraintId() === $constraintId ) {
325
-				$problems = $this->checkCommonConstraintParameters( $constraint );
323
+		foreach ($constraints as $constraint) {
324
+			if ($constraint->getConstraintId() === $constraintId) {
325
+				$problems = $this->checkCommonConstraintParameters($constraint);
326 326
 
327
-				if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
327
+				if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
328 328
 					$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
329
-					$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
329
+					$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
330 330
 				}
331 331
 
332 332
 				return $problems;
@@ -351,14 +351,14 @@  discard block
 block discarded – undo
351 351
 		$result = [];
352 352
 
353 353
 		/** @var Statement $statement */
354
-		foreach ( $entity->getStatements() as $statement ) {
355
-			$result = array_merge( $result,
354
+		foreach ($entity->getStatements() as $statement) {
355
+			$result = array_merge($result,
356 356
 				$this->checkStatement(
357 357
 					$entity,
358 358
 					$statement,
359 359
 					$constraintIds,
360 360
 					$defaultResultsPerContext
361
-				) );
361
+				));
362 362
 		}
363 363
 
364 364
 		return $result;
@@ -380,32 +380,32 @@  discard block
 block discarded – undo
380 380
 	) {
381 381
 		$result = [];
382 382
 
383
-		$result = array_merge( $result,
383
+		$result = array_merge($result,
384 384
 			$this->checkConstraintsForMainSnak(
385 385
 				$entity,
386 386
 				$statement,
387 387
 				$constraintIds,
388 388
 				$defaultResultsPerContext
389
-			) );
389
+			));
390 390
 
391
-		if ( $this->checkQualifiers ) {
392
-			$result = array_merge( $result,
391
+		if ($this->checkQualifiers) {
392
+			$result = array_merge($result,
393 393
 				$this->checkConstraintsForQualifiers(
394 394
 					$entity,
395 395
 					$statement,
396 396
 					$constraintIds,
397 397
 					$defaultResultsPerContext
398
-				) );
398
+				));
399 399
 		}
400 400
 
401
-		if ( $this->checkReferences ) {
402
-			$result = array_merge( $result,
401
+		if ($this->checkReferences) {
402
+			$result = array_merge($result,
403 403
 				$this->checkConstraintsForReferences(
404 404
 					$entity,
405 405
 					$statement,
406 406
 					$constraintIds,
407 407
 					$defaultResultsPerContext
408
-				) );
408
+				));
409 409
 		}
410 410
 
411 411
 		return $result;
@@ -420,12 +420,12 @@  discard block
 block discarded – undo
420 420
 	 * @param string[]|null $constraintIds
421 421
 	 * @return Constraint[]
422 422
 	 */
423
-	private function getConstraintsToUse( PropertyId $propertyId, array $constraintIds = null ) {
424
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
425
-		if ( $constraintIds !== null ) {
423
+	private function getConstraintsToUse(PropertyId $propertyId, array $constraintIds = null) {
424
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
425
+		if ($constraintIds !== null) {
426 426
 			$constraintsToUse = [];
427
-			foreach ( $constraints as $constraint ) {
428
-				if ( in_array( $constraint->getConstraintId(), $constraintIds ) ) {
427
+			foreach ($constraints as $constraint) {
428
+				if (in_array($constraint->getConstraintId(), $constraintIds)) {
429 429
 					$constraintsToUse[] = $constraint;
430 430
 				}
431 431
 			}
@@ -449,18 +449,18 @@  discard block
 block discarded – undo
449 449
 		array $constraintIds = null,
450 450
 		callable $defaultResults = null
451 451
 	) {
452
-		$context = new MainSnakContext( $entity, $statement );
452
+		$context = new MainSnakContext($entity, $statement);
453 453
 		$constraints = $this->getConstraintsToUse(
454 454
 			$statement->getPropertyId(),
455 455
 			$constraintIds
456 456
 		);
457
-		$result = $defaultResults !== null ? $defaultResults( $context ) : [];
457
+		$result = $defaultResults !== null ? $defaultResults($context) : [];
458 458
 
459
-		foreach ( $constraints as $constraint ) {
459
+		foreach ($constraints as $constraint) {
460 460
 			$parameters = $constraint->getConstraintParameters();
461 461
 			try {
462
-				$exceptions = $this->constraintParameterParser->parseExceptionParameter( $parameters );
463
-			} catch ( ConstraintParameterException $e ) {
462
+				$exceptions = $this->constraintParameterParser->parseExceptionParameter($parameters);
463
+			} catch (ConstraintParameterException $e) {
464 464
 				$result[] = new CheckResult(
465 465
 					$context,
466 466
 					$constraint,
@@ -470,13 +470,13 @@  discard block
 block discarded – undo
470 470
 				continue;
471 471
 			}
472 472
 
473
-			if ( in_array( $entity->getId(), $exceptions ) ) {
474
-				$message = new ViolationMessage( 'wbqc-violation-message-exception' );
475
-				$result[] = new CheckResult( $context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message );
473
+			if (in_array($entity->getId(), $exceptions)) {
474
+				$message = new ViolationMessage('wbqc-violation-message-exception');
475
+				$result[] = new CheckResult($context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message);
476 476
 				continue;
477 477
 			}
478 478
 
479
-			$result[] = $this->getCheckResultFor( $context, $constraint );
479
+			$result[] = $this->getCheckResultFor($context, $constraint);
480 480
 		}
481 481
 
482 482
 		return $result;
@@ -498,24 +498,24 @@  discard block
 block discarded – undo
498 498
 	) {
499 499
 		$result = [];
500 500
 
501
-		if ( in_array(
501
+		if (in_array(
502 502
 			$statement->getPropertyId()->getSerialization(),
503 503
 			$this->propertiesWithViolatingQualifiers
504
-		) ) {
504
+		)) {
505 505
 			return $result;
506 506
 		}
507 507
 
508
-		foreach ( $statement->getQualifiers() as $qualifier ) {
509
-			$qualifierContext = new QualifierContext( $entity, $statement, $qualifier );
510
-			if ( $defaultResultsPerContext !== null ) {
511
-				$result = array_merge( $result, $defaultResultsPerContext( $qualifierContext ) );
508
+		foreach ($statement->getQualifiers() as $qualifier) {
509
+			$qualifierContext = new QualifierContext($entity, $statement, $qualifier);
510
+			if ($defaultResultsPerContext !== null) {
511
+				$result = array_merge($result, $defaultResultsPerContext($qualifierContext));
512 512
 			}
513 513
 			$qualifierConstraints = $this->getConstraintsToUse(
514 514
 				$qualifierContext->getSnak()->getPropertyId(),
515 515
 				$constraintIds
516 516
 			);
517
-			foreach ( $qualifierConstraints as $qualifierConstraint ) {
518
-				$result[] = $this->getCheckResultFor( $qualifierContext, $qualifierConstraint );
517
+			foreach ($qualifierConstraints as $qualifierConstraint) {
518
+				$result[] = $this->getCheckResultFor($qualifierContext, $qualifierConstraint);
519 519
 			}
520 520
 		}
521 521
 
@@ -539,19 +539,19 @@  discard block
 block discarded – undo
539 539
 		$result = [];
540 540
 
541 541
 		/** @var Reference $reference */
542
-		foreach ( $statement->getReferences() as $reference ) {
543
-			foreach ( $reference->getSnaks() as $snak ) {
542
+		foreach ($statement->getReferences() as $reference) {
543
+			foreach ($reference->getSnaks() as $snak) {
544 544
 				$referenceContext = new ReferenceContext(
545 545
 					$entity, $statement, $reference, $snak
546 546
 				);
547
-				if ( $defaultResultsPerContext !== null ) {
548
-					$result = array_merge( $result, $defaultResultsPerContext( $referenceContext ) );
547
+				if ($defaultResultsPerContext !== null) {
548
+					$result = array_merge($result, $defaultResultsPerContext($referenceContext));
549 549
 				}
550 550
 				$referenceConstraints = $this->getConstraintsToUse(
551 551
 					$referenceContext->getSnak()->getPropertyId(),
552 552
 					$constraintIds
553 553
 				);
554
-				foreach ( $referenceConstraints as $referenceConstraint ) {
554
+				foreach ($referenceConstraints as $referenceConstraint) {
555 555
 					$result[] = $this->getCheckResultFor(
556 556
 						$referenceContext,
557 557
 						$referenceConstraint
@@ -570,20 +570,20 @@  discard block
 block discarded – undo
570 570
 	 * @throws InvalidArgumentException
571 571
 	 * @return CheckResult
572 572
 	 */
573
-	private function getCheckResultFor( Context $context, Constraint $constraint ) {
574
-		if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
573
+	private function getCheckResultFor(Context $context, Constraint $constraint) {
574
+		if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
575 575
 			$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
576
-			$result = $this->handleScope( $checker, $context, $constraint );
576
+			$result = $this->handleScope($checker, $context, $constraint);
577 577
 
578
-			if ( $result !== null ) {
579
-				$this->addMetadata( $context, $result );
578
+			if ($result !== null) {
579
+				$this->addMetadata($context, $result);
580 580
 				return $result;
581 581
 			}
582 582
 
583
-			$startTime = microtime( true );
583
+			$startTime = microtime(true);
584 584
 			try {
585
-				$result = $checker->checkConstraint( $context, $constraint );
586
-			} catch ( ConstraintParameterException $e ) {
585
+				$result = $checker->checkConstraint($context, $constraint);
586
+			} catch (ConstraintParameterException $e) {
587 587
 				$result = new CheckResult(
588 588
 					$context,
589 589
 					$constraint,
@@ -591,28 +591,28 @@  discard block
 block discarded – undo
591 591
 					CheckResult::STATUS_BAD_PARAMETERS,
592 592
 					$e->getViolationMessage()
593 593
 				);
594
-			} catch ( SparqlHelperException $e ) {
595
-				$message = new ViolationMessage( 'wbqc-violation-message-sparql-error' );
596
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, $message );
594
+			} catch (SparqlHelperException $e) {
595
+				$message = new ViolationMessage('wbqc-violation-message-sparql-error');
596
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, $message);
597 597
 			}
598
-			$endTime = microtime( true );
598
+			$endTime = microtime(true);
599 599
 
600
-			$this->addMetadata( $context, $result );
600
+			$this->addMetadata($context, $result);
601 601
 
602
-			$this->downgradeResultStatus( $context, $result );
602
+			$this->downgradeResultStatus($context, $result);
603 603
 
604 604
 			$this->loggingHelper->logConstraintCheck(
605 605
 				$context,
606 606
 				$constraint,
607 607
 				$result,
608
-				get_class( $checker ),
608
+				get_class($checker),
609 609
 				$endTime - $startTime,
610 610
 				__METHOD__
611 611
 			);
612 612
 
613 613
 			return $result;
614 614
 		} else {
615
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
615
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
616 616
 		}
617 617
 	}
618 618
 
@@ -621,84 +621,84 @@  discard block
 block discarded – undo
621 621
 		Context $context,
622 622
 		Constraint $constraint
623 623
 	): ?CheckResult {
624
-		$validContextTypes = $this->getAllowedContextTypes( $constraint );
625
-		$validEntityTypes = $this->getAllowedEntityTypes( $constraint );
624
+		$validContextTypes = $this->getAllowedContextTypes($constraint);
625
+		$validEntityTypes = $this->getAllowedEntityTypes($constraint);
626 626
 		try {
627
-			[ $checkedContextTypes, $checkedEntityTypes ] = $this->constraintParameterParser->parseConstraintScopeParameters(
627
+			[$checkedContextTypes, $checkedEntityTypes] = $this->constraintParameterParser->parseConstraintScopeParameters(
628 628
 				$constraint->getConstraintParameters(),
629 629
 				$constraint->getConstraintTypeItemId(),
630 630
 				$validContextTypes,
631 631
 				$validEntityTypes
632 632
 			);
633
-		} catch ( ConstraintParameterException $e ) {
634
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
633
+		} catch (ConstraintParameterException $e) {
634
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
635 635
 		}
636 636
 
637
-		if ( $checkedContextTypes === null ) {
637
+		if ($checkedContextTypes === null) {
638 638
 			$checkedContextTypes = $checker->getDefaultContextTypes();
639 639
 		}
640 640
 		$contextType = $context->getType();
641
-		if ( !in_array( $contextType, $checkedContextTypes ) ) {
642
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null );
641
+		if (!in_array($contextType, $checkedContextTypes)) {
642
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null);
643 643
 		}
644
-		if ( $checker->getSupportedContextTypes()[$contextType] === CheckResult::STATUS_TODO ) {
645
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
644
+		if ($checker->getSupportedContextTypes()[$contextType] === CheckResult::STATUS_TODO) {
645
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
646 646
 		}
647 647
 
648
-		if ( $checkedEntityTypes === null ) {
648
+		if ($checkedEntityTypes === null) {
649 649
 			$checkedEntityTypes = $validEntityTypes;
650 650
 		}
651 651
 		$entityType = $context->getEntity()->getType();
652
-		if ( !in_array( $entityType, $checkedEntityTypes ) ) {
653
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null );
652
+		if (!in_array($entityType, $checkedEntityTypes)) {
653
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null);
654 654
 		}
655
-		if ( $checker->getSupportedEntityTypes()[$entityType] === CheckResult::STATUS_TODO ) {
656
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
655
+		if ($checker->getSupportedEntityTypes()[$entityType] === CheckResult::STATUS_TODO) {
656
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
657 657
 		}
658 658
 
659 659
 		return null;
660 660
 	}
661 661
 
662
-	private function addMetadata( Context $context, CheckResult $result ) {
663
-		$result->withMetadata( Metadata::merge( [
662
+	private function addMetadata(Context $context, CheckResult $result) {
663
+		$result->withMetadata(Metadata::merge([
664 664
 			$result->getMetadata(),
665
-			Metadata::ofDependencyMetadata( DependencyMetadata::merge( [
666
-				DependencyMetadata::ofEntityId( $context->getEntity()->getId() ),
667
-				DependencyMetadata::ofEntityId( $result->getConstraint()->getPropertyId() ),
668
-			] ) ),
669
-		] ) );
665
+			Metadata::ofDependencyMetadata(DependencyMetadata::merge([
666
+				DependencyMetadata::ofEntityId($context->getEntity()->getId()),
667
+				DependencyMetadata::ofEntityId($result->getConstraint()->getPropertyId()),
668
+			])),
669
+		]));
670 670
 	}
671 671
 
672
-	private function downgradeResultStatus( Context $context, CheckResult &$result ) {
672
+	private function downgradeResultStatus(Context $context, CheckResult &$result) {
673 673
 		$constraint = $result->getConstraint();
674 674
 		try {
675 675
 			$constraintStatus = $this->constraintParameterParser
676
-				->parseConstraintStatusParameter( $constraint->getConstraintParameters() );
677
-		} catch ( ConstraintParameterException $e ) {
678
-			$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
676
+				->parseConstraintStatusParameter($constraint->getConstraintParameters());
677
+		} catch (ConstraintParameterException $e) {
678
+			$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
679 679
 			$constraintStatus = null;
680 680
 		}
681
-		if ( $constraintStatus === null ) {
681
+		if ($constraintStatus === null) {
682 682
 			// downgrade violation to warning
683
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
684
-				$result->setStatus( CheckResult::STATUS_WARNING );
683
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
684
+				$result->setStatus(CheckResult::STATUS_WARNING);
685 685
 			}
686
-		} elseif ( $constraintStatus === 'suggestion' ) {
686
+		} elseif ($constraintStatus === 'suggestion') {
687 687
 			// downgrade violation to suggestion
688
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
689
-				$result->setStatus( CheckResult::STATUS_SUGGESTION );
688
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
689
+				$result->setStatus(CheckResult::STATUS_SUGGESTION);
690 690
 			}
691
-			$result->addParameter( 'constraint_status', $constraintStatus );
691
+			$result->addParameter('constraint_status', $constraintStatus);
692 692
 		} else {
693
-			if ( $constraintStatus !== 'mandatory' ) {
693
+			if ($constraintStatus !== 'mandatory') {
694 694
 				// @codeCoverageIgnoreStart
695 695
 				throw new LogicException(
696
-					"Unknown constraint status '$constraintStatus', " .
696
+					"Unknown constraint status '$constraintStatus', ".
697 697
 					"only known statuses are 'mandatory' and 'suggestion'"
698 698
 				);
699 699
 				// @codeCoverageIgnoreEnd
700 700
 			}
701
-			$result->addParameter( 'constraint_status', $constraintStatus );
701
+			$result->addParameter('constraint_status', $constraintStatus);
702 702
 		}
703 703
 	}
704 704
 
@@ -707,12 +707,12 @@  discard block
 block discarded – undo
707 707
 	 *
708 708
 	 * @return CheckResult[]
709 709
 	 */
710
-	private function sortResult( array $result ) {
711
-		if ( count( $result ) < 2 ) {
710
+	private function sortResult(array $result) {
711
+		if (count($result) < 2) {
712 712
 			return $result;
713 713
 		}
714 714
 
715
-		$sortFunction = static function ( CheckResult $a, CheckResult $b ) {
715
+		$sortFunction = static function(CheckResult $a, CheckResult $b) {
716 716
 			$orderNum = 0;
717 717
 			$order = [
718 718
 				CheckResult::STATUS_BAD_PARAMETERS => $orderNum++,
@@ -729,55 +729,55 @@  discard block
 block discarded – undo
729 729
 			$statusA = $a->getStatus();
730 730
 			$statusB = $b->getStatus();
731 731
 
732
-			$orderA = array_key_exists( $statusA, $order ) ? $order[ $statusA ] : $order[ 'other' ];
733
-			$orderB = array_key_exists( $statusB, $order ) ? $order[ $statusB ] : $order[ 'other' ];
732
+			$orderA = array_key_exists($statusA, $order) ? $order[$statusA] : $order['other'];
733
+			$orderB = array_key_exists($statusB, $order) ? $order[$statusB] : $order['other'];
734 734
 
735
-			if ( $orderA === $orderB ) {
735
+			if ($orderA === $orderB) {
736 736
 				$cursorA = $a->getContextCursor();
737 737
 				$cursorB = $b->getContextCursor();
738 738
 
739
-				if ( $cursorA instanceof EntityContextCursor ) {
739
+				if ($cursorA instanceof EntityContextCursor) {
740 740
 					return $cursorB instanceof EntityContextCursor ? 0 : -1;
741 741
 				}
742
-				if ( $cursorB instanceof EntityContextCursor ) {
742
+				if ($cursorB instanceof EntityContextCursor) {
743 743
 					return $cursorA instanceof EntityContextCursor ? 0 : 1;
744 744
 				}
745 745
 
746 746
 				$pidA = $cursorA->getSnakPropertyId();
747 747
 				$pidB = $cursorB->getSnakPropertyId();
748 748
 
749
-				if ( $pidA === $pidB ) {
749
+				if ($pidA === $pidB) {
750 750
 					$hashA = $cursorA->getSnakHash();
751 751
 					$hashB = $cursorB->getSnakHash();
752 752
 
753
-					if ( $hashA === $hashB ) {
754
-						if ( $a instanceof NullResult ) {
753
+					if ($hashA === $hashB) {
754
+						if ($a instanceof NullResult) {
755 755
 							return $b instanceof NullResult ? 0 : -1;
756 756
 						}
757
-						if ( $b instanceof NullResult ) {
757
+						if ($b instanceof NullResult) {
758 758
 							return $a instanceof NullResult ? 0 : 1;
759 759
 						}
760 760
 
761 761
 						$typeA = $a->getConstraint()->getConstraintTypeItemId();
762 762
 						$typeB = $b->getConstraint()->getConstraintTypeItemId();
763 763
 
764
-						if ( $typeA == $typeB ) {
764
+						if ($typeA == $typeB) {
765 765
 							return 0;
766 766
 						} else {
767
-							return ( $typeA > $typeB ) ? 1 : -1;
767
+							return ($typeA > $typeB) ? 1 : -1;
768 768
 						}
769 769
 					} else {
770
-						return ( $hashA > $hashB ) ? 1 : -1;
770
+						return ($hashA > $hashB) ? 1 : -1;
771 771
 					}
772 772
 				} else {
773
-					return ( $pidA > $pidB ) ? 1 : -1;
773
+					return ($pidA > $pidB) ? 1 : -1;
774 774
 				}
775 775
 			} else {
776
-				return ( $orderA > $orderB ) ? 1 : -1;
776
+				return ($orderA > $orderB) ? 1 : -1;
777 777
 			}
778 778
 		};
779 779
 
780
-		uasort( $result, $sortFunction );
780
+		uasort($result, $sortFunction);
781 781
 
782 782
 		return $result;
783 783
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +278 added lines, -278 removed lines patch added patch discarded remove patch
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
 	 * @param array $parameters
78 78
 	 * @throws ConstraintParameterException
79 79
 	 */
80
-	public function checkError( array $parameters ) {
81
-		if ( array_key_exists( '@error', $parameters ) ) {
80
+	public function checkError(array $parameters) {
81
+		if (array_key_exists('@error', $parameters)) {
82 82
 			$error = $parameters['@error'];
83
-			if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) {
83
+			if (array_key_exists('toolong', $error) && $error['toolong']) {
84 84
 				$msg = 'wbqc-violation-message-parameters-error-toolong';
85 85
 			} else {
86 86
 				$msg = 'wbqc-violation-message-parameters-error-unknown';
87 87
 			}
88
-			throw new ConstraintParameterException( new ViolationMessage( $msg ) );
88
+			throw new ConstraintParameterException(new ViolationMessage($msg));
89 89
 		}
90 90
 	}
91 91
 
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 	 * @param string $parameterId
96 96
 	 * @throws ConstraintParameterException
97 97
 	 */
98
-	private function requireSingleParameter( array $parameters, $parameterId ) {
99
-		if ( count( $parameters[$parameterId] ) !== 1 ) {
98
+	private function requireSingleParameter(array $parameters, $parameterId) {
99
+		if (count($parameters[$parameterId]) !== 1) {
100 100
 			throw new ConstraintParameterException(
101
-				( new ViolationMessage( 'wbqc-violation-message-parameter-single' ) )
102
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
101
+				(new ViolationMessage('wbqc-violation-message-parameter-single'))
102
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
103 103
 			);
104 104
 		}
105 105
 	}
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	 * @return void
112 112
 	 * @throws ConstraintParameterException
113 113
 	 */
114
-	private function requireValueParameter( Snak $snak, $parameterId ) {
115
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
114
+	private function requireValueParameter(Snak $snak, $parameterId) {
115
+		if (!($snak instanceof PropertyValueSnak)) {
116 116
 			throw new ConstraintParameterException(
117
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
118
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
117
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
118
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
119 119
 			);
120 120
 		}
121 121
 	}
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
 	 * @throws ConstraintParameterException
128 128
 	 * @return EntityId
129 129
 	 */
130
-	private function parseEntityIdParameter( array $snakSerialization, $parameterId ) {
131
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
132
-		$this->requireValueParameter( $snak, $parameterId );
130
+	private function parseEntityIdParameter(array $snakSerialization, $parameterId) {
131
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
132
+		$this->requireValueParameter($snak, $parameterId);
133 133
 		$value = $snak->getDataValue();
134
-		if ( $value instanceof EntityIdValue ) {
134
+		if ($value instanceof EntityIdValue) {
135 135
 			return $value->getEntityId();
136 136
 		} else {
137 137
 			throw new ConstraintParameterException(
138
-				( new ViolationMessage( 'wbqc-violation-message-parameter-entity' ) )
139
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
140
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
138
+				(new ViolationMessage('wbqc-violation-message-parameter-entity'))
139
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
140
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
141 141
 			);
142 142
 		}
143 143
 	}
@@ -148,20 +148,20 @@  discard block
 block discarded – undo
148 148
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
149 149
 	 * @return string[] class entity ID serializations
150 150
 	 */
151
-	public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) {
152
-		$this->checkError( $constraintParameters );
153
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
154
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
151
+	public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) {
152
+		$this->checkError($constraintParameters);
153
+		$classId = $this->config->get('WBQualityConstraintsClassId');
154
+		if (!array_key_exists($classId, $constraintParameters)) {
155 155
 			throw new ConstraintParameterException(
156
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
157
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
158
-					->withEntityId( new PropertyId( $classId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
156
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
157
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
158
+					->withEntityId(new PropertyId($classId), Role::CONSTRAINT_PARAMETER_PROPERTY)
159 159
 			);
160 160
 		}
161 161
 
162 162
 		$classes = [];
163
-		foreach ( $constraintParameters[$classId] as $class ) {
164
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
163
+		foreach ($constraintParameters[$classId] as $class) {
164
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
165 165
 		}
166 166
 		return $classes;
167 167
 	}
@@ -172,31 +172,31 @@  discard block
 block discarded – undo
172 172
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
173 173
 	 * @return string 'instance', 'subclass', or 'instanceOrSubclass'
174 174
 	 */
175
-	public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) {
176
-		$this->checkError( $constraintParameters );
177
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
178
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
175
+	public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) {
176
+		$this->checkError($constraintParameters);
177
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
178
+		if (!array_key_exists($relationId, $constraintParameters)) {
179 179
 			throw new ConstraintParameterException(
180
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
181
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
182
-					->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
180
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
181
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
182
+					->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
183 183
 			);
184 184
 		}
185 185
 
186
-		$this->requireSingleParameter( $constraintParameters, $relationId );
187
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
188
-		if ( !( $relationEntityId instanceof ItemId ) ) {
186
+		$this->requireSingleParameter($constraintParameters, $relationId);
187
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
188
+		if (!($relationEntityId instanceof ItemId)) {
189 189
 			throw new ConstraintParameterException(
190
-				( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
191
-					->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
192
-					->withDataValue( new EntityIdValue( $relationEntityId ), Role::CONSTRAINT_PARAMETER_VALUE )
190
+				(new ViolationMessage('wbqc-violation-message-parameter-item'))
191
+					->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
192
+					->withDataValue(new EntityIdValue($relationEntityId), Role::CONSTRAINT_PARAMETER_VALUE)
193 193
 			);
194 194
 		}
195
-		return $this->mapItemId( $relationEntityId, [
196
-			$this->config->get( 'WBQualityConstraintsInstanceOfRelationId' ) => 'instance',
197
-			$this->config->get( 'WBQualityConstraintsSubclassOfRelationId' ) => 'subclass',
198
-			$this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' ) => 'instanceOrSubclass',
199
-		], $relationId );
195
+		return $this->mapItemId($relationEntityId, [
196
+			$this->config->get('WBQualityConstraintsInstanceOfRelationId') => 'instance',
197
+			$this->config->get('WBQualityConstraintsSubclassOfRelationId') => 'subclass',
198
+			$this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId') => 'instanceOrSubclass',
199
+		], $relationId);
200 200
 	}
201 201
 
202 202
 	/**
@@ -206,20 +206,20 @@  discard block
 block discarded – undo
206 206
 	 * @throws ConstraintParameterException
207 207
 	 * @return PropertyId
208 208
 	 */
209
-	private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) {
210
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
211
-		$this->requireValueParameter( $snak, $parameterId );
209
+	private function parsePropertyIdParameter(array $snakSerialization, $parameterId) {
210
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
211
+		$this->requireValueParameter($snak, $parameterId);
212 212
 		$value = $snak->getDataValue();
213
-		if ( $value instanceof EntityIdValue ) {
213
+		if ($value instanceof EntityIdValue) {
214 214
 			$id = $value->getEntityId();
215
-			if ( $id instanceof PropertyId ) {
215
+			if ($id instanceof PropertyId) {
216 216
 				return $id;
217 217
 			}
218 218
 		}
219 219
 		throw new ConstraintParameterException(
220
-			( new ViolationMessage( 'wbqc-violation-message-parameter-property' ) )
221
-				->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
222
-				->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
220
+			(new ViolationMessage('wbqc-violation-message-parameter-property'))
221
+				->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
222
+				->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
223 223
 		);
224 224
 	}
225 225
 
@@ -230,33 +230,33 @@  discard block
 block discarded – undo
230 230
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
231 231
 	 * @return PropertyId
232 232
 	 */
233
-	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
234
-		$this->checkError( $constraintParameters );
235
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
236
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
233
+	public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) {
234
+		$this->checkError($constraintParameters);
235
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
236
+		if (!array_key_exists($propertyId, $constraintParameters)) {
237 237
 			throw new ConstraintParameterException(
238
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
239
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
240
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
238
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
239
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
240
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
241 241
 			);
242 242
 		}
243 243
 
244
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
245
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
244
+		$this->requireSingleParameter($constraintParameters, $propertyId);
245
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
246 246
 	}
247 247
 
248
-	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
248
+	private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) {
249 249
 		$dataValue = $snak->getDataValue();
250
-		if ( $dataValue instanceof EntityIdValue ) {
250
+		if ($dataValue instanceof EntityIdValue) {
251 251
 			$entityId = $dataValue->getEntityId();
252
-			if ( $entityId instanceof ItemId ) {
253
-				return ItemIdSnakValue::fromItemId( $entityId );
252
+			if ($entityId instanceof ItemId) {
253
+				return ItemIdSnakValue::fromItemId($entityId);
254 254
 			}
255 255
 		}
256 256
 		throw new ConstraintParameterException(
257
-			( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
258
-				->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
259
-				->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
257
+			(new ViolationMessage('wbqc-violation-message-parameter-item'))
258
+				->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
259
+				->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
260 260
 		);
261 261
 	}
262 262
 
@@ -274,16 +274,16 @@  discard block
 block discarded – undo
274 274
 		$required,
275 275
 		$parameterId = null
276 276
 	) {
277
-		$this->checkError( $constraintParameters );
278
-		if ( $parameterId === null ) {
279
-			$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
277
+		$this->checkError($constraintParameters);
278
+		if ($parameterId === null) {
279
+			$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
280 280
 		}
281
-		if ( !array_key_exists( $parameterId, $constraintParameters ) ) {
282
-			if ( $required ) {
281
+		if (!array_key_exists($parameterId, $constraintParameters)) {
282
+			if ($required) {
283 283
 				throw new ConstraintParameterException(
284
-					( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
285
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
286
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
284
+					(new ViolationMessage('wbqc-violation-message-parameter-needed'))
285
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
286
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
287 287
 				);
288 288
 			} else {
289 289
 				return [];
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
 		}
292 292
 
293 293
 		$values = [];
294
-		foreach ( $constraintParameters[$parameterId] as $parameter ) {
295
-			$snak = $this->snakDeserializer->deserialize( $parameter );
296
-			switch ( true ) {
294
+		foreach ($constraintParameters[$parameterId] as $parameter) {
295
+			$snak = $this->snakDeserializer->deserialize($parameter);
296
+			switch (true) {
297 297
 				case $snak instanceof PropertyValueSnak:
298
-					$values[] = $this->parseItemIdParameter( $snak, $parameterId );
298
+					$values[] = $this->parseItemIdParameter($snak, $parameterId);
299 299
 					break;
300 300
 				case $snak instanceof PropertySomeValueSnak:
301 301
 					$values[] = ItemIdSnakValue::someValue();
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
 		bool $required,
324 324
 		string $parameterId
325 325
 	): array {
326
-		return array_map( static function ( ItemIdSnakValue $value ) use ( $parameterId ): ItemId {
327
-			if ( $value->isValue() ) {
326
+		return array_map(static function(ItemIdSnakValue $value) use ($parameterId): ItemId {
327
+			if ($value->isValue()) {
328 328
 				return $value->getItemId();
329 329
 			} else {
330 330
 				throw new ConstraintParameterException(
331
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
332
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
331
+					(new ViolationMessage('wbqc-violation-message-parameter-value'))
332
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
333 333
 				);
334 334
 			}
335 335
 		}, $this->parseItemsParameter(
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 			$constraintTypeItemId,
338 338
 			$required,
339 339
 			$parameterId
340
-		) );
340
+		));
341 341
 	}
342 342
 
343 343
 	/**
@@ -345,18 +345,18 @@  discard block
 block discarded – undo
345 345
 	 * @throws ConstraintParameterException
346 346
 	 * @return mixed elements of $mapping
347 347
 	 */
348
-	private function mapItemId( ItemId $itemId, array $mapping, string $parameterId ) {
348
+	private function mapItemId(ItemId $itemId, array $mapping, string $parameterId) {
349 349
 		$serialization = $itemId->getSerialization();
350
-		if ( array_key_exists( $serialization, $mapping ) ) {
350
+		if (array_key_exists($serialization, $mapping)) {
351 351
 			return $mapping[$serialization];
352 352
 		} else {
353
-			$allowed = array_map( static function ( $id ) {
354
-				return new ItemId( $id );
355
-			}, array_keys( $mapping ) );
353
+			$allowed = array_map(static function($id) {
354
+				return new ItemId($id);
355
+			}, array_keys($mapping));
356 356
 			throw new ConstraintParameterException(
357
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
358
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
359
-					->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
357
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
358
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
359
+					->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
360 360
 			);
361 361
 		}
362 362
 	}
@@ -367,27 +367,27 @@  discard block
 block discarded – undo
367 367
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
368 368
 	 * @return PropertyId[]
369 369
 	 */
370
-	public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) {
371
-		$this->checkError( $constraintParameters );
372
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
373
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
370
+	public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) {
371
+		$this->checkError($constraintParameters);
372
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
373
+		if (!array_key_exists($propertyId, $constraintParameters)) {
374 374
 			throw new ConstraintParameterException(
375
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
376
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
377
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
375
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
376
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
377
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
378 378
 			);
379 379
 		}
380 380
 
381 381
 		$parameters = $constraintParameters[$propertyId];
382
-		if ( count( $parameters ) === 1 &&
383
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
382
+		if (count($parameters) === 1 &&
383
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
384 384
 		) {
385 385
 			return [];
386 386
 		}
387 387
 
388 388
 		$properties = [];
389
-		foreach ( $parameters as $parameter ) {
390
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
389
+		foreach ($parameters as $parameter) {
390
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
391 391
 		}
392 392
 		return $properties;
393 393
 	}
@@ -398,16 +398,16 @@  discard block
 block discarded – undo
398 398
 	 * @throws ConstraintParameterException
399 399
 	 * @return DataValue|null
400 400
 	 */
401
-	private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) {
402
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
403
-		if ( $snak instanceof PropertyValueSnak ) {
401
+	private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) {
402
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
403
+		if ($snak instanceof PropertyValueSnak) {
404 404
 			return $snak->getDataValue();
405
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
405
+		} elseif ($snak instanceof PropertyNoValueSnak) {
406 406
 			return null;
407 407
 		} else {
408 408
 			throw new ConstraintParameterException(
409
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
410
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
409
+				(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
410
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
411 411
 			);
412 412
 		}
413 413
 	}
@@ -417,10 +417,10 @@  discard block
 block discarded – undo
417 417
 	 * @param string $parameterId
418 418
 	 * @return DataValue|null
419 419
 	 */
420
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) {
420
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) {
421 421
 		try {
422
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
423
-		} catch ( ConstraintParameterException $e ) {
422
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
423
+		} catch (ConstraintParameterException $e) {
424 424
 			// unknown value means “now”
425 425
 			return new NowValue();
426 426
 		}
@@ -433,14 +433,14 @@  discard block
 block discarded – undo
433 433
 	 * @param string $unit
434 434
 	 * @return bool
435 435
 	 */
436
-	private function exactlyOneQuantityWithUnit( ?DataValue $min, ?DataValue $max, $unit ) {
437
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
438
-			!( $max instanceof UnboundedQuantityValue )
436
+	private function exactlyOneQuantityWithUnit(?DataValue $min, ?DataValue $max, $unit) {
437
+		if (!($min instanceof UnboundedQuantityValue) ||
438
+			!($max instanceof UnboundedQuantityValue)
439 439
 		) {
440 440
 			return false;
441 441
 		}
442 442
 
443
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
443
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
444 444
 	}
445 445
 
446 446
 	/**
@@ -453,42 +453,42 @@  discard block
 block discarded – undo
453 453
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
454 454
 	 * @return DataValue[] if the parameter is invalid or missing
455 455
 	 */
456
-	private function parseRangeParameter( array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type ) {
457
-		$this->checkError( $constraintParameters );
458
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
459
-			!array_key_exists( $maximumId, $constraintParameters )
456
+	private function parseRangeParameter(array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type) {
457
+		$this->checkError($constraintParameters);
458
+		if (!array_key_exists($minimumId, $constraintParameters) ||
459
+			!array_key_exists($maximumId, $constraintParameters)
460 460
 		) {
461 461
 			throw new ConstraintParameterException(
462
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-needed' ) )
463
-					->withDataValueType( $type )
464
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
465
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
466
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
462
+				(new ViolationMessage('wbqc-violation-message-range-parameters-needed'))
463
+					->withDataValueType($type)
464
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
465
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
466
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
467 467
 			);
468 468
 		}
469 469
 
470
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
471
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
470
+		$this->requireSingleParameter($constraintParameters, $minimumId);
471
+		$this->requireSingleParameter($constraintParameters, $maximumId);
472 472
 		$parseFunction = $type === 'time' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
473
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
474
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
473
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
474
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
475 475
 
476
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
477
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
476
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
477
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
478 478
 			throw new ConstraintParameterException(
479
-				new ViolationMessage( 'wbqc-violation-message-range-parameters-one-year' )
479
+				new ViolationMessage('wbqc-violation-message-range-parameters-one-year')
480 480
 			);
481 481
 		}
482
-		if ( $min === null && $max === null ||
483
-			$min !== null && $max !== null && $min->equals( $max ) ) {
482
+		if ($min === null && $max === null ||
483
+			$min !== null && $max !== null && $min->equals($max)) {
484 484
 			throw new ConstraintParameterException(
485
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-same' ) )
486
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
487
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
485
+				(new ViolationMessage('wbqc-violation-message-range-parameters-same'))
486
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
487
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
488 488
 			);
489 489
 		}
490 490
 
491
-		return [ $min, $max ];
491
+		return [$min, $max];
492 492
 	}
493 493
 
494 494
 	/**
@@ -498,11 +498,11 @@  discard block
 block discarded – undo
498 498
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
499 499
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
500 500
 	 */
501
-	public function parseQuantityRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
501
+	public function parseQuantityRangeParameter(array $constraintParameters, $constraintTypeItemId) {
502 502
 		return $this->parseRangeParameter(
503 503
 			$constraintParameters,
504
-			$this->config->get( 'WBQualityConstraintsMinimumQuantityId' ),
505
-			$this->config->get( 'WBQualityConstraintsMaximumQuantityId' ),
504
+			$this->config->get('WBQualityConstraintsMinimumQuantityId'),
505
+			$this->config->get('WBQualityConstraintsMaximumQuantityId'),
506 506
 			$constraintTypeItemId,
507 507
 			'quantity'
508 508
 		);
@@ -515,11 +515,11 @@  discard block
 block discarded – undo
515 515
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
516 516
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
517 517
 	 */
518
-	public function parseTimeRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
518
+	public function parseTimeRangeParameter(array $constraintParameters, $constraintTypeItemId) {
519 519
 		return $this->parseRangeParameter(
520 520
 			$constraintParameters,
521
-			$this->config->get( 'WBQualityConstraintsMinimumDateId' ),
522
-			$this->config->get( 'WBQualityConstraintsMaximumDateId' ),
521
+			$this->config->get('WBQualityConstraintsMinimumDateId'),
522
+			$this->config->get('WBQualityConstraintsMaximumDateId'),
523 523
 			$constraintTypeItemId,
524 524
 			'time'
525 525
 		);
@@ -532,17 +532,17 @@  discard block
 block discarded – undo
532 532
 	 * @throws ConstraintParameterException
533 533
 	 * @return string
534 534
 	 */
535
-	private function parseStringParameter( array $snakSerialization, $parameterId ) {
536
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
537
-		$this->requireValueParameter( $snak, $parameterId );
535
+	private function parseStringParameter(array $snakSerialization, $parameterId) {
536
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
537
+		$this->requireValueParameter($snak, $parameterId);
538 538
 		$value = $snak->getDataValue();
539
-		if ( $value instanceof StringValue ) {
539
+		if ($value instanceof StringValue) {
540 540
 			return $value->getValue();
541 541
 		} else {
542 542
 			throw new ConstraintParameterException(
543
-				( new ViolationMessage( 'wbqc-violation-message-parameter-string' ) )
544
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
545
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
543
+				(new ViolationMessage('wbqc-violation-message-parameter-string'))
544
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
545
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
546 546
 			);
547 547
 		}
548 548
 	}
@@ -553,15 +553,15 @@  discard block
 block discarded – undo
553 553
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
554 554
 	 * @return string
555 555
 	 */
556
-	public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) {
557
-		$this->checkError( $constraintParameters );
558
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
559
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
556
+	public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) {
557
+		$this->checkError($constraintParameters);
558
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
559
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
560 560
 			return '';
561 561
 		}
562 562
 
563
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
564
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
563
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
564
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
565 565
 	}
566 566
 
567 567
 	/**
@@ -570,19 +570,19 @@  discard block
 block discarded – undo
570 570
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
571 571
 	 * @return string
572 572
 	 */
573
-	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
574
-		$this->checkError( $constraintParameters );
575
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
576
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
573
+	public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) {
574
+		$this->checkError($constraintParameters);
575
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
576
+		if (!array_key_exists($formatId, $constraintParameters)) {
577 577
 			throw new ConstraintParameterException(
578
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
579
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
580
-					->withEntityId( new PropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
578
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
579
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
580
+					->withEntityId(new PropertyId($formatId), Role::CONSTRAINT_PARAMETER_PROPERTY)
581 581
 			);
582 582
 		}
583 583
 
584
-		$this->requireSingleParameter( $constraintParameters, $formatId );
585
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
584
+		$this->requireSingleParameter($constraintParameters, $formatId);
585
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
586 586
 	}
587 587
 
588 588
 	/**
@@ -590,16 +590,16 @@  discard block
 block discarded – undo
590 590
 	 * @throws ConstraintParameterException if the parameter is invalid
591 591
 	 * @return EntityId[]
592 592
 	 */
593
-	public function parseExceptionParameter( array $constraintParameters ) {
594
-		$this->checkError( $constraintParameters );
595
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
596
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
593
+	public function parseExceptionParameter(array $constraintParameters) {
594
+		$this->checkError($constraintParameters);
595
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
596
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
597 597
 			return [];
598 598
 		}
599 599
 
600 600
 		return array_map(
601
-			function ( $snakSerialization ) use ( $exceptionId ) {
602
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
601
+			function($snakSerialization) use ($exceptionId) {
602
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
603 603
 			},
604 604
 			$constraintParameters[$exceptionId]
605 605
 		);
@@ -610,39 +610,39 @@  discard block
 block discarded – undo
610 610
 	 * @throws ConstraintParameterException if the parameter is invalid
611 611
 	 * @return string|null 'mandatory', 'suggestion' or null
612 612
 	 */
613
-	public function parseConstraintStatusParameter( array $constraintParameters ) {
614
-		$this->checkError( $constraintParameters );
615
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
616
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
613
+	public function parseConstraintStatusParameter(array $constraintParameters) {
614
+		$this->checkError($constraintParameters);
615
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
616
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
617 617
 			return null;
618 618
 		}
619 619
 
620
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
621
-		$supportedStatuses = [ new ItemId( $mandatoryId ) ];
622
-		if ( $this->config->get( 'WBQualityConstraintsEnableSuggestionConstraintStatus' ) ) {
623
-			$suggestionId = $this->config->get( 'WBQualityConstraintsSuggestionConstraintId' );
624
-			$supportedStatuses[] = new ItemId( $suggestionId );
620
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
621
+		$supportedStatuses = [new ItemId($mandatoryId)];
622
+		if ($this->config->get('WBQualityConstraintsEnableSuggestionConstraintStatus')) {
623
+			$suggestionId = $this->config->get('WBQualityConstraintsSuggestionConstraintId');
624
+			$supportedStatuses[] = new ItemId($suggestionId);
625 625
 		} else {
626 626
 			$suggestionId = null;
627 627
 		}
628 628
 
629
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
630
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
631
-		$this->requireValueParameter( $snak, $constraintStatusId );
629
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
630
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
631
+		$this->requireValueParameter($snak, $constraintStatusId);
632 632
 		'@phan-var \Wikibase\DataModel\Snak\PropertyValueSnak $snak';
633 633
 		$dataValue = $snak->getDataValue();
634 634
 		'@phan-var EntityIdValue $dataValue';
635 635
 		$entityId = $dataValue->getEntityId();
636 636
 		$statusId = $entityId->getSerialization();
637 637
 
638
-		if ( $statusId === $mandatoryId ) {
638
+		if ($statusId === $mandatoryId) {
639 639
 			return 'mandatory';
640
-		} elseif ( $statusId === $suggestionId ) {
640
+		} elseif ($statusId === $suggestionId) {
641 641
 			return 'suggestion';
642 642
 		} else {
643 643
 			throw new ConstraintParameterException(
644
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
645
-					->withEntityId( new PropertyId( $constraintStatusId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
644
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
645
+					->withEntityId(new PropertyId($constraintStatusId), Role::CONSTRAINT_PARAMETER_PROPERTY)
646 646
 					->withEntityIdList(
647 647
 						$supportedStatuses,
648 648
 						Role::CONSTRAINT_PARAMETER_VALUE
@@ -658,12 +658,12 @@  discard block
 block discarded – undo
658 658
 	 * @return void
659 659
 	 * @throws ConstraintParameterException
660 660
 	 */
661
-	private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) {
662
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
661
+	private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) {
662
+		if (!($dataValue instanceof MonolingualTextValue)) {
663 663
 			throw new ConstraintParameterException(
664
-				( new ViolationMessage( 'wbqc-violation-message-parameter-monolingualtext' ) )
665
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
666
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
664
+				(new ViolationMessage('wbqc-violation-message-parameter-monolingualtext'))
665
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
666
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
667 667
 			);
668 668
 		}
669 669
 	}
@@ -676,31 +676,31 @@  discard block
 block discarded – undo
676 676
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
677 677
 	 * @return MultilingualTextValue
678 678
 	 */
679
-	private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) {
679
+	private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) {
680 680
 		$result = [];
681 681
 
682
-		foreach ( $snakSerializations as $snakSerialization ) {
683
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
684
-			$this->requireValueParameter( $snak, $parameterId );
682
+		foreach ($snakSerializations as $snakSerialization) {
683
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
684
+			$this->requireValueParameter($snak, $parameterId);
685 685
 
686 686
 			$value = $snak->getDataValue();
687
-			$this->requireMonolingualTextParameter( $value, $parameterId );
687
+			$this->requireMonolingualTextParameter($value, $parameterId);
688 688
 			/** @var MonolingualTextValue $value */
689 689
 			'@phan-var MonolingualTextValue $value';
690 690
 
691 691
 			$code = $value->getLanguageCode();
692
-			if ( array_key_exists( $code, $result ) ) {
692
+			if (array_key_exists($code, $result)) {
693 693
 				throw new ConstraintParameterException(
694
-					( new ViolationMessage( 'wbqc-violation-message-parameter-single-per-language' ) )
695
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
696
-						->withLanguage( $code )
694
+					(new ViolationMessage('wbqc-violation-message-parameter-single-per-language'))
695
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
696
+						->withLanguage($code)
697 697
 				);
698 698
 			}
699 699
 
700 700
 			$result[$code] = $value;
701 701
 		}
702 702
 
703
-		return new MultilingualTextValue( $result );
703
+		return new MultilingualTextValue($result);
704 704
 	}
705 705
 
706 706
 	/**
@@ -708,11 +708,11 @@  discard block
 block discarded – undo
708 708
 	 * @throws ConstraintParameterException if the parameter is invalid
709 709
 	 * @return MultilingualTextValue
710 710
 	 */
711
-	public function parseSyntaxClarificationParameter( array $constraintParameters ) {
712
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
711
+	public function parseSyntaxClarificationParameter(array $constraintParameters) {
712
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
713 713
 
714
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
715
-			return new MultilingualTextValue( [] );
714
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
715
+			return new MultilingualTextValue([]);
716 716
 		}
717 717
 
718 718
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
@@ -745,14 +745,14 @@  discard block
 block discarded – undo
745 745
 		array $validContextTypes,
746 746
 		array $validEntityTypes
747 747
 	): array {
748
-		$contextTypeParameterId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
748
+		$contextTypeParameterId = $this->config->get('WBQualityConstraintsConstraintScopeId');
749 749
 		$contextTypeItemIds = $this->parseItemIdsParameter(
750 750
 			$constraintParameters,
751 751
 			$constraintTypeItemId,
752 752
 			false,
753 753
 			$contextTypeParameterId
754 754
 		);
755
-		$entityTypeParameterId = $this->config->get( 'WBQualityConstraintsConstraintEntityTypesId' );
755
+		$entityTypeParameterId = $this->config->get('WBQualityConstraintsConstraintEntityTypesId');
756 756
 		$entityTypeItemIds = $this->parseItemIdsParameter(
757 757
 			$constraintParameters,
758 758
 			$constraintTypeItemId,
@@ -768,26 +768,26 @@  discard block
 block discarded – undo
768 768
 		$contextTypes = null;
769 769
 		$entityTypes = null;
770 770
 
771
-		if ( $contextTypeParameterId === $entityTypeParameterId ) {
771
+		if ($contextTypeParameterId === $entityTypeParameterId) {
772 772
 			$itemIds = $contextTypeItemIds;
773 773
 			$mapping = $contextTypeMapping + $entityTypeMapping;
774
-			foreach ( $itemIds as $itemId ) {
775
-				$mapped = $this->mapItemId( $itemId, $mapping, $contextTypeParameterId );
776
-				if ( in_array( $mapped, $contextTypeMapping, true ) ) {
774
+			foreach ($itemIds as $itemId) {
775
+				$mapped = $this->mapItemId($itemId, $mapping, $contextTypeParameterId);
776
+				if (in_array($mapped, $contextTypeMapping, true)) {
777 777
 					$contextTypes[] = $mapped;
778 778
 				} else {
779 779
 					$entityTypes[] = $mapped;
780 780
 				}
781 781
 			}
782 782
 		} else {
783
-			foreach ( $contextTypeItemIds as $contextTypeItemId ) {
783
+			foreach ($contextTypeItemIds as $contextTypeItemId) {
784 784
 				$contextTypes[] = $this->mapItemId(
785 785
 					$contextTypeItemId,
786 786
 					$contextTypeMapping,
787 787
 					$contextTypeParameterId
788 788
 				);
789 789
 			}
790
-			foreach ( $entityTypeItemIds as $entityTypeItemId ) {
790
+			foreach ($entityTypeItemIds as $entityTypeItemId) {
791 791
 				$entityTypes[] = $this->mapItemId(
792 792
 					$entityTypeItemId,
793 793
 					$entityTypeMapping,
@@ -796,21 +796,21 @@  discard block
 block discarded – undo
796 796
 			}
797 797
 		}
798 798
 
799
-		$this->checkValidScope( $constraintTypeItemId, $contextTypes, $validContextTypes );
800
-		$this->checkValidScope( $constraintTypeItemId, $entityTypes, $validEntityTypes );
799
+		$this->checkValidScope($constraintTypeItemId, $contextTypes, $validContextTypes);
800
+		$this->checkValidScope($constraintTypeItemId, $entityTypes, $validEntityTypes);
801 801
 
802
-		return [ $contextTypes, $entityTypes ];
802
+		return [$contextTypes, $entityTypes];
803 803
 	}
804 804
 
805
-	private function checkValidScope( string $constraintTypeItemId, ?array $types, array $validTypes ): void {
806
-		$invalidTypes = array_diff( $types ?: [], $validTypes );
807
-		if ( $invalidTypes !== [] ) {
808
-			$invalidType = array_pop( $invalidTypes );
805
+	private function checkValidScope(string $constraintTypeItemId, ?array $types, array $validTypes): void {
806
+		$invalidTypes = array_diff($types ?: [], $validTypes);
807
+		if ($invalidTypes !== []) {
808
+			$invalidType = array_pop($invalidTypes);
809 809
 			throw new ConstraintParameterException(
810
-				( new ViolationMessage( 'wbqc-violation-message-invalid-scope' ) )
811
-					->withConstraintScope( $invalidType, Role::CONSTRAINT_PARAMETER_VALUE )
812
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
813
-					->withConstraintScopeList( $validTypes, Role::CONSTRAINT_PARAMETER_VALUE )
810
+				(new ViolationMessage('wbqc-violation-message-invalid-scope'))
811
+					->withConstraintScope($invalidType, Role::CONSTRAINT_PARAMETER_VALUE)
812
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
813
+					->withConstraintScopeList($validTypes, Role::CONSTRAINT_PARAMETER_VALUE)
814 814
 			);
815 815
 		}
816 816
 	}
@@ -821,8 +821,8 @@  discard block
 block discarded – undo
821 821
 	 * @param ItemId $unitId
822 822
 	 * @return string unit
823 823
 	 */
824
-	private function parseUnitParameter( ItemId $unitId ) {
825
-		return $this->unitItemConceptBaseUri . $unitId->getSerialization();
824
+	private function parseUnitParameter(ItemId $unitId) {
825
+		return $this->unitItemConceptBaseUri.$unitId->getSerialization();
826 826
 	}
827 827
 
828 828
 	/**
@@ -832,23 +832,23 @@  discard block
 block discarded – undo
832 832
 	 * @return UnitsParameter
833 833
 	 * @throws ConstraintParameterException
834 834
 	 */
835
-	private function parseUnitItem( ItemIdSnakValue $item ) {
836
-		switch ( true ) {
835
+	private function parseUnitItem(ItemIdSnakValue $item) {
836
+		switch (true) {
837 837
 			case $item->isValue():
838
-				$unit = $this->parseUnitParameter( $item->getItemId() );
838
+				$unit = $this->parseUnitParameter($item->getItemId());
839 839
 				return new UnitsParameter(
840
-					[ $item->getItemId() ],
841
-					[ UnboundedQuantityValue::newFromNumber( 1, $unit ) ],
840
+					[$item->getItemId()],
841
+					[UnboundedQuantityValue::newFromNumber(1, $unit)],
842 842
 					false
843 843
 				);
844 844
 			case $item->isSomeValue():
845
-				$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
845
+				$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
846 846
 				throw new ConstraintParameterException(
847
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
848
-						->withEntityId( new PropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
847
+					(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
848
+						->withEntityId(new PropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
849 849
 				);
850 850
 			case $item->isNoValue():
851
-				return new UnitsParameter( [], [], true );
851
+				return new UnitsParameter([], [], true);
852 852
 		}
853 853
 	}
854 854
 
@@ -858,36 +858,36 @@  discard block
 block discarded – undo
858 858
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
859 859
 	 * @return UnitsParameter
860 860
 	 */
861
-	public function parseUnitsParameter( array $constraintParameters, $constraintTypeItemId ) {
862
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
861
+	public function parseUnitsParameter(array $constraintParameters, $constraintTypeItemId) {
862
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
863 863
 		$unitItems = [];
864 864
 		$unitQuantities = [];
865 865
 		$unitlessAllowed = false;
866 866
 
867
-		foreach ( $items as $item ) {
868
-			$unit = $this->parseUnitItem( $item );
869
-			$unitItems = array_merge( $unitItems, $unit->getUnitItemIds() );
870
-			$unitQuantities = array_merge( $unitQuantities, $unit->getUnitQuantities() );
867
+		foreach ($items as $item) {
868
+			$unit = $this->parseUnitItem($item);
869
+			$unitItems = array_merge($unitItems, $unit->getUnitItemIds());
870
+			$unitQuantities = array_merge($unitQuantities, $unit->getUnitQuantities());
871 871
 			$unitlessAllowed = $unitlessAllowed || $unit->getUnitlessAllowed();
872 872
 		}
873 873
 
874
-		if ( $unitQuantities === [] && !$unitlessAllowed ) {
874
+		if ($unitQuantities === [] && !$unitlessAllowed) {
875 875
 			throw new LogicException(
876 876
 				'The "units" parameter is required, and yet we seem to be missing any allowed unit'
877 877
 			);
878 878
 		}
879 879
 
880
-		return new UnitsParameter( $unitItems, $unitQuantities, $unitlessAllowed );
880
+		return new UnitsParameter($unitItems, $unitQuantities, $unitlessAllowed);
881 881
 	}
882 882
 
883 883
 	private function getEntityTypeMapping(): array {
884 884
 		return [
885
-			$this->config->get( 'WBQualityConstraintsWikibaseItemId' ) => 'item',
886
-			$this->config->get( 'WBQualityConstraintsWikibasePropertyId' ) => 'property',
887
-			$this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ) => 'lexeme',
888
-			$this->config->get( 'WBQualityConstraintsWikibaseFormId' ) => 'form',
889
-			$this->config->get( 'WBQualityConstraintsWikibaseSenseId' ) => 'sense',
890
-			$this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ) => 'mediainfo',
885
+			$this->config->get('WBQualityConstraintsWikibaseItemId') => 'item',
886
+			$this->config->get('WBQualityConstraintsWikibasePropertyId') => 'property',
887
+			$this->config->get('WBQualityConstraintsWikibaseLexemeId') => 'lexeme',
888
+			$this->config->get('WBQualityConstraintsWikibaseFormId') => 'form',
889
+			$this->config->get('WBQualityConstraintsWikibaseSenseId') => 'sense',
890
+			$this->config->get('WBQualityConstraintsWikibaseMediaInfoId') => 'mediainfo',
891 891
 		];
892 892
 	}
893 893
 
@@ -897,10 +897,10 @@  discard block
 block discarded – undo
897 897
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
898 898
 	 * @return EntityTypesParameter
899 899
 	 */
900
-	public function parseEntityTypesParameter( array $constraintParameters, $constraintTypeItemId ) {
900
+	public function parseEntityTypesParameter(array $constraintParameters, $constraintTypeItemId) {
901 901
 		$entityTypes = [];
902 902
 		$entityTypeItemIds = [];
903
-		$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
903
+		$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
904 904
 		$itemIds = $this->parseItemIdsParameter(
905 905
 			$constraintParameters,
906 906
 			$constraintTypeItemId,
@@ -909,22 +909,22 @@  discard block
 block discarded – undo
909 909
 		);
910 910
 
911 911
 		$mapping = $this->getEntityTypeMapping();
912
-		foreach ( $itemIds as $itemId ) {
913
-			$entityType = $this->mapItemId( $itemId, $mapping, $parameterId );
912
+		foreach ($itemIds as $itemId) {
913
+			$entityType = $this->mapItemId($itemId, $mapping, $parameterId);
914 914
 			$entityTypes[] = $entityType;
915 915
 			$entityTypeItemIds[] = $itemId;
916 916
 		}
917 917
 
918
-		if ( empty( $entityTypes ) ) {
918
+		if (empty($entityTypes)) {
919 919
 			// @codeCoverageIgnoreStart
920 920
 			throw new LogicException(
921
-				'The "entity types" parameter is required, ' .
921
+				'The "entity types" parameter is required, '.
922 922
 				'and yet we seem to be missing any allowed entity type'
923 923
 			);
924 924
 			// @codeCoverageIgnoreEnd
925 925
 		}
926 926
 
927
-		return new EntityTypesParameter( $entityTypes, $entityTypeItemIds );
927
+		return new EntityTypesParameter($entityTypes, $entityTypeItemIds);
928 928
 	}
929 929
 
930 930
 	/**
@@ -932,18 +932,18 @@  discard block
 block discarded – undo
932 932
 	 * @throws ConstraintParameterException if the parameter is invalid
933 933
 	 * @return PropertyId[]
934 934
 	 */
935
-	public function parseSeparatorsParameter( array $constraintParameters ) {
936
-		$separatorId = $this->config->get( 'WBQualityConstraintsSeparatorId' );
935
+	public function parseSeparatorsParameter(array $constraintParameters) {
936
+		$separatorId = $this->config->get('WBQualityConstraintsSeparatorId');
937 937
 
938
-		if ( !array_key_exists( $separatorId, $constraintParameters ) ) {
938
+		if (!array_key_exists($separatorId, $constraintParameters)) {
939 939
 			return [];
940 940
 		}
941 941
 
942 942
 		$parameters = $constraintParameters[$separatorId];
943 943
 		$separators = [];
944 944
 
945
-		foreach ( $parameters as $parameter ) {
946
-			$separators[] = $this->parsePropertyIdParameter( $parameter, $separatorId );
945
+		foreach ($parameters as $parameter) {
946
+			$separators[] = $this->parsePropertyIdParameter($parameter, $separatorId);
947 947
 		}
948 948
 
949 949
 		return $separators;
@@ -951,17 +951,17 @@  discard block
 block discarded – undo
951 951
 
952 952
 	private function getConstraintScopeContextTypeMapping(): array {
953 953
 		return [
954
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' ) => Context::TYPE_STATEMENT,
955
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' ) => Context::TYPE_QUALIFIER,
956
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' ) => Context::TYPE_REFERENCE,
954
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId') => Context::TYPE_STATEMENT,
955
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId') => Context::TYPE_QUALIFIER,
956
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId') => Context::TYPE_REFERENCE,
957 957
 		];
958 958
 	}
959 959
 
960 960
 	private function getPropertyScopeContextTypeMapping(): array {
961 961
 		return [
962
-			$this->config->get( 'WBQualityConstraintsAsMainValueId' ) => Context::TYPE_STATEMENT,
963
-			$this->config->get( 'WBQualityConstraintsAsQualifiersId' ) => Context::TYPE_QUALIFIER,
964
-			$this->config->get( 'WBQualityConstraintsAsReferencesId' ) => Context::TYPE_REFERENCE,
962
+			$this->config->get('WBQualityConstraintsAsMainValueId') => Context::TYPE_STATEMENT,
963
+			$this->config->get('WBQualityConstraintsAsQualifiersId') => Context::TYPE_QUALIFIER,
964
+			$this->config->get('WBQualityConstraintsAsReferencesId') => Context::TYPE_REFERENCE,
965 965
 		];
966 966
 	}
967 967
 
@@ -971,9 +971,9 @@  discard block
 block discarded – undo
971 971
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
972 972
 	 * @return string[] list of Context::TYPE_* constants
973 973
 	 */
974
-	public function parsePropertyScopeParameter( array $constraintParameters, $constraintTypeItemId ) {
974
+	public function parsePropertyScopeParameter(array $constraintParameters, $constraintTypeItemId) {
975 975
 		$contextTypes = [];
976
-		$parameterId = $this->config->get( 'WBQualityConstraintsPropertyScopeId' );
976
+		$parameterId = $this->config->get('WBQualityConstraintsPropertyScopeId');
977 977
 		$itemIds = $this->parseItemIdsParameter(
978 978
 			$constraintParameters,
979 979
 			$constraintTypeItemId,
@@ -982,14 +982,14 @@  discard block
 block discarded – undo
982 982
 		);
983 983
 
984 984
 		$mapping = $this->getPropertyScopeContextTypeMapping();
985
-		foreach ( $itemIds as $itemId ) {
986
-			$contextTypes[] = $this->mapItemId( $itemId, $mapping, $parameterId );
985
+		foreach ($itemIds as $itemId) {
986
+			$contextTypes[] = $this->mapItemId($itemId, $mapping, $parameterId);
987 987
 		}
988 988
 
989
-		if ( empty( $contextTypes ) ) {
989
+		if (empty($contextTypes)) {
990 990
 			// @codeCoverageIgnoreStart
991 991
 			throw new LogicException(
992
-				'The "property scope" parameter is required, ' .
992
+				'The "property scope" parameter is required, '.
993 993
 				'and yet we seem to be missing any allowed scope'
994 994
 			);
995 995
 			// @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.