Completed
Push — master ( d48b91...d3e045 )
by
unknown
01:34 queued 11s
created
src/ConstraintCheck/DelegatingConstraintChecker.php 1 patch
Spacing   +146 added lines, -146 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,12 +221,12 @@  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 232
 	/**
@@ -237,32 +237,32 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return ConstraintParameterException[]
239 239
 	 */
240
-	private function checkCommonConstraintParameters( Constraint $constraint ) {
240
+	private function checkCommonConstraintParameters(Constraint $constraint) {
241 241
 		$constraintParameters = $constraint->getConstraintParameters();
242 242
 		try {
243
-			$this->constraintParameterParser->checkError( $constraintParameters );
244
-		} catch ( ConstraintParameterException $e ) {
245
-			return [ $e ];
243
+			$this->constraintParameterParser->checkError($constraintParameters);
244
+		} catch (ConstraintParameterException $e) {
245
+			return [$e];
246 246
 		}
247 247
 
248 248
 		$problems = [];
249 249
 		try {
250
-			$this->constraintParameterParser->parseExceptionParameter( $constraintParameters );
251
-		} catch ( ConstraintParameterException $e ) {
250
+			$this->constraintParameterParser->parseExceptionParameter($constraintParameters);
251
+		} catch (ConstraintParameterException $e) {
252 252
 			$problems[] = $e;
253 253
 		}
254 254
 		try {
255
-			$this->constraintParameterParser->parseConstraintStatusParameter( $constraintParameters );
256
-		} catch ( ConstraintParameterException $e ) {
255
+			$this->constraintParameterParser->parseConstraintStatusParameter($constraintParameters);
256
+		} catch (ConstraintParameterException $e) {
257 257
 			$problems[] = $e;
258 258
 		}
259 259
 		try {
260 260
 			$this->constraintParameterParser->parseConstraintScopeParameter(
261 261
 				$constraintParameters,
262 262
 				$constraint->getConstraintTypeItemId(),
263
-				$this->getAllowedContextTypes( $constraint )
263
+				$this->getAllowedContextTypes($constraint)
264 264
 			);
265
-		} catch ( ConstraintParameterException $e ) {
265
+		} catch (ConstraintParameterException $e) {
266 266
 			$problems[] = $e;
267 267
 		}
268 268
 		return $problems;
@@ -275,16 +275,16 @@  discard block
 block discarded – undo
275 275
 	 * @return ConstraintParameterException[][] first level indexed by constraint ID,
276 276
 	 * second level like checkConstraintParametersOnConstraintId (but without possibility of null)
277 277
 	 */
278
-	public function checkConstraintParametersOnPropertyId( PropertyId $propertyId ) {
279
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
278
+	public function checkConstraintParametersOnPropertyId(PropertyId $propertyId) {
279
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
280 280
 		$result = [];
281 281
 
282
-		foreach ( $constraints as $constraint ) {
283
-			$problems = $this->checkCommonConstraintParameters( $constraint );
282
+		foreach ($constraints as $constraint) {
283
+			$problems = $this->checkCommonConstraintParameters($constraint);
284 284
 
285
-			if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
285
+			if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
286 286
 				$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
287
-				$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
287
+				$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
288 288
 			}
289 289
 
290 290
 			$result[$constraint->getConstraintId()] = $problems;
@@ -301,18 +301,18 @@  discard block
 block discarded – undo
301 301
 	 * @return ConstraintParameterException[]|null list of constraint parameter exceptions
302 302
 	 * (empty means all parameters okay), or null if constraint is not found
303 303
 	 */
304
-	public function checkConstraintParametersOnConstraintId( $constraintId ) {
305
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
304
+	public function checkConstraintParametersOnConstraintId($constraintId) {
305
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
306 306
 		'@phan-var PropertyId $propertyId';
307
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
307
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
308 308
 
309
-		foreach ( $constraints as $constraint ) {
310
-			if ( $constraint->getConstraintId() === $constraintId ) {
311
-				$problems = $this->checkCommonConstraintParameters( $constraint );
309
+		foreach ($constraints as $constraint) {
310
+			if ($constraint->getConstraintId() === $constraintId) {
311
+				$problems = $this->checkCommonConstraintParameters($constraint);
312 312
 
313
-				if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
313
+				if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
314 314
 					$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
315
-					$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
315
+					$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
316 316
 				}
317 317
 
318 318
 				return $problems;
@@ -337,14 +337,14 @@  discard block
 block discarded – undo
337 337
 		$result = [];
338 338
 
339 339
 		/** @var Statement $statement */
340
-		foreach ( $entity->getStatements() as $statement ) {
341
-			$result = array_merge( $result,
340
+		foreach ($entity->getStatements() as $statement) {
341
+			$result = array_merge($result,
342 342
 				$this->checkStatement(
343 343
 					$entity,
344 344
 					$statement,
345 345
 					$constraintIds,
346 346
 					$defaultResultsPerContext
347
-				) );
347
+				));
348 348
 		}
349 349
 
350 350
 		return $result;
@@ -366,32 +366,32 @@  discard block
 block discarded – undo
366 366
 	) {
367 367
 		$result = [];
368 368
 
369
-		$result = array_merge( $result,
369
+		$result = array_merge($result,
370 370
 			$this->checkConstraintsForMainSnak(
371 371
 				$entity,
372 372
 				$statement,
373 373
 				$constraintIds,
374 374
 				$defaultResultsPerContext
375
-			) );
375
+			));
376 376
 
377
-		if ( $this->checkQualifiers ) {
378
-			$result = array_merge( $result,
377
+		if ($this->checkQualifiers) {
378
+			$result = array_merge($result,
379 379
 				$this->checkConstraintsForQualifiers(
380 380
 					$entity,
381 381
 					$statement,
382 382
 					$constraintIds,
383 383
 					$defaultResultsPerContext
384
-				) );
384
+				));
385 385
 		}
386 386
 
387
-		if ( $this->checkReferences ) {
388
-			$result = array_merge( $result,
387
+		if ($this->checkReferences) {
388
+			$result = array_merge($result,
389 389
 				$this->checkConstraintsForReferences(
390 390
 					$entity,
391 391
 					$statement,
392 392
 					$constraintIds,
393 393
 					$defaultResultsPerContext
394
-				) );
394
+				));
395 395
 		}
396 396
 
397 397
 		return $result;
@@ -406,12 +406,12 @@  discard block
 block discarded – undo
406 406
 	 * @param string[]|null $constraintIds
407 407
 	 * @return Constraint[]
408 408
 	 */
409
-	private function getConstraintsToUse( PropertyId $propertyId, array $constraintIds = null ) {
410
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
411
-		if ( $constraintIds !== null ) {
409
+	private function getConstraintsToUse(PropertyId $propertyId, array $constraintIds = null) {
410
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
411
+		if ($constraintIds !== null) {
412 412
 			$constraintsToUse = [];
413
-			foreach ( $constraints as $constraint ) {
414
-				if ( in_array( $constraint->getConstraintId(), $constraintIds ) ) {
413
+			foreach ($constraints as $constraint) {
414
+				if (in_array($constraint->getConstraintId(), $constraintIds)) {
415 415
 					$constraintsToUse[] = $constraint;
416 416
 				}
417 417
 			}
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
 		array $constraintIds = null,
436 436
 		callable $defaultResults = null
437 437
 	) {
438
-		$context = new MainSnakContext( $entity, $statement );
438
+		$context = new MainSnakContext($entity, $statement);
439 439
 		$constraints = $this->getConstraintsToUse(
440 440
 			$statement->getPropertyId(),
441 441
 			$constraintIds
442 442
 		);
443
-		$result = $defaultResults !== null ? $defaultResults( $context ) : [];
443
+		$result = $defaultResults !== null ? $defaultResults($context) : [];
444 444
 
445
-		foreach ( $constraints as $constraint ) {
445
+		foreach ($constraints as $constraint) {
446 446
 			$parameters = $constraint->getConstraintParameters();
447 447
 			try {
448
-				$exceptions = $this->constraintParameterParser->parseExceptionParameter( $parameters );
449
-			} catch ( ConstraintParameterException $e ) {
448
+				$exceptions = $this->constraintParameterParser->parseExceptionParameter($parameters);
449
+			} catch (ConstraintParameterException $e) {
450 450
 				$result[] = new CheckResult(
451 451
 					$context,
452 452
 					$constraint,
@@ -456,13 +456,13 @@  discard block
 block discarded – undo
456 456
 				continue;
457 457
 			}
458 458
 
459
-			if ( in_array( $entity->getId(), $exceptions ) ) {
460
-				$message = new ViolationMessage( 'wbqc-violation-message-exception' );
461
-				$result[] = new CheckResult( $context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message );
459
+			if (in_array($entity->getId(), $exceptions)) {
460
+				$message = new ViolationMessage('wbqc-violation-message-exception');
461
+				$result[] = new CheckResult($context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message);
462 462
 				continue;
463 463
 			}
464 464
 
465
-			$result[] = $this->getCheckResultFor( $context, $constraint );
465
+			$result[] = $this->getCheckResultFor($context, $constraint);
466 466
 		}
467 467
 
468 468
 		return $result;
@@ -484,24 +484,24 @@  discard block
 block discarded – undo
484 484
 	) {
485 485
 		$result = [];
486 486
 
487
-		if ( in_array(
487
+		if (in_array(
488 488
 			$statement->getPropertyId()->getSerialization(),
489 489
 			$this->propertiesWithViolatingQualifiers
490
-		) ) {
490
+		)) {
491 491
 			return $result;
492 492
 		}
493 493
 
494
-		foreach ( $statement->getQualifiers() as $qualifier ) {
495
-			$qualifierContext = new QualifierContext( $entity, $statement, $qualifier );
496
-			if ( $defaultResultsPerContext !== null ) {
497
-				$result = array_merge( $result, $defaultResultsPerContext( $qualifierContext ) );
494
+		foreach ($statement->getQualifiers() as $qualifier) {
495
+			$qualifierContext = new QualifierContext($entity, $statement, $qualifier);
496
+			if ($defaultResultsPerContext !== null) {
497
+				$result = array_merge($result, $defaultResultsPerContext($qualifierContext));
498 498
 			}
499 499
 			$qualifierConstraints = $this->getConstraintsToUse(
500 500
 				$qualifierContext->getSnak()->getPropertyId(),
501 501
 				$constraintIds
502 502
 			);
503
-			foreach ( $qualifierConstraints as $qualifierConstraint ) {
504
-				$result[] = $this->getCheckResultFor( $qualifierContext, $qualifierConstraint );
503
+			foreach ($qualifierConstraints as $qualifierConstraint) {
504
+				$result[] = $this->getCheckResultFor($qualifierContext, $qualifierConstraint);
505 505
 			}
506 506
 		}
507 507
 
@@ -525,19 +525,19 @@  discard block
 block discarded – undo
525 525
 		$result = [];
526 526
 
527 527
 		/** @var Reference $reference */
528
-		foreach ( $statement->getReferences() as $reference ) {
529
-			foreach ( $reference->getSnaks() as $snak ) {
528
+		foreach ($statement->getReferences() as $reference) {
529
+			foreach ($reference->getSnaks() as $snak) {
530 530
 				$referenceContext = new ReferenceContext(
531 531
 					$entity, $statement, $reference, $snak
532 532
 				);
533
-				if ( $defaultResultsPerContext !== null ) {
534
-					$result = array_merge( $result, $defaultResultsPerContext( $referenceContext ) );
533
+				if ($defaultResultsPerContext !== null) {
534
+					$result = array_merge($result, $defaultResultsPerContext($referenceContext));
535 535
 				}
536 536
 				$referenceConstraints = $this->getConstraintsToUse(
537 537
 					$referenceContext->getSnak()->getPropertyId(),
538 538
 					$constraintIds
539 539
 				);
540
-				foreach ( $referenceConstraints as $referenceConstraint ) {
540
+				foreach ($referenceConstraints as $referenceConstraint) {
541 541
 					$result[] = $this->getCheckResultFor(
542 542
 						$referenceContext,
543 543
 						$referenceConstraint
@@ -556,20 +556,20 @@  discard block
 block discarded – undo
556 556
 	 * @throws InvalidArgumentException
557 557
 	 * @return CheckResult
558 558
 	 */
559
-	private function getCheckResultFor( Context $context, Constraint $constraint ) {
560
-		if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
559
+	private function getCheckResultFor(Context $context, Constraint $constraint) {
560
+		if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
561 561
 			$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
562
-			$result = $this->handleScope( $checker, $context, $constraint );
562
+			$result = $this->handleScope($checker, $context, $constraint);
563 563
 
564
-			if ( $result !== null ) {
565
-				$this->addMetadata( $context, $result );
564
+			if ($result !== null) {
565
+				$this->addMetadata($context, $result);
566 566
 				return $result;
567 567
 			}
568 568
 
569
-			$startTime = microtime( true );
569
+			$startTime = microtime(true);
570 570
 			try {
571
-				$result = $checker->checkConstraint( $context, $constraint );
572
-			} catch ( ConstraintParameterException $e ) {
571
+				$result = $checker->checkConstraint($context, $constraint);
572
+			} catch (ConstraintParameterException $e) {
573 573
 				$result = new CheckResult(
574 574
 					$context,
575 575
 					$constraint,
@@ -577,28 +577,28 @@  discard block
 block discarded – undo
577 577
 					CheckResult::STATUS_BAD_PARAMETERS,
578 578
 					$e->getViolationMessage()
579 579
 				);
580
-			} catch ( SparqlHelperException $e ) {
581
-				$message = new ViolationMessage( 'wbqc-violation-message-sparql-error' );
582
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, $message );
580
+			} catch (SparqlHelperException $e) {
581
+				$message = new ViolationMessage('wbqc-violation-message-sparql-error');
582
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, $message);
583 583
 			}
584
-			$endTime = microtime( true );
584
+			$endTime = microtime(true);
585 585
 
586
-			$this->addMetadata( $context, $result );
586
+			$this->addMetadata($context, $result);
587 587
 
588
-			$this->downgradeResultStatus( $context, $result );
588
+			$this->downgradeResultStatus($context, $result);
589 589
 
590 590
 			$this->loggingHelper->logConstraintCheck(
591 591
 				$context,
592 592
 				$constraint,
593 593
 				$result,
594
-				get_class( $checker ),
594
+				get_class($checker),
595 595
 				$endTime - $startTime,
596 596
 				__METHOD__
597 597
 			);
598 598
 
599 599
 			return $result;
600 600
 		} else {
601
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
601
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
602 602
 		}
603 603
 	}
604 604
 
@@ -611,67 +611,67 @@  discard block
 block discarded – undo
611 611
 			$checkedContextTypes = $this->constraintParameterParser->parseConstraintScopeParameter(
612 612
 				$constraint->getConstraintParameters(),
613 613
 				$constraint->getConstraintTypeItemId(),
614
-				$this->getAllowedContextTypes( $constraint )
614
+				$this->getAllowedContextTypes($constraint)
615 615
 			);
616
-		} catch ( ConstraintParameterException $e ) {
617
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
616
+		} catch (ConstraintParameterException $e) {
617
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
618 618
 		}
619
-		if ( $checkedContextTypes === null ) {
619
+		if ($checkedContextTypes === null) {
620 620
 			$checkedContextTypes = $checker->getDefaultContextTypes();
621 621
 		}
622
-		if ( !in_array( $context->getType(), $checkedContextTypes ) ) {
623
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null );
622
+		if (!in_array($context->getType(), $checkedContextTypes)) {
623
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null);
624 624
 		}
625
-		if ( $checker->getSupportedContextTypes()[$context->getType()] === CheckResult::STATUS_TODO ) {
626
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
625
+		if ($checker->getSupportedContextTypes()[$context->getType()] === CheckResult::STATUS_TODO) {
626
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
627 627
 		}
628 628
 		$statusForEntityType = $checker->getSupportedEntityTypes()[$context->getEntity()->getType()];
629
-		if ( $statusForEntityType !== CheckResult::STATUS_COMPLIANCE ) {
630
-			return new CheckResult( $context, $constraint, [], $statusForEntityType, null );
629
+		if ($statusForEntityType !== CheckResult::STATUS_COMPLIANCE) {
630
+			return new CheckResult($context, $constraint, [], $statusForEntityType, null);
631 631
 		}
632 632
 		return null;
633 633
 	}
634 634
 
635
-	private function addMetadata( Context $context, CheckResult $result ) {
636
-		$result->withMetadata( Metadata::merge( [
635
+	private function addMetadata(Context $context, CheckResult $result) {
636
+		$result->withMetadata(Metadata::merge([
637 637
 			$result->getMetadata(),
638
-			Metadata::ofDependencyMetadata( DependencyMetadata::merge( [
639
-				DependencyMetadata::ofEntityId( $context->getEntity()->getId() ),
640
-				DependencyMetadata::ofEntityId( $result->getConstraint()->getPropertyId() ),
641
-			] ) ),
642
-		] ) );
638
+			Metadata::ofDependencyMetadata(DependencyMetadata::merge([
639
+				DependencyMetadata::ofEntityId($context->getEntity()->getId()),
640
+				DependencyMetadata::ofEntityId($result->getConstraint()->getPropertyId()),
641
+			])),
642
+		]));
643 643
 	}
644 644
 
645
-	private function downgradeResultStatus( Context $context, CheckResult &$result ) {
645
+	private function downgradeResultStatus(Context $context, CheckResult &$result) {
646 646
 		$constraint = $result->getConstraint();
647 647
 		try {
648 648
 			$constraintStatus = $this->constraintParameterParser
649
-				->parseConstraintStatusParameter( $constraint->getConstraintParameters() );
650
-		} catch ( ConstraintParameterException $e ) {
651
-			$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
649
+				->parseConstraintStatusParameter($constraint->getConstraintParameters());
650
+		} catch (ConstraintParameterException $e) {
651
+			$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
652 652
 			$constraintStatus = null;
653 653
 		}
654
-		if ( $constraintStatus === null ) {
654
+		if ($constraintStatus === null) {
655 655
 			// downgrade violation to warning
656
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
657
-				$result->setStatus( CheckResult::STATUS_WARNING );
656
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
657
+				$result->setStatus(CheckResult::STATUS_WARNING);
658 658
 			}
659
-		} elseif ( $constraintStatus === 'suggestion' ) {
659
+		} elseif ($constraintStatus === 'suggestion') {
660 660
 			// downgrade violation to suggestion
661
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
662
-				$result->setStatus( CheckResult::STATUS_SUGGESTION );
661
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
662
+				$result->setStatus(CheckResult::STATUS_SUGGESTION);
663 663
 			}
664
-			$result->addParameter( 'constraint_status', $constraintStatus );
664
+			$result->addParameter('constraint_status', $constraintStatus);
665 665
 		} else {
666
-			if ( $constraintStatus !== 'mandatory' ) {
666
+			if ($constraintStatus !== 'mandatory') {
667 667
 				// @codeCoverageIgnoreStart
668 668
 				throw new LogicException(
669
-					"Unknown constraint status '$constraintStatus', " .
669
+					"Unknown constraint status '$constraintStatus', ".
670 670
 					"only known statuses are 'mandatory' and 'suggestion'"
671 671
 				);
672 672
 				// @codeCoverageIgnoreEnd
673 673
 			}
674
-			$result->addParameter( 'constraint_status', $constraintStatus );
674
+			$result->addParameter('constraint_status', $constraintStatus);
675 675
 		}
676 676
 	}
677 677
 
@@ -680,12 +680,12 @@  discard block
 block discarded – undo
680 680
 	 *
681 681
 	 * @return CheckResult[]
682 682
 	 */
683
-	private function sortResult( array $result ) {
684
-		if ( count( $result ) < 2 ) {
683
+	private function sortResult(array $result) {
684
+		if (count($result) < 2) {
685 685
 			return $result;
686 686
 		}
687 687
 
688
-		$sortFunction = static function ( CheckResult $a, CheckResult $b ) {
688
+		$sortFunction = static function(CheckResult $a, CheckResult $b) {
689 689
 			$orderNum = 0;
690 690
 			$order = [
691 691
 				CheckResult::STATUS_BAD_PARAMETERS => $orderNum++,
@@ -702,55 +702,55 @@  discard block
 block discarded – undo
702 702
 			$statusA = $a->getStatus();
703 703
 			$statusB = $b->getStatus();
704 704
 
705
-			$orderA = array_key_exists( $statusA, $order ) ? $order[ $statusA ] : $order[ 'other' ];
706
-			$orderB = array_key_exists( $statusB, $order ) ? $order[ $statusB ] : $order[ 'other' ];
705
+			$orderA = array_key_exists($statusA, $order) ? $order[$statusA] : $order['other'];
706
+			$orderB = array_key_exists($statusB, $order) ? $order[$statusB] : $order['other'];
707 707
 
708
-			if ( $orderA === $orderB ) {
708
+			if ($orderA === $orderB) {
709 709
 				$cursorA = $a->getContextCursor();
710 710
 				$cursorB = $b->getContextCursor();
711 711
 
712
-				if ( $cursorA instanceof EntityContextCursor ) {
712
+				if ($cursorA instanceof EntityContextCursor) {
713 713
 					return $cursorB instanceof EntityContextCursor ? 0 : -1;
714 714
 				}
715
-				if ( $cursorB instanceof EntityContextCursor ) {
715
+				if ($cursorB instanceof EntityContextCursor) {
716 716
 					return $cursorA instanceof EntityContextCursor ? 0 : 1;
717 717
 				}
718 718
 
719 719
 				$pidA = $cursorA->getSnakPropertyId();
720 720
 				$pidB = $cursorB->getSnakPropertyId();
721 721
 
722
-				if ( $pidA === $pidB ) {
722
+				if ($pidA === $pidB) {
723 723
 					$hashA = $cursorA->getSnakHash();
724 724
 					$hashB = $cursorB->getSnakHash();
725 725
 
726
-					if ( $hashA === $hashB ) {
727
-						if ( $a instanceof NullResult ) {
726
+					if ($hashA === $hashB) {
727
+						if ($a instanceof NullResult) {
728 728
 							return $b instanceof NullResult ? 0 : -1;
729 729
 						}
730
-						if ( $b instanceof NullResult ) {
730
+						if ($b instanceof NullResult) {
731 731
 							return $a instanceof NullResult ? 0 : 1;
732 732
 						}
733 733
 
734 734
 						$typeA = $a->getConstraint()->getConstraintTypeItemId();
735 735
 						$typeB = $b->getConstraint()->getConstraintTypeItemId();
736 736
 
737
-						if ( $typeA == $typeB ) {
737
+						if ($typeA == $typeB) {
738 738
 							return 0;
739 739
 						} else {
740
-							return ( $typeA > $typeB ) ? 1 : -1;
740
+							return ($typeA > $typeB) ? 1 : -1;
741 741
 						}
742 742
 					} else {
743
-						return ( $hashA > $hashB ) ? 1 : -1;
743
+						return ($hashA > $hashB) ? 1 : -1;
744 744
 					}
745 745
 				} else {
746
-					return ( $pidA > $pidB ) ? 1 : -1;
746
+					return ($pidA > $pidB) ? 1 : -1;
747 747
 				}
748 748
 			} else {
749
-				return ( $orderA > $orderB ) ? 1 : -1;
749
+				return ($orderA > $orderB) ? 1 : -1;
750 750
 			}
751 751
 		};
752 752
 
753
-		uasort( $result, $sortFunction );
753
+		uasort($result, $sortFunction);
754 754
 
755 755
 		return $result;
756 756
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/Lexeme/LanguageChecker.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 	 * @throws ConstraintParameterException
85 85
 	 * @return CheckResult
86 86
 	 */
87
-	public function checkConstraint( Context $context, Constraint $constraint ) {
88
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
89
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
87
+	public function checkConstraint(Context $context, Constraint $constraint) {
88
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
89
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
90 90
 		}
91 91
 
92 92
 		$parameters = [];
@@ -100,50 +100,50 @@  discard block
 block discarded – undo
100 100
 		);
101 101
 		$parameters['languages'] = $languages;
102 102
 
103
-		$message = ( new ViolationMessage( 'wbqc-violation-message-language' ) )
104
-			->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE )
105
-			->withItemIdSnakValueList( $languages, Role::OBJECT );
103
+		$message = (new ViolationMessage('wbqc-violation-message-language'))
104
+			->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)
105
+			->withItemIdSnakValueList($languages, Role::OBJECT);
106 106
 		$status = CheckResult::STATUS_VIOLATION;
107 107
 
108
-		$lexeme = $this->getLexeme( $context );
109
-		if ( !$lexeme ) {
108
+		$lexeme = $this->getLexeme($context);
109
+		if (!$lexeme) {
110 110
 			// Lexeme doesn't exist, let's not bother
111
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE );
111
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE);
112 112
 		}
113 113
 
114 114
 		/** @var Lexeme $lexeme */
115 115
 		'@phan-var Lexeme $lexeme';
116 116
 
117
-		foreach ( $languages as $language ) {
118
-			if ( $language->isNoValue() || $language->isSomeValue() ) {
117
+		foreach ($languages as $language) {
118
+			if ($language->isNoValue() || $language->isSomeValue()) {
119 119
 				continue;
120 120
 			}
121
-			if ( $lexeme->getLanguage()->equals( $language->getItemId() ) ) {
121
+			if ($lexeme->getLanguage()->equals($language->getItemId())) {
122 122
 				$message = null;
123 123
 				$status = CheckResult::STATUS_COMPLIANCE;
124 124
 				break;
125 125
 			}
126 126
 		}
127 127
 
128
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
128
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
129 129
 	}
130 130
 
131
-	private function getLexeme( Context $context ): ?EntityDocument {
131
+	private function getLexeme(Context $context): ?EntityDocument {
132 132
 		$entityType = $context->getEntity()->getType();
133 133
 
134
-		if ( $entityType === Lexeme::ENTITY_TYPE ) {
134
+		if ($entityType === Lexeme::ENTITY_TYPE) {
135 135
 			return $context->getEntity();
136 136
 		}
137 137
 
138
-		if ( in_array( $entityType, [ Form::ENTITY_TYPE, Sense::ENTITY_TYPE ] ) ) {
138
+		if (in_array($entityType, [Form::ENTITY_TYPE, Sense::ENTITY_TYPE])) {
139 139
 			/** @var LexemeSubEntityId $id */
140 140
 			$id = $context->getEntity()->getId();
141 141
 			'@phan-var LexemeSubEntityId $id';
142
-			return $this->entityLookup->getEntity( $id->getLexemeId() );
142
+			return $this->entityLookup->getEntity($id->getLexemeId());
143 143
 		}
144 144
 	}
145 145
 
146
-	public function checkConstraintParameters( Constraint $constraint ): array {
146
+	public function checkConstraintParameters(Constraint $constraint): array {
147 147
 		$constraintParameters = $constraint->getConstraintParameters();
148 148
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
149 149
 		$exceptions = [];
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 				$constraintTypeItemId,
154 154
 				true
155 155
 			);
156
-		} catch ( ConstraintParameterException $e ) {
156
+		} catch (ConstraintParameterException $e) {
157 157
 			$exceptions[] = $e;
158 158
 		}
159 159
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/PropertyScopeChecker.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
55 55
 	}
56 56
 
57
-	public function checkConstraint( Context $context, Constraint $constraint ) {
57
+	public function checkConstraint(Context $context, Constraint $constraint) {
58 58
 		$constraintParameters = $constraint->getConstraintParameters();
59 59
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
60 60
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			$constraintTypeItemId
64 64
 		);
65 65
 
66
-		if ( in_array( $context->getType(), $allowedContextTypes ) ) {
66
+		if (in_array($context->getType(), $allowedContextTypes)) {
67 67
 			return new CheckResult(
68 68
 				$context->getCursor(),
69 69
 				$constraint,
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 				$constraint,
77 77
 				[],
78 78
 				CheckResult::STATUS_VIOLATION,
79
-				( new ViolationMessage( 'wbqc-violation-message-property-scope' ) )
80
-					->withEntityId( $context->getSnak()->getPropertyId() )
81
-					->withPropertyScope( $context->getType() )
82
-					->withPropertyScopeList( $allowedContextTypes )
79
+				(new ViolationMessage('wbqc-violation-message-property-scope'))
80
+					->withEntityId($context->getSnak()->getPropertyId())
81
+					->withPropertyScope($context->getType())
82
+					->withPropertyScopeList($allowedContextTypes)
83 83
 			);
84 84
 		}
85 85
 	}
86 86
 
87
-	public function checkConstraintParameters( Constraint $constraint ) {
87
+	public function checkConstraintParameters(Constraint $constraint) {
88 88
 		$constraintParameters = $constraint->getConstraintParameters();
89 89
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
90 90
 		$exceptions = [];
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 				$constraintParameters,
94 94
 				$constraintTypeItemId
95 95
 			);
96
-		} catch ( ConstraintParameterException $e ) {
96
+		} catch (ConstraintParameterException $e) {
97 97
 			$exceptions[] = $e;
98 98
 		}
99 99
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ContemporaryChecker.php 1 patch
Spacing   +42 added lines, -43 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * @codeCoverageIgnore This method is purely declarative.
80 80
 	 */
81 81
 	public function getDefaultContextTypes() {
82
-		return [ Context::TYPE_STATEMENT ];
82
+		return [Context::TYPE_STATEMENT];
83 83
 	}
84 84
 
85 85
 	/** @codeCoverageIgnore This method is purely declarative. */
@@ -96,31 +96,31 @@  discard block
 block discarded – undo
96 96
 	 * @return CheckResult
97 97
 	 * @throws \ConfigException
98 98
 	 */
99
-	public function checkConstraint( Context $context, Constraint $constraint ) {
100
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
101
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
99
+	public function checkConstraint(Context $context, Constraint $constraint) {
100
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
101
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
102 102
 		}
103 103
 		$snak = $context->getSnak();
104
-		if ( !$snak instanceof PropertyValueSnak ) {
104
+		if (!$snak instanceof PropertyValueSnak) {
105 105
 			// nothing to check
106
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
106
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
107 107
 		}
108 108
 
109 109
 		$dataValue = $snak->getDataValue();
110
-		if ( !$dataValue instanceof EntityIdValue ) {
110
+		if (!$dataValue instanceof EntityIdValue) {
111 111
 			// wrong data type
112
-			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
113
-				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
114
-				->withDataValueType( 'wikibase-entityid' );
115
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
112
+			$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type'))
113
+				->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM)
114
+				->withDataValueType('wikibase-entityid');
115
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
116 116
 		}
117 117
 
118 118
 		$objectId = $dataValue->getEntityId();
119
-		$objectItem = $this->entityLookup->getEntity( $objectId );
120
-		if ( !( $objectItem instanceof StatementListProvider ) ) {
119
+		$objectItem = $this->entityLookup->getEntity($objectId);
120
+		if (!($objectItem instanceof StatementListProvider)) {
121 121
 			// object was deleted/doesn't exist
122
-			$message = new ViolationMessage( 'wbqc-violation-message-value-entity-must-exist' );
123
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
122
+			$message = new ViolationMessage('wbqc-violation-message-value-entity-must-exist');
123
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
124 124
 		}
125 125
 		/** @var Statement[] $objectStatements */
126 126
 		$objectStatements = $objectItem->getStatements()->toArray();
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 		$subjectId = $context->getEntity()->getId();
129 129
 		$subjectStatements = $context->getEntity()->getStatements()->toArray();
130 130
 		/** @var String[] $startPropertyIds */
131
-		$startPropertyIds = $this->config->get( self::CONFIG_VARIABLE_START_PROPERTY_IDS );
131
+		$startPropertyIds = $this->config->get(self::CONFIG_VARIABLE_START_PROPERTY_IDS);
132 132
 		/** @var String[] $endPropertyIds */
133
-		$endPropertyIds = $this->config->get( self::CONFIG_VARIABLE_END_PROPERTY_IDS );
133
+		$endPropertyIds = $this->config->get(self::CONFIG_VARIABLE_END_PROPERTY_IDS);
134 134
 		$subjectStartValue = $this->getExtremeValue(
135 135
 			$startPropertyIds,
136 136
 			$subjectStatements,
@@ -152,15 +152,15 @@  discard block
 block discarded – undo
152 152
 			'end'
153 153
 		);
154 154
 		if (
155
-			$this->rangeCheckerHelper->getComparison( $subjectStartValue, $subjectEndValue ) <= 0 &&
156
-			$this->rangeCheckerHelper->getComparison( $objectStartValue, $objectEndValue ) <= 0 && (
157
-				$this->rangeCheckerHelper->getComparison( $subjectEndValue, $objectStartValue ) < 0 ||
158
-				$this->rangeCheckerHelper->getComparison( $objectEndValue, $subjectStartValue ) < 0
155
+			$this->rangeCheckerHelper->getComparison($subjectStartValue, $subjectEndValue) <= 0 &&
156
+			$this->rangeCheckerHelper->getComparison($objectStartValue, $objectEndValue) <= 0 && (
157
+				$this->rangeCheckerHelper->getComparison($subjectEndValue, $objectStartValue) < 0 ||
158
+				$this->rangeCheckerHelper->getComparison($objectEndValue, $subjectStartValue) < 0
159 159
 			)
160 160
 		) {
161 161
 			if (
162 162
 				$subjectEndValue == null ||
163
-				$this->rangeCheckerHelper->getComparison( $objectEndValue, $subjectEndValue ) < 0
163
+				$this->rangeCheckerHelper->getComparison($objectEndValue, $subjectEndValue) < 0
164 164
 			) {
165 165
 				$earlierEntityId = $objectId;
166 166
 				$minEndValue = $objectEndValue;
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			$message = null;
184 184
 			$status = CheckResult::STATUS_COMPLIANCE;
185 185
 		}
186
-		return new CheckResult( $context, $constraint, [], $status, $message );
186
+		return new CheckResult($context, $constraint, [], $status, $message);
187 187
 	}
188 188
 
189 189
 	/**
@@ -193,19 +193,19 @@  discard block
 block discarded – undo
193 193
 	 *
194 194
 	 * @return DataValue|null
195 195
 	 */
196
-	private function getExtremeValue( $extremePropertyIds, $statements, $startOrEnd ) {
197
-		if ( $startOrEnd !== 'start' && $startOrEnd !== 'end' ) {
198
-			throw new \InvalidArgumentException( '$startOrEnd must be \'start\' or \'end\'.' );
196
+	private function getExtremeValue($extremePropertyIds, $statements, $startOrEnd) {
197
+		if ($startOrEnd !== 'start' && $startOrEnd !== 'end') {
198
+			throw new \InvalidArgumentException('$startOrEnd must be \'start\' or \'end\'.');
199 199
 		}
200 200
 		$extremeValue = null;
201
-		foreach ( $extremePropertyIds as $extremePropertyId ) {
202
-			$statementList = new StatementList( ...$statements );
203
-			$extremeStatements = $statementList->getByPropertyId( new PropertyId( $extremePropertyId ) );
201
+		foreach ($extremePropertyIds as $extremePropertyId) {
202
+			$statementList = new StatementList(...$statements);
203
+			$extremeStatements = $statementList->getByPropertyId(new PropertyId($extremePropertyId));
204 204
 			/** @var Statement $extremeStatement */
205
-			foreach ( $extremeStatements as $extremeStatement ) {
206
-				if ( $extremeStatement->getRank() !== Statement::RANK_DEPRECATED ) {
205
+			foreach ($extremeStatements as $extremeStatement) {
206
+				if ($extremeStatement->getRank() !== Statement::RANK_DEPRECATED) {
207 207
 					$snak = $extremeStatement->getMainSnak();
208
-					if ( !$snak instanceof PropertyValueSnak ) {
208
+					if (!$snak instanceof PropertyValueSnak) {
209 209
 						return null;
210 210
 					} else {
211 211
 						$comparison = $this->rangeCheckerHelper->getComparison(
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 						);
215 215
 						if (
216 216
 							$extremeValue === null ||
217
-							( $startOrEnd === 'start' && $comparison < 0 ) ||
218
-							( $startOrEnd === 'end' && $comparison > 0 )
217
+							($startOrEnd === 'start' && $comparison < 0) ||
218
+							($startOrEnd === 'end' && $comparison > 0)
219 219
 						) {
220 220
 							$extremeValue = $snak->getDataValue();
221 221
 						}
@@ -245,17 +245,16 @@  discard block
 block discarded – undo
245 245
 		DataValue $maxStartValue
246 246
 	) {
247 247
 		$messageKey = $earlierEntityId === $subjectId ?
248
-			'wbqc-violation-message-contemporary-subject-earlier' :
249
-			'wbqc-violation-message-contemporary-value-earlier';
250
-		return ( new ViolationMessage( $messageKey ) )
251
-			->withEntityId( $subjectId, Role::SUBJECT )
252
-			->withEntityId( $propertyId, Role::PREDICATE )
253
-			->withEntityId( $objectId, Role::OBJECT )
254
-			->withDataValue( $minEndValue, Role::OBJECT )
255
-			->withDataValue( $maxStartValue, Role::OBJECT );
248
+			'wbqc-violation-message-contemporary-subject-earlier' : 'wbqc-violation-message-contemporary-value-earlier';
249
+		return (new ViolationMessage($messageKey))
250
+			->withEntityId($subjectId, Role::SUBJECT)
251
+			->withEntityId($propertyId, Role::PREDICATE)
252
+			->withEntityId($objectId, Role::OBJECT)
253
+			->withDataValue($minEndValue, Role::OBJECT)
254
+			->withDataValue($maxStartValue, Role::OBJECT);
256 255
 	}
257 256
 
258
-	public function checkConstraintParameters( Constraint $constraint ) {
257
+	public function checkConstraintParameters(Constraint $constraint) {
259 258
 		// no parameters
260 259
 		return [];
261 260
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/IntegerChecker.php 1 patch
Spacing   +21 added lines, -22 removed lines patch added patch discarded remove patch
@@ -46,23 +46,22 @@  discard block
 block discarded – undo
46 46
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
47 47
 	}
48 48
 
49
-	public function checkConstraint( Context $context, Constraint $constraint ) {
49
+	public function checkConstraint(Context $context, Constraint $constraint) {
50 50
 		$snak = $context->getSnak();
51 51
 
52
-		if ( !$snak instanceof PropertyValueSnak ) {
52
+		if (!$snak instanceof PropertyValueSnak) {
53 53
 			// nothing to check
54
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
54
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
55 55
 		}
56 56
 
57
-		$violationMessage = $this->checkSnak( $snak );
57
+		$violationMessage = $this->checkSnak($snak);
58 58
 
59 59
 		return new CheckResult(
60 60
 			$context,
61 61
 			$constraint,
62 62
 			[],
63 63
 			$violationMessage === null ?
64
-				CheckResult::STATUS_COMPLIANCE :
65
-				CheckResult::STATUS_VIOLATION,
64
+				CheckResult::STATUS_COMPLIANCE : CheckResult::STATUS_VIOLATION,
66 65
 			$violationMessage
67 66
 		);
68 67
 	}
@@ -71,23 +70,23 @@  discard block
 block discarded – undo
71 70
 	 * @param PropertyValueSnak $snak
72 71
 	 * @return ViolationMessage|null
73 72
 	 */
74
-	public function checkSnak( PropertyValueSnak $snak ) {
73
+	public function checkSnak(PropertyValueSnak $snak) {
75 74
 		$dataValue = $snak->getDataValue();
76 75
 
77
-		if ( $dataValue instanceof DecimalValue ) {
78
-			if ( !$this->isInteger( $dataValue ) ) {
79
-				return $this->getViolationMessage( 'wbqc-violation-message-integer', $snak );
76
+		if ($dataValue instanceof DecimalValue) {
77
+			if (!$this->isInteger($dataValue)) {
78
+				return $this->getViolationMessage('wbqc-violation-message-integer', $snak);
80 79
 			}
81
-		} elseif ( $dataValue instanceof UnboundedQuantityValue ) {
82
-			if ( !$this->isInteger( $dataValue->getAmount() ) ) {
83
-				return $this->getViolationMessage( 'wbqc-violation-message-integer', $snak );
80
+		} elseif ($dataValue instanceof UnboundedQuantityValue) {
81
+			if (!$this->isInteger($dataValue->getAmount())) {
82
+				return $this->getViolationMessage('wbqc-violation-message-integer', $snak);
84 83
 			} elseif (
85 84
 				$dataValue instanceof QuantityValue && (
86
-					!$this->isInteger( $dataValue->getLowerBound() ) ||
87
-					!$this->isInteger( $dataValue->getUpperBound() )
85
+					!$this->isInteger($dataValue->getLowerBound()) ||
86
+					!$this->isInteger($dataValue->getUpperBound())
88 87
 				)
89 88
 			) {
90
-				return $this->getViolationMessage( 'wbqc-violation-message-integer-bounds', $snak );
89
+				return $this->getViolationMessage('wbqc-violation-message-integer-bounds', $snak);
91 90
 			}
92 91
 		}
93 92
 
@@ -98,7 +97,7 @@  discard block
 block discarded – undo
98 97
 	 * @param DecimalValue $decimalValue
99 98
 	 * @return bool
100 99
 	 */
101
-	private function isInteger( DecimalValue $decimalValue ) {
100
+	private function isInteger(DecimalValue $decimalValue) {
102 101
 		return $decimalValue->getTrimmed()->getFractionalPart() === '';
103 102
 	}
104 103
 
@@ -107,13 +106,13 @@  discard block
 block discarded – undo
107 106
 	 * @param PropertyValueSnak $snak
108 107
 	 * @return ViolationMessage
109 108
 	 */
110
-	private function getViolationMessage( $messageKey, PropertyValueSnak $snak ) {
111
-		return ( new ViolationMessage( $messageKey ) )
112
-			->withEntityId( $snak->getPropertyId(), Role::CONSTRAINT_PROPERTY )
113
-			->withDataValue( $snak->getDataValue() );
109
+	private function getViolationMessage($messageKey, PropertyValueSnak $snak) {
110
+		return (new ViolationMessage($messageKey))
111
+			->withEntityId($snak->getPropertyId(), Role::CONSTRAINT_PROPERTY)
112
+			->withDataValue($snak->getDataValue());
114 113
 	}
115 114
 
116
-	public function checkConstraintParameters( Constraint $constraint ) {
115
+	public function checkConstraintParameters(Constraint $constraint) {
117 116
 		// no parameters
118 117
 		return [];
119 118
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ReferenceChecker.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,16 +41,16 @@
 block discarded – undo
41 41
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
42 42
 	}
43 43
 
44
-	public function checkConstraint( Context $context, Constraint $constraint ) {
45
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
46
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
44
+	public function checkConstraint(Context $context, Constraint $constraint) {
45
+		if ($context->getType() === Context::TYPE_REFERENCE) {
46
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
47 47
 		} else {
48
-			$message = new ViolationMessage( 'wbqc-violation-message-reference' );
49
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
48
+			$message = new ViolationMessage('wbqc-violation-message-reference');
49
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
50 50
 		}
51 51
 	}
52 52
 
53
-	public function checkConstraintParameters( Constraint $constraint ) {
53
+	public function checkConstraintParameters(Constraint $constraint) {
54 54
 		// no parameters
55 55
 		return [];
56 56
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/NoBoundsChecker.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
45 45
 	}
46 46
 
47
-	public function checkConstraint( Context $context, Constraint $constraint ) {
47
+	public function checkConstraint(Context $context, Constraint $constraint) {
48 48
 		$snak = $context->getSnak();
49 49
 
50
-		if ( !$snak instanceof PropertyValueSnak ) {
50
+		if (!$snak instanceof PropertyValueSnak) {
51 51
 			// nothing to check
52
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
52
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
53 53
 		}
54 54
 
55
-		if ( $snak->getDataValue() instanceof QuantityValue ) {
56
-			$message = ( new ViolationMessage( 'wbqc-violation-message-noBounds' ) )
57
-				->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY );
55
+		if ($snak->getDataValue() instanceof QuantityValue) {
56
+			$message = (new ViolationMessage('wbqc-violation-message-noBounds'))
57
+				->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY);
58 58
 			return new CheckResult(
59 59
 				$context,
60 60
 				$constraint,
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 			);
65 65
 		}
66 66
 
67
-		return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
67
+		return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
68 68
 	}
69 69
 
70
-	public function checkConstraintParameters( Constraint $constraint ) {
70
+	public function checkConstraintParameters(Constraint $constraint) {
71 71
 		// no parameters
72 72
 		return [];
73 73
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/CitationNeededChecker.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @codeCoverageIgnore This method is purely declarative.
31 31
 	 */
32 32
 	public function getDefaultContextTypes() {
33
-		return [ Context::TYPE_STATEMENT ];
33
+		return [Context::TYPE_STATEMENT];
34 34
 	}
35 35
 
36 36
 	/** @codeCoverageIgnore This method is purely declarative. */
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
39 39
 	}
40 40
 
41
-	public function checkConstraint( Context $context, Constraint $constraint ) {
41
+	public function checkConstraint(Context $context, Constraint $constraint) {
42 42
 		$referenceList = $context->getSnakStatement()->getReferences();
43 43
 
44
-		if ( $referenceList->isEmpty() ) {
45
-			$message = ( new ViolationMessage( 'wbqc-violation-message-citationNeeded' ) )
46
-				->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY );
44
+		if ($referenceList->isEmpty()) {
45
+			$message = (new ViolationMessage('wbqc-violation-message-citationNeeded'))
46
+				->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY);
47 47
 			return new CheckResult(
48 48
 				$context,
49 49
 				$constraint,
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 			);
54 54
 		}
55 55
 
56
-		return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
56
+		return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
57 57
 	}
58 58
 
59
-	public function checkConstraintParameters( Constraint $constraint ) {
59
+	public function checkConstraintParameters(Constraint $constraint) {
60 60
 		// no parameters
61 61
 		return [];
62 62
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ValueOnlyChecker.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -41,16 +41,16 @@
 block discarded – undo
41 41
 		return self::ALL_ENTITY_TYPES_SUPPORTED;
42 42
 	}
43 43
 
44
-	public function checkConstraint( Context $context, Constraint $constraint ) {
45
-		if ( $context->getType() === Context::TYPE_STATEMENT ) {
46
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
44
+	public function checkConstraint(Context $context, Constraint $constraint) {
45
+		if ($context->getType() === Context::TYPE_STATEMENT) {
46
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
47 47
 		} else {
48
-			$message = new ViolationMessage( 'wbqc-violation-message-valueOnly' );
49
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
48
+			$message = new ViolationMessage('wbqc-violation-message-valueOnly');
49
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
50 50
 		}
51 51
 	}
52 52
 
53
-	public function checkConstraintParameters( Constraint $constraint ) {
53
+	public function checkConstraintParameters(Constraint $constraint) {
54 54
 		// no parameters
55 55
 		return [];
56 56
 	}
Please login to merge, or discard this patch.