Completed
Push — master ( 96730f...365b86 )
by
unknown
01:53
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( 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(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 PropertyId( $result->getContextCursor()->getSnakPropertyId() );
401
+		$propertyId = new PropertyId($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 PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ),
420
+			new PropertyId($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, PropertyId $propertyId, $text ) {
639
+	private function getClaimLink(EntityId $entityId, PropertyId $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, PropertyId $propertyId ) {
659
-		$title = $this->entityTitleLookup->getTitleForId( $entityId );
660
-		$entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() );
658
+	private function getClaimUrl(EntityId $entityId, PropertyId $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/ServiceWiring.php 1 patch
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -28,47 +28,47 @@  discard block
 block discarded – undo
28 28
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer;
29 29
 
30 30
 return [
31
-	ConstraintsServices::EXPIRY_LOCK => function ( MediaWikiServices $services ) {
32
-		return new ExpiryLock( ObjectCache::getInstance( CACHE_ANYTHING ) );
31
+	ConstraintsServices::EXPIRY_LOCK => function(MediaWikiServices $services) {
32
+		return new ExpiryLock(ObjectCache::getInstance(CACHE_ANYTHING));
33 33
 	},
34 34
 
35
-	ConstraintsServices::LOGGING_HELPER => function ( MediaWikiServices $services ) {
35
+	ConstraintsServices::LOGGING_HELPER => function(MediaWikiServices $services) {
36 36
 		return new LoggingHelper(
37 37
 			$services->getStatsdDataFactory(),
38
-			LoggerFactory::getInstance( 'WikibaseQualityConstraints' ),
38
+			LoggerFactory::getInstance('WikibaseQualityConstraints'),
39 39
 			$services->getMainConfig()
40 40
 		);
41 41
 	},
42 42
 
43
-	ConstraintsServices::CONSTRAINT_STORE => function ( MediaWikiServices $services ) {
43
+	ConstraintsServices::CONSTRAINT_STORE => function(MediaWikiServices $services) {
44 44
 		$wbRepo = WikibaseRepo::getDefaultInstance();
45 45
 		$sourceDefinitions = $wbRepo->getEntitySourceDefinitions();
46
-		$propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE );
46
+		$propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE);
47 47
 		$dbName = $propertySource->getDatabaseName();
48 48
 
49
-		if ( $propertySource->getSourceName() !== $wbRepo->getLocalEntitySource()->getSourceName() ) {
50
-			throw new \RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' );
49
+		if ($propertySource->getSourceName() !== $wbRepo->getLocalEntitySource()->getSourceName()) {
50
+			throw new \RuntimeException('Can\'t get a ConstraintStore for a non local entity source.');
51 51
 		}
52 52
 
53 53
 		return new ConstraintRepositoryStore(
54
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
54
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
55 55
 			$dbName
56 56
 		);
57 57
 	},
58 58
 
59
-	ConstraintsServices::CONSTRAINT_LOOKUP => function ( MediaWikiServices $services ) {
59
+	ConstraintsServices::CONSTRAINT_LOOKUP => function(MediaWikiServices $services) {
60 60
 		$wbRepo = WikibaseRepo::getDefaultInstance();
61 61
 		$sourceDefinitions = $wbRepo->getEntitySourceDefinitions();
62
-		$propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE );
62
+		$propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE);
63 63
 		$dbName = $propertySource->getDatabaseName();
64 64
 		$rawLookup = new ConstraintRepositoryLookup(
65
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
65
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
66 66
 			$dbName
67 67
 		);
68
-		return new CachingConstraintLookup( $rawLookup );
68
+		return new CachingConstraintLookup($rawLookup);
69 69
 	},
70 70
 
71
-	ConstraintsServices::CHECK_RESULT_SERIALIZER => function ( MediaWikiServices $services ) {
71
+	ConstraintsServices::CHECK_RESULT_SERIALIZER => function(MediaWikiServices $services) {
72 72
 		return new CheckResultSerializer(
73 73
 			new ConstraintSerializer(
74 74
 				false // constraint parameters are not exposed
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 		);
80 80
 	},
81 81
 
82
-	ConstraintsServices::CHECK_RESULT_DESERIALIZER => function ( MediaWikiServices $services ) {
82
+	ConstraintsServices::CHECK_RESULT_DESERIALIZER => function(MediaWikiServices $services) {
83 83
 		// TODO in the future, get DataValueFactory from $services?
84 84
 		$repo = WikibaseRepo::getDefaultInstance();
85
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
85
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
86 86
 		$dataValueFactory = $repo->getDataValueFactory();
87 87
 
88 88
 		return new CheckResultDeserializer(
@@ -96,14 +96,14 @@  discard block
 block discarded – undo
96 96
 		);
97 97
 	},
98 98
 
99
-	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function ( MediaWikiServices $services ) {
99
+	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function(MediaWikiServices $services) {
100 100
 		return new ViolationMessageSerializer();
101 101
 	},
102 102
 
103
-	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function ( MediaWikiServices $services ) {
103
+	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function(MediaWikiServices $services) {
104 104
 		// TODO in the future, get DataValueFactory from $services?
105 105
 		$repo = WikibaseRepo::getDefaultInstance();
106
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
106
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
107 107
 		$dataValueFactory = $repo->getDataValueFactory();
108 108
 
109 109
 		return new ViolationMessageDeserializer(
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		);
113 113
 	},
114 114
 
115
-	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function ( MediaWikiServices $services ) {
115
+	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) {
116 116
 		// TODO in the future, get DeserializerFactory and entity source definitions from $services?
117 117
 		$repo = WikibaseRepo::getDefaultInstance();
118 118
 		$deserializerFactory = $repo->getBaseDataModelDeserializerFactory();
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
 		return new ConstraintParameterParser(
122 122
 			$services->getMainConfig(),
123 123
 			$deserializerFactory,
124
-			$entitySourceDefinitions->getSourceForEntityType( 'item' )->getConceptBaseUri()
124
+			$entitySourceDefinitions->getSourceForEntityType('item')->getConceptBaseUri()
125 125
 		);
126 126
 	},
127 127
 
128
-	ConstraintsServices::CONNECTION_CHECKER_HELPER => function ( MediaWikiServices $services ) {
128
+	ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) {
129 129
 		return new ConnectionCheckerHelper();
130 130
 	},
131 131
 
132
-	ConstraintsServices::RANGE_CHECKER_HELPER => function ( MediaWikiServices $services ) {
132
+	ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) {
133 133
 		// TODO in the future, get UnitConverter from $services?
134 134
 		$repo = WikibaseRepo::getDefaultInstance();
135 135
 		$unitConverter = $repo->getUnitConverter();
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
 		);
141 141
 	},
142 142
 
143
-	ConstraintsServices::SPARQL_HELPER => function ( MediaWikiServices $services ) {
144
-		$endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' );
145
-		if ( $endpoint === '' ) {
143
+	ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) {
144
+		$endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint');
145
+		if ($endpoint === '') {
146 146
 			return new DummySparqlHelper();
147 147
 		}
148 148
 
149 149
 		// TODO in the future, get RDFVocabulary and PropertyDataTypeLookup from $services?
150 150
 		$repo = WikibaseRepo::getDefaultInstance();
151 151
 		$rdfVocabulary = $repo->getRdfVocabulary();
152
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
152
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
153 153
 		$propertyDataTypeLookup = $repo->getPropertyDataTypeLookup();
154 154
 
155 155
 		return new SparqlHelper(
@@ -158,122 +158,122 @@  discard block
 block discarded – undo
158 158
 			$entityIdParser,
159 159
 			$propertyDataTypeLookup,
160 160
 			$services->getMainWANObjectCache(),
161
-			ConstraintsServices::getViolationMessageSerializer( $services ),
162
-			ConstraintsServices::getViolationMessageDeserializer( $services ),
161
+			ConstraintsServices::getViolationMessageSerializer($services),
162
+			ConstraintsServices::getViolationMessageDeserializer($services),
163 163
 			$services->getStatsdDataFactory(),
164
-			ConstraintsServices::getExpiryLock( $services ),
164
+			ConstraintsServices::getExpiryLock($services),
165 165
 			ConstraintsServices::getLoggingHelper(),
166
-			wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(),
166
+			wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(),
167 167
 			$services->getHttpRequestFactory()
168 168
 		);
169 169
 	},
170 170
 
171
-	ConstraintsServices::TYPE_CHECKER_HELPER => function ( MediaWikiServices $services ) {
171
+	ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) {
172 172
 		return new TypeCheckerHelper(
173
-			WikibaseServices::getEntityLookup( $services ),
173
+			WikibaseServices::getEntityLookup($services),
174 174
 			$services->getMainConfig(),
175
-			ConstraintsServices::getSparqlHelper( $services ),
175
+			ConstraintsServices::getSparqlHelper($services),
176 176
 			$services->getStatsdDataFactory()
177 177
 		);
178 178
 	},
179 179
 
180
-	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function ( MediaWikiServices $services ) {
180
+	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) {
181 181
 		// TODO in the future, get StatementGuidParser from $services?
182 182
 		$repo = WikibaseRepo::getDefaultInstance();
183 183
 		$statementGuidParser = $repo->getStatementGuidParser();
184 184
 
185 185
 		$config = $services->getMainConfig();
186 186
 		$checkerMap = [
187
-			$config->get( 'WBQualityConstraintsConflictsWithConstraintId' )
188
-				=> ConstraintCheckerServices::getConflictsWithChecker( $services ),
189
-			$config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' )
190
-				=> ConstraintCheckerServices::getItemChecker( $services ),
191
-			$config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' )
192
-				=> ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ),
193
-			$config->get( 'WBQualityConstraintsSymmetricConstraintId' )
194
-				=> ConstraintCheckerServices::getSymmetricChecker( $services ),
195
-			$config->get( 'WBQualityConstraintsInverseConstraintId' )
196
-				=> ConstraintCheckerServices::getInverseChecker( $services ),
197
-			$config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' )
198
-				=> ConstraintCheckerServices::getQualifierChecker( $services ),
199
-			$config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' )
200
-				=> ConstraintCheckerServices::getQualifiersChecker( $services ),
201
-			$config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' )
202
-				=> ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ),
203
-			$config->get( 'WBQualityConstraintsRangeConstraintId' )
204
-				=> ConstraintCheckerServices::getRangeChecker( $services ),
205
-			$config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' )
206
-				=> ConstraintCheckerServices::getDiffWithinRangeChecker( $services ),
207
-			$config->get( 'WBQualityConstraintsTypeConstraintId' )
208
-				=> ConstraintCheckerServices::getTypeChecker( $services ),
209
-			$config->get( 'WBQualityConstraintsValueTypeConstraintId' )
210
-				=> ConstraintCheckerServices::getValueTypeChecker( $services ),
211
-			$config->get( 'WBQualityConstraintsSingleValueConstraintId' )
212
-				=> ConstraintCheckerServices::getSingleValueChecker( $services ),
213
-			$config->get( 'WBQualityConstraintsMultiValueConstraintId' )
214
-				=> ConstraintCheckerServices::getMultiValueChecker( $services ),
215
-			$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' )
216
-				=> ConstraintCheckerServices::getUniqueValueChecker( $services ),
217
-			$config->get( 'WBQualityConstraintsFormatConstraintId' )
218
-				=> ConstraintCheckerServices::getFormatChecker( $services ),
219
-			$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' )
220
-				=> ConstraintCheckerServices::getCommonsLinkChecker( $services ),
221
-			$config->get( 'WBQualityConstraintsOneOfConstraintId' )
222
-				=> ConstraintCheckerServices::getOneOfChecker( $services ),
223
-			$config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' )
224
-				=> ConstraintCheckerServices::getValueOnlyChecker( $services ),
225
-			$config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' )
226
-				=> ConstraintCheckerServices::getReferenceChecker( $services ),
227
-			$config->get( 'WBQualityConstraintsNoBoundsConstraintId' )
228
-				=> ConstraintCheckerServices::getNoBoundsChecker( $services ),
229
-			$config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' )
230
-				=> ConstraintCheckerServices::getAllowedUnitsChecker( $services ),
231
-			$config->get( 'WBQualityConstraintsSingleBestValueConstraintId' )
232
-				=> ConstraintCheckerServices::getSingleBestValueChecker( $services ),
233
-			$config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' )
234
-				=> ConstraintCheckerServices::getEntityTypeChecker( $services ),
235
-			$config->get( 'WBQualityConstraintsNoneOfConstraintId' )
236
-				=> ConstraintCheckerServices::getNoneOfChecker( $services ),
237
-			$config->get( 'WBQualityConstraintsIntegerConstraintId' )
238
-				=> ConstraintCheckerServices::getIntegerChecker( $services ),
239
-			$config->get( 'WBQualityConstraintsCitationNeededConstraintId' )
240
-				=> ConstraintCheckerServices::getCitationNeededChecker( $services ),
241
-			$config->get( 'WBQualityConstraintsPropertyScopeConstraintId' )
242
-				=> ConstraintCheckerServices::getPropertyScopeChecker( $services ),
243
-			$config->get( 'WBQualityConstraintsContemporaryConstraintId' )
244
-				=> ConstraintCheckerServices::getContemporaryChecker( $services ),
187
+			$config->get('WBQualityConstraintsConflictsWithConstraintId')
188
+				=> ConstraintCheckerServices::getConflictsWithChecker($services),
189
+			$config->get('WBQualityConstraintsItemRequiresClaimConstraintId')
190
+				=> ConstraintCheckerServices::getItemChecker($services),
191
+			$config->get('WBQualityConstraintsValueRequiresClaimConstraintId')
192
+				=> ConstraintCheckerServices::getTargetRequiredClaimChecker($services),
193
+			$config->get('WBQualityConstraintsSymmetricConstraintId')
194
+				=> ConstraintCheckerServices::getSymmetricChecker($services),
195
+			$config->get('WBQualityConstraintsInverseConstraintId')
196
+				=> ConstraintCheckerServices::getInverseChecker($services),
197
+			$config->get('WBQualityConstraintsUsedAsQualifierConstraintId')
198
+				=> ConstraintCheckerServices::getQualifierChecker($services),
199
+			$config->get('WBQualityConstraintsAllowedQualifiersConstraintId')
200
+				=> ConstraintCheckerServices::getQualifiersChecker($services),
201
+			$config->get('WBQualityConstraintsMandatoryQualifierConstraintId')
202
+				=> ConstraintCheckerServices::getMandatoryQualifiersChecker($services),
203
+			$config->get('WBQualityConstraintsRangeConstraintId')
204
+				=> ConstraintCheckerServices::getRangeChecker($services),
205
+			$config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId')
206
+				=> ConstraintCheckerServices::getDiffWithinRangeChecker($services),
207
+			$config->get('WBQualityConstraintsTypeConstraintId')
208
+				=> ConstraintCheckerServices::getTypeChecker($services),
209
+			$config->get('WBQualityConstraintsValueTypeConstraintId')
210
+				=> ConstraintCheckerServices::getValueTypeChecker($services),
211
+			$config->get('WBQualityConstraintsSingleValueConstraintId')
212
+				=> ConstraintCheckerServices::getSingleValueChecker($services),
213
+			$config->get('WBQualityConstraintsMultiValueConstraintId')
214
+				=> ConstraintCheckerServices::getMultiValueChecker($services),
215
+			$config->get('WBQualityConstraintsDistinctValuesConstraintId')
216
+				=> ConstraintCheckerServices::getUniqueValueChecker($services),
217
+			$config->get('WBQualityConstraintsFormatConstraintId')
218
+				=> ConstraintCheckerServices::getFormatChecker($services),
219
+			$config->get('WBQualityConstraintsCommonsLinkConstraintId')
220
+				=> ConstraintCheckerServices::getCommonsLinkChecker($services),
221
+			$config->get('WBQualityConstraintsOneOfConstraintId')
222
+				=> ConstraintCheckerServices::getOneOfChecker($services),
223
+			$config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId')
224
+				=> ConstraintCheckerServices::getValueOnlyChecker($services),
225
+			$config->get('WBQualityConstraintsUsedAsReferenceConstraintId')
226
+				=> ConstraintCheckerServices::getReferenceChecker($services),
227
+			$config->get('WBQualityConstraintsNoBoundsConstraintId')
228
+				=> ConstraintCheckerServices::getNoBoundsChecker($services),
229
+			$config->get('WBQualityConstraintsAllowedUnitsConstraintId')
230
+				=> ConstraintCheckerServices::getAllowedUnitsChecker($services),
231
+			$config->get('WBQualityConstraintsSingleBestValueConstraintId')
232
+				=> ConstraintCheckerServices::getSingleBestValueChecker($services),
233
+			$config->get('WBQualityConstraintsAllowedEntityTypesConstraintId')
234
+				=> ConstraintCheckerServices::getEntityTypeChecker($services),
235
+			$config->get('WBQualityConstraintsNoneOfConstraintId')
236
+				=> ConstraintCheckerServices::getNoneOfChecker($services),
237
+			$config->get('WBQualityConstraintsIntegerConstraintId')
238
+				=> ConstraintCheckerServices::getIntegerChecker($services),
239
+			$config->get('WBQualityConstraintsCitationNeededConstraintId')
240
+				=> ConstraintCheckerServices::getCitationNeededChecker($services),
241
+			$config->get('WBQualityConstraintsPropertyScopeConstraintId')
242
+				=> ConstraintCheckerServices::getPropertyScopeChecker($services),
243
+			$config->get('WBQualityConstraintsContemporaryConstraintId')
244
+				=> ConstraintCheckerServices::getContemporaryChecker($services),
245 245
 		];
246 246
 
247 247
 		return new DelegatingConstraintChecker(
248
-			WikibaseServices::getEntityLookup( $services ),
248
+			WikibaseServices::getEntityLookup($services),
249 249
 			$checkerMap,
250
-			ConstraintsServices::getConstraintLookup( $services ),
251
-			ConstraintsServices::getConstraintParameterParser( $services ),
250
+			ConstraintsServices::getConstraintLookup($services),
251
+			ConstraintsServices::getConstraintParameterParser($services),
252 252
 			$statementGuidParser,
253
-			ConstraintsServices::getLoggingHelper( $services ),
254
-			$config->get( 'WBQualityConstraintsCheckQualifiers' ),
255
-			$config->get( 'WBQualityConstraintsCheckReferences' ),
256
-			$config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' )
253
+			ConstraintsServices::getLoggingHelper($services),
254
+			$config->get('WBQualityConstraintsCheckQualifiers'),
255
+			$config->get('WBQualityConstraintsCheckReferences'),
256
+			$config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers')
257 257
 		);
258 258
 	},
259 259
 
260
-	ConstraintsServices::RESULTS_SOURCE => function ( MediaWikiServices $services ) {
260
+	ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) {
261 261
 		$config = $services->getMainConfig();
262 262
 		$resultsSource = new CheckingResultsSource(
263
-			ConstraintsServices::getDelegatingConstraintChecker( $services )
263
+			ConstraintsServices::getDelegatingConstraintChecker($services)
264 264
 		);
265 265
 
266 266
 		$cacheCheckConstraintsResults = false;
267 267
 
268
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
268
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
269 269
 			$cacheCheckConstraintsResults = true;
270 270
 			// check that we can use getLocalRepoWikiPageMetaDataAccessor()
271 271
 			// TODO we should always be able to cache constraint check results (T244726)
272 272
 			$repo = WikibaseRepo::getDefaultInstance();
273
-			foreach ( $repo->getEntitySourceDefinitions()->getSources() as $entitySource ) {
274
-				if ( $entitySource->getSourceName() !== $repo->getLocalEntitySource()->getSourceName() ) {
275
-					LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning(
276
-						'Cannot cache constraint check results for non-local source: ' .
273
+			foreach ($repo->getEntitySourceDefinitions()->getSources() as $entitySource) {
274
+				if ($entitySource->getSourceName() !== $repo->getLocalEntitySource()->getSourceName()) {
275
+					LoggerFactory::getInstance('WikibaseQualityConstraints')->warning(
276
+						'Cannot cache constraint check results for non-local source: '.
277 277
 						$entitySource->getSourceName()
278 278
 					);
279 279
 					$cacheCheckConstraintsResults = false;
@@ -282,29 +282,29 @@  discard block
 block discarded – undo
282 282
 			}
283 283
 		}
284 284
 
285
-		if ( $cacheCheckConstraintsResults ) {
285
+		if ($cacheCheckConstraintsResults) {
286 286
 			$possiblyStaleConstraintTypes = [
287
-				$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
288
-				$config->get( 'WBQualityConstraintsTypeConstraintId' ),
289
-				$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
290
-				$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
287
+				$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
288
+				$config->get('WBQualityConstraintsTypeConstraintId'),
289
+				$config->get('WBQualityConstraintsValueTypeConstraintId'),
290
+				$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
291 291
 			];
292 292
 			// TODO in the future, get WikiPageEntityMetaDataAccessor from $services?
293 293
 			$repo = WikibaseRepo::getDefaultInstance();
294
-			$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
294
+			$entityIdParser = WikibaseRepo::getEntityIdParser($services);
295 295
 			$wikiPageEntityMetaDataAccessor = $repo->getLocalRepoWikiPageMetaDataAccessor();
296 296
 
297 297
 			$resultsSource = new CachingResultsSource(
298 298
 				$resultsSource,
299 299
 				ResultsCache::getDefaultInstance(),
300
-				ConstraintsServices::getCheckResultSerializer( $services ),
301
-				ConstraintsServices::getCheckResultDeserializer( $services ),
300
+				ConstraintsServices::getCheckResultSerializer($services),
301
+				ConstraintsServices::getCheckResultDeserializer($services),
302 302
 				$wikiPageEntityMetaDataAccessor,
303 303
 				$entityIdParser,
304
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
304
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
305 305
 				$possiblyStaleConstraintTypes,
306
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ),
307
-				ConstraintsServices::getLoggingHelper( $services )
306
+				$config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'),
307
+				ConstraintsServices::getLoggingHelper($services)
308 308
 			);
309 309
 		}
310 310
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/TypeChecker.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
76 76
 	 * @return CheckResult
77 77
 	 */
78
-	public function checkConstraint( Context $context, Constraint $constraint ) {
79
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
80
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
78
+	public function checkConstraint(Context $context, Constraint $constraint) {
79
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
80
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
81 81
 		}
82
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
83
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE );
82
+		if ($context->getType() === Context::TYPE_REFERENCE) {
83
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE);
84 84
 		}
85 85
 
86 86
 		$parameters = [];
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 			$constraintTypeItemId
93 93
 		);
94 94
 		$parameters['class'] = array_map(
95
-			function ( $id ) {
96
-				return new ItemId( $id );
95
+			function($id) {
96
+				return new ItemId($id);
97 97
 			},
98 98
 			$classes
99 99
 		);
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 			$constraintTypeItemId
104 104
 		);
105 105
 		$relationIds = [];
106
-		if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) {
107
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
106
+		if ($relation === 'instance' || $relation === 'instanceOrSubclass') {
107
+			$relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId');
108 108
 		}
109
-		if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) {
110
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
109
+		if ($relation === 'subclass' || $relation === 'instanceOrSubclass') {
110
+			$relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId');
111 111
 		}
112
-		$parameters['relation'] = [ $relation ];
112
+		$parameters['relation'] = [$relation];
113 113
 
114 114
 		$result = $this->typeCheckerHelper->hasClassInRelation(
115 115
 			$context->getEntity()->getStatements(),
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			$classes
118 118
 		);
119 119
 
120
-		if ( $result->getBool() ) {
120
+		if ($result->getBool()) {
121 121
 			$message = null;
122 122
 			$status = CheckResult::STATUS_COMPLIANCE;
123 123
 		} else {
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 			$status = CheckResult::STATUS_VIOLATION;
132 132
 		}
133 133
 
134
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
135
-			->withMetadata( $result->getMetadata() );
134
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
135
+			->withMetadata($result->getMetadata());
136 136
 	}
137 137
 
138
-	public function checkConstraintParameters( Constraint $constraint ) {
138
+	public function checkConstraintParameters(Constraint $constraint) {
139 139
 		$constraintParameters = $constraint->getConstraintParameters();
140 140
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
141 141
 		$exceptions = [];
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 				$constraintParameters,
145 145
 				$constraintTypeItemId
146 146
 			);
147
-		} catch ( ConstraintParameterException $e ) {
147
+		} catch (ConstraintParameterException $e) {
148 148
 			$exceptions[] = $e;
149 149
 		}
150 150
 		try {
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 				$constraintParameters,
153 153
 				$constraintTypeItemId
154 154
 			);
155
-		} catch ( ConstraintParameterException $e ) {
155
+		} catch (ConstraintParameterException $e) {
156 156
 			$exceptions[] = $e;
157 157
 		}
158 158
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ValueTypeChecker.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
92 92
 	 * @return CheckResult
93 93
 	 */
94
-	public function checkConstraint( Context $context, Constraint $constraint ) {
95
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
96
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
94
+	public function checkConstraint(Context $context, Constraint $constraint) {
95
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
96
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
97 97
 		}
98 98
 
99 99
 		$parameters = [];
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 			$constraintTypeItemId
106 106
 		);
107 107
 		$parameters['class'] = array_map(
108
-			function ( $id ) {
109
-				return new ItemId( $id );
108
+			function($id) {
109
+				return new ItemId($id);
110 110
 			},
111 111
 			$classes
112 112
 		);
@@ -116,19 +116,19 @@  discard block
 block discarded – undo
116 116
 			$constraintTypeItemId
117 117
 		);
118 118
 		$relationIds = [];
119
-		if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) {
120
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
119
+		if ($relation === 'instance' || $relation === 'instanceOrSubclass') {
120
+			$relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId');
121 121
 		}
122
-		if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) {
123
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
122
+		if ($relation === 'subclass' || $relation === 'instanceOrSubclass') {
123
+			$relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId');
124 124
 		}
125
-		$parameters['relation'] = [ $relation ];
125
+		$parameters['relation'] = [$relation];
126 126
 
127 127
 		$snak = $context->getSnak();
128 128
 
129
-		if ( !$snak instanceof PropertyValueSnak ) {
129
+		if (!$snak instanceof PropertyValueSnak) {
130 130
 			// nothing to check
131
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
131
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
132 132
 		}
133 133
 
134 134
 		$dataValue = $snak->getDataValue();
@@ -137,23 +137,23 @@  discard block
 block discarded – undo
137 137
 		 * error handling:
138 138
 		 *   type of $dataValue for properties with 'Value type' constraint has to be 'wikibase-entityid'
139 139
 		 */
140
-		if ( !$dataValue instanceof EntityIdValue ) {
141
-			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
142
-				->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
143
-				->withDataValueType( 'wikibase-entityid' );
144
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
140
+		if (!$dataValue instanceof EntityIdValue) {
141
+			$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type'))
142
+				->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
143
+				->withDataValueType('wikibase-entityid');
144
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
145 145
 		}
146 146
 
147 147
 		try {
148
-			$item = $this->entityLookup->getEntity( $dataValue->getEntityId() );
149
-		} catch ( UnresolvedEntityRedirectException $e ) {
148
+			$item = $this->entityLookup->getEntity($dataValue->getEntityId());
149
+		} catch (UnresolvedEntityRedirectException $e) {
150 150
 			// Edge case (double redirect): Pretend the entity doesn't exist
151 151
 			$item = null;
152 152
 		}
153 153
 
154
-		if ( !( $item instanceof StatementListProvidingEntity ) ) {
155
-			$message = new ViolationMessage( 'wbqc-violation-message-value-entity-must-exist' );
156
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
154
+		if (!($item instanceof StatementListProvidingEntity)) {
155
+			$message = new ViolationMessage('wbqc-violation-message-value-entity-must-exist');
156
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
157 157
 		}
158 158
 
159 159
 		$statements = $item->getStatements();
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			$classes
165 165
 		);
166 166
 
167
-		if ( $result->getBool() ) {
167
+		if ($result->getBool()) {
168 168
 			$message = null;
169 169
 			$status = CheckResult::STATUS_COMPLIANCE;
170 170
 		} else {
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 			$status = CheckResult::STATUS_VIOLATION;
179 179
 		}
180 180
 
181
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
182
-			->withMetadata( $result->getMetadata() );
181
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
182
+			->withMetadata($result->getMetadata());
183 183
 	}
184 184
 
185
-	public function checkConstraintParameters( Constraint $constraint ) {
185
+	public function checkConstraintParameters(Constraint $constraint) {
186 186
 		$constraintParameters = $constraint->getConstraintParameters();
187 187
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
188 188
 		$exceptions = [];
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 				$constraintParameters,
192 192
 				$constraintTypeItemId
193 193
 			);
194
-		} catch ( ConstraintParameterException $e ) {
194
+		} catch (ConstraintParameterException $e) {
195 195
 			$exceptions[] = $e;
196 196
 		}
197 197
 		try {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				$constraintParameters,
200 200
 				$constraintTypeItemId
201 201
 			);
202
-		} catch ( ConstraintParameterException $e ) {
202
+		} catch (ConstraintParameterException $e) {
203 203
 			$exceptions[] = $e;
204 204
 		}
205 205
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/SparqlHelper.php 1 patch
Spacing   +175 added lines, -178 removed lines patch added patch discarded remove patch
@@ -163,58 +163,58 @@  discard block
 block discarded – undo
163 163
 		$this->defaultUserAgent = $defaultUserAgent;
164 164
 		$this->requestFactory = $requestFactory;
165 165
 		$this->entityPrefixes = [];
166
-		foreach ( $rdfVocabulary->entityNamespaceNames as $namespaceName ) {
167
-			$this->entityPrefixes[] = $rdfVocabulary->getNamespaceURI( $namespaceName );
166
+		foreach ($rdfVocabulary->entityNamespaceNames as $namespaceName) {
167
+			$this->entityPrefixes[] = $rdfVocabulary->getNamespaceURI($namespaceName);
168 168
 		}
169 169
 
170
-		$this->prefixes = $this->getQueryPrefixes( $rdfVocabulary );
170
+		$this->prefixes = $this->getQueryPrefixes($rdfVocabulary);
171 171
 	}
172 172
 
173
-	private function getQueryPrefixes( RdfVocabulary $rdfVocabulary ) {
173
+	private function getQueryPrefixes(RdfVocabulary $rdfVocabulary) {
174 174
 		// TODO: it would probably be smarter that RdfVocubulary exposed these prefixes somehow
175 175
 		$prefixes = '';
176
-		foreach ( $rdfVocabulary->entityNamespaceNames as $sourceName => $namespaceName ) {
176
+		foreach ($rdfVocabulary->entityNamespaceNames as $sourceName => $namespaceName) {
177 177
 			$prefixes .= <<<END
178
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
178
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
179 179
 END;
180 180
 		}
181 181
 		$prefixes .= <<<END
182
-PREFIX wds: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_STATEMENT )}>
183
-PREFIX wdv: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_VALUE )}>\n
182
+PREFIX wds: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_STATEMENT)}>
183
+PREFIX wdv: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_VALUE)}>\n
184 184
 END;
185 185
 
186
-		foreach ( $rdfVocabulary->propertyNamespaceNames as $sourceName => $sourceNamespaces ) {
186
+		foreach ($rdfVocabulary->propertyNamespaceNames as $sourceName => $sourceNamespaces) {
187 187
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_DIRECT_CLAIM];
188 188
 			$prefixes .= <<<END
189
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
189
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
190 190
 END;
191 191
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM];
192 192
 			$prefixes .= <<<END
193
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
193
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
194 194
 END;
195 195
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM_STATEMENT];
196 196
 			$prefixes .= <<<END
197
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
197
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
198 198
 END;
199 199
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_QUALIFIER];
200 200
 			$prefixes .= <<<END
201
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
201
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
202 202
 END;
203 203
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_QUALIFIER_VALUE];
204 204
 			$prefixes .= <<<END
205
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
205
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
206 206
 END;
207 207
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_REFERENCE];
208 208
 			$prefixes .= <<<END
209
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
209
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
210 210
 END;
211 211
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_REFERENCE_VALUE];
212 212
 			$prefixes .= <<<END
213
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
213
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
214 214
 END;
215 215
 		}
