Completed
Push — master ( 692202...e8870b )
by
unknown
05:01 queued 02:13
created
src/Specials/SpecialConstraintReport.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		Config $config,
137 137
 		IBufferingStatsdDataFactory $dataFactory
138 138
 	) {
139
-		parent::__construct( 'ConstraintReport' );
139
+		parent::__construct('ConstraintReport');
140 140
 
141 141
 		$this->entityLookup = $entityLookup;
142 142
 		$this->entityTitleLookup = $entityTitleLookup;
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 		$language = $this->getLanguage();
146 146
 
147 147
 		$formatterOptions = new FormatterOptions();
148
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
148
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
149 149
 		$this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(
150 150
 			SnakFormatter::FORMAT_HTML,
151 151
 			$formatterOptions
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * @return string
206 206
 	 */
207 207
 	public function getDescription() {
208
-		return $this->msg( 'wbqc-constraintreport' )->escaped();
208
+		return $this->msg('wbqc-constraintreport')->escaped();
209 209
 	}
210 210
 
211 211
 	/**
@@ -217,43 +217,43 @@  discard block
 block discarded – undo
217 217
 	 * @throws EntityIdParsingException
218 218
 	 * @throws UnexpectedValueException
219 219
 	 */
220
-	public function execute( $subPage ) {
220
+	public function execute($subPage) {
221 221
 		$out = $this->getOutput();
222 222
 
223
-		$postRequest = $this->getContext()->getRequest()->getVal( 'entityid' );
224
-		if ( $postRequest ) {
225
-			$out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() );
223
+		$postRequest = $this->getContext()->getRequest()->getVal('entityid');
224
+		if ($postRequest) {
225
+			$out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL());
226 226
 			return;
227 227
 		}
228 228
 
229 229
 		$out->enableOOUI();
230
-		$out->addModules( $this->getModules() );
230
+		$out->addModules($this->getModules());
231 231
 
232 232
 		$this->setHeaders();
233 233
 
234
-		$out->addHTML( $this->getExplanationText() );
234
+		$out->addHTML($this->getExplanationText());
235 235
 		$this->buildEntityIdForm();
236 236
 
237
-		if ( !$subPage ) {
237
+		if (!$subPage) {
238 238
 			return;
239 239
 		}
240 240
 
241
-		if ( !is_string( $subPage ) ) {
242
-			throw new InvalidArgumentException( '$subPage must be string.' );
241
+		if (!is_string($subPage)) {
242
+			throw new InvalidArgumentException('$subPage must be string.');
243 243
 		}
244 244
 
245 245
 		try {
246
-			$entityId = $this->entityIdParser->parse( $subPage );
247
-		} catch ( EntityIdParsingException $e ) {
246
+			$entityId = $this->entityIdParser->parse($subPage);
247
+		} catch (EntityIdParsingException $e) {
248 248
 			$out->addHTML(
249
-				$this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true )
249
+				$this->buildNotice('wbqc-constraintreport-invalid-entity-id', true)
250 250
 			);
251 251
 			return;
252 252
 		}
253 253
 
254
-		if ( !$this->entityLookup->hasEntity( $entityId ) ) {
254
+		if (!$this->entityLookup->hasEntity($entityId)) {
255 255
 			$out->addHTML(
256
-				$this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true )
256
+				$this->buildNotice('wbqc-constraintreport-not-existent-entity', true)
257 257
 			);
258 258
 			return;
259 259
 		}
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
 		$this->dataFactory->increment(
262 262
 			'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck'
263 263
 		);
264
-		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId );
264
+		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId);
265 265
 
266
-		if ( $results !== [] ) {
266
+		if ($results !== []) {
267 267
 			$out->addHTML(
268
-				$this->buildResultHeader( $entityId )
269
-				. $this->buildSummary( $results )
270
-				. $this->buildResultTable( $entityId, $results )
268
+				$this->buildResultHeader($entityId)
269
+				. $this->buildSummary($results)
270
+				. $this->buildResultTable($entityId, $results)
271 271
 			);
272 272
 		} else {
273 273
 			$out->addHTML(
274
-				$this->buildResultHeader( $entityId )
275
-				. $this->buildNotice( 'wbqc-constraintreport-empty-result' )
274
+				$this->buildResultHeader($entityId)
275
+				. $this->buildNotice('wbqc-constraintreport-empty-result')
276 276
 			);
277 277
 		}
278 278
 	}
@@ -288,15 +288,15 @@  discard block
 block discarded – undo
288 288
 				'name' => 'entityid',
289 289
 				'label-message' => 'wbqc-constraintreport-form-entityid-label',
290 290
 				'cssclass' => 'wbqc-constraintreport-form-entity-id',
291
-				'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped()
291
+				'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped()
292 292
 			]
293 293
 		];
294
-		$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' );
295
-		$htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() );
296
-		$htmlForm->setSubmitCallback( function() {
294
+		$htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form');
295
+		$htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped());
296
+		$htmlForm->setSubmitCallback(function() {
297 297
 			return false;
298 298
 		} );
299
-		$htmlForm->setMethod( 'post' );
299
+		$htmlForm->setMethod('post');
300 300
 		$htmlForm->show();
301 301
 	}
302 302
 
@@ -310,16 +310,16 @@  discard block
 block discarded – undo
310 310
 	 *
311 311
 	 * @return string HTML
312 312
 	 */
