Completed
Push — master ( 53dce4...57a3b4 )
by
unknown
32s
created
src/Specials/SpecialConstraintReport.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		Config $config,
135 135
 		IBufferingStatsdDataFactory $dataFactory
136 136
 	) {
137
-		parent::__construct( 'ConstraintReport' );
137
+		parent::__construct('ConstraintReport');
138 138
 
139 139
 		$this->entityLookup = $entityLookup;
140 140
 		$this->entityTitleLookup = $entityTitleLookup;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		$language = $this->getLanguage();
144 144
 
145 145
 		$formatterOptions = new FormatterOptions();
146
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
146
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
147 147
 		$this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(
148 148
 			SnakFormatter::FORMAT_HTML,
149 149
 			$formatterOptions
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @return string
204 204
 	 */
205 205
 	public function getDescription() {
206
-		return $this->msg( 'wbqc-constraintreport' )->escaped();
206
+		return $this->msg('wbqc-constraintreport')->escaped();
207 207
 	}
208 208
 
209 209
 	/**
@@ -215,43 +215,43 @@  discard block
 block discarded – undo
215 215
 	 * @throws EntityIdParsingException
216 216
 	 * @throws UnexpectedValueException
217 217
 	 */
218
-	public function execute( $subPage ) {
218
+	public function execute($subPage) {
219 219
 		$out = $this->getOutput();
220 220
 
221
-		$postRequest = $this->getContext()->getRequest()->getVal( 'entityid' );
222
-		if ( $postRequest ) {
223
-			$out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() );
221
+		$postRequest = $this->getContext()->getRequest()->getVal('entityid');
222
+		if ($postRequest) {
223
+			$out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL());
224 224
 			return;
225 225
 		}
226 226
 
227 227
 		$out->enableOOUI();
228
-		$out->addModules( $this->getModules() );
228
+		$out->addModules($this->getModules());
229 229
 
230 230
 		$this->setHeaders();
231 231
 
232
-		$out->addHTML( $this->getExplanationText() );
232
+		$out->addHTML($this->getExplanationText());
233 233
 		$this->buildEntityIdForm();
234 234
 
235
-		if ( !$subPage ) {
235
+		if (!$subPage) {
236 236
 			return;
237 237
 		}
238 238
 
239
-		if ( !is_string( $subPage ) ) {
240
-			throw new InvalidArgumentException( '$subPage must be string.' );
239
+		if (!is_string($subPage)) {
240
+			throw new InvalidArgumentException('$subPage must be string.');
241 241
 		}
242 242
 
243 243
 		try {
244
-			$entityId = $this->entityIdParser->parse( $subPage );
245
-		} catch ( EntityIdParsingException $e ) {
244
+			$entityId = $this->entityIdParser->parse($subPage);
245
+		} catch (EntityIdParsingException $e) {
246 246
 			$out->addHTML(
247
-				$this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true )
247
+				$this->buildNotice('wbqc-constraintreport-invalid-entity-id', true)
248 248
 			);
249 249
 			return;
250 250
 		}
251 251
 
252
-		if ( !$this->entityLookup->hasEntity( $entityId ) ) {
252
+		if (!$this->entityLookup->hasEntity($entityId)) {
253 253
 			$out->addHTML(
254
-				$this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true )
254
+				$this->buildNotice('wbqc-constraintreport-not-existent-entity', true)
255 255
 			);
256 256
 			return;
257 257
 		}
@@ -259,18 +259,18 @@  discard block
 block discarded – undo
259 259
 		$this->dataFactory->increment(
260 260
 			'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck'
261 261
 		);
262
-		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId );
262
+		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId);
263 263
 
264
-		if ( $results !== [] ) {
264
+		if ($results !== []) {
265 265
 			$out->addHTML(
266
-				$this->buildResultHeader( $entityId )
267
-				. $this->buildSummary( $results )
268
-				. $this->buildResultTable( $entityId, $results )
266
+				$this->buildResultHeader($entityId)
267
+				. $this->buildSummary($results)
268
+				. $this->buildResultTable($entityId, $results)
269 269
 			);
270 270
 		} else {
271 271
 			$out->addHTML(
272
-				$this->buildResultHeader( $entityId )
273
-				. $this->buildNotice( 'wbqc-constraintreport-empty-result' )
272
+				$this->buildResultHeader($entityId)
273
+				. $this->buildNotice('wbqc-constraintreport-empty-result')
274 274
 			);
275 275
 		}
276 276
 	}
@@ -286,15 +286,15 @@  discard block
 block discarded – undo
286 286
 				'name' => 'entityid',
287 287
 				'label-message' => 'wbqc-constraintreport-form-entityid-label',
288 288
 				'cssclass' => 'wbqc-constraintreport-form-entity-id',
289
-				'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped()
289
+				'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped()
290 290
 			]
291 291
 		];
292
-		$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' );
293
-		$htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() );
294
-		$htmlForm->setSubmitCallback( static function () {
292
+		$htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form');
293
+		$htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped());
294
+		$htmlForm->setSubmitCallback(static function() {
295 295
 			return false;
296 296
 		} );
297
-		$htmlForm->setMethod( 'post' );
297
+		$htmlForm->setMethod('post');
298 298
 		$htmlForm->show();
299 299
 	}
300 300
 
@@ -308,16 +308,16 @@  discard block
 block discarded – undo
308 308
 	 *
309 309
 	 * @return string HTML
310 310
 	 */