216 216
 		$prefixes .= <<<END
217
-PREFIX wikibase: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_ONTOLOGY )}>\n
217
+PREFIX wikibase: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_ONTOLOGY)}>\n
218 218
 END;
219 219
 		return $prefixes;
220 220
 	}
@@ -226,22 +226,21 @@  discard block
 block discarded – undo
226 226
 	 * @return CachedBool
227 227
 	 * @throws SparqlHelperException if the query times out or some other error occurs
228 228
 	 */
229
-	public function hasType( $id, array $classes ) {
230
-		$subclassOfId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
229
+	public function hasType($id, array $classes) {
230
+		$subclassOfId = $this->config->get('WBQualityConstraintsSubclassOfId');
231 231
 		// TODO hint:gearing is a workaround for T168973 and can hopefully be removed eventually
232
-		$gearingHint = $this->config->get( 'WBQualityConstraintsSparqlHasWikibaseSupport' ) ?
233
-			' hint:Prior hint:gearing "forward".' :
234
-			'';
232
+		$gearingHint = $this->config->get('WBQualityConstraintsSparqlHasWikibaseSupport') ?
233
+			' hint:Prior hint:gearing "forward".' : '';
235 234
 
236 235
 		$metadatas = [];
237 236
 
238
-		foreach ( array_chunk( $classes, 20 ) as $classesChunk ) {
239
-			$classesValues = implode( ' ', array_map(
240
-				function ( $class ) {
241
-					return 'wd:' . $class;
237
+		foreach (array_chunk($classes, 20) as $classesChunk) {
238
+			$classesValues = implode(' ', array_map(
239
+				function($class) {
240
+					return 'wd:'.$class;
242 241
 				},
243 242
 				$classesChunk
244
-			) );
243
+			));
245 244
 
246 245
 			$query = <<<EOF
247 246
 ASK {
@@ -251,19 +250,19 @@  discard block
 block discarded – undo
251 250
 }
252 251
 EOF;
253 252
 
254
-			$result = $this->runQuery( $query );
253
+			$result = $this->runQuery($query);
255 254
 			$metadatas[] = $result->getMetadata();
256
-			if ( $result->getArray()['boolean'] ) {
255
+			if ($result->getArray()['boolean']) {
257 256
 				return new CachedBool(
258 257
 					true,
259
-					Metadata::merge( $metadatas )
258
+					Metadata::merge($metadatas)
260 259
 				);
261 260
 			}
262 261
 		}
263 262
 
264 263
 		return new CachedBool(
265 264
 			false,
266
-			Metadata::merge( $metadatas )
265
+			Metadata::merge($metadatas)
267 266
 		);
268 267
 	}
269 268
 
@@ -279,10 +278,10 @@  discard block
 block discarded – undo
279 278
 		$ignoreDeprecatedStatements
280 279
 	) {
281 280
 		$pid = $statement->getPropertyId()->serialize();
282
-		$guid = str_replace( '$', '-', $statement->getGuid() );
281
+		$guid = str_replace('$', '-', $statement->getGuid());
283 282
 
284 283
 		$deprecatedFilter = '';
285
-		if ( $ignoreDeprecatedStatements ) {
284
+		if ($ignoreDeprecatedStatements) {
286 285
 			$deprecatedFilter = 'MINUS { ?otherStatement wikibase:rank wikibase:DeprecatedRank. }';
287 286
 		}
288 287
 
@@ -301,9 +300,9 @@  discard block
 block discarded – undo
301 300
 LIMIT 10
302 301
 EOF;
303 302
 
304
-		$result = $this->runQuery( $query );
303
+		$result = $this->runQuery($query);
305 304
 
306
-		return $this->getOtherEntities( $result );
305
+		return $this->getOtherEntities($result);
307 306
 	}
308 307
 
309 308
 	/**
@@ -328,16 +327,15 @@  discard block
 block discarded – undo
328 327
 		$dataType = $this->propertyDataTypeLookup->getDataTypeIdForProperty(
329 328
 			$snak->getPropertyId()
330 329
 		);
331
-		list( $value, $isFullValue ) = $this->getRdfLiteral( $dataType, $dataValue );
332
-		if ( $isFullValue ) {
330
+		list($value, $isFullValue) = $this->getRdfLiteral($dataType, $dataValue);
331
+		if ($isFullValue) {
333 332
 			$prefix .= 'v';
334 333
 		}
335 334
 		$path = $type === Context::TYPE_QUALIFIER ?
336
-			"$prefix:$pid" :
337
-			"prov:wasDerivedFrom/$prefix:$pid";
335
+			"$prefix:$pid" : "prov:wasDerivedFrom/$prefix:$pid";
338 336
 
339 337
 		$deprecatedFilter = '';
340
-		if ( $ignoreDeprecatedStatements ) {
338
+		if ($ignoreDeprecatedStatements) {
341 339
 			$deprecatedFilter = <<< EOF
342 340
   MINUS { ?otherStatement wikibase:rank wikibase:DeprecatedRank. }
343 341
 EOF;
@@ -357,9 +355,9 @@  discard block
 block discarded – undo
357 355
 LIMIT 10
358 356
 EOF;
359 357
 
360
-		$result = $this->runQuery( $query );
358
+		$result = $this->runQuery($query);
361 359
 
362
-		return $this->getOtherEntities( $result );
360
+		return $this->getOtherEntities($result);
363 361
 	}
364 362
 
365 363
 	/**
@@ -369,8 +367,8 @@  discard block
 block discarded – undo
369 367
 	 *
370 368
 	 * @return string
371 369
 	 */
372
-	private function stringLiteral( $text ) {
373
-		return '"' . strtr( $text, [ '"' => '\\"', '\\' => '\\\\' ] ) . '"';
370
+	private function stringLiteral($text) {
371
+		return '"'.strtr($text, ['"' => '\\"', '\\' => '\\\\']).'"';
374 372
 	}
375 373
 
376 374
 	/**
@@ -380,18 +378,18 @@  discard block
 block discarded – undo
380 378
 	 *
381 379
 	 * @return CachedEntityIds
382 380
 	 */
383
-	private function getOtherEntities( CachedQueryResults $results ) {
384
-		return new CachedEntityIds( array_map(
385
-			function ( $resultBindings ) {
381
+	private function getOtherEntities(CachedQueryResults $results) {
382
+		return new CachedEntityIds(array_map(
383
+			function($resultBindings) {
386 384
 				$entityIRI = $resultBindings['otherEntity']['value'];
387
-				foreach ( $this->entityPrefixes as $entityPrefix ) {
388
-					$entityPrefixLength = strlen( $entityPrefix );
389
-					if ( substr( $entityIRI, 0, $entityPrefixLength ) === $entityPrefix ) {
385
+				foreach ($this->entityPrefixes as $entityPrefix) {
386
+					$entityPrefixLength = strlen($entityPrefix);
387
+					if (substr($entityIRI, 0, $entityPrefixLength) === $entityPrefix) {
390 388
 						try {
391 389
 							return $this->entityIdParser->parse(
392
-								substr( $entityIRI, $entityPrefixLength )
390
+								substr($entityIRI, $entityPrefixLength)
393 391
 							);
394
-						} catch ( EntityIdParsingException $e ) {
392
+						} catch (EntityIdParsingException $e) {
395 393
 							// fall through
396 394
 						}
397 395
 					}
@@ -402,7 +400,7 @@  discard block
 block discarded – undo
402 400
 				return null;
403 401
 			},
404 402
 			$results->getArray()['results']['bindings']
405
-		), $results->getMetadata() );
403
+		), $results->getMetadata());
406 404
 	}
407 405
 
408 406
 	// @codingStandardsIgnoreStart cyclomatic complexity of this function is too high
@@ -415,49 +413,49 @@  discard block
 block discarded – undo
415 413
 	 * @return array the literal or IRI as a string in SPARQL syntax,
416 414
 	 * and a boolean indicating whether it refers to a full value node or not
417 415
 	 */
418
-	private function getRdfLiteral( $dataType, DataValue $dataValue ) {
419
-		switch ( $dataType ) {
416
+	private function getRdfLiteral($dataType, DataValue $dataValue) {
417
+		switch ($dataType) {
420 418
 			case 'string':
421 419
 			case 'external-id':
422
-				return [ $this->stringLiteral( $dataValue->getValue() ), false ];
420
+				return [$this->stringLiteral($dataValue->getValue()), false];
423 421
 			case 'commonsMedia':
424
-				$url = $this->rdfVocabulary->getMediaFileURI( $dataValue->getValue() );
425
-				return [ '<' . $url . '>', false ];
422
+				$url = $this->rdfVocabulary->getMediaFileURI($dataValue->getValue());
423
+				return ['<'.$url.'>', false];
426 424
 			case 'geo-shape':
427
-				$url = $this->rdfVocabulary->getGeoShapeURI( $dataValue->getValue() );
428
-				return [ '<' . $url . '>', false ];
425
+				$url = $this->rdfVocabulary->getGeoShapeURI($dataValue->getValue());
426
+				return ['<'.$url.'>', false];
429 427
 			case 'tabular-data':
430
-				$url = $this->rdfVocabulary->getTabularDataURI( $dataValue->getValue() );
431
-				return [ '<' . $url . '>', false ];
428
+				$url = $this->rdfVocabulary->getTabularDataURI($dataValue->getValue());
429
+				return ['<'.$url.'>', false];
432 430
 			case 'url':
433 431
 				$url = $dataValue->getValue();
434
-				if ( !preg_match( '/^[^<>"{}\\\\|^`\\x00-\\x20]*$/D', $url ) ) {
432
+				if (!preg_match('/^[^<>"{}\\\\|^`\\x00-\\x20]*$/D', $url)) {
435 433
 					// not a valid URL for SPARQL (see SPARQL spec, production 139 IRIREF)
436 434
 					// such an URL should never reach us, so just throw
437
-					throw new InvalidArgumentException( 'invalid URL: ' . $url );
435
+					throw new InvalidArgumentException('invalid URL: '.$url);
438 436
 				}
439
-				return [ '<' . $url . '>', false ];
437
+				return ['<'.$url.'>', false];
440 438
 			case 'wikibase-item':
441 439
 			case 'wikibase-property':
442 440
 				/** @var EntityIdValue $dataValue */
443 441
 				'@phan-var EntityIdValue $dataValue';
444
-				return [ 'wd:' . $dataValue->getEntityId()->getSerialization(), false ];
442
+				return ['wd:'.$dataValue->getEntityId()->getSerialization(), false];
445 443
 			case 'monolingualtext':
446 444
 				/** @var MonolingualTextValue $dataValue */
447 445
 				'@phan-var MonolingualTextValue $dataValue';
448 446
 				$lang = $dataValue->getLanguageCode();
449
-				if ( !preg_match( '/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/D', $lang ) ) {
447
+				if (!preg_match('/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/D', $lang)) {
450 448
 					// not a valid language tag for SPARQL (see SPARQL spec, production 145 LANGTAG)
451 449
 					// such a language tag should never reach us, so just throw
452
-					throw new InvalidArgumentException( 'invalid language tag: ' . $lang );
450
+					throw new InvalidArgumentException('invalid language tag: '.$lang);
453 451
 				}
454
-				return [ $this->stringLiteral( $dataValue->getText() ) . '@' . $lang, false ];
452
+				return [$this->stringLiteral($dataValue->getText()).'@'.$lang, false];
455 453
 			case 'globe-coordinate':
456 454
 			case 'quantity':
457 455
 			case 'time':
458
-				return [ 'wdv:' . $dataValue->getHash(), true ];
456
+				return ['wdv:'.$dataValue->getHash(), true];
459 457
 			default:
460
-				throw new InvalidArgumentException( 'unknown data type: ' . $dataType );
458
+				throw new InvalidArgumentException('unknown data type: '.$dataType);
461 459
 		}
462 460
 	}
463 461
 	// @codingStandardsIgnoreEnd
@@ -470,44 +468,44 @@  discard block
 block discarded – undo
470 468
 	 * @throws SparqlHelperException if the query times out or some other error occurs
471 469
 	 * @throws ConstraintParameterException if the $regex is invalid
472 470
 	 */
473
-	public function matchesRegularExpression( $text, $regex ) {
471
+	public function matchesRegularExpression($text, $regex) {
474 472
 		// caching wrapper around matchesRegularExpressionWithSparql
475 473
 
476
-		$textHash = hash( 'sha256', $text );
474
+		$textHash = hash('sha256', $text);
477 475
 		$cacheKey = $this->cache->makeKey(
478 476
 			'WikibaseQualityConstraints', // extension
479 477
 			'regex', // action
480 478
 			'WDQS-Java', // regex flavor
481
-			hash( 'sha256', $regex )
479
+			hash('sha256', $regex)
482 480
 		);
483
-		$cacheMapSize = $this->config->get( 'WBQualityConstraintsFormatCacheMapSize' );
481
+		$cacheMapSize = $this->config->get('WBQualityConstraintsFormatCacheMapSize');
484 482
 
485 483
 		$cacheMapArray = $this->cache->getWithSetCallback(
486 484
 			$cacheKey,
487 485
 			WANObjectCache::TTL_DAY,
488
-			function ( $cacheMapArray ) use ( $text, $regex, $textHash, $cacheMapSize ) {
486
+			function($cacheMapArray) use ($text, $regex, $textHash, $cacheMapSize) {
489 487
 				// Initialize the cache map if not set
490
-				if ( $cacheMapArray === false ) {
488
+				if ($cacheMapArray === false) {
491 489
 					$key = 'wikibase.quality.constraints.regex.cache.refresh.init';
492
-					$this->dataFactory->increment( $key );
490
+					$this->dataFactory->increment($key);
493 491
 					return [];
494 492
 				}
495 493
 
496 494
 				$key = 'wikibase.quality.constraints.regex.cache.refresh';
497
-				$this->dataFactory->increment( $key );
498
-				$cacheMap = MapCacheLRU::newFromArray( $cacheMapArray, $cacheMapSize );
499
-				if ( $cacheMap->has( $textHash ) ) {
495
+				$this->dataFactory->increment($key);
496
+				$cacheMap = MapCacheLRU::newFromArray($cacheMapArray, $cacheMapSize);
497
+				if ($cacheMap->has($textHash)) {
500 498
 					$key = 'wikibase.quality.constraints.regex.cache.refresh.hit';
501
-					$this->dataFactory->increment( $key );
502
-					$cacheMap->get( $textHash ); // ping cache
499
+					$this->dataFactory->increment($key);
500
+					$cacheMap->get($textHash); // ping cache
503 501
 				} else {
504 502
 					$key = 'wikibase.quality.constraints.regex.cache.refresh.miss';
505
-					$this->dataFactory->increment( $key );
503
+					$this->dataFactory->increment($key);
506 504
 					try {
507
-						$matches = $this->matchesRegularExpressionWithSparql( $text, $regex );
508
-					} catch ( ConstraintParameterException $e ) {
509
-						$matches = $this->serializeConstraintParameterException( $e );
510
-					} catch ( SparqlHelperException $e ) {
505
+						$matches = $this->matchesRegularExpressionWithSparql($text, $regex);
506
+					} catch (ConstraintParameterException $e) {
507
+						$matches = $this->serializeConstraintParameterException($e);
508
+					} catch (SparqlHelperException $e) {
511 509
 						// don’t cache this
512 510
 						return $cacheMap->toArray();
513 511
 					}
@@ -531,42 +529,42 @@  discard block
 block discarded – undo
531 529
 			]
532 530
 		);
533 531
 
534
-		if ( isset( $cacheMapArray[$textHash] ) ) {
532
+		if (isset($cacheMapArray[$textHash])) {
535 533
 			$key = 'wikibase.quality.constraints.regex.cache.hit';
536
-			$this->dataFactory->increment( $key );
534
+			$this->dataFactory->increment($key);
537 535
 			$matches = $cacheMapArray[$textHash];
538
-			if ( is_bool( $matches ) ) {
536
+			if (is_bool($matches)) {
539 537
 				return $matches;
540
-			} elseif ( is_array( $matches ) &&
541
-				$matches['type'] == ConstraintParameterException::class ) {
542
-				throw $this->deserializeConstraintParameterException( $matches );
538
+			} elseif (is_array($matches) &&
539
+				$matches['type'] == ConstraintParameterException::class) {
540
+				throw $this->deserializeConstraintParameterException($matches);
543 541
 			} else {
544 542
 				throw new MWException(
545
-					'Value of unknown type in object cache (' .
546
-					'cache key: ' . $cacheKey . ', ' .
547
-					'cache map key: ' . $textHash . ', ' .
548
-					'value type: ' . gettype( $matches ) . ')'
543
+					'Value of unknown type in object cache ('.
544
+					'cache key: '.$cacheKey.', '.
545
+					'cache map key: '.$textHash.', '.
546
+					'value type: '.gettype($matches).')'
549 547
 				);
550 548
 			}
551 549
 		} else {
552 550
 			$key = 'wikibase.quality.constraints.regex.cache.miss';
553
-			$this->dataFactory->increment( $key );
554
-			return $this->matchesRegularExpressionWithSparql( $text, $regex );
551
+			$this->dataFactory->increment($key);
552
+			return $this->matchesRegularExpressionWithSparql($text, $regex);
555 553
 		}
556 554
 	}
557 555
 
558
-	private function serializeConstraintParameterException( ConstraintParameterException $cpe ) {
556
+	private function serializeConstraintParameterException(ConstraintParameterException $cpe) {
559 557
 		return [
560 558
 			'type' => ConstraintParameterException::class,
561
-			'violationMessage' => $this->violationMessageSerializer->serialize( $cpe->getViolationMessage() ),
559
+			'violationMessage' => $this->violationMessageSerializer->serialize($cpe->getViolationMessage()),
562 560
 		];
563 561
 	}
564 562
 
565
-	private function deserializeConstraintParameterException( array $serialization ) {
563
+	private function deserializeConstraintParameterException(array $serialization) {
566 564
 		$message = $this->violationMessageDeserializer->deserialize(
567 565
 			$serialization['violationMessage']
568 566
 		);
569
-		return new ConstraintParameterException( $message );
567
+		return new ConstraintParameterException($message);
570 568
 	}
571 569
 
572 570
 	/**
@@ -580,25 +578,25 @@  discard block
 block discarded – undo
580 578
 	 * @throws SparqlHelperException if the query times out or some other error occurs
581 579
 	 * @throws ConstraintParameterException if the $regex is invalid
582 580
 	 */
583
-	public function matchesRegularExpressionWithSparql( $text, $regex ) {
584
-		$textStringLiteral = $this->stringLiteral( $text );
585
-		$regexStringLiteral = $this->stringLiteral( '^(?:' . $regex . ')$' );
581
+	public function matchesRegularExpressionWithSparql($text, $regex) {
582
+		$textStringLiteral = $this->stringLiteral($text);
583
+		$regexStringLiteral = $this->stringLiteral('^(?:'.$regex.')$');
586 584
 
587 585
 		$query = <<<EOF
588 586
 SELECT (REGEX($textStringLiteral, $regexStringLiteral) AS ?matches) {}
589 587
 EOF;
590 588
 
591
-		$result = $this->runQuery( $query, false );
589
+		$result = $this->runQuery($query, false);
592 590
 
593 591
 		$vars = $result->getArray()['results']['bindings'][0];
594
-		if ( array_key_exists( 'matches', $vars ) ) {
592
+		if (array_key_exists('matches', $vars)) {
595 593
 			// true or false ⇒ regex okay, text matches or not
596 594
 			return $vars['matches']['value'] === 'true';
597 595
 		} else {
598 596
 			// empty result: regex broken
599 597
 			throw new ConstraintParameterException(
600
-				( new ViolationMessage( 'wbqc-violation-message-parameter-regex' ) )
601
-					->withInlineCode( $regex, Role::CONSTRAINT_PARAMETER_VALUE )
598
+				(new ViolationMessage('wbqc-violation-message-parameter-regex'))
599
+					->withInlineCode($regex, Role::CONSTRAINT_PARAMETER_VALUE)
602 600
 			);
603 601
 		}
604 602
 	}
@@ -610,14 +608,14 @@  discard block
 block discarded – undo
610 608
 	 *
611 609
 	 * @return boolean
612 610
 	 */
613
-	public function isTimeout( $responseContent ) {
614
-		$timeoutRegex = implode( '|', array_map(
615
-			function ( $fqn ) {
616
-				return preg_quote( $fqn, '/' );
611
+	public function isTimeout($responseContent) {
612
+		$timeoutRegex = implode('|', array_map(
613
+			function($fqn) {
614
+				return preg_quote($fqn, '/');
617 615
 			},
618
-			$this->config->get( 'WBQualityConstraintsSparqlTimeoutExceptionClasses' )
619
-		) );
620
-		return (bool)preg_match( '/' . $timeoutRegex . '/', $responseContent );
616
+			$this->config->get('WBQualityConstraintsSparqlTimeoutExceptionClasses')
617
+		));
618
+		return (bool) preg_match('/'.$timeoutRegex.'/', $responseContent);
621 619
 	}
622 620
 
623 621
 	/**
@@ -629,17 +627,17 @@  discard block
 block discarded – undo
629 627
 	 * @return int|boolean the max-age (in seconds)
630 628
 	 * or a plain boolean if no max-age can be determined
631 629
 	 */
632
-	public function getCacheMaxAge( $responseHeaders ) {
630
+	public function getCacheMaxAge($responseHeaders) {
633 631
 		if (
634
-			array_key_exists( 'x-cache-status', $responseHeaders ) &&
635
-			preg_match( '/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0] )
632
+			array_key_exists('x-cache-status', $responseHeaders) &&
633
+			preg_match('/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0])
636 634
 		) {
637 635
 			$maxage = [];
638 636
 			if (
639
-				array_key_exists( 'cache-control', $responseHeaders ) &&
640
-				preg_match( '/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage )
637
+				array_key_exists('cache-control', $responseHeaders) &&
638
+				preg_match('/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage)
641 639
 			) {
642
-				return intval( $maxage[1] );
640
+				return intval($maxage[1]);
643 641
 			} else {
644 642
 				return true;
645 643
 			}
@@ -660,34 +658,34 @@  discard block
 block discarded – undo
660 658
 	 * or SparlHelper::EMPTY_RETRY_AFTER if there is an empty Retry-After
661 659
 	 * or SparlHelper::INVALID_RETRY_AFTER if there is something wrong with the format
662 660
 	 */
663
-	public function getThrottling( MWHttpRequest $request ) {
664
-		$retryAfterValue = $request->getResponseHeader( 'Retry-After' );
665
-		if ( $retryAfterValue === null ) {
661
+	public function getThrottling(MWHttpRequest $request) {
662
+		$retryAfterValue = $request->getResponseHeader('Retry-After');
663
+		if ($retryAfterValue === null) {
666 664
 			return self::NO_RETRY_AFTER;
667 665
 		}
668 666
 
669
-		$trimmedRetryAfterValue = trim( $retryAfterValue );
670
-		if ( empty( $trimmedRetryAfterValue ) ) {
667
+		$trimmedRetryAfterValue = trim($retryAfterValue);
668
+		if (empty($trimmedRetryAfterValue)) {
671 669
 			return self::EMPTY_RETRY_AFTER;
672 670
 		}
673 671
 
674
-		if ( is_numeric( $trimmedRetryAfterValue ) ) {
675
-			$delaySeconds = (int)$trimmedRetryAfterValue;
676
-			if ( $delaySeconds >= 0 ) {
677
-				return $this->getTimestampInFuture( new DateInterval( 'PT' . $delaySeconds . 'S' ) );
672
+		if (is_numeric($trimmedRetryAfterValue)) {
673
+			$delaySeconds = (int) $trimmedRetryAfterValue;
674
+			if ($delaySeconds >= 0) {
675
+				return $this->getTimestampInFuture(new DateInterval('PT'.$delaySeconds.'S'));
678 676
 			}
679 677
 		} else {
680
-			$return = strtotime( $trimmedRetryAfterValue );
681
-			if ( !empty( $return ) ) {
682
-				return new ConvertibleTimestamp( $return );
678
+			$return = strtotime($trimmedRetryAfterValue);
679
+			if (!empty($return)) {
680
+				return new ConvertibleTimestamp($return);
683 681
 			}
684 682
 		}
685 683
 		return self::INVALID_RETRY_AFTER;
686 684
 	}
687 685
 
688
-	private function getTimestampInFuture( DateInterval $delta ) {
686
+	private function getTimestampInFuture(DateInterval $delta) {
689 687
 		$now = new ConvertibleTimestamp();
690
-		return new ConvertibleTimestamp( $now->timestamp->add( $delta ) );
688
+		return new ConvertibleTimestamp($now->timestamp->add($delta));
691 689
 	}
692 690
 
693 691
 	/**
@@ -701,68 +699,67 @@  discard block
 block discarded – undo
701 699
 	 *
702 700
 	 * @throws SparqlHelperException if the query times out or some other error occurs
703 701
 	 */
704
-	public function runQuery( $query, $needsPrefixes = true ) {
702
+	public function runQuery($query, $needsPrefixes = true) {
705 703
 
706
-		if ( $this->throttlingLock->isLocked( self::EXPIRY_LOCK_ID ) ) {
707
-			$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.throttling' );
704
+		if ($this->throttlingLock->isLocked(self::EXPIRY_LOCK_ID)) {
705
+			$this->dataFactory->increment('wikibase.quality.constraints.sparql.throttling');
708 706
 			throw new TooManySparqlRequestsException();
709 707
 		}
710 708
 
711
-		$endpoint = $this->config->get( 'WBQualityConstraintsSparqlEndpoint' );
712
-		$maxQueryTimeMillis = $this->config->get( 'WBQualityConstraintsSparqlMaxMillis' );
709
+		$endpoint = $this->config->get('WBQualityConstraintsSparqlEndpoint');
710
+		$maxQueryTimeMillis = $this->config->get('WBQualityConstraintsSparqlMaxMillis');
713 711
 
714
-		if ( $this->config->get( 'WBQualityConstraintsSparqlHasWikibaseSupport' ) ) {
712
+		if ($this->config->get('WBQualityConstraintsSparqlHasWikibaseSupport')) {
715 713
 			$needsPrefixes = false;
716 714
 		}
717 715
 
718
-		if ( $needsPrefixes ) {
719
-			$query = $this->prefixes . $query;
716
+		if ($needsPrefixes) {
717
+			$query = $this->prefixes.$query;
720 718
 		}
721
-		$query = "#wbqc\n" . $query;
719
+		$query = "#wbqc\n".$query;
722 720
 
723
-		$url = $endpoint . '?' . http_build_query(
721
+		$url = $endpoint.'?'.http_build_query(
724 722
 			[
725 723
 				'query' => $query,
726 724
 				'format' => 'json',
727 725
 				'maxQueryTimeMillis' => $maxQueryTimeMillis,
728 726
 			],
729
-			null, ini_get( 'arg_separator.output' ),
727
+			null, ini_get('arg_separator.output'),
730 728
 			// encode spaces with %20, not +
731 729
 			PHP_QUERY_RFC3986
732 730
 		);
733 731
 
734 732
 		$options = [
735 733
 			'method' => 'GET',
736
-			'timeout' => (int)round( ( $maxQueryTimeMillis + 1000 ) / 1000 ),
734
+			'timeout' => (int) round(($maxQueryTimeMillis + 1000) / 1000),
737 735
 			'connectTimeout' => 'default',
738 736
 			'userAgent' => $this->defaultUserAgent,
739 737
 		];
740
-		$request = $this->requestFactory->create( $url, $options, __METHOD__ );
741
-		$startTime = microtime( true );
738
+		$request = $this->requestFactory->create($url, $options, __METHOD__);
739
+		$startTime = microtime(true);
742 740
 		$requestStatus = $request->execute();
743
-		$endTime = microtime( true );
741
+		$endTime = microtime(true);
744 742
 		$this->dataFactory->timing(
745 743
 			'wikibase.quality.constraints.sparql.timing',
746
-			( $endTime - $startTime ) * 1000
744
+			($endTime - $startTime) * 1000
747 745
 		);
748 746
 
749
-		$this->guardAgainstTooManyRequestsError( $request );
747
+		$this->guardAgainstTooManyRequestsError($request);
750 748
 
751
-		$maxAge = $this->getCacheMaxAge( $request->getResponseHeaders() );
752
-		if ( $maxAge ) {
753
-			$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.cached' );
749
+		$maxAge = $this->getCacheMaxAge($request->getResponseHeaders());
750
+		if ($maxAge) {
751
+			$this->dataFactory->increment('wikibase.quality.constraints.sparql.cached');
754 752
 		}
755 753
 
756
-		if ( $requestStatus->isOK() ) {
754
+		if ($requestStatus->isOK()) {
757 755
 			$json = $request->getContent();
758
-			$jsonStatus = FormatJson::parse( $json, FormatJson::FORCE_ASSOC );
759
-			if ( $jsonStatus->isOK() ) {
756
+			$jsonStatus = FormatJson::parse($json, FormatJson::FORCE_ASSOC);
757
+			if ($jsonStatus->isOK()) {
760 758
 				return new CachedQueryResults(
761 759
 					$jsonStatus->getValue(),
762 760
 					Metadata::ofCachingMetadata(
763 761
 						$maxAge ?
764
-							CachingMetadata::ofMaximumAgeInSeconds( $maxAge ) :
765
-							CachingMetadata::fresh()
762
+							CachingMetadata::ofMaximumAgeInSeconds($maxAge) : CachingMetadata::fresh()
766 763
 					)
767 764
 				);
768 765
 			} else {
@@ -779,9 +776,9 @@  discard block
 block discarded – undo
779 776
 			// fall through to general error handling
780 777
 		}
781 778
 
782
-		$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.error' );
779
+		$this->dataFactory->increment('wikibase.quality.constraints.sparql.error');
783 780
 
784
-		if ( $this->isTimeout( $request->getContent() ) ) {
781
+		if ($this->isTimeout($request->getContent())) {
785 782
 			$this->dataFactory->increment(
786 783
 				'wikibase.quality.constraints.sparql.error.timeout'
787 784
 			);
@@ -796,29 +793,29 @@  discard block
 block discarded – undo
796 793
 	 * @param MWHttpRequest $request
797 794
 	 * @throws TooManySparqlRequestsException
798 795
 	 */
799
-	private function guardAgainstTooManyRequestsError( MWHttpRequest $request ): void {
800
-		if ( $request->getStatus() !== self::HTTP_TOO_MANY_REQUESTS ) {
796
+	private function guardAgainstTooManyRequestsError(MWHttpRequest $request): void {
797
+		if ($request->getStatus() !== self::HTTP_TOO_MANY_REQUESTS) {
801 798
 			return;
802 799
 		}
803 800
 
804
-		$fallbackBlockDuration = (int)$this->config->get( 'WBQualityConstraintsSparqlThrottlingFallbackDuration' );
801
+		$fallbackBlockDuration = (int) $this->config->get('WBQualityConstraintsSparqlThrottlingFallbackDuration');
805 802
 
806
-		if ( $fallbackBlockDuration < 0 ) {
807
-			throw new InvalidArgumentException( 'Fallback duration must be positive int but is: ' .
808
-				$fallbackBlockDuration );
803
+		if ($fallbackBlockDuration < 0) {
804
+			throw new InvalidArgumentException('Fallback duration must be positive int but is: '.
805
+				$fallbackBlockDuration);
809 806
 		}
810 807
 
811
-		$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.throttling' );
812
-		$throttlingUntil = $this->getThrottling( $request );
813
-		if ( !( $throttlingUntil instanceof ConvertibleTimestamp ) ) {
814
-			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterInvalid( $request );
808
+		$this->dataFactory->increment('wikibase.quality.constraints.sparql.throttling');
809
+		$throttlingUntil = $this->getThrottling($request);
810
+		if (!($throttlingUntil instanceof ConvertibleTimestamp)) {
811
+			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterInvalid($request);
815 812
 			$this->throttlingLock->lock(
816 813
 				self::EXPIRY_LOCK_ID,
817
-				$this->getTimestampInFuture( new DateInterval( 'PT' . $fallbackBlockDuration . 'S' ) )
814
+				$this->getTimestampInFuture(new DateInterval('PT'.$fallbackBlockDuration.'S'))
818 815
 			);
819 816
 		} else {
820
-			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterPresent( $throttlingUntil, $request );
821
-			$this->throttlingLock->lock( self::EXPIRY_LOCK_ID, $throttlingUntil );
817
+			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterPresent($throttlingUntil, $request);
818
+			$this->throttlingLock->lock(self::EXPIRY_LOCK_ID, $throttlingUntil);
822 819
 		}
823 820
 		throw new TooManySparqlRequestsException();
824 821
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
 	 * @param array $parameters
78 78
 	 * @throws ConstraintParameterException
79 79
 	 */
80
-	public function checkError( array $parameters ) {
81
-		if ( array_key_exists( '@error', $parameters ) ) {
80
+	public function checkError(array $parameters) {
81
+		if (array_key_exists('@error', $parameters)) {
82 82
 			$error = $parameters['@error'];
83
-			if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) {
83
+			if (array_key_exists('toolong', $error) && $error['toolong']) {
84 84
 				$msg = 'wbqc-violation-message-parameters-error-toolong';
85 85
 			} else {
86 86
 				$msg = 'wbqc-violation-message-parameters-error-unknown';
87 87
 			}
88
-			throw new ConstraintParameterException( new ViolationMessage( $msg ) );
88
+			throw new ConstraintParameterException(new ViolationMessage($msg));
89 89
 		}
90 90
 	}
91 91
 
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 	 * @param string $parameterId
96 96
 	 * @throws ConstraintParameterException
97 97
 	 */
98
-	private function requireSingleParameter( array $parameters, $parameterId ) {
99
-		if ( count( $parameters[$parameterId] ) !== 1 ) {
98
+	private function requireSingleParameter(array $parameters, $parameterId) {
99
+		if (count($parameters[$parameterId]) !== 1) {
100 100
 			throw new ConstraintParameterException(
101
-				( new ViolationMessage( 'wbqc-violation-message-parameter-single' ) )
102
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
101
+				(new ViolationMessage('wbqc-violation-message-parameter-single'))
102
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
103 103
 			);
104 104
 		}
105 105
 	}
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	 * @return void
112 112
 	 * @throws ConstraintParameterException
113 113
 	 */
114
-	private function requireValueParameter( Snak $snak, $parameterId ) {
115
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
114
+	private function requireValueParameter(Snak $snak, $parameterId) {
115
+		if (!($snak instanceof PropertyValueSnak)) {
116 116
 			throw new ConstraintParameterException(
117
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
118
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
117
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
118
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
119 119
 			);
120 120
 		}
121 121
 	}
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
 	 * @throws ConstraintParameterException
128 128
 	 * @return EntityId
129 129
 	 */
130
-	private function parseEntityIdParameter( array $snakSerialization, $parameterId ) {
131
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
132
-		$this->requireValueParameter( $snak, $parameterId );
130
+	private function parseEntityIdParameter(array $snakSerialization, $parameterId) {
131
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
132
+		$this->requireValueParameter($snak, $parameterId);
133 133
 		$value = $snak->getDataValue();
134
-		if ( $value instanceof EntityIdValue ) {
134
+		if ($value instanceof EntityIdValue) {
135 135
 			return $value->getEntityId();
136 136
 		} else {
137 137
 			throw new ConstraintParameterException(
138
-				( new ViolationMessage( 'wbqc-violation-message-parameter-entity' ) )
139
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
140
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
138
+				(new ViolationMessage('wbqc-violation-message-parameter-entity'))
139
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
140
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
141 141
 			);
142 142
 		}
143 143
 	}
@@ -148,20 +148,20 @@  discard block
 block discarded – undo
148 148
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
149 149
 	 * @return string[] class entity ID serializations
150 150
 	 */
151
-	public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) {
152
-		$this->checkError( $constraintParameters );
153
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
154
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
151
+	public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) {
152
+		$this->checkError($constraintParameters);
153
+		$classId = $this->config->get('WBQualityConstraintsClassId');
154
+		if (!array_key_exists($classId, $constraintParameters)) {
155 155
 			throw new ConstraintParameterException(
156
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
157
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
158
-					->withEntityId( new PropertyId( $classId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
156
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
157
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
158
+					->withEntityId(new PropertyId($classId), Role::CONSTRAINT_PARAMETER_PROPERTY)
159 159
 			);
160 160
 		}
161 161
 
162 162
 		$classes = [];
163
-		foreach ( $constraintParameters[$classId] as $class ) {
164
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
163
+		foreach ($constraintParameters[$classId] as $class) {
164
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
165 165
 		}
166 166
 		return $classes;
167 167
 	}
@@ -172,23 +172,23 @@  discard block
 block discarded – undo
172 172
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
173 173
 	 * @return string 'instance', 'subclass', or 'instanceOrSubclass'
174 174
 	 */
175
-	public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) {
176
-		$this->checkError( $constraintParameters );
177
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
178
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
175
+	public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) {
176
+		$this->checkError($constraintParameters);
177
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
178
+		if (!array_key_exists($relationId, $constraintParameters)) {
179 179
 			throw new ConstraintParameterException(
180
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
181
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
182
-					->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
180
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
181
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
182
+					->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
183 183
 			);
184 184
 		}
185 185
 
186
-		$this->requireSingleParameter( $constraintParameters, $relationId );
187
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
188
-		$instanceId = $this->config->get( 'WBQualityConstraintsInstanceOfRelationId' );
189
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfRelationId' );
190
-		$instanceOrSubclassId = $this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' );
191
-		switch ( $relationEntityId->getSerialization() ) {
186
+		$this->requireSingleParameter($constraintParameters, $relationId);
187
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
188
+		$instanceId = $this->config->get('WBQualityConstraintsInstanceOfRelationId');
189
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfRelationId');
190
+		$instanceOrSubclassId = $this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId');
191
+		switch ($relationEntityId->getSerialization()) {
192 192
 			case $instanceId:
193 193
 				return 'instance';
194 194
 			case $subclassId:
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
 				return 'instanceOrSubclass';
198 198
 			default:
199 199
 				throw new ConstraintParameterException(
200
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
201
-						->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
200
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
201
+						->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
202 202
 						->withEntityIdList(
203 203
 							[
204
-								new ItemId( $instanceId ),
205
-								new ItemId( $subclassId ),
206
-								new ItemId( $instanceOrSubclassId ),
204
+								new ItemId($instanceId),
205
+								new ItemId($subclassId),
206
+								new ItemId($instanceOrSubclassId),
207 207
 							],
208 208
 							Role::CONSTRAINT_PARAMETER_VALUE
209 209
 						)
@@ -218,20 +218,20 @@  discard block
 block discarded – undo
218 218
 	 * @throws ConstraintParameterException
219 219
 	 * @return PropertyId
220 220
 	 */
221
-	private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) {
222
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
223
-		$this->requireValueParameter( $snak, $parameterId );
221
+	private function parsePropertyIdParameter(array $snakSerialization, $parameterId) {
222
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
223
+		$this->requireValueParameter($snak, $parameterId);
224 224
 		$value = $snak->getDataValue();
225
-		if ( $value instanceof EntityIdValue ) {
225
+		if ($value instanceof EntityIdValue) {
226 226
 			$id = $value->getEntityId();
227
-			if ( $id instanceof PropertyId ) {
227
+			if ($id instanceof PropertyId) {
228 228
 				return $id;
229 229
 			}
230 230
 		}
231 231
 		throw new ConstraintParameterException(
232
-			( new ViolationMessage( 'wbqc-violation-message-parameter-property' ) )
233
-				->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
234
-				->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
232
+			(new ViolationMessage('wbqc-violation-message-parameter-property'))
233
+				->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
234
+				->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
235 235
 		);
236 236
 	}
237 237
 
@@ -242,33 +242,33 @@  discard block
 block discarded – undo
242 242
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
243 243
 	 * @return PropertyId
244 244
 	 */
245
-	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
246
-		$this->checkError( $constraintParameters );
247
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
248
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
245
+	public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) {
246
+		$this->checkError($constraintParameters);
247
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
248
+		if (!array_key_exists($propertyId, $constraintParameters)) {
249 249
 			throw new ConstraintParameterException(
250
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
251
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
252
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
250
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
251
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
252
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
253 253
 			);
254 254
 		}
255 255
 
256
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
257
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
256
+		$this->requireSingleParameter($constraintParameters, $propertyId);
257
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
258 258
 	}
259 259
 
260
-	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
260
+	private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) {
261 261
 		$dataValue = $snak->getDataValue();
262
-		if ( $dataValue instanceof EntityIdValue ) {
262
+		if ($dataValue instanceof EntityIdValue) {
263 263
 			$entityId = $dataValue->getEntityId();
264
-			if ( $entityId instanceof ItemId ) {
265
-				return ItemIdSnakValue::fromItemId( $entityId );
264
+			if ($entityId instanceof ItemId) {
265
+				return ItemIdSnakValue::fromItemId($entityId);
266 266
 			}
267 267
 		}
268 268
 		throw new ConstraintParameterException(
269
-			( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
270
-				->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
271
-				->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
269
+			(new ViolationMessage('wbqc-violation-message-parameter-item'))
270
+				->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
271
+				->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
272 272
 		);
273 273
 	}
274 274
 
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
 		$required,
287 287
 		$parameterId = null
288 288
 	) {
289
-		$this->checkError( $constraintParameters );
290
-		if ( $parameterId === null ) {
291
-			$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
289
+		$this->checkError($constraintParameters);
290
+		if ($parameterId === null) {
291
+			$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
292 292
 		}
293
-		if ( !array_key_exists( $parameterId, $constraintParameters ) ) {
294
-			if ( $required ) {
293
+		if (!array_key_exists($parameterId, $constraintParameters)) {
294
+			if ($required) {
295 295
 				throw new ConstraintParameterException(
296
-					( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
297
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
298
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
296
+					(new ViolationMessage('wbqc-violation-message-parameter-needed'))
297
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
298
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
299 299
 				);
300 300
 			} else {
301 301
 				return [];
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 		}
304 304
 
305 305
 		$values = [];
306
-		foreach ( $constraintParameters[$parameterId] as $parameter ) {
307
-			$snak = $this->snakDeserializer->deserialize( $parameter );
308
-			switch ( true ) {
306
+		foreach ($constraintParameters[$parameterId] as $parameter) {
307
+			$snak = $this->snakDeserializer->deserialize($parameter);
308
+			switch (true) {
309 309
 				case $snak instanceof PropertyValueSnak:
310
-					$values[] = $this->parseItemIdParameter( $snak, $parameterId );
310
+					$values[] = $this->parseItemIdParameter($snak, $parameterId);
311 311
 					break;
312 312
 				case $snak instanceof PropertySomeValueSnak:
313 313
 					$values[] = ItemIdSnakValue::someValue();
@@ -326,27 +326,27 @@  discard block
 block discarded – undo
326 326
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
327 327
 	 * @return PropertyId[]
328 328
 	 */
329
-	public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) {
330
-		$this->checkError( $constraintParameters );
331
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
332
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
329
+	public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) {
330
+		$this->checkError($constraintParameters);
331
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
332
+		if (!array_key_exists($propertyId, $constraintParameters)) {
333 333
 			throw new ConstraintParameterException(
334
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
335
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
336
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
334
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
335
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
336
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
337 337
 			);
338 338
 		}
339 339
 
340 340
 		$parameters = $constraintParameters[$propertyId];
341
-		if ( count( $parameters ) === 1 &&
342
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
341
+		if (count($parameters) === 1 &&
342
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
343 343
 		) {
344 344
 			return [];
345 345
 		}
346 346
 
347 347
 		$properties = [];
348
-		foreach ( $parameters as $parameter ) {
349
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
348
+		foreach ($parameters as $parameter) {
349
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
350 350
 		}
351 351
 		return $properties;
352 352
 	}
@@ -357,16 +357,16 @@  discard block
 block discarded – undo
357 357
 	 * @throws ConstraintParameterException
358 358
 	 * @return DataValue|null
359 359
 	 */
360
-	private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) {
361
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
362
-		if ( $snak instanceof PropertyValueSnak ) {
360
+	private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) {
361
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
362
+		if ($snak instanceof PropertyValueSnak) {
363 363
 			return $snak->getDataValue();
364
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
364
+		} elseif ($snak instanceof PropertyNoValueSnak) {
365 365
 			return null;
366 366
 		} else {
367 367
 			throw new ConstraintParameterException(
368
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
369
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
368
+				(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
369
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
370 370
 			);
371 371
 		}
372 372
 	}
@@ -376,10 +376,10 @@  discard block
 block discarded – undo
376 376
 	 * @param string $parameterId
377 377
 	 * @return DataValue|null
378 378
 	 */
379
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) {
379
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) {
380 380
 		try {
381
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
382
-		} catch ( ConstraintParameterException $e ) {
381
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
382
+		} catch (ConstraintParameterException $e) {
383 383
 			// unknown value means “now”
384 384
 			return new NowValue();
385 385
 		}
@@ -392,14 +392,14 @@  discard block
 block discarded – undo
392 392
 	 * @param string $unit
393 393
 	 * @return bool
394 394
 	 */
395
-	private function exactlyOneQuantityWithUnit( ?DataValue $min, ?DataValue $max, $unit ) {
396
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
397
-			!( $max instanceof UnboundedQuantityValue )
395
+	private function exactlyOneQuantityWithUnit(?DataValue $min, ?DataValue $max, $unit) {
396
+		if (!($min instanceof UnboundedQuantityValue) ||
397
+			!($max instanceof UnboundedQuantityValue)
398 398
 		) {
399 399
 			return false;
400 400
 		}
401 401
 
402
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
402
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
403 403
 	}
404 404
 
405 405
 	/**
@@ -412,42 +412,42 @@  discard block
 block discarded – undo
412 412
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
413 413
 	 * @return DataValue[] if the parameter is invalid or missing
414 414
 	 */
415
-	private function parseRangeParameter( array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type ) {
416
-		$this->checkError( $constraintParameters );
417
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
418
-			!array_key_exists( $maximumId, $constraintParameters )
415
+	private function parseRangeParameter(array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type) {
416
+		$this->checkError($constraintParameters);
417
+		if (!array_key_exists($minimumId, $constraintParameters) ||
418
+			!array_key_exists($maximumId, $constraintParameters)
419 419
 		) {
420 420
 			throw new ConstraintParameterException(
421
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-needed' ) )
422
-					->withDataValueType( $type )
423
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
424
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
425
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
421
+				(new ViolationMessage('wbqc-violation-message-range-parameters-needed'))
422
+					->withDataValueType($type)
423
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
424
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
425
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
426 426
 			);
427 427
 		}
428 428
 
429
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
430
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
429
+		$this->requireSingleParameter($constraintParameters, $minimumId);
430
+		$this->requireSingleParameter($constraintParameters, $maximumId);
431 431
 		$parseFunction = $type === 'time' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
432
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
433
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
432
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
433
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
434 434
 
435
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
436
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
435
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
436
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
437 437
 			throw new ConstraintParameterException(
438
-				new ViolationMessage( 'wbqc-violation-message-range-parameters-one-year' )
438
+				new ViolationMessage('wbqc-violation-message-range-parameters-one-year')
439 439
 			);
440 440
 		}
441
-		if ( $min === null && $max === null ||
442
-			$min !== null && $max !== null && $min->equals( $max ) ) {
441
+		if ($min === null && $max === null ||
442
+			$min !== null && $max !== null && $min->equals($max)) {
443 443
 			throw new ConstraintParameterException(
444
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-same' ) )
445
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
446
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
444
+				(new ViolationMessage('wbqc-violation-message-range-parameters-same'))
445
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
446
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
447 447
 			);
448 448
 		}
449 449
 
450
-		return [ $min, $max ];
450
+		return [$min, $max];
451 451
 	}
452 452
 
453 453
 	/**
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
458 458
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
459 459
 	 */
460
-	public function parseQuantityRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
460
+	public function parseQuantityRangeParameter(array $constraintParameters, $constraintTypeItemId) {
461 461
 		return $this->parseRangeParameter(
462 462
 			$constraintParameters,
463
-			$this->config->get( 'WBQualityConstraintsMinimumQuantityId' ),
464
-			$this->config->get( 'WBQualityConstraintsMaximumQuantityId' ),
463
+			$this->config->get('WBQualityConstraintsMinimumQuantityId'),
464
+			$this->config->get('WBQualityConstraintsMaximumQuantityId'),
465 465
 			$constraintTypeItemId,
466 466
 			'quantity'
467 467
 		);
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
475 475
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
476 476
 	 */
477
-	public function parseTimeRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
477
+	public function parseTimeRangeParameter(array $constraintParameters, $constraintTypeItemId) {
478 478
 		return $this->parseRangeParameter(
479 479
 			$constraintParameters,
480
-			$this->config->get( 'WBQualityConstraintsMinimumDateId' ),
481
-			$this->config->get( 'WBQualityConstraintsMaximumDateId' ),
480
+			$this->config->get('WBQualityConstraintsMinimumDateId'),
481
+			$this->config->get('WBQualityConstraintsMaximumDateId'),
482 482
 			$constraintTypeItemId,
483 483
 			'time'
484 484
 		);
@@ -491,17 +491,17 @@  discard block
 block discarded – undo
491 491
 	 * @throws ConstraintParameterException
492 492
 	 * @return string
493 493
 	 */
494
-	private function parseStringParameter( array $snakSerialization, $parameterId ) {
495
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
496
-		$this->requireValueParameter( $snak, $parameterId );
494
+	private function parseStringParameter(array $snakSerialization, $parameterId) {
495
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
496
+		$this->requireValueParameter($snak, $parameterId);
497 497
 		$value = $snak->getDataValue();
498
-		if ( $value instanceof StringValue ) {
498
+		if ($value instanceof StringValue) {
499 499
 			return $value->getValue();
500 500
 		} else {
501 501
 			throw new ConstraintParameterException(
502
-				( new ViolationMessage( 'wbqc-violation-message-parameter-string' ) )
503
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
504
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
502
+				(new ViolationMessage('wbqc-violation-message-parameter-string'))
503
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
504
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
505 505
 			);
506 506
 		}
507 507
 	}
@@ -512,15 +512,15 @@  discard block
 block discarded – undo
512 512
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
513 513
 	 * @return string
514 514
 	 */
515
-	public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) {
516
-		$this->checkError( $constraintParameters );
517
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
518
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
515
+	public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) {
516
+		$this->checkError($constraintParameters);
517
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
518
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
519 519
 			return '';
520 520
 		}
521 521
 
522
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
523
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
522
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
523
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
524 524
 	}
525 525
 
526 526
 	/**
@@ -529,19 +529,19 @@  discard block
 block discarded – undo
529 529
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
530 530
 	 * @return string
531 531
 	 */
532
-	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
533
-		$this->checkError( $constraintParameters );
534
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
535
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
532
+	public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) {
533
+		$this->checkError($constraintParameters);
534
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
535
+		if (!array_key_exists($formatId, $constraintParameters)) {
536 536
 			throw new ConstraintParameterException(
537
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
538
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
539
-					->withEntityId( new PropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
537
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
538
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
539
+					->withEntityId(new PropertyId($formatId), Role::CONSTRAINT_PARAMETER_PROPERTY)
540 540
 			);
541 541
 		}
542 542
 
543
-		$this->requireSingleParameter( $constraintParameters, $formatId );
544
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
543
+		$this->requireSingleParameter($constraintParameters, $formatId);
544
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
545 545
 	}
546 546
 
547 547
 	/**
@@ -549,16 +549,16 @@  discard block
 block discarded – undo
549 549
 	 * @throws ConstraintParameterException if the parameter is invalid
550 550
 	 * @return EntityId[]
551 551
 	 */
552
-	public function parseExceptionParameter( array $constraintParameters ) {
553
-		$this->checkError( $constraintParameters );
554
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
555
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
552
+	public function parseExceptionParameter(array $constraintParameters) {
553
+		$this->checkError($constraintParameters);
554
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
555
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
556 556
 			return [];
557 557
 		}
558 558
 
559 559
 		return array_map(
560
-			function ( $snakSerialization ) use ( $exceptionId ) {
561
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
560
+			function($snakSerialization) use ($exceptionId) {
561
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
562 562
 			},
563 563
 			$constraintParameters[$exceptionId]
564 564
 		);
@@ -569,39 +569,39 @@  discard block
 block discarded – undo
569 569
 	 * @throws ConstraintParameterException if the parameter is invalid
570 570
 	 * @return string|null 'mandatory', 'suggestion' or null
571 571
 	 */
572
-	public function parseConstraintStatusParameter( array $constraintParameters ) {
573
-		$this->checkError( $constraintParameters );
574
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
575
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
572
+	public function parseConstraintStatusParameter(array $constraintParameters) {
573
+		$this->checkError($constraintParameters);
574
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
575
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
576 576
 			return null;
577 577
 		}
578 578
 
579
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
580
-		$supportedStatuses = [ new ItemId( $mandatoryId ) ];
581
-		if ( $this->config->get( 'WBQualityConstraintsEnableSuggestionConstraintStatus' ) ) {
582
-			$suggestionId = $this->config->get( 'WBQualityConstraintsSuggestionConstraintId' );
583
-			$supportedStatuses[] = new ItemId( $suggestionId );
579
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
580
+		$supportedStatuses = [new ItemId($mandatoryId)];
581
+		if ($this->config->get('WBQualityConstraintsEnableSuggestionConstraintStatus')) {
582
+			$suggestionId = $this->config->get('WBQualityConstraintsSuggestionConstraintId');
583
+			$supportedStatuses[] = new ItemId($suggestionId);
584 584
 		} else {
585 585
 			$suggestionId = null;
586 586
 		}
587 587
 
588
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
589
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
590
-		$this->requireValueParameter( $snak, $constraintStatusId );
588
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
589
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
590
+		$this->requireValueParameter($snak, $constraintStatusId);
591 591
 		'@phan-var \Wikibase\DataModel\Snak\PropertyValueSnak $snak';
592 592
 		$dataValue = $snak->getDataValue();
593 593
 		'@phan-var EntityIdValue $dataValue';
594 594
 		$entityId = $dataValue->getEntityId();
595 595
 		$statusId = $entityId->getSerialization();
596 596
 
597
-		if ( $statusId === $mandatoryId ) {
597
+		if ($statusId === $mandatoryId) {
598 598
 			return 'mandatory';
599
-		} elseif ( $statusId === $suggestionId ) {
599
+		} elseif ($statusId === $suggestionId) {
600 600
 			return 'suggestion';
601 601
 		} else {
602 602
 			throw new ConstraintParameterException(
603
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
604
-					->withEntityId( new PropertyId( $constraintStatusId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
603
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
604
+					->withEntityId(new PropertyId($constraintStatusId), Role::CONSTRAINT_PARAMETER_PROPERTY)
605 605
 					->withEntityIdList(
606 606
 						$supportedStatuses,
607 607
 						Role::CONSTRAINT_PARAMETER_VALUE
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
 	 * @return void
618 618
 	 * @throws ConstraintParameterException
619 619
 	 */
620
-	private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) {
621
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
620
+	private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) {
621
+		if (!($dataValue instanceof MonolingualTextValue)) {
622 622
 			throw new ConstraintParameterException(
623
-				( new ViolationMessage( 'wbqc-violation-message-parameter-monolingualtext' ) )
624
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
625
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
623
+				(new ViolationMessage('wbqc-violation-message-parameter-monolingualtext'))
624
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
625
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
626 626
 			);
627 627
 		}
628 628
 	}
@@ -635,31 +635,31 @@  discard block
 block discarded – undo
635 635
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
636 636
 	 * @return MultilingualTextValue
637 637
 	 */
638
-	private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) {
638
+	private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) {
639 639
 		$result = [];
640 640
 
641
-		foreach ( $snakSerializations as $snakSerialization ) {
642
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
643
-			$this->requireValueParameter( $snak, $parameterId );
641
+		foreach ($snakSerializations as $snakSerialization) {
642
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
643
+			$this->requireValueParameter($snak, $parameterId);
644 644
 
645 645
 			$value = $snak->getDataValue();
646
-			$this->requireMonolingualTextParameter( $value, $parameterId );
646
+			$this->requireMonolingualTextParameter($value, $parameterId);
647 647
 			/** @var MonolingualTextValue $value */
648 648
 			'@phan-var MonolingualTextValue $value';
649 649
 
650 650
 			$code = $value->getLanguageCode();
651
-			if ( array_key_exists( $code, $result ) ) {
651
+			if (array_key_exists($code, $result)) {
652 652
 				throw new ConstraintParameterException(
653
-					( new ViolationMessage( 'wbqc-violation-message-parameter-single-per-language' ) )
654
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
655
-						->withLanguage( $code )
653
+					(new ViolationMessage('wbqc-violation-message-parameter-single-per-language'))
654
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
655
+						->withLanguage($code)
656 656
 				);
657 657
 			}
658 658
 
659 659
 			$result[$code] = $value;
660 660
 		}
661 661
 
662
-		return new MultilingualTextValue( $result );
662
+		return new MultilingualTextValue($result);
663 663
 	}
664 664
 
665 665
 	/**
@@ -667,11 +667,11 @@  discard block
 block discarded – undo
667 667
 	 * @throws ConstraintParameterException if the parameter is invalid
668 668
 	 * @return MultilingualTextValue
669 669
 	 */
670
-	public function parseSyntaxClarificationParameter( array $constraintParameters ) {
671
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
670
+	public function parseSyntaxClarificationParameter(array $constraintParameters) {
671
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
672 672
 
673
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
674
-			return new MultilingualTextValue( [] );
673
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
674
+			return new MultilingualTextValue([]);
675 675
 		}
676 676
 
677 677
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 		array $validScopes = null
697 697
 	) {
698 698
 		$contextTypes = [];
699
-		$parameterId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
699
+		$parameterId = $this->config->get('WBQualityConstraintsConstraintScopeId');
700 700
 		$items = $this->parseItemsParameter(
701 701
 			$constraintParameters,
702 702
 			$constraintTypeItemId,
@@ -704,23 +704,23 @@  discard block
 block discarded – undo
704 704
 			$parameterId
705 705
 		);
706 706
 
707
-		if ( $items === [] ) {
707
+		if ($items === []) {
708 708
 			return null;
709 709
 		}
710 710
 
711
-		foreach ( $items as $item ) {
712
-			$contextTypes[] = $this->parseContextTypeItem( $item, 'constraint scope', $parameterId );
711
+		foreach ($items as $item) {
712
+			$contextTypes[] = $this->parseContextTypeItem($item, 'constraint scope', $parameterId);
713 713
 		}
714 714
 
715
-		if ( $validScopes !== null ) {
716
-			$invalidScopes = array_diff( $contextTypes, $validScopes );
717
-			if ( $invalidScopes !== [] ) {
718
-				$invalidScope = array_pop( $invalidScopes );
715
+		if ($validScopes !== null) {
716
+			$invalidScopes = array_diff($contextTypes, $validScopes);
717
+			if ($invalidScopes !== []) {
718
+				$invalidScope = array_pop($invalidScopes);
719 719
 				throw new ConstraintParameterException(
720
-					( new ViolationMessage( 'wbqc-violation-message-invalid-scope' ) )
721
-						->withConstraintScope( $invalidScope, Role::CONSTRAINT_PARAMETER_VALUE )
722
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
723
-						->withConstraintScopeList( $validScopes, Role::CONSTRAINT_PARAMETER_VALUE )
720
+					(new ViolationMessage('wbqc-violation-message-invalid-scope'))
721
+						->withConstraintScope($invalidScope, Role::CONSTRAINT_PARAMETER_VALUE)
722
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
723
+						->withConstraintScopeList($validScopes, Role::CONSTRAINT_PARAMETER_VALUE)
724 724
 				);
725 725
 			}
726 726
 		}
@@ -734,8 +734,8 @@  discard block
 block discarded – undo
734 734
 	 * @param ItemId $unitId
735 735
 	 * @return string unit
736 736
 	 */
737
-	private function parseUnitParameter( ItemId $unitId ) {
738
-		return $this->unitItemConceptBaseUri . $unitId->getSerialization();
737
+	private function parseUnitParameter(ItemId $unitId) {
738
+		return $this->unitItemConceptBaseUri.$unitId->getSerialization();
739 739
 	}
740 740
 
741 741
 	/**
@@ -745,23 +745,23 @@  discard block
 block discarded – undo
745 745
 	 * @return UnitsParameter
746 746
 	 * @throws ConstraintParameterException
747 747
 	 */
748
-	private function parseUnitItem( ItemIdSnakValue $item ) {
749
-		switch ( true ) {
748
+	private function parseUnitItem(ItemIdSnakValue $item) {
749
+		switch (true) {
750 750
 			case $item->isValue():
751
-				$unit = $this->parseUnitParameter( $item->getItemId() );
751
+				$unit = $this->parseUnitParameter($item->getItemId());
752 752
 				return new UnitsParameter(
753
-					[ $item->getItemId() ],
754
-					[ UnboundedQuantityValue::newFromNumber( 1, $unit ) ],
753
+					[$item->getItemId()],
754
+					[UnboundedQuantityValue::newFromNumber(1, $unit)],
755 755
 					false
756 756
 				);
757 757
 			case $item->isSomeValue():
758
-				$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
758
+				$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
759 759
 				throw new ConstraintParameterException(
760
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
761
-						->withEntityId( new PropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
760
+					(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
761
+						->withEntityId(new PropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
762 762
 				);
763 763
 			case $item->isNoValue():
764
-				return new UnitsParameter( [], [], true );
764
+				return new UnitsParameter([], [], true);
765 765
 		}
766 766
 	}
767 767
 
@@ -771,26 +771,26 @@  discard block
 block discarded – undo
771 771
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
772 772
 	 * @return UnitsParameter
773 773
 	 */
774
-	public function parseUnitsParameter( array $constraintParameters, $constraintTypeItemId ) {
775
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
774
+	public function parseUnitsParameter(array $constraintParameters, $constraintTypeItemId) {
775
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
776 776
 		$unitItems = [];
777 777
 		$unitQuantities = [];
778 778
 		$unitlessAllowed = false;
779 779
 
780
-		foreach ( $items as $item ) {
781
-			$unit = $this->parseUnitItem( $item );
782
-			$unitItems = array_merge( $unitItems, $unit->getUnitItemIds() );
783
-			$unitQuantities = array_merge( $unitQuantities, $unit->getUnitQuantities() );
780
+		foreach ($items as $item) {
781
+			$unit = $this->parseUnitItem($item);
782
+			$unitItems = array_merge($unitItems, $unit->getUnitItemIds());
783
+			$unitQuantities = array_merge($unitQuantities, $unit->getUnitQuantities());
784 784
 			$unitlessAllowed = $unitlessAllowed || $unit->getUnitlessAllowed();
785 785
 		}
786 786
 
787
-		if ( $unitQuantities === [] && !$unitlessAllowed ) {
787
+		if ($unitQuantities === [] && !$unitlessAllowed) {
788 788
 			throw new LogicException(
789 789
 				'The "units" parameter is required, and yet we seem to be missing any allowed unit'
790 790
 			);
791 791
 		}
792 792
 
793
-		return new UnitsParameter( $unitItems, $unitQuantities, $unitlessAllowed );
793
+		return new UnitsParameter($unitItems, $unitQuantities, $unitlessAllowed);
794 794
 	}
795 795
 
796 796
 	/**
@@ -800,53 +800,53 @@  discard block
 block discarded – undo
800 800
 	 * @return EntityTypesParameter
801 801
 	 * @throws ConstraintParameterException
802 802
 	 */
803
-	private function parseEntityTypeItem( ItemIdSnakValue $item ) {
804
-		$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
803
+	private function parseEntityTypeItem(ItemIdSnakValue $item) {
804
+		$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
805 805
 
806
-		if ( !$item->isValue() ) {
806
+		if (!$item->isValue()) {
807 807
 			throw new ConstraintParameterException(
808
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
809
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
808
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
809
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
810 810
 			);
811 811
 		}
812 812
 
813 813
 		$itemId = $item->getItemId();
814
-		switch ( $itemId->getSerialization() ) {
815
-			case $this->config->get( 'WBQualityConstraintsWikibaseItemId' ):
814
+		switch ($itemId->getSerialization()) {
815
+			case $this->config->get('WBQualityConstraintsWikibaseItemId'):
816 816
 				$entityType = 'item';
817 817
 				break;
818
-			case $this->config->get( 'WBQualityConstraintsWikibasePropertyId' ):
818
+			case $this->config->get('WBQualityConstraintsWikibasePropertyId'):
819 819
 				$entityType = 'property';
820 820
 				break;
821
-			case $this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ):
821
+			case $this->config->get('WBQualityConstraintsWikibaseLexemeId'):
822 822
 				$entityType = 'lexeme';
823 823
 				break;
824
-			case $this->config->get( 'WBQualityConstraintsWikibaseFormId' ):
824
+			case $this->config->get('WBQualityConstraintsWikibaseFormId'):
825 825
 				$entityType = 'form';
826 826
 				break;
827
-			case $this->config->get( 'WBQualityConstraintsWikibaseSenseId' ):
827
+			case $this->config->get('WBQualityConstraintsWikibaseSenseId'):
828 828
 				$entityType = 'sense';
829 829
 				break;
830
-			case $this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ):
830
+			case $this->config->get('WBQualityConstraintsWikibaseMediaInfoId'):
831 831
 				$entityType = 'mediainfo';
832 832
 				break;
833 833
 			default:
834 834
 				$allowed = [
835
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseItemId' ) ),
836
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibasePropertyId' ) ),
837
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ) ),
838
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseFormId' ) ),
839
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseSenseId' ) ),
840
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ) ),
835
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseItemId')),
836
+					new ItemId($this->config->get('WBQualityConstraintsWikibasePropertyId')),
837
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseLexemeId')),
838
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseFormId')),
839
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseSenseId')),
840
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseMediaInfoId')),
841 841
 				];
842 842
 				throw new ConstraintParameterException(
843
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
844
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
845
-						->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
843
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
844
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
845
+						->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
846 846
 				);
847 847
 		}
848 848
 
849
-		return new EntityTypesParameter( [ $entityType ], [ $itemId ] );
849
+		return new EntityTypesParameter([$entityType], [$itemId]);
850 850
 	}
851 851
 
852 852
 	/**
@@ -855,27 +855,27 @@  discard block
 block discarded – undo
855 855
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
856 856
 	 * @return EntityTypesParameter
857 857
 	 */
858
-	public function parseEntityTypesParameter( array $constraintParameters, $constraintTypeItemId ) {
858
+	public function parseEntityTypesParameter(array $constraintParameters, $constraintTypeItemId) {
859 859
 		$entityTypes = [];
860 860
 		$entityTypeItemIds = [];
861
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
861
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
862 862
 
863
-		foreach ( $items as $item ) {
864
-			$entityType = $this->parseEntityTypeItem( $item );
865
-			$entityTypes = array_merge( $entityTypes, $entityType->getEntityTypes() );
866
-			$entityTypeItemIds = array_merge( $entityTypeItemIds, $entityType->getEntityTypeItemIds() );
863
+		foreach ($items as $item) {
864
+			$entityType = $this->parseEntityTypeItem($item);
865
+			$entityTypes = array_merge($entityTypes, $entityType->getEntityTypes());
866
+			$entityTypeItemIds = array_merge($entityTypeItemIds, $entityType->getEntityTypeItemIds());
867 867
 		}
868 868
 
869
-		if ( empty( $entityTypes ) ) {
869
+		if (empty($entityTypes)) {
870 870
 			// @codeCoverageIgnoreStart
871 871
 			throw new LogicException(
872
-				'The "entity types" parameter is required, ' .
872
+				'The "entity types" parameter is required, '.
873 873
 				'and yet we seem to be missing any allowed entity type'
874 874
 			);
875 875
 			// @codeCoverageIgnoreEnd
876 876
 		}
877 877
 
878
-		return new EntityTypesParameter( $entityTypes, $entityTypeItemIds );
878
+		return new EntityTypesParameter($entityTypes, $entityTypeItemIds);
879 879
 	}
880 880
 
881 881
 	/**
@@ -883,18 +883,18 @@  discard block
 block discarded – undo
883 883
 	 * @throws ConstraintParameterException if the parameter is invalid
884 884
 	 * @return PropertyId[]
885 885
 	 */
886
-	public function parseSeparatorsParameter( array $constraintParameters ) {
887
-		$separatorId = $this->config->get( 'WBQualityConstraintsSeparatorId' );
886
+	public function parseSeparatorsParameter(array $constraintParameters) {
887
+		$separatorId = $this->config->get('WBQualityConstraintsSeparatorId');
888 888
 
889
-		if ( !array_key_exists( $separatorId, $constraintParameters ) ) {
889
+		if (!array_key_exists($separatorId, $constraintParameters)) {
890 890
 			return [];
891 891
 		}
892 892
 
893 893
 		$parameters = $constraintParameters[$separatorId];
894 894
 		$separators = [];
895 895
 
896
-		foreach ( $parameters as $parameter ) {
897
-			$separators[] = $this->parsePropertyIdParameter( $parameter, $separatorId );
896
+		foreach ($parameters as $parameter) {
897
+			$separators[] = $this->parsePropertyIdParameter($parameter, $separatorId);
898 898
 		}
899 899
 
900 900
 		return $separators;
@@ -909,26 +909,26 @@  discard block
 block discarded – undo
909 909
 	 * @return string one of the Context::TYPE_* constants
910 910
 	 * @throws ConstraintParameterException
911 911
 	 */
912
-	private function parseContextTypeItem( ItemIdSnakValue $item, $use, $parameterId ) {
913
-		if ( !$item->isValue() ) {
912
+	private function parseContextTypeItem(ItemIdSnakValue $item, $use, $parameterId) {
913
+		if (!$item->isValue()) {
914 914
 			throw new ConstraintParameterException(
915
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
916
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
915
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
916
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
917 917
 			);
918 918
 		}
919 919
 
920
-		if ( $use === 'constraint scope' ) {
921
-			$mainSnakId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' );
922
-			$qualifiersId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' );
923
-			$referencesId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' );
920
+		if ($use === 'constraint scope') {
921
+			$mainSnakId = $this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId');
922
+			$qualifiersId = $this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId');
923
+			$referencesId = $this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId');
924 924
 		} else {
925
-			$mainSnakId = $this->config->get( 'WBQualityConstraintsAsMainValueId' );
926
-			$qualifiersId = $this->config->get( 'WBQualityConstraintsAsQualifiersId' );
927
-			$referencesId = $this->config->get( 'WBQualityConstraintsAsReferencesId' );
925
+			$mainSnakId = $this->config->get('WBQualityConstraintsAsMainValueId');
926
+			$qualifiersId = $this->config->get('WBQualityConstraintsAsQualifiersId');
927
+			$referencesId = $this->config->get('WBQualityConstraintsAsReferencesId');
928 928
 		}
929 929
 
930 930
 		$itemId = $item->getItemId();
931
-		switch ( $itemId->getSerialization() ) {
931
+		switch ($itemId->getSerialization()) {
932 932
 			case $mainSnakId:
933 933
 				return Context::TYPE_STATEMENT;
934 934
 			case $qualifiersId:
@@ -937,14 +937,14 @@  discard block
 block discarded – undo
937 937
 				return Context::TYPE_REFERENCE;
938 938
 			default:
939 939
 				$allowed = [
940
-					new ItemId( $mainSnakId ),
941
-					new ItemId( $qualifiersId ),
942
-					new ItemId( $referencesId ),
940
+					new ItemId($mainSnakId),
941
+					new ItemId($qualifiersId),
942
+					new ItemId($referencesId),
943 943
 				];
944 944
 				throw new ConstraintParameterException(
945
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
946
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
947
-						->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
945
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
946
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
947
+						->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
948 948
 				);
949 949
 		}
950 950
 	}
@@ -955,9 +955,9 @@  discard block
 block discarded – undo
955 955
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
956 956
 	 * @return string[] list of Context::TYPE_* constants
957 957
 	 */
958
-	public function parsePropertyScopeParameter( array $constraintParameters, $constraintTypeItemId ) {
958
+	public function parsePropertyScopeParameter(array $constraintParameters, $constraintTypeItemId) {
959 959
 		$contextTypes = [];
960
-		$parameterId = $this->config->get( 'WBQualityConstraintsPropertyScopeId' );
960
+		$parameterId = $this->config->get('WBQualityConstraintsPropertyScopeId');
961 961
 		$items = $this->parseItemsParameter(
962 962
 			$constraintParameters,
963 963
 			$constraintTypeItemId,
@@ -965,14 +965,14 @@  discard block
 block discarded – undo
965 965
 			$parameterId
966 966
 		);
967 967
 
968
-		foreach ( $items as $item ) {
969
-			$contextTypes[] = $this->parseContextTypeItem( $item, 'property scope', $parameterId );
968
+		foreach ($items as $item) {
969
+			$contextTypes[] = $this->parseContextTypeItem($item, 'property scope', $parameterId);
970 970
 		}
971 971
 
972
-		if ( empty( $contextTypes ) ) {
972
+		if (empty($contextTypes)) {
973 973
 			// @codeCoverageIgnoreStart
974 974
 			throw new LogicException(
975
-				'The "property scope" parameter is required, ' .
975
+				'The "property scope" parameter is required, '.
976 976
 				'and yet we seem to be missing any allowed scope'
977 977
 			);
978 978
 			// @codeCoverageIgnoreEnd
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
@@ -80,23 +80,23 @@  discard block
 block discarded – undo
80 80
 	 * @return bool
81 81
 	 * @throws OverflowException if $entitiesChecked exceeds the configured limit
82 82
 	 */
83
-	private function isSubclassOf( EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0 ) {
84
-		$maxEntities = $this->config->get( 'WBQualityConstraintsTypeCheckMaxEntities' );
83
+	private function isSubclassOf(EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0) {
84
+		$maxEntities = $this->config->get('WBQualityConstraintsTypeCheckMaxEntities');
85 85
 		if ( ++$entitiesChecked > $maxEntities ) {
86
-			throw new OverflowException( 'Too many entities to check' );
86
+			throw new OverflowException('Too many entities to check');
87 87
 		}
88 88
 
89
-		$item = $this->entityLookup->getEntity( $comparativeClass );
90
-		if ( !( $item instanceof StatementListProvider ) ) {
89
+		$item = $this->entityLookup->getEntity($comparativeClass);
90
+		if (!($item instanceof StatementListProvider)) {
91 91
 			return false; // lookup failed, probably because item doesn't exist
92 92
 		}
93 93
 
94
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
94
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfId');
95 95
 		/** @var Statement $statement */
96
-		foreach ( $item->getStatements()->getByPropertyId( new PropertyId( $subclassId ) ) as $statement ) {
96
+		foreach ($item->getStatements()->getByPropertyId(new PropertyId($subclassId)) as $statement) {
97 97
 			$mainSnak = $statement->getMainSnak();
98 98
 
99
-			if ( !( $this->hasCorrectType( $mainSnak ) ) ) {
99
+			if (!($this->hasCorrectType($mainSnak))) {
100 100
 				continue;
101 101
 			}
102 102
 			/** @var PropertyValueSnak $mainSnak */
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 			'@phan-var EntityIdValue $dataValue';
107 107
 			$comparativeClass = $dataValue->getEntityId();
108 108
 
109
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
109
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
110 110
 				return true;
111 111
 			}
112 112
 
113
-			if ( $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ) ) {
113
+			if ($this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked)) {
114 114
 				return true;
115 115
 			}
116 116
 		}
@@ -131,48 +131,48 @@  discard block
 block discarded – undo
131 131
 	 * @return CachedBool
132 132
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
133 133
 	 */
134
-	public function isSubclassOfWithSparqlFallback( EntityId $comparativeClass, array $classesToCheck ) {
134
+	public function isSubclassOfWithSparqlFallback(EntityId $comparativeClass, array $classesToCheck) {
135 135
 		try {
136 136
 			$entitiesChecked = 0;
137
-			$start1 = microtime( true );
138
-			$isSubclass = $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked );
139
-			$end1 = microtime( true );
137
+			$start1 = microtime(true);
138
+			$isSubclass = $this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked);
139
+			$end1 = microtime(true);
140 140
 			$this->dataFactory->timing(
141 141
 				'wikibase.quality.constraints.type.php.success.timing',
142
-				( $end1 - $start1 ) * 1000
142
+				($end1 - $start1) * 1000
143 143
 			);
144 144
 			$this->dataFactory->timing( // not really a timing, but works like one (we want percentiles etc.)
145 145
 				'wikibase.quality.constraints.type.php.success.entities',
146 146
 				$entitiesChecked
147 147
 			);
148 148
 
149
-			return new CachedBool( $isSubclass, Metadata::blank() );
150
-		} catch ( OverflowException $e ) {
151
-			$end1 = microtime( true );
149
+			return new CachedBool($isSubclass, Metadata::blank());
150
+		} catch (OverflowException $e) {
151
+			$end1 = microtime(true);
152 152
 			$this->dataFactory->timing(
153 153
 				'wikibase.quality.constraints.type.php.overflow.timing',
154
-				( $end1 - $start1 ) * 1000
154
+				($end1 - $start1) * 1000
155 155
 			);
156 156
 
157
-			if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) {
157
+			if (!($this->sparqlHelper instanceof DummySparqlHelper)) {
158 158
 				$this->dataFactory->increment(
159 159
 					'wikibase.quality.constraints.sparql.typeFallback'
160 160
 				);
161 161
 
162
-				$start2 = microtime( true );
162
+				$start2 = microtime(true);
163 163
 				$hasType = $this->sparqlHelper->hasType(
164 164
 					$comparativeClass->getSerialization(),
165 165
 					$classesToCheck
166 166
 				);
167
-				$end2 = microtime( true );
167
+				$end2 = microtime(true);
168 168
 				$this->dataFactory->timing(
169 169
 					'wikibase.quality.constraints.type.sparql.success.timing',
170
-					( $end2 - $start2 ) * 1000
170
+					($end2 - $start2) * 1000
171 171
 				);
172 172
 
173 173
 				return $hasType;
174 174
 			} else {
175
-				return new CachedBool( false, Metadata::blank() );
175
+				return new CachedBool(false, Metadata::blank());
176 176
 			}
177 177
 		}
178 178
 	}
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
 	 * @return CachedBool
191 191
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
192 192
 	 */
193
-	public function hasClassInRelation( StatementList $statements, array $relationIds, array $classesToCheck ) {
193
+	public function hasClassInRelation(StatementList $statements, array $relationIds, array $classesToCheck) {
194 194
 		$metadatas = [];
195 195
 
196
-		foreach ( $this->getStatementsByPropertyIds( $statements, $relationIds ) as $statement ) {
196
+		foreach ($this->getStatementsByPropertyIds($statements, $relationIds) as $statement) {
197 197
 			$mainSnak = $statement->getMainSnak();
198 198
 
199
-			if ( !$this->hasCorrectType( $mainSnak ) ) {
199
+			if (!$this->hasCorrectType($mainSnak)) {
200 200
 				continue;
201 201
 			}
202 202
 			/** @var PropertyValueSnak $mainSnak */
@@ -206,24 +206,24 @@  discard block
 block discarded – undo
206 206
 			'@phan-var EntityIdValue $dataValue';
207 207
 			$comparativeClass = $dataValue->getEntityId();
208 208
 
209
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
209
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
210 210
 				// discard $metadatas, we know this is fresh
211
-				return new CachedBool( true, Metadata::blank() );
211
+				return new CachedBool(true, Metadata::blank());
212 212
 			}
213 213
 
214
-			$result = $this->isSubclassOfWithSparqlFallback( $comparativeClass, $classesToCheck );
214
+			$result = $this->isSubclassOfWithSparqlFallback($comparativeClass, $classesToCheck);
215 215
 			$metadatas[] = $result->getMetadata();
216
-			if ( $result->getBool() ) {
216
+			if ($result->getBool()) {
217 217
 				return new CachedBool(
218 218
 					true,
219
-					Metadata::merge( $metadatas )
219
+					Metadata::merge($metadatas)
220 220
 				);
221 221
 			}
222 222
 		}
223 223
 
224 224
 		return new CachedBool(
225 225
 			false,
226
-			Metadata::merge( $metadatas )
226
+			Metadata::merge($metadatas)
227 227
 		);
228 228
 	}
229 229
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 * @return bool
233 233
 	 * @phan-assert PropertyValueSnak $mainSnak
234 234
 	 */
235
-	private function hasCorrectType( Snak $mainSnak ) {
235
+	private function hasCorrectType(Snak $mainSnak) {
236 236
 		return $mainSnak instanceof PropertyValueSnak
237 237
 			&& $mainSnak->getDataValue()->getType() === 'wikibase-entityid';
238 238
 	}
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
 	) {
250 250
 		$statementArrays = [];
251 251
 
252
-		foreach ( $propertyIdSerializations as $propertyIdSerialization ) {
253
-			$propertyId = new PropertyId( $propertyIdSerialization );
254
-			$statementArrays[] = $statements->getByPropertyId( $propertyId )->toArray();
252
+		foreach ($propertyIdSerializations as $propertyIdSerialization) {
253
+			$propertyId = new PropertyId($propertyIdSerialization);
254
+			$statementArrays[] = $statements->getByPropertyId($propertyId)->toArray();
255 255
 		}
256 256
 
257
-		return call_user_func_array( 'array_merge', $statementArrays );
257
+		return call_user_func_array('array_merge', $statementArrays);
258 258
 	}
259 259
 
260 260
 	/**
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 	 *
267 267
 	 * @return ViolationMessage
268 268
 	 */
269
-	public function getViolationMessage( PropertyId $propertyId, EntityId $entityId, array $classes, $checker, $relation ) {
269
+	public function getViolationMessage(PropertyId $propertyId, EntityId $entityId, array $classes, $checker, $relation) {
270 270
 		$classes = array_map(
271
-			function ( $itemIdSerialization ) {
272
-				return new ItemId( $itemIdSerialization );
271
+			function($itemIdSerialization) {
272
+				return new ItemId($itemIdSerialization);
273 273
 			},
274 274
 			$classes
275 275
 		);
@@ -281,10 +281,10 @@  discard block
 block discarded – undo
281 281
 		// wbqc-violation-message-valueType-instance
282 282
 		// wbqc-violation-message-valueType-subclass
283 283
 		// wbqc-violation-message-valueType-instanceOrSubclass
284
-		return ( new ViolationMessage( 'wbqc-violation-message-' . $checker . '-' . $relation ) )
285
-			->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY )
286
-			->withEntityId( $entityId, Role::SUBJECT )
287
-			->withEntityIdList( $classes, Role::OBJECT );
284
+		return (new ViolationMessage('wbqc-violation-message-'.$checker.'-'.$relation))
285
+			->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY)
286
+			->withEntityId($entityId, Role::SUBJECT)
287
+			->withEntityIdList($classes, Role::OBJECT);
288 288
 	}
289 289
 
290 290
 }
Please login to merge, or discard this patch.
src/ServiceWiring-Wikibase.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@
 block discarded – undo
8 8
 use Wikibase\Repo\WikibaseRepo;
9 9
 
10 10
 return [
11
-	WikibaseServices::ENTITY_LOOKUP => function ( MediaWikiServices $services ) {
11
+	WikibaseServices::ENTITY_LOOKUP => function(MediaWikiServices $services) {
12 12
 		return new ExceptionIgnoringEntityLookup(
13 13
 			WikibaseRepo::getDefaultInstance()->getEntityLookup()
14 14
 		);
15 15
 	},
16 16
 
17
-	WikibaseServices::ENTITY_LOOKUP_WITHOUT_CACHE => function ( MediaWikiServices $services ) {
17
+	WikibaseServices::ENTITY_LOOKUP_WITHOUT_CACHE => function(MediaWikiServices $services) {
18 18
 		return new ExceptionIgnoringEntityLookup(
19
-			WikibaseRepo::getDefaultInstance()->getEntityLookup( Store::LOOKUP_CACHING_RETRIEVE_ONLY )
19
+			WikibaseRepo::getDefaultInstance()->getEntityLookup(Store::LOOKUP_CACHING_RETRIEVE_ONLY)
20 20
 		);
21 21
 	},
22 22
 
23
-	WikibaseServices::PROPERTY_DATA_TYPE_LOOKUP => function ( MediaWikiServices $services ) {
23
+	WikibaseServices::PROPERTY_DATA_TYPE_LOOKUP => function(MediaWikiServices $services) {
24 24
 		return WikibaseRepo::getDefaultInstance()->getPropertyDataTypeLookup();
25 25
 	},
26 26
 ];
Please login to merge, or discard this patch.
src/ConstraintsServices.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -38,87 +38,87 @@
 block discarded – undo
38 38
 	public const RESULTS_SOURCE = 'WBQC_ResultsSource';
39 39
 	public const EXPIRY_LOCK = 'WBQC_ExpiryLock';
40 40
 
41
-	private static function getService( ?MediaWikiServices $services, $name ) {
42
-		if ( $services === null ) {
41
+	private static function getService(?MediaWikiServices $services, $name) {
42
+		if ($services === null) {
43 43
 			$services = MediaWikiServices::getInstance();
44 44
 		}
45
-		return $services->getService( $name );
45
+		return $services->getService($name);
46 46
 	}
47 47
 
48
-	public static function getLoggingHelper( MediaWikiServices $services = null ): LoggingHelper {
49
-		return self::getService( $services, self::LOGGING_HELPER );
48
+	public static function getLoggingHelper(MediaWikiServices $services = null): LoggingHelper {
49
+		return self::getService($services, self::LOGGING_HELPER);
50 50
 	}
51 51
 
52 52
 	public static function getConstraintStore(
53 53
 		MediaWikiServices $services = null
54 54
 	): ConstraintStore {
55
-		return self::getService( $services, self::CONSTRAINT_STORE );
55
+		return self::getService($services, self::CONSTRAINT_STORE);
56 56
 	}
57 57
 
58
-	public static function getConstraintLookup( MediaWikiServices $services = null ): ConstraintLookup {
59
-		return self::getService( $services, self::CONSTRAINT_LOOKUP );
58
+	public static function getConstraintLookup(MediaWikiServices $services = null): ConstraintLookup {
59
+		return self::getService($services, self::CONSTRAINT_LOOKUP);
60 60
 	}
61 61
 
62 62
 	public static function getCheckResultSerializer(
63 63
 		MediaWikiServices $services = null
64 64
 	): CheckResultSerializer {
65
-		return self::getService( $services, self::CHECK_RESULT_SERIALIZER );
65
+		return self::getService($services, self::CHECK_RESULT_SERIALIZER);
66 66
 	}
67 67
 
68 68
 	public static function getCheckResultDeserializer(
69 69
 		MediaWikiServices $services = null
70 70
 	): CheckResultDeserializer {
71
-		return self::getService( $services, self::CHECK_RESULT_DESERIALIZER );
71
+		return self::getService($services, self::CHECK_RESULT_DESERIALIZER);
72 72
 	}
73 73
 
74 74
 	public static function getViolationMessageSerializer(
75 75
 		MediaWikiServices $services = null
76 76
 	): ViolationMessageSerializer {
77
-		return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER );
77
+		return self::getService($services, self::VIOLATION_MESSAGE_SERIALIZER);
78 78
 	}
79 79
 
80 80
 	public static function getViolationMessageDeserializer(
81 81
 		MediaWikiServices $services = null
82 82
 	): ViolationMessageDeserializer {
83
-		return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER );
83
+		return self::getService($services, self::VIOLATION_MESSAGE_DESERIALIZER);
84 84
 	}
85 85
 
86 86
 	public static function getConstraintParameterParser(
87 87
 		MediaWikiServices $services = null
88 88
 	): ConstraintParameterParser {
89
-		return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER );
89
+		return self::getService($services, self::CONSTRAINT_PARAMETER_PARSER);
90 90
 	}
91 91
 
92 92
 	public static function getConnectionCheckerHelper(
93 93
 		MediaWikiServices $services = null
94 94
 	): ConnectionCheckerHelper {
95
-		return self::getService( $services, self::CONNECTION_CHECKER_HELPER );
95
+		return self::getService($services, self::CONNECTION_CHECKER_HELPER);
96 96
 	}
97 97
 
98
-	public static function getRangeCheckerHelper( MediaWikiServices $services = null ): RangeCheckerHelper {
99
-		return self::getService( $services, self::RANGE_CHECKER_HELPER );
98
+	public static function getRangeCheckerHelper(MediaWikiServices $services = null): RangeCheckerHelper {
99
+		return self::getService($services, self::RANGE_CHECKER_HELPER);
100 100
 	}
101 101
 
102
-	public static function getSparqlHelper( MediaWikiServices $services = null ): SparqlHelper {
103
-		return self::getService( $services, self::SPARQL_HELPER );
102
+	public static function getSparqlHelper(MediaWikiServices $services = null): SparqlHelper {
103
+		return self::getService($services, self::SPARQL_HELPER);
104 104
 	}
105 105
 
106
-	public static function getTypeCheckerHelper( MediaWikiServices $services = null ): TypeCheckerHelper {
107
-		return self::getService( $services, self::TYPE_CHECKER_HELPER );
106
+	public static function getTypeCheckerHelper(MediaWikiServices $services = null): TypeCheckerHelper {
107
+		return self::getService($services, self::TYPE_CHECKER_HELPER);
108 108
 	}
109 109
 
110 110
 	public static function getDelegatingConstraintChecker(
111 111
 		MediaWikiServices $services = null
112 112
 	): DelegatingConstraintChecker {
113
-		return self::getService( $services, self::DELEGATING_CONSTRAINT_CHECKER );
113
+		return self::getService($services, self::DELEGATING_CONSTRAINT_CHECKER);
114 114
 	}
115 115
 
116
-	public static function getResultsSource( MediaWikiServices $services = null ): ResultsSource {
117
-		return self::getService( $services, self::RESULTS_SOURCE );
116
+	public static function getResultsSource(MediaWikiServices $services = null): ResultsSource {
117
+		return self::getService($services, self::RESULTS_SOURCE);
118 118
 	}
119 119
 
120
-	public static function getExpiryLock( MediaWikiServices $services = null ): ExpiryLock {
121
-		return self::getService( $services, self::EXPIRY_LOCK );
120
+	public static function getExpiryLock(MediaWikiServices $services = null): ExpiryLock {
121
+		return self::getService($services, self::EXPIRY_LOCK);
122 122
 	}
123 123
 
124 124
 }
Please login to merge, or discard this patch.