@@ -24,7 +24,7 @@ |
||
24 | 24 | * @param bool $bool |
25 | 25 | * @param Metadata $metadata |
26 | 26 | */ |
27 | - public function __construct( $bool, Metadata $metadata ) { |
|
27 | + public function __construct($bool, Metadata $metadata) { |
|
28 | 28 | $this->bool = $bool; |
29 | 29 | $this->metadata = $metadata; |
30 | 30 | } |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | return $ret; |
33 | 33 | } |
34 | 34 | |
35 | - public static function ofCachingMetadata( CachingMetadata $cachingMetadata ) { |
|
35 | + public static function ofCachingMetadata(CachingMetadata $cachingMetadata) { |
|
36 | 36 | $ret = new self; |
37 | 37 | $ret->cachingMetadata = $cachingMetadata; |
38 | 38 | $ret->dependencyMetadata = DependencyMetadata::blank(); |
39 | 39 | return $ret; |
40 | 40 | } |
41 | 41 | |
42 | - public static function ofDependencyMetadata( DependencyMetadata $dependencyMetadata ) { |
|
42 | + public static function ofDependencyMetadata(DependencyMetadata $dependencyMetadata) { |
|
43 | 43 | $ret = new self; |
44 | 44 | $ret->cachingMetadata = CachingMetadata::fresh(); |
45 | 45 | $ret->dependencyMetadata = $dependencyMetadata; |
@@ -50,17 +50,17 @@ discard block |
||
50 | 50 | * @param self[] $metadatas |
51 | 51 | * @return self |
52 | 52 | */ |
53 | - public static function merge( array $metadatas ) { |
|
54 | - Assert::parameterElementType( self::class, $metadatas, '$metadatas' ); |
|
53 | + public static function merge(array $metadatas) { |
|
54 | + Assert::parameterElementType(self::class, $metadatas, '$metadatas'); |
|
55 | 55 | $cachingMetadatas = []; |
56 | 56 | $dependencyMetadatas = []; |
57 | - foreach ( $metadatas as $metadata ) { |
|
57 | + foreach ($metadatas as $metadata) { |
|
58 | 58 | $cachingMetadatas[] = $metadata->cachingMetadata; |
59 | 59 | $dependencyMetadatas[] = $metadata->dependencyMetadata; |
60 | 60 | } |
61 | 61 | $ret = new self; |
62 | - $ret->cachingMetadata = CachingMetadata::merge( $cachingMetadatas ); |
|
63 | - $ret->dependencyMetadata = DependencyMetadata::merge( $dependencyMetadatas ); |
|
62 | + $ret->cachingMetadata = CachingMetadata::merge($cachingMetadatas); |
|
63 | + $ret->dependencyMetadata = DependencyMetadata::merge($dependencyMetadatas); |
|
64 | 64 | return $ret; |
65 | 65 | } |
66 | 66 |
@@ -137,14 +137,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | private $cache; |
19 | 19 | |
20 | 20 | public static function getDefaultInstance() { |
21 | - return new self( MediaWikiServices::getInstance()->getMainWANObjectCache() ); |
|
21 | + return new self(MediaWikiServices::getInstance()->getMainWANObjectCache()); |
|
22 | 22 | } |
23 | 23 | |
24 | - public function __construct( WANObjectCache $cache ) { |
|
24 | + public function __construct(WANObjectCache $cache) { |
|
25 | 25 | $this->cache = $cache; |
26 | 26 | } |
27 | 27 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param EntityId $entityId |
30 | 30 | * @return string cache key |
31 | 31 | */ |
32 | - public function makeKey( EntityId $entityId ) { |
|
32 | + public function makeKey(EntityId $entityId) { |
|
33 | 33 | return $this->cache->makeKey( |
34 | 34 | 'WikibaseQualityConstraints', // extension |
35 | 35 | 'checkConstraints', // action |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * @param float &$asOf |
46 | 46 | * @return mixed |
47 | 47 | */ |
48 | - public function get( EntityId $key, &$curTTL = null, array $checkKeys = [], &$asOf = null ) { |
|
49 | - return $this->cache->get( $this->makeKey( $key ), $curTTL, $checkKeys, $asOf ); |
|
48 | + public function get(EntityId $key, &$curTTL = null, array $checkKeys = [], &$asOf = null) { |
|
49 | + return $this->cache->get($this->makeKey($key), $curTTL, $checkKeys, $asOf); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | * @param array $opts |
57 | 57 | * @return bool |
58 | 58 | */ |
59 | - public function set( EntityId $key, $value, $ttl = 0, array $opts = [] ) { |
|
60 | - return $this->cache->set( $this->makeKey( $key ), $value, $ttl, $opts ); |
|
59 | + public function set(EntityId $key, $value, $ttl = 0, array $opts = []) { |
|
60 | + return $this->cache->set($this->makeKey($key), $value, $ttl, $opts); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param EntityId $key |
65 | 65 | * @return bool |
66 | 66 | */ |
67 | - public function delete( EntityId $key ) { |
|
68 | - return $this->cache->delete( $this->makeKey( $key ) ); |
|
67 | + public function delete(EntityId $key) { |
|
68 | + return $this->cache->delete($this->makeKey($key)); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | } |
@@ -28,36 +28,36 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return bool |
30 | 30 | */ |
31 | - public static function onCreateSchema( DatabaseUpdater $updater ) { |
|
32 | - $updater->addExtensionTable( 'wbqc_constraints', __DIR__ . '/../sql/create_wbqc_constraints.sql' ); |
|
31 | + public static function onCreateSchema(DatabaseUpdater $updater) { |
|
32 | + $updater->addExtensionTable('wbqc_constraints', __DIR__.'/../sql/create_wbqc_constraints.sql'); |
|
33 | 33 | return true; |
34 | 34 | } |
35 | 35 | |
36 | - public static function onWikibaseChange( Change $change ) { |
|
36 | + public static function onWikibaseChange(Change $change) { |
|
37 | 37 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
38 | - if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
39 | - self::isConstraintStatementsChange( $config, $change ) |
|
38 | + if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
39 | + self::isConstraintStatementsChange($config, $change) |
|
40 | 40 | ) { |
41 | 41 | /** @var EntityChange $change */ |
42 | 42 | $title = Title::newMainPage(); |
43 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
43 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
44 | 44 | JobQueueGroup::singleton()->push( |
45 | - new JobSpecification( 'constraintsTableUpdate', $params, [], $title ) |
|
45 | + new JobSpecification('constraintsTableUpdate', $params, [], $title) |
|
46 | 46 | ); |
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | - public static function isConstraintStatementsChange( Config $config, Change $change ) { |
|
51 | - if ( !( $change instanceof EntityChange ) || |
|
50 | + public static function isConstraintStatementsChange(Config $config, Change $change) { |
|
51 | + if (!($change instanceof EntityChange) || |
|
52 | 52 | $change->getAction() !== EntityChange::UPDATE || |
53 | - !( $change->getEntityId() instanceof PropertyId ) |
|
53 | + !($change->getEntityId() instanceof PropertyId) |
|
54 | 54 | ) { |
55 | 55 | return false; |
56 | 56 | } |
57 | 57 | |
58 | 58 | $info = $change->getInfo(); |
59 | 59 | |
60 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
60 | + if (!array_key_exists('compactDiff', $info)) { |
|
61 | 61 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
62 | 62 | // so we only know that the change *might* affect the constraint statements |
63 | 63 | return true; |
@@ -66,18 +66,18 @@ discard block |
||
66 | 66 | /** @var EntityDiffChangedAspects $aspects */ |
67 | 67 | $aspects = $info['compactDiff']; |
68 | 68 | |
69 | - $propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
70 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
69 | + $propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
70 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
71 | 71 | } |
72 | 72 | |
73 | - public static function onArticlePurge( WikiPage $wikiPage ) { |
|
73 | + public static function onArticlePurge(WikiPage $wikiPage) { |
|
74 | 74 | $repo = WikibaseRepo::getDefaultInstance(); |
75 | 75 | |
76 | 76 | $entityContentFactory = $repo->getEntityContentFactory(); |
77 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
78 | - $entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
77 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
78 | + $entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle()); |
|
79 | 79 | $resultsCache = ResultsCache::getDefaultInstance(); |
80 | - $resultsCache->delete( $entityId ); |
|
80 | + $resultsCache->delete($entityId); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | Config $config, |
140 | 140 | IBufferingStatsdDataFactory $dataFactory |
141 | 141 | ) { |
142 | - parent::__construct( 'ConstraintReport' ); |
|
142 | + parent::__construct('ConstraintReport'); |
|
143 | 143 | |
144 | 144 | $this->entityLookup = $entityLookup; |
145 | 145 | $this->entityTitleLookup = $entityTitleLookup; |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | $language = $this->getLanguage(); |
149 | 149 | |
150 | 150 | $formatterOptions = new FormatterOptions(); |
151 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
151 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
152 | 152 | $this->dataValueFormatter = $valueFormatterFactory->getValueFormatter( |
153 | 153 | SnakFormatter::FORMAT_HTML, |
154 | 154 | $formatterOptions |
155 | 155 | ); |
156 | 156 | |
157 | - $labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup( $language ); |
|
157 | + $labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup($language); |
|
158 | 158 | |
159 | 159 | $this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( |
160 | 160 | $labelLookup |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | $this->constraintChecker = $constraintChecker; |
168 | 168 | |
169 | - $this->constraintParameterRenderer = new ConstraintParameterRenderer( $this->entityIdLabelFormatter, $this->dataValueFormatter ); |
|
169 | + $this->constraintParameterRenderer = new ConstraintParameterRenderer($this->entityIdLabelFormatter, $this->dataValueFormatter); |
|
170 | 170 | |
171 | 171 | $this->config = $config; |
172 | 172 | $this->dataFactory = $dataFactory; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @return array |
179 | 179 | */ |
180 | 180 | private function getModules() { |
181 | - return [ 'SpecialConstraintReportPage' ]; |
|
181 | + return ['SpecialConstraintReportPage']; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @return string |
197 | 197 | */ |
198 | 198 | public function getDescription() { |
199 | - return $this->msg( 'wbqc-constraintreport' )->escaped(); |
|
199 | + return $this->msg('wbqc-constraintreport')->escaped(); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | /** |
@@ -208,42 +208,42 @@ discard block |
||
208 | 208 | * @throws EntityIdParsingException |
209 | 209 | * @throws UnexpectedValueException |
210 | 210 | */ |
211 | - public function execute( $subPage ) { |
|
211 | + public function execute($subPage) { |
|
212 | 212 | $out = $this->getOutput(); |
213 | 213 | |
214 | - $postRequest = $this->getContext()->getRequest()->getVal( 'entityid' ); |
|
215 | - if ( $postRequest ) { |
|
216 | - $out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() ); |
|
214 | + $postRequest = $this->getContext()->getRequest()->getVal('entityid'); |
|
215 | + if ($postRequest) { |
|
216 | + $out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL()); |
|
217 | 217 | return; |
218 | 218 | } |
219 | 219 | |
220 | - $out->addModules( $this->getModules() ); |
|
220 | + $out->addModules($this->getModules()); |
|
221 | 221 | |
222 | 222 | $this->setHeaders(); |
223 | 223 | |
224 | - $out->addHTML( $this->getExplanationText() ); |
|
224 | + $out->addHTML($this->getExplanationText()); |
|
225 | 225 | $this->buildEntityIdForm(); |
226 | 226 | |
227 | - if ( !$subPage ) { |
|
227 | + if (!$subPage) { |
|
228 | 228 | return; |
229 | 229 | } |
230 | 230 | |
231 | - if ( !is_string( $subPage ) ) { |
|
232 | - throw new InvalidArgumentException( '$subPage must be string.' ); |
|
231 | + if (!is_string($subPage)) { |
|
232 | + throw new InvalidArgumentException('$subPage must be string.'); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | try { |
236 | - $entityId = $this->entityIdParser->parse( $subPage ); |
|
237 | - } catch ( EntityIdParsingException $e ) { |
|
236 | + $entityId = $this->entityIdParser->parse($subPage); |
|
237 | + } catch (EntityIdParsingException $e) { |
|
238 | 238 | $out->addHTML( |
239 | - $this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true ) |
|
239 | + $this->buildNotice('wbqc-constraintreport-invalid-entity-id', true) |
|
240 | 240 | ); |
241 | 241 | return; |
242 | 242 | } |
243 | 243 | |
244 | - if ( !$this->entityLookup->hasEntity( $entityId ) ) { |
|
244 | + if (!$this->entityLookup->hasEntity($entityId)) { |
|
245 | 245 | $out->addHTML( |
246 | - $this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true ) |
|
246 | + $this->buildNotice('wbqc-constraintreport-not-existent-entity', true) |
|
247 | 247 | ); |
248 | 248 | return; |
249 | 249 | } |
@@ -251,18 +251,18 @@ discard block |
||
251 | 251 | $this->dataFactory->increment( |
252 | 252 | 'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck' |
253 | 253 | ); |
254 | - $results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId ); |
|
254 | + $results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId); |
|
255 | 255 | |
256 | - if ( count( $results ) > 0 ) { |
|
256 | + if (count($results) > 0) { |
|
257 | 257 | $out->addHTML( |
258 | - $this->buildResultHeader( $entityId ) |
|
259 | - . $this->buildSummary( $results ) |
|
260 | - . $this->buildResultTable( $entityId, $results ) |
|
258 | + $this->buildResultHeader($entityId) |
|
259 | + . $this->buildSummary($results) |
|
260 | + . $this->buildResultTable($entityId, $results) |
|
261 | 261 | ); |
262 | 262 | } else { |
263 | 263 | $out->addHTML( |
264 | - $this->buildResultHeader( $entityId ) |
|
265 | - . $this->buildNotice( 'wbqc-constraintreport-empty-result' ) |
|
264 | + $this->buildResultHeader($entityId) |
|
265 | + . $this->buildNotice('wbqc-constraintreport-empty-result') |
|
266 | 266 | ); |
267 | 267 | } |
268 | 268 | } |
@@ -278,15 +278,15 @@ discard block |
||
278 | 278 | 'name' => 'entityid', |
279 | 279 | 'label-message' => 'wbqc-constraintreport-form-entityid-label', |
280 | 280 | 'cssclass' => 'wbqc-constraintreport-form-entity-id', |
281 | - 'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped() |
|
281 | + 'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped() |
|
282 | 282 | ] |
283 | 283 | ]; |
284 | - $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' ); |
|
285 | - $htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() ); |
|
286 | - $htmlForm->setSubmitCallback( function() { |
|
284 | + $htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form'); |
|
285 | + $htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped()); |
|
286 | + $htmlForm->setSubmitCallback(function() { |
|
287 | 287 | return false; |
288 | 288 | } ); |
289 | - $htmlForm->setMethod( 'post' ); |
|
289 | + $htmlForm->setMethod('post'); |
|
290 | 290 | $htmlForm->show(); |
291 | 291 | } |
292 | 292 | |
@@ -300,16 +300,16 @@ discard block |
||
300 | 300 | * |
301 | 301 | * @return string HTML |
302 | 302 | */ |
303 | - private function buildNotice( $messageKey, $error = false ) { |
|
304 | - if ( !is_string( $messageKey ) ) { |
|
305 | - throw new InvalidArgumentException( '$message must be string.' ); |
|
303 | + private function buildNotice($messageKey, $error = false) { |
|
304 | + if (!is_string($messageKey)) { |
|
305 | + throw new InvalidArgumentException('$message must be string.'); |
|
306 | 306 | } |
307 | - if ( !is_bool( $error ) ) { |
|
308 | - throw new InvalidArgumentException( '$error must be bool.' ); |
|
307 | + if (!is_bool($error)) { |
|
308 | + throw new InvalidArgumentException('$error must be bool.'); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | $cssClasses = 'wbqc-constraintreport-notice'; |
312 | - if ( $error ) { |
|
312 | + if ($error) { |
|
313 | 313 | $cssClasses .= ' wbqc-constraintreport-notice-error'; |
314 | 314 | } |
315 | 315 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | [ |
319 | 319 | 'class' => $cssClasses |
320 | 320 | ], |
321 | - $this->msg( $messageKey )->escaped() |
|
321 | + $this->msg($messageKey)->escaped() |
|
322 | 322 | ); |
323 | 323 | } |
324 | 324 | |
@@ -328,16 +328,16 @@ discard block |
||
328 | 328 | private function getExplanationText() { |
329 | 329 | return Html::rawElement( |
330 | 330 | 'div', |
331 | - [ 'class' => 'wbqc-explanation' ], |
|
331 | + ['class' => 'wbqc-explanation'], |
|
332 | 332 | Html::rawElement( |
333 | 333 | 'p', |
334 | 334 | [], |
335 | - $this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped() |
|
335 | + $this->msg('wbqc-constraintreport-explanation-part-one')->escaped() |
|
336 | 336 | ) |
337 | 337 | . Html::rawElement( |
338 | 338 | 'p', |
339 | 339 | [], |
340 | - $this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped() |
|
340 | + $this->msg('wbqc-constraintreport-explanation-part-two')->escaped() |
|
341 | 341 | ) |
342 | 342 | ); |
343 | 343 | } |
@@ -348,69 +348,69 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return string HTML |
350 | 350 | */ |
351 | - private function buildResultTable( EntityId $entityId, array $results ) { |
|
351 | + private function buildResultTable(EntityId $entityId, array $results) { |
|
352 | 352 | // Set table headers |
353 | 353 | $table = new HtmlTableBuilder( |
354 | 354 | [ |
355 | 355 | new HtmlTableHeaderBuilder( |
356 | - $this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(), |
|
356 | + $this->msg('wbqc-constraintreport-result-table-header-status')->escaped(), |
|
357 | 357 | true |
358 | 358 | ), |
359 | 359 | new HtmlTableHeaderBuilder( |
360 | - $this->msg( 'wbqc-constraintreport-result-table-header-claim' )->escaped(), |
|
360 | + $this->msg('wbqc-constraintreport-result-table-header-claim')->escaped(), |
|
361 | 361 | true |
362 | 362 | ), |
363 | 363 | new HtmlTableHeaderBuilder( |
364 | - $this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(), |
|
364 | + $this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(), |
|
365 | 365 | true |
366 | 366 | ) |
367 | 367 | ] |
368 | 368 | ); |
369 | 369 | |
370 | - foreach ( $results as $result ) { |
|
371 | - $table = $this->appendToResultTable( $table, $entityId, $result ); |
|
370 | + foreach ($results as $result) { |
|
371 | + $table = $this->appendToResultTable($table, $entityId, $result); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | return $table->toHtml(); |
375 | 375 | } |
376 | 376 | |
377 | - private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) { |
|
377 | + private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) { |
|
378 | 378 | // Status column |
379 | 379 | $statusColumn = $this->buildTooltipElement( |
380 | - $this->formatStatus( $result->getStatus() ), |
|
380 | + $this->formatStatus($result->getStatus()), |
|
381 | 381 | $result->getMessage(), |
382 | 382 | '[?]' |
383 | 383 | ); |
384 | 384 | |
385 | 385 | // Claim column |
386 | - $property = $this->entityIdLabelFormatter->formatEntityId( $result->getContext()->getSnak()->getPropertyId() ); |
|
387 | - if ( $result->getSnakType() === 'value' ) { |
|
388 | - $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()); |
|
389 | 389 | } else { |
390 | - $value = htmlspecialchars( $result->getSnakType() ); |
|
390 | + $value = htmlspecialchars($result->getSnakType()); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | $claimColumn = $this->getClaimLink( |
394 | 394 | $entityId, |
395 | 395 | $result->getContext()->getSnak()->getPropertyId(), |
396 | - $property . ': ' . $value |
|
396 | + $property.': '.$value |
|
397 | 397 | ); |
398 | 398 | |
399 | 399 | // Constraint column |
400 | 400 | $constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId(); |
401 | 401 | try { |
402 | - $constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) ); |
|
403 | - } catch ( InvalidArgumentException $e ) { |
|
404 | - $constraintTypeLabel = htmlspecialchars( $constraintTypeItemId ); |
|
402 | + $constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId)); |
|
403 | + } catch (InvalidArgumentException $e) { |
|
404 | + $constraintTypeLabel = htmlspecialchars($constraintTypeItemId); |
|
405 | 405 | } |
406 | 406 | $constraintLink = $this->getClaimLink( |
407 | 407 | $result->getContext()->getSnak()->getPropertyId(), |
408 | - new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ), |
|
408 | + new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')), |
|
409 | 409 | $constraintTypeLabel |
410 | 410 | ); |
411 | 411 | $constraintColumn = $this->buildExpandableElement( |
412 | 412 | $constraintLink, |
413 | - $this->constraintParameterRenderer->formatParameters( $result->getParameters() ), |
|
413 | + $this->constraintParameterRenderer->formatParameters($result->getParameters()), |
|
414 | 414 | '[...]' |
415 | 415 | ); |
416 | 416 | |
@@ -445,15 +445,15 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @return string HTML |
447 | 447 | */ |
448 | - protected function buildResultHeader( EntityId $entityId ) { |
|
449 | - $entityLink = sprintf( '%s (%s)', |
|
450 | - $this->entityIdLinkFormatter->formatEntityId( $entityId ), |
|
451 | - htmlspecialchars( $entityId->getSerialization() ) ); |
|
448 | + protected function buildResultHeader(EntityId $entityId) { |
|
449 | + $entityLink = sprintf('%s (%s)', |
|
450 | + $this->entityIdLinkFormatter->formatEntityId($entityId), |
|
451 | + htmlspecialchars($entityId->getSerialization())); |
|
452 | 452 | |
453 | 453 | return Html::rawElement( |
454 | 454 | 'h3', |
455 | 455 | [], |
456 | - sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink ) |
|
456 | + sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink) |
|
457 | 457 | ); |
458 | 458 | } |
459 | 459 | |
@@ -464,24 +464,24 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @return string HTML |
466 | 466 | */ |
467 | - protected function buildSummary( array $results ) { |
|
467 | + protected function buildSummary(array $results) { |
|
468 | 468 | $statuses = []; |
469 | - foreach ( $results as $result ) { |
|
470 | - $status = strtolower( $result->getStatus() ); |
|
471 | - $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; |
|
472 | 472 | } |
473 | 473 | |
474 | 474 | $statusElements = []; |
475 | - foreach ( $statuses as $status => $count ) { |
|
476 | - if ( $count > 0 ) { |
|
475 | + foreach ($statuses as $status => $count) { |
|
476 | + if ($count > 0) { |
|
477 | 477 | $statusElements[] = |
478 | - $this->formatStatus( $status ) |
|
478 | + $this->formatStatus($status) |
|
479 | 479 | . ': ' |
480 | 480 | . $count; |
481 | 481 | } |
482 | 482 | } |
483 | 483 | |
484 | - return Html::rawElement( 'p', [], implode( ', ', $statusElements ) ); |
|
484 | + return Html::rawElement('p', [], implode(', ', $statusElements)); |
|
485 | 485 | } |
486 | 486 | |
487 | 487 | /** |
@@ -496,15 +496,15 @@ discard block |
||
496 | 496 | * |
497 | 497 | * @return string HTML |
498 | 498 | */ |
499 | - protected function buildTooltipElement( $content, $tooltipContent, $indicator ) { |
|
500 | - if ( !is_string( $content ) ) { |
|
501 | - 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.'); |
|
502 | 502 | } |
503 | - if ( $tooltipContent && ( !is_string( $tooltipContent ) ) ) { |
|
504 | - 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.'); |
|
505 | 505 | } |
506 | 506 | |
507 | - if ( empty( $tooltipContent ) ) { |
|
507 | + if (empty($tooltipContent)) { |
|
508 | 508 | return $content; |
509 | 509 | } |
510 | 510 | |
@@ -521,13 +521,13 @@ discard block |
||
521 | 521 | [ |
522 | 522 | 'class' => 'wbqc-indicator' |
523 | 523 | ], |
524 | - htmlspecialchars( $indicator ) . $tooltip |
|
524 | + htmlspecialchars($indicator).$tooltip |
|
525 | 525 | ); |
526 | 526 | |
527 | 527 | return Html::rawElement( |
528 | 528 | 'span', |
529 | 529 | [], |
530 | - sprintf( '%s %s', $content, $tooltipIndicator ) |
|
530 | + sprintf('%s %s', $content, $tooltipIndicator) |
|
531 | 531 | ); |
532 | 532 | } |
533 | 533 | |
@@ -543,15 +543,15 @@ discard block |
||
543 | 543 | * |
544 | 544 | * @return string HTML |
545 | 545 | */ |
546 | - protected function buildExpandableElement( $content, $expandableContent, $indicator ) { |
|
547 | - if ( !is_string( $content ) ) { |
|
548 | - 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.'); |
|
549 | 549 | } |
550 | - if ( $expandableContent && ( !is_string( $expandableContent ) ) ) { |
|
551 | - 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.'); |
|
552 | 552 | } |
553 | 553 | |
554 | - if ( empty( $expandableContent ) ) { |
|
554 | + if (empty($expandableContent)) { |
|
555 | 555 | return $content; |
556 | 556 | } |
557 | 557 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | ); |
573 | 573 | |
574 | 574 | return |
575 | - sprintf( '%s %s %s', $content, $tooltipIndicator, $expandableContent ); |
|
575 | + sprintf('%s %s %s', $content, $tooltipIndicator, $expandableContent); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -584,16 +584,16 @@ discard block |
||
584 | 584 | * |
585 | 585 | * @return string HTML |
586 | 586 | */ |
587 | - private function formatStatus( $status ) { |
|
588 | - $messageName = "wbqc-constraintreport-status-" . strtolower( $status ); |
|
587 | + private function formatStatus($status) { |
|
588 | + $messageName = "wbqc-constraintreport-status-".strtolower($status); |
|
589 | 589 | |
590 | 590 | $formattedStatus = |
591 | 591 | Html::element( |
592 | 592 | 'span', |
593 | 593 | [ |
594 | - 'class' => 'wbqc-status wbqc-status-' . $status |
|
594 | + 'class' => 'wbqc-status wbqc-status-'.$status |
|
595 | 595 | ], |
596 | - $this->msg( $messageName )->text() |
|
596 | + $this->msg($messageName)->text() |
|
597 | 597 | ); |
598 | 598 | |
599 | 599 | return $formattedStatus; |
@@ -609,26 +609,26 @@ discard block |
||
609 | 609 | * |
610 | 610 | * @return string HTML |
611 | 611 | */ |
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.' ); |
|
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.'); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | $formattedDataValues = []; |
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.' ); |
|
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.'); |
|
623 | 623 | } |
624 | - if ( $dataValue instanceof EntityIdValue ) { |
|
625 | - $formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() ); |
|
624 | + if ($dataValue instanceof EntityIdValue) { |
|
625 | + $formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId()); |
|
626 | 626 | } else { |
627 | - $formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue ); |
|
627 | + $formattedDataValues[] = $this->dataValueFormatter->format($dataValue); |
|
628 | 628 | } |
629 | 629 | } |
630 | 630 | |
631 | - return implode( $separator, $formattedDataValues ); |
|
631 | + return implode($separator, $formattedDataValues); |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | /** |
@@ -640,12 +640,12 @@ discard block |
||
640 | 640 | * |
641 | 641 | * @return string HTML |
642 | 642 | */ |
643 | - private function getClaimLink( EntityId $entityId, PropertyId $propertyId, $text ) { |
|
643 | + private function getClaimLink(EntityId $entityId, PropertyId $propertyId, $text) { |
|
644 | 644 | return |
645 | 645 | Html::rawElement( |
646 | 646 | 'a', |
647 | 647 | [ |
648 | - 'href' => $this->getClaimUrl( $entityId, $propertyId ), |
|
648 | + 'href' => $this->getClaimUrl($entityId, $propertyId), |
|
649 | 649 | 'target' => '_blank' |
650 | 650 | ], |
651 | 651 | $text |
@@ -660,9 +660,9 @@ discard block |
||
660 | 660 | * |
661 | 661 | * @return string |
662 | 662 | */ |
663 | - private function getClaimUrl( EntityId $entityId, PropertyId $propertyId ) { |
|
664 | - $title = $this->entityTitleLookup->getTitleForId( $entityId ); |
|
665 | - $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()); |
|
666 | 666 | |
667 | 667 | return $entityUrl; |
668 | 668 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | public static function getDefaultInstance() { |
138 | 138 | static $instance = null; |
139 | 139 | |
140 | - if ( $instance === null ) { |
|
140 | + if ($instance === null) { |
|
141 | 141 | $wikibaseRepo = WikibaseRepo::getDefaultInstance(); |
142 | 142 | $entityIdFormatter = $wikibaseRepo->getEntityIdHtmlLinkFormatterFactory()->getEntityIdFormatter( |
143 | 143 | $wikibaseRepo->getLanguageFallbackLabelDescriptionLookupFactory()->newLabelDescriptionLookup( |
@@ -205,21 +205,21 @@ discard block |
||
205 | 205 | * @return DelegatingConstraintChecker |
206 | 206 | */ |
207 | 207 | public function getConstraintChecker() { |
208 | - if ( $this->delegatingConstraintChecker === null ) { |
|
208 | + if ($this->delegatingConstraintChecker === null) { |
|
209 | 209 | $this->delegatingConstraintChecker = new DelegatingConstraintChecker( |
210 | 210 | $this->lookup, |
211 | 211 | $this->getConstraintCheckerMap(), |
212 | - new CachingConstraintLookup( $this->getConstraintRepository() ), |
|
212 | + new CachingConstraintLookup($this->getConstraintRepository()), |
|
213 | 213 | $this->constraintParameterParser, |
214 | 214 | $this->statementGuidParser, |
215 | 215 | new LoggingHelper( |
216 | 216 | $this->dataFactory, |
217 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
217 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
218 | 218 | $this->config |
219 | 219 | ), |
220 | - $this->config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
221 | - $this->config->get( 'WBQualityConstraintsCheckReferences' ), |
|
222 | - $this->config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
220 | + $this->config->get('WBQualityConstraintsCheckQualifiers'), |
|
221 | + $this->config->get('WBQualityConstraintsCheckReferences'), |
|
222 | + $this->config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
223 | 223 | ); |
224 | 224 | } |
225 | 225 | |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | * @return ConstraintChecker[] |
231 | 231 | */ |
232 | 232 | private function getConstraintCheckerMap() { |
233 | - if ( $this->constraintCheckerMap === null ) { |
|
233 | + if ($this->constraintCheckerMap === null) { |
|
234 | 234 | $connectionCheckerHelper = new ConnectionCheckerHelper(); |
235 | - $rangeCheckerHelper = new RangeCheckerHelper( $this->config, $this->unitConverter ); |
|
236 | - if ( $this->config->get( 'WBQualityConstraintsSparqlEndpoint' ) !== '' ) { |
|
235 | + $rangeCheckerHelper = new RangeCheckerHelper($this->config, $this->unitConverter); |
|
236 | + if ($this->config->get('WBQualityConstraintsSparqlEndpoint') !== '') { |
|
237 | 237 | $sparqlHelper = new SparqlHelper( |
238 | 238 | $this->config, |
239 | 239 | $this->rdfVocabulary, |
@@ -254,74 +254,74 @@ discard block |
||
254 | 254 | ); |
255 | 255 | |
256 | 256 | $this->constraintCheckerMap = [ |
257 | - $this->config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
257 | + $this->config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
258 | 258 | => new ConflictsWithChecker( |
259 | 259 | $this->lookup, |
260 | 260 | $this->constraintParameterParser, |
261 | 261 | $connectionCheckerHelper, |
262 | 262 | $this->constraintParameterRenderer |
263 | 263 | ), |
264 | - $this->config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
264 | + $this->config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
265 | 265 | => new ItemChecker( |
266 | 266 | $this->lookup, |
267 | 267 | $this->constraintParameterParser, |
268 | 268 | $connectionCheckerHelper, |
269 | 269 | $this->constraintParameterRenderer |
270 | 270 | ), |
271 | - $this->config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
271 | + $this->config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
272 | 272 | => new TargetRequiredClaimChecker( |
273 | 273 | $this->lookup, |
274 | 274 | $this->constraintParameterParser, |
275 | 275 | $connectionCheckerHelper, |
276 | 276 | $this->constraintParameterRenderer |
277 | 277 | ), |
278 | - $this->config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
278 | + $this->config->get('WBQualityConstraintsSymmetricConstraintId') |
|
279 | 279 | => new SymmetricChecker( |
280 | 280 | $this->lookup, |
281 | 281 | $connectionCheckerHelper, |
282 | 282 | $this->constraintParameterRenderer |
283 | 283 | ), |
284 | - $this->config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
284 | + $this->config->get('WBQualityConstraintsInverseConstraintId') |
|
285 | 285 | => new InverseChecker( |
286 | 286 | $this->lookup, |
287 | 287 | $this->constraintParameterParser, |
288 | 288 | $connectionCheckerHelper, |
289 | 289 | $this->constraintParameterRenderer |
290 | 290 | ), |
291 | - $this->config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
291 | + $this->config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
292 | 292 | => new QualifierChecker(), |
293 | - $this->config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
293 | + $this->config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
294 | 294 | => new QualifiersChecker( |
295 | 295 | $this->constraintParameterParser, |
296 | 296 | $this->constraintParameterRenderer |
297 | 297 | ), |
298 | - $this->config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
298 | + $this->config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
299 | 299 | => new MandatoryQualifiersChecker( |
300 | 300 | $this->constraintParameterParser, |
301 | 301 | $this->constraintParameterRenderer |
302 | 302 | ), |
303 | - $this->config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
303 | + $this->config->get('WBQualityConstraintsRangeConstraintId') |
|
304 | 304 | => new RangeChecker( |
305 | 305 | $this->propertyDataTypeLookup, |
306 | 306 | $this->constraintParameterParser, |
307 | 307 | $rangeCheckerHelper, |
308 | 308 | $this->constraintParameterRenderer |
309 | 309 | ), |
310 | - $this->config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
310 | + $this->config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
311 | 311 | => new DiffWithinRangeChecker( |
312 | 312 | $this->constraintParameterParser, |
313 | 313 | $rangeCheckerHelper, |
314 | 314 | $this->constraintParameterRenderer, |
315 | 315 | $this->config |
316 | 316 | ), |
317 | - $this->config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
317 | + $this->config->get('WBQualityConstraintsTypeConstraintId') |
|
318 | 318 | => new TypeChecker( |
319 | 319 | $this->lookup, |
320 | 320 | $this->constraintParameterParser, |
321 | 321 | $typeCheckerHelper, |
322 | 322 | $this->config |
323 | 323 | ), |
324 | - $this->config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
324 | + $this->config->get('WBQualityConstraintsValueTypeConstraintId') |
|
325 | 325 | => new ValueTypeChecker( |
326 | 326 | $this->lookup, |
327 | 327 | $this->constraintParameterParser, |
@@ -329,36 +329,36 @@ discard block |
||
329 | 329 | $typeCheckerHelper, |
330 | 330 | $this->config |
331 | 331 | ), |
332 | - $this->config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
332 | + $this->config->get('WBQualityConstraintsSingleValueConstraintId') |
|
333 | 333 | => new SingleValueChecker(), |
334 | - $this->config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
334 | + $this->config->get('WBQualityConstraintsMultiValueConstraintId') |
|
335 | 335 | => new MultiValueChecker(), |
336 | - $this->config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
336 | + $this->config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
337 | 337 | => new UniqueValueChecker( |
338 | 338 | $this->constraintParameterRenderer, |
339 | 339 | $sparqlHelper |
340 | 340 | ), |
341 | - $this->config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
341 | + $this->config->get('WBQualityConstraintsFormatConstraintId') |
|
342 | 342 | => new FormatChecker( |
343 | 343 | $this->constraintParameterParser, |
344 | 344 | $this->constraintParameterRenderer, |
345 | 345 | $this->config, |
346 | 346 | $sparqlHelper |
347 | 347 | ), |
348 | - $this->config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
348 | + $this->config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
349 | 349 | => new CommonsLinkChecker( |
350 | 350 | $this->constraintParameterParser, |
351 | 351 | $this->constraintParameterRenderer, |
352 | 352 | $this->titleParser |
353 | 353 | ), |
354 | - $this->config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
354 | + $this->config->get('WBQualityConstraintsOneOfConstraintId') |
|
355 | 355 | => new OneOfChecker( |
356 | 356 | $this->constraintParameterParser, |
357 | 357 | $this->constraintParameterRenderer |
358 | 358 | ), |
359 | - $this->config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
359 | + $this->config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
360 | 360 | => new ValueOnlyChecker(), |
361 | - $this->config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
361 | + $this->config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
362 | 362 | => new ReferenceChecker(), |
363 | 363 | ]; |
364 | 364 | } |
@@ -370,26 +370,26 @@ discard block |
||
370 | 370 | * @return array[] |
371 | 371 | */ |
372 | 372 | public function getConstraintParameterMap() { |
373 | - if ( $this->constraintParameterMap === null ) { |
|
373 | + if ($this->constraintParameterMap === null) { |
|
374 | 374 | $this->constraintParameterMap = [ |
375 | - 'Commons link' => [ 'namespace' ], |
|
376 | - 'Conflicts with' => [ 'property', 'item' ], |
|
377 | - 'Diff within range' => [ 'property', 'minimum_quantity', 'maximum_quantity' ], |
|
378 | - 'Format' => [ 'pattern' ], |
|
379 | - 'Inverse' => [ 'property' ], |
|
380 | - 'Item' => [ 'property', 'item' ], |
|
381 | - 'Mandatory qualifiers' => [ 'property' ], |
|
375 | + 'Commons link' => ['namespace'], |
|
376 | + 'Conflicts with' => ['property', 'item'], |
|
377 | + 'Diff within range' => ['property', 'minimum_quantity', 'maximum_quantity'], |
|
378 | + 'Format' => ['pattern'], |
|
379 | + 'Inverse' => ['property'], |
|
380 | + 'Item' => ['property', 'item'], |
|
381 | + 'Mandatory qualifiers' => ['property'], |
|
382 | 382 | 'Multi value' => [], |
383 | - 'One of' => [ 'item' ], |
|
383 | + 'One of' => ['item'], |
|
384 | 384 | 'Qualifier' => [], |
385 | - 'Qualifiers' => [ 'property' ], |
|
386 | - 'Range' => [ 'minimum_quantity', 'maximum_quantity', 'minimum_date', 'maximum_date' ], |
|
385 | + 'Qualifiers' => ['property'], |
|
386 | + 'Range' => ['minimum_quantity', 'maximum_quantity', 'minimum_date', 'maximum_date'], |
|
387 | 387 | 'Single value' => [], |
388 | 388 | 'Symmetric' => [], |
389 | - 'Target required claim' => [ 'property', 'item' ], |
|
390 | - 'Type' => [ 'class', 'relation' ], |
|
389 | + 'Target required claim' => ['property', 'item'], |
|
390 | + 'Type' => ['class', 'relation'], |
|
391 | 391 | 'Unique value' => [], |
392 | - 'Value type' => [ 'class', 'relation' ] |
|
392 | + 'Value type' => ['class', 'relation'] |
|
393 | 393 | ]; |
394 | 394 | } |
395 | 395 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @return ConstraintRepository |
401 | 401 | */ |
402 | 402 | public function getConstraintRepository() { |
403 | - if ( $this->constraintRepository === null ) { |
|
403 | + if ($this->constraintRepository === null) { |
|
404 | 404 | $this->constraintRepository = new ConstraintRepository(); |
405 | 405 | } |
406 | 406 |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return self |
67 | 67 | */ |
68 | - public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) { |
|
68 | + public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') { |
|
69 | 69 | $constraintReportFactory = ConstraintReportFactory::getDefaultInstance(); |
70 | 70 | $repo = WikibaseRepo::getDefaultInstance(); |
71 | - $helperFactory = $repo->getApiHelperFactory( RequestContext::getMain() ); |
|
71 | + $helperFactory = $repo->getApiHelperFactory(RequestContext::getMain()); |
|
72 | 72 | return new self( |
73 | 73 | $main, |
74 | 74 | $name, |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | StatementGuidParser $statementGuidParser, |
99 | 99 | IBufferingStatsdDataFactory $dataFactory |
100 | 100 | ) { |
101 | - parent::__construct( $main, $name, $prefix ); |
|
101 | + parent::__construct($main, $name, $prefix); |
|
102 | 102 | |
103 | - $this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
103 | + $this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this); |
|
104 | 104 | $this->delegatingConstraintChecker = $delegatingConstraintChecker; |
105 | 105 | $this->statementGuidParser = $statementGuidParser; |
106 | 106 | $this->dataFactory = $dataFactory; |
@@ -114,39 +114,39 @@ discard block |
||
114 | 114 | $params = $this->extractRequestParams(); |
115 | 115 | $result = $this->getResult(); |
116 | 116 | |
117 | - $propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] ); |
|
118 | - $constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] ); |
|
117 | + $propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]); |
|
118 | + $constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]); |
|
119 | 119 | |
120 | - $this->checkPropertyIds( $propertyIds, $result ); |
|
121 | - $this->checkConstraintIds( $constraintIds, $result ); |
|
120 | + $this->checkPropertyIds($propertyIds, $result); |
|
121 | + $this->checkConstraintIds($constraintIds, $result); |
|
122 | 122 | |
123 | - $result->addValue( null, 'success', 1 ); |
|
123 | + $result->addValue(null, 'success', 1); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | 127 | * @param array|null $propertyIdSerializations |
128 | 128 | * @return PropertyId[] |
129 | 129 | */ |
130 | - private function parsePropertyIds( $propertyIdSerializations ) { |
|
131 | - if ( $propertyIdSerializations === null ) { |
|
130 | + private function parsePropertyIds($propertyIdSerializations) { |
|
131 | + if ($propertyIdSerializations === null) { |
|
132 | 132 | return []; |
133 | - } elseif ( empty( $propertyIdSerializations ) ) { |
|
133 | + } elseif (empty($propertyIdSerializations)) { |
|
134 | 134 | $this->apiErrorReporter->dieError( |
135 | - 'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.', |
|
135 | + 'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.', |
|
136 | 136 | 'no-data' |
137 | 137 | ); |
138 | 138 | } |
139 | 139 | |
140 | 140 | return array_map( |
141 | - function( $propertyIdSerialization ) { |
|
141 | + function($propertyIdSerialization) { |
|
142 | 142 | try { |
143 | - return new PropertyId( $propertyIdSerialization ); |
|
144 | - } catch ( InvalidArgumentException $e ) { |
|
143 | + return new PropertyId($propertyIdSerialization); |
|
144 | + } catch (InvalidArgumentException $e) { |
|
145 | 145 | $this->apiErrorReporter->dieError( |
146 | 146 | "Invalid id: $propertyIdSerialization", |
147 | 147 | 'invalid-property-id', |
148 | 148 | 0, // default argument |
149 | - [ self::PARAM_PROPERTY_ID => $propertyIdSerialization ] |
|
149 | + [self::PARAM_PROPERTY_ID => $propertyIdSerialization] |
|
150 | 150 | ); |
151 | 151 | } |
152 | 152 | }, |
@@ -158,35 +158,35 @@ discard block |
||
158 | 158 | * @param array|null $constraintIds |
159 | 159 | * @return string[] |
160 | 160 | */ |
161 | - private function parseConstraintIds( $constraintIds ) { |
|
162 | - if ( $constraintIds === null ) { |
|
161 | + private function parseConstraintIds($constraintIds) { |
|
162 | + if ($constraintIds === null) { |
|
163 | 163 | return []; |
164 | - } elseif ( empty( $constraintIds ) ) { |
|
164 | + } elseif (empty($constraintIds)) { |
|
165 | 165 | $this->apiErrorReporter->dieError( |
166 | - 'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.', |
|
166 | + 'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.', |
|
167 | 167 | 'no-data' |
168 | 168 | ); |
169 | 169 | } |
170 | 170 | |
171 | 171 | return array_map( |
172 | - function( $constraintId ) { |
|
172 | + function($constraintId) { |
|
173 | 173 | try { |
174 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
175 | - if ( !$propertyId instanceof PropertyId ) { |
|
174 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
175 | + if (!$propertyId instanceof PropertyId) { |
|
176 | 176 | $this->apiErrorReporter->dieError( |
177 | 177 | "Invalid property ID: {$propertyId->getSerialization()}", |
178 | 178 | 'invalid-property-id', |
179 | 179 | 0, // default argument |
180 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
180 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
181 | 181 | ); |
182 | 182 | } |
183 | 183 | return $constraintId; |
184 | - } catch ( StatementGuidParsingException $e ) { |
|
184 | + } catch (StatementGuidParsingException $e) { |
|
185 | 185 | $this->apiErrorReporter->dieError( |
186 | 186 | "Invalid statement GUID: $constraintId", |
187 | 187 | 'invalid-guid', |
188 | 188 | 0, // default argument |
189 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
189 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
190 | 190 | ); |
191 | 191 | } |
192 | 192 | }, |
@@ -198,12 +198,12 @@ discard block |
||
198 | 198 | * @param PropertyId[] $propertyIds |
199 | 199 | * @param ApiResult $result |
200 | 200 | */ |
201 | - private function checkPropertyIds( array $propertyIds, ApiResult $result ) { |
|
202 | - foreach ( $propertyIds as $propertyId ) { |
|
203 | - $result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' ); |
|
204 | - $allConstraintExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnPropertyId( $propertyId ); |
|
205 | - foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) { |
|
206 | - $this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result ); |
|
201 | + private function checkPropertyIds(array $propertyIds, ApiResult $result) { |
|
202 | + foreach ($propertyIds as $propertyId) { |
|
203 | + $result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc'); |
|
204 | + $allConstraintExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnPropertyId($propertyId); |
|
205 | + foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) { |
|
206 | + $this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | } |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | * @param string[] $constraintIds |
213 | 213 | * @param ApiResult $result |
214 | 214 | */ |
215 | - private function checkConstraintIds( array $constraintIds, ApiResult $result ) { |
|
216 | - foreach ( $constraintIds as $constraintId ) { |
|
217 | - if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) { |
|
215 | + private function checkConstraintIds(array $constraintIds, ApiResult $result) { |
|
216 | + foreach ($constraintIds as $constraintId) { |
|
217 | + if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) { |
|
218 | 218 | // already checked as part of checkPropertyIds() |
219 | 219 | continue; |
220 | 220 | } |
221 | - $constraintParameterExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnConstraintId( $constraintId ); |
|
222 | - $this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result ); |
|
221 | + $constraintParameterExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnConstraintId($constraintId); |
|
222 | + $this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
@@ -227,17 +227,17 @@ discard block |
||
227 | 227 | * @param PropertyId $propertyId |
228 | 228 | * @return string[] |
229 | 229 | */ |
230 | - private function getResultPathForPropertyId( PropertyId $propertyId ) { |
|
231 | - return [ $this->getModuleName(), $propertyId->getSerialization() ]; |
|
230 | + private function getResultPathForPropertyId(PropertyId $propertyId) { |
|
231 | + return [$this->getModuleName(), $propertyId->getSerialization()]; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
235 | 235 | * @param string $constraintId |
236 | 236 | * @return string[] |
237 | 237 | */ |
238 | - private function getResultPathForConstraintId( $constraintId ) { |
|
239 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
240 | - return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] ); |
|
238 | + private function getResultPathForConstraintId($constraintId) { |
|
239 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
240 | + return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | * @param ConstraintParameterException[]|null $constraintParameterExceptions |
248 | 248 | * @param ApiResult $result |
249 | 249 | */ |
250 | - private function addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, ApiResult $result ) { |
|
251 | - $path = $this->getResultPathForConstraintId( $constraintId ); |
|
252 | - if ( $constraintParameterExceptions === null ) { |
|
250 | + private function addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, ApiResult $result) { |
|
251 | + $path = $this->getResultPathForConstraintId($constraintId); |
|
252 | + if ($constraintParameterExceptions === null) { |
|
253 | 253 | $result->addValue( |
254 | 254 | $path, |
255 | 255 | self::KEY_STATUS, |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | $result->addValue( |
260 | 260 | $path, |
261 | 261 | self::KEY_STATUS, |
262 | - empty( $constraintParameterExceptions ) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY |
|
262 | + empty($constraintParameterExceptions) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY |
|
263 | 263 | ); |
264 | 264 | $result->addValue( |
265 | 265 | $path, |
266 | 266 | self::KEY_PROBLEMS, |
267 | - array_map( [ $this, 'formatConstraintParameterException' ], $constraintParameterExceptions ) |
|
267 | + array_map([$this, 'formatConstraintParameterException'], $constraintParameterExceptions) |
|
268 | 268 | ); |
269 | 269 | } |
270 | 270 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * @param ConstraintParameterException $e |
276 | 276 | * @return array |
277 | 277 | */ |
278 | - private function formatConstraintParameterException( ConstraintParameterException $e ) { |
|
278 | + private function formatConstraintParameterException(ConstraintParameterException $e) { |
|
279 | 279 | return [ |
280 | 280 | self::KEY_MESSAGE_HTML => $e->getMessage(), |
281 | 281 | ]; |
@@ -87,23 +87,23 @@ discard block |
||
87 | 87 | * @return bool |
88 | 88 | * @throws OverflowException if $entitiesChecked exceeds the configured limit |
89 | 89 | */ |
90 | - private function isSubclassOf( EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0 ) { |
|
91 | - $maxEntities = $this->config->get( 'WBQualityConstraintsTypeCheckMaxEntities' ); |
|
90 | + private function isSubclassOf(EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0) { |
|
91 | + $maxEntities = $this->config->get('WBQualityConstraintsTypeCheckMaxEntities'); |
|
92 | 92 | if ( ++$entitiesChecked > $maxEntities ) { |
93 | - throw new OverflowException( 'Too many entities to check' ); |
|
93 | + throw new OverflowException('Too many entities to check'); |
|
94 | 94 | } |
95 | 95 | |
96 | - $item = $this->entityLookup->getEntity( $comparativeClass ); |
|
97 | - if ( !( $item instanceof StatementListProvider ) ) { |
|
96 | + $item = $this->entityLookup->getEntity($comparativeClass); |
|
97 | + if (!($item instanceof StatementListProvider)) { |
|
98 | 98 | return false; // lookup failed, probably because item doesn't exist |
99 | 99 | } |
100 | 100 | |
101 | - $subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfId' ); |
|
101 | + $subclassId = $this->config->get('WBQualityConstraintsSubclassOfId'); |
|
102 | 102 | /** @var Statement $statement */ |
103 | - foreach ( $item->getStatements()->getByPropertyId( new PropertyId( $subclassId ) ) as $statement ) { |
|
103 | + foreach ($item->getStatements()->getByPropertyId(new PropertyId($subclassId)) as $statement) { |
|
104 | 104 | $mainSnak = $statement->getMainSnak(); |
105 | 105 | |
106 | - if ( !( $this->hasCorrectType( $mainSnak ) ) ) { |
|
106 | + if (!($this->hasCorrectType($mainSnak))) { |
|
107 | 107 | continue; |
108 | 108 | } |
109 | 109 | /** @var PropertyValueSnak $mainSnak */ |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | $dataValue = $mainSnak->getDataValue(); |
113 | 113 | $comparativeClass = $dataValue->getEntityId(); |
114 | 114 | |
115 | - if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) { |
|
115 | + if (in_array($comparativeClass->getSerialization(), $classesToCheck)) { |
|
116 | 116 | return true; |
117 | 117 | } |
118 | 118 | |
119 | - if ( $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ) ) { |
|
119 | + if ($this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked)) { |
|
120 | 120 | return true; |
121 | 121 | } |
122 | 122 | } |
@@ -137,14 +137,14 @@ discard block |
||
137 | 137 | * @return CachedBool |
138 | 138 | * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs |
139 | 139 | */ |
140 | - public function isSubclassOfWithSparqlFallback( EntityId $comparativeClass, array $classesToCheck ) { |
|
140 | + public function isSubclassOfWithSparqlFallback(EntityId $comparativeClass, array $classesToCheck) { |
|
141 | 141 | try { |
142 | 142 | return new CachedBool( |
143 | - $this->isSubclassOf( $comparativeClass, $classesToCheck ), |
|
143 | + $this->isSubclassOf($comparativeClass, $classesToCheck), |
|
144 | 144 | Metadata::blank() |
145 | 145 | ); |
146 | - } catch ( OverflowException $e ) { |
|
147 | - if ( $this->sparqlHelper !== null ) { |
|
146 | + } catch (OverflowException $e) { |
|
147 | + if ($this->sparqlHelper !== null) { |
|
148 | 148 | $this->dataFactory->increment( |
149 | 149 | 'wikibase.quality.constraints.sparql.typeFallback' |
150 | 150 | ); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | /* withInstance = */ false |
155 | 155 | ); |
156 | 156 | } else { |
157 | - return new CachedBool( false, Metadata::blank() ); |
|
157 | + return new CachedBool(false, Metadata::blank()); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | } |
@@ -172,14 +172,14 @@ discard block |
||
172 | 172 | * @return CachedBool |
173 | 173 | * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs |
174 | 174 | */ |
175 | - public function hasClassInRelation( StatementList $statements, $relationId, array $classesToCheck ) { |
|
175 | + public function hasClassInRelation(StatementList $statements, $relationId, array $classesToCheck) { |
|
176 | 176 | $metadatas = []; |
177 | 177 | |
178 | 178 | /** @var Statement $statement */ |
179 | - foreach ( $statements->getByPropertyId( new PropertyId( $relationId ) ) as $statement ) { |
|
179 | + foreach ($statements->getByPropertyId(new PropertyId($relationId)) as $statement) { |
|
180 | 180 | $mainSnak = $statement->getMainSnak(); |
181 | 181 | |
182 | - if ( !$this->hasCorrectType( $mainSnak ) ) { |
|
182 | + if (!$this->hasCorrectType($mainSnak)) { |
|
183 | 183 | continue; |
184 | 184 | } |
185 | 185 | /** @var PropertyValueSnak $mainSnak */ |
@@ -188,28 +188,28 @@ discard block |
||
188 | 188 | $dataValue = $mainSnak->getDataValue(); |
189 | 189 | $comparativeClass = $dataValue->getEntityId(); |
190 | 190 | |
191 | - if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) { |
|
191 | + if (in_array($comparativeClass->getSerialization(), $classesToCheck)) { |
|
192 | 192 | // discard $metadatas, we know this is fresh |
193 | - return new CachedBool( true, Metadata::blank() ); |
|
193 | + return new CachedBool(true, Metadata::blank()); |
|
194 | 194 | } |
195 | 195 | |
196 | - $result = $this->isSubclassOfWithSparqlFallback( $comparativeClass, $classesToCheck ); |
|
196 | + $result = $this->isSubclassOfWithSparqlFallback($comparativeClass, $classesToCheck); |
|
197 | 197 | $metadatas[] = $result->getMetadata(); |
198 | - if ( $result->getBool() ) { |
|
198 | + if ($result->getBool()) { |
|
199 | 199 | return new CachedBool( |
200 | 200 | true, |
201 | - Metadata::merge( $metadatas ) |
|
201 | + Metadata::merge($metadatas) |
|
202 | 202 | ); |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | 206 | return new CachedBool( |
207 | 207 | false, |
208 | - Metadata::merge( $metadatas ) |
|
208 | + Metadata::merge($metadatas) |
|
209 | 209 | ); |
210 | 210 | } |
211 | 211 | |
212 | - private function hasCorrectType( Snak $mainSnak ) { |
|
212 | + private function hasCorrectType(Snak $mainSnak) { |
|
213 | 213 | return $mainSnak instanceof PropertyValueSnak |
214 | 214 | && $mainSnak->getDataValue()->getType() === 'wikibase-entityid'; |
215 | 215 | } |
@@ -223,20 +223,20 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return string Localized HTML message |
225 | 225 | */ |
226 | - public function getViolationMessage( PropertyId $propertyId, EntityId $entityId, array $classes, $checker, $relation ) { |
|
226 | + public function getViolationMessage(PropertyId $propertyId, EntityId $entityId, array $classes, $checker, $relation) { |
|
227 | 227 | // Possible messages: |
228 | 228 | // wbqc-violation-message-type-instance |
229 | 229 | // wbqc-violation-message-type-subclass |
230 | 230 | // wbqc-violation-message-valueType-instance |
231 | 231 | // wbqc-violation-message-valueType-subclass |
232 | - $message = wfMessage( 'wbqc-violation-message-' . $checker . '-' . $relation ); |
|
232 | + $message = wfMessage('wbqc-violation-message-'.$checker.'-'.$relation); |
|
233 | 233 | |
234 | 234 | $message->rawParams( |
235 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::CONSTRAINT_PROPERTY ), |
|
236 | - $this->constraintParameterRenderer->formatEntityId( $entityId, Role::SUBJECT ) |
|
235 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::CONSTRAINT_PROPERTY), |
|
236 | + $this->constraintParameterRenderer->formatEntityId($entityId, Role::SUBJECT) |
|
237 | 237 | ); |
238 | - $message->numParams( count( $classes ) ); |
|
239 | - $message->rawParams( $this->constraintParameterRenderer->formatItemIdList( $classes, Role::OBJECT ) ); |
|
238 | + $message->numParams(count($classes)); |
|
239 | + $message->rawParams($this->constraintParameterRenderer->formatItemIdList($classes, Role::OBJECT)); |
|
240 | 240 | |
241 | 241 | return $message->escaped(); |
242 | 242 | } |