@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | ) { |
145 | 145 | $results = []; |
146 | 146 | $metadatas = []; |
147 | - if ( $this->canUseStoredResults( $claimIds, $constraintIds, $statuses ) ) { |
|
147 | + if ($this->canUseStoredResults($claimIds, $constraintIds, $statuses)) { |
|
148 | 148 | $storedEntityIds = []; |
149 | - foreach ( $entityIds as $entityId ) { |
|
150 | - $storedResults = $this->getStoredResults( $entityId ); |
|
151 | - if ( $storedResults !== null ) { |
|
152 | - $this->loggingHelper->logCheckConstraintsCacheHit( $entityId ); |
|
153 | - foreach ( $storedResults->getArray() as $checkResult ) { |
|
154 | - if ( $this->statusSelected( $statuses, $checkResult ) ) { |
|
149 | + foreach ($entityIds as $entityId) { |
|
150 | + $storedResults = $this->getStoredResults($entityId); |
|
151 | + if ($storedResults !== null) { |
|
152 | + $this->loggingHelper->logCheckConstraintsCacheHit($entityId); |
|
153 | + foreach ($storedResults->getArray() as $checkResult) { |
|
154 | + if ($this->statusSelected($statuses, $checkResult)) { |
|
155 | 155 | $results[] = $checkResult; |
156 | 156 | } |
157 | 157 | } |
@@ -159,19 +159,19 @@ discard block |
||
159 | 159 | $storedEntityIds[] = $entityId; |
160 | 160 | } |
161 | 161 | } |
162 | - $entityIds = array_values( array_diff( $entityIds, $storedEntityIds ) ); |
|
162 | + $entityIds = array_values(array_diff($entityIds, $storedEntityIds)); |
|
163 | 163 | } |
164 | - if ( $entityIds !== [] || $claimIds !== [] ) { |
|
165 | - if ( $entityIds !== [] ) { |
|
166 | - $this->loggingHelper->logCheckConstraintsCacheMisses( $entityIds ); |
|
164 | + if ($entityIds !== [] || $claimIds !== []) { |
|
165 | + if ($entityIds !== []) { |
|
166 | + $this->loggingHelper->logCheckConstraintsCacheMisses($entityIds); |
|
167 | 167 | } |
168 | - $response = $this->getAndStoreResults( $entityIds, $claimIds, $constraintIds, $statuses ); |
|
169 | - $results = array_merge( $results, $response->getArray() ); |
|
168 | + $response = $this->getAndStoreResults($entityIds, $claimIds, $constraintIds, $statuses); |
|
169 | + $results = array_merge($results, $response->getArray()); |
|
170 | 170 | $metadatas[] = $response->getMetadata(); |
171 | 171 | } |
172 | 172 | return new CachedCheckResults( |
173 | 173 | $results, |
174 | - Metadata::merge( $metadatas ) |
|
174 | + Metadata::merge($metadatas) |
|
175 | 175 | ); |
176 | 176 | } |
177 | 177 | |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | ?array $constraintIds, |
193 | 193 | array $statuses |
194 | 194 | ) { |
195 | - if ( $claimIds !== [] ) { |
|
195 | + if ($claimIds !== []) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | - if ( $constraintIds !== null ) { |
|
198 | + if ($constraintIds !== null) { |
|
199 | 199 | return false; |
200 | 200 | } |
201 | - if ( array_diff( $statuses, self::CACHED_STATUSES ) !== [] ) { |
|
201 | + if (array_diff($statuses, self::CACHED_STATUSES) !== []) { |
|
202 | 202 | return false; |
203 | 203 | } |
204 | 204 | return true; |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | * @param CheckResult $result |
214 | 214 | * @return bool |
215 | 215 | */ |
216 | - private function statusSelected( array $statuses, CheckResult $result ) { |
|
217 | - return in_array( $result->getStatus(), $statuses, true ) || |
|
216 | + private function statusSelected(array $statuses, CheckResult $result) { |
|
217 | + return in_array($result->getStatus(), $statuses, true) || |
|
218 | 218 | $result instanceof NullResult; |
219 | 219 | } |
220 | 220 | |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | ?array $constraintIds, |
232 | 232 | array $statuses |
233 | 233 | ) { |
234 | - $results = $this->resultsSource->getResults( $entityIds, $claimIds, $constraintIds, $statuses ); |
|
234 | + $results = $this->resultsSource->getResults($entityIds, $claimIds, $constraintIds, $statuses); |
|
235 | 235 | |
236 | - if ( $this->canStoreResults( $constraintIds, $statuses ) ) { |
|
237 | - foreach ( $entityIds as $entityId ) { |
|
238 | - $this->storeResults( $entityId, $results ); |
|
236 | + if ($this->canStoreResults($constraintIds, $statuses)) { |
|
237 | + foreach ($entityIds as $entityId) { |
|
238 | + $this->storeResults($entityId, $results); |
|
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | ?array $constraintIds, |
263 | 263 | array $statuses |
264 | 264 | ) { |
265 | - if ( $constraintIds !== null ) { |
|
265 | + if ($constraintIds !== null) { |
|
266 | 266 | return false; |
267 | 267 | } |
268 | - if ( array_diff( self::CACHED_STATUSES, $statuses ) !== [] ) { |
|
268 | + if (array_diff(self::CACHED_STATUSES, $statuses) !== []) { |
|
269 | 269 | return false; |
270 | 270 | } |
271 | 271 | return true; |
@@ -279,21 +279,21 @@ discard block |
||
279 | 279 | * May include check results for other entity IDs as well, |
280 | 280 | * or check results with statuses that we’re not interested in caching. |
281 | 281 | */ |
282 | - private function storeResults( EntityId $entityId, CachedCheckResults $results ) { |
|
282 | + private function storeResults(EntityId $entityId, CachedCheckResults $results) { |
|
283 | 283 | $latestRevisionIds = $this->getLatestRevisionIds( |
284 | 284 | $results->getMetadata()->getDependencyMetadata()->getEntityIds() |
285 | 285 | ); |
286 | - if ( $latestRevisionIds === null ) { |
|
286 | + if ($latestRevisionIds === null) { |
|
287 | 287 | return; |
288 | 288 | } |
289 | 289 | |
290 | 290 | $resultSerializations = []; |
291 | - foreach ( $results->getArray() as $checkResult ) { |
|
292 | - if ( $checkResult->getContextCursor()->getEntityId() !== $entityId->getSerialization() ) { |
|
291 | + foreach ($results->getArray() as $checkResult) { |
|
292 | + if ($checkResult->getContextCursor()->getEntityId() !== $entityId->getSerialization()) { |
|
293 | 293 | continue; |
294 | 294 | } |
295 | - if ( $this->statusSelected( self::CACHED_STATUSES, $checkResult ) ) { |
|
296 | - $resultSerializations[] = $this->checkResultSerializer->serialize( $checkResult ); |
|
295 | + if ($this->statusSelected(self::CACHED_STATUSES, $checkResult)) { |
|
296 | + $resultSerializations[] = $this->checkResultSerializer->serialize($checkResult); |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
@@ -302,11 +302,11 @@ discard block |
||
302 | 302 | 'latestRevisionIds' => $latestRevisionIds, |
303 | 303 | ]; |
304 | 304 | $futureTime = $results->getMetadata()->getDependencyMetadata()->getFutureTime(); |
305 | - if ( $futureTime !== null ) { |
|
305 | + if ($futureTime !== null) { |
|
306 | 306 | $value['futureTime'] = $futureTime->getArrayValue(); |
307 | 307 | } |
308 | 308 | |
309 | - $this->cache->set( $entityId, $value, $this->ttlInSeconds ); |
|
309 | + $this->cache->set($entityId, $value, $this->ttlInSeconds); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -321,33 +321,32 @@ discard block |
||
321 | 321 | $forRevision = 0 |
322 | 322 | ) { |
323 | 323 | $cacheInfo = WANObjectCache::PASS_BY_REF; |
324 | - $value = $this->cache->get( $entityId, $curTTL, [], $cacheInfo ); |
|
325 | - $now = ( $this->microtime )( true ); |
|
324 | + $value = $this->cache->get($entityId, $curTTL, [], $cacheInfo); |
|
325 | + $now = ($this->microtime)(true); |
|
326 | 326 | |
327 | - $dependencyMetadata = $this->checkDependencyMetadata( $value, |
|
328 | - [ $entityId->getSerialization() => $forRevision ] ); |
|
329 | - if ( $dependencyMetadata === null ) { |
|
327 | + $dependencyMetadata = $this->checkDependencyMetadata($value, |
|
328 | + [$entityId->getSerialization() => $forRevision]); |
|
329 | + if ($dependencyMetadata === null) { |
|
330 | 330 | return null; |
331 | 331 | } |
332 | 332 | |
333 | 333 | // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset False positive |
334 | 334 | $asOf = $cacheInfo[WANObjectCache::KEY_AS_OF]; |
335 | - $ageInSeconds = (int)ceil( $now - $asOf ); |
|
335 | + $ageInSeconds = (int) ceil($now - $asOf); |
|
336 | 336 | $cachingMetadata = $ageInSeconds > 0 ? |
337 | - CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) : |
|
338 | - CachingMetadata::fresh(); |
|
337 | + CachingMetadata::ofMaximumAgeInSeconds($ageInSeconds) : CachingMetadata::fresh(); |
|
339 | 338 | |
340 | 339 | $results = []; |
341 | - foreach ( $value['results'] as $resultSerialization ) { |
|
342 | - $results[] = $this->deserializeCheckResult( $resultSerialization, $cachingMetadata ); |
|
340 | + foreach ($value['results'] as $resultSerialization) { |
|
341 | + $results[] = $this->deserializeCheckResult($resultSerialization, $cachingMetadata); |
|
343 | 342 | } |
344 | 343 | |
345 | 344 | return new CachedCheckResults( |
346 | 345 | $results, |
347 | - Metadata::merge( [ |
|
348 | - Metadata::ofCachingMetadata( $cachingMetadata ), |
|
349 | - Metadata::ofDependencyMetadata( $dependencyMetadata ), |
|
350 | - ] ) |
|
346 | + Metadata::merge([ |
|
347 | + Metadata::ofCachingMetadata($cachingMetadata), |
|
348 | + Metadata::ofDependencyMetadata($dependencyMetadata), |
|
349 | + ]) |
|
351 | 350 | ); |
352 | 351 | } |
353 | 352 | |
@@ -363,43 +362,43 @@ discard block |
||
363 | 362 | * @return DependencyMetadata|null the dependency metadata, |
364 | 363 | * or null if $value should no longer be used |
365 | 364 | */ |
366 | - private function checkDependencyMetadata( $value, $paramRevs ) { |
|
367 | - if ( $value === false ) { |
|
365 | + private function checkDependencyMetadata($value, $paramRevs) { |
|
366 | + if ($value === false) { |
|
368 | 367 | return null; |
369 | 368 | } |
370 | 369 | |
371 | - if ( array_key_exists( 'futureTime', $value ) ) { |
|
372 | - $futureTime = TimeValue::newFromArray( $value['futureTime'] ); |
|
373 | - if ( !$this->timeValueComparer->isFutureTime( $futureTime ) ) { |
|
370 | + if (array_key_exists('futureTime', $value)) { |
|
371 | + $futureTime = TimeValue::newFromArray($value['futureTime']); |
|
372 | + if (!$this->timeValueComparer->isFutureTime($futureTime)) { |
|
374 | 373 | return null; |
375 | 374 | } |
376 | - $futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime( $futureTime ); |
|
375 | + $futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime($futureTime); |
|
377 | 376 | } else { |
378 | 377 | $futureTimeDependencyMetadata = DependencyMetadata::blank(); |
379 | 378 | } |
380 | 379 | |
381 | - foreach ( $paramRevs as $id => $revision ) { |
|
382 | - if ( $revision > 0 ) { |
|
383 | - $value['latestRevisionIds'][$id] = min( $revision, $value['latestRevisionIds'][$id] ?? PHP_INT_MAX ); |
|
380 | + foreach ($paramRevs as $id => $revision) { |
|
381 | + if ($revision > 0) { |
|
382 | + $value['latestRevisionIds'][$id] = min($revision, $value['latestRevisionIds'][$id] ?? PHP_INT_MAX); |
|
384 | 383 | } |
385 | 384 | } |
386 | 385 | |
387 | 386 | $dependedEntityIds = array_map( |
388 | - [ $this->entityIdParser, "parse" ], |
|
389 | - array_keys( $value['latestRevisionIds'] ) |
|
387 | + [$this->entityIdParser, "parse"], |
|
388 | + array_keys($value['latestRevisionIds']) |
|
390 | 389 | ); |
391 | 390 | |
392 | - if ( $value['latestRevisionIds'] !== $this->getLatestRevisionIds( $dependedEntityIds ) ) { |
|
391 | + if ($value['latestRevisionIds'] !== $this->getLatestRevisionIds($dependedEntityIds)) { |
|
393 | 392 | return null; |
394 | 393 | } |
395 | 394 | |
396 | 395 | return array_reduce( |
397 | 396 | $dependedEntityIds, |
398 | - static function ( DependencyMetadata $metadata, EntityId $entityId ) { |
|
399 | - return DependencyMetadata::merge( [ |
|
397 | + static function(DependencyMetadata $metadata, EntityId $entityId) { |
|
398 | + return DependencyMetadata::merge([ |
|
400 | 399 | $metadata, |
401 | - DependencyMetadata::ofEntityId( $entityId ), |
|
402 | - ] ); |
|
400 | + DependencyMetadata::ofEntityId($entityId), |
|
401 | + ]); |
|
403 | 402 | }, |
404 | 403 | $futureTimeDependencyMetadata |
405 | 404 | ); |
@@ -419,13 +418,13 @@ discard block |
||
419 | 418 | array $resultSerialization, |
420 | 419 | CachingMetadata $cachingMetadata |
421 | 420 | ) { |
422 | - $result = $this->checkResultDeserializer->deserialize( $resultSerialization ); |
|
423 | - if ( $this->isPossiblyStaleResult( $result ) ) { |
|
421 | + $result = $this->checkResultDeserializer->deserialize($resultSerialization); |
|
422 | + if ($this->isPossiblyStaleResult($result)) { |
|
424 | 423 | $result->withMetadata( |
425 | - Metadata::merge( [ |
|
424 | + Metadata::merge([ |
|
426 | 425 | $result->getMetadata(), |
427 | - Metadata::ofCachingMetadata( $cachingMetadata ), |
|
428 | - ] ) |
|
426 | + Metadata::ofCachingMetadata($cachingMetadata), |
|
427 | + ]) |
|
429 | 428 | ); |
430 | 429 | } |
431 | 430 | return $result; |
@@ -435,8 +434,8 @@ discard block |
||
435 | 434 | * @param CheckResult $result |
436 | 435 | * @return bool |
437 | 436 | */ |
438 | - private function isPossiblyStaleResult( CheckResult $result ) { |
|
439 | - if ( $result instanceof NullResult ) { |
|
437 | + private function isPossiblyStaleResult(CheckResult $result) { |
|
438 | + if ($result instanceof NullResult) { |
|
440 | 439 | return false; |
441 | 440 | } |
442 | 441 | |
@@ -451,14 +450,14 @@ discard block |
||
451 | 450 | * @return int[]|null array from entity ID serializations to revision ID, |
452 | 451 | * or null to indicate that not all revision IDs could be loaded |
453 | 452 | */ |
454 | - private function getLatestRevisionIds( array $entityIds ) { |
|
455 | - if ( $entityIds === [] ) { |
|
453 | + private function getLatestRevisionIds(array $entityIds) { |
|
454 | + if ($entityIds === []) { |
|
456 | 455 | $this->loggingHelper->logEmptyDependencyMetadata(); |
457 | 456 | return []; |
458 | 457 | } |
459 | - if ( count( $entityIds ) > $this->maxRevisionIds ) { |
|
458 | + if (count($entityIds) > $this->maxRevisionIds) { |
|
460 | 459 | // one of those entities will probably be edited soon, so might as well skip caching |
461 | - $this->loggingHelper->logHugeDependencyMetadata( $entityIds, $this->maxRevisionIds ); |
|
460 | + $this->loggingHelper->logHugeDependencyMetadata($entityIds, $this->maxRevisionIds); |
|
462 | 461 | return null; |
463 | 462 | } |
464 | 463 | |
@@ -466,7 +465,7 @@ discard block |
||
466 | 465 | $entityIds, |
467 | 466 | LookupConstants::LATEST_FROM_REPLICA |
468 | 467 | ); |
469 | - if ( $this->hasFalseElements( $latestRevisionIds ) ) { |
|
468 | + if ($this->hasFalseElements($latestRevisionIds)) { |
|
470 | 469 | return null; |
471 | 470 | } |
472 | 471 | return $latestRevisionIds; |
@@ -476,14 +475,14 @@ discard block |
||
476 | 475 | * @param array $array |
477 | 476 | * @return bool |
478 | 477 | */ |
479 | - private function hasFalseElements( array $array ) { |
|
480 | - return in_array( false, $array, true ); |
|
478 | + private function hasFalseElements(array $array) { |
|
479 | + return in_array(false, $array, true); |
|
481 | 480 | } |
482 | 481 | |
483 | 482 | /** |
484 | 483 | * Set a custom function to get the current time, instead of microtime(). |
485 | 484 | */ |
486 | - public function setMicrotimeFunction( callable $microtime ) { |
|
485 | + public function setMicrotimeFunction(callable $microtime) { |
|
487 | 486 | $this->microtime = $microtime; |
488 | 487 | } |
489 | 488 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\Api; |
6 | 6 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | private BagOStuff $cache; |
23 | 23 | |
24 | - public function __construct( BagOStuff $cache ) { |
|
24 | + public function __construct(BagOStuff $cache) { |
|
25 | 25 | $this->cache = $cache; |
26 | 26 | } |
27 | 27 | |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @throws \Wikimedia\Assert\ParameterTypeException |
34 | 34 | */ |
35 | - private function makeKey( string $id ): string { |
|
36 | - if ( trim( $id ) === '' ) { |
|
37 | - throw new ParameterTypeException( '$id', 'non-empty string' ); |
|
35 | + private function makeKey(string $id): string { |
|
36 | + if (trim($id) === '') { |
|
37 | + throw new ParameterTypeException('$id', 'non-empty string'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | return $this->cache->makeKey( |
@@ -52,15 +52,15 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @throws \Wikimedia\Assert\ParameterTypeException |
54 | 54 | */ |
55 | - public function lock( string $id, ConvertibleTimestamp $expiryTimestamp ): bool { |
|
55 | + public function lock(string $id, ConvertibleTimestamp $expiryTimestamp): bool { |
|
56 | 56 | |
57 | - $cacheId = $this->makeKey( $id ); |
|
57 | + $cacheId = $this->makeKey($id); |
|
58 | 58 | |
59 | - if ( !$this->isLockedInternal( $cacheId ) ) { |
|
59 | + if (!$this->isLockedInternal($cacheId)) { |
|
60 | 60 | return $this->cache->set( |
61 | 61 | $cacheId, |
62 | - $expiryTimestamp->getTimestamp( TS_UNIX ), |
|
63 | - (int)$expiryTimestamp->getTimestamp( TS_UNIX ) |
|
62 | + $expiryTimestamp->getTimestamp(TS_UNIX), |
|
63 | + (int) $expiryTimestamp->getTimestamp(TS_UNIX) |
|
64 | 64 | ); |
65 | 65 | } else { |
66 | 66 | return false; |
@@ -74,20 +74,20 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @throws \Wikimedia\Assert\ParameterTypeException |
76 | 76 | */ |
77 | - private function isLockedInternal( string $cacheId ): bool { |
|
78 | - $expiryTime = $this->cache->get( $cacheId ); |
|
79 | - if ( !$expiryTime ) { |
|
77 | + private function isLockedInternal(string $cacheId): bool { |
|
78 | + $expiryTime = $this->cache->get($cacheId); |
|
79 | + if (!$expiryTime) { |
|
80 | 80 | return false; |
81 | 81 | } |
82 | 82 | |
83 | 83 | try { |
84 | - $lockExpiryTimeStamp = new ConvertibleTimestamp( $expiryTime ); |
|
85 | - } catch ( TimestampException ) { |
|
84 | + $lockExpiryTimeStamp = new ConvertibleTimestamp($expiryTime); |
|
85 | + } catch (TimestampException) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
89 | 89 | $now = new ConvertibleTimestamp(); |
90 | - if ( $now->timestamp < $lockExpiryTimeStamp->timestamp ) { |
|
90 | + if ($now->timestamp < $lockExpiryTimeStamp->timestamp) { |
|
91 | 91 | return true; |
92 | 92 | } else { |
93 | 93 | return false; |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @throws \Wikimedia\Assert\ParameterTypeException |
103 | 103 | */ |
104 | - public function isLocked( string $id ): bool { |
|
105 | - return $this->isLockedInternal( $this->makeKey( $id ) ); |
|
104 | + public function isLocked(string $id): bool { |
|
105 | + return $this->isLockedInternal($this->makeKey($id)); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | // @phan-file-suppress PhanPluginNeverReturnMethod |
6 | 6 | |
@@ -28,22 +28,22 @@ discard block |
||
28 | 28 | */ |
29 | 29 | private const NULL_PROPERTY_ID = 'P2147483647'; |
30 | 30 | |
31 | - public function __construct( ContextCursor $contextCursor ) { |
|
31 | + public function __construct(ContextCursor $contextCursor) { |
|
32 | 32 | $constraint = new Constraint( |
33 | 33 | 'null', |
34 | - new NumericPropertyId( self::NULL_PROPERTY_ID ), |
|
34 | + new NumericPropertyId(self::NULL_PROPERTY_ID), |
|
35 | 35 | 'none', |
36 | 36 | [] |
37 | 37 | ); |
38 | - parent::__construct( $contextCursor, $constraint ); |
|
38 | + parent::__construct($contextCursor, $constraint); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function getConstraint(): Constraint { |
42 | - throw new DomainException( 'NullResult holds no constraint' ); |
|
42 | + throw new DomainException('NullResult holds no constraint'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function getConstraintId(): string { |
46 | - throw new DomainException( 'NullResult holds no constraint' ); |
|
46 | + throw new DomainException('NullResult holds no constraint'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | // @phan-file-suppress PhanPluginNeverReturnMethod |
6 | 6 | |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | // no parent::__construct() call |
30 | 30 | } |
31 | 31 | |
32 | - public function hasType( EntityId $id, array $classes ): CachedBool { |
|
33 | - throw new LogicException( 'methods of this class should never be called' ); |
|
32 | + public function hasType(EntityId $id, array $classes): CachedBool { |
|
33 | + throw new LogicException('methods of this class should never be called'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public function findEntitiesWithSameStatement( |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | Statement $statement, |
39 | 39 | array $separators |
40 | 40 | ): CachedEntityIds { |
41 | - throw new LogicException( 'methods of this class should never be called' ); |
|
41 | + throw new LogicException('methods of this class should never be called'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | public function findEntitiesWithSameQualifierOrReference( |
@@ -47,15 +47,15 @@ discard block |
||
47 | 47 | string $type, |
48 | 48 | bool $ignoreDeprecatedStatements |
49 | 49 | ): CachedEntityIds { |
50 | - throw new LogicException( 'methods of this class should never be called' ); |
|
50 | + throw new LogicException('methods of this class should never be called'); |
|
51 | 51 | } |
52 | 52 | |
53 | - public function matchesRegularExpression( string $text, string $regex ): bool { |
|
54 | - throw new LogicException( 'methods of this class should never be called' ); |
|
53 | + public function matchesRegularExpression(string $text, string $regex): bool { |
|
54 | + throw new LogicException('methods of this class should never be called'); |
|
55 | 55 | } |
56 | 56 | |
57 | - public function runQuery( string $query, string $endpoint, bool $needsPrefixes = true ): CachedQueryResults { |
|
58 | - throw new LogicException( 'methods of this class should never be called' ); |
|
57 | + public function runQuery(string $query, string $endpoint, bool $needsPrefixes = true): CachedQueryResults { |
|
58 | + throw new LogicException('methods of this class should never be called'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | // @phan-file-suppress PhanPluginNeverReturnMethod |
6 | 6 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @codeCoverageIgnore This method is not supported. |
34 | 34 | */ |
35 | 35 | public function getType(): string { |
36 | - throw new LogicException( 'EntityContextCursor has no full associated context' ); |
|
36 | + throw new LogicException('EntityContextCursor has no full associated context'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | public function getEntityId(): string { |
@@ -44,35 +44,35 @@ discard block |
||
44 | 44 | * @codeCoverageIgnore This method is not supported. |
45 | 45 | */ |
46 | 46 | public function getStatementPropertyId(): string { |
47 | - throw new LogicException( 'EntityContextCursor has no full associated context' ); |
|
47 | + throw new LogicException('EntityContextCursor has no full associated context'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @codeCoverageIgnore This method is not supported. |
52 | 52 | */ |
53 | 53 | public function getStatementGuid(): string { |
54 | - throw new LogicException( 'EntityContextCursor has no full associated context' ); |
|
54 | + throw new LogicException('EntityContextCursor has no full associated context'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @codeCoverageIgnore This method is not supported. |
59 | 59 | */ |
60 | 60 | public function getSnakPropertyId(): string { |
61 | - throw new LogicException( 'EntityContextCursor has no full associated context' ); |
|
61 | + throw new LogicException('EntityContextCursor has no full associated context'); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @codeCoverageIgnore This method is not supported. |
66 | 66 | */ |
67 | 67 | public function getSnakHash(): string { |
68 | - throw new LogicException( 'EntityContextCursor has no full associated context' ); |
|
68 | + throw new LogicException('EntityContextCursor has no full associated context'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | 72 | * @codeCoverageIgnore This method is not supported. |
73 | 73 | */ |
74 | - public function &getMainArray( array &$container ): array { |
|
75 | - throw new LogicException( 'EntityContextCursor cannot store check results' ); |
|
74 | + public function &getMainArray(array &$container): array { |
|
75 | + throw new LogicException('EntityContextCursor cannot store check results'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | * @param ?array $result must be null |
82 | 82 | * @param array[] &$container |
83 | 83 | */ |
84 | - public function storeCheckResultInArray( ?array $result, array &$container ): void { |
|
85 | - if ( $result !== null ) { |
|
86 | - throw new LogicException( 'EntityContextCursor cannot store check results' ); |
|
84 | + public function storeCheckResultInArray(?array $result, array &$container): void { |
|
85 | + if ($result !== null) { |
|
86 | + throw new LogicException('EntityContextCursor cannot store check results'); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | // this ensures that the claims array is present in the $container, |
90 | 90 | // populating it if necessary, even though we ignore the return value |
91 | - $this->getClaimsArray( $container ); |
|
91 | + $this->getClaimsArray($container); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Message; |
6 | 6 | |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | $this->maxListLength = $maxListLength; |
71 | 71 | } |
72 | 72 | |
73 | - public function render( ViolationMessage $violationMessage ): string { |
|
73 | + public function render(ViolationMessage $violationMessage): string { |
|
74 | 74 | $messageKey = $violationMessage->getMessageKey(); |
75 | - $paramsLists = [ [] ]; |
|
76 | - foreach ( $violationMessage->getArguments() as $argument ) { |
|
77 | - $params = $this->renderArgument( $argument ); |
|
75 | + $paramsLists = [[]]; |
|
76 | + foreach ($violationMessage->getArguments() as $argument) { |
|
77 | + $params = $this->renderArgument($argument); |
|
78 | 78 | $paramsLists[] = $params; |
79 | 79 | } |
80 | - $allParams = array_merge( ...$paramsLists ); |
|
81 | - return $this->messageLocalizer->msg( $messageKey, ...$allParams )->escaped(); |
|
80 | + $allParams = array_merge(...$paramsLists); |
|
81 | + return $this->messageLocalizer->msg($messageKey, ...$allParams)->escaped(); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | * @param string|null $role one of the Role::* constants |
87 | 87 | * @return string HTML |
88 | 88 | */ |
89 | - protected function addRole( string $value, ?string $role ): string { |
|
90 | - if ( $role === null ) { |
|
89 | + protected function addRole(string $value, ?string $role): string { |
|
90 | + if ($role === null) { |
|
91 | 91 | return $value; |
92 | 92 | } |
93 | 93 | |
94 | - return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' . |
|
95 | - $value . |
|
94 | + return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'. |
|
95 | + $value. |
|
96 | 96 | '</span>'; |
97 | 97 | } |
98 | 98 | |
@@ -100,15 +100,15 @@ discard block |
||
100 | 100 | * @param string $key message key |
101 | 101 | * @return string HTML |
102 | 102 | */ |
103 | - protected function msgEscaped( string $key ): string { |
|
104 | - return $this->messageLocalizer->msg( $key )->escaped(); |
|
103 | + protected function msgEscaped(string $key): string { |
|
104 | + return $this->messageLocalizer->msg($key)->escaped(); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
108 | 108 | * @param array $argument |
109 | 109 | * @return MessageParam[] params (for Message::params) |
110 | 110 | */ |
111 | - protected function renderArgument( array $argument ): array { |
|
111 | + protected function renderArgument(array $argument): array { |
|
112 | 112 | $methods = [ |
113 | 113 | ViolationMessage::TYPE_ENTITY_ID => 'renderEntityId', |
114 | 114 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'renderEntityIdList', |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | $value = $argument['value']; |
130 | 130 | $role = $argument['role']; |
131 | 131 | |
132 | - if ( array_key_exists( $type, $methods ) ) { |
|
132 | + if (array_key_exists($type, $methods)) { |
|
133 | 133 | $method = $methods[$type]; |
134 | - $params = $this->$method( $value, $role ); |
|
134 | + $params = $this->$method($value, $role); |
|
135 | 135 | } else { |
136 | 136 | throw new InvalidArgumentException( |
137 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
137 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
138 | 138 | ); |
139 | 139 | } |
140 | 140 | |
@@ -148,34 +148,34 @@ discard block |
||
148 | 148 | * and return a single-element array with a raw message param (i. e. [ Message::rawParam( … ) ]) |
149 | 149 | * @return MessageParam[] list of parameters as accepted by Message::params() |
150 | 150 | */ |
151 | - private function renderList( array $list, ?string $role, callable $render ): array { |
|
152 | - if ( $list === [] ) { |
|
151 | + private function renderList(array $list, ?string $role, callable $render): array { |
|
152 | + if ($list === []) { |
|
153 | 153 | return [ |
154 | - Message::numParam( 0 ), |
|
155 | - Message::rawParam( '<ul></ul>' ), |
|
154 | + Message::numParam(0), |
|
155 | + Message::rawParam('<ul></ul>'), |
|
156 | 156 | ]; |
157 | 157 | } |
158 | 158 | |
159 | - $truncated = count( $list ) > $this->maxListLength; |
|
160 | - if ( $truncated ) { |
|
161 | - $list = array_slice( $list, 0, $this->maxListLength ); |
|
159 | + $truncated = count($list) > $this->maxListLength; |
|
160 | + if ($truncated) { |
|
161 | + $list = array_slice($list, 0, $this->maxListLength); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | $renderedParamsLists = array_map( |
165 | 165 | $render, |
166 | 166 | $list, |
167 | - array_fill( 0, count( $list ), $role ) |
|
167 | + array_fill(0, count($list), $role) |
|
168 | 168 | ); |
169 | - $renderedParams = array_column( $renderedParamsLists, 0 ); |
|
170 | - $renderedElements = array_map( static fn ( MessageParam $p ) => $p->getValue(), $renderedParams ); |
|
171 | - if ( $truncated ) { |
|
172 | - $renderedElements[] = $this->msgEscaped( 'ellipsis' ); |
|
169 | + $renderedParams = array_column($renderedParamsLists, 0); |
|
170 | + $renderedElements = array_map(static fn (MessageParam $p) => $p->getValue(), $renderedParams); |
|
171 | + if ($truncated) { |
|
172 | + $renderedElements[] = $this->msgEscaped('ellipsis'); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | return [ |
176 | - Message::numParam( count( $list ) ), |
|
176 | + Message::numParam(count($list)), |
|
177 | 177 | Message::rawParam( |
178 | - '<ul><li>' . implode( '</li><li>', $renderedElements ) . '</li></ul>' |
|
178 | + '<ul><li>'.implode('</li><li>', $renderedElements).'</li></ul>' |
|
179 | 179 | ), |
180 | 180 | ...$renderedParams, |
181 | 181 | ]; |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | * @param string|null $role one of the Role::* constants |
187 | 187 | * @return MessageParam[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
188 | 188 | */ |
189 | - private function renderEntityId( EntityId $entityId, ?string $role ): array { |
|
190 | - return [ Message::rawParam( $this->addRole( |
|
191 | - $this->entityIdFormatter->formatEntityId( $entityId ), |
|
189 | + private function renderEntityId(EntityId $entityId, ?string $role): array { |
|
190 | + return [Message::rawParam($this->addRole( |
|
191 | + $this->entityIdFormatter->formatEntityId($entityId), |
|
192 | 192 | $role |
193 | - ) ) ]; |
|
193 | + ))]; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | * @param string|null $role one of the Role::* constants |
199 | 199 | * @return MessageParam[] list of parameters as accepted by Message::params() |
200 | 200 | */ |
201 | - private function renderEntityIdList( array $entityIdList, ?string $role ): array { |
|
202 | - return $this->renderList( $entityIdList, $role, [ $this, 'renderEntityId' ] ); |
|
201 | + private function renderEntityIdList(array $entityIdList, ?string $role): array { |
|
202 | + return $this->renderList($entityIdList, $role, [$this, 'renderEntityId']); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -207,24 +207,24 @@ discard block |
||
207 | 207 | * @param string|null $role one of the Role::* constants |
208 | 208 | * @return MessageParam[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
209 | 209 | */ |
210 | - private function renderItemIdSnakValue( ItemIdSnakValue $value, ?string $role ): array { |
|
211 | - switch ( true ) { |
|
210 | + private function renderItemIdSnakValue(ItemIdSnakValue $value, ?string $role): array { |
|
211 | + switch (true) { |
|
212 | 212 | case $value->isValue(): |
213 | - return $this->renderEntityId( $value->getItemId(), $role ); |
|
213 | + return $this->renderEntityId($value->getItemId(), $role); |
|
214 | 214 | case $value->isSomeValue(): |
215 | - return [ Message::rawParam( $this->addRole( |
|
216 | - '<span class="wikibase-snakview-variation-somevaluesnak">' . |
|
217 | - $this->msgEscaped( 'wikibase-snakview-snaktypeselector-somevalue' ) . |
|
215 | + return [Message::rawParam($this->addRole( |
|
216 | + '<span class="wikibase-snakview-variation-somevaluesnak">'. |
|
217 | + $this->msgEscaped('wikibase-snakview-snaktypeselector-somevalue'). |
|
218 | 218 | '</span>', |
219 | 219 | $role |
220 | - ) ) ]; |
|
220 | + ))]; |
|
221 | 221 | case $value->isNoValue(): |
222 | - return [ Message::rawParam( $this->addRole( |
|
223 | - '<span class="wikibase-snakview-variation-novaluesnak">' . |
|
224 | - $this->msgEscaped( 'wikibase-snakview-snaktypeselector-novalue' ) . |
|
222 | + return [Message::rawParam($this->addRole( |
|
223 | + '<span class="wikibase-snakview-variation-novaluesnak">'. |
|
224 | + $this->msgEscaped('wikibase-snakview-snaktypeselector-novalue'). |
|
225 | 225 | '</span>', |
226 | 226 | $role |
227 | - ) ) ]; |
|
227 | + ))]; |
|
228 | 228 | default: |
229 | 229 | // @codeCoverageIgnoreStart |
230 | 230 | throw new LogicException( |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | * @param string|null $role one of the Role::* constants |
240 | 240 | * @return MessageParam[] list of parameters as accepted by Message::params() |
241 | 241 | */ |
242 | - private function renderItemIdSnakValueList( array $valueList, ?string $role ): array { |
|
243 | - return $this->renderList( $valueList, $role, [ $this, 'renderItemIdSnakValue' ] ); |
|
242 | + private function renderItemIdSnakValueList(array $valueList, ?string $role): array { |
|
243 | + return $this->renderList($valueList, $role, [$this, 'renderItemIdSnakValue']); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -248,11 +248,11 @@ discard block |
||
248 | 248 | * @param string|null $role one of the Role::* constants |
249 | 249 | * @return MessageParam[] list of parameters as accepted by Message::params() |
250 | 250 | */ |
251 | - private function renderDataValue( DataValue $dataValue, ?string $role ): array { |
|
252 | - return [ Message::rawParam( $this->addRole( |
|
253 | - $this->dataValueFormatter->format( $dataValue ), |
|
251 | + private function renderDataValue(DataValue $dataValue, ?string $role): array { |
|
252 | + return [Message::rawParam($this->addRole( |
|
253 | + $this->dataValueFormatter->format($dataValue), |
|
254 | 254 | $role |
255 | - ) ) ]; |
|
255 | + ))]; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | /** |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * @param string|null $role one of the Role::* constants |
261 | 261 | * @return MessageParam[] list of parameters as accepted by Message::params() |
262 | 262 | */ |
263 | - private function renderDataValueType( string $dataValueType, ?string $role ): array { |
|
263 | + private function renderDataValueType(string $dataValueType, ?string $role): array { |
|
264 | 264 | $messageKeys = [ |
265 | 265 | 'string' => 'datatypes-type-string', |
266 | 266 | 'monolingualtext' => 'datatypes-type-monolingualtext', |
@@ -269,15 +269,15 @@ discard block |
||
269 | 269 | 'wikibase-entityid' => 'wbqc-dataValueType-wikibase-entityid', |
270 | 270 | ]; |
271 | 271 | |
272 | - if ( array_key_exists( $dataValueType, $messageKeys ) ) { |
|
273 | - return [ Message::rawParam( $this->addRole( |
|
274 | - $this->msgEscaped( $messageKeys[$dataValueType] ), |
|
272 | + if (array_key_exists($dataValueType, $messageKeys)) { |
|
273 | + return [Message::rawParam($this->addRole( |
|
274 | + $this->msgEscaped($messageKeys[$dataValueType]), |
|
275 | 275 | $role |
276 | - ) ) ]; |
|
276 | + ))]; |
|
277 | 277 | } else { |
278 | 278 | // @codeCoverageIgnoreStart |
279 | 279 | throw new LogicException( |
280 | - 'Unknown data value type ' . $dataValueType |
|
280 | + 'Unknown data value type '.$dataValueType |
|
281 | 281 | ); |
282 | 282 | // @codeCoverageIgnoreEnd |
283 | 283 | } |
@@ -288,11 +288,11 @@ discard block |
||
288 | 288 | * @param string|null $role one of the Role::* constants |
289 | 289 | * @return MessageParam[] list of parameters as accepted by Message::params() |
290 | 290 | */ |
291 | - private function renderInlineCode( string $code, ?string $role ): array { |
|
292 | - return [ Message::rawParam( $this->addRole( |
|
293 | - '<code>' . htmlspecialchars( $code ) . '</code>', |
|
291 | + private function renderInlineCode(string $code, ?string $role): array { |
|
292 | + return [Message::rawParam($this->addRole( |
|
293 | + '<code>'.htmlspecialchars($code).'</code>', |
|
294 | 294 | $role |
295 | - ) ) ]; |
|
295 | + ))]; |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | * @param string|null $role one of the Role::* constants |
301 | 301 | * @return MessageParam[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
302 | 302 | */ |
303 | - private function renderConstraintScope( string $scope, ?string $role ): array { |
|
304 | - switch ( $scope ) { |
|
303 | + private function renderConstraintScope(string $scope, ?string $role): array { |
|
304 | + switch ($scope) { |
|
305 | 305 | case Context::TYPE_STATEMENT: |
306 | 306 | $itemId = $this->config->get( |
307 | 307 | 'WBQualityConstraintsConstraintCheckedOnMainValueId' |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | // callers should never let this happen, but if it does happen, |
322 | 322 | // showing “unknown value” seems reasonable |
323 | 323 | // @codeCoverageIgnoreStart |
324 | - return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
324 | + return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
325 | 325 | // @codeCoverageIgnoreEnd |
326 | 326 | } |
327 | - return $this->renderEntityId( new ItemId( $itemId ), $role ); |
|
327 | + return $this->renderEntityId(new ItemId($itemId), $role); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | * @param string|null $role one of the Role::* constants |
333 | 333 | * @return MessageParam[] list of parameters as accepted by Message::params() |
334 | 334 | */ |
335 | - private function renderConstraintScopeList( array $scopeList, ?string $role ): array { |
|
336 | - return $this->renderList( $scopeList, $role, [ $this, 'renderConstraintScope' ] ); |
|
335 | + private function renderConstraintScopeList(array $scopeList, ?string $role): array { |
|
336 | + return $this->renderList($scopeList, $role, [$this, 'renderConstraintScope']); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
@@ -341,25 +341,25 @@ discard block |
||
341 | 341 | * @param string|null $role one of the Role::* constants |
342 | 342 | * @return MessageParam[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
343 | 343 | */ |
344 | - private function renderPropertyScope( string $scope, ?string $role ): array { |
|
345 | - switch ( $scope ) { |
|
344 | + private function renderPropertyScope(string $scope, ?string $role): array { |
|
345 | + switch ($scope) { |
|
346 | 346 | case Context::TYPE_STATEMENT: |
347 | - $itemId = $this->config->get( 'WBQualityConstraintsAsMainValueId' ); |
|
347 | + $itemId = $this->config->get('WBQualityConstraintsAsMainValueId'); |
|
348 | 348 | break; |
349 | 349 | case Context::TYPE_QUALIFIER: |
350 | - $itemId = $this->config->get( 'WBQualityConstraintsAsQualifiersId' ); |
|
350 | + $itemId = $this->config->get('WBQualityConstraintsAsQualifiersId'); |
|
351 | 351 | break; |
352 | 352 | case Context::TYPE_REFERENCE: |
353 | - $itemId = $this->config->get( 'WBQualityConstraintsAsReferencesId' ); |
|
353 | + $itemId = $this->config->get('WBQualityConstraintsAsReferencesId'); |
|
354 | 354 | break; |
355 | 355 | default: |
356 | 356 | // callers should never let this happen, but if it does happen, |
357 | 357 | // showing “unknown value” seems reasonable |
358 | 358 | // @codeCoverageIgnoreStart |
359 | - return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
359 | + return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
360 | 360 | // @codeCoverageIgnoreEnd |
361 | 361 | } |
362 | - return $this->renderEntityId( new ItemId( $itemId ), $role ); |
|
362 | + return $this->renderEntityId(new ItemId($itemId), $role); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * @param string|null $role one of the Role::* constants |
368 | 368 | * @return MessageParam[] list of parameters as accepted by Message::params() |
369 | 369 | */ |
370 | - private function renderPropertyScopeList( array $scopeList, ?string $role ): array { |
|
371 | - return $this->renderList( $scopeList, $role, [ $this, 'renderPropertyScope' ] ); |
|
370 | + private function renderPropertyScopeList(array $scopeList, ?string $role): array { |
|
371 | + return $this->renderList($scopeList, $role, [$this, 'renderPropertyScope']); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -377,14 +377,14 @@ discard block |
||
377 | 377 | * @return MessageParam[] list of parameters as accepted by Message::params() |
378 | 378 | * @suppress PhanUnusedPrivateMethodParameter |
379 | 379 | */ |
380 | - private function renderLanguage( string $languageCode, ?string $role ): array { |
|
380 | + private function renderLanguage(string $languageCode, ?string $role): array { |
|
381 | 381 | return [ |
382 | 382 | // ::renderList (through ::renderLanguageList) requires 'raw' parameter |
383 | 383 | // so we effectively build Message::plaintextParam here |
384 | - Message::rawParam( htmlspecialchars( |
|
385 | - $this->languageNameUtils->getLanguageName( $languageCode, $this->userLanguageCode ) |
|
386 | - ) ), |
|
387 | - Message::plaintextParam( $languageCode ), |
|
384 | + Message::rawParam(htmlspecialchars( |
|
385 | + $this->languageNameUtils->getLanguageName($languageCode, $this->userLanguageCode) |
|
386 | + )), |
|
387 | + Message::plaintextParam($languageCode), |
|
388 | 388 | ]; |
389 | 389 | } |
390 | 390 | |
@@ -393,8 +393,8 @@ discard block |
||
393 | 393 | * @param string|null $role one of the Role::* constants |
394 | 394 | * @return MessageParam[] list of parameters as accepted by Message::params() |
395 | 395 | */ |
396 | - private function renderLanguageList( array $languageCodes, ?string $role ): array { |
|
397 | - return $this->renderList( $languageCodes, $role, [ $this, 'renderLanguage' ] ); |
|
396 | + private function renderLanguageList(array $languageCodes, ?string $role): array { |
|
397 | + return $this->renderList($languageCodes, $role, [$this, 'renderLanguage']); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\Api; |
6 | 6 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $delegatingConstraintChecker, |
66 | 66 | $violationMessageRendererFactory, |
67 | 67 | $statementGuidParser, |
68 | - $statsFactory->withComponent( 'WikibaseQualityConstraints' ) |
|
68 | + $statsFactory->withComponent('WikibaseQualityConstraints') |
|
69 | 69 | ); |
70 | 70 | } |
71 | 71 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | StatementGuidParser $statementGuidParser, |
80 | 80 | StatsFactory $statsFactory |
81 | 81 | ) { |
82 | - parent::__construct( $main, $name ); |
|
82 | + parent::__construct($main, $name); |
|
83 | 83 | |
84 | - $this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
84 | + $this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this); |
|
85 | 85 | $this->languageFallbackChainFactory = $languageFallbackChainFactory; |
86 | 86 | $this->delegatingConstraintChecker = $delegatingConstraintChecker; |
87 | 87 | $this->violationMessageRendererFactory = $violationMessageRendererFactory; |
@@ -90,45 +90,45 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | public function execute() { |
93 | - $this->statsFactory->getCounter( 'check_constraint_parameters_execute_total' ) |
|
93 | + $this->statsFactory->getCounter('check_constraint_parameters_execute_total') |
|
94 | 94 | ->increment(); |
95 | 95 | |
96 | 96 | $params = $this->extractRequestParams(); |
97 | 97 | $result = $this->getResult(); |
98 | 98 | |
99 | - $propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] ); |
|
100 | - $constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] ); |
|
99 | + $propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]); |
|
100 | + $constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]); |
|
101 | 101 | |
102 | - $this->checkPropertyIds( $propertyIds, $result ); |
|
103 | - $this->checkConstraintIds( $constraintIds, $result ); |
|
102 | + $this->checkPropertyIds($propertyIds, $result); |
|
103 | + $this->checkConstraintIds($constraintIds, $result); |
|
104 | 104 | |
105 | - $result->addValue( null, 'success', 1 ); |
|
105 | + $result->addValue(null, 'success', 1); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * @param array|null $propertyIdSerializations |
110 | 110 | * @return NumericPropertyId[] |
111 | 111 | */ |
112 | - private function parsePropertyIds( ?array $propertyIdSerializations ): array { |
|
113 | - if ( $propertyIdSerializations === null ) { |
|
112 | + private function parsePropertyIds(?array $propertyIdSerializations): array { |
|
113 | + if ($propertyIdSerializations === null) { |
|
114 | 114 | return []; |
115 | - } elseif ( $propertyIdSerializations === [] ) { |
|
115 | + } elseif ($propertyIdSerializations === []) { |
|
116 | 116 | $this->apiErrorReporter->dieError( |
117 | - 'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.', |
|
117 | + 'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.', |
|
118 | 118 | 'no-data' |
119 | 119 | ); |
120 | 120 | } |
121 | 121 | |
122 | 122 | return array_map( |
123 | - function ( $propertyIdSerialization ) { |
|
123 | + function($propertyIdSerialization) { |
|
124 | 124 | try { |
125 | - return new NumericPropertyId( $propertyIdSerialization ); |
|
126 | - } catch ( InvalidArgumentException ) { |
|
125 | + return new NumericPropertyId($propertyIdSerialization); |
|
126 | + } catch (InvalidArgumentException) { |
|
127 | 127 | $this->apiErrorReporter->dieError( |
128 | 128 | "Invalid id: $propertyIdSerialization", |
129 | 129 | 'invalid-property-id', |
130 | 130 | 0, // default argument |
131 | - [ self::PARAM_PROPERTY_ID => $propertyIdSerialization ] |
|
131 | + [self::PARAM_PROPERTY_ID => $propertyIdSerialization] |
|
132 | 132 | ); |
133 | 133 | } |
134 | 134 | }, |
@@ -140,35 +140,35 @@ discard block |
||
140 | 140 | * @param array|null $constraintIds |
141 | 141 | * @return string[] |
142 | 142 | */ |
143 | - private function parseConstraintIds( ?array $constraintIds ): array { |
|
144 | - if ( $constraintIds === null ) { |
|
143 | + private function parseConstraintIds(?array $constraintIds): array { |
|
144 | + if ($constraintIds === null) { |
|
145 | 145 | return []; |
146 | - } elseif ( $constraintIds === [] ) { |
|
146 | + } elseif ($constraintIds === []) { |
|
147 | 147 | $this->apiErrorReporter->dieError( |
148 | - 'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.', |
|
148 | + 'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.', |
|
149 | 149 | 'no-data' |
150 | 150 | ); |
151 | 151 | } |
152 | 152 | |
153 | 153 | return array_map( |
154 | - function ( $constraintId ) { |
|
154 | + function($constraintId) { |
|
155 | 155 | try { |
156 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
157 | - if ( !$propertyId instanceof NumericPropertyId ) { |
|
156 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
157 | + if (!$propertyId instanceof NumericPropertyId) { |
|
158 | 158 | $this->apiErrorReporter->dieError( |
159 | 159 | "Invalid property ID: {$propertyId->getSerialization()}", |
160 | 160 | 'invalid-property-id', |
161 | 161 | 0, // default argument |
162 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
162 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
163 | 163 | ); |
164 | 164 | } |
165 | 165 | return $constraintId; |
166 | - } catch ( StatementGuidParsingException ) { |
|
166 | + } catch (StatementGuidParsingException) { |
|
167 | 167 | $this->apiErrorReporter->dieError( |
168 | 168 | "Invalid statement GUID: $constraintId", |
169 | 169 | 'invalid-guid', |
170 | 170 | 0, // default argument |
171 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
171 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
172 | 172 | ); |
173 | 173 | } |
174 | 174 | }, |
@@ -180,12 +180,12 @@ discard block |
||
180 | 180 | * @param NumericPropertyId[] $propertyIds |
181 | 181 | * @param ApiResult $result |
182 | 182 | */ |
183 | - private function checkPropertyIds( array $propertyIds, ApiResult $result ): void { |
|
184 | - foreach ( $propertyIds as $propertyId ) { |
|
185 | - $result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' ); |
|
183 | + private function checkPropertyIds(array $propertyIds, ApiResult $result): void { |
|
184 | + foreach ($propertyIds as $propertyId) { |
|
185 | + $result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc'); |
|
186 | 186 | $allConstraintExceptions = $this->delegatingConstraintChecker |
187 | - ->checkConstraintParametersOnPropertyId( $propertyId ); |
|
188 | - foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) { |
|
187 | + ->checkConstraintParametersOnPropertyId($propertyId); |
|
188 | + foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) { |
|
189 | 189 | $this->addConstraintParameterExceptionsToResult( |
190 | 190 | $constraintId, |
191 | 191 | $constraintParameterExceptions, |
@@ -199,15 +199,15 @@ discard block |
||
199 | 199 | * @param string[] $constraintIds |
200 | 200 | * @param ApiResult $result |
201 | 201 | */ |
202 | - private function checkConstraintIds( array $constraintIds, ApiResult $result ): void { |
|
203 | - foreach ( $constraintIds as $constraintId ) { |
|
204 | - if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) { |
|
202 | + private function checkConstraintIds(array $constraintIds, ApiResult $result): void { |
|
203 | + foreach ($constraintIds as $constraintId) { |
|
204 | + if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) { |
|
205 | 205 | // already checked as part of checkPropertyIds() |
206 | 206 | continue; |
207 | 207 | } |
208 | 208 | $constraintParameterExceptions = $this->delegatingConstraintChecker |
209 | - ->checkConstraintParametersOnConstraintId( $constraintId ); |
|
210 | - $this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result ); |
|
209 | + ->checkConstraintParametersOnConstraintId($constraintId); |
|
210 | + $this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | |
@@ -215,18 +215,18 @@ discard block |
||
215 | 215 | * @param NumericPropertyId $propertyId |
216 | 216 | * @return string[] |
217 | 217 | */ |
218 | - private function getResultPathForPropertyId( NumericPropertyId $propertyId ): array { |
|
219 | - return [ $this->getModuleName(), $propertyId->getSerialization() ]; |
|
218 | + private function getResultPathForPropertyId(NumericPropertyId $propertyId): array { |
|
219 | + return [$this->getModuleName(), $propertyId->getSerialization()]; |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
223 | 223 | * @param string $constraintId |
224 | 224 | * @return string[] |
225 | 225 | */ |
226 | - private function getResultPathForConstraintId( string $constraintId ): array { |
|
227 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
226 | + private function getResultPathForConstraintId(string $constraintId): array { |
|
227 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
228 | 228 | '@phan-var NumericPropertyId $propertyId'; |
229 | - return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] ); |
|
229 | + return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | ?array $constraintParameterExceptions, |
242 | 242 | ApiResult $result |
243 | 243 | ): void { |
244 | - $path = $this->getResultPathForConstraintId( $constraintId ); |
|
245 | - if ( $constraintParameterExceptions === null ) { |
|
244 | + $path = $this->getResultPathForConstraintId($constraintId); |
|
245 | + if ($constraintParameterExceptions === null) { |
|
246 | 246 | $result->addValue( |
247 | 247 | $path, |
248 | 248 | self::KEY_STATUS, |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | $violationMessageRenderer = $this->violationMessageRendererFactory |
260 | 260 | ->getViolationMessageRenderer( |
261 | 261 | $language, |
262 | - $this->languageFallbackChainFactory->newFromLanguage( $language ), |
|
262 | + $this->languageFallbackChainFactory->newFromLanguage($language), |
|
263 | 263 | $this |
264 | 264 | ); |
265 | 265 | $problems = []; |
266 | - foreach ( $constraintParameterExceptions as $constraintParameterException ) { |
|
266 | + foreach ($constraintParameterExceptions as $constraintParameterException) { |
|
267 | 267 | $problems[] = [ |
268 | 268 | self::KEY_MESSAGE_HTML => $violationMessageRenderer->render( |
269 | 269 | $constraintParameterException->getViolationMessage() ), |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | return [ |
303 | 303 | 'action=wbcheckconstraintparameters&propertyid=P247' |
304 | 304 | => 'apihelp-wbcheckconstraintparameters-example-propertyid-1', |
305 | - 'action=wbcheckconstraintparameters&' . |
|
306 | - 'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|' . |
|
305 | + 'action=wbcheckconstraintparameters&'. |
|
306 | + 'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|'. |
|
307 | 307 | 'P225$cdc71e4a-47a0-12c5-dfb3-3f6fc0b6613f' |
308 | 308 | => 'apihelp-wbcheckconstraintparameters-example-constraintid-2', |
309 | 309 | ]; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\Specials; |
6 | 6 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | Config $config, |
92 | 92 | StatsFactory $statsFactory |
93 | 93 | ) { |
94 | - parent::__construct( 'ConstraintReport' ); |
|
94 | + parent::__construct('ConstraintReport'); |
|
95 | 95 | |
96 | 96 | $this->entityLookup = $entityLookup; |
97 | 97 | $this->entityTitleLookup = $entityTitleLookup; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | $this->violationMessageRenderer = $violationMessageRendererFactory->getViolationMessageRenderer( |
113 | 113 | $language, |
114 | - $languageFallbackChainFactory->newFromLanguage( $language ), |
|
114 | + $languageFallbackChainFactory->newFromLanguage($language), |
|
115 | 115 | $this->getContext() |
116 | 116 | ); |
117 | 117 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @inheritDoc |
146 | 146 | */ |
147 | 147 | public function getDescription() { |
148 | - return $this->msg( 'wbqc-constraintreport' ); |
|
148 | + return $this->msg('wbqc-constraintreport'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -157,71 +157,71 @@ discard block |
||
157 | 157 | * @throws EntityIdParsingException |
158 | 158 | * @throws UnexpectedValueException |
159 | 159 | */ |
160 | - public function execute( $subPage ) { |
|
160 | + public function execute($subPage) { |
|
161 | 161 | $out = $this->getOutput(); |
162 | 162 | |
163 | - $postRequest = $this->getContext()->getRequest()->getVal( 'entityid' ); |
|
164 | - if ( $postRequest ) { |
|
163 | + $postRequest = $this->getContext()->getRequest()->getVal('entityid'); |
|
164 | + if ($postRequest) { |
|
165 | 165 | try { |
166 | - $entityId = $this->entityIdParser->parse( $postRequest ); |
|
167 | - $out->redirect( $this->getPageTitle( $entityId->getSerialization() )->getLocalURL() ); |
|
166 | + $entityId = $this->entityIdParser->parse($postRequest); |
|
167 | + $out->redirect($this->getPageTitle($entityId->getSerialization())->getLocalURL()); |
|
168 | 168 | return; |
169 | - } catch ( EntityIdParsingException ) { |
|
169 | + } catch (EntityIdParsingException) { |
|
170 | 170 | // fall through, error is shown later |
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | 174 | $out->enableOOUI(); |
175 | - $out->addModules( $this->getModules() ); |
|
175 | + $out->addModules($this->getModules()); |
|
176 | 176 | |
177 | 177 | $this->setHeaders(); |
178 | 178 | |
179 | - $out->addHTML( $this->getExplanationText() ); |
|
179 | + $out->addHTML($this->getExplanationText()); |
|
180 | 180 | $this->buildEntityIdForm(); |
181 | 181 | |
182 | - if ( $postRequest ) { |
|
182 | + if ($postRequest) { |
|
183 | 183 | // must be an invalid entity ID (otherwise we would have redirected and returned above) |
184 | 184 | $out->addHTML( |
185 | - $this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true ) |
|
185 | + $this->buildNotice('wbqc-constraintreport-invalid-entity-id', true) |
|
186 | 186 | ); |
187 | 187 | return; |
188 | 188 | } |
189 | 189 | |
190 | - if ( !$subPage ) { |
|
190 | + if (!$subPage) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
194 | 194 | try { |
195 | - $entityId = $this->entityIdParser->parse( $subPage ); |
|
196 | - } catch ( EntityIdParsingException ) { |
|
195 | + $entityId = $this->entityIdParser->parse($subPage); |
|
196 | + } catch (EntityIdParsingException) { |
|
197 | 197 | $out->addHTML( |
198 | - $this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true ) |
|
198 | + $this->buildNotice('wbqc-constraintreport-invalid-entity-id', true) |
|
199 | 199 | ); |
200 | 200 | return; |
201 | 201 | } |
202 | 202 | |
203 | - if ( !$this->entityLookup->hasEntity( $entityId ) ) { |
|
203 | + if (!$this->entityLookup->hasEntity($entityId)) { |
|
204 | 204 | $out->addHTML( |
205 | - $this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true ) |
|
205 | + $this->buildNotice('wbqc-constraintreport-not-existent-entity', true) |
|
206 | 206 | ); |
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
210 | - $this->statsFactory->getCounter( 'special_constraint_report_execute_check_total' ) |
|
210 | + $this->statsFactory->getCounter('special_constraint_report_execute_check_total') |
|
211 | 211 | ->increment(); |
212 | - $results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId ); |
|
212 | + $results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId); |
|
213 | 213 | |
214 | - if ( !$results ) { |
|
215 | - $out->addHTML( $this->buildResultHeader( $entityId ) . |
|
216 | - $this->buildNotice( 'wbqc-constraintreport-empty-result' ) |
|
214 | + if (!$results) { |
|
215 | + $out->addHTML($this->buildResultHeader($entityId). |
|
216 | + $this->buildNotice('wbqc-constraintreport-empty-result') |
|
217 | 217 | ); |
218 | 218 | return; |
219 | 219 | } |
220 | 220 | |
221 | 221 | $out->addHTML( |
222 | - $this->buildResultHeader( $entityId ) |
|
223 | - . $this->buildSummary( $results ) |
|
224 | - . $this->buildResultTable( $entityId, $results ) |
|
222 | + $this->buildResultHeader($entityId) |
|
223 | + . $this->buildSummary($results) |
|
224 | + . $this->buildResultTable($entityId, $results) |
|
225 | 225 | ); |
226 | 226 | } |
227 | 227 | |
@@ -236,15 +236,15 @@ discard block |
||
236 | 236 | 'name' => 'entityid', |
237 | 237 | 'label-message' => 'wbqc-constraintreport-form-entityid-label', |
238 | 238 | 'cssclass' => 'wbqc-constraintreport-form-entity-id', |
239 | - 'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->text(), |
|
239 | + 'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->text(), |
|
240 | 240 | 'required' => true, |
241 | 241 | ], |
242 | 242 | ]; |
243 | - $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), |
|
243 | + $htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), |
|
244 | 244 | 'wbqc-constraintreport-form' |
245 | 245 | ); |
246 | - $htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->text() ); |
|
247 | - $htmlForm->setSubmitCallback( static fn () => false ); |
|
246 | + $htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->text()); |
|
247 | + $htmlForm->setSubmitCallback(static fn () => false); |
|
248 | 248 | $htmlForm->show(); |
249 | 249 | } |
250 | 250 | |
@@ -258,16 +258,16 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return string HTML |
260 | 260 | */ |
261 | - private function buildNotice( string $messageKey, bool $error = false ): string { |
|
262 | - $cssClasses = [ 'wbqc-constraintreport-notice' ]; |
|
263 | - if ( $error ) { |
|
261 | + private function buildNotice(string $messageKey, bool $error = false): string { |
|
262 | + $cssClasses = ['wbqc-constraintreport-notice']; |
|
263 | + if ($error) { |
|
264 | 264 | $cssClasses[] = ' wbqc-constraintreport-notice-error'; |
265 | 265 | } |
266 | 266 | |
267 | 267 | return Html::element( |
268 | 268 | 'p', |
269 | - [ 'class' => $cssClasses ], |
|
270 | - $this->msg( $messageKey )->text() |
|
269 | + ['class' => $cssClasses], |
|
270 | + $this->msg($messageKey)->text() |
|
271 | 271 | ); |
272 | 272 | } |
273 | 273 | |
@@ -277,16 +277,16 @@ discard block |
||
277 | 277 | private function getExplanationText(): string { |
278 | 278 | return Html::rawElement( |
279 | 279 | 'div', |
280 | - [ 'class' => 'wbqc-explanation' ], |
|
280 | + ['class' => 'wbqc-explanation'], |
|
281 | 281 | Html::element( |
282 | 282 | 'p', |
283 | 283 | [], |
284 | - $this->msg( 'wbqc-constraintreport-explanation-part-one' )->text() |
|
284 | + $this->msg('wbqc-constraintreport-explanation-part-one')->text() |
|
285 | 285 | ) |
286 | 286 | . Html::element( |
287 | 287 | 'p', |
288 | 288 | [], |
289 | - $this->msg( 'wbqc-constraintreport-explanation-part-two' )->text() |
|
289 | + $this->msg('wbqc-constraintreport-explanation-part-two')->text() |
|
290 | 290 | ) |
291 | 291 | ); |
292 | 292 | } |
@@ -297,31 +297,31 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return string HTML |
299 | 299 | */ |
300 | - private function buildResultTable( EntityId $entityId, array $results ): string { |
|
300 | + private function buildResultTable(EntityId $entityId, array $results): string { |
|
301 | 301 | // Set table headers |
302 | 302 | $table = new HtmlTableBuilder( |
303 | 303 | [ |
304 | 304 | new HtmlTableHeaderBuilder( |
305 | - $this->msg( 'wbqc-constraintreport-result-table-header-status' )->text(), |
|
305 | + $this->msg('wbqc-constraintreport-result-table-header-status')->text(), |
|
306 | 306 | true |
307 | 307 | ), |
308 | 308 | new HtmlTableHeaderBuilder( |
309 | - $this->msg( 'wbqc-constraintreport-result-table-header-property' )->text(), |
|
309 | + $this->msg('wbqc-constraintreport-result-table-header-property')->text(), |
|
310 | 310 | true |
311 | 311 | ), |
312 | 312 | new HtmlTableHeaderBuilder( |
313 | - $this->msg( 'wbqc-constraintreport-result-table-header-message' )->text(), |
|
313 | + $this->msg('wbqc-constraintreport-result-table-header-message')->text(), |
|
314 | 314 | true |
315 | 315 | ), |
316 | 316 | new HtmlTableHeaderBuilder( |
317 | - $this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->text(), |
|
317 | + $this->msg('wbqc-constraintreport-result-table-header-constraint')->text(), |
|
318 | 318 | true |
319 | 319 | ), |
320 | 320 | ] |
321 | 321 | ); |
322 | 322 | |
323 | - foreach ( $results as $result ) { |
|
324 | - $this->appendToResultTable( $table, $entityId, $result ); |
|
323 | + foreach ($results as $result) { |
|
324 | + $this->appendToResultTable($table, $entityId, $result); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | return $table->toHtml(); |
@@ -333,35 +333,35 @@ discard block |
||
333 | 333 | CheckResult $result |
334 | 334 | ): void { |
335 | 335 | $message = $result->getMessage(); |
336 | - if ( !$message ) { |
|
336 | + if (!$message) { |
|
337 | 337 | // no row for this result |
338 | 338 | return; |
339 | 339 | } |
340 | 340 | |
341 | 341 | // Status column |
342 | - $statusColumn = $this->formatStatus( $result->getStatus() ); |
|
342 | + $statusColumn = $this->formatStatus($result->getStatus()); |
|
343 | 343 | |
344 | 344 | // Property column |
345 | - $propertyId = new NumericPropertyId( $result->getContextCursor()->getSnakPropertyId() ); |
|
345 | + $propertyId = new NumericPropertyId($result->getContextCursor()->getSnakPropertyId()); |
|
346 | 346 | $propertyColumn = $this->getClaimLink( |
347 | 347 | $entityId, |
348 | 348 | $propertyId, |
349 | - $this->entityIdLabelFormatter->formatEntityId( $propertyId ) |
|
349 | + $this->entityIdLabelFormatter->formatEntityId($propertyId) |
|
350 | 350 | ); |
351 | 351 | |
352 | 352 | // Message column |
353 | - $messageColumn = $this->violationMessageRenderer->render( $message ); |
|
353 | + $messageColumn = $this->violationMessageRenderer->render($message); |
|
354 | 354 | |
355 | 355 | // Constraint column |
356 | 356 | $constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId(); |
357 | 357 | try { |
358 | - $constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) ); |
|
359 | - } catch ( InvalidArgumentException ) { |
|
360 | - $constraintTypeLabel = htmlspecialchars( $constraintTypeItemId ); |
|
358 | + $constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId)); |
|
359 | + } catch (InvalidArgumentException) { |
|
360 | + $constraintTypeLabel = htmlspecialchars($constraintTypeItemId); |
|
361 | 361 | } |
362 | 362 | $constraintColumn = $this->getClaimLink( |
363 | 363 | $propertyId, |
364 | - new NumericPropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ), |
|
364 | + new NumericPropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')), |
|
365 | 365 | $constraintTypeLabel |
366 | 366 | ); |
367 | 367 | |
@@ -369,16 +369,16 @@ discard block |
||
369 | 369 | $table->appendRow( |
370 | 370 | [ |
371 | 371 | new HtmlTableCellBuilder( |
372 | - new HtmlArmor( $statusColumn ) |
|
372 | + new HtmlArmor($statusColumn) |
|
373 | 373 | ), |
374 | 374 | new HtmlTableCellBuilder( |
375 | - new HtmlArmor( $propertyColumn ) |
|
375 | + new HtmlArmor($propertyColumn) |
|
376 | 376 | ), |
377 | 377 | new HtmlTableCellBuilder( |
378 | - new HtmlArmor( $messageColumn ) |
|
378 | + new HtmlArmor($messageColumn) |
|
379 | 379 | ), |
380 | 380 | new HtmlTableCellBuilder( |
381 | - new HtmlArmor( $constraintColumn ) |
|
381 | + new HtmlArmor($constraintColumn) |
|
382 | 382 | ), |
383 | 383 | ] |
384 | 384 | ); |
@@ -391,15 +391,15 @@ discard block |
||
391 | 391 | * |
392 | 392 | * @return string HTML |
393 | 393 | */ |
394 | - protected function buildResultHeader( EntityId $entityId ): string { |
|
394 | + protected function buildResultHeader(EntityId $entityId): string { |
|
395 | 395 | return Html::rawElement( |
396 | 396 | 'h3', |
397 | 397 | [], |
398 | - $this->msg( 'wbqc-constraintreport-result-headline' )->escaped() . |
|
399 | - $this->msg( 'word-separator' )->escaped() . |
|
400 | - $this->entityIdLinkFormatter->formatEntityId( $entityId ) . |
|
401 | - $this->msg( 'word-separator' )->escaped() . |
|
402 | - $this->msg( 'parentheses', $entityId->getSerialization() )->escaped() |
|
398 | + $this->msg('wbqc-constraintreport-result-headline')->escaped(). |
|
399 | + $this->msg('word-separator')->escaped(). |
|
400 | + $this->entityIdLinkFormatter->formatEntityId($entityId). |
|
401 | + $this->msg('word-separator')->escaped(). |
|
402 | + $this->msg('parentheses', $entityId->getSerialization())->escaped() |
|
403 | 403 | ); |
404 | 404 | } |
405 | 405 | |
@@ -410,23 +410,23 @@ discard block |
||
410 | 410 | * |
411 | 411 | * @return string HTML |
412 | 412 | */ |
413 | - protected function buildSummary( array $results ): string { |
|
413 | + protected function buildSummary(array $results): string { |
|
414 | 414 | $statuses = []; |
415 | - foreach ( $results as $result ) { |
|
416 | - $status = strtolower( $result->getStatus() ); |
|
415 | + foreach ($results as $result) { |
|
416 | + $status = strtolower($result->getStatus()); |
|
417 | 417 | $statuses[$status] ??= 0; |
418 | 418 | $statuses[$status]++; |
419 | 419 | } |
420 | 420 | |
421 | 421 | $statusElements = []; |
422 | - foreach ( $statuses as $status => $count ) { |
|
423 | - $statusElements[] = $this->formatStatus( $status ) . |
|
424 | - $this->msg( 'colon-separator' )->escaped() . |
|
425 | - htmlspecialchars( $this->getLanguage()->formatNum( $count ) ); |
|
422 | + foreach ($statuses as $status => $count) { |
|
423 | + $statusElements[] = $this->formatStatus($status). |
|
424 | + $this->msg('colon-separator')->escaped(). |
|
425 | + htmlspecialchars($this->getLanguage()->formatNum($count)); |
|
426 | 426 | } |
427 | 427 | |
428 | - return Html::rawElement( 'p', [], |
|
429 | - implode( $this->msg( 'comma-separator' )->escaped(), $statusElements ) |
|
428 | + return Html::rawElement('p', [], |
|
429 | + implode($this->msg('comma-separator')->escaped(), $statusElements) |
|
430 | 430 | ); |
431 | 431 | } |
432 | 432 | |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | * |
440 | 440 | * @return string HTML |
441 | 441 | */ |
442 | - private function formatStatus( string $status ): string { |
|
443 | - $messageName = "wbqc-constraintreport-status-" . strtolower( $status ); |
|
442 | + private function formatStatus(string $status): string { |
|
443 | + $messageName = "wbqc-constraintreport-status-".strtolower($status); |
|
444 | 444 | $statusIcons = [ |
445 | 445 | CheckResult::STATUS_SUGGESTION => [ |
446 | 446 | 'icon' => 'suggestion-constraint-violation', |
@@ -457,21 +457,21 @@ discard block |
||
457 | 457 | ], |
458 | 458 | ]; |
459 | 459 | |
460 | - if ( array_key_exists( $status, $statusIcons ) ) { |
|
461 | - $iconHtml = new IconWidget( $statusIcons[$status] ) . |
|
462 | - $this->msg( 'word-separator' )->escaped(); |
|
460 | + if (array_key_exists($status, $statusIcons)) { |
|
461 | + $iconHtml = new IconWidget($statusIcons[$status]). |
|
462 | + $this->msg('word-separator')->escaped(); |
|
463 | 463 | } else { |
464 | 464 | $iconHtml = ''; |
465 | 465 | } |
466 | 466 | |
467 | - $labelWidget = new LabelWidget( [ 'label' => $this->msg( $messageName )->text() ] ); |
|
467 | + $labelWidget = new LabelWidget(['label' => $this->msg($messageName)->text()]); |
|
468 | 468 | |
469 | 469 | return Html::rawElement( |
470 | 470 | 'span', |
471 | 471 | [ |
472 | - 'class' => 'wbqc-status wbqc-status-' . $status, |
|
472 | + 'class' => 'wbqc-status wbqc-status-'.$status, |
|
473 | 473 | ], |
474 | - $iconHtml . $labelWidget |
|
474 | + $iconHtml.$labelWidget |
|
475 | 475 | ); |
476 | 476 | } |
477 | 477 | |
@@ -489,10 +489,10 @@ discard block |
||
489 | 489 | NumericPropertyId $propertyId, |
490 | 490 | string $text |
491 | 491 | ): string { |
492 | - $title = clone $this->entityTitleLookup->getTitleForId( $entityId ); |
|
493 | - $title->setFragment( $propertyId->getSerialization() ); |
|
492 | + $title = clone $this->entityTitleLookup->getTitleForId($entityId); |
|
493 | + $title->setFragment($propertyId->getSerialization()); |
|
494 | 494 | |
495 | - return Html::rawElement( 'a', |
|
495 | + return Html::rawElement('a', |
|
496 | 496 | [ |
497 | 497 | 'href' => $title->getLinkURL(), |
498 | 498 | 'target' => '_blank', |
@@ -81,26 +81,26 @@ discard block |
||
81 | 81 | * @return bool |
82 | 82 | * @throws OverflowException if $entitiesChecked exceeds the configured limit |
83 | 83 | */ |
84 | - private function isSubclassOf( EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0 ) { |
|
85 | - $maxEntities = $this->config->get( 'WBQualityConstraintsTypeCheckMaxEntities' ); |
|
84 | + private function isSubclassOf(EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0) { |
|
85 | + $maxEntities = $this->config->get('WBQualityConstraintsTypeCheckMaxEntities'); |
|
86 | 86 | if ( ++$entitiesChecked > $maxEntities ) { |
87 | - throw new OverflowException( 'Too many entities to check' ); |
|
87 | + throw new OverflowException('Too many entities to check'); |
|
88 | 88 | } |
89 | 89 | |
90 | - $item = $this->entityLookup->getEntity( $comparativeClass ); |
|
91 | - if ( !( $item instanceof StatementListProvider ) ) { |
|
90 | + $item = $this->entityLookup->getEntity($comparativeClass); |
|
91 | + if (!($item instanceof StatementListProvider)) { |
|
92 | 92 | return false; // lookup failed, probably because item doesn't exist |
93 | 93 | } |
94 | 94 | |
95 | - $subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfId' ); |
|
95 | + $subclassId = $this->config->get('WBQualityConstraintsSubclassOfId'); |
|
96 | 96 | $statements = $item->getStatements() |
97 | - ->getByPropertyId( new NumericPropertyId( $subclassId ) ) |
|
97 | + ->getByPropertyId(new NumericPropertyId($subclassId)) |
|
98 | 98 | ->getBestStatements(); |
99 | 99 | /** @var Statement $statement */ |
100 | - foreach ( $statements as $statement ) { |
|
100 | + foreach ($statements as $statement) { |
|
101 | 101 | $mainSnak = $statement->getMainSnak(); |
102 | 102 | |
103 | - if ( !$this->hasCorrectType( $mainSnak ) ) { |
|
103 | + if (!$this->hasCorrectType($mainSnak)) { |
|
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | /** @var PropertyValueSnak $mainSnak */ |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | '@phan-var EntityIdValue $dataValue'; |
111 | 111 | $comparativeClass = $dataValue->getEntityId(); |
112 | 112 | |
113 | - if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) { |
|
113 | + if (in_array($comparativeClass->getSerialization(), $classesToCheck)) { |
|
114 | 114 | return true; |
115 | 115 | } |
116 | 116 | |
117 | - if ( $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ) ) { |
|
117 | + if ($this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked)) { |
|
118 | 118 | return true; |
119 | 119 | } |
120 | 120 | } |
@@ -135,35 +135,35 @@ discard block |
||
135 | 135 | * @return CachedBool |
136 | 136 | * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs |
137 | 137 | */ |
138 | - public function isSubclassOfWithSparqlFallback( EntityId $comparativeClass, array $classesToCheck ) { |
|
139 | - $timing = $this->statsFactory->getTiming( 'isSubclassOf_duration_seconds' ) |
|
140 | - ->setLabel( 'result', 'success' ) |
|
141 | - ->setLabel( 'TypeCheckerImplementation', 'php' ); |
|
138 | + public function isSubclassOfWithSparqlFallback(EntityId $comparativeClass, array $classesToCheck) { |
|
139 | + $timing = $this->statsFactory->getTiming('isSubclassOf_duration_seconds') |
|
140 | + ->setLabel('result', 'success') |
|
141 | + ->setLabel('TypeCheckerImplementation', 'php'); |
|
142 | 142 | $timing->start(); |
143 | 143 | |
144 | 144 | try { |
145 | 145 | $entitiesChecked = 0; |
146 | - $isSubclass = $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ); |
|
146 | + $isSubclass = $this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked); |
|
147 | 147 | $timing->stop(); |
148 | 148 | |
149 | 149 | // not really a timing, but works like one (we want percentiles etc.) |
150 | 150 | // TODO: probably a good candidate for T348796 |
151 | - $this->statsFactory->getTiming( 'isSubclassOf_entities_total' ) |
|
152 | - ->setLabel( 'TypeCheckerImplementation', 'php' ) |
|
153 | - ->setLabel( 'result', 'success' ) |
|
154 | - ->observe( $entitiesChecked ); |
|
155 | - |
|
156 | - return new CachedBool( $isSubclass, Metadata::blank() ); |
|
157 | - } catch ( OverflowException ) { |
|
158 | - $timing->setLabel( 'result', 'overflow' ) |
|
151 | + $this->statsFactory->getTiming('isSubclassOf_entities_total') |
|
152 | + ->setLabel('TypeCheckerImplementation', 'php') |
|
153 | + ->setLabel('result', 'success') |
|
154 | + ->observe($entitiesChecked); |
|
155 | + |
|
156 | + return new CachedBool($isSubclass, Metadata::blank()); |
|
157 | + } catch (OverflowException) { |
|
158 | + $timing->setLabel('result', 'overflow') |
|
159 | 159 | ->stop(); |
160 | 160 | |
161 | - if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) { |
|
162 | - $this->statsFactory->getCounter( 'sparql_typeFallback_total' ) |
|
161 | + if (!($this->sparqlHelper instanceof DummySparqlHelper)) { |
|
162 | + $this->statsFactory->getCounter('sparql_typeFallback_total') |
|
163 | 163 | ->increment(); |
164 | 164 | |
165 | - $timing->setLabel( 'TypeCheckerImplementation', 'sparql' ) |
|
166 | - ->setLabel( 'result', 'success' ) |
|
165 | + $timing->setLabel('TypeCheckerImplementation', 'sparql') |
|
166 | + ->setLabel('result', 'success') |
|
167 | 167 | ->start(); |
168 | 168 | |
169 | 169 | $hasType = $this->sparqlHelper->hasType( |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | return $hasType; |
177 | 177 | } else { |
178 | - return new CachedBool( false, Metadata::blank() ); |
|
178 | + return new CachedBool(false, Metadata::blank()); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | } |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | * @return CachedBool |
194 | 194 | * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs |
195 | 195 | */ |
196 | - public function hasClassInRelation( StatementList $statements, array $relationIds, array $classesToCheck ) { |
|
196 | + public function hasClassInRelation(StatementList $statements, array $relationIds, array $classesToCheck) { |
|
197 | 197 | $metadatas = []; |
198 | 198 | |
199 | - foreach ( $this->getBestStatementsByPropertyIds( $statements, $relationIds ) as $statement ) { |
|
199 | + foreach ($this->getBestStatementsByPropertyIds($statements, $relationIds) as $statement) { |
|
200 | 200 | $mainSnak = $statement->getMainSnak(); |
201 | 201 | |
202 | - if ( !$this->hasCorrectType( $mainSnak ) ) { |
|
202 | + if (!$this->hasCorrectType($mainSnak)) { |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | /** @var PropertyValueSnak $mainSnak */ |
@@ -209,24 +209,24 @@ discard block |
||
209 | 209 | '@phan-var EntityIdValue $dataValue'; |
210 | 210 | $comparativeClass = $dataValue->getEntityId(); |
211 | 211 | |
212 | - if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) { |
|
212 | + if (in_array($comparativeClass->getSerialization(), $classesToCheck)) { |
|
213 | 213 | // discard $metadatas, we know this is fresh |
214 | - return new CachedBool( true, Metadata::blank() ); |
|
214 | + return new CachedBool(true, Metadata::blank()); |
|
215 | 215 | } |
216 | 216 | |
217 | - $result = $this->isSubclassOfWithSparqlFallback( $comparativeClass, $classesToCheck ); |
|
217 | + $result = $this->isSubclassOfWithSparqlFallback($comparativeClass, $classesToCheck); |
|
218 | 218 | $metadatas[] = $result->getMetadata(); |
219 | - if ( $result->getBool() ) { |
|
219 | + if ($result->getBool()) { |
|
220 | 220 | return new CachedBool( |
221 | 221 | true, |
222 | - Metadata::merge( $metadatas ) |
|
222 | + Metadata::merge($metadatas) |
|
223 | 223 | ); |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | 227 | return new CachedBool( |
228 | 228 | false, |
229 | - Metadata::merge( $metadatas ) |
|
229 | + Metadata::merge($metadatas) |
|
230 | 230 | ); |
231 | 231 | } |
232 | 232 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @return bool |
236 | 236 | * @phan-assert PropertyValueSnak $mainSnak |
237 | 237 | */ |
238 | - private function hasCorrectType( Snak $mainSnak ) { |
|
238 | + private function hasCorrectType(Snak $mainSnak) { |
|
239 | 239 | return $mainSnak instanceof PropertyValueSnak |
240 | 240 | && $mainSnak->getDataValue()->getType() === 'wikibase-entityid'; |
241 | 241 | } |
@@ -252,15 +252,15 @@ discard block |
||
252 | 252 | ) { |
253 | 253 | $statementArrays = []; |
254 | 254 | |
255 | - foreach ( $propertyIdSerializations as $propertyIdSerialization ) { |
|
256 | - $propertyId = new NumericPropertyId( $propertyIdSerialization ); |
|
255 | + foreach ($propertyIdSerializations as $propertyIdSerialization) { |
|
256 | + $propertyId = new NumericPropertyId($propertyIdSerialization); |
|
257 | 257 | $statementArrays[] = $statements |
258 | - ->getByPropertyId( $propertyId ) |
|
258 | + ->getByPropertyId($propertyId) |
|
259 | 259 | ->getBestStatements() |
260 | 260 | ->toArray(); |
261 | 261 | } |
262 | 262 | |
263 | - return array_merge( ...$statementArrays ); |
|
263 | + return array_merge(...$statementArrays); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | $relation |
281 | 281 | ) { |
282 | 282 | $classes = array_map( |
283 | - static function ( $itemIdSerialization ) { |
|
284 | - return new ItemId( $itemIdSerialization ); |
|
283 | + static function($itemIdSerialization) { |
|
284 | + return new ItemId($itemIdSerialization); |
|
285 | 285 | }, |
286 | 286 | $classes |
287 | 287 | ); |
@@ -293,10 +293,10 @@ discard block |
||
293 | 293 | // wbqc-violation-message-valueType-instance |
294 | 294 | // wbqc-violation-message-valueType-subclass |
295 | 295 | // wbqc-violation-message-valueType-instanceOrSubclass |
296 | - return ( new ViolationMessage( 'wbqc-violation-message-' . $checker . '-' . $relation ) ) |
|
297 | - ->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY ) |
|
298 | - ->withEntityId( $entityId, Role::SUBJECT ) |
|
299 | - ->withEntityIdList( $classes, Role::OBJECT ); |
|
296 | + return (new ViolationMessage('wbqc-violation-message-'.$checker.'-'.$relation)) |
|
297 | + ->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY) |
|
298 | + ->withEntityId($entityId, Role::SUBJECT) |
|
299 | + ->withEntityIdList($classes, Role::OBJECT); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | } |