Completed
Push — master ( 44effd...b7045c )
by
unknown
05:40 queued 02:09
created
WikibaseQualityConstraints.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( function_exists( 'wfLoadExtension' ) ) {
4
-	wfLoadExtension( 'WikibaseQualityConstraints', __DIR__ . '/extension.json' );
3
+if (function_exists('wfLoadExtension')) {
4
+	wfLoadExtension('WikibaseQualityConstraints', __DIR__.'/extension.json');
5 5
 	// Keep i18n globals so mergeMessageFileList.php doesn't break
6
-	$wgMessagesDirs['WikibaseQualityConstraints'] = __DIR__ . '/i18n';
7
-	$wgExtensionMessagesFiles['WikibaseQualityConstraintsAlias'] = __DIR__ . '/WikibaseQualityConstraints.alias.php';
6
+	$wgMessagesDirs['WikibaseQualityConstraints'] = __DIR__.'/i18n';
7
+	$wgExtensionMessagesFiles['WikibaseQualityConstraintsAlias'] = __DIR__.'/WikibaseQualityConstraints.alias.php';
8 8
 	/* wfWarn(
9 9
 		'Deprecated PHP entry point used for WikibaseQualityConstraints extension. ' .
10 10
 		'Please use wfLoadExtension instead, ' .
@@ -12,5 +12,5 @@  discard block
 block discarded – undo
12 12
 	); */
13 13
 	return;
14 14
 } else {
15
-	die( 'This version of the WikibaseQualityConstraints extension requires MediaWiki 1.25+' );
15
+	die('This version of the WikibaseQualityConstraints extension requires MediaWiki 1.25+');
16 16
 }
Please login to merge, or discard this patch.
WikibaseQualityConstraints.alias.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,5 +10,5 @@
 block discarded – undo
10 10
 
11 11
 /** English (English) */
12 12
 $specialPageAliases['en'] = [
13
-	'ConstraintReport' => [ 'ConstraintReport', 'Constraint Report' ],
13
+	'ConstraintReport' => ['ConstraintReport', 'Constraint Report'],
14 14
 ];
Please login to merge, or discard this patch.
maintenance/ImportConstraintStatements.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@  discard block
 block discarded – undo
8 8
 use WikibaseQuality\ConstraintReport\UpdateConstraintsTableJob;
9 9
 use Wikibase\Repo\WikibaseRepo;
10 10
 
11
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
12
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
11
+$basePath = getenv("MW_INSTALL_PATH") !== false
12
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
13 13
 
14
-require_once $basePath . "/maintenance/Maintenance.php";
14
+require_once $basePath."/maintenance/Maintenance.php";
15 15
 
16 16
 /**
17 17
  * Runs {@link UpdateConstraintsTableJob} once for every property.
@@ -23,23 +23,23 @@  discard block
 block discarded – undo
23 23
 	public function __construct() {
24 24
 		parent::__construct();
25 25
 
26
-		$this->addDescription( 'Imports property constraints from statements on properties' );
26
+		$this->addDescription('Imports property constraints from statements on properties');
27 27
 	}
28 28
 
29 29
 	public function execute() {
30
-		if ( !MediaWikiServices::getInstance()->getMainConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
31
-			$this->error( 'Constraint statements are not enabled. Aborting.', 1 );
30
+		if (!MediaWikiServices::getInstance()->getMainConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) {
31
+			$this->error('Constraint statements are not enabled. Aborting.', 1);
32 32
 		}
33 33
 
34 34
 		$propertyInfoLookup = WikibaseRepo::getDefaultInstance()->getStore()->getPropertyInfoLookup();
35
-		foreach ( $propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info ) {
36
-			$this->output( sprintf( 'Importing constraint statements for % 6s... ', $propertyIdSerialization ), $propertyIdSerialization );
37
-			$startTime = microtime( true );
38
-			$job = UpdateConstraintsTableJob::newFromGlobalState( Title::newMainPage(), [ 'propertyId' => $propertyIdSerialization ] );
35
+		foreach ($propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info) {
36
+			$this->output(sprintf('Importing constraint statements for % 6s... ', $propertyIdSerialization), $propertyIdSerialization);
37
+			$startTime = microtime(true);
38
+			$job = UpdateConstraintsTableJob::newFromGlobalState(Title::newMainPage(), ['propertyId' => $propertyIdSerialization]);
39 39
 			$job->run();
40
-			$endTime = microtime( true );
41
-			$millis = ( $endTime - $startTime ) * 1000;
42
-			$this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization );
40
+			$endTime = microtime(true);
41
+			$millis = ($endTime - $startTime) * 1000;
42
+			$this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization);
43 43
 		}
44 44
 	}
45 45
 
Please login to merge, or discard this patch.
src/ConstraintCheck/DelegatingConstraintChecker.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	}
271 271
 
272 272
 	/**
273
-	 * @param EntityDocument|StatementListProvider $entity
273
+	 * @param EntityDocument $entity
274 274
 	 * @param string[]|null $constraintIds list of constraints to check (if null: all constraints)
275 275
 	 * @param callable|null $defaultResults optional function to pre-populate the check results
276 276
 	 *
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	}
299 299
 
300 300
 	/**
301
-	 * @param EntityDocument|StatementListProvider $entity
301
+	 * @param EntityDocument $entity
302 302
 	 * @param Statement $statement
303 303
 	 * @param string[]|null $constraintIds list of constraints to check (if null: all constraints)
304 304
 	 * @param callable|null $defaultResults optional function to pre-populate the check results
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
 		callable $defaultResults = null
138 138
 	) {
139 139
 
140
-		$entity = $this->entityLookup->getEntity( $entityId );
141
-		if ( $entity instanceof StatementListProvider ) {
140
+		$entity = $this->entityLookup->getEntity($entityId);
141
+		if ($entity instanceof StatementListProvider) {
142 142
 			$result = $this->checkEveryStatement(
143
-				$this->entityLookup->getEntity( $entityId ),
143
+				$this->entityLookup->getEntity($entityId),
144 144
 				$constraintIds,
145 145
 				$defaultResults
146 146
 			);
147
-			$output = $this->sortResult( $result );
147
+			$output = $this->sortResult($result);
148 148
 			return $output;
149 149
 		}
150 150
 
@@ -170,19 +170,19 @@  discard block
 block discarded – undo
170 170
 		callable $defaultResults = null
171 171
 	) {
172 172
 
173
-		$parsedGuid = $this->statementGuidParser->parse( $guid );
173
+		$parsedGuid = $this->statementGuidParser->parse($guid);
174 174
 		$entityId = $parsedGuid->getEntityId();
175
-		$entity = $this->entityLookup->getEntity( $entityId );
176
-		if ( $entity instanceof StatementListProvider ) {
177
-			$statement = $entity->getStatements()->getFirstStatementWithGuid( $guid );
178
-			if ( $statement ) {
175
+		$entity = $this->entityLookup->getEntity($entityId);
176
+		if ($entity instanceof StatementListProvider) {
177
+			$statement = $entity->getStatements()->getFirstStatementWithGuid($guid);
178
+			if ($statement) {
179 179
 				$result = $this->checkStatement(
180 180
 					$entity,
181 181
 					$statement,
182 182
 					$constraintIds,
183 183
 					$defaultResults
184 184
 				);
185
-				$output = $this->sortResult( $result );
185
+				$output = $this->sortResult($result);
186 186
 				return $output;
187 187
 			}
188 188
 		}
@@ -198,23 +198,23 @@  discard block
 block discarded – undo
198 198
 	 *
199 199
 	 * @return ConstraintParameterException[]
200 200
 	 */
201
-	private function checkCommonConstraintParameters( Constraint $constraint ) {
201
+	private function checkCommonConstraintParameters(Constraint $constraint) {
202 202
 		$constraintParameters = $constraint->getConstraintParameters();
203 203
 		try {
204
-			$this->constraintParameterParser->checkError( $constraintParameters );
205
-		} catch ( ConstraintParameterException $e ) {
206
-			return [ $e ];
204
+			$this->constraintParameterParser->checkError($constraintParameters);
205
+		} catch (ConstraintParameterException $e) {
206
+			return [$e];
207 207
 		}
208 208
 
209 209
 		$problems = [];
210 210
 		try {
211
-			$this->constraintParameterParser->parseExceptionParameter( $constraintParameters );
212
-		} catch ( ConstraintParameterException $e ) {
211
+			$this->constraintParameterParser->parseExceptionParameter($constraintParameters);
212
+		} catch (ConstraintParameterException $e) {
213 213
 			$problems[] = $e;
214 214
 		}
215 215
 		try {
216
-			$this->constraintParameterParser->parseConstraintStatusParameter( $constraintParameters );
217
-		} catch ( ConstraintParameterException $e ) {
216
+			$this->constraintParameterParser->parseConstraintStatusParameter($constraintParameters);
217
+		} catch (ConstraintParameterException $e) {
218 218
 			$problems[] = $e;
219 219
 		}
220 220
 		return $problems;
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
 	 * @return ConstraintParameterException[][] first level indexed by constraint ID,
228 228
 	 * second level like checkConstraintParametersOnConstraintId (but without possibility of null)
229 229
 	 */
230
-	public function checkConstraintParametersOnPropertyId( PropertyId $propertyId ) {
231
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
230
+	public function checkConstraintParametersOnPropertyId(PropertyId $propertyId) {
231
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
232 232
 		$result = [];
233 233
 
234
-		foreach ( $constraints as $constraint ) {
235
-			$problems = $this->checkCommonConstraintParameters( $constraint );
234
+		foreach ($constraints as $constraint) {
235
+			$problems = $this->checkCommonConstraintParameters($constraint);
236 236
 
237
-			if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
237
+			if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
238 238
 				$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
239
-				$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
239
+				$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
240 240
 			}
241 241
 
242 242
 			$result[$constraint->getConstraintId()] = $problems;
@@ -253,17 +253,17 @@  discard block
 block discarded – undo
253 253
 	 * @return ConstraintParameterException[]|null list of constraint parameter exceptions
254 254
 	 * (empty means all parameters okay), or null if constraint is not found
255 255
 	 */
256
-	public function checkConstraintParametersOnConstraintId( $constraintId ) {
257
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
258
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
256
+	public function checkConstraintParametersOnConstraintId($constraintId) {
257
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
258
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
259 259
 
260
-		foreach ( $constraints as $constraint ) {
261
-			if ( $constraint->getConstraintId() === $constraintId ) {
262
-				$problems = $this->checkCommonConstraintParameters( $constraint );
260
+		foreach ($constraints as $constraint) {
261
+			if ($constraint->getConstraintId() === $constraintId) {
262
+				$problems = $this->checkCommonConstraintParameters($constraint);
263 263
 
264
-				if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
264
+				if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
265 265
 					$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
266
-					$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
266
+					$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
267 267
 				}
268 268
 
269 269
 				return $problems;
@@ -288,14 +288,14 @@  discard block
 block discarded – undo
288 288
 		$result = [];
289 289
 
290 290
 		/** @var Statement $statement */
291
-		foreach ( $entity->getStatements() as $statement ) {
292
-			$result = array_merge( $result,
291
+		foreach ($entity->getStatements() as $statement) {
292
+			$result = array_merge($result,
293 293
 				$this->checkStatement(
294 294
 					$entity,
295 295
 					$statement,
296 296
 					$constraintIds,
297 297
 					$defaultResults
298
-				) );
298
+				));
299 299
 		}
300 300
 
301 301
 		return $result;
@@ -317,32 +317,32 @@  discard block
 block discarded – undo
317 317
 	) {
318 318
 		$result = [];
319 319
 
320
-		$result = array_merge( $result,
320
+		$result = array_merge($result,
321 321
 			$this->checkConstraintsForMainSnak(
322 322
 				$entity,
323 323
 				$statement,
324 324
 				$constraintIds,
325 325
 				$defaultResults
326
-			) );
326
+			));
327 327
 
328
-		if ( $this->checkQualifiers ) {
329
-			$result = array_merge( $result,
328
+		if ($this->checkQualifiers) {
329
+			$result = array_merge($result,
330 330
 				$this->checkConstraintsForQualifiers(
331 331
 					$entity,
332 332
 					$statement,
333 333
 					$constraintIds,
334 334
 					$defaultResults
335
-				) );
335
+				));
336 336
 		}
337 337
 
338
-		if ( $this->checkReferences ) {
339
-			$result = array_merge( $result,
338
+		if ($this->checkReferences) {
339
+			$result = array_merge($result,
340 340
 				$this->checkConstraintsForReferences(
341 341
 					$entity,
342 342
 					$statement,
343 343
 					$constraintIds,
344 344
 					$defaultResults
345
-				) );
345
+				));
346 346
 		}
347 347
 
348 348
 		return $result;
@@ -357,12 +357,12 @@  discard block
 block discarded – undo
357 357
 	 * @param string[]|null $constraintIds
358 358
 	 * @return Constraint[]
359 359
 	 */
360
-	private function getConstraintsToUse( PropertyId $propertyId, array $constraintIds = null ) {
361
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
362
-		if ( $constraintIds !== null ) {
360
+	private function getConstraintsToUse(PropertyId $propertyId, array $constraintIds = null) {
361
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
362
+		if ($constraintIds !== null) {
363 363
 			$constraintsToUse = [];
364
-			foreach ( $constraints as $constraint ) {
365
-				if ( in_array( $constraint->getConstraintId(), $constraintIds ) ) {
364
+			foreach ($constraints as $constraint) {
365
+				if (in_array($constraint->getConstraintId(), $constraintIds)) {
366 366
 					$constraintsToUse[] = $constraint;
367 367
 				}
368 368
 			}
@@ -386,29 +386,29 @@  discard block
 block discarded – undo
386 386
 		array $constraintIds = null,
387 387
 		callable $defaultResults = null
388 388
 	) {
389
-		$context = new MainSnakContext( $entity, $statement );
389
+		$context = new MainSnakContext($entity, $statement);
390 390
 		$constraints = $this->getConstraintsToUse(
391 391
 			$statement->getPropertyId(),
392 392
 			$constraintIds
393 393
 		);
394
-		$result = $defaultResults !== null ? $defaultResults( $context ) : [];
394
+		$result = $defaultResults !== null ? $defaultResults($context) : [];
395 395
 
396
-		foreach ( $constraints as $constraint ) {
396
+		foreach ($constraints as $constraint) {
397 397
 			$parameters = $constraint->getConstraintParameters();
398 398
 			try {
399
-				$exceptions = $this->constraintParameterParser->parseExceptionParameter( $parameters );
400
-			} catch ( ConstraintParameterException $e ) {
401
-				$result[] = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage() );
399
+				$exceptions = $this->constraintParameterParser->parseExceptionParameter($parameters);
400
+			} catch (ConstraintParameterException $e) {
401
+				$result[] = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage());
402 402
 				continue;
403 403
 			}
404 404
 
405
-			if ( in_array( $entity->getId(), $exceptions ) ) {
406
-				$message = wfMessage( 'wbqc-exception-message' )->escaped();
407
-				$result[] = new CheckResult( $context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message );
405
+			if (in_array($entity->getId(), $exceptions)) {
406
+				$message = wfMessage('wbqc-exception-message')->escaped();
407
+				$result[] = new CheckResult($context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message);
408 408
 				continue;
409 409
 			}
410 410
 
411
-			$result[] = $this->getCheckResultFor( $context, $constraint );
411
+			$result[] = $this->getCheckResultFor($context, $constraint);
412 412
 		}
413 413
 
414 414
 		return $result;
@@ -430,24 +430,24 @@  discard block
 block discarded – undo
430 430
 	) {
431 431
 		$result = [];
432 432
 
433
-		if ( in_array(
433
+		if (in_array(
434 434
 			$statement->getPropertyId()->getSerialization(),
435 435
 			$this->propertiesWithViolatingQualifiers
436
-		) ) {
436
+		)) {
437 437
 			return $result;
438 438
 		}
439 439
 
440
-		foreach ( $statement->getQualifiers() as $qualifier ) {
441
-			$qualifierContext = new QualifierContext( $entity, $statement, $qualifier );
442
-			if ( $defaultResults !== null ) {
443
-				$result = array_merge( $result, $defaultResults( $qualifierContext ) );
440
+		foreach ($statement->getQualifiers() as $qualifier) {
441
+			$qualifierContext = new QualifierContext($entity, $statement, $qualifier);
442
+			if ($defaultResults !== null) {
443
+				$result = array_merge($result, $defaultResults($qualifierContext));
444 444
 			}
445 445
 			$qualifierConstraints = $this->getConstraintsToUse(
446 446
 				$qualifierContext->getSnak()->getPropertyId(),
447 447
 				$constraintIds
448 448
 			);
449
-			foreach ( $qualifierConstraints as $qualifierConstraint ) {
450
-				$result[] = $this->getCheckResultFor( $qualifierContext, $qualifierConstraint );
449
+			foreach ($qualifierConstraints as $qualifierConstraint) {
450
+				$result[] = $this->getCheckResultFor($qualifierContext, $qualifierConstraint);
451 451
 			}
452 452
 		}
453 453
 
@@ -471,19 +471,19 @@  discard block
 block discarded – undo
471 471
 		$result = [];
472 472
 
473 473
 		/** @var Reference $reference */
474
-		foreach ( $statement->getReferences() as $reference ) {
475
-			foreach ( $reference->getSnaks() as $snak ) {
474
+		foreach ($statement->getReferences() as $reference) {
475
+			foreach ($reference->getSnaks() as $snak) {
476 476
 				$referenceContext = new ReferenceContext(
477 477
 					$entity, $statement, $reference, $snak
478 478
 				);
479
-				if ( $defaultResults !== null ) {
480
-					$result = array_merge( $result, $defaultResults( $referenceContext ) );
479
+				if ($defaultResults !== null) {
480
+					$result = array_merge($result, $defaultResults($referenceContext));
481 481
 				}
482 482
 				$referenceConstraints = $this->getConstraintsToUse(
483 483
 					$referenceContext->getSnak()->getPropertyId(),
484 484
 					$constraintIds
485 485
 				);
486
-				foreach ( $referenceConstraints as $referenceConstraint ) {
486
+				foreach ($referenceConstraints as $referenceConstraint) {
487 487
 					$result[] = $this->getCheckResultFor(
488 488
 						$referenceContext,
489 489
 						$referenceConstraint
@@ -502,70 +502,70 @@  discard block
 block discarded – undo
502 502
 	 * @throws InvalidArgumentException
503 503
 	 * @return CheckResult
504 504
 	 */
505
-	private function getCheckResultFor( Context $context, Constraint $constraint ) {
506
-		if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
505
+	private function getCheckResultFor(Context $context, Constraint $constraint) {
506
+		if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
507 507
 			$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
508 508
 
509
-			$startTime = microtime( true );
509
+			$startTime = microtime(true);
510 510
 			try {
511
-				$result = $checker->checkConstraint( $context, $constraint );
512
-			} catch ( ConstraintParameterException $e ) {
513
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage() );
514
-			} catch ( SparqlHelperException $e ) {
515
-				$message = wfMessage( 'wbqc-violation-message-sparql-error' )->escaped();
516
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
511
+				$result = $checker->checkConstraint($context, $constraint);
512
+			} catch (ConstraintParameterException $e) {
513
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage());
514
+			} catch (SparqlHelperException $e) {
515
+				$message = wfMessage('wbqc-violation-message-sparql-error')->escaped();
516
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
517 517
 			}
518
-			$endTime = microtime( true );
518
+			$endTime = microtime(true);
519 519
 
520
-			$this->addMetadata( $result );
520
+			$this->addMetadata($result);
521 521
 
522 522
 			try {
523 523
 				$constraintStatus = $this->constraintParameterParser
524
-					->parseConstraintStatusParameter( $constraint->getConstraintParameters() );
525
-			} catch ( ConstraintParameterException $e ) {
526
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage() );
524
+					->parseConstraintStatusParameter($constraint->getConstraintParameters());
525
+			} catch (ConstraintParameterException $e) {
526
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage());
527 527
 				$constraintStatus = null;
528 528
 			}
529
-			if ( $constraintStatus === null ) {
529
+			if ($constraintStatus === null) {
530 530
 				// downgrade violation to warning
531
-				if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
532
-					$result->setStatus( CheckResult::STATUS_WARNING );
531
+				if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
532
+					$result->setStatus(CheckResult::STATUS_WARNING);
533 533
 				}
534 534
 			} else {
535
-				if ( $constraintStatus !== 'mandatory' ) {
535
+				if ($constraintStatus !== 'mandatory') {
536 536
 					// @codeCoverageIgnoreStart
537 537
 					throw new LogicException(
538
-						"Unknown constraint status '$constraintStatus', " .
538
+						"Unknown constraint status '$constraintStatus', ".
539 539
 						"only known status is 'mandatory'"
540 540
 					);
541 541
 					// @codeCoverageIgnoreEnd
542 542
 				}
543
-				$result->addParameter( 'constraint_status', $constraintStatus );
543
+				$result->addParameter('constraint_status', $constraintStatus);
544 544
 			}
545 545
 
546 546
 			$this->loggingHelper->logConstraintCheck(
547 547
 				$context,
548 548
 				$constraint,
549 549
 				$result,
550
-				get_class( $checker ),
550
+				get_class($checker),
551 551
 				$endTime - $startTime,
552 552
 				__METHOD__
553 553
 			);
554 554
 
555 555
 			return $result;
556 556
 		} else {
557
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
557
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
558 558
 		}
559 559
 	}
560 560
 
561
-	private function addMetadata( CheckResult $result ) {
562
-		$result->withMetadata( Metadata::merge( [
561
+	private function addMetadata(CheckResult $result) {
562
+		$result->withMetadata(Metadata::merge([
563 563
 			$result->getMetadata(),
564
-			Metadata::ofDependencyMetadata( DependencyMetadata::merge( [
565
-				DependencyMetadata::ofEntityId( $result->getEntityId() ),
566
-				DependencyMetadata::ofEntityId( $result->getConstraint()->getPropertyId() ),
567
-			] ) ),
568
-		] ) );
564
+			Metadata::ofDependencyMetadata(DependencyMetadata::merge([
565
+				DependencyMetadata::ofEntityId($result->getEntityId()),
566
+				DependencyMetadata::ofEntityId($result->getConstraint()->getPropertyId()),
567
+			])),
568
+		]));
569 569
 	}
570 570
 
571 571
 	/**
@@ -573,12 +573,12 @@  discard block
 block discarded – undo
573 573
 	 *
574 574
 	 * @return CheckResult[]
575 575
 	 */
576
-	private function sortResult( array $result ) {
577
-		if ( count( $result ) < 2 ) {
576
+	private function sortResult(array $result) {
577
+		if (count($result) < 2) {
578 578
 			return $result;
579 579
 		}
580 580
 
581
-		$sortFunction = function ( CheckResult $a, CheckResult $b ) {
581
+		$sortFunction = function(CheckResult $a, CheckResult $b) {
582 582
 			$orderNum = 0;
583 583
 			$order = [
584 584
 				CheckResult::STATUS_BAD_PARAMETERS => $orderNum++,
@@ -594,45 +594,45 @@  discard block
 block discarded – undo
594 594
 			$statusA = $a->getStatus();
595 595
 			$statusB = $b->getStatus();
596 596
 
597
-			$orderA = array_key_exists( $statusA, $order ) ? $order[ $statusA ] : $order[ 'other' ];
598
-			$orderB = array_key_exists( $statusB, $order ) ? $order[ $statusB ] : $order[ 'other' ];
597
+			$orderA = array_key_exists($statusA, $order) ? $order[$statusA] : $order['other'];
598
+			$orderB = array_key_exists($statusB, $order) ? $order[$statusB] : $order['other'];
599 599
 
600
-			if ( $orderA === $orderB ) {
600
+			if ($orderA === $orderB) {
601 601
 				$pidA = $a->getContext()->getSnak()->getPropertyId()->getSerialization();
602 602
 				$pidB = $b->getContext()->getSnak()->getPropertyId()->getSerialization();
603 603
 
604
-				if ( $pidA === $pidB ) {
604
+				if ($pidA === $pidB) {
605 605
 					$hashA = $a->getContext()->getSnak()->getHash();
606 606
 					$hashB = $b->getContext()->getSnak()->getHash();
607 607
 
608
-					if ( $hashA === $hashB ) {
609
-						if ( $a instanceof NullResult ) {
608
+					if ($hashA === $hashB) {
609
+						if ($a instanceof NullResult) {
610 610
 							return $b instanceof NullResult ? 0 : -1;
611 611
 						}
612
-						if ( $b instanceof NullResult ) {
612
+						if ($b instanceof NullResult) {
613 613
 							return $a instanceof NullResult ? 0 : 1;
614 614
 						}
615 615
 
616 616
 						$typeA = $a->getConstraint()->getConstraintTypeItemId();
617 617
 						$typeB = $b->getConstraint()->getConstraintTypeItemId();
618 618
 
619
-						if ( $typeA == $typeB ) {
619
+						if ($typeA == $typeB) {
620 620
 							return 0;
621 621
 						} else {
622
-							return ( $typeA > $typeB ) ? 1 : -1;
622
+							return ($typeA > $typeB) ? 1 : -1;
623 623
 						}
624 624
 					} else {
625
-						return ( $hashA > $hashB ) ? 1 : -1;
625
+						return ($hashA > $hashB) ? 1 : -1;
626 626
 					}
627 627
 				} else {
628
-					return ( $pidA > $pidB ) ? 1 : -1;
628
+					return ($pidA > $pidB) ? 1 : -1;
629 629
 				}
630 630
 			} else {
631
-				return ( $orderA > $orderB ) ? 1 : -1;
631
+				return ($orderA > $orderB) ? 1 : -1;
632 632
 			}
633 633
 		};
634 634
 
635
-		uasort( $result, $sortFunction );
635
+		uasort($result, $sortFunction);
636 636
 
637 637
 		return $result;
638 638
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/RangeCheckerHelper.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -119,8 +119,8 @@
 block discarded – undo
119 119
 	 * for quantity values, the difference is the numerical difference between the quantities,
120 120
 	 * after attempting normalization of each side.
121 121
 	 *
122
-	 * @param TimeValue|QuantityValue|UnboundedQuantityValue $minuend
123
-	 * @param TimeValue|QuantityValue|UnboundedQuantityValue $subtrahend
122
+	 * @param DataValue $minuend
123
+	 * @param DataValue $subtrahend
124 124
 	 *
125 125
 	 * @throws InvalidArgumentException if the values do not both have the same, supported data value type
126 126
 	 * @return UnboundedQuantityValue
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		UnitConverter $unitConverter = null
48 48
 	) {
49 49
 		$this->config = $config;
50
-		$this->timeParser = ( new TimeParserFactory() )->getTimeParser();
50
+		$this->timeParser = (new TimeParserFactory())->getTimeParser();
51 51
 		$this->timeCalculator = new TimeValueCalculator();
52 52
 		$this->unitConverter = $unitConverter;
53 53
 	}
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 	 * @param UnboundedQuantityValue $value
57 57
 	 * @return UnboundedQuantityValue $value converted to standard units if possible, otherwise unchanged $value.
58 58
 	 */
59
-	private function standardize( UnboundedQuantityValue $value ) {
60
-		if ( $this->unitConverter !== null ) {
61
-			$standard = $this->unitConverter->toStandardUnits( $value );
62
-			if ( $standard !== null ) {
59
+	private function standardize(UnboundedQuantityValue $value) {
60
+		if ($this->unitConverter !== null) {
61
+			$standard = $this->unitConverter->toStandardUnits($value);
62
+			if ($standard !== null) {
63 63
 				return $standard;
64 64
 			} else {
65 65
 				return $value;
@@ -81,23 +81,23 @@  discard block
 block discarded – undo
81 81
 	 *                 when $lhs is respectively less than, equal to, or greater than $rhs.
82 82
 	 *                 (In other words, just like the “spaceship” operator <=>.)
83 83
 	 */
84
-	public function getComparison( DataValue $lhs = null, DataValue $rhs = null ) {
85
-		if ( $lhs === null || $rhs === null ) {
84
+	public function getComparison(DataValue $lhs = null, DataValue $rhs = null) {
85
+		if ($lhs === null || $rhs === null) {
86 86
 			return 0;
87 87
 		}
88 88
 
89
-		if ( $lhs->getType() !== $rhs->getType() ) {
90
-			throw new InvalidArgumentException( 'Different data value types' );
89
+		if ($lhs->getType() !== $rhs->getType()) {
90
+			throw new InvalidArgumentException('Different data value types');
91 91
 		}
92 92
 
93
-		switch ( $lhs->getType() ) {
93
+		switch ($lhs->getType()) {
94 94
 			case 'time':
95 95
 				/** @var TimeValue $lhs */
96 96
 				/** @var TimeValue $rhs */
97
-				$lhsTimestamp = $this->timeCalculator->getTimestamp( $lhs );
98
-				$rhsTimestamp = $this->timeCalculator->getTimestamp( $rhs );
97
+				$lhsTimestamp = $this->timeCalculator->getTimestamp($lhs);
98
+				$rhsTimestamp = $this->timeCalculator->getTimestamp($rhs);
99 99
 
100
-				if ( $lhsTimestamp === $rhsTimestamp ) {
100
+				if ($lhsTimestamp === $rhsTimestamp) {
101 101
 					return 0;
102 102
 				}
103 103
 
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
 			case 'quantity':
106 106
 				/** @var QuantityValue|UnboundedQuantityValue $lhs */
107 107
 				/** @var QuantityValue|UnboundedQuantityValue $rhs */
108
-				$lhsStandard = $this->standardize( $lhs );
109
-				$rhsStandard = $this->standardize( $rhs );
110
-				return $lhsStandard->getAmount()->compare( $rhsStandard->getAmount() );
108
+				$lhsStandard = $this->standardize($lhs);
109
+				$rhsStandard = $this->standardize($rhs);
110
+				return $lhsStandard->getAmount()->compare($rhsStandard->getAmount());
111 111
 		}
112 112
 
113
-		throw new InvalidArgumentException( 'Unsupported data value type' );
113
+		throw new InvalidArgumentException('Unsupported data value type');
114 114
 	}
115 115
 
116 116
 	/**
@@ -125,83 +125,83 @@  discard block
 block discarded – undo
125 125
 	 * @throws InvalidArgumentException if the values do not both have the same, supported data value type
126 126
 	 * @return UnboundedQuantityValue
127 127
 	 */
128
-	public function getDifference( DataValue $minuend, DataValue $subtrahend ) {
129
-		if ( $minuend->getType() === 'time' && $subtrahend->getType() === 'time' ) {
130
-			$minuendSeconds = $this->timeCalculator->getTimestamp( $minuend );
131
-			$subtrahendSeconds = $this->timeCalculator->getTimestamp( $subtrahend );
128
+	public function getDifference(DataValue $minuend, DataValue $subtrahend) {
129
+		if ($minuend->getType() === 'time' && $subtrahend->getType() === 'time') {
130
+			$minuendSeconds = $this->timeCalculator->getTimestamp($minuend);
131
+			$subtrahendSeconds = $this->timeCalculator->getTimestamp($subtrahend);
132 132
 			return UnboundedQuantityValue::newFromNumber(
133 133
 				$minuendSeconds - $subtrahendSeconds,
134
-				$this->config->get( 'WBQualityConstraintsSecondUnit' )
134
+				$this->config->get('WBQualityConstraintsSecondUnit')
135 135
 			);
136 136
 		}
137
-		if ( $minuend->getType() === 'quantity' && $subtrahend->getType() === 'quantity' ) {
138
-			$minuendStandard = $this->standardize( $minuend );
139
-			$subtrahendStandard = $this->standardize( $subtrahend );
137
+		if ($minuend->getType() === 'quantity' && $subtrahend->getType() === 'quantity') {
138
+			$minuendStandard = $this->standardize($minuend);
139
+			$subtrahendStandard = $this->standardize($subtrahend);
140 140
 			$minuendValue = $minuendStandard->getAmount()->getValueFloat();
141 141
 			$subtrahendValue = $subtrahendStandard->getAmount()->getValueFloat();
142 142
 			$diff = $minuendValue - $subtrahendValue;
143 143
 			// we don’t check whether both quantities have the same standard unit –
144 144
 			// that’s the job of a different constraint type, Units (T164372)
145
-			return UnboundedQuantityValue::newFromNumber( $diff, $minuendStandard->getUnit() );
145
+			return UnboundedQuantityValue::newFromNumber($diff, $minuendStandard->getUnit());
146 146
 		}
147 147
 
148
-		throw new InvalidArgumentException( 'Unsupported or different data value types' );
148
+		throw new InvalidArgumentException('Unsupported or different data value types');
149 149
 	}
150 150
 
151
-	public function getDifferenceInYears( TimeValue $minuend, TimeValue $subtrahend ) {
152
-		if ( !preg_match( '/^([-+]\d{1,16})-(.*)$/', $minuend->getTime(), $minuendMatches ) ||
153
-			!preg_match( '/^([-+]\d{1,16})-(.*)$/', $subtrahend->getTime(), $subtrahendMatches )
151
+	public function getDifferenceInYears(TimeValue $minuend, TimeValue $subtrahend) {
152
+		if (!preg_match('/^([-+]\d{1,16})-(.*)$/', $minuend->getTime(), $minuendMatches) ||
153
+			!preg_match('/^([-+]\d{1,16})-(.*)$/', $subtrahend->getTime(), $subtrahendMatches)
154 154
 		) {
155
-			throw new InvalidArgumentException( 'TimeValue::getTime() did not match expected format' );
155
+			throw new InvalidArgumentException('TimeValue::getTime() did not match expected format');
156 156
 		}
157
-		$minuendYear = (float)$minuendMatches[1];
158
-		$subtrahendYear = (float)$subtrahendMatches[1];
157
+		$minuendYear = (float) $minuendMatches[1];
158
+		$subtrahendYear = (float) $subtrahendMatches[1];
159 159
 		$minuendRest = $minuendMatches[2];
160 160
 		$subtrahendRest = $subtrahendMatches[2];
161 161
 
162 162
 		// calculate difference of years
163 163
 		$diff = $minuendYear - $subtrahendYear;
164
-		if ( $minuendYear > 0.0 && $subtrahendYear < 0.0 ) {
164
+		if ($minuendYear > 0.0 && $subtrahendYear < 0.0) {
165 165
 			$diff -= 1.0; // there is no year 0, remove it from difference
166
-		} elseif ( $minuendYear < 0.0 && $subtrahendYear > 0.0 ) {
166
+		} elseif ($minuendYear < 0.0 && $subtrahendYear > 0.0) {
167 167
 			$diff -= -1.0; // there is no year 0, remove it from negative difference
168 168
 		}
169 169
 
170 170
 		// adjust for date within year by parsing the month-day part within the same year
171
-		$minuendDateValue = $this->timeParser->parse( '+0000000000001970-' . $minuendRest );
172
-		$subtrahendDateValue = $this->timeParser->parse( '+0000000000001970-' . $subtrahendRest );
173
-		$minuendDateSeconds = $this->timeCalculator->getTimestamp( $minuendDateValue );
174
-		$subtrahendDateSeconds = $this->timeCalculator->getTimestamp( $subtrahendDateValue );
175
-		if ( $minuendDateSeconds < $subtrahendDateSeconds ) {
171
+		$minuendDateValue = $this->timeParser->parse('+0000000000001970-'.$minuendRest);
172
+		$subtrahendDateValue = $this->timeParser->parse('+0000000000001970-'.$subtrahendRest);
173
+		$minuendDateSeconds = $this->timeCalculator->getTimestamp($minuendDateValue);
174
+		$subtrahendDateSeconds = $this->timeCalculator->getTimestamp($subtrahendDateValue);
175
+		if ($minuendDateSeconds < $subtrahendDateSeconds) {
176 176
 			// difference in the last year is actually less than one full year
177 177
 			// e. g. 1975-03-01 - 1974-09-01 is just six months
178 178
 			// (we don’t need sub-year precision in the difference, adjusting by 0.5 is enough)
179 179
 			$diff -= 0.5;
180
-		} elseif ( $minuendDateSeconds > $subtrahendDateSeconds ) {
180
+		} elseif ($minuendDateSeconds > $subtrahendDateSeconds) {
181 181
 			// difference in the last year is actually more than one full year
182 182
 			// e. g. 1975-09-01 - 1974-03-01 is 18 months
183 183
 			// (we don’t need sub-year precision in the difference, adjusting by 0.5 is enough)
184 184
 			$diff += 0.5;
185 185
 		}
186 186
 
187
-		$unit = $this->config->get( 'WBQualityConstraintsYearUnit' );
188
-		return UnboundedQuantityValue::newFromNumber( $diff, $unit );
187
+		$unit = $this->config->get('WBQualityConstraintsYearUnit');
188
+		return UnboundedQuantityValue::newFromNumber($diff, $unit);
189 189
 	}
190 190
 
191 191
 	/**
192 192
 	 * @param string $timeString
193 193
 	 * @return TimeValue
194 194
 	 */
195
-	public function parseTime( $timeString ) {
196
-		return $this->timeParser->parse( $timeString );
195
+	public function parseTime($timeString) {
196
+		return $this->timeParser->parse($timeString);
197 197
 	}
198 198
 
199 199
 	/**
200 200
 	 * @param string $quantityString
201 201
 	 * @return QuantityValue|UnboundedQuantityValue
202 202
 	 */
203
-	public function parseQuantity( $quantityString ) {
204
-		return UnboundedQuantityValue::newFromNumber( $quantityString );
203
+	public function parseQuantity($quantityString) {
204
+		return UnboundedQuantityValue::newFromNumber($quantityString);
205 205
 	}
206 206
 
207 207
 }
Please login to merge, or discard this patch.
src/Specials/SpecialConstraintReport.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@
 block discarded – undo
162 162
 	/**
163 163
 	 * Returns array of modules that should be added
164 164
 	 *
165
-	 * @return array
165
+	 * @return string[]
166 166
 	 */
167 167
 	private function getModules() {
168 168
 		return [ 'SpecialConstraintReportPage' ];
Please login to merge, or discard this patch.
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		DelegatingConstraintChecker $constraintChecker,
132 132
 		Config $config
133 133
 	) {
134
-		parent::__construct( 'ConstraintReport' );
134
+		parent::__construct('ConstraintReport');
135 135
 
136 136
 		$this->entityLookup = $entityLookup;
137 137
 		$this->entityTitleLookup = $entityTitleLookup;
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
 		$language = $this->getLanguage();
141 141
 
142 142
 		$formatterOptions = new FormatterOptions();
143
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
143
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
144 144
 		$this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(
145 145
 			SnakFormatter::FORMAT_HTML,
146 146
 			$formatterOptions
147 147
 		);
148 148
 
149
-		$labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup( $language );
149
+		$labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup($language);
150 150
 
151 151
 		$this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter(
152 152
 			$labelLookup
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 		$this->constraintChecker = $constraintChecker;
160 160
 
161
-		$this->constraintParameterRenderer = new ConstraintParameterRenderer( $this->entityIdLabelFormatter, $this->dataValueFormatter );
161
+		$this->constraintParameterRenderer = new ConstraintParameterRenderer($this->entityIdLabelFormatter, $this->dataValueFormatter);
162 162
 
163 163
 		$this->config = $config;
164 164
 	}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 * @return array
170 170
 	 */
171 171
 	private function getModules() {
172
-		return [ 'SpecialConstraintReportPage' ];
172
+		return ['SpecialConstraintReportPage'];
173 173
 	}
174 174
 
175 175
 	/**
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @return string
188 188
 	 */
189 189
 	public function getDescription() {
190
-		return $this->msg( 'wbqc-constraintreport' )->escaped();
190
+		return $this->msg('wbqc-constraintreport')->escaped();
191 191
 	}
192 192
 
193 193
 	/**
@@ -199,60 +199,60 @@  discard block
 block discarded – undo
199 199
 	 * @throws EntityIdParsingException
200 200
 	 * @throws UnexpectedValueException
201 201
 	 */
202
-	public function execute( $subPage ) {
202
+	public function execute($subPage) {
203 203
 		$out = $this->getOutput();
204 204
 
205
-		$postRequest = $this->getContext()->getRequest()->getVal( 'entityid' );
206
-		if ( $postRequest ) {
207
-			$out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() );
205
+		$postRequest = $this->getContext()->getRequest()->getVal('entityid');
206
+		if ($postRequest) {
207
+			$out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL());
208 208
 			return;
209 209
 		}
210 210
 
211
-		$out->addModules( $this->getModules() );
211
+		$out->addModules($this->getModules());
212 212
 
213 213
 		$this->setHeaders();
214 214
 
215
-		$out->addHTML( $this->getExplanationText() );
215
+		$out->addHTML($this->getExplanationText());
216 216
 		$this->buildEntityIdForm();
217 217
 
218
-		if ( !$subPage ) {
218
+		if (!$subPage) {
219 219
 			return;
220 220
 		}
221 221
 
222
-		if ( !is_string( $subPage ) ) {
223
-			throw new InvalidArgumentException( '$subPage must be string.' );
222
+		if (!is_string($subPage)) {
223
+			throw new InvalidArgumentException('$subPage must be string.');
224 224
 		}
225 225
 
226 226
 		try {
227
-			$entityId = $this->entityIdParser->parse( $subPage );
228
-		} catch ( EntityIdParsingException $e ) {
227
+			$entityId = $this->entityIdParser->parse($subPage);
228
+		} catch (EntityIdParsingException $e) {
229 229
 			$out->addHTML(
230
-				$this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true )
230
+				$this->buildNotice('wbqc-constraintreport-invalid-entity-id', true)
231 231
 			);
232 232
 			return;
233 233
 		}
234 234
 
235
-		if ( !$this->entityLookup->hasEntity( $entityId ) ) {
235
+		if (!$this->entityLookup->hasEntity($entityId)) {
236 236
 			$out->addHTML(
237
-				$this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true )
237
+				$this->buildNotice('wbqc-constraintreport-not-existent-entity', true)
238 238
 			);
239 239
 			return;
240 240
 		}
241 241
 
242 242
 		MediaWikiServices::getInstance()->getStatsdDataFactory()
243
-			->increment( 'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck' );
244
-		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId );
243
+			->increment('wikibase.quality.constraints.specials.specialConstraintReport.executeCheck');
244
+		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId);
245 245
 
246
-		if ( count( $results ) > 0 ) {
246
+		if (count($results) > 0) {
247 247
 			$out->addHTML(
248
-				$this->buildResultHeader( $entityId )
249
-				. $this->buildSummary( $results )
250
-				. $this->buildResultTable( $entityId, $results )
248
+				$this->buildResultHeader($entityId)
249
+				. $this->buildSummary($results)
250
+				. $this->buildResultTable($entityId, $results)
251 251
 			);
252 252
 		} else {
253 253
 			$out->addHTML(
254
-				$this->buildResultHeader( $entityId )
255
-				. $this->buildNotice( 'wbqc-constraintreport-empty-result' )
254
+				$this->buildResultHeader($entityId)
255
+				. $this->buildNotice('wbqc-constraintreport-empty-result')
256 256
 			);
257 257
 		}
258 258
 	}
@@ -268,15 +268,15 @@  discard block
 block discarded – undo
268 268
 				'name' => 'entityid',
269 269
 				'label-message' => 'wbqc-constraintreport-form-entityid-label',
270 270
 				'cssclass' => 'wbqc-constraintreport-form-entity-id',
271
-				'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped()
271
+				'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped()
272 272
 			]
273 273
 		];
274
-		$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' );
275
-		$htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() );
276
-		$htmlForm->setSubmitCallback( function() {
274
+		$htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form');
275
+		$htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped());
276
+		$htmlForm->setSubmitCallback(function() {
277 277
 			return false;
278 278
 		} );
279
-		$htmlForm->setMethod( 'post' );
279
+		$htmlForm->setMethod('post');
280 280
 		$htmlForm->show();
281 281
 	}
282 282
 
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
 	 *
291 291
 	 * @return string HTML
292 292
 	 */
293
-	private function buildNotice( $messageKey, $error = false ) {
294
-		if ( !is_string( $messageKey ) ) {
295
-			throw new InvalidArgumentException( '$message must be string.' );
293
+	private function buildNotice($messageKey, $error = false) {
294
+		if (!is_string($messageKey)) {
295
+			throw new InvalidArgumentException('$message must be string.');
296 296
 		}
297
-		if ( !is_bool( $error ) ) {
298
-			throw new InvalidArgumentException( '$error must be bool.' );
297
+		if (!is_bool($error)) {
298
+			throw new InvalidArgumentException('$error must be bool.');
299 299
 		}
300 300
 
301 301
 		$cssClasses = 'wbqc-constraintreport-notice';
302
-		if ( $error ) {
302
+		if ($error) {
303 303
 			$cssClasses .= ' wbqc-constraintreport-notice-error';
304 304
 		}
305 305
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 				[
309 309
 					'class' => $cssClasses
310 310
 				],
311
-				$this->msg( $messageKey )->escaped()
311
+				$this->msg($messageKey)->escaped()
312 312
 			);
313 313
 	}
314 314
 
@@ -318,16 +318,16 @@  discard block
 block discarded – undo
318 318
 	private function getExplanationText() {
319 319
 		return Html::rawElement(
320 320
 			'div',
321
-			[ 'class' => 'wbqc-explanation' ],
321
+			['class' => 'wbqc-explanation'],
322 322
 			Html::rawElement(
323 323
 				'p',
324 324
 				[],
325
-				$this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped()
325
+				$this->msg('wbqc-constraintreport-explanation-part-one')->escaped()
326 326
 			)
327 327
 			. Html::rawElement(
328 328
 				'p',
329 329
 				[],
330
-				$this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped()
330
+				$this->msg('wbqc-constraintreport-explanation-part-two')->escaped()
331 331
 			)
332 332
 		);
333 333
 	}
@@ -338,69 +338,69 @@  discard block
 block discarded – undo
338 338
 	 *
339 339
 	 * @return string HTML
340 340
 	 */
341
-	private function buildResultTable( EntityId $entityId, array $results ) {
341
+	private function buildResultTable(EntityId $entityId, array $results) {
342 342
 		// Set table headers
343 343
 		$table = new HtmlTableBuilder(
344 344
 			[
345 345
 				new HtmlTableHeaderBuilder(
346
-					$this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(),
346
+					$this->msg('wbqc-constraintreport-result-table-header-status')->escaped(),
347 347
 					true
348 348
 				),
349 349
 				new HtmlTableHeaderBuilder(
350
-					$this->msg( 'wbqc-constraintreport-result-table-header-claim' )->escaped(),
350
+					$this->msg('wbqc-constraintreport-result-table-header-claim')->escaped(),
351 351
 					true
352 352
 				),
353 353
 				new HtmlTableHeaderBuilder(
354
-					$this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(),
354
+					$this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(),
355 355
 					true
356 356
 				)
357 357
 			]
358 358
 		);
359 359
 
360
-		foreach ( $results as $result ) {
361
-			$table = $this->appendToResultTable( $table, $entityId, $result );
360
+		foreach ($results as $result) {
361
+			$table = $this->appendToResultTable($table, $entityId, $result);
362 362
 		}
363 363
 
364 364
 		return $table->toHtml();
365 365
 	}
366 366
 
367
-	private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) {
367
+	private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) {
368 368
 		// Status column
369 369
 		$statusColumn = $this->buildTooltipElement(
370
-			$this->formatStatus( $result->getStatus() ),
370
+			$this->formatStatus($result->getStatus()),
371 371
 			$result->getMessage(),
372 372
 			'[?]'
373 373
 		);
374 374
 
375 375
 		// Claim column
376
-		$property = $this->entityIdLabelFormatter->formatEntityId( $result->getContext()->getSnak()->getPropertyId() );
377
-		if ( $result->getSnakType() === 'value' ) {
378
-			$value = $this->constraintParameterRenderer->formatValue( $result->getDataValue() );
376
+		$property = $this->entityIdLabelFormatter->formatEntityId($result->getContext()->getSnak()->getPropertyId());
377
+		if ($result->getSnakType() === 'value') {
378
+			$value = $this->constraintParameterRenderer->formatValue($result->getDataValue());
379 379
 		} else {
380
-			$value = htmlspecialchars( $result->getSnakType() );
380
+			$value = htmlspecialchars($result->getSnakType());
381 381
 		}
382 382
 
383 383
 		$claimColumn = $this->getClaimLink(
384 384
 			$entityId,
385 385
 			$result->getContext()->getSnak()->getPropertyId(),
386
-			$property . ': ' . $value
386
+			$property.': '.$value
387 387
 		);
388 388
 
389 389
 		// Constraint column
390 390
 		$constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId();
391 391
 		try {
392
-			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) );
393
-		} catch ( InvalidArgumentException $e ) {
394
-			$constraintTypeLabel = htmlspecialchars( $constraintTypeItemId );
392
+			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId));
393
+		} catch (InvalidArgumentException $e) {
394
+			$constraintTypeLabel = htmlspecialchars($constraintTypeItemId);
395 395
 		}
396 396
 		$constraintLink = $this->getClaimLink(
397 397
 			$result->getContext()->getSnak()->getPropertyId(),
398
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ),
398
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')),
399 399
 			$constraintTypeLabel
400 400
 		);
401 401
 		$constraintColumn = $this->buildExpandableElement(
402 402
 			$constraintLink,
403
-			$this->constraintParameterRenderer->formatParameters( $result->getParameters() ),
403
+			$this->constraintParameterRenderer->formatParameters($result->getParameters()),
404 404
 			'[...]'
405 405
 		);
406 406
 
@@ -435,15 +435,15 @@  discard block
 block discarded – undo
435 435
 	 *
436 436
 	 * @return string HTML
437 437
 	 */
438
-	protected function buildResultHeader( EntityId $entityId ) {
439
-		$entityLink = sprintf( '%s (%s)',
440
-							   $this->entityIdLinkFormatter->formatEntityId( $entityId ),
441
-							   htmlspecialchars( $entityId->getSerialization() ) );
438
+	protected function buildResultHeader(EntityId $entityId) {
439
+		$entityLink = sprintf('%s (%s)',
440
+							   $this->entityIdLinkFormatter->formatEntityId($entityId),
441
+							   htmlspecialchars($entityId->getSerialization()));
442 442
 
443 443
 		return Html::rawElement(
444 444
 			'h3',
445 445
 			[],
446
-			sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
446
+			sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink)
447 447
 		);
448 448
 	}
449 449
 
@@ -454,24 +454,24 @@  discard block
 block discarded – undo
454 454
 	 *
455 455
 	 * @return string HTML
456 456
 	 */
457
-	protected function buildSummary( array $results ) {
457
+	protected function buildSummary(array $results) {
458 458
 		$statuses = [];
459
-		foreach ( $results as $result ) {
460
-			$status = strtolower( $result->getStatus() );
461
-			$statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1;
459
+		foreach ($results as $result) {
460
+			$status = strtolower($result->getStatus());
461
+			$statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1;
462 462
 		}
463 463
 
464 464
 		$statusElements = [];
465
-		foreach ( $statuses as $status => $count ) {
466
-			if ( $count > 0 ) {
465
+		foreach ($statuses as $status => $count) {
466
+			if ($count > 0) {
467 467
 				$statusElements[] =
468
-					$this->formatStatus( $status )
468
+					$this->formatStatus($status)
469 469
 					. ': '
470 470
 					. $count;
471 471
 			}
472 472
 		}
473 473
 
474
-		return Html::rawElement( 'p', [], implode( ', ', $statusElements ) );
474
+		return Html::rawElement('p', [], implode(', ', $statusElements));
475 475
 	}
476 476
 
477 477
 	/**
@@ -486,15 +486,15 @@  discard block
 block discarded – undo
486 486
 	 *
487 487
 	 * @return string HTML
488 488
 	 */
489
-	protected function buildTooltipElement( $content, $tooltipContent, $indicator ) {
490
-		if ( !is_string( $content ) ) {
491
-			throw new InvalidArgumentException( '$content has to be string.' );
489
+	protected function buildTooltipElement($content, $tooltipContent, $indicator) {
490
+		if (!is_string($content)) {
491
+			throw new InvalidArgumentException('$content has to be string.');
492 492
 		}
493
-		if ( $tooltipContent && ( !is_string( $tooltipContent ) ) ) {
494
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
493
+		if ($tooltipContent && (!is_string($tooltipContent))) {
494
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
495 495
 		}
496 496
 
497
-		if ( empty( $tooltipContent ) ) {
497
+		if (empty($tooltipContent)) {
498 498
 			return $content;
499 499
 		}
500 500
 
@@ -511,13 +511,13 @@  discard block
 block discarded – undo
511 511
 			[
512 512
 				'class' => 'wbqc-indicator'
513 513
 			],
514
-			htmlspecialchars( $indicator ) . $tooltip
514
+			htmlspecialchars($indicator).$tooltip
515 515
 		);
516 516
 
517 517
 		return Html::rawElement(
518 518
 			'span',
519 519
 			[],
520
-			sprintf( '%s %s', $content, $tooltipIndicator )
520
+			sprintf('%s %s', $content, $tooltipIndicator)
521 521
 		);
522 522
 	}
523 523
 
@@ -533,15 +533,15 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @return string HTML
535 535
 	 */
536
-	protected function buildExpandableElement( $content, $expandableContent, $indicator ) {
537
-		if ( !is_string( $content ) ) {
538
-			throw new InvalidArgumentException( '$content has to be string.' );
536
+	protected function buildExpandableElement($content, $expandableContent, $indicator) {
537
+		if (!is_string($content)) {
538
+			throw new InvalidArgumentException('$content has to be string.');
539 539
 		}
540
-		if ( $expandableContent && ( !is_string( $expandableContent ) ) ) {
541
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
540
+		if ($expandableContent && (!is_string($expandableContent))) {
541
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
542 542
 		}
543 543
 
544
-		if ( empty( $expandableContent ) ) {
544
+		if (empty($expandableContent)) {
545 545
 			return $content;
546 546
 		}
547 547
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 		);
563 563
 
564 564
 		return
565
-			sprintf( '%s %s %s', $content, $tooltipIndicator, $expandableContent );
565
+			sprintf('%s %s %s', $content, $tooltipIndicator, $expandableContent);
566 566
 	}
567 567
 
568 568
 	/**
@@ -574,16 +574,16 @@  discard block
 block discarded – undo
574 574
 	 *
575 575
 	 * @return string HTML
576 576
 	 */
577
-	private function formatStatus( $status ) {
578
-		$messageName = "wbqc-constraintreport-status-" . strtolower( $status );
577
+	private function formatStatus($status) {
578
+		$messageName = "wbqc-constraintreport-status-".strtolower($status);
579 579
 
580 580
 		$formattedStatus =
581 581
 			Html::element(
582 582
 				'span',
583 583
 				[
584
-					'class' => 'wbqc-status wbqc-status-' . $status
584
+					'class' => 'wbqc-status wbqc-status-'.$status
585 585
 				],
586
-				$this->msg( $messageName )->text()
586
+				$this->msg($messageName)->text()
587 587
 			);
588 588
 
589 589
 		return $formattedStatus;
@@ -599,26 +599,26 @@  discard block
 block discarded – undo
599 599
 	 *
600 600
 	 * @return string HTML
601 601
 	 */
602
-	protected function formatDataValues( $dataValues, $separator = ', ' ) {
603
-		if ( $dataValues instanceof DataValue ) {
604
-			$dataValues = [ $dataValues ];
605
-		} elseif ( !is_array( $dataValues ) ) {
606
-			throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
602
+	protected function formatDataValues($dataValues, $separator = ', ') {
603
+		if ($dataValues instanceof DataValue) {
604
+			$dataValues = [$dataValues];
605
+		} elseif (!is_array($dataValues)) {
606
+			throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
607 607
 		}
608 608
 
609 609
 		$formattedDataValues = [];
610
-		foreach ( $dataValues as $dataValue ) {
611
-			if ( !( $dataValue instanceof DataValue ) ) {
612
-				throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
610
+		foreach ($dataValues as $dataValue) {
611
+			if (!($dataValue instanceof DataValue)) {
612
+				throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
613 613
 			}
614
-			if ( $dataValue instanceof EntityIdValue ) {
615
-				$formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() );
614
+			if ($dataValue instanceof EntityIdValue) {
615
+				$formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId());
616 616
 			} else {
617
-				$formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue );
617
+				$formattedDataValues[] = $this->dataValueFormatter->format($dataValue);
618 618
 			}
619 619
 		}
620 620
 
621
-		return implode( $separator, $formattedDataValues );
621
+		return implode($separator, $formattedDataValues);
622 622
 	}
623 623
 
624 624
 	/**
@@ -630,12 +630,12 @@  discard block
 block discarded – undo
630 630
 	 *
631 631
 	 * @return string HTML
632 632
 	 */
633
-	private function getClaimLink( EntityId $entityId, PropertyId $propertyId, $text ) {
633
+	private function getClaimLink(EntityId $entityId, PropertyId $propertyId, $text) {
634 634
 		return
635 635
 			Html::rawElement(
636 636
 				'a',
637 637
 				[
638
-					'href' => $this->getClaimUrl( $entityId, $propertyId ),
638
+					'href' => $this->getClaimUrl($entityId, $propertyId),
639 639
 					'target' => '_blank'
640 640
 				],
641 641
 				$text
@@ -650,9 +650,9 @@  discard block
 block discarded – undo
650 650
 	 *
651 651
 	 * @return string
652 652
 	 */
653
-	private function getClaimUrl( EntityId $entityId, PropertyId $propertyId ) {
654
-		$title = $this->entityTitleLookup->getTitleForId( $entityId );
655
-		$entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() );
653
+	private function getClaimUrl(EntityId $entityId, PropertyId $propertyId) {
654
+		$title = $this->entityTitleLookup->getTitleForId($entityId);
655
+		$entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization());
656 656
 
657 657
 		return $entityUrl;
658 658
 	}
Please login to merge, or discard this patch.
src/Api/CheckConstraintParameters.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @return self
61 61
 	 */
62
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
62
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
63 63
 		$constraintReportFactory = ConstraintReportFactory::getDefaultInstance();
64 64
 		$repo = WikibaseRepo::getDefaultInstance();
65
-		$helperFactory = $repo->getApiHelperFactory( RequestContext::getMain() );
65
+		$helperFactory = $repo->getApiHelperFactory(RequestContext::getMain());
66 66
 		return new self(
67 67
 			$main,
68 68
 			$name,
@@ -89,53 +89,53 @@  discard block
 block discarded – undo
89 89
 		DelegatingConstraintChecker $delegatingConstraintChecker,
90 90
 		StatementGuidParser $statementGuidParser
91 91
 	) {
92
-		parent::__construct( $main, $name, $prefix );
92
+		parent::__construct($main, $name, $prefix);
93 93
 
94
-		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this );
94
+		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this);
95 95
 		$this->delegatingConstraintChecker = $delegatingConstraintChecker;
96 96
 		$this->statementGuidParser = $statementGuidParser;
97 97
 	}
98 98
 
99 99
 	public function execute() {
100 100
 		MediaWikiServices::getInstance()->getStatsdDataFactory()
101
-			->increment( 'wikibase.quality.constraints.api.checkConstraintParameters.execute' );
101
+			->increment('wikibase.quality.constraints.api.checkConstraintParameters.execute');
102 102
 
103 103
 		$params = $this->extractRequestParams();
104 104
 		$result = $this->getResult();
105 105
 
106
-		$propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] );
107
-		$constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] );
106
+		$propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]);
107
+		$constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]);
108 108
 
109
-		$this->checkPropertyIds( $propertyIds, $result );
110
-		$this->checkConstraintIds( $constraintIds, $result );
109
+		$this->checkPropertyIds($propertyIds, $result);
110
+		$this->checkConstraintIds($constraintIds, $result);
111 111
 
112
-		$result->addValue( null, 'success', 1 );
112
+		$result->addValue(null, 'success', 1);
113 113
 	}
114 114
 
115 115
 	/**
116 116
 	 * @param array|null $propertyIdSerializations
117 117
 	 * @return PropertyId[]
118 118
 	 */
119
-	private function parsePropertyIds( $propertyIdSerializations ) {
120
-		if ( $propertyIdSerializations === null ) {
119
+	private function parsePropertyIds($propertyIdSerializations) {
120
+		if ($propertyIdSerializations === null) {
121 121
 			return [];
122
-		} elseif ( empty( $propertyIdSerializations ) ) {
122
+		} elseif (empty($propertyIdSerializations)) {
123 123
 			$this->apiErrorReporter->dieError(
124
-				'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.',
124
+				'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.',
125 125
 				'no-data'
126 126
 			);
127 127
 		}
128 128
 
129 129
 		return array_map(
130
-			function( $propertyIdSerialization ) {
130
+			function($propertyIdSerialization) {
131 131
 				try {
132
-					return new PropertyId( $propertyIdSerialization );
133
-				} catch ( InvalidArgumentException $e ) {
132
+					return new PropertyId($propertyIdSerialization);
133
+				} catch (InvalidArgumentException $e) {
134 134
 					$this->apiErrorReporter->dieError(
135 135
 						"Invalid id: $propertyIdSerialization",
136 136
 						'invalid-property-id',
137 137
 						0, // default argument
138
-						[ self::PARAM_PROPERTY_ID => $propertyIdSerialization ]
138
+						[self::PARAM_PROPERTY_ID => $propertyIdSerialization]
139 139
 					);
140 140
 				}
141 141
 			},
@@ -147,35 +147,35 @@  discard block
 block discarded – undo
147 147
 	 * @param array|null $constraintIds
148 148
 	 * @return string[]
149 149
 	 */
150
-	private function parseConstraintIds( $constraintIds ) {
151
-		if ( $constraintIds === null ) {
150
+	private function parseConstraintIds($constraintIds) {
151
+		if ($constraintIds === null) {
152 152
 			return [];
153
-		} elseif ( empty( $constraintIds ) ) {
153
+		} elseif (empty($constraintIds)) {
154 154
 			$this->apiErrorReporter->dieError(
155
-				'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.',
155
+				'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.',
156 156
 				'no-data'
157 157
 			);
158 158
 		}
159 159
 
160 160
 		return array_map(
161
-			function( $constraintId ) {
161
+			function($constraintId) {
162 162
 				try {
163
-					$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
164
-					if ( !$propertyId instanceof PropertyId ) {
163
+					$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
164
+					if (!$propertyId instanceof PropertyId) {
165 165
 						$this->apiErrorReporter->dieError(
166 166
 							"Invalid property ID: {$propertyId->getSerialization()}",
167 167
 							'invalid-property-id',
168 168
 							0, // default argument
169
-							[ self::PARAM_CONSTRAINT_ID => $constraintId ]
169
+							[self::PARAM_CONSTRAINT_ID => $constraintId]
170 170
 						);
171 171
 					}
172 172
 					return $constraintId;
173
-				} catch ( StatementGuidParsingException $e ) {
173
+				} catch (StatementGuidParsingException $e) {
174 174
 					$this->apiErrorReporter->dieError(
175 175
 						"Invalid statement GUID: $constraintId",
176 176
 						'invalid-guid',
177 177
 						0, // default argument
178
-						[ self::PARAM_CONSTRAINT_ID => $constraintId ]
178
+						[self::PARAM_CONSTRAINT_ID => $constraintId]
179 179
 					);
180 180
 				}
181 181
 			},
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 	 * @param PropertyId[] $propertyIds
188 188
 	 * @param ApiResult $result
189 189
 	 */
190
-	private function checkPropertyIds( array $propertyIds, ApiResult $result ) {
191
-		foreach ( $propertyIds as $propertyId ) {
192
-			$result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' );
193
-			$allConstraintExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnPropertyId( $propertyId );
194
-			foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) {
195
-				$this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result );
190
+	private function checkPropertyIds(array $propertyIds, ApiResult $result) {
191
+		foreach ($propertyIds as $propertyId) {
192
+			$result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc');
193
+			$allConstraintExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnPropertyId($propertyId);
194
+			foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) {
195
+				$this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result);
196 196
 			}
197 197
 		}
198 198
 	}
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 	 * @param string[] $constraintIds
202 202
 	 * @param ApiResult $result
203 203
 	 */
204
-	private function checkConstraintIds( array $constraintIds, ApiResult $result ) {
205
-		foreach ( $constraintIds as $constraintId ) {
206
-			if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) {
204
+	private function checkConstraintIds(array $constraintIds, ApiResult $result) {
205
+		foreach ($constraintIds as $constraintId) {
206
+			if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) {
207 207
 				// already checked as part of checkPropertyIds()
208 208
 				continue;
209 209
 			}
210
-			$constraintParameterExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnConstraintId( $constraintId );
211
-			$this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result );
210
+			$constraintParameterExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnConstraintId($constraintId);
211
+			$this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result);
212 212
 		}
213 213
 	}
214 214
 
@@ -216,17 +216,17 @@  discard block
 block discarded – undo
216 216
 	 * @param PropertyId $propertyId
217 217
 	 * @return string[]
218 218
 	 */
219
-	private function getResultPathForPropertyId( PropertyId $propertyId ) {
220
-		return [ $this->getModuleName(), $propertyId->getSerialization() ];
219
+	private function getResultPathForPropertyId(PropertyId $propertyId) {
220
+		return [$this->getModuleName(), $propertyId->getSerialization()];
221 221
 	}
222 222
 
223 223
 	/**
224 224
 	 * @param string $constraintId
225 225
 	 * @return string[]
226 226
 	 */
227
-	private function getResultPathForConstraintId( $constraintId ) {
228
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
229
-		return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] );
227
+	private function getResultPathForConstraintId($constraintId) {
228
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
229
+		return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]);
230 230
 	}
231 231
 
232 232
 	/**
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 	 * @param ConstraintParameterException[]|null $constraintParameterExceptions
237 237
 	 * @param ApiResult $result
238 238
 	 */
239
-	private function addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, ApiResult $result ) {
240
-		$path = $this->getResultPathForConstraintId( $constraintId );
241
-		if ( $constraintParameterExceptions === null ) {
239
+	private function addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, ApiResult $result) {
240
+		$path = $this->getResultPathForConstraintId($constraintId);
241
+		if ($constraintParameterExceptions === null) {
242 242
 			$result->addValue(
243 243
 				$path,
244 244
 				self::KEY_STATUS,
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
 			$result->addValue(
249 249
 				$path,
250 250
 				self::KEY_STATUS,
251
-				empty( $constraintParameterExceptions ) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY
251
+				empty($constraintParameterExceptions) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY
252 252
 			);
253 253
 			$result->addValue(
254 254
 				$path,
255 255
 				self::KEY_PROBLEMS,
256
-				array_map( [ $this, 'formatConstraintParameterException' ], $constraintParameterExceptions )
256
+				array_map([$this, 'formatConstraintParameterException'], $constraintParameterExceptions)
257 257
 			);
258 258
 		}
259 259
 	}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 * @param ConstraintParameterException $e
265 265
 	 * @return array
266 266
 	 */
267
-	private function formatConstraintParameterException( ConstraintParameterException $e ) {
267
+	private function formatConstraintParameterException(ConstraintParameterException $e) {
268 268
 		return [
269 269
 			self::KEY_MESSAGE_HTML => $e->getMessage(),
270 270
 		];
Please login to merge, or discard this patch.
src/ConstraintLookup.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,6 +14,6 @@
 block discarded – undo
14 14
 	 *
15 15
 	 * @return Constraint[]
16 16
 	 */
17
-	public function queryConstraintsForProperty( PropertyId $propertyId );
17
+	public function queryConstraintsForProperty(PropertyId $propertyId);
18 18
 
19 19
 }
Please login to merge, or discard this patch.
src/UpdateConstraintsTableJob.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 
27 27
 	const BATCH_SIZE = 10;
28 28
 
29
-	public static function newFromGlobalState( Title $title, array $params ) {
30
-		Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' );
29
+	public static function newFromGlobalState(Title $title, array $params) {
30
+		Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]');
31 31
 		$repo = WikibaseRepo::getDefaultInstance();
32 32
 		return new UpdateConstraintsTableJob(
33 33
 			$title,
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		EntityLookup $entityLookup,
84 84
 		Serializer $snakSerializer
85 85
 	) {
86
-		parent::__construct( 'constraintsTableUpdate', $title, $params );
86
+		parent::__construct('constraintsTableUpdate', $title, $params);
87 87
 
88 88
 		$this->propertyId = $propertyId;
89 89
 		$this->config = $config;
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 		$this->snakSerializer = $snakSerializer;
93 93
 	}
94 94
 
95
-	public function extractParametersFromQualifiers( SnakList $qualifiers ) {
95
+	public function extractParametersFromQualifiers(SnakList $qualifiers) {
96 96
 		$parameters = [];
97
-		foreach ( $qualifiers as $qualifier ) {
97
+		foreach ($qualifiers as $qualifier) {
98 98
 			$qualifierId = $qualifier->getPropertyId()->getSerialization();
99
-			$paramSerialization = $this->snakSerializer->serialize( $qualifier );
99
+			$paramSerialization = $this->snakSerializer->serialize($qualifier);
100 100
 			$parameters[$qualifierId][] = $paramSerialization;
101 101
 		}
102 102
 		return $parameters;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	) {
109 109
 		$constraintId = $constraintStatement->getGuid();
110 110
 		$constraintTypeQid = $constraintStatement->getMainSnak()->getDataValue()->getEntityId()->getSerialization();
111
-		$parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() );
111
+		$parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers());
112 112
 		return new Constraint(
113 113
 			$constraintId,
114 114
 			$propertyId,
@@ -122,16 +122,16 @@  discard block
 block discarded – undo
122 122
 		ConstraintRepository $constraintRepo,
123 123
 		PropertyId $propertyConstraintPropertyId
124 124
 	) {
125
-		$constraintsStatements = $property->getStatements()->getByPropertyId( $propertyConstraintPropertyId );
125
+		$constraintsStatements = $property->getStatements()->getByPropertyId($propertyConstraintPropertyId);
126 126
 		$constraints = [];
127
-		foreach ( $constraintsStatements->getIterator() as $constraintStatement ) {
128
-			$constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement );
129
-			if ( count( $constraints ) >= self::BATCH_SIZE ) {
130
-				$constraintRepo->insertBatch( $constraints );
127
+		foreach ($constraintsStatements->getIterator() as $constraintStatement) {
128
+			$constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement);
129
+			if (count($constraints) >= self::BATCH_SIZE) {
130
+				$constraintRepo->insertBatch($constraints);
131 131
 				$constraints = [];
132 132
 			}
133 133
 		}
134
-		$constraintRepo->insertBatch( $constraints );
134
+		$constraintRepo->insertBatch($constraints);
135 135
 	}
136 136
 
137 137
 	/**
@@ -142,14 +142,14 @@  discard block
 block discarded – undo
142 142
 	public function run() {
143 143
 		// TODO in the future: only touch constraints affected by the edit (requires T163465)
144 144
 
145
-		$propertyId = new PropertyId( $this->propertyId );
146
-		$this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId( $propertyId );
145
+		$propertyId = new PropertyId($this->propertyId);
146
+		$this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId($propertyId);
147 147
 
148
-		$property = $this->entityLookup->getEntity( $propertyId );
148
+		$property = $this->entityLookup->getEntity($propertyId);
149 149
 		$this->importConstraintsForProperty(
150 150
 			$property,
151 151
 			$this->constraintRepo,
152
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) )
152
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId'))
153 153
 		);
154 154
 
155 155
 		return true;
Please login to merge, or discard this patch.