@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | private $cache; |
19 | 19 | |
20 | 20 | public static function getDefaultInstance() { |
21 | - return new self( MediaWikiServices::getInstance()->getMainWANObjectCache() ); |
|
21 | + return new self(MediaWikiServices::getInstance()->getMainWANObjectCache()); |
|
22 | 22 | } |
23 | 23 | |
24 | - public function __construct( WANObjectCache $cache ) { |
|
24 | + public function __construct(WANObjectCache $cache) { |
|
25 | 25 | $this->cache = $cache; |
26 | 26 | } |
27 | 27 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param EntityId $entityId |
30 | 30 | * @return string cache key |
31 | 31 | */ |
32 | - public function makeKey( EntityId $entityId ) { |
|
32 | + public function makeKey(EntityId $entityId) { |
|
33 | 33 | return $this->cache->makeKey( |
34 | 34 | 'WikibaseQualityConstraints', // extension |
35 | 35 | 'checkConstraints', // action |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * @param float &$asOf |
46 | 46 | * @return mixed |
47 | 47 | */ |
48 | - public function get( EntityId $key, &$curTTL = null, array $checkKeys = [], &$asOf = null ) { |
|
49 | - return $this->cache->get( $this->makeKey( $key ), $curTTL, $checkKeys, $asOf ); |
|
48 | + public function get(EntityId $key, &$curTTL = null, array $checkKeys = [], &$asOf = null) { |
|
49 | + return $this->cache->get($this->makeKey($key), $curTTL, $checkKeys, $asOf); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | * @param array $opts |
57 | 57 | * @return bool |
58 | 58 | */ |
59 | - public function set( EntityId $key, $value, $ttl = 0, array $opts = [] ) { |
|
60 | - return $this->cache->set( $this->makeKey( $key ), $value, $ttl, $opts ); |
|
59 | + public function set(EntityId $key, $value, $ttl = 0, array $opts = []) { |
|
60 | + return $this->cache->set($this->makeKey($key), $value, $ttl, $opts); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param EntityId $key |
65 | 65 | * @return bool |
66 | 66 | */ |
67 | - public function delete( EntityId $key ) { |
|
68 | - return $this->cache->delete( $this->makeKey( $key ) ); |
|
67 | + public function delete(EntityId $key) { |
|
68 | + return $this->cache->delete($this->makeKey($key)); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | public static function getDefaultInstance() { |
138 | 138 | static $instance = null; |
139 | 139 | |
140 | - if ( $instance === null ) { |
|
140 | + if ($instance === null) { |
|
141 | 141 | $wikibaseRepo = WikibaseRepo::getDefaultInstance(); |
142 | 142 | $entityIdFormatter = $wikibaseRepo->getEntityIdHtmlLinkFormatterFactory()->getEntityIdFormatter( |
143 | 143 | $wikibaseRepo->getLanguageFallbackLabelDescriptionLookupFactory()->newLabelDescriptionLookup( |
@@ -205,21 +205,21 @@ discard block |
||
205 | 205 | * @return DelegatingConstraintChecker |
206 | 206 | */ |
207 | 207 | public function getConstraintChecker() { |
208 | - if ( $this->delegatingConstraintChecker === null ) { |
|
208 | + if ($this->delegatingConstraintChecker === null) { |
|
209 | 209 | $this->delegatingConstraintChecker = new DelegatingConstraintChecker( |
210 | 210 | $this->lookup, |
211 | 211 | $this->getConstraintCheckerMap(), |
212 | - new CachingConstraintLookup( $this->getConstraintRepository() ), |
|
212 | + new CachingConstraintLookup($this->getConstraintRepository()), |
|
213 | 213 | $this->constraintParameterParser, |
214 | 214 | $this->statementGuidParser, |
215 | 215 | new LoggingHelper( |
216 | 216 | $this->dataFactory, |
217 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
217 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
218 | 218 | $this->config |
219 | 219 | ), |
220 | - $this->config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
221 | - $this->config->get( 'WBQualityConstraintsCheckReferences' ), |
|
222 | - $this->config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
220 | + $this->config->get('WBQualityConstraintsCheckQualifiers'), |
|
221 | + $this->config->get('WBQualityConstraintsCheckReferences'), |
|
222 | + $this->config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
223 | 223 | ); |
224 | 224 | } |
225 | 225 | |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | * @return ConstraintChecker[] |
231 | 231 | */ |
232 | 232 | private function getConstraintCheckerMap() { |
233 | - if ( $this->constraintCheckerMap === null ) { |
|
233 | + if ($this->constraintCheckerMap === null) { |
|
234 | 234 | $connectionCheckerHelper = new ConnectionCheckerHelper(); |
235 | - $rangeCheckerHelper = new RangeCheckerHelper( $this->config, $this->unitConverter ); |
|
236 | - if ( $this->config->get( 'WBQualityConstraintsSparqlEndpoint' ) !== '' ) { |
|
235 | + $rangeCheckerHelper = new RangeCheckerHelper($this->config, $this->unitConverter); |
|
236 | + if ($this->config->get('WBQualityConstraintsSparqlEndpoint') !== '') { |
|
237 | 237 | $sparqlHelper = new SparqlHelper( |
238 | 238 | $this->config, |
239 | 239 | $this->rdfVocabulary, |
@@ -254,74 +254,74 @@ discard block |
||
254 | 254 | ); |
255 | 255 | |
256 | 256 | $this->constraintCheckerMap = [ |
257 | - $this->config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
257 | + $this->config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
258 | 258 | => new ConflictsWithChecker( |
259 | 259 | $this->lookup, |
260 | 260 | $this->constraintParameterParser, |
261 | 261 | $connectionCheckerHelper, |
262 | 262 | $this->constraintParameterRenderer |
263 | 263 | ), |
264 | - $this->config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
264 | + $this->config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
265 | 265 | => new ItemChecker( |
266 | 266 | $this->lookup, |
267 | 267 | $this->constraintParameterParser, |
268 | 268 | $connectionCheckerHelper, |
269 | 269 | $this->constraintParameterRenderer |
270 | 270 | ), |
271 | - $this->config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
271 | + $this->config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
272 | 272 | => new TargetRequiredClaimChecker( |
273 | 273 | $this->lookup, |
274 | 274 | $this->constraintParameterParser, |
275 | 275 | $connectionCheckerHelper, |
276 | 276 | $this->constraintParameterRenderer |
277 | 277 | ), |
278 | - $this->config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
278 | + $this->config->get('WBQualityConstraintsSymmetricConstraintId') |
|
279 | 279 | => new SymmetricChecker( |
280 | 280 | $this->lookup, |
281 | 281 | $connectionCheckerHelper, |
282 | 282 | $this->constraintParameterRenderer |
283 | 283 | ), |
284 | - $this->config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
284 | + $this->config->get('WBQualityConstraintsInverseConstraintId') |
|
285 | 285 | => new InverseChecker( |
286 | 286 | $this->lookup, |
287 | 287 | $this->constraintParameterParser, |
288 | 288 | $connectionCheckerHelper, |
289 | 289 | $this->constraintParameterRenderer |
290 | 290 | ), |
291 | - $this->config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
291 | + $this->config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
292 | 292 | => new QualifierChecker(), |
293 | - $this->config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
293 | + $this->config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
294 | 294 | => new QualifiersChecker( |
295 | 295 | $this->constraintParameterParser, |
296 | 296 | $this->constraintParameterRenderer |
297 | 297 | ), |
298 | - $this->config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
298 | + $this->config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
299 | 299 | => new MandatoryQualifiersChecker( |
300 | 300 | $this->constraintParameterParser, |
301 | 301 | $this->constraintParameterRenderer |
302 | 302 | ), |
303 | - $this->config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
303 | + $this->config->get('WBQualityConstraintsRangeConstraintId') |
|
304 | 304 | => new RangeChecker( |
305 | 305 | $this->propertyDataTypeLookup, |
306 | 306 | $this->constraintParameterParser, |
307 | 307 | $rangeCheckerHelper, |
308 | 308 | $this->constraintParameterRenderer |
309 | 309 | ), |
310 | - $this->config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
310 | + $this->config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
311 | 311 | => new DiffWithinRangeChecker( |
312 | 312 | $this->constraintParameterParser, |
313 | 313 | $rangeCheckerHelper, |
314 | 314 | $this->constraintParameterRenderer, |
315 | 315 | $this->config |
316 | 316 | ), |
317 | - $this->config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
317 | + $this->config->get('WBQualityConstraintsTypeConstraintId') |
|
318 | 318 | => new TypeChecker( |
319 | 319 | $this->lookup, |
320 | 320 | $this->constraintParameterParser, |
321 | 321 | $typeCheckerHelper, |
322 | 322 | $this->config |
323 | 323 | ), |
324 | - $this->config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
324 | + $this->config->get('WBQualityConstraintsValueTypeConstraintId') |
|
325 | 325 | => new ValueTypeChecker( |
326 | 326 | $this->lookup, |
327 | 327 | $this->constraintParameterParser, |
@@ -329,36 +329,36 @@ discard block |
||
329 | 329 | $typeCheckerHelper, |
330 | 330 | $this->config |
331 | 331 | ), |
332 | - $this->config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
332 | + $this->config->get('WBQualityConstraintsSingleValueConstraintId') |
|
333 | 333 | => new SingleValueChecker(), |
334 | - $this->config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
334 | + $this->config->get('WBQualityConstraintsMultiValueConstraintId') |
|
335 | 335 | => new MultiValueChecker(), |
336 | - $this->config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
336 | + $this->config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
337 | 337 | => new UniqueValueChecker( |
338 | 338 | $this->constraintParameterRenderer, |
339 | 339 | $sparqlHelper |
340 | 340 | ), |
341 | - $this->config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
341 | + $this->config->get('WBQualityConstraintsFormatConstraintId') |
|
342 | 342 | => new FormatChecker( |
343 | 343 | $this->constraintParameterParser, |
344 | 344 | $this->constraintParameterRenderer, |
345 | 345 | $this->config, |
346 | 346 | $sparqlHelper |
347 | 347 | ), |
348 | - $this->config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
348 | + $this->config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
349 | 349 | => new CommonsLinkChecker( |
350 | 350 | $this->constraintParameterParser, |
351 | 351 | $this->constraintParameterRenderer, |
352 | 352 | $this->titleParser |
353 | 353 | ), |
354 | - $this->config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
354 | + $this->config->get('WBQualityConstraintsOneOfConstraintId') |
|
355 | 355 | => new OneOfChecker( |
356 | 356 | $this->constraintParameterParser, |
357 | 357 | $this->constraintParameterRenderer |
358 | 358 | ), |
359 | - $this->config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
359 | + $this->config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
360 | 360 | => new ValueOnlyChecker(), |
361 | - $this->config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
361 | + $this->config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
362 | 362 | => new ReferenceChecker(), |
363 | 363 | ]; |
364 | 364 | } |
@@ -370,26 +370,26 @@ discard block |
||
370 | 370 | * @return array[] |
371 | 371 | */ |
372 | 372 | public function getConstraintParameterMap() { |
373 | - if ( $this->constraintParameterMap === null ) { |
|
373 | + if ($this->constraintParameterMap === null) { |
|
374 | 374 | $this->constraintParameterMap = [ |
375 | - 'Commons link' => [ 'namespace' ], |
|
376 | - 'Conflicts with' => [ 'property', 'item' ], |
|
377 | - 'Diff within range' => [ 'property', 'minimum_quantity', 'maximum_quantity' ], |
|
378 | - 'Format' => [ 'pattern' ], |
|
379 | - 'Inverse' => [ 'property' ], |
|
380 | - 'Item' => [ 'property', 'item' ], |
|
381 | - 'Mandatory qualifiers' => [ 'property' ], |
|
375 | + 'Commons link' => ['namespace'], |
|
376 | + 'Conflicts with' => ['property', 'item'], |
|
377 | + 'Diff within range' => ['property', 'minimum_quantity', 'maximum_quantity'], |
|
378 | + 'Format' => ['pattern'], |
|
379 | + 'Inverse' => ['property'], |
|
380 | + 'Item' => ['property', 'item'], |
|
381 | + 'Mandatory qualifiers' => ['property'], |
|
382 | 382 | 'Multi value' => [], |
383 | - 'One of' => [ 'item' ], |
|
383 | + 'One of' => ['item'], |
|
384 | 384 | 'Qualifier' => [], |
385 | - 'Qualifiers' => [ 'property' ], |
|
386 | - 'Range' => [ 'minimum_quantity', 'maximum_quantity', 'minimum_date', 'maximum_date' ], |
|
385 | + 'Qualifiers' => ['property'], |
|
386 | + 'Range' => ['minimum_quantity', 'maximum_quantity', 'minimum_date', 'maximum_date'], |
|
387 | 387 | 'Single value' => [], |
388 | 388 | 'Symmetric' => [], |
389 | - 'Target required claim' => [ 'property', 'item' ], |
|
390 | - 'Type' => [ 'class', 'relation' ], |
|
389 | + 'Target required claim' => ['property', 'item'], |
|
390 | + 'Type' => ['class', 'relation'], |
|
391 | 391 | 'Unique value' => [], |
392 | - 'Value type' => [ 'class', 'relation' ] |
|
392 | + 'Value type' => ['class', 'relation'] |
|
393 | 393 | ]; |
394 | 394 | } |
395 | 395 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @return ConstraintRepository |
401 | 401 | */ |
402 | 402 | public function getConstraintRepository() { |
403 | - if ( $this->constraintRepository === null ) { |
|
403 | + if ($this->constraintRepository === null) { |
|
404 | 404 | $this->constraintRepository = new ConstraintRepository(); |
405 | 405 | } |
406 | 406 |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return self |
67 | 67 | */ |
68 | - public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) { |
|
68 | + public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') { |
|
69 | 69 | $constraintReportFactory = ConstraintReportFactory::getDefaultInstance(); |
70 | 70 | $repo = WikibaseRepo::getDefaultInstance(); |
71 | - $helperFactory = $repo->getApiHelperFactory( RequestContext::getMain() ); |
|
71 | + $helperFactory = $repo->getApiHelperFactory(RequestContext::getMain()); |
|
72 | 72 | return new self( |
73 | 73 | $main, |
74 | 74 | $name, |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | StatementGuidParser $statementGuidParser, |
99 | 99 | IBufferingStatsdDataFactory $dataFactory |
100 | 100 | ) { |
101 | - parent::__construct( $main, $name, $prefix ); |
|
101 | + parent::__construct($main, $name, $prefix); |
|
102 | 102 | |
103 | - $this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
103 | + $this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this); |
|
104 | 104 | $this->delegatingConstraintChecker = $delegatingConstraintChecker; |
105 | 105 | $this->statementGuidParser = $statementGuidParser; |
106 | 106 | $this->dataFactory = $dataFactory; |
@@ -114,39 +114,39 @@ discard block |
||
114 | 114 | $params = $this->extractRequestParams(); |
115 | 115 | $result = $this->getResult(); |
116 | 116 | |
117 | - $propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] ); |
|
118 | - $constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] ); |
|
117 | + $propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]); |
|
118 | + $constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]); |
|
119 | 119 | |
120 | - $this->checkPropertyIds( $propertyIds, $result ); |
|
121 | - $this->checkConstraintIds( $constraintIds, $result ); |
|
120 | + $this->checkPropertyIds($propertyIds, $result); |
|
121 | + $this->checkConstraintIds($constraintIds, $result); |
|
122 | 122 | |
123 | - $result->addValue( null, 'success', 1 ); |
|
123 | + $result->addValue(null, 'success', 1); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | 127 | * @param array|null $propertyIdSerializations |
128 | 128 | * @return PropertyId[] |
129 | 129 | */ |
130 | - private function parsePropertyIds( $propertyIdSerializations ) { |
|
131 | - if ( $propertyIdSerializations === null ) { |
|
130 | + private function parsePropertyIds($propertyIdSerializations) { |
|
131 | + if ($propertyIdSerializations === null) { |
|
132 | 132 | return []; |
133 | - } elseif ( empty( $propertyIdSerializations ) ) { |
|
133 | + } elseif (empty($propertyIdSerializations)) { |
|
134 | 134 | $this->apiErrorReporter->dieError( |
135 | - 'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.', |
|
135 | + 'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.', |
|
136 | 136 | 'no-data' |
137 | 137 | ); |
138 | 138 | } |
139 | 139 | |
140 | 140 | return array_map( |
141 | - function( $propertyIdSerialization ) { |
|
141 | + function($propertyIdSerialization) { |
|
142 | 142 | try { |
143 | - return new PropertyId( $propertyIdSerialization ); |
|
144 | - } catch ( InvalidArgumentException $e ) { |
|
143 | + return new PropertyId($propertyIdSerialization); |
|
144 | + } catch (InvalidArgumentException $e) { |
|
145 | 145 | $this->apiErrorReporter->dieError( |
146 | 146 | "Invalid id: $propertyIdSerialization", |
147 | 147 | 'invalid-property-id', |
148 | 148 | 0, // default argument |
149 | - [ self::PARAM_PROPERTY_ID => $propertyIdSerialization ] |
|
149 | + [self::PARAM_PROPERTY_ID => $propertyIdSerialization] |
|
150 | 150 | ); |
151 | 151 | } |
152 | 152 | }, |
@@ -158,35 +158,35 @@ discard block |
||
158 | 158 | * @param array|null $constraintIds |
159 | 159 | * @return string[] |
160 | 160 | */ |
161 | - private function parseConstraintIds( $constraintIds ) { |
|
162 | - if ( $constraintIds === null ) { |
|
161 | + private function parseConstraintIds($constraintIds) { |
|
162 | + if ($constraintIds === null) { |
|
163 | 163 | return []; |
164 | - } elseif ( empty( $constraintIds ) ) { |
|
164 | + } elseif (empty($constraintIds)) { |
|
165 | 165 | $this->apiErrorReporter->dieError( |
166 | - 'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.', |
|
166 | + 'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.', |
|
167 | 167 | 'no-data' |
168 | 168 | ); |
169 | 169 | } |
170 | 170 | |
171 | 171 | return array_map( |
172 | - function( $constraintId ) { |
|
172 | + function($constraintId) { |
|
173 | 173 | try { |
174 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
175 | - if ( !$propertyId instanceof PropertyId ) { |
|
174 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
175 | + if (!$propertyId instanceof PropertyId) { |
|
176 | 176 | $this->apiErrorReporter->dieError( |
177 | 177 | "Invalid property ID: {$propertyId->getSerialization()}", |
178 | 178 | 'invalid-property-id', |
179 | 179 | 0, // default argument |
180 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
180 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
181 | 181 | ); |
182 | 182 | } |
183 | 183 | return $constraintId; |
184 | - } catch ( StatementGuidParsingException $e ) { |
|
184 | + } catch (StatementGuidParsingException $e) { |
|
185 | 185 | $this->apiErrorReporter->dieError( |
186 | 186 | "Invalid statement GUID: $constraintId", |
187 | 187 | 'invalid-guid', |
188 | 188 | 0, // default argument |
189 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
189 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
190 | 190 | ); |
191 | 191 | } |
192 | 192 | }, |
@@ -198,12 +198,12 @@ discard block |
||
198 | 198 | * @param PropertyId[] $propertyIds |
199 | 199 | * @param ApiResult $result |
200 | 200 | */ |
201 | - private function checkPropertyIds( array $propertyIds, ApiResult $result ) { |
|
202 | - foreach ( $propertyIds as $propertyId ) { |
|
203 | - $result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' ); |
|
204 | - $allConstraintExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnPropertyId( $propertyId ); |
|
205 | - foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) { |
|
206 | - $this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result ); |
|
201 | + private function checkPropertyIds(array $propertyIds, ApiResult $result) { |
|
202 | + foreach ($propertyIds as $propertyId) { |
|
203 | + $result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc'); |
|
204 | + $allConstraintExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnPropertyId($propertyId); |
|
205 | + foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) { |
|
206 | + $this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | } |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | * @param string[] $constraintIds |
213 | 213 | * @param ApiResult $result |
214 | 214 | */ |
215 | - private function checkConstraintIds( array $constraintIds, ApiResult $result ) { |
|
216 | - foreach ( $constraintIds as $constraintId ) { |
|
217 | - if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) { |
|
215 | + private function checkConstraintIds(array $constraintIds, ApiResult $result) { |
|
216 | + foreach ($constraintIds as $constraintId) { |
|
217 | + if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) { |
|
218 | 218 | // already checked as part of checkPropertyIds() |
219 | 219 | continue; |
220 | 220 | } |
221 | - $constraintParameterExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnConstraintId( $constraintId ); |
|
222 | - $this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result ); |
|
221 | + $constraintParameterExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnConstraintId($constraintId); |
|
222 | + $this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
@@ -227,17 +227,17 @@ discard block |
||
227 | 227 | * @param PropertyId $propertyId |
228 | 228 | * @return string[] |
229 | 229 | */ |
230 | - private function getResultPathForPropertyId( PropertyId $propertyId ) { |
|
231 | - return [ $this->getModuleName(), $propertyId->getSerialization() ]; |
|
230 | + private function getResultPathForPropertyId(PropertyId $propertyId) { |
|
231 | + return [$this->getModuleName(), $propertyId->getSerialization()]; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
235 | 235 | * @param string $constraintId |
236 | 236 | * @return string[] |
237 | 237 | */ |
238 | - private function getResultPathForConstraintId( $constraintId ) { |
|
239 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
240 | - return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] ); |
|
238 | + private function getResultPathForConstraintId($constraintId) { |
|
239 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
240 | + return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -247,9 +247,9 @@ discard block |
||
247 | 247 | * @param ConstraintParameterException[]|null $constraintParameterExceptions |
248 | 248 | * @param ApiResult $result |
249 | 249 | */ |
250 | - private function addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, ApiResult $result ) { |
|
251 | - $path = $this->getResultPathForConstraintId( $constraintId ); |
|
252 | - if ( $constraintParameterExceptions === null ) { |
|
250 | + private function addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, ApiResult $result) { |
|
251 | + $path = $this->getResultPathForConstraintId($constraintId); |
|
252 | + if ($constraintParameterExceptions === null) { |
|
253 | 253 | $result->addValue( |
254 | 254 | $path, |
255 | 255 | self::KEY_STATUS, |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | $result->addValue( |
260 | 260 | $path, |
261 | 261 | self::KEY_STATUS, |
262 | - empty( $constraintParameterExceptions ) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY |
|
262 | + empty($constraintParameterExceptions) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY |
|
263 | 263 | ); |
264 | 264 | $result->addValue( |
265 | 265 | $path, |
266 | 266 | self::KEY_PROBLEMS, |
267 | - array_map( [ $this, 'formatConstraintParameterException' ], $constraintParameterExceptions ) |
|
267 | + array_map([$this, 'formatConstraintParameterException'], $constraintParameterExceptions) |
|
268 | 268 | ); |
269 | 269 | } |
270 | 270 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * @param ConstraintParameterException $e |
276 | 276 | * @return array |
277 | 277 | */ |
278 | - private function formatConstraintParameterException( ConstraintParameterException $e ) { |
|
278 | + private function formatConstraintParameterException(ConstraintParameterException $e) { |
|
279 | 279 | return [ |
280 | 280 | self::KEY_MESSAGE_HTML => $e->getMessage(), |
281 | 281 | ]; |
@@ -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 | } |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | * @throws ConstraintParameterException |
69 | 69 | * @return CheckResult |
70 | 70 | */ |
71 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
72 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
73 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
71 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
72 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
73 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $parameters = []; |
@@ -78,42 +78,42 @@ discard block |
||
78 | 78 | |
79 | 79 | $snak = $context->getSnak(); |
80 | 80 | |
81 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
81 | + if (!$snak instanceof PropertyValueSnak) { |
|
82 | 82 | // nothing to check |
83 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' ); |
|
83 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, ''); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | $dataValue = $snak->getDataValue(); |
87 | 87 | |
88 | - list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter( |
|
88 | + list($min, $max) = $this->constraintParameterParser->parseRangeParameter( |
|
89 | 89 | $constraintParameters, |
90 | 90 | $constraint->getConstraintTypeItemId(), |
91 | 91 | $dataValue->getType() |
92 | 92 | ); |
93 | 93 | $parameterKey = $dataValue->getType() === 'quantity' ? 'quantity' : 'date'; |
94 | - if ( $min !== null ) { |
|
95 | - $parameters['minimum_' . $parameterKey] = [ $min ]; |
|
94 | + if ($min !== null) { |
|
95 | + $parameters['minimum_'.$parameterKey] = [$min]; |
|
96 | 96 | } |
97 | - if ( $max !== null ) { |
|
98 | - $parameters['maximum_' . $parameterKey] = [ $max ]; |
|
97 | + if ($max !== null) { |
|
98 | + $parameters['maximum_'.$parameterKey] = [$max]; |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( $this->rangeCheckerHelper->getComparison( $min, $dataValue ) > 0 || |
|
102 | - $this->rangeCheckerHelper->getComparison( $dataValue, $max ) > 0 |
|
101 | + if ($this->rangeCheckerHelper->getComparison($min, $dataValue) > 0 || |
|
102 | + $this->rangeCheckerHelper->getComparison($dataValue, $max) > 0 |
|
103 | 103 | ) { |
104 | 104 | // at least one of $min, $max is set at this point, otherwise there could be no violation |
105 | 105 | $type = $dataValue->getType(); |
106 | - $openness = $min !== null ? ( $max !== null ? 'closed' : 'rightopen' ) : 'leftopen'; |
|
107 | - $message = wfMessage( "wbqc-violation-message-range-$type-$openness" ); |
|
106 | + $openness = $min !== null ? ($max !== null ? 'closed' : 'rightopen') : 'leftopen'; |
|
107 | + $message = wfMessage("wbqc-violation-message-range-$type-$openness"); |
|
108 | 108 | $message->rawParams( |
109 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ), |
|
110 | - $this->constraintParameterRenderer->formatDataValue( $dataValue, Role::OBJECT ) |
|
109 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE), |
|
110 | + $this->constraintParameterRenderer->formatDataValue($dataValue, Role::OBJECT) |
|
111 | 111 | ); |
112 | - if ( $min !== null ) { |
|
113 | - $message->rawParams( $this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) ); |
|
112 | + if ($min !== null) { |
|
113 | + $message->rawParams($this->constraintParameterRenderer->formatDataValue($min, Role::OBJECT)); |
|
114 | 114 | } |
115 | - if ( $max !== null ) { |
|
116 | - $message->rawParams( $this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) ); |
|
115 | + if ($max !== null) { |
|
116 | + $message->rawParams($this->constraintParameterRenderer->formatDataValue($max, Role::OBJECT)); |
|
117 | 117 | } |
118 | 118 | $message = $message->escaped(); |
119 | 119 | $status = CheckResult::STATUS_VIOLATION; |
@@ -122,22 +122,22 @@ discard block |
||
122 | 122 | $status = CheckResult::STATUS_COMPLIANCE; |
123 | 123 | } |
124 | 124 | |
125 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
125 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
126 | 126 | } |
127 | 127 | |
128 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
128 | + public function checkConstraintParameters(Constraint $constraint) { |
|
129 | 129 | $constraintParameters = $constraint->getConstraintParameters(); |
130 | 130 | $exceptions = []; |
131 | 131 | try { |
132 | 132 | // we don’t have a data value here, so get the type from the property instead |
133 | 133 | // (the distinction between data type and data value type is irrelevant for 'quantity' and 'time') |
134 | - $type = $this->propertyDataTypeLookup->getDataTypeIdForProperty( $constraint->getPropertyId() ); |
|
134 | + $type = $this->propertyDataTypeLookup->getDataTypeIdForProperty($constraint->getPropertyId()); |
|
135 | 135 | $this->constraintParameterParser->parseRangeParameter( |
136 | 136 | $constraintParameters, |
137 | 137 | $constraint->getConstraintTypeItemId(), |
138 | 138 | $type |
139 | 139 | ); |
140 | - } catch ( ConstraintParameterException $e ) { |
|
140 | + } catch (ConstraintParameterException $e) { |
|
141 | 141 | $exceptions[] = $e; |
142 | 142 | } |
143 | 143 | return $exceptions; |
@@ -49,43 +49,43 @@ |
||
49 | 49 | * @throws ConstraintParameterException |
50 | 50 | * @return CheckResult |
51 | 51 | */ |
52 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
53 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
54 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
52 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
53 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
54 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $parameters = []; |
58 | 58 | $constraintParameters = $constraint->getConstraintParameters(); |
59 | 59 | |
60 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true ); |
|
60 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true); |
|
61 | 61 | $parameters['item'] = $items; |
62 | 62 | |
63 | 63 | $snak = $context->getSnak(); |
64 | 64 | |
65 | - $message = wfMessage( 'wbqc-violation-message-one-of' ); |
|
66 | - $message->rawParams( $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) ); |
|
67 | - $message->numParams( count( $items ) ); |
|
68 | - $message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) ); |
|
65 | + $message = wfMessage('wbqc-violation-message-one-of'); |
|
66 | + $message->rawParams($this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)); |
|
67 | + $message->numParams(count($items)); |
|
68 | + $message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT)); |
|
69 | 69 | $message = $message->escaped(); |
70 | 70 | $status = CheckResult::STATUS_VIOLATION; |
71 | 71 | |
72 | - foreach ( $items as $item ) { |
|
73 | - if ( $item->matchesSnak( $snak ) ) { |
|
72 | + foreach ($items as $item) { |
|
73 | + if ($item->matchesSnak($snak)) { |
|
74 | 74 | $message = ''; |
75 | 75 | $status = CheckResult::STATUS_COMPLIANCE; |
76 | 76 | break; |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
80 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
81 | 81 | } |
82 | 82 | |
83 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
83 | + public function checkConstraintParameters(Constraint $constraint) { |
|
84 | 84 | $constraintParameters = $constraint->getConstraintParameters(); |
85 | 85 | $exceptions = []; |
86 | 86 | try { |
87 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true ); |
|
88 | - } catch ( ConstraintParameterException $e ) { |
|
87 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true); |
|
88 | + } catch (ConstraintParameterException $e) { |
|
89 | 89 | $exceptions[] = $e; |
90 | 90 | } |
91 | 91 | return $exceptions; |
@@ -71,25 +71,25 @@ discard block |
||
71 | 71 | * @throws ConstraintParameterException |
72 | 72 | * @return CheckResult |
73 | 73 | */ |
74 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
75 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
76 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
74 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
75 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
76 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $parameters = []; |
80 | 80 | $constraintParameters = $constraint->getConstraintParameters(); |
81 | 81 | |
82 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
83 | - $parameters['property'] = [ $propertyId ]; |
|
82 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
83 | + $parameters['property'] = [$propertyId]; |
|
84 | 84 | |
85 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
85 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
86 | 86 | $parameters['items'] = $items; |
87 | 87 | |
88 | 88 | $snak = $context->getSnak(); |
89 | 89 | |
90 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
90 | + if (!$snak instanceof PropertyValueSnak) { |
|
91 | 91 | // nothing to check |
92 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' ); |
|
92 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, ''); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $dataValue = $snak->getDataValue(); |
@@ -98,22 +98,22 @@ discard block |
||
98 | 98 | * error handling: |
99 | 99 | * type of $dataValue for properties with 'Target required claim' constraint has to be 'wikibase-entityid' |
100 | 100 | */ |
101 | - if ( $dataValue->getType() !== 'wikibase-entityid' ) { |
|
102 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
101 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
102 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
103 | 103 | ->rawParams( |
104 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
104 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
105 | 105 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
106 | 106 | ) |
107 | 107 | ->escaped(); |
108 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
108 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
109 | 109 | } |
110 | 110 | /** @var EntityIdValue $dataValue */ |
111 | 111 | |
112 | 112 | $targetEntityId = $dataValue->getEntityId(); |
113 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
114 | - if ( $targetEntity === null ) { |
|
115 | - $message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped(); |
|
116 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
113 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
114 | + if ($targetEntity === null) { |
|
115 | + $message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped(); |
|
116 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /* |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * a) a property only |
122 | 122 | * b) a property and a number of items (each combination forming an individual claim) |
123 | 123 | */ |
124 | - if ( $items === [] ) { |
|
124 | + if ($items === []) { |
|
125 | 125 | $requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty( |
126 | 126 | $targetEntity->getStatements(), |
127 | 127 | $propertyId |
@@ -134,37 +134,37 @@ discard block |
||
134 | 134 | ); |
135 | 135 | } |
136 | 136 | |
137 | - if ( $requiredStatement !== null ) { |
|
137 | + if ($requiredStatement !== null) { |
|
138 | 138 | $status = CheckResult::STATUS_COMPLIANCE; |
139 | 139 | $message = ''; |
140 | 140 | } else { |
141 | 141 | $status = CheckResult::STATUS_VIOLATION; |
142 | - $message = wfMessage( 'wbqc-violation-message-target-required-claim' ); |
|
142 | + $message = wfMessage('wbqc-violation-message-target-required-claim'); |
|
143 | 143 | $message->rawParams( |
144 | - $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ), |
|
145 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ) |
|
144 | + $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT), |
|
145 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE) |
|
146 | 146 | ); |
147 | - $message->numParams( count( $items ) ); |
|
148 | - $message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) ); |
|
147 | + $message->numParams(count($items)); |
|
148 | + $message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT)); |
|
149 | 149 | $message = $message->escaped(); |
150 | 150 | } |
151 | 151 | |
152 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
153 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
154 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
152 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
153 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
154 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
155 | 155 | } |
156 | 156 | |
157 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
157 | + public function checkConstraintParameters(Constraint $constraint) { |
|
158 | 158 | $constraintParameters = $constraint->getConstraintParameters(); |
159 | 159 | $exceptions = []; |
160 | 160 | try { |
161 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
162 | - } catch ( ConstraintParameterException $e ) { |
|
161 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
162 | + } catch (ConstraintParameterException $e) { |
|
163 | 163 | $exceptions[] = $e; |
164 | 164 | } |
165 | 165 | try { |
166 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
167 | - } catch ( ConstraintParameterException $e ) { |
|
166 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
167 | + } catch (ConstraintParameterException $e) { |
|
168 | 168 | $exceptions[] = $e; |
169 | 169 | } |
170 | 170 | return $exceptions; |