311
-	private function buildNotice( $messageKey, $error = false ) {
312
-		if ( !is_string( $messageKey ) ) {
313
-			throw new InvalidArgumentException( '$message must be string.' );
311
+	private function buildNotice($messageKey, $error = false) {
312
+		if (!is_string($messageKey)) {
313
+			throw new InvalidArgumentException('$message must be string.');
314 314
 		}
315
-		if ( !is_bool( $error ) ) {
316
-			throw new InvalidArgumentException( '$error must be bool.' );
315
+		if (!is_bool($error)) {
316
+			throw new InvalidArgumentException('$error must be bool.');
317 317
 		}
318 318
 
319 319
 		$cssClasses = 'wbqc-constraintreport-notice';
320
-		if ( $error ) {
320
+		if ($error) {
321 321
 			$cssClasses .= ' wbqc-constraintreport-notice-error';
322 322
 		}
323 323
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 				[
327 327
 					'class' => $cssClasses
328 328
 				],
329
-				$this->msg( $messageKey )->escaped()
329
+				$this->msg($messageKey)->escaped()
330 330
 			);
331 331
 	}
332 332
 
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
 	private function getExplanationText() {
337 337
 		return Html::rawElement(
338 338
 			'div',
339
-			[ 'class' => 'wbqc-explanation' ],
339
+			['class' => 'wbqc-explanation'],
340 340
 			Html::rawElement(
341 341
 				'p',
342 342
 				[],
343
-				$this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped()
343
+				$this->msg('wbqc-constraintreport-explanation-part-one')->escaped()
344 344
 			)
345 345
 			. Html::rawElement(
346 346
 				'p',
347 347
 				[],
348
-				$this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped()
348
+				$this->msg('wbqc-constraintreport-explanation-part-two')->escaped()
349 349
 			)
350 350
 		);
351 351
 	}
@@ -357,72 +357,72 @@  discard block
 block discarded – undo
357 357
 	 * @return string HTML
358 358
 	 * @suppress SecurityCheck-DoubleEscaped
359 359
 	 */
360
-	private function buildResultTable( EntityId $entityId, array $results ) {
360
+	private function buildResultTable(EntityId $entityId, array $results) {
361 361
 		// Set table headers
362 362
 		$table = new HtmlTableBuilder(
363 363
 			[
364 364
 				new HtmlTableHeaderBuilder(
365
-					$this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(),
365
+					$this->msg('wbqc-constraintreport-result-table-header-status')->escaped(),
366 366
 					true
367 367
 				),
368 368
 				new HtmlTableHeaderBuilder(
369
-					$this->msg( 'wbqc-constraintreport-result-table-header-property' )->escaped(),
369
+					$this->msg('wbqc-constraintreport-result-table-header-property')->escaped(),
370 370
 					true
371 371
 				),
372 372
 				new HtmlTableHeaderBuilder(
373
-					$this->msg( 'wbqc-constraintreport-result-table-header-message' )->escaped(),
373
+					$this->msg('wbqc-constraintreport-result-table-header-message')->escaped(),
374 374
 					true
375 375
 				),
376 376
 				new HtmlTableHeaderBuilder(
377
-					$this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(),
377
+					$this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(),
378 378
 					true
379 379
 				)
380 380
 			]
381 381
 		);
382 382
 
383
-		foreach ( $results as $result ) {
384
-			$table = $this->appendToResultTable( $table, $entityId, $result );
383
+		foreach ($results as $result) {
384
+			$table = $this->appendToResultTable($table, $entityId, $result);
385 385
 		}
386 386
 
387 387
 		return $table->toHtml();
388 388
 	}
389 389
 
390
-	private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) {
390
+	private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) {
391 391
 		$message = $result->getMessage();
392
-		if ( $message === null ) {
392
+		if ($message === null) {
393 393
 			// no row for this result
394 394
 			return $table;
395 395
 		}
396 396
 
397 397
 		// Status column
398
-		$statusColumn = $this->formatStatus( $result->getStatus() );
398
+		$statusColumn = $this->formatStatus($result->getStatus());
399 399
 
400 400
 		// Property column
401
-		$propertyId = new NumericPropertyId( $result->getContextCursor()->getSnakPropertyId() );
401
+		$propertyId = new NumericPropertyId($result->getContextCursor()->getSnakPropertyId());
402 402
 		$propertyColumn = $this->getClaimLink(
403 403
 			$entityId,
404 404
 			$propertyId,
405
-			$this->entityIdLabelFormatter->formatEntityId( $propertyId )
405
+			$this->entityIdLabelFormatter->formatEntityId($propertyId)
406 406
 		);
407 407
 
408 408
 		// Message column
409
-		$messageColumn = $this->violationMessageRenderer->render( $message );
409
+		$messageColumn = $this->violationMessageRenderer->render($message);
410 410
 
411 411
 		// Constraint column
412 412
 		$constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId();
413 413
 		try {
414
-			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) );
415
-		} catch ( InvalidArgumentException $e ) {
416
-			$constraintTypeLabel = htmlspecialchars( $constraintTypeItemId );
414
+			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId));
415
+		} catch (InvalidArgumentException $e) {
416
+			$constraintTypeLabel = htmlspecialchars($constraintTypeItemId);
417 417
 		}
418 418
 		$constraintLink = $this->getClaimLink(
419 419
 			$propertyId,
420
-			new NumericPropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ),
420
+			new NumericPropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')),
421 421
 			$constraintTypeLabel
422 422
 		);
423 423
 		$constraintColumn = $this->buildExpandableElement(
424 424
 			$constraintLink,
425
-			$this->constraintParameterRenderer->formatParameters( $result->getParameters() ),
425
+			$this->constraintParameterRenderer->formatParameters($result->getParameters()),
426 426
 			'[...]'
427 427
 		);
428 428
 
@@ -462,15 +462,15 @@  discard block
 block discarded – undo
462 462
 	 *
463 463
 	 * @return string HTML
464 464
 	 */
465
-	protected function buildResultHeader( EntityId $entityId ) {
466
-		$entityLink = sprintf( '%s (%s)',
467
-							   $this->entityIdLinkFormatter->formatEntityId( $entityId ),
468
-							   htmlspecialchars( $entityId->getSerialization() ) );
465
+	protected function buildResultHeader(EntityId $entityId) {
466
+		$entityLink = sprintf('%s (%s)',
467
+							   $this->entityIdLinkFormatter->formatEntityId($entityId),
468
+							   htmlspecialchars($entityId->getSerialization()));
469 469
 
470 470
 		return Html::rawElement(
471 471
 			'h3',
472 472
 			[],
473
-			sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
473
+			sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink)
474 474
 		);
475 475
 	}
476 476
 
@@ -481,24 +481,24 @@  discard block
 block discarded – undo
481 481
 	 *
482 482
 	 * @return string HTML
483 483
 	 */
484
-	protected function buildSummary( array $results ) {
484
+	protected function buildSummary(array $results) {
485 485
 		$statuses = [];
486
-		foreach ( $results as $result ) {
487
-			$status = strtolower( $result->getStatus() );
488
-			$statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1;
486
+		foreach ($results as $result) {
487
+			$status = strtolower($result->getStatus());
488
+			$statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1;
489 489
 		}
490 490
 
491 491
 		$statusElements = [];
492
-		foreach ( $statuses as $status => $count ) {
493
-			if ( $count > 0 ) {
492
+		foreach ($statuses as $status => $count) {
493
+			if ($count > 0) {
494 494
 				$statusElements[] =
495
-					$this->formatStatus( $status )
495
+					$this->formatStatus($status)
496 496
 					. ': '
497 497
 					. $count;
498 498
 			}
499 499
 		}
500 500
 
501
-		return Html::rawElement( 'p', [], implode( ', ', $statusElements ) );
501
+		return Html::rawElement('p', [], implode(', ', $statusElements));
502 502
 	}
503 503
 
504 504
 	/**
@@ -513,15 +513,15 @@  discard block
 block discarded – undo
513 513
 	 *
514 514
 	 * @return string HTML
515 515
 	 */
516
-	protected function buildExpandableElement( $content, $expandableContent, $indicator ) {
517
-		if ( !is_string( $content ) ) {
518
-			throw new InvalidArgumentException( '$content has to be string.' );
516
+	protected function buildExpandableElement($content, $expandableContent, $indicator) {
517
+		if (!is_string($content)) {
518
+			throw new InvalidArgumentException('$content has to be string.');
519 519
 		}
520
-		if ( $expandableContent && ( !is_string( $expandableContent ) ) ) {
521
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
520
+		if ($expandableContent && (!is_string($expandableContent))) {
521
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
522 522
 		}
523 523
 
524
-		if ( empty( $expandableContent ) ) {
524
+		if (empty($expandableContent)) {
525 525
 			return $content;
526 526
 		}
527 527
 
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 			$expandableContent
542 542
 		);
543 543
 
544
-		return sprintf( '%s %s %s', $content, $tooltipIndicator, $wrappedExpandableContent );
544
+		return sprintf('%s %s %s', $content, $tooltipIndicator, $wrappedExpandableContent);
545 545
 	}
546 546
 
547 547
 	/**
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
 	 *
554 554
 	 * @return string HTML
555 555
 	 */
556
-	private function formatStatus( $status ) {
557
-		$messageName = "wbqc-constraintreport-status-" . strtolower( $status );
556
+	private function formatStatus($status) {
557
+		$messageName = "wbqc-constraintreport-status-".strtolower($status);
558 558
 		$statusIcons = [
559 559
 			CheckResult::STATUS_SUGGESTION => [
560 560
 				'icon' => 'suggestion-constraint-violation',
@@ -571,25 +571,25 @@  discard block
 block discarded – undo
571 571
 			],
572 572
 		];
573 573
 
574
-		if ( array_key_exists( $status, $statusIcons ) ) {
575
-			$iconWidget = new IconWidget( $statusIcons[$status] );
576
-			$iconHtml = $iconWidget->toString() . ' ';
574
+		if (array_key_exists($status, $statusIcons)) {
575
+			$iconWidget = new IconWidget($statusIcons[$status]);
576
+			$iconHtml = $iconWidget->toString().' ';
577 577
 		} else {
578 578
 			$iconHtml = '';
579 579
 		}
580 580
 
581
-		$labelWidget = new LabelWidget( [
582
-			'label' => $this->msg( $messageName )->text(),
583
-		] );
581
+		$labelWidget = new LabelWidget([
582
+			'label' => $this->msg($messageName)->text(),
583
+		]);
584 584
 		$labelHtml = $labelWidget->toString();
585 585
 
586 586
 		$formattedStatus =
587 587
 			Html::rawElement(
588 588
 				'span',
589 589
 				[
590
-					'class' => 'wbqc-status wbqc-status-' . $status
590
+					'class' => 'wbqc-status wbqc-status-'.$status
591 591
 				],
592
-				$iconHtml . $labelHtml
592
+				$iconHtml.$labelHtml
593 593
 			);
594 594
 
595 595
 		return $formattedStatus;
@@ -605,26 +605,26 @@  discard block
 block discarded – undo
605 605
 	 *
606 606
 	 * @return string HTML
607 607
 	 */
608
-	protected function formatDataValues( $dataValues, $separator = ', ' ) {
609
-		if ( $dataValues instanceof DataValue ) {
610
-			$dataValues = [ $dataValues ];
611
-		} elseif ( !is_array( $dataValues ) ) {
612
-			throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
608
+	protected function formatDataValues($dataValues, $separator = ', ') {
609
+		if ($dataValues instanceof DataValue) {
610
+			$dataValues = [$dataValues];
611
+		} elseif (!is_array($dataValues)) {
612
+			throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
613 613
 		}
614 614
 
615 615
 		$formattedDataValues = [];
616
-		foreach ( $dataValues as $dataValue ) {
617
-			if ( !( $dataValue instanceof DataValue ) ) {
618
-				throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
616
+		foreach ($dataValues as $dataValue) {
617
+			if (!($dataValue instanceof DataValue)) {
618
+				throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
619 619
 			}
620
-			if ( $dataValue instanceof EntityIdValue ) {
621
-				$formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() );
620
+			if ($dataValue instanceof EntityIdValue) {
621
+				$formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId());
622 622
 			} else {
623
-				$formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue );
623
+				$formattedDataValues[] = $this->dataValueFormatter->format($dataValue);
624 624
 			}
625 625
 		}
626 626
 
627
-		return implode( $separator, $formattedDataValues );
627
+		return implode($separator, $formattedDataValues);
628 628
 	}
629 629
 
630 630
 	/**
@@ -636,11 +636,11 @@  discard block
 block discarded – undo
636 636
 	 *
637 637
 	 * @return string HTML
638 638
 	 */
639
-	private function getClaimLink( EntityId $entityId, NumericPropertyId $propertyId, $text ) {
639
+	private function getClaimLink(EntityId $entityId, NumericPropertyId $propertyId, $text) {
640 640
 		return Html::rawElement(
641 641
 			'a',
642 642
 			[
643
-				'href' => $this->getClaimUrl( $entityId, $propertyId ),
643
+				'href' => $this->getClaimUrl($entityId, $propertyId),
644 644
 				'target' => '_blank'
645 645
 			],
646 646
 			$text
@@ -655,9 +655,9 @@  discard block
 block discarded – undo
655 655
 	 *
656 656
 	 * @return string
657 657
 	 */
658
-	private function getClaimUrl( EntityId $entityId, NumericPropertyId $propertyId ) {
659
-		$title = $this->entityTitleLookup->getTitleForId( $entityId );
660
-		$entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() );
658
+	private function getClaimUrl(EntityId $entityId, NumericPropertyId $propertyId) {
659
+		$title = $this->entityTitleLookup->getTitleForId($entityId);
660
+		$entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization());
661 661
 
662 662
 		return $entityUrl;
663 663
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/DelegatingConstraintChecker.php 1 patch
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 		callable $defaultResultsPerEntity = null
145 145
 	) {
146 146
 		$checkResults = [];
147
-		$entity = $this->entityLookup->getEntity( $entityId );
147
+		$entity = $this->entityLookup->getEntity($entityId);
148 148
 
149
-		if ( $entity instanceof StatementListProvidingEntity ) {
150
-			$startTime = microtime( true );
149
+		if ($entity instanceof StatementListProvidingEntity) {
150
+			$startTime = microtime(true);
151 151
 
152 152
 			$checkResults = $this->checkEveryStatement(
153 153
 				$entity,
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 				$defaultResultsPerContext
156 156
 			);
157 157
 
158
-			$endTime = microtime( true );
158
+			$endTime = microtime(true);
159 159
 
160
-			if ( $constraintIds === null ) { // only log full constraint checks
160
+			if ($constraintIds === null) { // only log full constraint checks
161 161
 				$this->loggingHelper->logConstraintCheckOnEntity(
162 162
 					$entityId,
163 163
 					$checkResults,
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 			}
168 168
 		}
169 169
 
170
-		if ( $defaultResultsPerEntity !== null ) {
171
-			$checkResults = array_merge( $defaultResultsPerEntity( $entityId ), $checkResults );
170
+		if ($defaultResultsPerEntity !== null) {
171
+			$checkResults = array_merge($defaultResultsPerEntity($entityId), $checkResults);
172 172
 		}
173 173
 
174
-		return $this->sortResult( $checkResults );
174
+		return $this->sortResult($checkResults);
175 175
 	}
176 176
 
177 177
 	/**
@@ -193,19 +193,19 @@  discard block
 block discarded – undo
193 193
 		callable $defaultResults = null
194 194
 	) {
195 195
 
196
-		$parsedGuid = $this->statementGuidParser->parse( $guid );
196
+		$parsedGuid = $this->statementGuidParser->parse($guid);
197 197
 		$entityId = $parsedGuid->getEntityId();
198
-		$entity = $this->entityLookup->getEntity( $entityId );
199
-		if ( $entity instanceof StatementListProvidingEntity ) {
200
-			$statement = $entity->getStatements()->getFirstStatementWithGuid( $guid );
201
-			if ( $statement ) {
198
+		$entity = $this->entityLookup->getEntity($entityId);
199
+		if ($entity instanceof StatementListProvidingEntity) {
200
+			$statement = $entity->getStatements()->getFirstStatementWithGuid($guid);
201
+			if ($statement) {
202 202
 				$result = $this->checkStatement(
203 203
 					$entity,
204 204
 					$statement,
205 205
 					$constraintIds,
206 206
 					$defaultResults
207 207
 				);
208
-				$output = $this->sortResult( $result );
208
+				$output = $this->sortResult($result);
209 209
 				return $output;
210 210
 			}
211 211
 		}
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 		return [];
214 214
 	}
215 215
 
216
-	private function getValidContextTypes( Constraint $constraint ) {
217
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
216
+	private function getValidContextTypes(Constraint $constraint) {
217
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
218 218
 			return [
219 219
 				Context::TYPE_STATEMENT,
220 220
 				Context::TYPE_QUALIFIER,
@@ -222,25 +222,25 @@  discard block
 block discarded – undo
222 222
 			];
223 223
 		}
224 224
 
225
-		return array_keys( array_filter(
225
+		return array_keys(array_filter(
226 226
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedContextTypes(),
227
-			static function ( $resultStatus ) {
227
+			static function($resultStatus) {
228 228
 				return $resultStatus !== CheckResult::STATUS_NOT_IN_SCOPE;
229 229
 			}
230
-		) );
230
+		));
231 231
 	}
232 232
 
233
-	private function getValidEntityTypes( Constraint $constraint ) {
234
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
235
-			return array_keys( ConstraintChecker::ALL_ENTITY_TYPES_SUPPORTED );
233
+	private function getValidEntityTypes(Constraint $constraint) {
234
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
235
+			return array_keys(ConstraintChecker::ALL_ENTITY_TYPES_SUPPORTED);
236 236
 		}
237 237
 
238
-		return array_keys( array_filter(
238
+		return array_keys(array_filter(
239 239
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedEntityTypes(),
240
-			static function ( $resultStatus ) {
240
+			static function($resultStatus) {
241 241
 				return $resultStatus !== CheckResult::STATUS_NOT_IN_SCOPE;
242 242
 			}
243
-		) );
243
+		));
244 244
 	}
245 245
 
246 246
 	/**
@@ -251,33 +251,33 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @return ConstraintParameterException[]
253 253
 	 */
254
-	private function checkCommonConstraintParameters( Constraint $constraint ) {
254
+	private function checkCommonConstraintParameters(Constraint $constraint) {
255 255
 		$constraintParameters = $constraint->getConstraintParameters();
256 256
 		try {
257
-			$this->constraintParameterParser->checkError( $constraintParameters );
258
-		} catch ( ConstraintParameterException $e ) {
259
-			return [ $e ];
257
+			$this->constraintParameterParser->checkError($constraintParameters);
258
+		} catch (ConstraintParameterException $e) {
259
+			return [$e];
260 260
 		}
261 261
 
262 262
 		$problems = [];
263 263
 		try {
264
-			$this->constraintParameterParser->parseExceptionParameter( $constraintParameters );
265
-		} catch ( ConstraintParameterException $e ) {
264
+			$this->constraintParameterParser->parseExceptionParameter($constraintParameters);
265
+		} catch (ConstraintParameterException $e) {
266 266
 			$problems[] = $e;
267 267
 		}
268 268
 		try {
269
-			$this->constraintParameterParser->parseConstraintStatusParameter( $constraintParameters );
270
-		} catch ( ConstraintParameterException $e ) {
269
+			$this->constraintParameterParser->parseConstraintStatusParameter($constraintParameters);
270
+		} catch (ConstraintParameterException $e) {
271 271
 			$problems[] = $e;
272 272
 		}
273 273
 		try {
274 274
 			$this->constraintParameterParser->parseConstraintScopeParameters(
275 275
 				$constraintParameters,
276 276
 				$constraint->getConstraintTypeItemId(),
277
-				$this->getValidContextTypes( $constraint ),
278
-				$this->getValidEntityTypes( $constraint )
277
+				$this->getValidContextTypes($constraint),
278
+				$this->getValidEntityTypes($constraint)
279 279
 			);
280
-		} catch ( ConstraintParameterException $e ) {
280
+		} catch (ConstraintParameterException $e) {
281 281
 			$problems[] = $e;
282 282
 		}
283 283
 		return $problems;
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
 	 * @return ConstraintParameterException[][] first level indexed by constraint ID,
291 291
 	 * second level like checkConstraintParametersOnConstraintId (but without possibility of null)
292 292
 	 */
293
-	public function checkConstraintParametersOnPropertyId( PropertyId $propertyId ) {
294
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
293
+	public function checkConstraintParametersOnPropertyId(PropertyId $propertyId) {
294
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
295 295
 		$result = [];
296 296
 
297
-		foreach ( $constraints as $constraint ) {
298
-			$problems = $this->checkCommonConstraintParameters( $constraint );
297
+		foreach ($constraints as $constraint) {
298
+			$problems = $this->checkCommonConstraintParameters($constraint);
299 299
 
300
-			if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
300
+			if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
301 301
 				$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
302
-				$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
302
+				$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
303 303
 			}
304 304
 
305 305
 			$result[$constraint->getConstraintId()] = $problems;
@@ -316,18 +316,18 @@  discard block
 block discarded – undo
316 316
 	 * @return ConstraintParameterException[]|null list of constraint parameter exceptions
317 317
 	 * (empty means all parameters okay), or null if constraint is not found
318 318
 	 */
319
-	public function checkConstraintParametersOnConstraintId( $constraintId ) {
320
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
319
+	public function checkConstraintParametersOnConstraintId($constraintId) {
320
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
321 321
 		'@phan-var NumericPropertyId $propertyId';
322
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
322
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
323 323
 
324
-		foreach ( $constraints as $constraint ) {
325
-			if ( $constraint->getConstraintId() === $constraintId ) {
326
-				$problems = $this->checkCommonConstraintParameters( $constraint );
324
+		foreach ($constraints as $constraint) {
325
+			if ($constraint->getConstraintId() === $constraintId) {
326
+				$problems = $this->checkCommonConstraintParameters($constraint);
327 327
 
328
-				if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
328
+				if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
329 329
 					$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
330
-					$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
330
+					$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
331 331
 				}
332 332
 
333 333
 				return $problems;
@@ -352,14 +352,14 @@  discard block
 block discarded – undo
352 352
 		$result = [];
353 353
 
354 354
 		/** @var Statement $statement */
355
-		foreach ( $entity->getStatements() as $statement ) {
356
-			$result = array_merge( $result,
355
+		foreach ($entity->getStatements() as $statement) {
356
+			$result = array_merge($result,
357 357
 				$this->checkStatement(
358 358
 					$entity,
359 359
 					$statement,
360 360
 					$constraintIds,
361 361
 					$defaultResultsPerContext
362
-				) );
362
+				));
363 363
 		}
364 364
 
365 365
 		return $result;
@@ -381,32 +381,32 @@  discard block
 block discarded – undo
381 381
 	) {
382 382
 		$result = [];
383 383
 
384
-		$result = array_merge( $result,
384
+		$result = array_merge($result,
385 385
 			$this->checkConstraintsForMainSnak(
386 386
 				$entity,
387 387
 				$statement,
388 388
 				$constraintIds,
389 389
 				$defaultResultsPerContext
390
-			) );
390
+			));
391 391
 
392
-		if ( $this->checkQualifiers ) {
393
-			$result = array_merge( $result,
392
+		if ($this->checkQualifiers) {
393
+			$result = array_merge($result,
394 394
 				$this->checkConstraintsForQualifiers(
395 395
 					$entity,
396 396
 					$statement,
397 397
 					$constraintIds,
398 398
 					$defaultResultsPerContext
399
-				) );
399
+				));
400 400
 		}
401 401
 
402
-		if ( $this->checkReferences ) {
403
-			$result = array_merge( $result,
402
+		if ($this->checkReferences) {
403
+			$result = array_merge($result,
404 404
 				$this->checkConstraintsForReferences(
405 405
 					$entity,
406 406
 					$statement,
407 407
 					$constraintIds,
408 408
 					$defaultResultsPerContext
409
-				) );
409
+				));
410 410
 		}
411 411
 
412 412
 		return $result;
@@ -421,12 +421,12 @@  discard block
 block discarded – undo
421 421
 	 * @param string[]|null $constraintIds
422 422
 	 * @return Constraint[]
423 423
 	 */
424
-	private function getConstraintsToUse( PropertyId $propertyId, array $constraintIds = null ) {
425
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
426
-		if ( $constraintIds !== null ) {
424
+	private function getConstraintsToUse(PropertyId $propertyId, array $constraintIds = null) {
425
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
426
+		if ($constraintIds !== null) {
427 427
 			$constraintsToUse = [];
428
-			foreach ( $constraints as $constraint ) {
429
-				if ( in_array( $constraint->getConstraintId(), $constraintIds ) ) {
428
+			foreach ($constraints as $constraint) {
429
+				if (in_array($constraint->getConstraintId(), $constraintIds)) {
430 430
 					$constraintsToUse[] = $constraint;
431 431
 				}
432 432
 			}
@@ -450,18 +450,18 @@  discard block
 block discarded – undo
450 450
 		array $constraintIds = null,
451 451
 		callable $defaultResults = null
452 452
 	) {
453
-		$context = new MainSnakContext( $entity, $statement );
453
+		$context = new MainSnakContext($entity, $statement);
454 454
 		$constraints = $this->getConstraintsToUse(
455 455
 			$statement->getPropertyId(),
456 456
 			$constraintIds
457 457
 		);
458
-		$result = $defaultResults !== null ? $defaultResults( $context ) : [];
458
+		$result = $defaultResults !== null ? $defaultResults($context) : [];
459 459
 
460
-		foreach ( $constraints as $constraint ) {
460
+		foreach ($constraints as $constraint) {
461 461
 			$parameters = $constraint->getConstraintParameters();
462 462
 			try {
463
-				$exceptions = $this->constraintParameterParser->parseExceptionParameter( $parameters );
464
-			} catch ( ConstraintParameterException $e ) {
463
+				$exceptions = $this->constraintParameterParser->parseExceptionParameter($parameters);
464
+			} catch (ConstraintParameterException $e) {
465 465
 				$result[] = new CheckResult(
466 466
 					$context,
467 467
 					$constraint,
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
 				continue;
472 472
 			}
473 473
 
474
-			if ( in_array( $entity->getId(), $exceptions ) ) {
475
-				$message = new ViolationMessage( 'wbqc-violation-message-exception' );
476
-				$result[] = new CheckResult( $context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message );
474
+			if (in_array($entity->getId(), $exceptions)) {
475
+				$message = new ViolationMessage('wbqc-violation-message-exception');
476
+				$result[] = new CheckResult($context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message);
477 477
 				continue;
478 478
 			}
479 479
 
480
-			$result[] = $this->getCheckResultFor( $context, $constraint );
480
+			$result[] = $this->getCheckResultFor($context, $constraint);
481 481
 		}
482 482
 
483 483
 		return $result;
@@ -499,24 +499,24 @@  discard block
 block discarded – undo
499 499
 	) {
500 500
 		$result = [];
501 501
 
502
-		if ( in_array(
502
+		if (in_array(
503 503
 			$statement->getPropertyId()->getSerialization(),
504 504
 			$this->propertiesWithViolatingQualifiers
505
-		) ) {
505
+		)) {
506 506
 			return $result;
507 507
 		}
508 508
 
509
-		foreach ( $statement->getQualifiers() as $qualifier ) {
510
-			$qualifierContext = new QualifierContext( $entity, $statement, $qualifier );
511
-			if ( $defaultResultsPerContext !== null ) {
512
-				$result = array_merge( $result, $defaultResultsPerContext( $qualifierContext ) );
509
+		foreach ($statement->getQualifiers() as $qualifier) {
510
+			$qualifierContext = new QualifierContext($entity, $statement, $qualifier);
511
+			if ($defaultResultsPerContext !== null) {
512
+				$result = array_merge($result, $defaultResultsPerContext($qualifierContext));
513 513
 			}
514 514
 			$qualifierConstraints = $this->getConstraintsToUse(
515 515
 				$qualifierContext->getSnak()->getPropertyId(),
516 516
 				$constraintIds
517 517
 			);
518
-			foreach ( $qualifierConstraints as $qualifierConstraint ) {
519
-				$result[] = $this->getCheckResultFor( $qualifierContext, $qualifierConstraint );
518
+			foreach ($qualifierConstraints as $qualifierConstraint) {
519
+				$result[] = $this->getCheckResultFor($qualifierContext, $qualifierConstraint);
520 520
 			}
521 521
 		}
522 522
 
@@ -540,19 +540,19 @@  discard block
 block discarded – undo
540 540
 		$result = [];
541 541
 
542 542
 		/** @var Reference $reference */
543
-		foreach ( $statement->getReferences() as $reference ) {
544
-			foreach ( $reference->getSnaks() as $snak ) {
543
+		foreach ($statement->getReferences() as $reference) {
544
+			foreach ($reference->getSnaks() as $snak) {
545 545
 				$referenceContext = new ReferenceContext(
546 546
 					$entity, $statement, $reference, $snak
547 547
 				);
548
-				if ( $defaultResultsPerContext !== null ) {
549
-					$result = array_merge( $result, $defaultResultsPerContext( $referenceContext ) );
548
+				if ($defaultResultsPerContext !== null) {
549
+					$result = array_merge($result, $defaultResultsPerContext($referenceContext));
550 550
 				}
551 551
 				$referenceConstraints = $this->getConstraintsToUse(
552 552
 					$referenceContext->getSnak()->getPropertyId(),
553 553
 					$constraintIds
554 554
 				);
555
-				foreach ( $referenceConstraints as $referenceConstraint ) {
555
+				foreach ($referenceConstraints as $referenceConstraint) {
556 556
 					$result[] = $this->getCheckResultFor(
557 557
 						$referenceContext,
558 558
 						$referenceConstraint
@@ -571,20 +571,20 @@  discard block
 block discarded – undo
571 571
 	 * @throws InvalidArgumentException
572 572
 	 * @return CheckResult
573 573
 	 */
574
-	private function getCheckResultFor( Context $context, Constraint $constraint ) {
575
-		if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
574
+	private function getCheckResultFor(Context $context, Constraint $constraint) {
575
+		if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
576 576
 			$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
577
-			$result = $this->handleScope( $checker, $context, $constraint );
577
+			$result = $this->handleScope($checker, $context, $constraint);
578 578
 
579
-			if ( $result !== null ) {
580
-				$this->addMetadata( $context, $result );
579
+			if ($result !== null) {
580
+				$this->addMetadata($context, $result);
581 581
 				return $result;
582 582
 			}
583 583
 
584
-			$startTime = microtime( true );
584
+			$startTime = microtime(true);
585 585
 			try {
586
-				$result = $checker->checkConstraint( $context, $constraint );
587
-			} catch ( ConstraintParameterException $e ) {
586
+				$result = $checker->checkConstraint($context, $constraint);
587
+			} catch (ConstraintParameterException $e) {
588 588
 				$result = new CheckResult(
589 589
 					$context,
590 590
 					$constraint,
@@ -592,28 +592,28 @@  discard block
 block discarded – undo
592 592
 					CheckResult::STATUS_BAD_PARAMETERS,
593 593
 					$e->getViolationMessage()
594 594
 				);
595
-			} catch ( SparqlHelperException $e ) {
596
-				$message = new ViolationMessage( 'wbqc-violation-message-sparql-error' );
597
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, $message );
595
+			} catch (SparqlHelperException $e) {
596
+				$message = new ViolationMessage('wbqc-violation-message-sparql-error');
597
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, $message);
598 598
 			}
599
-			$endTime = microtime( true );
599
+			$endTime = microtime(true);
600 600
 
601
-			$this->addMetadata( $context, $result );
601
+			$this->addMetadata($context, $result);
602 602
 
603
-			$this->downgradeResultStatus( $context, $result );
603
+			$this->downgradeResultStatus($context, $result);
604 604
 
605 605
 			$this->loggingHelper->logConstraintCheck(
606 606
 				$context,
607 607
 				$constraint,
608 608
 				$result,
609
-				get_class( $checker ),
609
+				get_class($checker),
610 610
 				$endTime - $startTime,
611 611
 				__METHOD__
612 612
 			);
613 613
 
614 614
 			return $result;
615 615
 		} else {
616
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
616
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
617 617
 		}
618 618
 	}
619 619
 
@@ -622,84 +622,84 @@  discard block
 block discarded – undo
622 622
 		Context $context,
623 623
 		Constraint $constraint
624 624
 	): ?CheckResult {
625
-		$validContextTypes = $this->getValidContextTypes( $constraint );
626
-		$validEntityTypes = $this->getValidEntityTypes( $constraint );
625
+		$validContextTypes = $this->getValidContextTypes($constraint);
626
+		$validEntityTypes = $this->getValidEntityTypes($constraint);
627 627
 		try {
628
-			[ $checkedContextTypes, $checkedEntityTypes ] = $this->constraintParameterParser->parseConstraintScopeParameters(
628
+			[$checkedContextTypes, $checkedEntityTypes] = $this->constraintParameterParser->parseConstraintScopeParameters(
629 629
 				$constraint->getConstraintParameters(),
630 630
 				$constraint->getConstraintTypeItemId(),
631 631
 				$validContextTypes,
632 632
 				$validEntityTypes
633 633
 			);
634
-		} catch ( ConstraintParameterException $e ) {
635
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
634
+		} catch (ConstraintParameterException $e) {
635
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
636 636
 		}
637 637
 
638
-		if ( $checkedContextTypes === null ) {
638
+		if ($checkedContextTypes === null) {
639 639
 			$checkedContextTypes = $checker->getDefaultContextTypes();
640 640
 		}
641 641
 		$contextType = $context->getType();
642
-		if ( !in_array( $contextType, $checkedContextTypes ) ) {
643
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null );
642
+		if (!in_array($contextType, $checkedContextTypes)) {
643
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null);
644 644
 		}
645
-		if ( $checker->getSupportedContextTypes()[$contextType] === CheckResult::STATUS_TODO ) {
646
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
645
+		if ($checker->getSupportedContextTypes()[$contextType] === CheckResult::STATUS_TODO) {
646
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
647 647
 		}
648 648
 
649
-		if ( $checkedEntityTypes === null ) {
649
+		if ($checkedEntityTypes === null) {
650 650
 			$checkedEntityTypes = $validEntityTypes;
651 651
 		}
652 652
 		$entityType = $context->getEntity()->getType();
653
-		if ( !in_array( $entityType, $checkedEntityTypes ) ) {
654
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null );
653
+		if (!in_array($entityType, $checkedEntityTypes)) {
654
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null);
655 655
 		}
656
-		if ( $checker->getSupportedEntityTypes()[$entityType] === CheckResult::STATUS_TODO ) {
657
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
656
+		if ($checker->getSupportedEntityTypes()[$entityType] === CheckResult::STATUS_TODO) {
657
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
658 658
 		}
659 659
 
660 660
 		return null;
661 661
 	}
662 662
 
663
-	private function addMetadata( Context $context, CheckResult $result ) {
664
-		$result->withMetadata( Metadata::merge( [
663
+	private function addMetadata(Context $context, CheckResult $result) {
664
+		$result->withMetadata(Metadata::merge([
665 665
 			$result->getMetadata(),
666
-			Metadata::ofDependencyMetadata( DependencyMetadata::merge( [
667
-				DependencyMetadata::ofEntityId( $context->getEntity()->getId() ),
668
-				DependencyMetadata::ofEntityId( $result->getConstraint()->getPropertyId() ),
669
-			] ) ),
670
-		] ) );
666
+			Metadata::ofDependencyMetadata(DependencyMetadata::merge([
667
+				DependencyMetadata::ofEntityId($context->getEntity()->getId()),
668
+				DependencyMetadata::ofEntityId($result->getConstraint()->getPropertyId()),
669
+			])),
670
+		]));
671 671
 	}
672 672
 
673
-	private function downgradeResultStatus( Context $context, CheckResult &$result ) {
673
+	private function downgradeResultStatus(Context $context, CheckResult &$result) {
674 674
 		$constraint = $result->getConstraint();
675 675
 		try {
676 676
 			$constraintStatus = $this->constraintParameterParser
677
-				->parseConstraintStatusParameter( $constraint->getConstraintParameters() );
678
-		} catch ( ConstraintParameterException $e ) {
679
-			$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
677
+				->parseConstraintStatusParameter($constraint->getConstraintParameters());
678
+		} catch (ConstraintParameterException $e) {
679
+			$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
680 680
 			$constraintStatus = null;
681 681
 		}
682
-		if ( $constraintStatus === null ) {
682
+		if ($constraintStatus === null) {
683 683
 			// downgrade violation to warning
684
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
685
-				$result->setStatus( CheckResult::STATUS_WARNING );
684
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
685
+				$result->setStatus(CheckResult::STATUS_WARNING);
686 686
 			}
687
-		} elseif ( $constraintStatus === 'suggestion' ) {
687
+		} elseif ($constraintStatus === 'suggestion') {
688 688
 			// downgrade violation to suggestion
689
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
690
-				$result->setStatus( CheckResult::STATUS_SUGGESTION );
689
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
690
+				$result->setStatus(CheckResult::STATUS_SUGGESTION);
691 691
 			}
692
-			$result->addParameter( 'constraint_status', $constraintStatus );
692
+			$result->addParameter('constraint_status', $constraintStatus);
693 693
 		} else {
694
-			if ( $constraintStatus !== 'mandatory' ) {
694
+			if ($constraintStatus !== 'mandatory') {
695 695
 				// @codeCoverageIgnoreStart
696 696
 				throw new LogicException(
697
-					"Unknown constraint status '$constraintStatus', " .
697
+					"Unknown constraint status '$constraintStatus', ".
698 698
 					"only known statuses are 'mandatory' and 'suggestion'"
699 699
 				);
700 700
 				// @codeCoverageIgnoreEnd
701 701
 			}
702
-			$result->addParameter( 'constraint_status', $constraintStatus );
702
+			$result->addParameter('constraint_status', $constraintStatus);
703 703
 		}
704 704
 	}
705 705
 
@@ -708,12 +708,12 @@  discard block
 block discarded – undo
708 708
 	 *
709 709
 	 * @return CheckResult[]
710 710
 	 */
711
-	private function sortResult( array $result ) {
712
-		if ( count( $result ) < 2 ) {
711
+	private function sortResult(array $result) {
712
+		if (count($result) < 2) {
713 713
 			return $result;
714 714
 		}
715 715
 
716
-		$sortFunction = static function ( CheckResult $a, CheckResult $b ) {
716
+		$sortFunction = static function(CheckResult $a, CheckResult $b) {
717 717
 			$orderNum = 0;
718 718
 			$order = [
719 719
 				CheckResult::STATUS_BAD_PARAMETERS => $orderNum++,
@@ -730,55 +730,55 @@  discard block
 block discarded – undo
730 730
 			$statusA = $a->getStatus();
731 731
 			$statusB = $b->getStatus();
732 732
 
733
-			$orderA = array_key_exists( $statusA, $order ) ? $order[ $statusA ] : $order[ 'other' ];
734
-			$orderB = array_key_exists( $statusB, $order ) ? $order[ $statusB ] : $order[ 'other' ];
733
+			$orderA = array_key_exists($statusA, $order) ? $order[$statusA] : $order['other'];
734
+			$orderB = array_key_exists($statusB, $order) ? $order[$statusB] : $order['other'];
735 735
 
736
-			if ( $orderA === $orderB ) {
736
+			if ($orderA === $orderB) {
737 737
 				$cursorA = $a->getContextCursor();
738 738
 				$cursorB = $b->getContextCursor();
739 739
 
740
-				if ( $cursorA instanceof EntityContextCursor ) {
740
+				if ($cursorA instanceof EntityContextCursor) {
741 741
 					return $cursorB instanceof EntityContextCursor ? 0 : -1;
742 742
 				}
743
-				if ( $cursorB instanceof EntityContextCursor ) {
743
+				if ($cursorB instanceof EntityContextCursor) {
744 744
 					return $cursorA instanceof EntityContextCursor ? 0 : 1;
745 745
 				}
746 746
 
747 747
 				$pidA = $cursorA->getSnakPropertyId();
748 748
 				$pidB = $cursorB->getSnakPropertyId();
749 749
 
750
-				if ( $pidA === $pidB ) {
750
+				if ($pidA === $pidB) {
751 751
 					$hashA = $cursorA->getSnakHash();
752 752
 					$hashB = $cursorB->getSnakHash();
753 753
 
754
-					if ( $hashA === $hashB ) {
755
-						if ( $a instanceof NullResult ) {
754
+					if ($hashA === $hashB) {
755
+						if ($a instanceof NullResult) {
756 756
 							return $b instanceof NullResult ? 0 : -1;
757 757
 						}
758
-						if ( $b instanceof NullResult ) {
758
+						if ($b instanceof NullResult) {
759 759
 							return $a instanceof NullResult ? 0 : 1;
760 760
 						}
761 761
 
762 762
 						$typeA = $a->getConstraint()->getConstraintTypeItemId();
763 763
 						$typeB = $b->getConstraint()->getConstraintTypeItemId();
764 764
 
765
-						if ( $typeA == $typeB ) {
765
+						if ($typeA == $typeB) {
766 766
 							return 0;
767 767
 						} else {
768
-							return ( $typeA > $typeB ) ? 1 : -1;
768
+							return ($typeA > $typeB) ? 1 : -1;
769 769
 						}
770 770
 					} else {
771
-						return ( $hashA > $hashB ) ? 1 : -1;
771
+						return ($hashA > $hashB) ? 1 : -1;
772 772
 					}
773 773
 				} else {
774
-					return ( $pidA > $pidB ) ? 1 : -1;
774
+					return ($pidA > $pidB) ? 1 : -1;
775 775
 				}
776 776
 			} else {
777
-				return ( $orderA > $orderB ) ? 1 : -1;
777
+				return ($orderA > $orderB) ? 1 : -1;
778 778
 			}
779 779
 		};
780 780
 
781
-		uasort( $result, $sortFunction );
781
+		uasort($result, $sortFunction);
782 782
 
783 783
 		return $result;
784 784
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/TypeCheckerHelper.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -81,26 +81,26 @@  discard block
 block discarded – undo
81 81
 	 * @return bool
82 82
 	 * @throws OverflowException if $entitiesChecked exceeds the configured limit
83 83
 	 */
84
-	private function isSubclassOf( EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0 ) {
85
-		$maxEntities = $this->config->get( 'WBQualityConstraintsTypeCheckMaxEntities' );
84
+	private function isSubclassOf(EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0) {
85
+		$maxEntities = $this->config->get('WBQualityConstraintsTypeCheckMaxEntities');
86 86
 		if ( ++$entitiesChecked > $maxEntities ) {
87
-			throw new OverflowException( 'Too many entities to check' );
87
+			throw new OverflowException('Too many entities to check');
88 88
 		}
89 89
 
90
-		$item = $this->entityLookup->getEntity( $comparativeClass );
91
-		if ( !( $item instanceof StatementListProvider ) ) {
90
+		$item = $this->entityLookup->getEntity($comparativeClass);
91
+		if (!($item instanceof StatementListProvider)) {
92 92
 			return false; // lookup failed, probably because item doesn't exist
93 93
 		}
94 94
 
95
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
95
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfId');
96 96
 		$statements = $item->getStatements()
97
-			->getByPropertyId( new NumericPropertyId( $subclassId ) )
97
+			->getByPropertyId(new NumericPropertyId($subclassId))
98 98
 			->getBestStatements();
99 99
 		/** @var Statement $statement */
100
-		foreach ( $statements as $statement ) {
100
+		foreach ($statements as $statement) {
101 101
 			$mainSnak = $statement->getMainSnak();
102 102
 
103
-			if ( !$this->hasCorrectType( $mainSnak ) ) {
103
+			if (!$this->hasCorrectType($mainSnak)) {
104 104
 				continue;
105 105
 			}
106 106
 			/** @var PropertyValueSnak $mainSnak */
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 			'@phan-var EntityIdValue $dataValue';
111 111
 			$comparativeClass = $dataValue->getEntityId();
112 112
 
113
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
113
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
114 114
 				return true;
115 115
 			}
116 116
 
117
-			if ( $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ) ) {
117
+			if ($this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked)) {
118 118
 				return true;
119 119
 			}
120 120
 		}
@@ -135,48 +135,48 @@  discard block
 block discarded – undo
135 135
 	 * @return CachedBool
136 136
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
137 137
 	 */
138
-	public function isSubclassOfWithSparqlFallback( EntityId $comparativeClass, array $classesToCheck ) {
138
+	public function isSubclassOfWithSparqlFallback(EntityId $comparativeClass, array $classesToCheck) {
139 139
 		try {
140 140
 			$entitiesChecked = 0;
141
-			$start1 = microtime( true );
142
-			$isSubclass = $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked );
143
-			$end1 = microtime( true );
141
+			$start1 = microtime(true);
142
+			$isSubclass = $this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked);
143
+			$end1 = microtime(true);
144 144
 			$this->dataFactory->timing(
145 145
 				'wikibase.quality.constraints.type.php.success.timing',
146
-				( $end1 - $start1 ) * 1000
146
+				($end1 - $start1) * 1000
147 147
 			);
148 148
 			$this->dataFactory->timing( // not really a timing, but works like one (we want percentiles etc.)
149 149
 				'wikibase.quality.constraints.type.php.success.entities',
150 150
 				$entitiesChecked
151 151
 			);
152 152
 
153
-			return new CachedBool( $isSubclass, Metadata::blank() );
154
-		} catch ( OverflowException $e ) {
155
-			$end1 = microtime( true );
153
+			return new CachedBool($isSubclass, Metadata::blank());
154
+		} catch (OverflowException $e) {
155
+			$end1 = microtime(true);
156 156
 			$this->dataFactory->timing(
157 157
 				'wikibase.quality.constraints.type.php.overflow.timing',
158
-				( $end1 - $start1 ) * 1000
158
+				($end1 - $start1) * 1000
159 159
 			);
160 160
 
161
-			if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) {
161
+			if (!($this->sparqlHelper instanceof DummySparqlHelper)) {
162 162
 				$this->dataFactory->increment(
163 163
 					'wikibase.quality.constraints.sparql.typeFallback'
164 164
 				);
165 165
 
166
-				$start2 = microtime( true );
166
+				$start2 = microtime(true);
167 167
 				$hasType = $this->sparqlHelper->hasType(
168 168
 					$comparativeClass->getSerialization(),
169 169
 					$classesToCheck
170 170
 				);
171
-				$end2 = microtime( true );
171
+				$end2 = microtime(true);
172 172
 				$this->dataFactory->timing(
173 173
 					'wikibase.quality.constraints.type.sparql.success.timing',
174
-					( $end2 - $start2 ) * 1000
174
+					($end2 - $start2) * 1000
175 175
 				);
176 176
 
177 177
 				return $hasType;
178 178
 			} else {
179
-				return new CachedBool( false, Metadata::blank() );
179
+				return new CachedBool(false, Metadata::blank());
180 180
 			}
181 181
 		}
182 182
 	}
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
 	 * @return CachedBool
195 195
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
196 196
 	 */
197
-	public function hasClassInRelation( StatementList $statements, array $relationIds, array $classesToCheck ) {
197
+	public function hasClassInRelation(StatementList $statements, array $relationIds, array $classesToCheck) {
198 198
 		$metadatas = [];
199 199
 
200
-		foreach ( $this->getBestStatementsByPropertyIds( $statements, $relationIds ) as $statement ) {
200
+		foreach ($this->getBestStatementsByPropertyIds($statements, $relationIds) as $statement) {
201 201
 			$mainSnak = $statement->getMainSnak();
202 202
 
203
-			if ( !$this->hasCorrectType( $mainSnak ) ) {
203
+			if (!$this->hasCorrectType($mainSnak)) {
204 204
 				continue;
205 205
 			}
206 206
 			/** @var PropertyValueSnak $mainSnak */
@@ -210,24 +210,24 @@  discard block
 block discarded – undo
210 210
 			'@phan-var EntityIdValue $dataValue';
211 211
 			$comparativeClass = $dataValue->getEntityId();
212 212
 
213
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
213
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
214 214
 				// discard $metadatas, we know this is fresh
215
-				return new CachedBool( true, Metadata::blank() );
215
+				return new CachedBool(true, Metadata::blank());
216 216
 			}
217 217
 
218
-			$result = $this->isSubclassOfWithSparqlFallback( $comparativeClass, $classesToCheck );
218
+			$result = $this->isSubclassOfWithSparqlFallback($comparativeClass, $classesToCheck);
219 219
 			$metadatas[] = $result->getMetadata();
220
-			if ( $result->getBool() ) {
220
+			if ($result->getBool()) {
221 221
 				return new CachedBool(
222 222
 					true,
223
-					Metadata::merge( $metadatas )
223
+					Metadata::merge($metadatas)
224 224
 				);
225 225
 			}
226 226
 		}
227 227
 
228 228
 		return new CachedBool(
229 229
 			false,
230
-			Metadata::merge( $metadatas )
230
+			Metadata::merge($metadatas)
231 231
 		);
232 232
 	}
233 233
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 * @return bool
237 237
 	 * @phan-assert PropertyValueSnak $mainSnak
238 238
 	 */
239
-	private function hasCorrectType( Snak $mainSnak ) {
239
+	private function hasCorrectType(Snak $mainSnak) {
240 240
 		return $mainSnak instanceof PropertyValueSnak
241 241
 			&& $mainSnak->getDataValue()->getType() === 'wikibase-entityid';
242 242
 	}
@@ -253,15 +253,15 @@  discard block
 block discarded – undo
253 253
 	) {
254 254
 		$statementArrays = [];
255 255
 
256
-		foreach ( $propertyIdSerializations as $propertyIdSerialization ) {
257
-			$propertyId = new NumericPropertyId( $propertyIdSerialization );
256
+		foreach ($propertyIdSerializations as $propertyIdSerialization) {
257
+			$propertyId = new NumericPropertyId($propertyIdSerialization);
258 258
 			$statementArrays[] = $statements
259
-				->getByPropertyId( $propertyId )
259
+				->getByPropertyId($propertyId)
260 260
 				->getBestStatements()
261 261
 				->toArray();
262 262
 		}
263 263
 
264
-		return call_user_func_array( 'array_merge', $statementArrays );
264
+		return call_user_func_array('array_merge', $statementArrays);
265 265
 	}
266 266
 
267 267
 	/**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 		$relation
282 282
 	) {
283 283
 		$classes = array_map(
284
-			static function ( $itemIdSerialization ) {
285
-				return new ItemId( $itemIdSerialization );
284
+			static function($itemIdSerialization) {
285
+				return new ItemId($itemIdSerialization);
286 286
 			},
287 287
 			$classes
288 288
 		);
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 		// wbqc-violation-message-valueType-instance
295 295
 		// wbqc-violation-message-valueType-subclass
296 296
 		// wbqc-violation-message-valueType-instanceOrSubclass
297
-		return ( new ViolationMessage( 'wbqc-violation-message-' . $checker . '-' . $relation ) )
298
-			->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY )
299
-			->withEntityId( $entityId, Role::SUBJECT )
300
-			->withEntityIdList( $classes, Role::OBJECT );
297
+		return (new ViolationMessage('wbqc-violation-message-'.$checker.'-'.$relation))
298
+			->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY)
299
+			->withEntityId($entityId, Role::SUBJECT)
300
+			->withEntityIdList($classes, Role::OBJECT);
301 301
 	}
302 302
 
303 303
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +287 added lines, -287 removed lines patch added patch discarded remove patch
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 	 * @param array $parameters
79 79
 	 * @throws ConstraintParameterException
80 80
 	 */
81
-	public function checkError( array $parameters ) {
82
-		if ( array_key_exists( '@error', $parameters ) ) {
81
+	public function checkError(array $parameters) {
82
+		if (array_key_exists('@error', $parameters)) {
83 83
 			$error = $parameters['@error'];
84
-			if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) {
84
+			if (array_key_exists('toolong', $error) && $error['toolong']) {
85 85
 				$msg = 'wbqc-violation-message-parameters-error-toolong';
86 86
 			} else {
87 87
 				$msg = 'wbqc-violation-message-parameters-error-unknown';
88 88
 			}
89
-			throw new ConstraintParameterException( new ViolationMessage( $msg ) );
89
+			throw new ConstraintParameterException(new ViolationMessage($msg));
90 90
 		}
91 91
 	}
92 92
 
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 	 * @param string $parameterId
97 97
 	 * @throws ConstraintParameterException
98 98
 	 */
99
-	private function requireSingleParameter( array $parameters, $parameterId ) {
100
-		if ( count( $parameters[$parameterId] ) !== 1 ) {
99
+	private function requireSingleParameter(array $parameters, $parameterId) {
100
+		if (count($parameters[$parameterId]) !== 1) {
101 101
 			throw new ConstraintParameterException(
102
-				( new ViolationMessage( 'wbqc-violation-message-parameter-single' ) )
103
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
102
+				(new ViolationMessage('wbqc-violation-message-parameter-single'))
103
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
104 104
 			);
105 105
 		}
106 106
 	}
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 	 * @return void
113 113
 	 * @throws ConstraintParameterException
114 114
 	 */
115
-	private function requireValueParameter( Snak $snak, $parameterId ) {
116
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
115
+	private function requireValueParameter(Snak $snak, $parameterId) {
116
+		if (!($snak instanceof PropertyValueSnak)) {
117 117
 			throw new ConstraintParameterException(
118
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
119
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
118
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
119
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
120 120
 			);
121 121
 		}
122 122
 	}
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
 	 * @throws ConstraintParameterException
129 129
 	 * @return EntityId
130 130
 	 */
131
-	private function parseEntityIdParameter( array $snakSerialization, $parameterId ) {
132
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
133
-		$this->requireValueParameter( $snak, $parameterId );
131
+	private function parseEntityIdParameter(array $snakSerialization, $parameterId) {
132
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
133
+		$this->requireValueParameter($snak, $parameterId);
134 134
 		$value = $snak->getDataValue();
135
-		if ( $value instanceof EntityIdValue ) {
135
+		if ($value instanceof EntityIdValue) {
136 136
 			return $value->getEntityId();
137 137
 		} else {
138 138
 			throw new ConstraintParameterException(
139
-				( new ViolationMessage( 'wbqc-violation-message-parameter-entity' ) )
140
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
141
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
139
+				(new ViolationMessage('wbqc-violation-message-parameter-entity'))
140
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
141
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
142 142
 			);
143 143
 		}
144 144
 	}
@@ -149,20 +149,20 @@  discard block
 block discarded – undo
149 149
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
150 150
 	 * @return string[] class entity ID serializations
151 151
 	 */
152
-	public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) {
153
-		$this->checkError( $constraintParameters );
154
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
155
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
152
+	public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) {
153
+		$this->checkError($constraintParameters);
154
+		$classId = $this->config->get('WBQualityConstraintsClassId');
155
+		if (!array_key_exists($classId, $constraintParameters)) {
156 156
 			throw new ConstraintParameterException(
157
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
158
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
159
-					->withEntityId( new NumericPropertyId( $classId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
157
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
158
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
159
+					->withEntityId(new NumericPropertyId($classId), Role::CONSTRAINT_PARAMETER_PROPERTY)
160 160
 			);
161 161
 		}
162 162
 
163 163
 		$classes = [];
164
-		foreach ( $constraintParameters[$classId] as $class ) {
165
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
164
+		foreach ($constraintParameters[$classId] as $class) {
165
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
166 166
 		}
167 167
 		return $classes;
168 168
 	}
@@ -173,31 +173,31 @@  discard block
 block discarded – undo
173 173
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
174 174
 	 * @return string 'instance', 'subclass', or 'instanceOrSubclass'
175 175
 	 */
176
-	public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) {
177
-		$this->checkError( $constraintParameters );
178
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
179
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
176
+	public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) {
177
+		$this->checkError($constraintParameters);
178
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
179
+		if (!array_key_exists($relationId, $constraintParameters)) {
180 180
 			throw new ConstraintParameterException(
181
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
182
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
183
-					->withEntityId( new NumericPropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
181
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
182
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
183
+					->withEntityId(new NumericPropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
184 184
 			);
185 185
 		}
186 186
 
187
-		$this->requireSingleParameter( $constraintParameters, $relationId );
188
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
189
-		if ( !( $relationEntityId instanceof ItemId ) ) {
187
+		$this->requireSingleParameter($constraintParameters, $relationId);
188
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
189
+		if (!($relationEntityId instanceof ItemId)) {
190 190
 			throw new ConstraintParameterException(
191
-				( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
192
-					->withEntityId( new NumericPropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
193
-					->withDataValue( new EntityIdValue( $relationEntityId ), Role::CONSTRAINT_PARAMETER_VALUE )
191
+				(new ViolationMessage('wbqc-violation-message-parameter-item'))
192
+					->withEntityId(new NumericPropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
193
+					->withDataValue(new EntityIdValue($relationEntityId), Role::CONSTRAINT_PARAMETER_VALUE)
194 194
 			);
195 195
 		}
196
-		return $this->mapItemId( $relationEntityId, [
197
-			$this->config->get( 'WBQualityConstraintsInstanceOfRelationId' ) => 'instance',
198
-			$this->config->get( 'WBQualityConstraintsSubclassOfRelationId' ) => 'subclass',
199
-			$this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' ) => 'instanceOrSubclass',
200
-		], $relationId );
196
+		return $this->mapItemId($relationEntityId, [
197
+			$this->config->get('WBQualityConstraintsInstanceOfRelationId') => 'instance',
198
+			$this->config->get('WBQualityConstraintsSubclassOfRelationId') => 'subclass',
199
+			$this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId') => 'instanceOrSubclass',
200
+		], $relationId);
201 201
 	}
202 202
 
203 203
 	/**
@@ -207,20 +207,20 @@  discard block
 block discarded – undo
207 207
 	 * @throws ConstraintParameterException
208 208
 	 * @return PropertyId
209 209
 	 */
210
-	private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) {
211
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
212
-		$this->requireValueParameter( $snak, $parameterId );
210
+	private function parsePropertyIdParameter(array $snakSerialization, $parameterId) {
211
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
212
+		$this->requireValueParameter($snak, $parameterId);
213 213
 		$value = $snak->getDataValue();
214
-		if ( $value instanceof EntityIdValue ) {
214
+		if ($value instanceof EntityIdValue) {
215 215
 			$id = $value->getEntityId();
216
-			if ( $id instanceof PropertyId ) {
216
+			if ($id instanceof PropertyId) {
217 217
 				return $id;
218 218
 			}
219 219
 		}
220 220
 		throw new ConstraintParameterException(
221
-			( new ViolationMessage( 'wbqc-violation-message-parameter-property' ) )
222
-				->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
223
-				->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
221
+			(new ViolationMessage('wbqc-violation-message-parameter-property'))
222
+				->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
223
+				->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
224 224
 		);
225 225
 	}
226 226
 
@@ -231,33 +231,33 @@  discard block
 block discarded – undo
231 231
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
232 232
 	 * @return PropertyId
233 233
 	 */
234
-	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
235
-		$this->checkError( $constraintParameters );
236
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
237
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
234
+	public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) {
235
+		$this->checkError($constraintParameters);
236
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
237
+		if (!array_key_exists($propertyId, $constraintParameters)) {
238 238
 			throw new ConstraintParameterException(
239
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
240
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
241
-					->withEntityId( new NumericPropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
239
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
240
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
241
+					->withEntityId(new NumericPropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
242 242
 			);
243 243
 		}
244 244
 
245
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
246
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
245
+		$this->requireSingleParameter($constraintParameters, $propertyId);
246
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
247 247
 	}
248 248
 
249
-	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
249
+	private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) {
250 250
 		$dataValue = $snak->getDataValue();
251
-		if ( $dataValue instanceof EntityIdValue ) {
251
+		if ($dataValue instanceof EntityIdValue) {
252 252
 			$entityId = $dataValue->getEntityId();
253
-			if ( $entityId instanceof ItemId ) {
254
-				return ItemIdSnakValue::fromItemId( $entityId );
253
+			if ($entityId instanceof ItemId) {
254
+				return ItemIdSnakValue::fromItemId($entityId);
255 255
 			}
256 256
 		}
257 257
 		throw new ConstraintParameterException(
258
-			( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
259
-				->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
260
-				->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
258
+			(new ViolationMessage('wbqc-violation-message-parameter-item'))
259
+				->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
260
+				->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
261 261
 		);
262 262
 	}
263 263
 
@@ -275,16 +275,16 @@  discard block
 block discarded – undo
275 275
 		$required,
276 276
 		$parameterId = null
277 277
 	) {
278
-		$this->checkError( $constraintParameters );
279
-		if ( $parameterId === null ) {
280
-			$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
278
+		$this->checkError($constraintParameters);
279
+		if ($parameterId === null) {
280
+			$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
281 281
 		}
282
-		if ( !array_key_exists( $parameterId, $constraintParameters ) ) {
283
-			if ( $required ) {
282
+		if (!array_key_exists($parameterId, $constraintParameters)) {
283
+			if ($required) {
284 284
 				throw new ConstraintParameterException(
285
-					( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
286
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
287
-						->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
285
+					(new ViolationMessage('wbqc-violation-message-parameter-needed'))
286
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
287
+						->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
288 288
 				);
289 289
 			} else {
290 290
 				return [];
@@ -292,11 +292,11 @@  discard block
 block discarded – undo
292 292
 		}
293 293
 
294 294
 		$values = [];
295
-		foreach ( $constraintParameters[$parameterId] as $parameter ) {
296
-			$snak = $this->snakDeserializer->deserialize( $parameter );
297
-			switch ( true ) {
295
+		foreach ($constraintParameters[$parameterId] as $parameter) {
296
+			$snak = $this->snakDeserializer->deserialize($parameter);
297
+			switch (true) {
298 298
 				case $snak instanceof PropertyValueSnak:
299
-					$values[] = $this->parseItemIdParameter( $snak, $parameterId );
299
+					$values[] = $this->parseItemIdParameter($snak, $parameterId);
300 300
 					break;
301 301
 				case $snak instanceof PropertySomeValueSnak:
302 302
 					$values[] = ItemIdSnakValue::someValue();
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
 		bool $required,
325 325
 		string $parameterId
326 326
 	): array {
327
-		return array_map( static function ( ItemIdSnakValue $value ) use ( $parameterId ): ItemId {
328
-			if ( $value->isValue() ) {
327
+		return array_map(static function(ItemIdSnakValue $value) use ($parameterId): ItemId {
328
+			if ($value->isValue()) {
329 329
 				return $value->getItemId();
330 330
 			} else {
331 331
 				throw new ConstraintParameterException(
332
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
333
-						->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
332
+					(new ViolationMessage('wbqc-violation-message-parameter-value'))
333
+						->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
334 334
 				);
335 335
 			}
336 336
 		}, $this->parseItemsParameter(
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 			$constraintTypeItemId,
339 339
 			$required,
340 340
 			$parameterId
341
-		) );
341
+		));
342 342
 	}
343 343
 
344 344
 	/**
@@ -346,18 +346,18 @@  discard block
 block discarded – undo
346 346
 	 * @throws ConstraintParameterException
347 347
 	 * @return mixed elements of $mapping
348 348
 	 */
349
-	private function mapItemId( ItemId $itemId, array $mapping, string $parameterId ) {
349
+	private function mapItemId(ItemId $itemId, array $mapping, string $parameterId) {
350 350
 		$serialization = $itemId->getSerialization();
351
-		if ( array_key_exists( $serialization, $mapping ) ) {
351
+		if (array_key_exists($serialization, $mapping)) {
352 352
 			return $mapping[$serialization];
353 353
 		} else {
354
-			$allowed = array_map( static function ( $id ) {
355
-				return new ItemId( $id );
356
-			}, array_keys( $mapping ) );
354
+			$allowed = array_map(static function($id) {
355
+				return new ItemId($id);
356
+			}, array_keys($mapping));
357 357
 			throw new ConstraintParameterException(
358
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
359
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
360
-					->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
358
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
359
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
360
+					->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
361 361
 			);
362 362
 		}
363 363
 	}
@@ -368,27 +368,27 @@  discard block
 block discarded – undo
368 368
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
369 369
 	 * @return PropertyId[]
370 370
 	 */
371
-	public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) {
372
-		$this->checkError( $constraintParameters );
373
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
374
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
371
+	public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) {
372
+		$this->checkError($constraintParameters);
373
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
374
+		if (!array_key_exists($propertyId, $constraintParameters)) {
375 375
 			throw new ConstraintParameterException(
376
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
377
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
378
-					->withEntityId( new NumericPropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
376
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
377
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
378
+					->withEntityId(new NumericPropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
379 379
 			);
380 380
 		}
381 381
 
382 382
 		$parameters = $constraintParameters[$propertyId];
383
-		if ( count( $parameters ) === 1 &&
384
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
383
+		if (count($parameters) === 1 &&
384
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
385 385
 		) {
386 386
 			return [];
387 387
 		}
388 388
 
389 389
 		$properties = [];
390
-		foreach ( $parameters as $parameter ) {
391
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
390
+		foreach ($parameters as $parameter) {
391
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
392 392
 		}
393 393
 		return $properties;
394 394
 	}
@@ -399,16 +399,16 @@  discard block
 block discarded – undo
399 399
 	 * @throws ConstraintParameterException
400 400
 	 * @return DataValue|null
401 401
 	 */
402
-	private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) {
403
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
404
-		if ( $snak instanceof PropertyValueSnak ) {
402
+	private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) {
403
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
404
+		if ($snak instanceof PropertyValueSnak) {
405 405
 			return $snak->getDataValue();
406
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
406
+		} elseif ($snak instanceof PropertyNoValueSnak) {
407 407
 			return null;
408 408
 		} else {
409 409
 			throw new ConstraintParameterException(
410
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
411
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
410
+				(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
411
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
412 412
 			);
413 413
 		}
414 414
 	}
@@ -418,10 +418,10 @@  discard block
 block discarded – undo
418 418
 	 * @param string $parameterId
419 419
 	 * @return DataValue|null
420 420
 	 */
421
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) {
421
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) {
422 422
 		try {
423
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
424
-		} catch ( ConstraintParameterException $e ) {
423
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
424
+		} catch (ConstraintParameterException $e) {
425 425
 			// unknown value means “now”
426 426
 			return new NowValue();
427 427
 		}
@@ -434,14 +434,14 @@  discard block
 block discarded – undo
434 434
 	 * @param string $unit
435 435
 	 * @return bool
436 436
 	 */
437
-	private function exactlyOneQuantityWithUnit( ?DataValue $min, ?DataValue $max, $unit ) {
438
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
439
-			!( $max instanceof UnboundedQuantityValue )
437
+	private function exactlyOneQuantityWithUnit(?DataValue $min, ?DataValue $max, $unit) {
438
+		if (!($min instanceof UnboundedQuantityValue) ||
439
+			!($max instanceof UnboundedQuantityValue)
440 440
 		) {
441 441
 			return false;
442 442
 		}
443 443
 
444
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
444
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
445 445
 	}
446 446
 
447 447
 	/**
@@ -454,42 +454,42 @@  discard block
 block discarded – undo
454 454
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
455 455
 	 * @return DataValue[] if the parameter is invalid or missing
456 456
 	 */
457
-	private function parseRangeParameter( array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type ) {
458
-		$this->checkError( $constraintParameters );
459
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
460
-			!array_key_exists( $maximumId, $constraintParameters )
457
+	private function parseRangeParameter(array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type) {
458
+		$this->checkError($constraintParameters);
459
+		if (!array_key_exists($minimumId, $constraintParameters) ||
460
+			!array_key_exists($maximumId, $constraintParameters)
461 461
 		) {
462 462
 			throw new ConstraintParameterException(
463
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-needed' ) )
464
-					->withDataValueType( $type )
465
-					->withEntityId( new NumericPropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
466
-					->withEntityId( new NumericPropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
467
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
463
+				(new ViolationMessage('wbqc-violation-message-range-parameters-needed'))
464
+					->withDataValueType($type)
465
+					->withEntityId(new NumericPropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
466
+					->withEntityId(new NumericPropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
467
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
468 468
 			);
469 469
 		}
470 470
 
471
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
472
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
471
+		$this->requireSingleParameter($constraintParameters, $minimumId);
472
+		$this->requireSingleParameter($constraintParameters, $maximumId);
473 473
 		$parseFunction = $type === 'time' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
474
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
475
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
474
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
475
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
476 476
 
477
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
478
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
477
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
478
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
479 479
 			throw new ConstraintParameterException(
480
-				new ViolationMessage( 'wbqc-violation-message-range-parameters-one-year' )
480
+				new ViolationMessage('wbqc-violation-message-range-parameters-one-year')
481 481
 			);
482 482
 		}
483
-		if ( $min === null && $max === null ||
484
-			$min !== null && $max !== null && $min->equals( $max ) ) {
483
+		if ($min === null && $max === null ||
484
+			$min !== null && $max !== null && $min->equals($max)) {
485 485
 			throw new ConstraintParameterException(
486
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-same' ) )
487
-					->withEntityId( new NumericPropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
488
-					->withEntityId( new NumericPropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
486
+				(new ViolationMessage('wbqc-violation-message-range-parameters-same'))
487
+					->withEntityId(new NumericPropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
488
+					->withEntityId(new NumericPropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
489 489
 			);
490 490
 		}
491 491
 
492
-		return [ $min, $max ];
492
+		return [$min, $max];
493 493
 	}
494 494
 
495 495
 	/**
@@ -499,11 +499,11 @@  discard block
 block discarded – undo
499 499
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
500 500
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
501 501
 	 */
502
-	public function parseQuantityRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
502
+	public function parseQuantityRangeParameter(array $constraintParameters, $constraintTypeItemId) {
503 503
 		return $this->parseRangeParameter(
504 504
 			$constraintParameters,
505
-			$this->config->get( 'WBQualityConstraintsMinimumQuantityId' ),
506
-			$this->config->get( 'WBQualityConstraintsMaximumQuantityId' ),
505
+			$this->config->get('WBQualityConstraintsMinimumQuantityId'),
506
+			$this->config->get('WBQualityConstraintsMaximumQuantityId'),
507 507
 			$constraintTypeItemId,
508 508
 			'quantity'
509 509
 		);
@@ -516,11 +516,11 @@  discard block
 block discarded – undo
516 516
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
517 517
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
518 518
 	 */
519
-	public function parseTimeRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
519
+	public function parseTimeRangeParameter(array $constraintParameters, $constraintTypeItemId) {
520 520
 		return $this->parseRangeParameter(
521 521
 			$constraintParameters,
522
-			$this->config->get( 'WBQualityConstraintsMinimumDateId' ),
523
-			$this->config->get( 'WBQualityConstraintsMaximumDateId' ),
522
+			$this->config->get('WBQualityConstraintsMinimumDateId'),
523
+			$this->config->get('WBQualityConstraintsMaximumDateId'),
524 524
 			$constraintTypeItemId,
525 525
 			'time'
526 526
 		);
@@ -532,20 +532,20 @@  discard block
 block discarded – undo
532 532
 	 * @throws ConstraintParameterException
533 533
 	 * @return string[]
534 534
 	 */
535
-	public function parseLanguageParameter( array $constraintParameters, $constraintTypeItemId ): array {
536
-		$this->checkError( $constraintParameters );
537
-		$languagePropertyId = $this->config->get( 'WBQualityConstraintsLanguagePropertyId' );
538
-		if ( !array_key_exists( $languagePropertyId, $constraintParameters ) ) {
535
+	public function parseLanguageParameter(array $constraintParameters, $constraintTypeItemId): array {
536
+		$this->checkError($constraintParameters);
537
+		$languagePropertyId = $this->config->get('WBQualityConstraintsLanguagePropertyId');
538
+		if (!array_key_exists($languagePropertyId, $constraintParameters)) {
539 539
 			throw new ConstraintParameterException(
540
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
541
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
542
-					->withEntityId( new NumericPropertyId( $languagePropertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
540
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
541
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
542
+					->withEntityId(new NumericPropertyId($languagePropertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
543 543
 			);
544 544
 		}
545 545
 
546 546
 		$languages = [];
547
-		foreach ( $constraintParameters[$languagePropertyId] as $snak ) {
548
-			$languages[] = $this->parseStringParameter( $snak, $languagePropertyId );
547
+		foreach ($constraintParameters[$languagePropertyId] as $snak) {
548
+			$languages[] = $this->parseStringParameter($snak, $languagePropertyId);
549 549
 		}
550 550
 		return $languages;
551 551
 	}
@@ -557,17 +557,17 @@  discard block
 block discarded – undo
557 557
 	 * @throws ConstraintParameterException
558 558
 	 * @return string
559 559
 	 */
560
-	private function parseStringParameter( array $snakSerialization, $parameterId ) {
561
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
562
-		$this->requireValueParameter( $snak, $parameterId );
560
+	private function parseStringParameter(array $snakSerialization, $parameterId) {
561
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
562
+		$this->requireValueParameter($snak, $parameterId);
563 563
 		$value = $snak->getDataValue();
564
-		if ( $value instanceof StringValue ) {
564
+		if ($value instanceof StringValue) {
565 565
 			return $value->getValue();
566 566
 		} else {
567 567
 			throw new ConstraintParameterException(
568
-				( new ViolationMessage( 'wbqc-violation-message-parameter-string' ) )
569
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
570
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
568
+				(new ViolationMessage('wbqc-violation-message-parameter-string'))
569
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
570
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
571 571
 			);
572 572
 		}
573 573
 	}
@@ -578,15 +578,15 @@  discard block
 block discarded – undo
578 578
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
579 579
 	 * @return string
580 580
 	 */
581
-	public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) {
582
-		$this->checkError( $constraintParameters );
583
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
584
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
581
+	public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) {
582
+		$this->checkError($constraintParameters);
583
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
584
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
585 585
 			return '';
586 586
 		}
587 587
 
588
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
589
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
588
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
589
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
590 590
 	}
591 591
 
592 592
 	/**
@@ -595,19 +595,19 @@  discard block
 block discarded – undo
595 595
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
596 596
 	 * @return string
597 597
 	 */
598
-	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
599
-		$this->checkError( $constraintParameters );
600
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
601
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
598
+	public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) {
599
+		$this->checkError($constraintParameters);
600
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
601
+		if (!array_key_exists($formatId, $constraintParameters)) {
602 602
 			throw new ConstraintParameterException(
603
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
604
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
605
-					->withEntityId( new NumericPropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
603
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
604
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
605
+					->withEntityId(new NumericPropertyId($formatId), Role::CONSTRAINT_PARAMETER_PROPERTY)
606 606
 			);
607 607
 		}
608 608
 
609
-		$this->requireSingleParameter( $constraintParameters, $formatId );
610
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
609
+		$this->requireSingleParameter($constraintParameters, $formatId);
610
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
611 611
 	}
612 612
 
613 613
 	/**
@@ -615,16 +615,16 @@  discard block
 block discarded – undo
615 615
 	 * @throws ConstraintParameterException if the parameter is invalid
616 616
 	 * @return EntityId[]
617 617
 	 */
618
-	public function parseExceptionParameter( array $constraintParameters ) {
619
-		$this->checkError( $constraintParameters );
620
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
621
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
618
+	public function parseExceptionParameter(array $constraintParameters) {
619
+		$this->checkError($constraintParameters);
620
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
621
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
622 622
 			return [];
623 623
 		}
624 624
 
625 625
 		return array_map(
626
-			function ( $snakSerialization ) use ( $exceptionId ) {
627
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
626
+			function($snakSerialization) use ($exceptionId) {
627
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
628 628
 			},
629 629
 			$constraintParameters[$exceptionId]
630 630
 		);
@@ -635,39 +635,39 @@  discard block
 block discarded – undo
635 635
 	 * @throws ConstraintParameterException if the parameter is invalid
636 636
 	 * @return string|null 'mandatory', 'suggestion' or null
637 637
 	 */
638
-	public function parseConstraintStatusParameter( array $constraintParameters ) {
639
-		$this->checkError( $constraintParameters );
640
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
641
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
638
+	public function parseConstraintStatusParameter(array $constraintParameters) {
639
+		$this->checkError($constraintParameters);
640
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
641
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
642 642
 			return null;
643 643
 		}
644 644
 
645
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
646
-		$supportedStatuses = [ new ItemId( $mandatoryId ) ];
647
-		if ( $this->config->get( 'WBQualityConstraintsEnableSuggestionConstraintStatus' ) ) {
648
-			$suggestionId = $this->config->get( 'WBQualityConstraintsSuggestionConstraintId' );
649
-			$supportedStatuses[] = new ItemId( $suggestionId );
645
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
646
+		$supportedStatuses = [new ItemId($mandatoryId)];
647
+		if ($this->config->get('WBQualityConstraintsEnableSuggestionConstraintStatus')) {
648
+			$suggestionId = $this->config->get('WBQualityConstraintsSuggestionConstraintId');
649
+			$supportedStatuses[] = new ItemId($suggestionId);
650 650
 		} else {
651 651
 			$suggestionId = null;
652 652
 		}
653 653
 
654
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
655
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
656
-		$this->requireValueParameter( $snak, $constraintStatusId );
654
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
655
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
656
+		$this->requireValueParameter($snak, $constraintStatusId);
657 657
 		'@phan-var \Wikibase\DataModel\Snak\PropertyValueSnak $snak';
658 658
 		$dataValue = $snak->getDataValue();
659 659
 		'@phan-var EntityIdValue $dataValue';
660 660
 		$entityId = $dataValue->getEntityId();
661 661
 		$statusId = $entityId->getSerialization();
662 662
 
663
-		if ( $statusId === $mandatoryId ) {
663
+		if ($statusId === $mandatoryId) {
664 664
 			return 'mandatory';
665
-		} elseif ( $statusId === $suggestionId ) {
665
+		} elseif ($statusId === $suggestionId) {
666 666
 			return 'suggestion';
667 667
 		} else {
668 668
 			throw new ConstraintParameterException(
669
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
670
-					->withEntityId( new NumericPropertyId( $constraintStatusId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
669
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
670
+					->withEntityId(new NumericPropertyId($constraintStatusId), Role::CONSTRAINT_PARAMETER_PROPERTY)
671 671
 					->withEntityIdList(
672 672
 						$supportedStatuses,
673 673
 						Role::CONSTRAINT_PARAMETER_VALUE
@@ -683,12 +683,12 @@  discard block
 block discarded – undo
683 683
 	 * @return void
684 684
 	 * @throws ConstraintParameterException
685 685
 	 */
686
-	private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) {
687
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
686
+	private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) {
687
+		if (!($dataValue instanceof MonolingualTextValue)) {
688 688
 			throw new ConstraintParameterException(
689
-				( new ViolationMessage( 'wbqc-violation-message-parameter-monolingualtext' ) )
690
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
691
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
689
+				(new ViolationMessage('wbqc-violation-message-parameter-monolingualtext'))
690
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
691
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
692 692
 			);
693 693
 		}
694 694
 	}
@@ -701,31 +701,31 @@  discard block
 block discarded – undo
701 701
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
702 702
 	 * @return MultilingualTextValue
703 703
 	 */
704
-	private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) {
704
+	private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) {
705 705
 		$result = [];
706 706
 
707
-		foreach ( $snakSerializations as $snakSerialization ) {
708
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
709
-			$this->requireValueParameter( $snak, $parameterId );
707
+		foreach ($snakSerializations as $snakSerialization) {
708
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
709
+			$this->requireValueParameter($snak, $parameterId);
710 710
 
711 711
 			$value = $snak->getDataValue();
712
-			$this->requireMonolingualTextParameter( $value, $parameterId );
712
+			$this->requireMonolingualTextParameter($value, $parameterId);
713 713
 			/** @var MonolingualTextValue $value */
714 714
 			'@phan-var MonolingualTextValue $value';
715 715
 
716 716
 			$code = $value->getLanguageCode();
717
-			if ( array_key_exists( $code, $result ) ) {
717
+			if (array_key_exists($code, $result)) {
718 718
 				throw new ConstraintParameterException(
719
-					( new ViolationMessage( 'wbqc-violation-message-parameter-single-per-language' ) )
720
-						->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
721
-						->withLanguage( $code )
719
+					(new ViolationMessage('wbqc-violation-message-parameter-single-per-language'))
720
+						->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
721
+						->withLanguage($code)
722 722
 				);
723 723
 			}
724 724
 
725 725
 			$result[$code] = $value;
726 726
 		}
727 727
 
728
-		return new MultilingualTextValue( $result );
728
+		return new MultilingualTextValue($result);
729 729
 	}
730 730
 
731 731
 	/**
@@ -733,11 +733,11 @@  discard block
 block discarded – undo
733 733
 	 * @throws ConstraintParameterException if the parameter is invalid
734 734
 	 * @return MultilingualTextValue
735 735
 	 */
736
-	public function parseSyntaxClarificationParameter( array $constraintParameters ) {
737
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
736
+	public function parseSyntaxClarificationParameter(array $constraintParameters) {
737
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
738 738
 
739
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
740
-			return new MultilingualTextValue( [] );
739
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
740
+			return new MultilingualTextValue([]);
741 741
 		}
742 742
 
743 743
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
@@ -770,14 +770,14 @@  discard block
 block discarded – undo
770 770
 		array $validContextTypes,
771 771
 		array $validEntityTypes
772 772
 	): array {
773
-		$contextTypeParameterId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
773
+		$contextTypeParameterId = $this->config->get('WBQualityConstraintsConstraintScopeId');
774 774
 		$contextTypeItemIds = $this->parseItemIdsParameter(
775 775
 			$constraintParameters,
776 776
 			$constraintTypeItemId,
777 777
 			false,
778 778
 			$contextTypeParameterId
779 779
 		);
780
-		$entityTypeParameterId = $this->config->get( 'WBQualityConstraintsConstraintEntityTypesId' );
780
+		$entityTypeParameterId = $this->config->get('WBQualityConstraintsConstraintEntityTypesId');
781 781
 		$entityTypeItemIds = $this->parseItemIdsParameter(
782 782
 			$constraintParameters,
783 783
 			$constraintTypeItemId,
@@ -793,26 +793,26 @@  discard block
 block discarded – undo
793 793
 		$contextTypes = null;
794 794
 		$entityTypes = null;
795 795
 
796
-		if ( $contextTypeParameterId === $entityTypeParameterId ) {
796
+		if ($contextTypeParameterId === $entityTypeParameterId) {
797 797
 			$itemIds = $contextTypeItemIds;
798 798
 			$mapping = $contextTypeMapping + $entityTypeMapping;
799
-			foreach ( $itemIds as $itemId ) {
800
-				$mapped = $this->mapItemId( $itemId, $mapping, $contextTypeParameterId );
801
-				if ( in_array( $mapped, $contextTypeMapping, true ) ) {
799
+			foreach ($itemIds as $itemId) {
800
+				$mapped = $this->mapItemId($itemId, $mapping, $contextTypeParameterId);
801
+				if (in_array($mapped, $contextTypeMapping, true)) {
802 802
 					$contextTypes[] = $mapped;
803 803
 				} else {
804 804
 					$entityTypes[] = $mapped;
805 805
 				}
806 806
 			}
807 807
 		} else {
808
-			foreach ( $contextTypeItemIds as $contextTypeItemId ) {
808
+			foreach ($contextTypeItemIds as $contextTypeItemId) {
809 809
 				$contextTypes[] = $this->mapItemId(
810 810
 					$contextTypeItemId,
811 811
 					$contextTypeMapping,
812 812
 					$contextTypeParameterId
813 813
 				);
814 814
 			}
815
-			foreach ( $entityTypeItemIds as $entityTypeItemId ) {
815
+			foreach ($entityTypeItemIds as $entityTypeItemId) {
816 816
 				$entityTypes[] = $this->mapItemId(
817 817
 					$entityTypeItemId,
818 818
 					$entityTypeMapping,
@@ -821,21 +821,21 @@  discard block
 block discarded – undo
821 821
 			}
822 822
 		}
823 823
 
824
-		$this->checkValidScope( $constraintTypeItemId, $contextTypes, $validContextTypes );
825
-		$this->checkValidScope( $constraintTypeItemId, $entityTypes, $validEntityTypes );
824
+		$this->checkValidScope($constraintTypeItemId, $contextTypes, $validContextTypes);
825
+		$this->checkValidScope($constraintTypeItemId, $entityTypes, $validEntityTypes);
826 826
 
827
-		return [ $contextTypes, $entityTypes ];
827
+		return [$contextTypes, $entityTypes];
828 828
 	}
829 829
 
830
-	private function checkValidScope( string $constraintTypeItemId, ?array $types, array $validTypes ): void {
831
-		$invalidTypes = array_diff( $types ?: [], $validTypes );
832
-		if ( $invalidTypes !== [] ) {
833
-			$invalidType = array_pop( $invalidTypes );
830
+	private function checkValidScope(string $constraintTypeItemId, ?array $types, array $validTypes): void {
831
+		$invalidTypes = array_diff($types ?: [], $validTypes);
832
+		if ($invalidTypes !== []) {
833
+			$invalidType = array_pop($invalidTypes);
834 834
 			throw new ConstraintParameterException(
835
-				( new ViolationMessage( 'wbqc-violation-message-invalid-scope' ) )
836
-					->withConstraintScope( $invalidType, Role::CONSTRAINT_PARAMETER_VALUE )
837
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
838
-					->withConstraintScopeList( $validTypes, Role::CONSTRAINT_PARAMETER_VALUE )
835
+				(new ViolationMessage('wbqc-violation-message-invalid-scope'))
836
+					->withConstraintScope($invalidType, Role::CONSTRAINT_PARAMETER_VALUE)
837
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
838
+					->withConstraintScopeList($validTypes, Role::CONSTRAINT_PARAMETER_VALUE)
839 839
 			);
840 840
 		}
841 841
 	}
@@ -846,8 +846,8 @@  discard block
 block discarded – undo
846 846
 	 * @param ItemId $unitId
847 847
 	 * @return string unit
848 848
 	 */
849
-	private function parseUnitParameter( ItemId $unitId ) {
850
-		return $this->unitItemConceptBaseUri . $unitId->getSerialization();
849
+	private function parseUnitParameter(ItemId $unitId) {
850
+		return $this->unitItemConceptBaseUri.$unitId->getSerialization();
851 851
 	}
852 852
 
853 853
 	/**
@@ -857,23 +857,23 @@  discard block
 block discarded – undo
857 857
 	 * @return UnitsParameter
858 858
 	 * @throws ConstraintParameterException
859 859
 	 */
860
-	private function parseUnitItem( ItemIdSnakValue $item ) {
861
-		switch ( true ) {
860
+	private function parseUnitItem(ItemIdSnakValue $item) {
861
+		switch (true) {
862 862
 			case $item->isValue():
863
-				$unit = $this->parseUnitParameter( $item->getItemId() );
863
+				$unit = $this->parseUnitParameter($item->getItemId());
864 864
 				return new UnitsParameter(
865
-					[ $item->getItemId() ],
866
-					[ UnboundedQuantityValue::newFromNumber( 1, $unit ) ],
865
+					[$item->getItemId()],
866
+					[UnboundedQuantityValue::newFromNumber(1, $unit)],
867 867
 					false
868 868
 				);
869 869
 			case $item->isSomeValue():
870
-				$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
870
+				$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
871 871
 				throw new ConstraintParameterException(
872
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
873
-						->withEntityId( new NumericPropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
872
+					(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
873
+						->withEntityId(new NumericPropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
874 874
 				);
875 875
 			case $item->isNoValue():
876
-				return new UnitsParameter( [], [], true );
876
+				return new UnitsParameter([], [], true);
877 877
 		}
878 878
 	}
879 879
 
@@ -883,36 +883,36 @@  discard block
 block discarded – undo
883 883
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
884 884
 	 * @return UnitsParameter
885 885
 	 */
886
-	public function parseUnitsParameter( array $constraintParameters, $constraintTypeItemId ) {
887
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
886
+	public function parseUnitsParameter(array $constraintParameters, $constraintTypeItemId) {
887
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
888 888
 		$unitItems = [];
889 889
 		$unitQuantities = [];
890 890
 		$unitlessAllowed = false;
891 891
 
892
-		foreach ( $items as $item ) {
893
-			$unit = $this->parseUnitItem( $item );
894
-			$unitItems = array_merge( $unitItems, $unit->getUnitItemIds() );
895
-			$unitQuantities = array_merge( $unitQuantities, $unit->getUnitQuantities() );
892
+		foreach ($items as $item) {
893
+			$unit = $this->parseUnitItem($item);
894
+			$unitItems = array_merge($unitItems, $unit->getUnitItemIds());
895
+			$unitQuantities = array_merge($unitQuantities, $unit->getUnitQuantities());
896 896
 			$unitlessAllowed = $unitlessAllowed || $unit->getUnitlessAllowed();
897 897
 		}
898 898
 
899
-		if ( $unitQuantities === [] && !$unitlessAllowed ) {
899
+		if ($unitQuantities === [] && !$unitlessAllowed) {
900 900
 			throw new LogicException(
901 901
 				'The "units" parameter is required, and yet we seem to be missing any allowed unit'
902 902
 			);
903 903
 		}
904 904
 
905
-		return new UnitsParameter( $unitItems, $unitQuantities, $unitlessAllowed );
905
+		return new UnitsParameter($unitItems, $unitQuantities, $unitlessAllowed);
906 906
 	}
907 907
 
908 908
 	private function getEntityTypeMapping(): array {
909 909
 		return [
910
-			$this->config->get( 'WBQualityConstraintsWikibaseItemId' ) => 'item',
911
-			$this->config->get( 'WBQualityConstraintsWikibasePropertyId' ) => 'property',
912
-			$this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ) => 'lexeme',
913
-			$this->config->get( 'WBQualityConstraintsWikibaseFormId' ) => 'form',
914
-			$this->config->get( 'WBQualityConstraintsWikibaseSenseId' ) => 'sense',
915
-			$this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ) => 'mediainfo',
910
+			$this->config->get('WBQualityConstraintsWikibaseItemId') => 'item',
911
+			$this->config->get('WBQualityConstraintsWikibasePropertyId') => 'property',
912
+			$this->config->get('WBQualityConstraintsWikibaseLexemeId') => 'lexeme',
913
+			$this->config->get('WBQualityConstraintsWikibaseFormId') => 'form',
914
+			$this->config->get('WBQualityConstraintsWikibaseSenseId') => 'sense',
915
+			$this->config->get('WBQualityConstraintsWikibaseMediaInfoId') => 'mediainfo',
916 916
 		];
917 917
 	}
918 918
 
@@ -922,10 +922,10 @@  discard block
 block discarded – undo
922 922
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
923 923
 	 * @return EntityTypesParameter
924 924
 	 */
925
-	public function parseEntityTypesParameter( array $constraintParameters, $constraintTypeItemId ) {
925
+	public function parseEntityTypesParameter(array $constraintParameters, $constraintTypeItemId) {
926 926
 		$entityTypes = [];
927 927
 		$entityTypeItemIds = [];
928
-		$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
928
+		$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
929 929
 		$itemIds = $this->parseItemIdsParameter(
930 930
 			$constraintParameters,
931 931
 			$constraintTypeItemId,
@@ -934,22 +934,22 @@  discard block
 block discarded – undo
934 934
 		);
935 935
 
936 936
 		$mapping = $this->getEntityTypeMapping();
937
-		foreach ( $itemIds as $itemId ) {
938
-			$entityType = $this->mapItemId( $itemId, $mapping, $parameterId );
937
+		foreach ($itemIds as $itemId) {
938
+			$entityType = $this->mapItemId($itemId, $mapping, $parameterId);
939 939
 			$entityTypes[] = $entityType;
940 940
 			$entityTypeItemIds[] = $itemId;
941 941
 		}
942 942
 
943
-		if ( empty( $entityTypes ) ) {
943
+		if (empty($entityTypes)) {
944 944
 			// @codeCoverageIgnoreStart
945 945
 			throw new LogicException(
946
-				'The "entity types" parameter is required, ' .
946
+				'The "entity types" parameter is required, '.
947 947
 				'and yet we seem to be missing any allowed entity type'
948 948
 			);
949 949
 			// @codeCoverageIgnoreEnd
950 950
 		}
951 951
 
952
-		return new EntityTypesParameter( $entityTypes, $entityTypeItemIds );
952
+		return new EntityTypesParameter($entityTypes, $entityTypeItemIds);
953 953
 	}
954 954
 
955 955
 	/**
@@ -957,18 +957,18 @@  discard block
 block discarded – undo
957 957
 	 * @throws ConstraintParameterException if the parameter is invalid
958 958
 	 * @return PropertyId[]
959 959
 	 */
960
-	public function parseSeparatorsParameter( array $constraintParameters ) {
961
-		$separatorId = $this->config->get( 'WBQualityConstraintsSeparatorId' );
960
+	public function parseSeparatorsParameter(array $constraintParameters) {
961
+		$separatorId = $this->config->get('WBQualityConstraintsSeparatorId');
962 962
 
963
-		if ( !array_key_exists( $separatorId, $constraintParameters ) ) {
963
+		if (!array_key_exists($separatorId, $constraintParameters)) {
964 964
 			return [];
965 965
 		}
966 966
 
967 967
 		$parameters = $constraintParameters[$separatorId];
968 968
 		$separators = [];
969 969
 
970
-		foreach ( $parameters as $parameter ) {
971
-			$separators[] = $this->parsePropertyIdParameter( $parameter, $separatorId );
970
+		foreach ($parameters as $parameter) {
971
+			$separators[] = $this->parsePropertyIdParameter($parameter, $separatorId);
972 972
 		}
973 973
 
974 974
 		return $separators;
@@ -976,17 +976,17 @@  discard block
 block discarded – undo
976 976
 
977 977
 	private function getConstraintScopeContextTypeMapping(): array {
978 978
 		return [
979
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' ) => Context::TYPE_STATEMENT,
980
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' ) => Context::TYPE_QUALIFIER,
981
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' ) => Context::TYPE_REFERENCE,
979
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId') => Context::TYPE_STATEMENT,
980
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId') => Context::TYPE_QUALIFIER,
981
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId') => Context::TYPE_REFERENCE,
982 982
 		];
983 983
 	}
984 984
 
985 985
 	private function getPropertyScopeContextTypeMapping(): array {
986 986
 		return [
987
-			$this->config->get( 'WBQualityConstraintsAsMainValueId' ) => Context::TYPE_STATEMENT,
988
-			$this->config->get( 'WBQualityConstraintsAsQualifiersId' ) => Context::TYPE_QUALIFIER,
989
-			$this->config->get( 'WBQualityConstraintsAsReferencesId' ) => Context::TYPE_REFERENCE,
987
+			$this->config->get('WBQualityConstraintsAsMainValueId') => Context::TYPE_STATEMENT,
988
+			$this->config->get('WBQualityConstraintsAsQualifiersId') => Context::TYPE_QUALIFIER,
989
+			$this->config->get('WBQualityConstraintsAsReferencesId') => Context::TYPE_REFERENCE,
990 990
 		];
991 991
 	}
992 992
 
@@ -996,9 +996,9 @@  discard block
 block discarded – undo
996 996
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
997 997
 	 * @return string[] list of Context::TYPE_* constants
998 998
 	 */
999
-	public function parsePropertyScopeParameter( array $constraintParameters, $constraintTypeItemId ) {
999
+	public function parsePropertyScopeParameter(array $constraintParameters, $constraintTypeItemId) {
1000 1000
 		$contextTypes = [];
1001
-		$parameterId = $this->config->get( 'WBQualityConstraintsPropertyScopeId' );
1001
+		$parameterId = $this->config->get('WBQualityConstraintsPropertyScopeId');
1002 1002
 		$itemIds = $this->parseItemIdsParameter(
1003 1003
 			$constraintParameters,
1004 1004
 			$constraintTypeItemId,
@@ -1007,14 +1007,14 @@  discard block
 block discarded – undo
1007 1007
 		);
1008 1008
 
1009 1009
 		$mapping = $this->getPropertyScopeContextTypeMapping();
1010
-		foreach ( $itemIds as $itemId ) {
1011
-			$contextTypes[] = $this->mapItemId( $itemId, $mapping, $parameterId );
1010
+		foreach ($itemIds as $itemId) {
1011
+			$contextTypes[] = $this->mapItemId($itemId, $mapping, $parameterId);
1012 1012
 		}
1013 1013
 
1014
-		if ( empty( $contextTypes ) ) {
1014
+		if (empty($contextTypes)) {
1015 1015
 			// @codeCoverageIgnoreStart
1016 1016
 			throw new LogicException(
1017
-				'The "property scope" parameter is required, ' .
1017
+				'The "property scope" parameter is required, '.
1018 1018
 				'and yet we seem to be missing any allowed scope'
1019 1019
 			);
1020 1020
 			// @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/DiffWithinRangeChecker.php 1 patch
Spacing   +41 added lines, -42 removed lines patch added patch discarded remove patch
@@ -73,8 +73,8 @@  discard block
 block discarded – undo
73 73
 	 * @throws ConstraintParameterException
74 74
 	 * @return array [ DataValue|null $min, DataValue|null $max, NumericPropertyId $property, array $parameters ]
75 75
 	 */
76
-	private function parseConstraintParameters( Constraint $constraint ) {
77
-		list( $min, $max ) = $this->constraintParameterParser->parseQuantityRangeParameter(
76
+	private function parseConstraintParameters(Constraint $constraint) {
77
+		list($min, $max) = $this->constraintParameterParser->parseQuantityRangeParameter(
78 78
 			$constraint->getConstraintParameters(),
79 79
 			$constraint->getConstraintTypeItemId()
80 80
 		);
@@ -84,15 +84,15 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 
86 86
 		$parameters = [];
87
-		if ( $min !== null ) {
88
-			$parameters['minimum_quantity'] = [ $min ];
87
+		if ($min !== null) {
88
+			$parameters['minimum_quantity'] = [$min];
89 89
 		}
90
-		if ( $max !== null ) {
91
-			$parameters['maximum_quantity'] = [ $max ];
90
+		if ($max !== null) {
91
+			$parameters['maximum_quantity'] = [$max];
92 92
 		}
93
-		$parameters['property'] = [ $property ];
93
+		$parameters['property'] = [$property];
94 94
 
95
-		return [ $min, $max, $property, $parameters ];
95
+		return [$min, $max, $property, $parameters];
96 96
 	}
97 97
 
98 98
 	/**
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @return bool
104 104
 	 */
105
-	private function rangeInYears( $min, $max ) {
106
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
105
+	private function rangeInYears($min, $max) {
106
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
107 107
 
108
-		if ( $min !== null && $min->getUnit() === $yearUnit ) {
108
+		if ($min !== null && $min->getUnit() === $yearUnit) {
109 109
 			return true;
110 110
 		}
111
-		if ( $max !== null && $max->getUnit() === $yearUnit ) {
111
+		if ($max !== null && $max->getUnit() === $yearUnit) {
112 112
 			return true;
113 113
 		}
114 114
 
@@ -124,30 +124,30 @@  discard block
 block discarded – undo
124 124
 	 * @throws ConstraintParameterException
125 125
 	 * @return CheckResult
126 126
 	 */
127
-	public function checkConstraint( Context $context, Constraint $constraint ) {
128
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
129
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
127
+	public function checkConstraint(Context $context, Constraint $constraint) {
128
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
129
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
130 130
 		}
131 131
 
132 132
 		$parameters = [];
133 133
 
134 134
 		$snak = $context->getSnak();
135 135
 
136
-		if ( !$snak instanceof PropertyValueSnak ) {
136
+		if (!$snak instanceof PropertyValueSnak) {
137 137
 			// nothing to check
138
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
138
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
139 139
 		}
140 140
 
141 141
 		$minuend = $snak->getDataValue();
142 142
 		'@phan-var \DataValues\TimeValue|\DataValues\QuantityValue|\DataValues\UnboundedQuantityValue $minuend';
143 143
 
144 144
 		/** @var NumericPropertyId $property */
145
-		list( $min, $max, $property, $parameters ) = $this->parseConstraintParameters( $constraint );
145
+		list($min, $max, $property, $parameters) = $this->parseConstraintParameters($constraint);
146 146
 
147 147
 		// checks only the first occurrence of the referenced property
148
-		foreach ( $context->getSnakGroup( Context::GROUP_NON_DEPRECATED ) as $otherSnak ) {
148
+		foreach ($context->getSnakGroup(Context::GROUP_NON_DEPRECATED) as $otherSnak) {
149 149
 			if (
150
-				!$property->equals( $otherSnak->getPropertyId() ) ||
150
+				!$property->equals($otherSnak->getPropertyId()) ||
151 151
 				!$otherSnak instanceof PropertyValueSnak
152 152
 			) {
153 153
 				continue;
@@ -155,30 +155,29 @@  discard block
 block discarded – undo
155 155
 
156 156
 			$subtrahend = $otherSnak->getDataValue();
157 157
 			'@phan-var \DataValues\TimeValue|\DataValues\QuantityValue|\DataValues\UnboundedQuantityValue $subtrahend';
158
-			if ( $subtrahend->getType() === $minuend->getType() ) {
159
-				$diff = $this->rangeInYears( $min, $max ) && $minuend->getType() === 'time' ?
160
-					$this->rangeCheckerHelper->getDifferenceInYears( $minuend, $subtrahend ) :
161
-					$this->rangeCheckerHelper->getDifference( $minuend, $subtrahend );
158
+			if ($subtrahend->getType() === $minuend->getType()) {
159
+				$diff = $this->rangeInYears($min, $max) && $minuend->getType() === 'time' ?
160
+					$this->rangeCheckerHelper->getDifferenceInYears($minuend, $subtrahend) : $this->rangeCheckerHelper->getDifference($minuend, $subtrahend);
162 161
 
163
-				if ( $this->rangeCheckerHelper->getComparison( $min, $diff ) > 0 ||
164
-					$this->rangeCheckerHelper->getComparison( $diff, $max ) > 0
162
+				if ($this->rangeCheckerHelper->getComparison($min, $diff) > 0 ||
163
+					$this->rangeCheckerHelper->getComparison($diff, $max) > 0
165 164
 				) {
166 165
 					// at least one of $min, $max is set at this point, otherwise there could be no violation
167
-					$openness = $min !== null ? ( $max !== null ? '' : '-rightopen' ) : '-leftopen';
166
+					$openness = $min !== null ? ($max !== null ? '' : '-rightopen') : '-leftopen';
168 167
 					// possible message keys:
169 168
 					// wbqc-violation-message-diff-within-range
170 169
 					// wbqc-violation-message-diff-within-range-leftopen
171 170
 					// wbqc-violation-message-diff-within-range-rightopen
172
-					$message = ( new ViolationMessage( "wbqc-violation-message-diff-within-range$openness" ) )
173
-						->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE )
174
-						->withDataValue( $minuend, Role::OBJECT )
175
-						->withEntityId( $otherSnak->getPropertyId(), Role::PREDICATE )
176
-						->withDataValue( $subtrahend, Role::OBJECT );
177
-					if ( $min !== null ) {
178
-						$message = $message->withDataValue( $min, Role::OBJECT );
171
+					$message = (new ViolationMessage("wbqc-violation-message-diff-within-range$openness"))
172
+						->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)
173
+						->withDataValue($minuend, Role::OBJECT)
174
+						->withEntityId($otherSnak->getPropertyId(), Role::PREDICATE)
175
+						->withDataValue($subtrahend, Role::OBJECT);
176
+					if ($min !== null) {
177
+						$message = $message->withDataValue($min, Role::OBJECT);
179 178
 					}
180
-					if ( $max !== null ) {
181
-						$message = $message->withDataValue( $max, Role::OBJECT );
179
+					if ($max !== null) {
180
+						$message = $message->withDataValue($max, Role::OBJECT);
182 181
 					}
183 182
 					$status = CheckResult::STATUS_VIOLATION;
184 183
 				} else {
@@ -186,17 +185,17 @@  discard block
 block discarded – undo
186 185
 					$status = CheckResult::STATUS_COMPLIANCE;
187 186
 				}
188 187
 			} else {
189
-				$message = new ViolationMessage( 'wbqc-violation-message-diff-within-range-must-have-equal-types' );
188
+				$message = new ViolationMessage('wbqc-violation-message-diff-within-range-must-have-equal-types');
190 189
 				$status = CheckResult::STATUS_VIOLATION;
191 190
 			}
192 191
 
193
-			return new CheckResult( $context, $constraint, $parameters, $status, $message );
192
+			return new CheckResult($context, $constraint, $parameters, $status, $message);
194 193
 		}
195 194
 
196
-		return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
195
+		return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
197 196
 	}
198 197
 
199
-	public function checkConstraintParameters( Constraint $constraint ) {
198
+	public function checkConstraintParameters(Constraint $constraint) {
200 199
 		$constraintParameters = $constraint->getConstraintParameters();
201 200
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
202 201
 		$exceptions = [];
@@ -205,7 +204,7 @@  discard block
 block discarded – undo
205 204
 				$constraintParameters,
206 205
 				$constraintTypeItemId
207 206
 			);
208
-		} catch ( ConstraintParameterException $e ) {
207
+		} catch (ConstraintParameterException $e) {
209 208
 			$exceptions[] = $e;
210 209
 		}
211 210
 		try {
@@ -213,7 +212,7 @@  discard block
 block discarded – undo
213 212
 				$constraintParameters,
214 213
 				$constraintTypeItemId
215 214
 			);
216
-		} catch ( ConstraintParameterException $e ) {
215
+		} catch (ConstraintParameterException $e) {
217 216
 			$exceptions[] = $e;
218 217
 		}
219 218
 		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 NumericPropertyId( $extremePropertyId ) );
201
+		foreach ($extremePropertyIds as $extremePropertyId) {
202
+			$statementList = new StatementList(...$statements);
203
+			$extremeStatements = $statementList->getByPropertyId(new NumericPropertyId($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/Result/NullResult.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,22 +25,22 @@
 block discarded – undo
25 25
 	 */
26 26
 	private const NULL_PROPERTY_ID = 'P2147483647';
27 27
 
28
-	public function __construct( ContextCursor $contextCursor ) {
28
+	public function __construct(ContextCursor $contextCursor) {
29 29
 		$constraint = new Constraint(
30 30
 			'null',
31
-			new NumericPropertyId( self::NULL_PROPERTY_ID ),
31
+			new NumericPropertyId(self::NULL_PROPERTY_ID),
32 32
 			'none',
33 33
 			[]
34 34
 		);
35
-		parent::__construct( $contextCursor, $constraint );
35
+		parent::__construct($contextCursor, $constraint);
36 36
 	}
37 37
 
38 38
 	public function getConstraint() {
39
-		throw new DomainException( 'NullResult holds no constraint' );
39
+		throw new DomainException('NullResult holds no constraint');
40 40
 	}
41 41
 
42 42
 	public function getConstraintId() {
43
-		throw new DomainException( 'NullResult holds no constraint' );
43
+		throw new DomainException('NullResult holds no constraint');
44 44
 	}
45 45
 
46 46
 }
Please login to merge, or discard this patch.
src/WikibaseQualityConstraintsHooks.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -28,27 +28,27 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @param DatabaseUpdater $updater
30 30
 	 */
31
-	public static function onCreateSchema( DatabaseUpdater $updater ) {
32
-		$dir = dirname( __DIR__ ) . '/sql/';
31
+	public static function onCreateSchema(DatabaseUpdater $updater) {
32
+		$dir = dirname(__DIR__).'/sql/';
33 33
 
34 34
 		$updater->addExtensionTable(
35 35
 			'wbqc_constraints',
36
-			$dir . "/{$updater->getDB()->getType()}/tables-generated.sql"
36
+			$dir."/{$updater->getDB()->getType()}/tables-generated.sql"
37 37
 		);
38 38
 		$updater->addExtensionField(
39 39
 			'wbqc_constraints',
40 40
 			'constraint_id',
41
-			$dir . '/patch-wbqc_constraints-constraint_id.sql'
41
+			$dir.'/patch-wbqc_constraints-constraint_id.sql'
42 42
 		);
43 43
 		$updater->addExtensionIndex(
44 44
 			'wbqc_constraints',
45 45
 			'wbqc_constraints_guid_uniq',
46
-			$dir . '/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql'
46
+			$dir.'/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql'
47 47
 		);
48 48
 	}
49 49
 
50
-	public static function onWikibaseChange( Change $change ) {
51
-		if ( !( $change instanceof EntityChange ) ) {
50
+	public static function onWikibaseChange(Change $change) {
51
+		if (!($change instanceof EntityChange)) {
52 52
 			return;
53 53
 		}
54 54
 
@@ -57,48 +57,48 @@  discard block
 block discarded – undo
57 57
 
58 58
 		// If jobs are enabled and the results would be stored in some way run a job.
59 59
 		if (
60
-			$config->get( 'WBQualityConstraintsEnableConstraintsCheckJobs' ) &&
61
-			$config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) &&
60
+			$config->get('WBQualityConstraintsEnableConstraintsCheckJobs') &&
61
+			$config->get('WBQualityConstraintsCacheCheckConstraintsResults') &&
62 62
 			self::isSelectedForJobRunBasedOnPercentage()
63 63
 		) {
64
-			$params = [ 'entityId' => $change->getEntityId()->getSerialization() ];
64
+			$params = ['entityId' => $change->getEntityId()->getSerialization()];
65 65
 			JobQueueGroup::singleton()->lazyPush(
66
-				new JobSpecification( CheckConstraintsJob::COMMAND, $params )
66
+				new JobSpecification(CheckConstraintsJob::COMMAND, $params)
67 67
 			);
68 68
 		}
69 69
 
70
-		if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) &&
71
-			self::isConstraintStatementsChange( $config, $change )
70
+		if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') &&
71
+			self::isConstraintStatementsChange($config, $change)
72 72
 		) {
73
-			$params = [ 'propertyId' => $change->getEntityId()->getSerialization() ];
73
+			$params = ['propertyId' => $change->getEntityId()->getSerialization()];
74 74
 			$metadata = $change->getMetadata();
75
-			if ( array_key_exists( 'rev_id', $metadata ) ) {
75
+			if (array_key_exists('rev_id', $metadata)) {
76 76
 				$params['revisionId'] = $metadata['rev_id'];
77 77
 			}
78 78
 			JobQueueGroup::singleton()->push(
79
-				new JobSpecification( 'constraintsTableUpdate', $params )
79
+				new JobSpecification('constraintsTableUpdate', $params)
80 80
 			);
81 81
 		}
82 82
 	}
83 83
 
84 84
 	private static function isSelectedForJobRunBasedOnPercentage() {
85 85
 		$config = MediaWikiServices::getInstance()->getMainConfig();
86
-		$percentage = $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobsRatio' );
86
+		$percentage = $config->get('WBQualityConstraintsEnableConstraintsCheckJobsRatio');
87 87
 
88
-		return mt_rand( 1, 100 ) <= $percentage;
88
+		return mt_rand(1, 100) <= $percentage;
89 89
 	}
90 90
 
91
-	public static function isConstraintStatementsChange( Config $config, Change $change ) {
92
-		if ( !( $change instanceof EntityChange ) ||
91
+	public static function isConstraintStatementsChange(Config $config, Change $change) {
92
+		if (!($change instanceof EntityChange) ||
93 93
 			 $change->getAction() !== EntityChange::UPDATE ||
94
-			 !( $change->getEntityId() instanceof NumericPropertyId )
94
+			 !($change->getEntityId() instanceof NumericPropertyId)
95 95
 		) {
96 96
 			return false;
97 97
 		}
98 98
 
99 99
 		$info = $change->getInfo();
100 100
 
101
-		if ( !array_key_exists( 'compactDiff', $info ) ) {
101
+		if (!array_key_exists('compactDiff', $info)) {
102 102
 			// the non-compact diff ($info['diff']) does not contain statement diffs (T110996),
103 103
 			// so we only know that the change *might* affect the constraint statements
104 104
 			return true;
@@ -107,43 +107,43 @@  discard block
 block discarded – undo
107 107
 		/** @var EntityDiffChangedAspects $aspects */
108 108
 		$aspects = $info['compactDiff'];
109 109
 
110
-		$propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' );
111
-		return in_array( $propertyConstraintId, $aspects->getStatementChanges() );
110
+		$propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId');
111
+		return in_array($propertyConstraintId, $aspects->getStatementChanges());
112 112
 	}
113 113
 
114
-	public static function onArticlePurge( WikiPage $wikiPage ) {
114
+	public static function onArticlePurge(WikiPage $wikiPage) {
115 115
 		$entityContentFactory = WikibaseRepo::getEntityContentFactory();
116
-		if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) {
116
+		if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) {
117 117
 			$entityIdLookup = WikibaseRepo::getEntityIdLookup();
118
-			$entityId = $entityIdLookup->getEntityIdForTitle( $wikiPage->getTitle() );
119
-			if ( $entityId !== null ) {
118
+			$entityId = $entityIdLookup->getEntityIdForTitle($wikiPage->getTitle());
119
+			if ($entityId !== null) {
120 120
 				$resultsCache = ResultsCache::getDefaultInstance();
121
-				$resultsCache->delete( $entityId );
121
+				$resultsCache->delete($entityId);
122 122
 			}
123 123
 		}
124 124
 	}
125 125
 
126
-	public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
126
+	public static function onBeforePageDisplay(OutputPage $out, Skin $skin) {
127 127
 		$lookup = WikibaseRepo::getEntityNamespaceLookup();
128 128
 		$title = $out->getTitle();
129
-		if ( $title === null ) {
129
+		if ($title === null) {
130 130
 			return;
131 131
 		}
132 132
 
133
-		if ( !$lookup->isNamespaceWithEntities( $title->getNamespace() ) ) {
133
+		if (!$lookup->isNamespaceWithEntities($title->getNamespace())) {
134 134
 			return;
135 135
 		}
136
-		if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) {
136
+		if (empty($out->getJsConfigVars()['wbIsEditView'])) {
137 137
 			return;
138 138
 		}
139 139
 
140
-		$out->addModules( 'wikibase.quality.constraints.suggestions' );
140
+		$out->addModules('wikibase.quality.constraints.suggestions');
141 141
 
142
-		if ( !$out->getUser()->isRegistered() ) {
142
+		if (!$out->getUser()->isRegistered()) {
143 143
 			return;
144 144
 		}
145 145
 
146
-		$out->addModules( 'wikibase.quality.constraints.gadget' );
146
+		$out->addModules('wikibase.quality.constraints.gadget');
147 147
 	}
148 148
 
149 149
 }
Please login to merge, or discard this patch.
src/ConstraintDeserializer.php 1 patch
Spacing   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,14 +10,13 @@
 block discarded – undo
10 10
  */
11 11
 class ConstraintDeserializer {
12 12
 
13
-	public function deserialize( array $serialization ) {
13
+	public function deserialize(array $serialization) {
14 14
 		return new Constraint(
15 15
 			$serialization['id'],
16
-			new NumericPropertyId( $serialization['pid'] ),
16
+			new NumericPropertyId($serialization['pid']),
17 17
 			$serialization['qid'],
18
-			array_key_exists( 'params', $serialization ) ?
19
-			$serialization['params'] :
20
-		[]
18
+			array_key_exists('params', $serialization) ?
19
+			$serialization['params'] : []
21 20
 			);
22 21
 	}
23 22
 
Please login to merge, or discard this patch.