Completed
Push — master ( f01a3a...0f0d16 )
by
unknown
10:05
created
src/ConstraintCheck/Message/ViolationMessageRenderer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,12 +24,12 @@
 block discarded – undo
24 24
 		$language = null,
25 25
 		$format = Message::FORMAT_ESCAPED
26 26
 	) {
27
-		if ( is_string( $violationMessage ) ) {
27
+		if (is_string($violationMessage)) {
28 28
 			// TODO remove this once all checkers produce ViolationMessage objects
29 29
 			return $violationMessage;
30 30
 		}
31
-		$message = new Message( $violationMessage->getMessageKey(), [], $language );
32
-		return $message->toString( $format );
31
+		$message = new Message($violationMessage->getMessageKey(), [], $language);
32
+		return $message->toString($format);
33 33
 	}
34 34
 
35 35
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/LoggingHelper.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 		$this->dataFactory = $dataFactory;
47 47
 		$this->logger = $logger;
48 48
 		$this->constraintCheckDurationLimits = [
49
-			'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ),
50
-			'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ),
49
+			'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'),
50
+			'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'),
51 51
 		];
52 52
 	}
53 53
 
@@ -73,46 +73,46 @@  discard block
 block discarded – undo
73 73
 		$durationSeconds,
74 74
 		$method
75 75
 	) {
76
-		$constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 );
76
+		$constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1);
77 77
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
78 78
 
79 79
 		$this->dataFactory->timing(
80
-			'wikibase.quality.constraints.check.timing.' .
81
-				$constraintTypeItemId . '-' .
80
+			'wikibase.quality.constraints.check.timing.'.
81
+				$constraintTypeItemId.'-'.
82 82
 				$constraintCheckerClassShortName,
83 83
 			$durationSeconds * 1000
84 84
 		);
85 85
 
86 86
 		// find the longest limit (and associated log level) that the duration exceeds