313
-	private function buildNotice( $messageKey, $error = false ) {
314
-		if ( !is_string( $messageKey ) ) {
315
-			throw new InvalidArgumentException( '$message must be string.' );
313
+	private function buildNotice($messageKey, $error = false) {
314
+		if (!is_string($messageKey)) {
315
+			throw new InvalidArgumentException('$message must be string.');
316 316
 		}
317
-		if ( !is_bool( $error ) ) {
318
-			throw new InvalidArgumentException( '$error must be bool.' );
317
+		if (!is_bool($error)) {
318
+			throw new InvalidArgumentException('$error must be bool.');
319 319
 		}
320 320
 
321 321
 		$cssClasses = 'wbqc-constraintreport-notice';
322
-		if ( $error ) {
322
+		if ($error) {
323 323
 			$cssClasses .= ' wbqc-constraintreport-notice-error';
324 324
 		}
325 325
 
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 				[
329 329
 					'class' => $cssClasses
330 330
 				],
331
-				$this->msg( $messageKey )->escaped()
331
+				$this->msg($messageKey)->escaped()
332 332
 			);
333 333
 	}
334 334
 
@@ -338,16 +338,16 @@  discard block
 block discarded – undo
338 338
 	private function getExplanationText() {
339 339
 		return Html::rawElement(
340 340
 			'div',
341
-			[ 'class' => 'wbqc-explanation' ],
341
+			['class' => 'wbqc-explanation'],
342 342
 			Html::rawElement(
343 343
 				'p',
344 344
 				[],
345
-				$this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped()
345
+				$this->msg('wbqc-constraintreport-explanation-part-one')->escaped()
346 346
 			)
347 347
 			. Html::rawElement(
348 348
 				'p',
349 349
 				[],
350
-				$this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped()
350
+				$this->msg('wbqc-constraintreport-explanation-part-two')->escaped()
351 351
 			)
352 352
 		);
353 353
 	}
@@ -358,72 +358,72 @@  discard block
 block discarded – undo
358 358
 	 *
359 359
 	 * @return string HTML
360 360
 	 */
361
-	private function buildResultTable( EntityId $entityId, array $results ) {
361
+	private function buildResultTable(EntityId $entityId, array $results) {
362 362
 		// Set table headers
363 363
 		$table = new HtmlTableBuilder(
364 364
 			[
365 365
 				new HtmlTableHeaderBuilder(
366
-					$this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(),
366
+					$this->msg('wbqc-constraintreport-result-table-header-status')->escaped(),
367 367
 					true
368 368
 				),
369 369
 				new HtmlTableHeaderBuilder(
370
-					$this->msg( 'wbqc-constraintreport-result-table-header-property' )->escaped(),
370
+					$this->msg('wbqc-constraintreport-result-table-header-property')->escaped(),
371 371
 					true
372 372
 				),
373 373
 				new HtmlTableHeaderBuilder(
374
-					$this->msg( 'wbqc-constraintreport-result-table-header-message' )->escaped(),
374
+					$this->msg('wbqc-constraintreport-result-table-header-message')->escaped(),
375 375
 					true
376 376
 				),
377 377
 				new HtmlTableHeaderBuilder(
378
-					$this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(),
378
+					$this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(),
379 379
 					true
380 380
 				)
381 381
 			]
382 382
 		);
383 383
 
384
-		foreach ( $results as $result ) {
385
-			$table = $this->appendToResultTable( $table, $entityId, $result );
384
+		foreach ($results as $result) {
385
+			$table = $this->appendToResultTable($table, $entityId, $result);
386 386
 		}
387 387
 
388 388
 		return $table->toHtml();
389 389
 	}
390 390
 
391
-	private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) {
391
+	private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) {
392 392
 		$message = $result->getMessage();
393
-		if ( $message === null ) {
393
+		if ($message === null) {
394 394
 			// no row for this result
395 395
 			return $table;
396 396
 		}
397 397
 
398 398
 		// Status column
399
-		$statusColumn = $this->formatStatus( $result->getStatus() );
399
+		$statusColumn = $this->formatStatus($result->getStatus());
400 400
 
401 401
 		// Property column
402
-		$propertyId = new PropertyId( $result->getContextCursor()->getSnakPropertyId() );
402
+		$propertyId = new PropertyId($result->getContextCursor()->getSnakPropertyId());
403 403
 		$propertyColumn = $this->getClaimLink(
404 404
 			$entityId,
405 405
 			$propertyId,
406
-			$this->entityIdLabelFormatter->formatEntityId( $propertyId )
406
+			$this->entityIdLabelFormatter->formatEntityId($propertyId)
407 407
 		);
408 408
 
409 409
 		// Message column
410
-		$messageColumn = $this->violationMessageRenderer->render( $message );
410
+		$messageColumn = $this->violationMessageRenderer->render($message);
411 411
 
412 412
 		// Constraint column
413 413
 		$constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId();
414 414
 		try {
415
-			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) );
416
-		} catch ( InvalidArgumentException $e ) {
417
-			$constraintTypeLabel = htmlspecialchars( $constraintTypeItemId );
415
+			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId));
416
+		} catch (InvalidArgumentException $e) {
417
+			$constraintTypeLabel = htmlspecialchars($constraintTypeItemId);
418 418
 		}
419 419
 		$constraintLink = $this->getClaimLink(
420 420
 			$propertyId,
421
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ),
421
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')),
422 422
 			$constraintTypeLabel
423 423
 		);
424 424
 		$constraintColumn = $this->buildExpandableElement(
425 425
 			$constraintLink,
426
-			$this->constraintParameterRenderer->formatParameters( $result->getParameters() ),
426
+			$this->constraintParameterRenderer->formatParameters($result->getParameters()),
427 427
 			'[...]'
428 428
 		);
429 429
 
@@ -463,15 +463,15 @@  discard block
 block discarded – undo
463 463
 	 *
464 464
 	 * @return string HTML
465 465
 	 */
466
-	protected function buildResultHeader( EntityId $entityId ) {
467
-		$entityLink = sprintf( '%s (%s)',
468
-							   $this->entityIdLinkFormatter->formatEntityId( $entityId ),
469
-							   htmlspecialchars( $entityId->getSerialization() ) );
466
+	protected function buildResultHeader(EntityId $entityId) {
467
+		$entityLink = sprintf('%s (%s)',
468
+							   $this->entityIdLinkFormatter->formatEntityId($entityId),
469
+							   htmlspecialchars($entityId->getSerialization()));
470 470
 
471 471
 		return Html::rawElement(
472 472
 			'h3',
473 473
 			[],
474
-			sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
474
+			sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink)
475 475
 		);
476 476
 	}
477 477
 
@@ -482,24 +482,24 @@  discard block
 block discarded – undo
482 482
 	 *
483 483
 	 * @return string HTML
484 484
 	 */
485
-	protected function buildSummary( array $results ) {
485
+	protected function buildSummary(array $results) {
486 486
 		$statuses = [];
487
-		foreach ( $results as $result ) {
488
-			$status = strtolower( $result->getStatus() );
489
-			$statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1;
487
+		foreach ($results as $result) {
488
+			$status = strtolower($result->getStatus());
489
+			$statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1;
490 490
 		}
491 491
 
492 492
 		$statusElements = [];
493
-		foreach ( $statuses as $status => $count ) {
494
-			if ( $count > 0 ) {
493
+		foreach ($statuses as $status => $count) {
494
+			if ($count > 0) {
495 495
 				$statusElements[] =
496
-					$this->formatStatus( $status )
496
+					$this->formatStatus($status)
497 497
 					. ': '
498 498
 					. $count;
499 499
 			}
500 500
 		}
501 501
 
502
-		return Html::rawElement( 'p', [], implode( ', ', $statusElements ) );
502
+		return Html::rawElement('p', [], implode(', ', $statusElements));
503 503
 	}
504 504
 
505 505
 	/**
@@ -514,15 +514,15 @@  discard block
 block discarded – undo
514 514
 	 *
515 515
 	 * @return string HTML
516 516
 	 */
517
-	protected function buildExpandableElement( $content, $expandableContent, $indicator ) {
518
-		if ( !is_string( $content ) ) {
519
-			throw new InvalidArgumentException( '$content has to be string.' );
517
+	protected function buildExpandableElement($content, $expandableContent, $indicator) {
518
+		if (!is_string($content)) {
519
+			throw new InvalidArgumentException('$content has to be string.');
520 520
 		}
521
-		if ( $expandableContent && ( !is_string( $expandableContent ) ) ) {
522
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
521
+		if ($expandableContent && (!is_string($expandableContent))) {
522
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
523 523
 		}
524 524
 
525
-		if ( empty( $expandableContent ) ) {
525
+		if (empty($expandableContent)) {
526 526
 			return $content;
527 527
 		}
528 528
 
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 			$expandableContent
543 543
 		);
544 544
 
545
-		return sprintf( '%s %s %s', $content, $tooltipIndicator, $expandableContent );
545
+		return sprintf('%s %s %s', $content, $tooltipIndicator, $expandableContent);
546 546
 	}
547 547
 
548 548
 	/**
@@ -554,8 +554,8 @@  discard block
 block discarded – undo
554 554
 	 *
555 555
 	 * @return string HTML
556 556
 	 */
557
-	private function formatStatus( $status ) {
558
-		$messageName = "wbqc-constraintreport-status-" . strtolower( $status );
557
+	private function formatStatus($status) {
558
+		$messageName = "wbqc-constraintreport-status-".strtolower($status);
559 559
 		$statusIcons = [
560 560
 			CheckResult::STATUS_WARNING => [
561 561
 				'icon' => 'non-mandatory-constraint-violation',
@@ -569,25 +569,25 @@  discard block
 block discarded – undo
569 569
 			],
570 570
 		];
571 571
 
572
-		if ( array_key_exists( $status, $statusIcons ) ) {
573
-			$iconWidget = new IconWidget( $statusIcons[$status] );
574
-			$iconHtml = $iconWidget->toString() . ' ';
572
+		if (array_key_exists($status, $statusIcons)) {
573
+			$iconWidget = new IconWidget($statusIcons[$status]);
574
+			$iconHtml = $iconWidget->toString().' ';
575 575
 		} else {
576 576
 			$iconHtml = '';
577 577
 		}
578 578
 
579
-		$labelWidget = new LabelWidget( [
580
-			'label' => $this->msg( $messageName )->text(),
581
-		] );
579
+		$labelWidget = new LabelWidget([
580
+			'label' => $this->msg($messageName)->text(),
581
+		]);
582 582
 		$labelHtml = $labelWidget->toString();
583 583
 
584 584
 		$formattedStatus =
585 585
 			Html::rawElement(
586 586
 				'span',
587 587
 				[
588
-					'class' => 'wbqc-status wbqc-status-' . $status
588
+					'class' => 'wbqc-status wbqc-status-'.$status
589 589
 				],
590
-				$iconHtml . $labelHtml
590
+				$iconHtml.$labelHtml
591 591
 			);
592 592
 
593 593
 		return $formattedStatus;
@@ -603,26 +603,26 @@  discard block
 block discarded – undo
603 603
 	 *
604 604
 	 * @return string HTML
605 605
 	 */
606
-	protected function formatDataValues( $dataValues, $separator = ', ' ) {
607
-		if ( $dataValues instanceof DataValue ) {
608
-			$dataValues = [ $dataValues ];
609
-		} elseif ( !is_array( $dataValues ) ) {
610
-			throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
606
+	protected function formatDataValues($dataValues, $separator = ', ') {
607
+		if ($dataValues instanceof DataValue) {
608
+			$dataValues = [$dataValues];
609
+		} elseif (!is_array($dataValues)) {
610
+			throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
611 611
 		}
612 612
 
613 613
 		$formattedDataValues = [];
614
-		foreach ( $dataValues as $dataValue ) {
615
-			if ( !( $dataValue instanceof DataValue ) ) {
616
-				throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
614
+		foreach ($dataValues as $dataValue) {
615
+			if (!($dataValue instanceof DataValue)) {
616
+				throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
617 617
 			}
618
-			if ( $dataValue instanceof EntityIdValue ) {
619
-				$formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() );
618
+			if ($dataValue instanceof EntityIdValue) {
619
+				$formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId());
620 620
 			} else {
621
-				$formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue );
621
+				$formattedDataValues[] = $this->dataValueFormatter->format($dataValue);
622 622
 			}
623 623
 		}
624 624
 
625
-		return implode( $separator, $formattedDataValues );
625
+		return implode($separator, $formattedDataValues);
626 626
 	}
627 627
 
628 628
 	/**
@@ -634,11 +634,11 @@  discard block
 block discarded – undo
634 634
 	 *
635 635
 	 * @return string HTML
636 636
 	 */
637
-	private function getClaimLink( EntityId $entityId, PropertyId $propertyId, $text ) {
637
+	private function getClaimLink(EntityId $entityId, PropertyId $propertyId, $text) {
638 638
 		return Html::rawElement(
639 639
 			'a',
640 640
 			[
641
-				'href' => $this->getClaimUrl( $entityId, $propertyId ),
641
+				'href' => $this->getClaimUrl($entityId, $propertyId),
642 642
 				'target' => '_blank'
643 643
 			],
644 644
 			$text
@@ -653,9 +653,9 @@  discard block
 block discarded – undo
653 653
 	 *
654 654
 	 * @return string
655 655
 	 */
656
-	private function getClaimUrl( EntityId $entityId, PropertyId $propertyId ) {
657
-		$title = $this->entityTitleLookup->getTitleForId( $entityId );
658
-		$entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() );
656
+	private function getClaimUrl(EntityId $entityId, PropertyId $propertyId) {
657
+		$title = $this->entityTitleLookup->getTitleForId($entityId);
658
+		$entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization());
659 659
 
660 660
 		return $entityUrl;
661 661
 	}
Please login to merge, or discard this patch.
src/WikibaseServices.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -19,27 +19,27 @@
 block discarded – undo
19 19
 	const ENTITY_LOOKUP = 'WBQC_EntityLookup';
20 20
 	const PROPERTY_DATA_TYPE_LOOKUP = 'WBQC_PropertyDataTypeLookup';
21 21
 
22
-	private static function getService( MediaWikiServices $services = null, $name ) {
23
-		if ( $services === null ) {
22
+	private static function getService(MediaWikiServices $services = null, $name) {
23
+		if ($services === null) {
24 24
 			$services = MediaWikiServices::getInstance();
25 25
 		}
26
-		return $services->getService( $name );
26
+		return $services->getService($name);
27 27
 	}
28 28
 
29 29
 	/**
30 30
 	 * @param MediaWikiServices|null $services
31 31
 	 * @return EntityLookup
32 32
 	 */
33
-	public static function getEntityLookup( MediaWikiServices $services = null ) {
34
-		return self::getService( $services, self::ENTITY_LOOKUP );
33
+	public static function getEntityLookup(MediaWikiServices $services = null) {
34
+		return self::getService($services, self::ENTITY_LOOKUP);
35 35
 	}
36 36
 
37 37
 	/**
38 38
 	 * @param MediaWikiServices|null $services
39 39
 	 * @return PropertyDataTypeLookup
40 40
 	 */
41
-	public static function getPropertyDataTypeLookup( MediaWikiServices $services = null ) {
42
-		return self::getService( $services, self::PROPERTY_DATA_TYPE_LOOKUP );
41
+	public static function getPropertyDataTypeLookup(MediaWikiServices $services = null) {
42
+		return self::getService($services, self::PROPERTY_DATA_TYPE_LOOKUP);
43 43
 	}
44 44
 
45 45
 }
Please login to merge, or discard this patch.
src/ConstraintCheckerServices.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -39,243 +39,243 @@
 block discarded – undo
39 39
 	const PROPERTY_SCOPE_CHECKER = 'WBQC_PropertyScopeChecker';
40 40
 	const CONTEMPORARY_CHECKER = 'WBQC_ContemporaryChecker';
41 41
 
42
-	private static function getService( MediaWikiServices $services = null, $name ) {
43
-		if ( $services === null ) {
42
+	private static function getService(MediaWikiServices $services = null, $name) {
43
+		if ($services === null) {
44 44
 			$services = MediaWikiServices::getInstance();
45 45
 		}
46
-		return $services->getService( $name );
46
+		return $services->getService($name);
47 47
 	}
48 48
 
49 49
 	/**
50 50
 	 * @param MediaWikiServices|null $services
51 51
 	 * @return ConstraintChecker
52 52
 	 */
53
-	public static function getConflictsWithChecker( MediaWikiServices $services = null ) {
54
-		return self::getService( $services, self::CONFLICTS_WITH_CHECKER );
53
+	public static function getConflictsWithChecker(MediaWikiServices $services = null) {
54
+		return self::getService($services, self::CONFLICTS_WITH_CHECKER);
55 55
 	}
56 56
 
57 57
 	/**
58 58
 	 * @param MediaWikiServices|null $services
59 59
 	 * @return ConstraintChecker
60 60
 	 */
61
-	public static function getItemChecker( MediaWikiServices $services = null ) {
62
-		return self::getService( $services, self::ITEM_CHECKER );
61
+	public static function getItemChecker(MediaWikiServices $services = null) {
62
+		return self::getService($services, self::ITEM_CHECKER);
63 63
 	}
64 64
 
65 65
 	/**
66 66
 	 * @param MediaWikiServices|null $services
67 67
 	 * @return ConstraintChecker
68 68
 	 */
69
-	public static function getTargetRequiredClaimChecker( MediaWikiServices $services = null ) {
70
-		return self::getService( $services, self::TARGET_REQUIRED_CLAIM_CHECKER );
69
+	public static function getTargetRequiredClaimChecker(MediaWikiServices $services = null) {
70
+		return self::getService($services, self::TARGET_REQUIRED_CLAIM_CHECKER);
71 71
 	}
72 72
 
73 73
 	/**
74 74
 	 * @param MediaWikiServices|null $services
75 75
 	 * @return ConstraintChecker
76 76
 	 */
77
-	public static function getSymmetricChecker( MediaWikiServices $services = null ) {
78
-		return self::getService( $services, self::SYMMETRIC_CHECKER );
77
+	public static function getSymmetricChecker(MediaWikiServices $services = null) {
78
+		return self::getService($services, self::SYMMETRIC_CHECKER);
79 79
 	}
80 80
 
81 81
 	/**
82 82
 	 * @param MediaWikiServices|null $services
83 83
 	 * @return ConstraintChecker
84 84
 	 */
85
-	public static function getInverseChecker( MediaWikiServices $services = null ) {
86
-		return self::getService( $services, self::INVERSE_CHECKER );
85
+	public static function getInverseChecker(MediaWikiServices $services = null) {
86
+		return self::getService($services, self::INVERSE_CHECKER);
87 87
 	}
88 88
 
89 89
 	/**
90 90
 	 * @param MediaWikiServices|null $services
91 91
 	 * @return ConstraintChecker
92 92
 	 */
93
-	public static function getQualifierChecker( MediaWikiServices $services = null ) {
94
-		return self::getService( $services, self::QUALIFIER_CHECKER );
93
+	public static function getQualifierChecker(MediaWikiServices $services = null) {
94
+		return self::getService($services, self::QUALIFIER_CHECKER);
95 95
 	}
96 96
 
97 97
 	/**
98 98
 	 * @param MediaWikiServices|null $services
99 99
 	 * @return ConstraintChecker
100 100
 	 */
101
-	public static function getQualifiersChecker( MediaWikiServices $services = null ) {
102
-		return self::getService( $services, self::QUALIFIERS_CHECKER );
101
+	public static function getQualifiersChecker(MediaWikiServices $services = null) {
102
+		return self::getService($services, self::QUALIFIERS_CHECKER);
103 103
 	}
104 104
 
105 105
 	/**
106 106
 	 * @param MediaWikiServices|null $services
107 107
 	 * @return ConstraintChecker
108 108
 	 */
109
-	public static function getMandatoryQualifiersChecker( MediaWikiServices $services = null ) {
110
-		return self::getService( $services, self::MANDATORY_QUALIFIERS_CHECKER );
109
+	public static function getMandatoryQualifiersChecker(MediaWikiServices $services = null) {
110
+		return self::getService($services, self::MANDATORY_QUALIFIERS_CHECKER);
111 111
 	}
112 112
 
113 113
 	/**
114 114
 	 * @param MediaWikiServices|null $services
115 115
 	 * @return ConstraintChecker
116 116
 	 */
117
-	public static function getRangeChecker( MediaWikiServices $services = null ) {
118
-		return self::getService( $services, self::RANGE_CHECKER );
117
+	public static function getRangeChecker(MediaWikiServices $services = null) {
118
+		return self::getService($services, self::RANGE_CHECKER);
119 119
 	}
120 120
 
121 121
 	/**
122 122
 	 * @param MediaWikiServices|null $services
123 123
 	 * @return ConstraintChecker
124 124
 	 */
125
-	public static function getDiffWithinRangeChecker( MediaWikiServices $services = null ) {
126
-		return self::getService( $services, self::DIFF_WITHIN_RANGE_CHECKER );
125
+	public static function getDiffWithinRangeChecker(MediaWikiServices $services = null) {
126
+		return self::getService($services, self::DIFF_WITHIN_RANGE_CHECKER);
127 127
 	}
128 128
 
129 129
 	/**
130 130
 	 * @param MediaWikiServices|null $services
131 131
 	 * @return ConstraintChecker
132 132
 	 */
133
-	public static function getTypeChecker( MediaWikiServices $services = null ) {
134
-		return self::getService( $services, self::TYPE_CHECKER );
133
+	public static function getTypeChecker(MediaWikiServices $services = null) {
134
+		return self::getService($services, self::TYPE_CHECKER);
135 135
 	}
136 136
 
137 137
 	/**
138 138
 	 * @param MediaWikiServices|null $services
139 139
 	 * @return ConstraintChecker
140 140
 	 */
141
-	public static function getValueTypeChecker( MediaWikiServices $services = null ) {
142
-		return self::getService( $services, self::VALUE_TYPE_CHECKER );
141
+	public static function getValueTypeChecker(MediaWikiServices $services = null) {
142
+		return self::getService($services, self::VALUE_TYPE_CHECKER);
143 143
 	}
144 144
 
145 145
 	/**
146 146
 	 * @param MediaWikiServices|null $services
147 147
 	 * @return ConstraintChecker
148 148
 	 */
149
-	public static function getSingleValueChecker( MediaWikiServices $services = null ) {
150
-		return self::getService( $services, self::SINGLE_VALUE_CHECKER );
149
+	public static function getSingleValueChecker(MediaWikiServices $services = null) {
150
+		return self::getService($services, self::SINGLE_VALUE_CHECKER);
151 151
 	}
152 152
 
153 153
 	/**
154 154
 	 * @param MediaWikiServices|null $services
155 155
 	 * @return ConstraintChecker
156 156
 	 */
157
-	public static function getMultiValueChecker( MediaWikiServices $services = null ) {
158
-		return self::getService( $services, self::MULTI_VALUE_CHECKER );
157
+	public static function getMultiValueChecker(MediaWikiServices $services = null) {
158
+		return self::getService($services, self::MULTI_VALUE_CHECKER);
159 159
 	}
160 160
 
161 161
 	/**
162 162
 	 * @param MediaWikiServices|null $services
163 163
 	 * @return ConstraintChecker
164 164
 	 */
165
-	public static function getUniqueValueChecker( MediaWikiServices $services = null ) {
166
-		return self::getService( $services, self::UNIQUE_VALUE_CHECKER );
165
+	public static function getUniqueValueChecker(MediaWikiServices $services = null) {
166
+		return self::getService($services, self::UNIQUE_VALUE_CHECKER);
167 167
 	}
168 168
 
169 169
 	/**
170 170
 	 * @param MediaWikiServices|null $services
171 171
 	 * @return ConstraintChecker
172 172
 	 */
173
-	public static function getFormatChecker( MediaWikiServices $services = null ) {
174
-		return self::getService( $services, self::FORMAT_CHECKER );
173
+	public static function getFormatChecker(MediaWikiServices $services = null) {
174
+		return self::getService($services, self::FORMAT_CHECKER);
175 175
 	}
176 176
 
177 177
 	/**
178 178
 	 * @param MediaWikiServices|null $services
179 179
 	 * @return ConstraintChecker
180 180
 	 */
181
-	public static function getCommonsLinkChecker( MediaWikiServices $services = null ) {
182
-		return self::getService( $services, self::COMMONS_LINK_CHECKER );
181
+	public static function getCommonsLinkChecker(MediaWikiServices $services = null) {
182
+		return self::getService($services, self::COMMONS_LINK_CHECKER);
183 183
 	}
184 184
 
185 185
 	/**
186 186
 	 * @param MediaWikiServices|null $services
187 187
 	 * @return ConstraintChecker
188 188
 	 */
189
-	public static function getOneOfChecker( MediaWikiServices $services = null ) {
190
-		return self::getService( $services, self::ONE_OF_CHECKER );
189
+	public static function getOneOfChecker(MediaWikiServices $services = null) {
190
+		return self::getService($services, self::ONE_OF_CHECKER);
191 191
 	}
192 192
 
193 193
 	/**
194 194
 	 * @param MediaWikiServices|null $services
195 195
 	 * @return ConstraintChecker
196 196
 	 */
197
-	public static function getValueOnlyChecker( MediaWikiServices $services = null ) {
198
-		return self::getService( $services, self::VALUE_ONLY_CHECKER );
197
+	public static function getValueOnlyChecker(MediaWikiServices $services = null) {
198
+		return self::getService($services, self::VALUE_ONLY_CHECKER);
199 199
 	}
200 200
 
201 201
 	/**
202 202
 	 * @param MediaWikiServices|null $services
203 203
 	 * @return ConstraintChecker
204 204
 	 */
205
-	public static function getReferenceChecker( MediaWikiServices $services = null ) {
206
-		return self::getService( $services, self::REFERENCE_CHECKER );
205
+	public static function getReferenceChecker(MediaWikiServices $services = null) {
206
+		return self::getService($services, self::REFERENCE_CHECKER);
207 207
 	}
208 208
 
209 209
 	/**
210 210
 	 * @param MediaWikiServices|null $services
211 211
 	 * @return ConstraintChecker
212 212
 	 */
213
-	public static function getNoBoundsChecker( MediaWikiServices $services = null ) {
214
-		return self::getService( $services, self::NO_BOUNDS_CHECKER );
213
+	public static function getNoBoundsChecker(MediaWikiServices $services = null) {
214
+		return self::getService($services, self::NO_BOUNDS_CHECKER);
215 215
 	}
216 216
 
217 217
 	/**
218 218
 	 * @param MediaWikiServices|null $services
219 219
 	 * @return ConstraintChecker
220 220
 	 */
221
-	public static function getAllowedUnitsChecker( MediaWikiServices $services = null ) {
222
-		return self::getService( $services, self::ALLOWED_UNITS_CHECKER );
221
+	public static function getAllowedUnitsChecker(MediaWikiServices $services = null) {
222
+		return self::getService($services, self::ALLOWED_UNITS_CHECKER);
223 223
 	}
224 224
 
225 225
 	/**
226 226
 	 * @param MediaWikiServices|null $services
227 227
 	 * @return ConstraintChecker
228 228
 	 */
229
-	public static function getSingleBestValueChecker( MediaWikiServices $services = null ) {
230
-		return self::getService( $services, self::SINGLE_BEST_VALUE_CHECKER );
229
+	public static function getSingleBestValueChecker(MediaWikiServices $services = null) {
230
+		return self::getService($services, self::SINGLE_BEST_VALUE_CHECKER);
231 231
 	}
232 232
 
233 233
 	/**
234 234
 	 * @param MediaWikiServices|null $services
235 235
 	 * @return ConstraintChecker
236 236
 	 */
237
-	public static function getEntityTypeChecker( MediaWikiServices $services = null ) {
238
-		return self::getService( $services, self::ENTITY_TYPE_CHECKER );
237
+	public static function getEntityTypeChecker(MediaWikiServices $services = null) {
238
+		return self::getService($services, self::ENTITY_TYPE_CHECKER);
239 239
 	}
240 240
 
241 241
 	/**
242 242
 	 * @param MediaWikiServices|null $services
243 243
 	 * @return ConstraintChecker
244 244
 	 */
245
-	public static function getNoneOfChecker( MediaWikiServices $services = null ) {
246
-		return self::getService( $services, self::NONE_OF_CHECKER );
245
+	public static function getNoneOfChecker(MediaWikiServices $services = null) {
246
+		return self::getService($services, self::NONE_OF_CHECKER);
247 247
 	}
248 248
 
249 249
 	/**
250 250
 	 * @param MediaWikiServices|null $services
251 251
 	 * @return ConstraintChecker
252 252
 	 */
253
-	public static function getIntegerChecker( MediaWikiServices $services = null ) {
254
-		return self::getService( $services, self::INTEGER_CHECKER );
253
+	public static function getIntegerChecker(MediaWikiServices $services = null) {
254
+		return self::getService($services, self::INTEGER_CHECKER);
255 255
 	}
256 256
 
257 257
 	/**
258 258
 	 * @param MediaWikiServices|null $services
259 259
 	 * @return ConstraintChecker
260 260
 	 */
261
-	public static function getCitationNeededChecker( MediaWikiServices $services = null ) {
262
-		return self::getService( $services, self::CITATION_NEEDED_CHECKER );
261
+	public static function getCitationNeededChecker(MediaWikiServices $services = null) {
262
+		return self::getService($services, self::CITATION_NEEDED_CHECKER);
263 263
 	}
264 264
 
265 265
 	/**
266 266
 	 * @param MediaWikiServices|null $services
267 267
 	 * @return ConstraintChecker
268 268
 	 */
269
-	public static function getPropertyScopeChecker( MediaWikiServices $services = null ) {
270
-		return self::getService( $services, self::PROPERTY_SCOPE_CHECKER );
269
+	public static function getPropertyScopeChecker(MediaWikiServices $services = null) {
270
+		return self::getService($services, self::PROPERTY_SCOPE_CHECKER);
271 271
 	}
272 272
 
273 273
 	/**
274 274
 	 * @param MediaWikiServices|null $services
275 275
 	 * @return ConstraintChecker
276 276
 	 */
277
-	public static function getContemporaryChecker( MediaWikiServices $services = null ) {
278
-		return self::getService( $services, self::CONTEMPORARY_CHECKER );
277
+	public static function getContemporaryChecker(MediaWikiServices $services = null) {
278
+		return self::getService($services, self::CONTEMPORARY_CHECKER);
279 279
 	}
280 280
 
281 281
 }
Please login to merge, or discard this patch.
src/ServiceWiring-Wikibase.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,11 +6,11 @@
 block discarded – undo
6 6
 use Wikibase\Repo\WikibaseRepo;
7 7
 
8 8
 return [
9
-	WikibaseServices::ENTITY_LOOKUP => function( MediaWikiServices $services ) {
9
+	WikibaseServices::ENTITY_LOOKUP => function(MediaWikiServices $services) {
10 10
 		return WikibaseRepo::getDefaultInstance()->getEntityLookup();
11 11
 	},
12 12
 
13
-	WikibaseServices::PROPERTY_DATA_TYPE_LOOKUP => function( MediaWikiServices $services ) {
13
+	WikibaseServices::PROPERTY_DATA_TYPE_LOOKUP => function(MediaWikiServices $services) {
14 14
 		return WikibaseRepo::getDefaultInstance()->getPropertyDataTypeLookup();
15 15
 	},
16 16
 ];
Please login to merge, or discard this patch.
src/Api/CheckConstraintParameters.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -74,17 +74,17 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return self
76 76
 	 */
77
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
77
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
78 78
 		$repo = WikibaseRepo::getDefaultInstance();
79
-		$helperFactory = $repo->getApiHelperFactory( RequestContext::getMain() );
79
+		$helperFactory = $repo->getApiHelperFactory(RequestContext::getMain());
80 80
 		$language = $repo->getUserLanguage();
81 81
 
82 82
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
83
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language );
83
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language);
84 84
 		$formatterOptions = new FormatterOptions();
85
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
85
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
86 86
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
87
-		$dataValueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
87
+		$dataValueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
88 88
 		$config = MediaWikiServices::getInstance()->getMainConfig();
89 89
 		$violationMessageRenderer = new MultilingualTextViolationMessageRenderer(
90 90
 			$entityIdHtmlLinkFormatter,
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 		StatementGuidParser $statementGuidParser,
125 125
 		IBufferingStatsdDataFactory $dataFactory
126 126
 	) {
127
-		parent::__construct( $main, $name, $prefix );
127
+		parent::__construct($main, $name, $prefix);
128 128
 
129
-		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this );
129
+		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this);
130 130
 		$this->delegatingConstraintChecker = $delegatingConstraintChecker;
131 131
 		$this->violationMessageRenderer = $violationMessageRenderer;
132 132
 		$this->statementGuidParser = $statementGuidParser;
@@ -141,39 +141,39 @@  discard block
 block discarded – undo
141 141
 		$params = $this->extractRequestParams();
142 142
 		$result = $this->getResult();
143 143
 
144
-		$propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] );
145
-		$constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] );
144
+		$propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]);
145
+		$constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]);
146 146
 
147
-		$this->checkPropertyIds( $propertyIds, $result );
148
-		$this->checkConstraintIds( $constraintIds, $result );
147
+		$this->checkPropertyIds($propertyIds, $result);
148
+		$this->checkConstraintIds($constraintIds, $result);
149 149
 
150
-		$result->addValue( null, 'success', 1 );
150
+		$result->addValue(null, 'success', 1);
151 151
 	}
152 152
 
153 153
 	/**
154 154
 	 * @param array|null $propertyIdSerializations
155 155
 	 * @return PropertyId[]
156 156
 	 */
157
-	private function parsePropertyIds( $propertyIdSerializations ) {
158
-		if ( $propertyIdSerializations === null ) {
157
+	private function parsePropertyIds($propertyIdSerializations) {
158
+		if ($propertyIdSerializations === null) {
159 159
 			return [];
160
-		} elseif ( empty( $propertyIdSerializations ) ) {
160
+		} elseif (empty($propertyIdSerializations)) {
161 161
 			$this->apiErrorReporter->dieError(
162
-				'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.',
162
+				'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.',
163 163
 				'no-data'
164 164
 			);
165 165
 		}
166 166
 
167 167
 		return array_map(
168
-			function( $propertyIdSerialization ) {
168
+			function($propertyIdSerialization) {
169 169
 				try {
170
-					return new PropertyId( $propertyIdSerialization );
171
-				} catch ( InvalidArgumentException $e ) {
170
+					return new PropertyId($propertyIdSerialization);
171
+				} catch (InvalidArgumentException $e) {
172 172
 					$this->apiErrorReporter->dieError(
173 173
 						"Invalid id: $propertyIdSerialization",
174 174
 						'invalid-property-id',
175 175
 						0, // default argument
176
-						[ self::PARAM_PROPERTY_ID => $propertyIdSerialization ]
176
+						[self::PARAM_PROPERTY_ID => $propertyIdSerialization]
177 177
 					);
178 178
 				}
179 179
 			},
@@ -185,35 +185,35 @@  discard block
 block discarded – undo
185 185
 	 * @param array|null $constraintIds
186 186
 	 * @return string[]
187 187
 	 */
188
-	private function parseConstraintIds( $constraintIds ) {
189
-		if ( $constraintIds === null ) {
188
+	private function parseConstraintIds($constraintIds) {
189
+		if ($constraintIds === null) {
190 190
 			return [];
191
-		} elseif ( empty( $constraintIds ) ) {
191
+		} elseif (empty($constraintIds)) {
192 192
 			$this->apiErrorReporter->dieError(
193
-				'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.',
193
+				'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.',
194 194
 				'no-data'
195 195
 			);
196 196
 		}
197 197
 
198 198
 		return array_map(
199
-			function( $constraintId ) {
199
+			function($constraintId) {
200 200
 				try {
201
-					$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
202
-					if ( !$propertyId instanceof PropertyId ) {
201
+					$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
202
+					if (!$propertyId instanceof PropertyId) {
203 203
 						$this->apiErrorReporter->dieError(
204 204
 							"Invalid property ID: {$propertyId->getSerialization()}",
205 205
 							'invalid-property-id',
206 206
 							0, // default argument
207
-							[ self::PARAM_CONSTRAINT_ID => $constraintId ]
207
+							[self::PARAM_CONSTRAINT_ID => $constraintId]
208 208
 						);
209 209
 					}
210 210
 					return $constraintId;
211
-				} catch ( StatementGuidParsingException $e ) {
211
+				} catch (StatementGuidParsingException $e) {
212 212
 					$this->apiErrorReporter->dieError(
213 213
 						"Invalid statement GUID: $constraintId",
214 214
 						'invalid-guid',
215 215
 						0, // default argument
216
-						[ self::PARAM_CONSTRAINT_ID => $constraintId ]
216
+						[self::PARAM_CONSTRAINT_ID => $constraintId]
217 217
 					);
218 218
 				}
219 219
 			},
@@ -225,12 +225,12 @@  discard block
 block discarded – undo
225 225
 	 * @param PropertyId[] $propertyIds
226 226
 	 * @param ApiResult $result
227 227
 	 */
228
-	private function checkPropertyIds( array $propertyIds, ApiResult $result ) {
229
-		foreach ( $propertyIds as $propertyId ) {
230
-			$result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' );
231
-			$allConstraintExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnPropertyId( $propertyId );
232
-			foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) {
233
-				$this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result );
228
+	private function checkPropertyIds(array $propertyIds, ApiResult $result) {
229
+		foreach ($propertyIds as $propertyId) {
230
+			$result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc');
231
+			$allConstraintExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnPropertyId($propertyId);
232
+			foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) {
233
+				$this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result);
234 234
 			}
235 235
 		}
236 236
 	}
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
 	 * @param string[] $constraintIds
240 240
 	 * @param ApiResult $result
241 241
 	 */
242
-	private function checkConstraintIds( array $constraintIds, ApiResult $result ) {
243
-		foreach ( $constraintIds as $constraintId ) {
244
-			if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) {
242
+	private function checkConstraintIds(array $constraintIds, ApiResult $result) {
243
+		foreach ($constraintIds as $constraintId) {
244
+			if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) {
245 245
 				// already checked as part of checkPropertyIds()
246 246
 				continue;
247 247
 			}
248
-			$constraintParameterExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnConstraintId( $constraintId );
249
-			$this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result );
248
+			$constraintParameterExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnConstraintId($constraintId);
249
+			$this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result);
250 250
 		}
251 251
 	}
252 252
 
@@ -254,17 +254,17 @@  discard block
 block discarded – undo
254 254
 	 * @param PropertyId $propertyId
255 255
 	 * @return string[]
256 256
 	 */
257
-	private function getResultPathForPropertyId( PropertyId $propertyId ) {
258
-		return [ $this->getModuleName(), $propertyId->getSerialization() ];
257
+	private function getResultPathForPropertyId(PropertyId $propertyId) {
258
+		return [$this->getModuleName(), $propertyId->getSerialization()];
259 259
 	}
260 260
 
261 261
 	/**
262 262
 	 * @param string $constraintId
263 263
 	 * @return string[]
264 264
 	 */
265
-	private function getResultPathForConstraintId( $constraintId ) {
266
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
267
-		return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] );
265
+	private function getResultPathForConstraintId($constraintId) {
266
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
267
+		return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]);
268 268
 	}
269 269
 
270 270
 	/**
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 	 * @param ConstraintParameterException[]|null $constraintParameterExceptions
275 275
 	 * @param ApiResult $result
276 276
 	 */
277
-	private function addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, ApiResult $result ) {
278
-		$path = $this->getResultPathForConstraintId( $constraintId );
279
-		if ( $constraintParameterExceptions === null ) {
277
+	private function addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, ApiResult $result) {
278
+		$path = $this->getResultPathForConstraintId($constraintId);
279
+		if ($constraintParameterExceptions === null) {
280 280
 			$result->addValue(
281 281
 				$path,
282 282
 				self::KEY_STATUS,
@@ -286,12 +286,12 @@  discard block
 block discarded – undo
286 286
 			$result->addValue(
287 287
 				$path,
288 288
 				self::KEY_STATUS,
289
-				empty( $constraintParameterExceptions ) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY
289
+				empty($constraintParameterExceptions) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY
290 290
 			);
291 291
 			$result->addValue(
292 292
 				$path,
293 293
 				self::KEY_PROBLEMS,
294
-				array_map( [ $this, 'formatConstraintParameterException' ], $constraintParameterExceptions )
294
+				array_map([$this, 'formatConstraintParameterException'], $constraintParameterExceptions)
295 295
 			);
296 296
 		}
297 297
 	}
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	 * @param ConstraintParameterException $e
303 303
 	 * @return string[]
304 304
 	 */
305
-	private function formatConstraintParameterException( ConstraintParameterException $e ) {
305
+	private function formatConstraintParameterException(ConstraintParameterException $e) {
306 306
 		return [
307 307
 			self::KEY_MESSAGE_HTML => $this->violationMessageRenderer->render(
308 308
 				$e->getViolationMessage()
Please login to merge, or discard this patch.
src/Api/CheckConstraintsRdf.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 		EntityIdLookup $entityIdLookup,
40 40
 		RdfVocabulary $rdfVocabulary
41 41
 	) {
42
-		parent::__construct( $page, $context );
42
+		parent::__construct($page, $context);
43 43
 		$this->resultsSource = $resultsSource;
44 44
 		$this->entityIdLookup = $entityIdLookup;
45 45
 		$this->rdfVocabulary = $rdfVocabulary;
46 46
 	}
47 47
 
48
-	public static function newFromGlobalState( Page $page, IContextSource $context = null ) {
48
+	public static function newFromGlobalState(Page $page, IContextSource $context = null) {
49 49
 		$repo = WikibaseRepo::getDefaultInstance();
50 50
 
51 51
 		return new static(
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	 * @param string $guid
93 93
 	 * @return string
94 94
 	 */
95
-	private function cleanupGuid( $guid ) {
96
-		return preg_replace( '/[^\w-]/', '-', $guid );
95
+	private function cleanupGuid($guid) {
96
+		return preg_replace('/[^\w-]/', '-', $guid);
97 97
 	}
98 98
 
99 99
 	/**
@@ -105,51 +105,51 @@  discard block
 block discarded – undo
105 105
 		$response = $this->getRequest()->response();
106 106
 		$this->getOutput()->disable();
107 107
 
108
-		if ( !$this->resultsSource instanceof CachingResultsSource ) {
108
+		if (!$this->resultsSource instanceof CachingResultsSource) {
109 109
 			// TODO: make configurable whether only cached results are returned
110
-			$response->statusHeader( 501 ); // Not Implemented
110
+			$response->statusHeader(501); // Not Implemented
111 111
 			return null;
112 112
 		}
113 113
 
114
-		$entityId = $this->entityIdLookup->getEntityIdForTitle( $this->getTitle() );
115
-		if ( $entityId === null ) {
116
-			$response->statusHeader( 404 ); // Not Found
114
+		$entityId = $this->entityIdLookup->getEntityIdForTitle($this->getTitle());
115
+		if ($entityId === null) {
116
+			$response->statusHeader(404); // Not Found
117 117
 			return null;
118 118
 		}
119 119
 
120
-		$results = $this->resultsSource->getStoredResults( $entityId );
121
-		if ( $results === null ) {
122
-			$response->statusHeader( 204 ); // No Content
120
+		$results = $this->resultsSource->getStoredResults($entityId);
121
+		if ($results === null) {
122
+			$response->statusHeader(204); // No Content
123 123
 			return null;
124 124
 		}
125 125
 
126 126
 		$format = 'ttl'; // TODO: make format an option
127 127
 
128 128
 		$writerFactory = new RdfWriterFactory();
129
-		$formatName = $writerFactory->getFormatName( $format );
130
-		$contentType = $writerFactory->getMimeTypes( $formatName )[0];
129
+		$formatName = $writerFactory->getFormatName($format);
130
+		$contentType = $writerFactory->getMimeTypes($formatName)[0];
131 131
 
132
-		$response->header( "Content-Type: $contentType; charset=UTF-8" );
132
+		$response->header("Content-Type: $contentType; charset=UTF-8");
133 133
 
134
-		$writer = $writerFactory->getWriter( $formatName );
135
-		foreach ( [ RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY ] as $ns ) {
136
-			$writer->prefix( $ns, $this->rdfVocabulary->getNamespaceURI( $ns ) );
134
+		$writer = $writerFactory->getWriter($formatName);
135
+		foreach ([RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY] as $ns) {
136
+			$writer->prefix($ns, $this->rdfVocabulary->getNamespaceURI($ns));
137 137
 		}
138 138
 		$writer->start();
139 139
 
140
-		foreach ( $results->getArray() as $checkResult ) {
141
-			if ( $checkResult instanceof NullResult ) {
140
+		foreach ($results->getArray() as $checkResult) {
141
+			if ($checkResult instanceof NullResult) {
142 142
 				continue;
143 143
 			}
144
-			if ( $checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS ) {
144
+			if ($checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS) {
145 145
 				continue;
146 146
 			}
147 147
 
148
-			$writer->about( RdfVocabulary::NS_STATEMENT,
149
-				$this->cleanupGuid( $checkResult->getContextCursor()->getStatementGuid() ) )
150
-				->say( RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint' )
151
-				->is( RdfVocabulary::NS_STATEMENT,
152
-					$this->cleanupGuid( $checkResult->getConstraint()->getConstraintId() ) );
148
+			$writer->about(RdfVocabulary::NS_STATEMENT,
149
+				$this->cleanupGuid($checkResult->getContextCursor()->getStatementGuid()))
150
+				->say(RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint')
151
+				->is(RdfVocabulary::NS_STATEMENT,
152
+					$this->cleanupGuid($checkResult->getConstraint()->getConstraintId()));
153 153
 		}
154 154
 		$writer->finish();
155 155
 		echo $writer->drain();
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @return self
81 81
 	 */
82
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
82
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
83 83
 		$repo = WikibaseRepo::getDefaultInstance();
84 84
 
85 85
 		$language = $repo->getUserLanguage();
86 86
 		$formatterOptions = new FormatterOptions();
87
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
87
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
88 88
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
89
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
89
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
90 90
 
91 91
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
92
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language );
92
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language);
93 93
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
94
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language );
94
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language);
95 95
 		$config = MediaWikiServices::getInstance()->getMainConfig();
96 96
 		$dataFactory = MediaWikiServices::getInstance()->getStatsdDataFactory();
97 97
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 			$prefix,
114 114
 			$repo->getEntityIdParser(),
115 115
 			$repo->getStatementGuidValidator(),
116
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
116
+			$repo->getApiHelperFactory(RequestContext::getMain()),
117 117
 			$resultsSource,
118 118
 			$checkResultsRenderer,
119 119
 			$dataFactory
@@ -142,11 +142,11 @@  discard block
 block discarded – undo
142 142
 		CheckResultsRenderer $checkResultsRenderer,
143 143
 		IBufferingStatsdDataFactory $dataFactory
144 144
 	) {
145
-		parent::__construct( $main, $name, $prefix );
145
+		parent::__construct($main, $name, $prefix);
146 146
 		$this->entityIdParser = $entityIdParser;
147 147
 		$this->statementGuidValidator = $statementGuidValidator;
148
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
149
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
148
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
149
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
150 150
 		$this->resultsSource = $resultsSource;
151 151
 		$this->checkResultsRenderer = $checkResultsRenderer;
152 152
 		$this->dataFactory = $dataFactory;
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 
163 163
 		$params = $this->extractRequestParams();
164 164
 
165
-		$this->validateParameters( $params );
166
-		$entityIds = $this->parseEntityIds( $params );
167
-		$claimIds = $this->parseClaimIds( $params );
165
+		$this->validateParameters($params);
166
+		$entityIds = $this->parseEntityIds($params);
167
+		$claimIds = $this->parseClaimIds($params);
168 168
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
169 169
 		$statuses = $params[self::PARAM_STATUS];
170 170
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 				)
181 181
 			)->getArray()
182 182
 		);
183
-		$this->resultBuilder->markSuccess( 1 );
183
+		$this->resultBuilder->markSuccess(1);
184 184
 	}
185 185
 
186 186
 	/**
@@ -188,24 +188,24 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return EntityId[]
190 190
 	 */
191
-	private function parseEntityIds( array $params ) {
191
+	private function parseEntityIds(array $params) {
192 192
 		$ids = $params[self::PARAM_ID];
193 193
 
194
-		if ( $ids === null ) {
194
+		if ($ids === null) {
195 195
 			return [];
196
-		} elseif ( $ids === [] ) {
196
+		} elseif ($ids === []) {
197 197
 			$this->errorReporter->dieError(
198
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
198
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
199 199
 		}
200 200
 
201
-		return array_map( function ( $id ) {
201
+		return array_map(function($id) {
202 202
 			try {
203
-				return $this->entityIdParser->parse( $id );
204
-			} catch ( EntityIdParsingException $e ) {
203
+				return $this->entityIdParser->parse($id);
204
+			} catch (EntityIdParsingException $e) {
205 205
 				$this->errorReporter->dieError(
206
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
206
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
207 207
 			}
208
-		}, $ids );
208
+		}, $ids);
209 209
 	}
210 210
 
211 211
 	/**
@@ -213,35 +213,35 @@  discard block
 block discarded – undo
213 213
 	 *
214 214
 	 * @return string[]
215 215
 	 */
216
-	private function parseClaimIds( array $params ) {
216
+	private function parseClaimIds(array $params) {
217 217
 		$ids = $params[self::PARAM_CLAIM_ID];
218 218
 
219
-		if ( $ids === null ) {
219
+		if ($ids === null) {
220 220
 			return [];
221
-		} elseif ( $ids === [] ) {
221
+		} elseif ($ids === []) {
222 222
 			$this->errorReporter->dieError(
223
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
223
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
224 224
 		}
225 225
 
226
-		foreach ( $ids as $id ) {
227
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
226
+		foreach ($ids as $id) {
227
+			if (!$this->statementGuidValidator->validate($id)) {
228 228
 				$this->errorReporter->dieError(
229
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
229
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
230 230
 			}
231 231
 		}
232 232
 
233 233
 		return $ids;
234 234
 	}
235 235
 
236
-	private function validateParameters( array $params ) {
237
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
238
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
236
+	private function validateParameters(array $params) {
237
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
238
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
239 239
 		) {
240 240
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
241 241
 			$this->errorReporter->dieError(
242 242
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
243 243
 		}
244
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
244
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
245 245
 			$paramId = self::PARAM_ID;
246 246
 			$paramClaimId = self::PARAM_CLAIM_ID;
247 247
 			$this->errorReporter->dieError(
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
 				],
282 282
 				ApiBase::PARAM_ISMULTI => true,
283 283
 				ApiBase::PARAM_ALL => true,
284
-				ApiBase::PARAM_DFLT => implode( '|', [
284
+				ApiBase::PARAM_DFLT => implode('|', [
285 285
 					CheckResult::STATUS_VIOLATION,
286 286
 					CheckResult::STATUS_WARNING,
287 287
 					CheckResult::STATUS_BAD_PARAMETERS,
288
-				] ),
288
+				]),
289 289
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
290 290
 			],
291 291
 		];
Please login to merge, or discard this patch.
src/ServiceWiring-ConstraintCheckers.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -35,124 +35,124 @@  discard block
 block discarded – undo
35 35
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker;
36 36
 
37 37
 return [
38
-	ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => function( MediaWikiServices $services ) {
38
+	ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => function(MediaWikiServices $services) {
39 39
 		return new ConflictsWithChecker(
40
-			WikibaseServices::getEntityLookup( $services ),
41
-			ConstraintsServices::getConstraintParameterParser( $services ),
42
-			ConstraintsServices::getConnectionCheckerHelper( $services )
40
+			WikibaseServices::getEntityLookup($services),
41
+			ConstraintsServices::getConstraintParameterParser($services),
42
+			ConstraintsServices::getConnectionCheckerHelper($services)
43 43
 		);
44 44
 	},
45 45
 
46
-	ConstraintCheckerServices::ITEM_CHECKER => function( MediaWikiServices $services ) {
46
+	ConstraintCheckerServices::ITEM_CHECKER => function(MediaWikiServices $services) {
47 47
 		return new ItemChecker(
48
-			WikibaseServices::getEntityLookup( $services ),
49
-			ConstraintsServices::getConstraintParameterParser( $services ),
50
-			ConstraintsServices::getConnectionCheckerHelper( $services )
48
+			WikibaseServices::getEntityLookup($services),
49
+			ConstraintsServices::getConstraintParameterParser($services),
50
+			ConstraintsServices::getConnectionCheckerHelper($services)
51 51
 		);
52 52
 	},
53 53
 
54
-	ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => function( MediaWikiServices $services ) {
54
+	ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => function(MediaWikiServices $services) {
55 55
 		return new TargetRequiredClaimChecker(
56
-			WikibaseServices::getEntityLookup( $services ),
57
-			ConstraintsServices::getConstraintParameterParser( $services ),
58
-			ConstraintsServices::getConnectionCheckerHelper( $services )
56
+			WikibaseServices::getEntityLookup($services),
57
+			ConstraintsServices::getConstraintParameterParser($services),
58
+			ConstraintsServices::getConnectionCheckerHelper($services)
59 59
 		);
60 60
 	},
61 61
 
62
-	ConstraintCheckerServices::SYMMETRIC_CHECKER => function( MediaWikiServices $services ) {
62
+	ConstraintCheckerServices::SYMMETRIC_CHECKER => function(MediaWikiServices $services) {
63 63
 		return new SymmetricChecker(
64
-			WikibaseServices::getEntityLookup( $services ),
65
-			ConstraintsServices::getConnectionCheckerHelper( $services )
64
+			WikibaseServices::getEntityLookup($services),
65
+			ConstraintsServices::getConnectionCheckerHelper($services)
66 66
 		);
67 67
 	},
68 68
 
69
-	ConstraintCheckerServices::INVERSE_CHECKER => function( MediaWikiServices $services ) {
69
+	ConstraintCheckerServices::INVERSE_CHECKER => function(MediaWikiServices $services) {
70 70
 		return new InverseChecker(
71
-			WikibaseServices::getEntityLookup( $services ),
72
-			ConstraintsServices::getConstraintParameterParser( $services ),
73
-			ConstraintsServices::getConnectionCheckerHelper( $services )
71
+			WikibaseServices::getEntityLookup($services),
72
+			ConstraintsServices::getConstraintParameterParser($services),
73
+			ConstraintsServices::getConnectionCheckerHelper($services)
74 74
 		);
75 75
 	},
76 76
 
77
-	ConstraintCheckerServices::QUALIFIER_CHECKER => function( MediaWikiServices $services ) {
77
+	ConstraintCheckerServices::QUALIFIER_CHECKER => function(MediaWikiServices $services) {
78 78
 		return new QualifierChecker();
79 79
 	},
80 80
 
81
-	ConstraintCheckerServices::QUALIFIERS_CHECKER => function( MediaWikiServices $services ) {
81
+	ConstraintCheckerServices::QUALIFIERS_CHECKER => function(MediaWikiServices $services) {
82 82
 		return new QualifiersChecker(
83
-			ConstraintsServices::getConstraintParameterParser( $services )
83
+			ConstraintsServices::getConstraintParameterParser($services)
84 84
 		);
85 85
 	},
86 86
 
87
-	ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => function( MediaWikiServices $services ) {
87
+	ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => function(MediaWikiServices $services) {
88 88
 		return new MandatoryQualifiersChecker(
89
-			ConstraintsServices::getConstraintParameterParser( $services )
89
+			ConstraintsServices::getConstraintParameterParser($services)
90 90
 		);
91 91
 	},
92 92
 
93
-	ConstraintCheckerServices::RANGE_CHECKER => function( MediaWikiServices $services ) {
93
+	ConstraintCheckerServices::RANGE_CHECKER => function(MediaWikiServices $services) {
94 94
 		return new RangeChecker(
95
-			WikibaseServices::getPropertyDataTypeLookup( $services ),
96
-			ConstraintsServices::getConstraintParameterParser( $services ),
97
-			ConstraintsServices::getRangeCheckerHelper( $services )
95
+			WikibaseServices::getPropertyDataTypeLookup($services),
96
+			ConstraintsServices::getConstraintParameterParser($services),
97
+			ConstraintsServices::getRangeCheckerHelper($services)
98 98
 		);
99 99
 	},
100 100
 
101
-	ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => function( MediaWikiServices $services ) {
101
+	ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => function(MediaWikiServices $services) {
102 102
 		return new DiffWithinRangeChecker(
103
-			ConstraintsServices::getConstraintParameterParser( $services ),
104
-			ConstraintsServices::getRangeCheckerHelper( $services ),
103
+			ConstraintsServices::getConstraintParameterParser($services),
104
+			ConstraintsServices::getRangeCheckerHelper($services),
105 105
 			$services->getMainConfig()
106 106
 		);
107 107
 	},
108 108
 
109
-	ConstraintCheckerServices::TYPE_CHECKER => function( MediaWikiServices $services ) {
109
+	ConstraintCheckerServices::TYPE_CHECKER => function(MediaWikiServices $services) {
110 110
 		return new TypeChecker(
111
-			WikibaseServices::getEntityLookup( $services ),
112
-			ConstraintsServices::getConstraintParameterParser( $services ),
113
-			ConstraintsServices::getTypeCheckerHelper( $services ),
111
+			WikibaseServices::getEntityLookup($services),
112
+			ConstraintsServices::getConstraintParameterParser($services),
113
+			ConstraintsServices::getTypeCheckerHelper($services),
114 114
 			$services->getMainConfig()
115 115
 		);
116 116
 	},
117 117
 
118
-	ConstraintCheckerServices::VALUE_TYPE_CHECKER => function( MediaWikiServices $services ) {
118
+	ConstraintCheckerServices::VALUE_TYPE_CHECKER => function(MediaWikiServices $services) {
119 119
 		return new ValueTypeChecker(
120
-			WikibaseServices::getEntityLookup( $services ),
121
-			ConstraintsServices::getConstraintParameterParser( $services ),
122
-			ConstraintsServices::getTypeCheckerHelper( $services ),
120
+			WikibaseServices::getEntityLookup($services),
121
+			ConstraintsServices::getConstraintParameterParser($services),
122
+			ConstraintsServices::getTypeCheckerHelper($services),
123 123
 			$services->getMainConfig()
124 124
 		);
125 125
 	},
126 126
 
127
-	ConstraintCheckerServices::SINGLE_VALUE_CHECKER => function( MediaWikiServices $services ) {
127
+	ConstraintCheckerServices::SINGLE_VALUE_CHECKER => function(MediaWikiServices $services) {
128 128
 		return new SingleValueChecker(
129
-			ConstraintsServices::getConstraintParameterParser( $services )
129
+			ConstraintsServices::getConstraintParameterParser($services)
130 130
 		);
131 131
 	},
132 132
 
133
-	ConstraintCheckerServices::MULTI_VALUE_CHECKER => function( MediaWikiServices $services ) {
133
+	ConstraintCheckerServices::MULTI_VALUE_CHECKER => function(MediaWikiServices $services) {
134 134
 		return new MultiValueChecker(
135
-			ConstraintsServices::getConstraintParameterParser( $services )
135
+			ConstraintsServices::getConstraintParameterParser($services)
136 136
 		);
137 137
 	},
138 138
 
139
-	ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => function( MediaWikiServices $services ) {
139
+	ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => function(MediaWikiServices $services) {
140 140
 		// TODO return a different, dummy implementation if SPARQL is not available
141 141
 		return new UniqueValueChecker(
142
-			ConstraintsServices::getSparqlHelper( $services )
142
+			ConstraintsServices::getSparqlHelper($services)
143 143
 		);
144 144
 	},
145 145
 
146
-	ConstraintCheckerServices::FORMAT_CHECKER => function( MediaWikiServices $services ) {
146
+	ConstraintCheckerServices::FORMAT_CHECKER => function(MediaWikiServices $services) {
147 147
 		// TODO return a different, dummy implementation if SPARQL is not available
148 148
 		return new FormatChecker(
149
-			ConstraintsServices::getConstraintParameterParser( $services ),
149
+			ConstraintsServices::getConstraintParameterParser($services),
150 150
 			$services->getMainConfig(),
151
-			ConstraintsServices::getSparqlHelper( $services )
151
+			ConstraintsServices::getSparqlHelper($services)
152 152
 		);
153 153
 	},
154 154
 
155
-	ConstraintCheckerServices::COMMONS_LINK_CHECKER => function( MediaWikiServices $services ) {
155
+	ConstraintCheckerServices::COMMONS_LINK_CHECKER => function(MediaWikiServices $services) {
156 156
 		// TODO return different implementations for:
157 157
 		// - Wikimedia production ('commonswiki' database available)
158 158
 		// - InstantCommons wikis
@@ -160,76 +160,76 @@  discard block
 block discarded – undo
160 160
 		// - …
161 161
 		// ? (see also T169538)
162 162
 		return new CommonsLinkChecker(
163
-			ConstraintsServices::getConstraintParameterParser( $services ),
163
+			ConstraintsServices::getConstraintParameterParser($services),
164 164
 			$services->getTitleParser()
165 165
 		);
166 166
 	},
167 167
 
168
-	ConstraintCheckerServices::ONE_OF_CHECKER => function( MediaWikiServices $services ) {
168
+	ConstraintCheckerServices::ONE_OF_CHECKER => function(MediaWikiServices $services) {
169 169
 		return new OneOfChecker(
170
-			ConstraintsServices::getConstraintParameterParser( $services )
170
+			ConstraintsServices::getConstraintParameterParser($services)
171 171
 		);
172 172
 	},
173 173
 
174
-	ConstraintCheckerServices::VALUE_ONLY_CHECKER => function( MediaWikiServices $services ) {
174
+	ConstraintCheckerServices::VALUE_ONLY_CHECKER => function(MediaWikiServices $services) {
175 175
 		return new ValueOnlyChecker();
176 176
 	},
177 177
 
178
-	ConstraintCheckerServices::REFERENCE_CHECKER => function( MediaWikiServices $services ) {
178
+	ConstraintCheckerServices::REFERENCE_CHECKER => function(MediaWikiServices $services) {
179 179
 		return new ReferenceChecker();
180 180
 	},
181 181
 
182
-	ConstraintCheckerServices::NO_BOUNDS_CHECKER => function( MediaWikiServices $services ) {
182
+	ConstraintCheckerServices::NO_BOUNDS_CHECKER => function(MediaWikiServices $services) {
183 183
 		return new NoBoundsChecker();
184 184
 	},
185 185
 
186
-	ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => function( MediaWikiServices $services ) {
186
+	ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => function(MediaWikiServices $services) {
187 187
 		// TODO in the future, get UnitConverter from $services?
188 188
 		$repo = WikibaseRepo::getDefaultInstance();
189 189
 		$unitConverter = $repo->getUnitConverter();
190 190
 
191 191
 		return new AllowedUnitsChecker(
192
-			ConstraintsServices::getConstraintParameterParser( $services ),
192
+			ConstraintsServices::getConstraintParameterParser($services),
193 193
 			$unitConverter
194 194
 		);
195 195
 	},
196 196
 
197
-	ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => function( MediaWikiServices $services ) {
197
+	ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => function(MediaWikiServices $services) {
198 198
 		return new SingleBestValueChecker(
199
-			ConstraintsServices::getConstraintParameterParser( $services )
199
+			ConstraintsServices::getConstraintParameterParser($services)
200 200
 		);
201 201
 	},
202 202
 
203
-	ConstraintCheckerServices::ENTITY_TYPE_CHECKER => function( MediaWikiServices $services ) {
203
+	ConstraintCheckerServices::ENTITY_TYPE_CHECKER => function(MediaWikiServices $services) {
204 204
 		return new EntityTypeChecker(
205
-			ConstraintsServices::getConstraintParameterParser( $services )
205
+			ConstraintsServices::getConstraintParameterParser($services)
206 206
 		);
207 207
 	},
208 208
 
209
-	ConstraintCheckerServices::NONE_OF_CHECKER => function( MediaWikiServices $services ) {
209
+	ConstraintCheckerServices::NONE_OF_CHECKER => function(MediaWikiServices $services) {
210 210
 		return new NoneOfChecker(
211
-			ConstraintsServices::getConstraintParameterParser( $services )
211
+			ConstraintsServices::getConstraintParameterParser($services)
212 212
 		);
213 213
 	},
214 214
 
215
-	ConstraintCheckerServices::INTEGER_CHECKER => function( MediaWikiServices $services ) {
215
+	ConstraintCheckerServices::INTEGER_CHECKER => function(MediaWikiServices $services) {
216 216
 		return new IntegerChecker();
217 217
 	},
218 218
 
219
-	ConstraintCheckerServices::CITATION_NEEDED_CHECKER => function( MediaWikiServices $services ) {
219
+	ConstraintCheckerServices::CITATION_NEEDED_CHECKER => function(MediaWikiServices $services) {
220 220
 		return new CitationNeededChecker();
221 221
 	},
222 222
 
223
-	ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => function( MediaWikiServices $services ) {
223
+	ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => function(MediaWikiServices $services) {
224 224
 		return new PropertyScopeChecker(
225
-			ConstraintsServices::getConstraintParameterParser( $services )
225
+			ConstraintsServices::getConstraintParameterParser($services)
226 226
 		);
227 227
 	},
228 228
 
229
-	ConstraintCheckerServices::CONTEMPORARY_CHECKER => function( MediaWikiServices $services ) {
229
+	ConstraintCheckerServices::CONTEMPORARY_CHECKER => function(MediaWikiServices $services) {
230 230
 		return new ContemporaryChecker(
231
-			WikibaseServices::getEntityLookup( $services ),
232
-			ConstraintsServices::getRangeCheckerHelper( $services ),
231
+			WikibaseServices::getEntityLookup($services),
232
+			ConstraintsServices::getRangeCheckerHelper($services),
233 233
 			$services->getMainConfig()
234 234
 		);
235 235
 	},
Please login to merge, or discard this patch.
src/Html/HtmlTableHeaderBuilder.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @throws InvalidArgumentException
42 42
 	 */
43
-	public function __construct( $content, $isSortable = false, $isRawContent = false ) {
44
-		Assert::parameterType( 'string', $content, '$content' );
45
-		Assert::parameterType( 'boolean', $isSortable, '$isSortable' );
46
-		Assert::parameterType( 'boolean', $isRawContent, '$isRawContent' );
43
+	public function __construct($content, $isSortable = false, $isRawContent = false) {
44
+		Assert::parameterType('string', $content, '$content');
45
+		Assert::parameterType('boolean', $isSortable, '$isSortable');
46
+		Assert::parameterType('boolean', $isRawContent, '$isRawContent');
47 47
 
48 48
 		$this->content = $content;
49 49
 		$this->isSortable = $isSortable;
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
 	 * @return string HTML
71 71
 	 */
72 72
 	public function toHtml() {
73
-		$attributes = [ 'role' => 'columnheader button' ];
73
+		$attributes = ['role' => 'columnheader button'];
74 74
 
75
-		if ( !$this->isSortable ) {
75
+		if (!$this->isSortable) {
76 76
 			$attributes['class'] = 'unsortable';
77 77
 		}
78 78
 
79 79
 		$content = $this->content;
80
-		if ( !$this->isRawContent ) {
81
-			$content = htmlspecialchars( $this->content );
80
+		if (!$this->isRawContent) {
81
+			$content = htmlspecialchars($this->content);
82 82
 		}
83 83
 
84
-		return Html::rawElement( 'th', $attributes, $content );
84
+		return Html::rawElement('th', $attributes, $content);
85 85
 	}
86 86
 
87 87
 }
Please login to merge, or discard this patch.