@@ -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,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 |
@@ -86,6 +86,6 @@ |
||
86 | 86 | * @param array|null $result |
87 | 87 | * @param array[] &$container |
88 | 88 | */ |
89 | - public function storeCheckResultInArray( array $result = null, array &$container ); |
|
89 | + public function storeCheckResultInArray(array $result = null, array &$container); |
|
90 | 90 | |
91 | 91 | } |
@@ -36,29 +36,29 @@ discard block |
||
36 | 36 | $propertyId, |
37 | 37 | $statementGuid |
38 | 38 | ) { |
39 | - if ( !array_key_exists( $entityId, $container ) ) { |
|
39 | + if (!array_key_exists($entityId, $container)) { |
|
40 | 40 | $container[$entityId] = []; |
41 | 41 | } |
42 | 42 | $entityContainer = &$container[$entityId]; |
43 | 43 | |
44 | - if ( !array_key_exists( 'claims', $entityContainer ) ) { |
|
44 | + if (!array_key_exists('claims', $entityContainer)) { |
|
45 | 45 | $entityContainer['claims'] = []; |
46 | 46 | } |
47 | 47 | $claimsContainer = &$entityContainer['claims']; |
48 | 48 | |
49 | - if ( !array_key_exists( $propertyId, $claimsContainer ) ) { |
|
49 | + if (!array_key_exists($propertyId, $claimsContainer)) { |
|
50 | 50 | $claimsContainer[$propertyId] = []; |
51 | 51 | } |
52 | 52 | $propertyContainer = &$claimsContainer[$propertyId]; |
53 | 53 | |
54 | - foreach ( $propertyContainer as &$statement ) { |
|
55 | - if ( $statement['id'] === $statementGuid ) { |
|
54 | + foreach ($propertyContainer as &$statement) { |
|
55 | + if ($statement['id'] === $statementGuid) { |
|
56 | 56 | $statementArray = &$statement; |
57 | 57 | break; |
58 | 58 | } |
59 | 59 | } |
60 | - if ( !isset( $statementArray ) ) { |
|
61 | - $statementArray = [ 'id' => $statementGuid ]; |
|
60 | + if (!isset($statementArray)) { |
|
61 | + $statementArray = ['id' => $statementGuid]; |
|
62 | 62 | $propertyContainer[] = &$statementArray; |
63 | 63 | } |
64 | 64 | |
@@ -73,19 +73,19 @@ discard block |
||
73 | 73 | * @param array[] &$container |
74 | 74 | * @return array |
75 | 75 | */ |
76 | - abstract protected function &getMainArray( array &$container ); |
|
76 | + abstract protected function &getMainArray(array &$container); |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @param array|null $result |
80 | 80 | * @param array[] &$container |
81 | 81 | */ |
82 | - public function storeCheckResultInArray( array $result = null, array &$container ) { |
|
83 | - $mainArray = &$this->getMainArray( $container ); |
|
84 | - if ( !array_key_exists( 'results', $mainArray ) ) { |
|
82 | + public function storeCheckResultInArray(array $result = null, array &$container) { |
|
83 | + $mainArray = &$this->getMainArray($container); |
|
84 | + if (!array_key_exists('results', $mainArray)) { |
|
85 | 85 | $mainArray['results'] = []; |
86 | 86 | } |
87 | 87 | |
88 | - if ( $result !== null ) { |
|
88 | + if ($result !== null) { |
|
89 | 89 | $mainArray['results'][] = $result; |
90 | 90 | } |
91 | 91 | } |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * @param int $maxAge The maximum age of the cached value (in seconds). |
30 | 30 | * @return self Indication that a value is possibly outdated by up to this many seconds. |
31 | 31 | */ |
32 | - public static function ofMaximumAgeInSeconds( $maxAge ) { |
|
33 | - Assert::parameterType( 'integer', $maxAge, '$maxAge' ); |
|
34 | - Assert::parameter( $maxAge > 0, '$maxAge', '$maxage > 0' ); |
|
32 | + public static function ofMaximumAgeInSeconds($maxAge) { |
|
33 | + Assert::parameterType('integer', $maxAge, '$maxAge'); |
|
34 | + Assert::parameter($maxAge > 0, '$maxAge', '$maxage > 0'); |
|
35 | 35 | $ret = new self; |
36 | 36 | $ret->maxAge = $maxAge; |
37 | 37 | return $ret; |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * @param array|null $array As returned by toArray. |
43 | 43 | * @return self |
44 | 44 | */ |
45 | - public static function ofArray( array $array = null ) { |
|
45 | + public static function ofArray(array $array = null) { |
|
46 | 46 | $ret = new self; |
47 | - if ( $array !== null ) { |
|
47 | + if ($array !== null) { |
|
48 | 48 | $ret->maxAge = $array['maximumAgeInSeconds']; |
49 | 49 | } |
50 | 50 | return $ret; |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | * @param self[] $metadatas |
55 | 55 | * @return self |
56 | 56 | */ |
57 | - public static function merge( array $metadatas ) { |
|
58 | - Assert::parameterElementType( self::class, $metadatas, '$metadatas' ); |
|
57 | + public static function merge(array $metadatas) { |
|
58 | + Assert::parameterElementType(self::class, $metadatas, '$metadatas'); |
|
59 | 59 | $ret = new self; |
60 | - foreach ( $metadatas as $metadata ) { |
|
61 | - $ret->maxAge = max( $ret->maxAge, $metadata->maxAge ); |
|
60 | + foreach ($metadatas as $metadata) { |
|
61 | + $ret->maxAge = max($ret->maxAge, $metadata->maxAge); |
|
62 | 62 | } |
63 | 63 | return $ret; |
64 | 64 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * For a fresh value, returns 0. |
77 | 77 | */ |
78 | 78 | public function getMaximumAgeInSeconds() { |
79 | - if ( is_int( $this->maxAge ) ) { |
|
79 | + if (is_int($this->maxAge)) { |
|
80 | 80 | return $this->maxAge; |
81 | 81 | } else { |
82 | 82 | return 0; |
@@ -91,8 +91,7 @@ discard block |
||
91 | 91 | return $this->isCached() ? |
92 | 92 | [ |
93 | 93 | 'maximumAgeInSeconds' => $this->maxAge, |
94 | - ] : |
|
95 | - null; |
|
94 | + ] : null; |
|
96 | 95 | } |
97 | 96 | |
98 | 97 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param ItemId $itemId |
45 | 45 | * @return self |
46 | 46 | */ |
47 | - public static function fromItemId( ItemId $itemId ) { |
|
47 | + public static function fromItemId(ItemId $itemId) { |
|
48 | 48 | $ret = new self; |
49 | 49 | $ret->itemId = $itemId; |
50 | 50 | return $ret; |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | * @throws InvalidArgumentException |
81 | 81 | * @return self |
82 | 82 | */ |
83 | - public static function fromSnak( Snak $snak ) { |
|
84 | - switch ( true ) { |
|
83 | + public static function fromSnak(Snak $snak) { |
|
84 | + switch (true) { |
|
85 | 85 | case $snak instanceof PropertyValueSnak: |
86 | 86 | $dataValue = $snak->getDataValue(); |
87 | - if ( $dataValue instanceof EntityIdValue |
|
87 | + if ($dataValue instanceof EntityIdValue |
|
88 | 88 | && $dataValue->getEntityId() instanceof ItemId |
89 | 89 | ) { |
90 | - return self::fromItemId( $dataValue->getEntityId() ); |
|
90 | + return self::fromItemId($dataValue->getEntityId()); |
|
91 | 91 | } |
92 | 92 | break; |
93 | 93 | case $snak instanceof PropertySomeValueSnak: |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | return self::noValue(); |
97 | 97 | } |
98 | 98 | |
99 | - throw new InvalidArgumentException( 'Snak must contain item ID value or be a somevalue / novalue snak' ); |
|
99 | + throw new InvalidArgumentException('Snak must contain item ID value or be a somevalue / novalue snak'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @return ItemId |
134 | 134 | */ |
135 | 135 | public function getItemId() { |
136 | - if ( ! $this->isValue() ) { |
|
137 | - throw new DomainException( 'This value does not contain an item ID.' ); |
|
136 | + if (!$this->isValue()) { |
|
137 | + throw new DomainException('This value does not contain an item ID.'); |
|
138 | 138 | } |
139 | 139 | return $this->itemId; |
140 | 140 | } |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * @param Snak $snak |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | - public function matchesSnak( Snak $snak ) { |
|
150 | - switch ( true ) { |
|
149 | + public function matchesSnak(Snak $snak) { |
|
150 | + switch (true) { |
|
151 | 151 | case $snak instanceof PropertyValueSnak: |
152 | 152 | return $this->isValue() && |
153 | 153 | $snak->getDataValue() instanceof EntityIdValue && |
154 | 154 | $snak->getDataValue()->getEntityId() instanceof ItemId && |
155 | - $snak->getDataValue()->getEntityId()->equals( $this->getItemId() ); |
|
155 | + $snak->getDataValue()->getEntityId()->equals($this->getItemId()); |
|
156 | 156 | case $snak instanceof PropertySomeValueSnak: |
157 | 157 | return $this->isSomeValue(); |
158 | 158 | case $snak instanceof PropertyNoValueSnak: |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | StatementList $statementList, |
31 | 31 | PropertyId $propertyId |
32 | 32 | ) { |
33 | - $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); |
|
34 | - if ( $statementListByPropertyId->isEmpty() ) { |
|
33 | + $statementListByPropertyId = $statementList->getByPropertyId($propertyId); |
|
34 | + if ($statementListByPropertyId->isEmpty()) { |
|
35 | 35 | return null; |
36 | 36 | } else { |
37 | 37 | return $statementListByPropertyId->toArray()[0]; |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | PropertyId $propertyId, |
53 | 53 | EntityId $value |
54 | 54 | ) { |
55 | - $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); |
|
55 | + $statementListByPropertyId = $statementList->getByPropertyId($propertyId); |
|
56 | 56 | /** @var Statement $statement */ |
57 | - foreach ( $statementListByPropertyId as $statement ) { |
|
57 | + foreach ($statementListByPropertyId as $statement) { |
|
58 | 58 | $snak = $statement->getMainSnak(); |
59 | - if ( $snak instanceof PropertyValueSnak ) { |
|
59 | + if ($snak instanceof PropertyValueSnak) { |
|
60 | 60 | $dataValue = $snak->getDataValue(); |
61 | - if ( $dataValue instanceof EntityIdValue && |
|
62 | - $dataValue->getEntityId()->equals( $value ) |
|
61 | + if ($dataValue instanceof EntityIdValue && |
|
62 | + $dataValue->getEntityId()->equals($value) |
|
63 | 63 | ) { |
64 | 64 | return $statement; |
65 | 65 | } |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | PropertyId $propertyId, |
83 | 83 | array $values |
84 | 84 | ) { |
85 | - $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); |
|
85 | + $statementListByPropertyId = $statementList->getByPropertyId($propertyId); |
|
86 | 86 | /** @var Statement $statement */ |
87 | - foreach ( $statementListByPropertyId as $statement ) { |
|
87 | + foreach ($statementListByPropertyId as $statement) { |
|
88 | 88 | $snak = $statement->getMainSnak(); |
89 | - foreach ( $values as $value ) { |
|
90 | - if ( $value->matchesSnak( $snak ) ) { |
|
89 | + foreach ($values as $value) { |
|
90 | + if ($value->matchesSnak($snak)) { |
|
91 | 91 | return $statement; |
92 | 92 | } |
93 | 93 | } |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | const BATCH_SIZE = 10; |
28 | 28 | |
29 | - public static function newFromGlobalState( Title $title, array $params ) { |
|
30 | - Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' ); |
|
29 | + public static function newFromGlobalState(Title $title, array $params) { |
|
30 | + Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]'); |
|
31 | 31 | $repo = WikibaseRepo::getDefaultInstance(); |
32 | 32 | return new UpdateConstraintsTableJob( |
33 | 33 | $title, |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | EntityLookup $entityLookup, |
84 | 84 | Serializer $snakSerializer |
85 | 85 | ) { |
86 | - parent::__construct( 'constraintsTableUpdate', $title, $params ); |
|
86 | + parent::__construct('constraintsTableUpdate', $title, $params); |
|
87 | 87 | |
88 | 88 | $this->propertyId = $propertyId; |
89 | 89 | $this->config = $config; |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | $this->snakSerializer = $snakSerializer; |
93 | 93 | } |
94 | 94 | |
95 | - public function extractParametersFromQualifiers( SnakList $qualifiers ) { |
|
95 | + public function extractParametersFromQualifiers(SnakList $qualifiers) { |
|
96 | 96 | $parameters = []; |
97 | - foreach ( $qualifiers as $qualifier ) { |
|
97 | + foreach ($qualifiers as $qualifier) { |
|
98 | 98 | $qualifierId = $qualifier->getPropertyId()->getSerialization(); |
99 | - $paramSerialization = $this->snakSerializer->serialize( $qualifier ); |
|
99 | + $paramSerialization = $this->snakSerializer->serialize($qualifier); |
|
100 | 100 | $parameters[$qualifierId][] = $paramSerialization; |
101 | 101 | } |
102 | 102 | return $parameters; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ) { |
109 | 109 | $constraintId = $constraintStatement->getGuid(); |
110 | 110 | $constraintTypeQid = $constraintStatement->getMainSnak()->getDataValue()->getEntityId()->getSerialization(); |
111 | - $parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() ); |
|
111 | + $parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers()); |
|
112 | 112 | return new Constraint( |
113 | 113 | $constraintId, |
114 | 114 | $propertyId, |
@@ -123,17 +123,17 @@ discard block |
||
123 | 123 | PropertyId $propertyConstraintPropertyId |
124 | 124 | ) { |
125 | 125 | $constraintsStatements = $property->getStatements() |
126 | - ->getByPropertyId( $propertyConstraintPropertyId ) |
|
127 | - ->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] ); |
|
126 | + ->getByPropertyId($propertyConstraintPropertyId) |
|
127 | + ->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]); |
|
128 | 128 | $constraints = []; |
129 | - foreach ( $constraintsStatements->getIterator() as $constraintStatement ) { |
|
130 | - $constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement ); |
|
131 | - if ( count( $constraints ) >= self::BATCH_SIZE ) { |
|
132 | - $constraintRepo->insertBatch( $constraints ); |
|
129 | + foreach ($constraintsStatements->getIterator() as $constraintStatement) { |
|
130 | + $constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement); |
|
131 | + if (count($constraints) >= self::BATCH_SIZE) { |
|
132 | + $constraintRepo->insertBatch($constraints); |
|
133 | 133 | $constraints = []; |
134 | 134 | } |
135 | 135 | } |
136 | - $constraintRepo->insertBatch( $constraints ); |
|
136 | + $constraintRepo->insertBatch($constraints); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | public function run() { |
145 | 145 | // TODO in the future: only touch constraints affected by the edit (requires T163465) |
146 | 146 | |
147 | - $propertyId = new PropertyId( $this->propertyId ); |
|
148 | - $this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId( $propertyId ); |
|
147 | + $propertyId = new PropertyId($this->propertyId); |
|
148 | + $this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId($propertyId); |
|
149 | 149 | |
150 | 150 | /** @var Property $property */ |
151 | - $property = $this->entityLookup->getEntity( $propertyId ); |
|
151 | + $property = $this->entityLookup->getEntity($propertyId); |
|
152 | 152 | $this->importConstraintsForProperty( |
153 | 153 | $property, |
154 | 154 | $this->constraintRepo, |
155 | - new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ) |
|
155 | + new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')) |
|
156 | 156 | ); |
157 | 157 | |
158 | 158 | return true; |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | protected $snak; |
25 | 25 | |
26 | - public function __construct( EntityDocument $entity, Snak $snak ) { |
|
26 | + public function __construct(EntityDocument $entity, Snak $snak) { |
|
27 | 27 | $this->entity = $entity; |
28 | 28 | $this->snak = $snak; |
29 | 29 | } |