87
-		foreach ( $this->constraintCheckDurationLimits as $level => $limit ) {
87
+		foreach ($this->constraintCheckDurationLimits as $level => $limit) {
88 88
 			if (
89 89
 				// duration exceeds this limit
90
-				isset( $limit ) && $durationSeconds > $limit &&
90
+				isset($limit) && $durationSeconds > $limit &&
91 91
 				// this limit is longer than previous longest limit
92
-				( !isset( $limitSeconds ) || $limit > $limitSeconds )
92
+				(!isset($limitSeconds) || $limit > $limitSeconds)
93 93
 			) {
94 94
 				$limitSeconds = $limit;
95 95
 				$logLevel = $level;
96 96
 			}
97 97
 		}
98 98
 
99
-		if ( !isset( $limitSeconds ) ) {
99
+		if (!isset($limitSeconds)) {
100 100
 			return;
101 101
 		}
102
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
102
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
103 103
 			// TODO log less details but still log something
104 104
 			return;
105 105
 		}
106 106
 
107 107
 		$resultMessage = $result->getMessage();
108
-		if ( $resultMessage instanceof ViolationMessage ) {
108
+		if ($resultMessage instanceof ViolationMessage) {
109 109
 			$resultMessage = $resultMessage->getMessageKey();
110 110
 		}
111 111
 
112 112
 		$this->logger->log(
113 113
 			$logLevel,
114
-			'Constraint check with {constraintCheckerClassShortName} ' .
115
-			'took longer than {limitSeconds} second(s) ' .
114
+			'Constraint check with {constraintCheckerClassShortName} '.
115
+			'took longer than {limitSeconds} second(s) '.
116 116
 			'(duration: {durationSeconds} seconds).',
117 117
 			[
118 118
 				'method' => $method,
Please login to merge, or discard this patch.
src/Specials/SpecialConstraintReport.php 1 patch
Spacing   +109 added lines, -110 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		Config $config,
134 134
 		IBufferingStatsdDataFactory $dataFactory
135 135
 	) {
136
-		parent::__construct( 'ConstraintReport' );
136
+		parent::__construct('ConstraintReport');
137 137
 
138 138
 		$this->entityLookup = $entityLookup;
139 139
 		$this->entityTitleLookup = $entityTitleLookup;
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
 		$language = $this->getLanguage();
143 143
 
144 144
 		$formatterOptions = new FormatterOptions();
145
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
145
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
146 146
 		$this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(
147 147
 			SnakFormatter::FORMAT_HTML,
148 148
 			$formatterOptions
149 149
 		);
150 150
 
151
-		$labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup( $language );
151
+		$labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup($language);
152 152
 
153 153
 		$this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter(
154 154
 			$labelLookup
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	 * @return array
178 178
 	 */
179 179
 	private function getModules() {
180
-		return [ 'SpecialConstraintReportPage' ];
180
+		return ['SpecialConstraintReportPage'];
181 181
 	}
182 182
 
183 183
 	/**
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @return string
196 196
 	 */
197 197
 	public function getDescription() {
198
-		return $this->msg( 'wbqc-constraintreport' )->escaped();
198
+		return $this->msg('wbqc-constraintreport')->escaped();
199 199
 	}
200 200
 
201 201
 	/**
@@ -207,42 +207,42 @@  discard block
 block discarded – undo
207 207
 	 * @throws EntityIdParsingException
208 208
 	 * @throws UnexpectedValueException
209 209
 	 */
210
-	public function execute( $subPage ) {
210
+	public function execute($subPage) {
211 211
 		$out = $this->getOutput();
212 212
 
213
-		$postRequest = $this->getContext()->getRequest()->getVal( 'entityid' );
214
-		if ( $postRequest ) {
215
-			$out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() );
213
+		$postRequest = $this->getContext()->getRequest()->getVal('entityid');
214
+		if ($postRequest) {
215
+			$out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL());
216 216
 			return;
217 217
 		}
218 218
 
219
-		$out->addModules( $this->getModules() );
219
+		$out->addModules($this->getModules());
220 220
 
221 221
 		$this->setHeaders();
222 222
 
223
-		$out->addHTML( $this->getExplanationText() );
223
+		$out->addHTML($this->getExplanationText());
224 224
 		$this->buildEntityIdForm();
225 225
 
226
-		if ( !$subPage ) {
226
+		if (!$subPage) {
227 227
 			return;
228 228
 		}
229 229
 
230
-		if ( !is_string( $subPage ) ) {
231
-			throw new InvalidArgumentException( '$subPage must be string.' );
230
+		if (!is_string($subPage)) {
231
+			throw new InvalidArgumentException('$subPage must be string.');
232 232
 		}
233 233
 
234 234
 		try {
235
-			$entityId = $this->entityIdParser->parse( $subPage );
236
-		} catch ( EntityIdParsingException $e ) {
235
+			$entityId = $this->entityIdParser->parse($subPage);
236
+		} catch (EntityIdParsingException $e) {
237 237
 			$out->addHTML(
238
-				$this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true )
238
+				$this->buildNotice('wbqc-constraintreport-invalid-entity-id', true)
239 239
 			);
240 240
 			return;
241 241
 		}
242 242
 
243
-		if ( !$this->entityLookup->hasEntity( $entityId ) ) {
243
+		if (!$this->entityLookup->hasEntity($entityId)) {
244 244
 			$out->addHTML(
245
-				$this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true )
245
+				$this->buildNotice('wbqc-constraintreport-not-existent-entity', true)
246 246
 			);
247 247
 			return;
248 248
 		}
@@ -250,18 +250,18 @@  discard block
 block discarded – undo
250 250
 		$this->dataFactory->increment(
251 251
 			'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck'
252 252
 		);
253
-		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId );
253
+		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId);
254 254
 
255
-		if ( count( $results ) > 0 ) {
255
+		if (count($results) > 0) {
256 256
 			$out->addHTML(
257
-				$this->buildResultHeader( $entityId )
258
-				. $this->buildSummary( $results )
259
-				. $this->buildResultTable( $entityId, $results )
257
+				$this->buildResultHeader($entityId)
258
+				. $this->buildSummary($results)
259
+				. $this->buildResultTable($entityId, $results)
260 260
 			);
261 261
 		} else {
262 262
 			$out->addHTML(
263
-				$this->buildResultHeader( $entityId )
264
-				. $this->buildNotice( 'wbqc-constraintreport-empty-result' )
263
+				$this->buildResultHeader($entityId)
264
+				. $this->buildNotice('wbqc-constraintreport-empty-result')
265 265
 			);
266 266
 		}
267 267
 	}
@@ -277,15 +277,15 @@  discard block
 block discarded – undo
277 277
 				'name' => 'entityid',
278 278
 				'label-message' => 'wbqc-constraintreport-form-entityid-label',
279 279
 				'cssclass' => 'wbqc-constraintreport-form-entity-id',
280
-				'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped()
280
+				'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped()
281 281
 			]
282 282
 		];
283
-		$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' );
284
-		$htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() );
285
-		$htmlForm->setSubmitCallback( function() {
283
+		$htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form');
284
+		$htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped());
285
+		$htmlForm->setSubmitCallback(function() {
286 286
 			return false;
287 287
 		} );
288
-		$htmlForm->setMethod( 'post' );
288
+		$htmlForm->setMethod('post');
289 289
 		$htmlForm->show();
290 290
 	}
291 291
 
@@ -299,16 +299,16 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @return string HTML
301 301
 	 */
302
-	private function buildNotice( $messageKey, $error = false ) {
303
-		if ( !is_string( $messageKey ) ) {
304
-			throw new InvalidArgumentException( '$message must be string.' );
302
+	private function buildNotice($messageKey, $error = false) {
303
+		if (!is_string($messageKey)) {
304
+			throw new InvalidArgumentException('$message must be string.');
305 305
 		}
306
-		if ( !is_bool( $error ) ) {
307
-			throw new InvalidArgumentException( '$error must be bool.' );
306
+		if (!is_bool($error)) {
307
+			throw new InvalidArgumentException('$error must be bool.');
308 308
 		}
309 309
 
310 310
 		$cssClasses = 'wbqc-constraintreport-notice';
311
-		if ( $error ) {
311
+		if ($error) {
312 312
 			$cssClasses .= ' wbqc-constraintreport-notice-error';
313 313
 		}
314 314
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 				[
318 318
 					'class' => $cssClasses
319 319
 				],
320
-				$this->msg( $messageKey )->escaped()
320
+				$this->msg($messageKey)->escaped()
321 321
 			);
322 322
 	}
323 323
 
@@ -327,16 +327,16 @@  discard block
 block discarded – undo
327 327
 	private function getExplanationText() {
328 328
 		return Html::rawElement(
329 329
 			'div',
330
-			[ 'class' => 'wbqc-explanation' ],
330
+			['class' => 'wbqc-explanation'],
331 331
 			Html::rawElement(
332 332
 				'p',
333 333
 				[],
334
-				$this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped()
334
+				$this->msg('wbqc-constraintreport-explanation-part-one')->escaped()
335 335
 			)
336 336
 			. Html::rawElement(
337 337
 				'p',
338 338
 				[],
339
-				$this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped()
339
+				$this->msg('wbqc-constraintreport-explanation-part-two')->escaped()
340 340
 			)
341 341
 		);
342 342
 	}
@@ -347,71 +347,70 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @return string HTML
349 349
 	 */
350
-	private function buildResultTable( EntityId $entityId, array $results ) {
350
+	private function buildResultTable(EntityId $entityId, array $results) {
351 351
 		// Set table headers
352 352
 		$table = new HtmlTableBuilder(
353 353
 			[
354 354
 				new HtmlTableHeaderBuilder(
355
-					$this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(),
355
+					$this->msg('wbqc-constraintreport-result-table-header-status')->escaped(),
356 356
 					true
357 357
 				),
358 358
 				new HtmlTableHeaderBuilder(
359
-					$this->msg( 'wbqc-constraintreport-result-table-header-claim' )->escaped(),
359
+					$this->msg('wbqc-constraintreport-result-table-header-claim')->escaped(),
360 360
 					true
361 361
 				),
362 362
 				new HtmlTableHeaderBuilder(
363
-					$this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(),
363
+					$this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(),
364 364
 					true
365 365
 				)
366 366
 			]
367 367
 		);
368 368
 
369
-		foreach ( $results as $result ) {
370
-			$table = $this->appendToResultTable( $table, $entityId, $result );
369
+		foreach ($results as $result) {
370
+			$table = $this->appendToResultTable($table, $entityId, $result);
371 371
 		}
372 372
 
373 373
 		return $table->toHtml();
374 374
 	}
375 375
 
376
-	private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) {
376
+	private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) {
377 377
 		// Status column
378 378
 		$statusColumn = $this->buildTooltipElement(
379
-			$this->formatStatus( $result->getStatus() ),
379
+			$this->formatStatus($result->getStatus()),
380 380
 			$result->getMessage() !== null ?
381
-				$this->violationMessageRenderer->render( $result->getMessage() ) :
382
-				null,
381
+				$this->violationMessageRenderer->render($result->getMessage()) : null,
383 382
 			'[?]'
384 383
 		);
385 384
 
386 385
 		// Claim column
387
-		$property = $this->entityIdLabelFormatter->formatEntityId( $result->getContext()->getSnak()->getPropertyId() );
388
-		if ( $result->getSnakType() === 'value' ) {
389
-			$value = $this->constraintParameterRenderer->formatValue( $result->getDataValue() );
386
+		$property = $this->entityIdLabelFormatter->formatEntityId($result->getContext()->getSnak()->getPropertyId());
387
+		if ($result->getSnakType() === 'value') {
388
+			$value = $this->constraintParameterRenderer->formatValue($result->getDataValue());
390 389
 		} else {
391
-			$value = htmlspecialchars( $result->getSnakType() );
390
+			$value = htmlspecialchars($result->getSnakType());
392 391
 		}
393 392
 
394 393
 		$claimColumn = $this->getClaimLink(
395 394
 			$entityId,
396 395
 			$result->getContext()->getSnak()->getPropertyId(),
397
-			$property . ': ' . $value
396
+			$property.': '.$value
398 397
 		);
399 398
 
400 399
 		// Constraint column
401 400
 		$constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId();
402 401
 		try {
403
-			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) );
404
-		} catch ( InvalidArgumentException $e ) {
405
-			$constraintTypeLabel = htmlspecialchars( $constraintTypeItemId );
402
+			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId));
403
+		} catch (InvalidArgumentException $e) {
404
+			$constraintTypeLabel = htmlspecialchars($constraintTypeItemId);
406 405
 		}
407 406
 		$constraintLink = $this->getClaimLink(
408 407
 			$result->getContext()->getSnak()->getPropertyId(),
409
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ),
408
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')),
410 409
 			$constraintTypeLabel
411 410
 		);
412 411
 		$constraintColumn = $this->buildExpandableElement(
413 412
 			$constraintLink,
414
-			$this->constraintParameterRenderer->formatParameters( $result->getParameters() ),
413
+			$this->constraintParameterRenderer->formatParameters($result->getParameters()),
415 414
 			'[...]'
416 415
 		);
417 416
 
@@ -446,15 +445,15 @@  discard block
 block discarded – undo
446 445
 	 *
447 446
 	 * @return string HTML
448 447
 	 */
449
-	protected function buildResultHeader( EntityId $entityId ) {
450
-		$entityLink = sprintf( '%s (%s)',
451
-							   $this->entityIdLinkFormatter->formatEntityId( $entityId ),
452
-							   htmlspecialchars( $entityId->getSerialization() ) );
448
+	protected function buildResultHeader(EntityId $entityId) {
449
+		$entityLink = sprintf('%s (%s)',
450
+							   $this->entityIdLinkFormatter->formatEntityId($entityId),
451
+							   htmlspecialchars($entityId->getSerialization()));
453 452
 
454 453
 		return Html::rawElement(
455 454
 			'h3',
456 455
 			[],
457
-			sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
456
+			sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink)
458 457
 		);
459 458
 	}
460 459
 
@@ -465,24 +464,24 @@  discard block
 block discarded – undo
465 464
 	 *
466 465
 	 * @return string HTML
467 466
 	 */
468
-	protected function buildSummary( array $results ) {
467
+	protected function buildSummary(array $results) {
469 468
 		$statuses = [];
470
-		foreach ( $results as $result ) {
471
-			$status = strtolower( $result->getStatus() );
472
-			$statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1;
469
+		foreach ($results as $result) {
470
+			$status = strtolower($result->getStatus());
471
+			$statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1;
473 472
 		}
474 473
 
475 474
 		$statusElements = [];
476
-		foreach ( $statuses as $status => $count ) {
477
-			if ( $count > 0 ) {
475
+		foreach ($statuses as $status => $count) {
476
+			if ($count > 0) {
478 477
 				$statusElements[] =
479
-					$this->formatStatus( $status )
478
+					$this->formatStatus($status)
480 479
 					. ': '
481 480
 					. $count;
482 481
 			}
483 482
 		}
484 483
 
485
-		return Html::rawElement( 'p', [], implode( ', ', $statusElements ) );
484
+		return Html::rawElement('p', [], implode(', ', $statusElements));
486 485
 	}
487 486
 
488 487
 	/**
@@ -497,15 +496,15 @@  discard block
 block discarded – undo
497 496
 	 *
498 497
 	 * @return string HTML
499 498
 	 */
500
-	protected function buildTooltipElement( $content, $tooltipContent, $indicator ) {
501
-		if ( !is_string( $content ) ) {
502
-			throw new InvalidArgumentException( '$content has to be string.' );
499
+	protected function buildTooltipElement($content, $tooltipContent, $indicator) {
500
+		if (!is_string($content)) {
501
+			throw new InvalidArgumentException('$content has to be string.');
503 502
 		}
504
-		if ( $tooltipContent && ( !is_string( $tooltipContent ) ) ) {
505
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
503
+		if ($tooltipContent && (!is_string($tooltipContent))) {
504
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
506 505
 		}
507 506
 
508
-		if ( empty( $tooltipContent ) ) {
507
+		if (empty($tooltipContent)) {
509 508
 			return $content;
510 509
 		}
511 510
 
@@ -522,13 +521,13 @@  discard block
 block discarded – undo
522 521
 			[
523 522
 				'class' => 'wbqc-indicator'
524 523
 			],
525
-			htmlspecialchars( $indicator ) . $tooltip
524
+			htmlspecialchars($indicator).$tooltip
526 525
 		);
527 526
 
528 527
 		return Html::rawElement(
529 528
 			'span',
530 529
 			[],
531
-			sprintf( '%s %s', $content, $tooltipIndicator )
530
+			sprintf('%s %s', $content, $tooltipIndicator)
532 531
 		);
533 532
 	}
534 533
 
@@ -544,15 +543,15 @@  discard block
 block discarded – undo
544 543
 	 *
545 544
 	 * @return string HTML
546 545
 	 */
547
-	protected function buildExpandableElement( $content, $expandableContent, $indicator ) {
548
-		if ( !is_string( $content ) ) {
549
-			throw new InvalidArgumentException( '$content has to be string.' );
546
+	protected function buildExpandableElement($content, $expandableContent, $indicator) {
547
+		if (!is_string($content)) {
548
+			throw new InvalidArgumentException('$content has to be string.');
550 549
 		}
551
-		if ( $expandableContent && ( !is_string( $expandableContent ) ) ) {
552
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
550
+		if ($expandableContent && (!is_string($expandableContent))) {
551
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
553 552
 		}
554 553
 
555
-		if ( empty( $expandableContent ) ) {
554
+		if (empty($expandableContent)) {
556 555
 			return $content;
557 556
 		}
558 557
 
@@ -573,7 +572,7 @@  discard block
 block discarded – undo
573 572
 		);
574 573
 
575 574
 		return
576
-			sprintf( '%s %s %s', $content, $tooltipIndicator, $expandableContent );
575
+			sprintf('%s %s %s', $content, $tooltipIndicator, $expandableContent);
577 576
 	}
578 577
 
579 578
 	/**
@@ -585,16 +584,16 @@  discard block
 block discarded – undo
585 584
 	 *
586 585
 	 * @return string HTML
587 586
 	 */
588
-	private function formatStatus( $status ) {
589
-		$messageName = "wbqc-constraintreport-status-" . strtolower( $status );
587
+	private function formatStatus($status) {
588
+		$messageName = "wbqc-constraintreport-status-".strtolower($status);
590 589
 
591 590
 		$formattedStatus =
592 591
 			Html::element(
593 592
 				'span',
594 593
 				[
595
-					'class' => 'wbqc-status wbqc-status-' . $status
594
+					'class' => 'wbqc-status wbqc-status-'.$status
596 595
 				],
597
-				$this->msg( $messageName )->text()
596
+				$this->msg($messageName)->text()
598 597
 			);
599 598
 
600 599
 		return $formattedStatus;
@@ -610,26 +609,26 @@  discard block
 block discarded – undo
610 609
 	 *
611 610
 	 * @return string HTML
612 611
 	 */
613
-	protected function formatDataValues( $dataValues, $separator = ', ' ) {
614
-		if ( $dataValues instanceof DataValue ) {
615
-			$dataValues = [ $dataValues ];
616
-		} elseif ( !is_array( $dataValues ) ) {
617
-			throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
612
+	protected function formatDataValues($dataValues, $separator = ', ') {
613
+		if ($dataValues instanceof DataValue) {
614
+			$dataValues = [$dataValues];
615
+		} elseif (!is_array($dataValues)) {
616
+			throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
618 617
 		}
619 618
 
620 619
 		$formattedDataValues = [];
621
-		foreach ( $dataValues as $dataValue ) {
622
-			if ( !( $dataValue instanceof DataValue ) ) {
623
-				throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
620
+		foreach ($dataValues as $dataValue) {
621
+			if (!($dataValue instanceof DataValue)) {
622
+				throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
624 623
 			}
625
-			if ( $dataValue instanceof EntityIdValue ) {
626
-				$formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() );
624
+			if ($dataValue instanceof EntityIdValue) {
625
+				$formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId());
627 626
 			} else {
628
-				$formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue );
627
+				$formattedDataValues[] = $this->dataValueFormatter->format($dataValue);
629 628
 			}
630 629
 		}
631 630
 
632
-		return implode( $separator, $formattedDataValues );
631
+		return implode($separator, $formattedDataValues);
633 632
 	}
634 633
 
635 634
 	/**
@@ -641,12 +640,12 @@  discard block
 block discarded – undo
641 640
 	 *
642 641
 	 * @return string HTML
643 642
 	 */
644
-	private function getClaimLink( EntityId $entityId, PropertyId $propertyId, $text ) {
643
+	private function getClaimLink(EntityId $entityId, PropertyId $propertyId, $text) {
645 644
 		return
646 645
 			Html::rawElement(
647 646
 				'a',
648 647
 				[
649
-					'href' => $this->getClaimUrl( $entityId, $propertyId ),
648
+					'href' => $this->getClaimUrl($entityId, $propertyId),
650 649
 					'target' => '_blank'
651 650
 				],
652 651
 				$text
@@ -661,9 +660,9 @@  discard block
 block discarded – undo
661 660
 	 *
662 661
 	 * @return string
663 662
 	 */
664
-	private function getClaimUrl( EntityId $entityId, PropertyId $propertyId ) {
665
-		$title = $this->entityTitleLookup->getTitleForId( $entityId );
666
-		$entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() );
663
+	private function getClaimUrl(EntityId $entityId, PropertyId $propertyId) {
664
+		$title = $this->entityTitleLookup->getTitleForId($entityId);
665
+		$entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization());
667 666
 
668 667
 		return $entityUrl;
669 668
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/QualifiersChecker.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -70,43 +70,43 @@  discard block
 block discarded – undo
70 70
 	 * @throws ConstraintParameterException
71 71
 	 * @return CheckResult
72 72
 	 */
73
-	public function checkConstraint( Context $context, Constraint $constraint ) {
74
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
75
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
73
+	public function checkConstraint(Context $context, Constraint $constraint) {
74
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
75
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
76 76
 		}
77 77
 
78 78
 		$parameters = [];
79 79
 		$constraintParameters = $constraint->getConstraintParameters();
80 80
 
81
-		$properties = $this->constraintParameterParser->parsePropertiesParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
81
+		$properties = $this->constraintParameterParser->parsePropertiesParameter($constraintParameters, $constraint->getConstraintTypeItemId());
82 82
 		$parameters['property'] = $properties;
83 83
 
84 84
 		$message = null;
85 85
 		$status = CheckResult::STATUS_COMPLIANCE;
86 86
 
87 87
 		/** @var Snak $qualifier */
88
-		foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) {
88
+		foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) {
89 89
 			$allowedQualifier = false;
90
-			foreach ( $properties as $property ) {
91
-				if ( $qualifier->getPropertyId()->equals( $property ) ) {
90
+			foreach ($properties as $property) {
91
+				if ($qualifier->getPropertyId()->equals($property)) {
92 92
 					$allowedQualifier = true;
93 93
 					break;
94 94
 				}
95 95
 			}
96
-			if ( !$allowedQualifier ) {
97
-				if ( empty( $properties ) || $properties === [ '' ] ) {
98
-					$message = wfMessage( 'wbqc-violation-message-no-qualifiers' );
96
+			if (!$allowedQualifier) {
97
+				if (empty($properties) || $properties === ['']) {
98
+					$message = wfMessage('wbqc-violation-message-no-qualifiers');
99 99
 					$message->rawParams(
100
-						$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY )
100
+						$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY)
101 101
 					);
102 102
 				} else {
103
-					$message = wfMessage( "wbqc-violation-message-qualifiers" );
103
+					$message = wfMessage("wbqc-violation-message-qualifiers");
104 104
 					$message->rawParams(
105
-						$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
106
-						$this->constraintParameterRenderer->formatEntityId( $qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE )
105
+						$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
106
+						$this->constraintParameterRenderer->formatEntityId($qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE)
107 107
 					);
108
-					$message->numParams( count( $properties ) );
109
-					$message->rawParams( $this->constraintParameterRenderer->formatPropertyIdList( $properties, Role::QUALIFIER_PREDICATE ) );
108
+					$message->numParams(count($properties));
109
+					$message->rawParams($this->constraintParameterRenderer->formatPropertyIdList($properties, Role::QUALIFIER_PREDICATE));
110 110
 				}
111 111
 				$message = $message->escaped();
112 112
 				$status = CheckResult::STATUS_VIOLATION;
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 			}
115 115
 		}
116 116
 
117
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
117
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
118 118
 	}
119 119
 
120
-	public function checkConstraintParameters( Constraint $constraint ) {
120
+	public function checkConstraintParameters(Constraint $constraint) {
121 121
 		$constraintParameters = $constraint->getConstraintParameters();
122 122
 		$exceptions = [];
123 123
 		try {
124
-			$this->constraintParameterParser->parsePropertiesParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
125
-		} catch ( ConstraintParameterException $e ) {
124
+			$this->constraintParameterParser->parsePropertiesParameter($constraintParameters, $constraint->getConstraintTypeItemId());
125
+		} catch (ConstraintParameterException $e) {
126 126
 			$exceptions[] = $e;
127 127
 		}
128 128
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/MandatoryQualifiersChecker.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -70,43 +70,43 @@
 block discarded – undo
70 70
 	 * @throws ConstraintParameterException
71 71
 	 * @return CheckResult
72 72
 	 */
73
-	public function checkConstraint( Context $context, Constraint $constraint ) {
74
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
75
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
73
+	public function checkConstraint(Context $context, Constraint $constraint) {
74
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
75
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
76 76
 		}
77 77
 
78 78
 		$parameters = [];
79 79
 		$constraintParameters = $constraint->getConstraintParameters();
80 80
 
81
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
82
-		$parameters['property'] = [ $propertyId ];
81
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
82
+		$parameters['property'] = [$propertyId];
83 83
 
84
-		$message = wfMessage( "wbqc-violation-message-mandatory-qualifier" )
84
+		$message = wfMessage("wbqc-violation-message-mandatory-qualifier")
85 85
 				 ->rawParams(
86
-					 $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
87
-					 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::QUALIFIER_PREDICATE )
86
+					 $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
87
+					 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::QUALIFIER_PREDICATE)
88 88
 				 )
89 89
 				 ->escaped();
90 90
 		$status = CheckResult::STATUS_VIOLATION;
91 91
 
92 92
 		/** @var Snak $qualifier */
93
-		foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) {
94
-			if ( $propertyId->equals( $qualifier->getPropertyId() ) ) {
93
+		foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) {
94
+			if ($propertyId->equals($qualifier->getPropertyId())) {
95 95
 				$message = null;
96 96
 				$status = CheckResult::STATUS_COMPLIANCE;
97 97
 				break;
98 98
 			}
99 99
 		}
100 100
 
101
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
101
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
102 102
 	}
103 103
 
104
-	public function checkConstraintParameters( Constraint $constraint ) {
104
+	public function checkConstraintParameters(Constraint $constraint) {
105 105
 		$constraintParameters = $constraint->getConstraintParameters();
106 106
 		$exceptions = [];
107 107
 		try {
108
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
109
-		} catch ( ConstraintParameterException $e ) {
108
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
109
+		} catch (ConstraintParameterException $e) {
110 110
 			$exceptions[] = $e;
111 111
 		}
112 112
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/RangeChecker.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 	 * @throws ConstraintParameterException
85 85
 	 * @return CheckResult
86 86
 	 */
87
-	public function checkConstraint( Context $context, Constraint $constraint ) {
88
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
89
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
87
+	public function checkConstraint(Context $context, Constraint $constraint) {
88
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
89
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
90 90
 		}
91 91
 
92 92
 		$parameters = [];
@@ -94,42 +94,42 @@  discard block
 block discarded – undo
94 94
 
95 95
 		$snak = $context->getSnak();
96 96
 
97
-		if ( !$snak instanceof PropertyValueSnak ) {
97
+		if (!$snak instanceof PropertyValueSnak) {
98 98
 			// nothing to check
99
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
99
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
100 100
 		}
101 101
 
102 102
 		$dataValue = $snak->getDataValue();
103 103
 
104
-		list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter(
104
+		list($min, $max) = $this->constraintParameterParser->parseRangeParameter(
105 105
 			$constraintParameters,
106 106
 			$constraint->getConstraintTypeItemId(),
107 107
 			$dataValue->getType()
108 108
 		);
109 109
 		$parameterKey = $dataValue->getType() === 'quantity' ? 'quantity' : 'date';
110
-		if ( $min !== null ) {
111
-			$parameters['minimum_' . $parameterKey] = [ $min ];
110
+		if ($min !== null) {
111
+			$parameters['minimum_'.$parameterKey] = [$min];
112 112
 		}
113
-		if ( $max !== null ) {
114
-			$parameters['maximum_' . $parameterKey] = [ $max ];
113
+		if ($max !== null) {
114
+			$parameters['maximum_'.$parameterKey] = [$max];
115 115
 		}
116 116
 
117
-		if ( $this->rangeCheckerHelper->getComparison( $min, $dataValue ) > 0 ||
118
-			 $this->rangeCheckerHelper->getComparison( $dataValue, $max ) > 0
117
+		if ($this->rangeCheckerHelper->getComparison($min, $dataValue) > 0 ||
118
+			 $this->rangeCheckerHelper->getComparison($dataValue, $max) > 0
119 119
 		) {
120 120
 			// at least one of $min, $max is set at this point, otherwise there could be no violation
121 121
 			$type = $dataValue->getType();
122
-			$openness = $min !== null ? ( $max !== null ? 'closed' : 'rightopen' ) : 'leftopen';
123
-			$message = wfMessage( "wbqc-violation-message-range-$type-$openness" );
122
+			$openness = $min !== null ? ($max !== null ? 'closed' : 'rightopen') : 'leftopen';
123
+			$message = wfMessage("wbqc-violation-message-range-$type-$openness");
124 124
 			$message->rawParams(
125
-				$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ),
126
-				$this->constraintParameterRenderer->formatDataValue( $dataValue, Role::OBJECT )
125
+				$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE),
126
+				$this->constraintParameterRenderer->formatDataValue($dataValue, Role::OBJECT)
127 127
 			);
128
-			if ( $min !== null ) {
129
-				$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) );
128
+			if ($min !== null) {
129
+				$message->rawParams($this->constraintParameterRenderer->formatDataValue($min, Role::OBJECT));
130 130
 			}
131
-			if ( $max !== null ) {
132
-				$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) );
131
+			if ($max !== null) {
132
+				$message->rawParams($this->constraintParameterRenderer->formatDataValue($max, Role::OBJECT));
133 133
 			}
134 134
 			$message = $message->escaped();
135 135
 			$status = CheckResult::STATUS_VIOLATION;
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
 			$status = CheckResult::STATUS_COMPLIANCE;
139 139
 		}
140 140
 
141
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
141
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
142 142
 	}
143 143
 
144
-	public function checkConstraintParameters( Constraint $constraint ) {
144
+	public function checkConstraintParameters(Constraint $constraint) {
145 145
 		$constraintParameters = $constraint->getConstraintParameters();
146 146
 		$exceptions = [];
147 147
 		try {
148 148
 			// we don’t have a data value here, so get the type from the property instead
149 149
 			// (the distinction between data type and data value type is irrelevant for 'quantity' and 'time')
150
-			$type = $this->propertyDataTypeLookup->getDataTypeIdForProperty( $constraint->getPropertyId() );
150
+			$type = $this->propertyDataTypeLookup->getDataTypeIdForProperty($constraint->getPropertyId());
151 151
 			$this->constraintParameterParser->parseRangeParameter(
152 152
 				$constraintParameters,
153 153
 				$constraint->getConstraintTypeItemId(),
154 154
 				$type
155 155
 			);
156
-		} catch ( ConstraintParameterException $e ) {
156
+		} catch (ConstraintParameterException $e) {
157 157
 			$exceptions[] = $e;
158 158
 		}
159 159
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/TypeChecker.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -83,34 +83,34 @@  discard block
 block discarded – undo
83 83
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
84 84
 	 * @return CheckResult
85 85
 	 */
86
-	public function checkConstraint( Context $context, Constraint $constraint ) {
87
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
88
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
86
+	public function checkConstraint(Context $context, Constraint $constraint) {
87
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
88
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
89 89
 		}
90
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
91
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE );
90
+		if ($context->getType() === Context::TYPE_REFERENCE) {
91
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE);
92 92
 		}
93 93
 
94 94
 		$parameters = [];
95 95
 		$constraintParameters = $constraint->getConstraintParameters();
96 96
 
97
-		$classes = $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
97
+		$classes = $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
98 98
 		$parameters['class'] = array_map(
99
-			function( $id ) {
100
-				return new ItemId( $id );
99
+			function($id) {
100
+				return new ItemId($id);
101 101
 			},
102 102
 			$classes
103 103
 		);
104 104
 
105
-		$relation = $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
105
+		$relation = $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
106 106
 		$relationIds = [];
107
-		if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) {
108
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
107
+		if ($relation === 'instance' || $relation === 'instanceOrSubclass') {
108
+			$relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId');
109 109
 		}
110
-		if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) {
111
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
110
+		if ($relation === 'subclass' || $relation === 'instanceOrSubclass') {
111
+			$relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId');
112 112
 		}
113
-		$parameters['relation'] = [ $relation ];
113
+		$parameters['relation'] = [$relation];
114 114
 
115 115
 		$result = $this->typeCheckerHelper->hasClassInRelation(
116 116
 			$context->getEntity()->getStatements(),
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			$classes
119 119
 		);
120 120
 
121
-		if ( $result->getBool() ) {
121
+		if ($result->getBool()) {
122 122
 			$message = null;
123 123
 			$status = CheckResult::STATUS_COMPLIANCE;
124 124
 		} else {
@@ -132,21 +132,21 @@  discard block
 block discarded – undo
132 132
 			$status = CheckResult::STATUS_VIOLATION;
133 133
 		}
134 134
 
135
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
136
-			->withMetadata( $result->getMetadata() );
135
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
136
+			->withMetadata($result->getMetadata());
137 137
 	}
138 138
 
139
-	public function checkConstraintParameters( Constraint $constraint ) {
139
+	public function checkConstraintParameters(Constraint $constraint) {
140 140
 		$constraintParameters = $constraint->getConstraintParameters();
141 141
 		$exceptions = [];
142 142
 		try {
143
-			$this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
144
-		} catch ( ConstraintParameterException $e ) {
143
+			$this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
144
+		} catch (ConstraintParameterException $e) {
145 145
 			$exceptions[] = $e;
146 146
 		}
147 147
 		try {
148
-			$this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
149
-		} catch ( ConstraintParameterException $e ) {
148
+			$this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
149
+		} catch (ConstraintParameterException $e) {
150 150
 			$exceptions[] = $e;
151 151
 		}
152 152
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/UniqueValueChecker.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -72,22 +72,22 @@  discard block
 block discarded – undo
72 72
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
73 73
 	 * @return CheckResult
74 74
 	 */
75
-	public function checkConstraint( Context $context, Constraint $constraint ) {
76
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
77
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
75
+	public function checkConstraint(Context $context, Constraint $constraint) {
76
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
77
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
78 78
 		}
79 79
 
80 80
 		$parameters = [];
81 81
 
82
-		if ( $this->sparqlHelper !== null ) {
83
-			if ( $context->getType() === 'statement' ) {
82
+		if ($this->sparqlHelper !== null) {
83
+			if ($context->getType() === 'statement') {
84 84
 				$result = $this->sparqlHelper->findEntitiesWithSameStatement(
85 85
 					$context->getSnakStatement(),
86 86
 					true // ignore deprecated statements
87 87
 				);
88 88
 			} else {
89
-				if ( $context->getSnak()->getType() !== 'value' ) {
90
-					return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
89
+				if ($context->getSnak()->getType() !== 'value') {
90
+					return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
91 91
 				}
92 92
 				$result = $this->sparqlHelper->findEntitiesWithSameQualifierOrReference(
93 93
 					$context->getEntity()->getId(),
@@ -100,29 +100,29 @@  discard block
 block discarded – undo
100 100
 			$otherEntities = $result->getArray();
101 101
 			$metadata = $result->getMetadata();
102 102
 
103
-			if ( $otherEntities === [] ) {
103
+			if ($otherEntities === []) {
104 104
 				$status = CheckResult::STATUS_COMPLIANCE;
105 105
 				$message = null;
106 106
 			} else {
107 107
 				$status = CheckResult::STATUS_VIOLATION;
108
-				$message = wfMessage( 'wbqc-violation-message-unique-value' )
109
-						 ->numParams( count( $otherEntities ) )
110
-						 ->rawParams( $this->constraintParameterRenderer->formatEntityIdList( $otherEntities, Role::SUBJECT ) )
108
+				$message = wfMessage('wbqc-violation-message-unique-value')
109
+						 ->numParams(count($otherEntities))
110
+						 ->rawParams($this->constraintParameterRenderer->formatEntityIdList($otherEntities, Role::SUBJECT))
111 111
 						 ->escaped();
112 112
 			}
113 113
 		} else {
114 114
 			$status = CheckResult::STATUS_TODO;
115
-			$message = wfMessage( "wbqc-violation-message-not-yet-implemented" )
116
-					 ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
115
+			$message = wfMessage("wbqc-violation-message-not-yet-implemented")
116
+					 ->rawParams($this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM))
117 117
 					 ->escaped();
118 118
 			$metadata = Metadata::blank();
119 119
 		}
120 120
 
121
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
122
-			->withMetadata( $metadata );
121
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
122
+			->withMetadata($metadata);
123 123
 	}
124 124
 
125
-	public function checkConstraintParameters( Constraint $constraint ) {
125
+	public function checkConstraintParameters(Constraint $constraint) {
126 126
 		// no parameters
127 127
 		return [];
128 128
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ItemChecker.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -85,18 +85,18 @@  discard block
 block discarded – undo
85 85
 	 * @throws ConstraintParameterException
86 86
 	 * @return CheckResult
87 87
 	 */
88
-	public function checkConstraint( Context $context, Constraint $constraint ) {
89
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
90
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
88
+	public function checkConstraint(Context $context, Constraint $constraint) {
89
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
90
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
91 91
 		}
92 92
 
93 93
 		$parameters = [];
94 94
 		$constraintParameters = $constraint->getConstraintParameters();
95 95
 
96
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
97
-		$parameters['property'] = [ $propertyId ];
96
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
97
+		$parameters['property'] = [$propertyId];
98 98
 
99
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
99
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
100 100
 		$parameters['items'] = $items;
101 101
 
102 102
 		/*
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		 *   a) a property only
105 105
 		 *   b) a property and a number of items (each combination of property and item forming an individual claim)
106 106
 		 */
107
-		if ( $items === [] ) {
107
+		if ($items === []) {
108 108
 			$requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty(
109 109
 				$context->getEntity()->getStatements(),
110 110
 				$propertyId
@@ -117,35 +117,35 @@  discard block
 block discarded – undo
117 117
 			);
118 118
 		}
119 119
 
120
-		if ( $requiredStatement !== null ) {
120
+		if ($requiredStatement !== null) {
121 121
 			$status = CheckResult::STATUS_COMPLIANCE;
122 122
 			$message = null;
123 123
 		} else {
124 124
 			$status = CheckResult::STATUS_VIOLATION;
125
-			$message = wfMessage( 'wbqc-violation-message-item' );
125
+			$message = wfMessage('wbqc-violation-message-item');
126 126
 			$message->rawParams(
127
-				$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
128
-				$this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE )
127
+				$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
128
+				$this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE)
129 129
 			);
130
-			$message->numParams( count( $items ) );
131
-			$message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) );
130
+			$message->numParams(count($items));
131
+			$message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT));
132 132
 			$message = $message->escaped();
133 133
 		}
134 134
 
135
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
135
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
136 136
 	}
137 137
 
138
-	public function checkConstraintParameters( Constraint $constraint ) {
138
+	public function checkConstraintParameters(Constraint $constraint) {
139 139
 		$constraintParameters = $constraint->getConstraintParameters();
140 140
 		$exceptions = [];
141 141
 		try {
142
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
143
-		} catch ( ConstraintParameterException $e ) {
142
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
143
+		} catch (ConstraintParameterException $e) {
144 144
 			$exceptions[] = $e;
145 145
 		}
146 146
 		try {
147
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
148
-		} catch ( ConstraintParameterException $e ) {
147
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
148
+		} catch (ConstraintParameterException $e) {
149 149
 			$exceptions[] = $e;
150 150
 		}
151 151
 		return $exceptions;
Please login to merge, or discard this patch.