@@ -77,15 +77,15 @@ discard block |
||
77 | 77 | * @param array $parameters |
78 | 78 | * @throws ConstraintParameterException |
79 | 79 | */ |
80 | - public function checkError( array $parameters ) { |
|
81 | - if ( array_key_exists( '@error', $parameters ) ) { |
|
80 | + public function checkError(array $parameters) { |
|
81 | + if (array_key_exists('@error', $parameters)) { |
|
82 | 82 | $error = $parameters['@error']; |
83 | - if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) { |
|
83 | + if (array_key_exists('toolong', $error) && $error['toolong']) { |
|
84 | 84 | $msg = 'wbqc-violation-message-parameters-error-toolong'; |
85 | 85 | } else { |
86 | 86 | $msg = 'wbqc-violation-message-parameters-error-unknown'; |
87 | 87 | } |
88 | - throw new ConstraintParameterException( wfMessage( $msg )->escaped() ); |
|
88 | + throw new ConstraintParameterException(wfMessage($msg)->escaped()); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * @param string $parameterId |
96 | 96 | * @throws ConstraintParameterException |
97 | 97 | */ |
98 | - private function requireSingleParameter( array $parameters, $parameterId ) { |
|
99 | - if ( count( $parameters[$parameterId] ) !== 1 ) { |
|
98 | + private function requireSingleParameter(array $parameters, $parameterId) { |
|
99 | + if (count($parameters[$parameterId]) !== 1) { |
|
100 | 100 | throw new ConstraintParameterException( |
101 | - wfMessage( 'wbqc-violation-message-parameter-single' ) |
|
102 | - ->rawParams( $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) ) |
|
101 | + wfMessage('wbqc-violation-message-parameter-single') |
|
102 | + ->rawParams($this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY)) |
|
103 | 103 | ->escaped() |
104 | 104 | ); |
105 | 105 | } |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | * @return void |
113 | 113 | * @throws ConstraintParameterException |
114 | 114 | */ |
115 | - private function requireValueParameter( Snak $snak, $parameterId ) { |
|
116 | - if ( !( $snak instanceof PropertyValueSnak ) ) { |
|
115 | + private function requireValueParameter(Snak $snak, $parameterId) { |
|
116 | + if (!($snak instanceof PropertyValueSnak)) { |
|
117 | 117 | throw new ConstraintParameterException( |
118 | - wfMessage( 'wbqc-violation-message-parameter-value' ) |
|
119 | - ->rawParams( $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) ) |
|
118 | + wfMessage('wbqc-violation-message-parameter-value') |
|
119 | + ->rawParams($this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY)) |
|
120 | 120 | ->escaped() |
121 | 121 | ); |
122 | 122 | } |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | * @throws ConstraintParameterException |
130 | 130 | * @return EntityId |
131 | 131 | */ |
132 | - private function parseEntityIdParameter( array $snakSerialization, $parameterId ) { |
|
133 | - $snak = $this->snakDeserializer->deserialize( $snakSerialization ); |
|
134 | - $this->requireValueParameter( $snak, $parameterId ); |
|
132 | + private function parseEntityIdParameter(array $snakSerialization, $parameterId) { |
|
133 | + $snak = $this->snakDeserializer->deserialize($snakSerialization); |
|
134 | + $this->requireValueParameter($snak, $parameterId); |
|
135 | 135 | $value = $snak->getDataValue(); |
136 | - if ( $value instanceof EntityIdValue ) { |
|
136 | + if ($value instanceof EntityIdValue) { |
|
137 | 137 | return $value->getEntityId(); |
138 | 138 | } else { |
139 | 139 | throw new ConstraintParameterException( |
140 | - wfMessage( 'wbqc-violation-message-parameter-entity' ) |
|
140 | + wfMessage('wbqc-violation-message-parameter-entity') |
|
141 | 141 | ->rawParams( |
142 | - $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ), |
|
143 | - $this->constraintParameterRenderer->formatDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE ) |
|
142 | + $this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY), |
|
143 | + $this->constraintParameterRenderer->formatDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE) |
|
144 | 144 | ) |
145 | 145 | ->escaped() |
146 | 146 | ); |
@@ -153,21 +153,21 @@ discard block |
||
153 | 153 | * @throws ConstraintParameterException if the parameter is invalid or missing |
154 | 154 | * @return string[] class entity ID serializations |
155 | 155 | */ |
156 | - public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) { |
|
157 | - $this->checkError( $constraintParameters ); |
|
158 | - $classId = $this->config->get( 'WBQualityConstraintsClassId' ); |
|
159 | - if ( !array_key_exists( $classId, $constraintParameters ) ) { |
|
156 | + public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) { |
|
157 | + $this->checkError($constraintParameters); |
|
158 | + $classId = $this->config->get('WBQualityConstraintsClassId'); |
|
159 | + if (!array_key_exists($classId, $constraintParameters)) { |
|
160 | 160 | throw new ConstraintParameterException( |
161 | - wfMessage( 'wbqc-violation-message-parameter-needed' ) |
|
162 | - ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) ) |
|
163 | - ->rawParams( $this->constraintParameterRenderer->formatPropertyId( $classId, Role::CONSTRAINT_PARAMETER_PROPERTY ) ) |
|
161 | + wfMessage('wbqc-violation-message-parameter-needed') |
|
162 | + ->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM)) |
|
163 | + ->rawParams($this->constraintParameterRenderer->formatPropertyId($classId, Role::CONSTRAINT_PARAMETER_PROPERTY)) |
|
164 | 164 | ->escaped() |
165 | 165 | ); |
166 | 166 | } |
167 | 167 | |
168 | 168 | $classes = []; |
169 | - foreach ( $constraintParameters[$classId] as $class ) { |
|
170 | - $classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization(); |
|
169 | + foreach ($constraintParameters[$classId] as $class) { |
|
170 | + $classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization(); |
|
171 | 171 | } |
172 | 172 | return $classes; |
173 | 173 | } |
@@ -178,24 +178,24 @@ discard block |
||
178 | 178 | * @throws ConstraintParameterException if the parameter is invalid or missing |
179 | 179 | * @return string 'instance', 'subclass', or 'instanceOrSubclass' |
180 | 180 | */ |
181 | - public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) { |
|
182 | - $this->checkError( $constraintParameters ); |
|
183 | - $relationId = $this->config->get( 'WBQualityConstraintsRelationId' ); |
|
184 | - if ( !array_key_exists( $relationId, $constraintParameters ) ) { |
|
181 | + public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) { |
|
182 | + $this->checkError($constraintParameters); |
|
183 | + $relationId = $this->config->get('WBQualityConstraintsRelationId'); |
|
184 | + if (!array_key_exists($relationId, $constraintParameters)) { |
|
185 | 185 | throw new ConstraintParameterException( |
186 | - wfMessage( 'wbqc-violation-message-parameter-needed' ) |
|
187 | - ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) ) |
|
188 | - ->rawParams( $this->constraintParameterRenderer->formatPropertyId( $relationId, Role::CONSTRAINT_PARAMETER_PROPERTY ) ) |
|
186 | + wfMessage('wbqc-violation-message-parameter-needed') |
|
187 | + ->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM)) |
|
188 | + ->rawParams($this->constraintParameterRenderer->formatPropertyId($relationId, Role::CONSTRAINT_PARAMETER_PROPERTY)) |
|
189 | 189 | ->escaped() |
190 | 190 | ); |
191 | 191 | } |
192 | 192 | |
193 | - $this->requireSingleParameter( $constraintParameters, $relationId ); |
|
194 | - $relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId ); |
|
195 | - $instanceId = $this->config->get( 'WBQualityConstraintsInstanceOfRelationId' ); |
|
196 | - $subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfRelationId' ); |
|
197 | - $instanceOrSubclassId = $this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' ); |
|
198 | - switch ( $relationEntityId ) { |
|
193 | + $this->requireSingleParameter($constraintParameters, $relationId); |
|
194 | + $relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId); |
|
195 | + $instanceId = $this->config->get('WBQualityConstraintsInstanceOfRelationId'); |
|
196 | + $subclassId = $this->config->get('WBQualityConstraintsSubclassOfRelationId'); |
|
197 | + $instanceOrSubclassId = $this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId'); |
|
198 | + switch ($relationEntityId) { |
|
199 | 199 | case $instanceId: |
200 | 200 | return 'instance'; |
201 | 201 | case $subclassId: |
@@ -204,13 +204,13 @@ discard block |
||
204 | 204 | return 'instanceOrSubclass'; |
205 | 205 | default: |
206 | 206 | throw new ConstraintParameterException( |
207 | - wfMessage( 'wbqc-violation-message-parameter-oneof' ) |
|
208 | - ->rawParams( $this->constraintParameterRenderer->formatPropertyId( $relationId, Role::CONSTRAINT_PARAMETER_PROPERTY ) ) |
|
209 | - ->numParams( 3 ) |
|
210 | - ->rawParams( $this->constraintParameterRenderer->formatItemIdList( |
|
211 | - [ $instanceId, $subclassId, $instanceOrSubclassId ], |
|
207 | + wfMessage('wbqc-violation-message-parameter-oneof') |
|
208 | + ->rawParams($this->constraintParameterRenderer->formatPropertyId($relationId, Role::CONSTRAINT_PARAMETER_PROPERTY)) |
|
209 | + ->numParams(3) |
|
210 | + ->rawParams($this->constraintParameterRenderer->formatItemIdList( |
|
211 | + [$instanceId, $subclassId, $instanceOrSubclassId], |
|
212 | 212 | Role::CONSTRAINT_PARAMETER_VALUE |
213 | - ) ) |
|
213 | + )) |
|
214 | 214 | ->escaped() |
215 | 215 | ); |
216 | 216 | } |
@@ -223,21 +223,21 @@ discard block |
||
223 | 223 | * @throws ConstraintParameterException |
224 | 224 | * @return PropertyId |
225 | 225 | */ |
226 | - private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) { |
|
227 | - $snak = $this->snakDeserializer->deserialize( $snakSerialization ); |
|
228 | - $this->requireValueParameter( $snak, $parameterId ); |
|
226 | + private function parsePropertyIdParameter(array $snakSerialization, $parameterId) { |
|
227 | + $snak = $this->snakDeserializer->deserialize($snakSerialization); |
|
228 | + $this->requireValueParameter($snak, $parameterId); |
|
229 | 229 | $value = $snak->getDataValue(); |
230 | - if ( $value instanceof EntityIdValue ) { |
|
230 | + if ($value instanceof EntityIdValue) { |
|
231 | 231 | $id = $value->getEntityId(); |
232 | - if ( $id instanceof PropertyId ) { |
|
232 | + if ($id instanceof PropertyId) { |
|
233 | 233 | return $id; |
234 | 234 | } |
235 | 235 | } |
236 | 236 | throw new ConstraintParameterException( |
237 | - wfMessage( 'wbqc-violation-message-parameter-property' ) |
|
237 | + wfMessage('wbqc-violation-message-parameter-property') |
|
238 | 238 | ->rawParams( |
239 | - $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ), |
|
240 | - $this->constraintParameterRenderer->formatDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE ) |
|
239 | + $this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY), |
|
240 | + $this->constraintParameterRenderer->formatDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE) |
|
241 | 241 | ) |
242 | 242 | ->escaped() |
243 | 243 | ); |
@@ -250,34 +250,34 @@ discard block |
||
250 | 250 | * @throws ConstraintParameterException if the parameter is invalid or missing |
251 | 251 | * @return PropertyId |
252 | 252 | */ |
253 | - public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) { |
|
254 | - $this->checkError( $constraintParameters ); |
|
255 | - $propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' ); |
|
256 | - if ( !array_key_exists( $propertyId, $constraintParameters ) ) { |
|
253 | + public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) { |
|
254 | + $this->checkError($constraintParameters); |
|
255 | + $propertyId = $this->config->get('WBQualityConstraintsPropertyId'); |
|
256 | + if (!array_key_exists($propertyId, $constraintParameters)) { |
|
257 | 257 | throw new ConstraintParameterException( |
258 | - wfMessage( 'wbqc-violation-message-parameter-needed' ) |
|
259 | - ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) ) |
|
260 | - ->rawParams( $this->constraintParameterRenderer->formatPropertyId( $propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY ) ) |
|
258 | + wfMessage('wbqc-violation-message-parameter-needed') |
|
259 | + ->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM)) |
|
260 | + ->rawParams($this->constraintParameterRenderer->formatPropertyId($propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY)) |
|
261 | 261 | ->escaped() |
262 | 262 | ); |
263 | 263 | } |
264 | 264 | |
265 | - $this->requireSingleParameter( $constraintParameters, $propertyId ); |
|
266 | - return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId ); |
|
265 | + $this->requireSingleParameter($constraintParameters, $propertyId); |
|
266 | + return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId); |
|
267 | 267 | } |
268 | 268 | |
269 | - private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) { |
|
269 | + private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) { |
|
270 | 270 | $dataValue = $snak->getDataValue(); |
271 | - if ( $dataValue instanceof EntityIdValue && |
|
271 | + if ($dataValue instanceof EntityIdValue && |
|
272 | 272 | $dataValue->getEntityId() instanceof ItemId |
273 | 273 | ) { |
274 | - return ItemIdSnakValue::fromItemId( $dataValue->getEntityId() ); |
|
274 | + return ItemIdSnakValue::fromItemId($dataValue->getEntityId()); |
|
275 | 275 | } else { |
276 | 276 | throw new ConstraintParameterException( |
277 | - wfMessage( 'wbqc-violation-message-parameter-item' ) |
|
277 | + wfMessage('wbqc-violation-message-parameter-item') |
|
278 | 278 | ->rawParams( |
279 | - $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ), |
|
280 | - $this->constraintParameterRenderer->formatDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE ) |
|
279 | + $this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY), |
|
280 | + $this->constraintParameterRenderer->formatDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE) |
|
281 | 281 | ) |
282 | 282 | ->escaped() |
283 | 283 | ); |
@@ -291,15 +291,15 @@ discard block |
||
291 | 291 | * @throws ConstraintParameterException if the parameter is invalid or missing |
292 | 292 | * @return ItemIdSnakValue[] array of values |
293 | 293 | */ |
294 | - public function parseItemsParameter( array $constraintParameters, $constraintTypeItemId, $required ) { |
|
295 | - $this->checkError( $constraintParameters ); |
|
296 | - $qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' ); |
|
297 | - if ( !array_key_exists( $qualifierId, $constraintParameters ) ) { |
|
298 | - if ( $required ) { |
|
294 | + public function parseItemsParameter(array $constraintParameters, $constraintTypeItemId, $required) { |
|
295 | + $this->checkError($constraintParameters); |
|
296 | + $qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId'); |
|
297 | + if (!array_key_exists($qualifierId, $constraintParameters)) { |
|
298 | + if ($required) { |
|
299 | 299 | throw new ConstraintParameterException( |
300 | - wfMessage( 'wbqc-violation-message-parameter-needed' ) |
|
301 | - ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) ) |
|
302 | - ->rawParams( $this->constraintParameterRenderer->formatPropertyId( $qualifierId, Role::CONSTRAINT_PARAMETER_PROPERTY ) ) |
|
300 | + wfMessage('wbqc-violation-message-parameter-needed') |
|
301 | + ->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM)) |
|
302 | + ->rawParams($this->constraintParameterRenderer->formatPropertyId($qualifierId, Role::CONSTRAINT_PARAMETER_PROPERTY)) |
|
303 | 303 | ->escaped() |
304 | 304 | ); |
305 | 305 | } else { |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | } |
309 | 309 | |
310 | 310 | $values = []; |
311 | - foreach ( $constraintParameters[$qualifierId] as $parameter ) { |
|
312 | - $snak = $this->snakDeserializer->deserialize( $parameter ); |
|
313 | - switch ( true ) { |
|
311 | + foreach ($constraintParameters[$qualifierId] as $parameter) { |
|
312 | + $snak = $this->snakDeserializer->deserialize($parameter); |
|
313 | + switch (true) { |
|
314 | 314 | case $snak instanceof PropertyValueSnak: |
315 | - $values[] = $this->parseItemIdParameter( $snak, $qualifierId ); |
|
315 | + $values[] = $this->parseItemIdParameter($snak, $qualifierId); |
|
316 | 316 | break; |
317 | 317 | case $snak instanceof PropertySomeValueSnak: |
318 | 318 | $values[] = ItemIdSnakValue::someValue(); |
@@ -331,28 +331,28 @@ discard block |
||
331 | 331 | * @throws ConstraintParameterException if the parameter is invalid or missing |
332 | 332 | * @return PropertyId[] |
333 | 333 | */ |
334 | - public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) { |
|
335 | - $this->checkError( $constraintParameters ); |
|
336 | - $propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' ); |
|
337 | - if ( !array_key_exists( $propertyId, $constraintParameters ) ) { |
|
334 | + public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) { |
|
335 | + $this->checkError($constraintParameters); |
|
336 | + $propertyId = $this->config->get('WBQualityConstraintsPropertyId'); |
|
337 | + if (!array_key_exists($propertyId, $constraintParameters)) { |
|
338 | 338 | throw new ConstraintParameterException( |
339 | - wfMessage( 'wbqc-violation-message-parameter-needed' ) |
|
340 | - ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) ) |
|
341 | - ->rawParams( $this->constraintParameterRenderer->formatPropertyId( $propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY ) ) |
|
339 | + wfMessage('wbqc-violation-message-parameter-needed') |
|
340 | + ->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM)) |
|
341 | + ->rawParams($this->constraintParameterRenderer->formatPropertyId($propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY)) |
|
342 | 342 | ->escaped() |
343 | 343 | ); |
344 | 344 | } |
345 | 345 | |
346 | 346 | $parameters = $constraintParameters[$propertyId]; |
347 | - if ( count( $parameters ) === 1 && |
|
348 | - $this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak |
|
347 | + if (count($parameters) === 1 && |
|
348 | + $this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak |
|
349 | 349 | ) { |
350 | 350 | return []; |
351 | 351 | } |
352 | 352 | |
353 | 353 | $properties = []; |
354 | - foreach ( $parameters as $parameter ) { |
|
355 | - $properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId ); |
|
354 | + foreach ($parameters as $parameter) { |
|
355 | + $properties[] = $this->parsePropertyIdParameter($parameter, $propertyId); |
|
356 | 356 | } |
357 | 357 | return $properties; |
358 | 358 | } |
@@ -363,16 +363,16 @@ discard block |
||
363 | 363 | * @throws ConstraintParameterException |
364 | 364 | * @return DataValue|null |
365 | 365 | */ |
366 | - private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) { |
|
367 | - $snak = $this->snakDeserializer->deserialize( $snakSerialization ); |
|
368 | - if ( $snak instanceof PropertyValueSnak ) { |
|
366 | + private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) { |
|
367 | + $snak = $this->snakDeserializer->deserialize($snakSerialization); |
|
368 | + if ($snak instanceof PropertyValueSnak) { |
|
369 | 369 | return $snak->getDataValue(); |
370 | - } elseif ( $snak instanceof PropertyNoValueSnak ) { |
|
370 | + } elseif ($snak instanceof PropertyNoValueSnak) { |
|
371 | 371 | return null; |
372 | 372 | } else { |
373 | 373 | throw new ConstraintParameterException( |
374 | - wfMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) |
|
375 | - ->rawParams( $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) ) |
|
374 | + wfMessage('wbqc-violation-message-parameter-value-or-novalue') |
|
375 | + ->rawParams($this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY)) |
|
376 | 376 | ->escaped() |
377 | 377 | ); |
378 | 378 | } |
@@ -383,13 +383,13 @@ discard block |
||
383 | 383 | * @param string $parameterId |
384 | 384 | * @return DataValue|null |
385 | 385 | */ |
386 | - private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) { |
|
386 | + private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) { |
|
387 | 387 | try { |
388 | - return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId ); |
|
389 | - } catch ( ConstraintParameterException $e ) { |
|
388 | + return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId); |
|
389 | + } catch (ConstraintParameterException $e) { |
|
390 | 390 | // unknown value means “now” |
391 | - $timeParser = ( new TimeParserFactory() )->getTimeParser(); |
|
392 | - return $timeParser->parse( gmdate( '+Y-m-d\T00:00:00\Z' ) ); |
|
391 | + $timeParser = (new TimeParserFactory())->getTimeParser(); |
|
392 | + return $timeParser->parse(gmdate('+Y-m-d\T00:00:00\Z')); |
|
393 | 393 | } |
394 | 394 | } |
395 | 395 | |
@@ -400,14 +400,14 @@ discard block |
||
400 | 400 | * @param string $unit |
401 | 401 | * @return bool |
402 | 402 | */ |
403 | - private function exactlyOneQuantityWithUnit( DataValue $min = null, DataValue $max = null, $unit ) { |
|
404 | - if ( !( $min instanceof UnboundedQuantityValue ) || |
|
405 | - !( $max instanceof UnboundedQuantityValue ) |
|
403 | + private function exactlyOneQuantityWithUnit(DataValue $min = null, DataValue $max = null, $unit) { |
|
404 | + if (!($min instanceof UnboundedQuantityValue) || |
|
405 | + !($max instanceof UnboundedQuantityValue) |
|
406 | 406 | ) { |
407 | 407 | return false; |
408 | 408 | } |
409 | 409 | |
410 | - return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit ); |
|
410 | + return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit); |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | /** |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | * @throws ConstraintParameterException if the parameter is invalid or missing |
419 | 419 | * @return DataValue[] a pair of two data values, either of which may be null to signify an open range |
420 | 420 | */ |
421 | - public function parseRangeParameter( array $constraintParameters, $constraintTypeItemId, $type ) { |
|
422 | - $this->checkError( $constraintParameters ); |
|
423 | - switch ( $type ) { |
|
421 | + public function parseRangeParameter(array $constraintParameters, $constraintTypeItemId, $type) { |
|
422 | + $this->checkError($constraintParameters); |
|
423 | + switch ($type) { |
|
424 | 424 | case 'quantity': |
425 | 425 | $configKey = 'Quantity'; |
426 | 426 | break; |
@@ -429,47 +429,47 @@ discard block |
||
429 | 429 | break; |
430 | 430 | default: |
431 | 431 | throw new ConstraintParameterException( |
432 | - wfMessage( 'wbqc-violation-message-value-needed-of-types-2' ) |
|
432 | + wfMessage('wbqc-violation-message-value-needed-of-types-2') |
|
433 | 433 | ->rawParams( |
434 | - $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ), |
|
435 | - wfMessage( 'datatypes-type-quantity' )->escaped(), |
|
436 | - wfMessage( 'datatypes-type-time' )->escaped() |
|
434 | + $this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM), |
|
435 | + wfMessage('datatypes-type-quantity')->escaped(), |
|
436 | + wfMessage('datatypes-type-time')->escaped() |
|
437 | 437 | ) |
438 | 438 | ->escaped() |
439 | 439 | ); |
440 | 440 | } |
441 | - $minimumId = $this->config->get( 'WBQualityConstraintsMinimum' . $configKey . 'Id' ); |
|
442 | - $maximumId = $this->config->get( 'WBQualityConstraintsMaximum' . $configKey . 'Id' ); |
|
443 | - if ( !array_key_exists( $minimumId, $constraintParameters ) || |
|
444 | - !array_key_exists( $maximumId, $constraintParameters ) |
|
441 | + $minimumId = $this->config->get('WBQualityConstraintsMinimum'.$configKey.'Id'); |
|
442 | + $maximumId = $this->config->get('WBQualityConstraintsMaximum'.$configKey.'Id'); |
|
443 | + if (!array_key_exists($minimumId, $constraintParameters) || |
|
444 | + !array_key_exists($maximumId, $constraintParameters) |
|
445 | 445 | ) { |
446 | 446 | throw new ConstraintParameterException( |
447 | - wfMessage( 'wbqc-violation-message-range-parameters-needed' ) |
|
447 | + wfMessage('wbqc-violation-message-range-parameters-needed') |
|
448 | 448 | ->rawParams( |
449 | - wfMessage( 'datatypes-type-' . $type )->escaped(), |
|
450 | - $this->constraintParameterRenderer->formatPropertyId( $minimumId, Role::CONSTRAINT_PARAMETER_PROPERTY ), |
|
451 | - $this->constraintParameterRenderer->formatPropertyId( $maximumId, Role::CONSTRAINT_PARAMETER_PROPERTY ) |
|
449 | + wfMessage('datatypes-type-'.$type)->escaped(), |
|
450 | + $this->constraintParameterRenderer->formatPropertyId($minimumId, Role::CONSTRAINT_PARAMETER_PROPERTY), |
|
451 | + $this->constraintParameterRenderer->formatPropertyId($maximumId, Role::CONSTRAINT_PARAMETER_PROPERTY) |
|
452 | 452 | ) |
453 | - ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) ) |
|
453 | + ->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM)) |
|
454 | 454 | ->escaped() |
455 | 455 | ); |
456 | 456 | } |
457 | 457 | |
458 | - $this->requireSingleParameter( $constraintParameters, $minimumId ); |
|
459 | - $this->requireSingleParameter( $constraintParameters, $maximumId ); |
|
458 | + $this->requireSingleParameter($constraintParameters, $minimumId); |
|
459 | + $this->requireSingleParameter($constraintParameters, $maximumId); |
|
460 | 460 | $parseFunction = $configKey === 'Date' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter'; |
461 | - $min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId ); |
|
462 | - $max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId ); |
|
461 | + $min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId); |
|
462 | + $max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId); |
|
463 | 463 | |
464 | - $yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' ); |
|
465 | - if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) { |
|
464 | + $yearUnit = $this->config->get('WBQualityConstraintsYearUnit'); |
|
465 | + if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) { |
|
466 | 466 | throw new ConstraintParameterException( |
467 | - wfMessage( 'wbqc-violation-message-range-parameters-one-year' ) |
|
467 | + wfMessage('wbqc-violation-message-range-parameters-one-year') |
|
468 | 468 | ->escaped() |
469 | 469 | ); |
470 | 470 | } |
471 | 471 | |
472 | - return [ $min, $max ]; |
|
472 | + return [$min, $max]; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -479,18 +479,18 @@ discard block |
||
479 | 479 | * @throws ConstraintParameterException |
480 | 480 | * @return string |
481 | 481 | */ |
482 | - private function parseStringParameter( array $snakSerialization, $parameterId ) { |
|
483 | - $snak = $this->snakDeserializer->deserialize( $snakSerialization ); |
|
484 | - $this->requireValueParameter( $snak, $parameterId ); |
|
482 | + private function parseStringParameter(array $snakSerialization, $parameterId) { |
|
483 | + $snak = $this->snakDeserializer->deserialize($snakSerialization); |
|
484 | + $this->requireValueParameter($snak, $parameterId); |
|
485 | 485 | $value = $snak->getDataValue(); |
486 | - if ( $value instanceof StringValue ) { |
|
486 | + if ($value instanceof StringValue) { |
|
487 | 487 | return $value->getValue(); |
488 | 488 | } else { |
489 | 489 | throw new ConstraintParameterException( |
490 | - wfMessage( 'wbqc-violation-message-parameter-string' ) |
|
490 | + wfMessage('wbqc-violation-message-parameter-string') |
|
491 | 491 | ->rawParams( |
492 | - $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ), |
|
493 | - $this->constraintParameterRenderer->formatDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE ) |
|
492 | + $this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY), |
|
493 | + $this->constraintParameterRenderer->formatDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE) |
|
494 | 494 | ) |
495 | 495 | ->escaped() |
496 | 496 | ); |
@@ -503,15 +503,15 @@ discard block |
||
503 | 503 | * @throws ConstraintParameterException if the parameter is invalid or missing |
504 | 504 | * @return string |
505 | 505 | */ |
506 | - public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) { |
|
507 | - $this->checkError( $constraintParameters ); |
|
508 | - $namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' ); |
|
509 | - if ( !array_key_exists( $namespaceId, $constraintParameters ) ) { |
|
506 | + public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) { |
|
507 | + $this->checkError($constraintParameters); |
|
508 | + $namespaceId = $this->config->get('WBQualityConstraintsNamespaceId'); |
|
509 | + if (!array_key_exists($namespaceId, $constraintParameters)) { |
|
510 | 510 | return ''; |
511 | 511 | } |
512 | 512 | |
513 | - $this->requireSingleParameter( $constraintParameters, $namespaceId ); |
|
514 | - return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId ); |
|
513 | + $this->requireSingleParameter($constraintParameters, $namespaceId); |
|
514 | + return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
@@ -520,20 +520,20 @@ discard block |
||
520 | 520 | * @throws ConstraintParameterException if the parameter is invalid or missing |
521 | 521 | * @return string |
522 | 522 | */ |
523 | - public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) { |
|
524 | - $this->checkError( $constraintParameters ); |
|
525 | - $formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' ); |
|
526 | - if ( !array_key_exists( $formatId, $constraintParameters ) ) { |
|
523 | + public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) { |
|
524 | + $this->checkError($constraintParameters); |
|
525 | + $formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId'); |
|
526 | + if (!array_key_exists($formatId, $constraintParameters)) { |
|
527 | 527 | throw new ConstraintParameterException( |
528 | - wfMessage( 'wbqc-violation-message-parameter-needed' ) |
|
529 | - ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) ) |
|
530 | - ->rawParams( $this->constraintParameterRenderer->formatPropertyId( $formatId, Role::CONSTRAINT_PARAMETER_PROPERTY ) ) |
|
528 | + wfMessage('wbqc-violation-message-parameter-needed') |
|
529 | + ->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM)) |
|
530 | + ->rawParams($this->constraintParameterRenderer->formatPropertyId($formatId, Role::CONSTRAINT_PARAMETER_PROPERTY)) |
|
531 | 531 | ->escaped() |
532 | 532 | ); |
533 | 533 | } |
534 | 534 | |
535 | - $this->requireSingleParameter( $constraintParameters, $formatId ); |
|
536 | - return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId ); |
|
535 | + $this->requireSingleParameter($constraintParameters, $formatId); |
|
536 | + return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId); |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | /** |
@@ -541,16 +541,16 @@ discard block |
||
541 | 541 | * @throws ConstraintParameterException if the parameter is invalid |
542 | 542 | * @return EntityId[] |
543 | 543 | */ |
544 | - public function parseExceptionParameter( array $constraintParameters ) { |
|
545 | - $this->checkError( $constraintParameters ); |
|
546 | - $exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' ); |
|
547 | - if ( !array_key_exists( $exceptionId, $constraintParameters ) ) { |
|
544 | + public function parseExceptionParameter(array $constraintParameters) { |
|
545 | + $this->checkError($constraintParameters); |
|
546 | + $exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId'); |
|
547 | + if (!array_key_exists($exceptionId, $constraintParameters)) { |
|
548 | 548 | return []; |
549 | 549 | } |
550 | 550 | |
551 | 551 | return array_map( |
552 | - function( $snakSerialization ) use ( $exceptionId ) { |
|
553 | - return $this->parseEntityIdParameter( $snakSerialization, $exceptionId ); |
|
552 | + function($snakSerialization) use ($exceptionId) { |
|
553 | + return $this->parseEntityIdParameter($snakSerialization, $exceptionId); |
|
554 | 554 | }, |
555 | 555 | $constraintParameters[$exceptionId] |
556 | 556 | ); |
@@ -561,27 +561,27 @@ discard block |
||
561 | 561 | * @throws ConstraintParameterException if the parameter is invalid |
562 | 562 | * @return string|null 'mandatory' or null |
563 | 563 | */ |
564 | - public function parseConstraintStatusParameter( array $constraintParameters ) { |
|
565 | - $this->checkError( $constraintParameters ); |
|
566 | - $constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' ); |
|
567 | - if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) { |
|
564 | + public function parseConstraintStatusParameter(array $constraintParameters) { |
|
565 | + $this->checkError($constraintParameters); |
|
566 | + $constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId'); |
|
567 | + if (!array_key_exists($constraintStatusId, $constraintParameters)) { |
|
568 | 568 | return null; |
569 | 569 | } |
570 | 570 | |
571 | - $mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' ); |
|
572 | - $this->requireSingleParameter( $constraintParameters, $constraintStatusId ); |
|
573 | - $snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] ); |
|
574 | - $this->requireValueParameter( $snak, $constraintStatusId ); |
|
571 | + $mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId'); |
|
572 | + $this->requireSingleParameter($constraintParameters, $constraintStatusId); |
|
573 | + $snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]); |
|
574 | + $this->requireValueParameter($snak, $constraintStatusId); |
|
575 | 575 | $statusId = $snak->getDataValue()->getEntityId()->getSerialization(); |
576 | 576 | |
577 | - if ( $statusId === $mandatoryId ) { |
|
577 | + if ($statusId === $mandatoryId) { |
|
578 | 578 | return 'mandatory'; |
579 | 579 | } else { |
580 | 580 | throw new ConstraintParameterException( |
581 | - wfMessage( 'wbqc-violation-message-parameter-oneof' ) |
|
582 | - ->rawParams( $this->constraintParameterRenderer->formatPropertyId( $constraintStatusId, Role::CONSTRAINT_PARAMETER_PROPERTY ) ) |
|
583 | - ->numParams( 1 ) |
|
584 | - ->rawParams( $this->constraintParameterRenderer->formatItemIdList( [ $mandatoryId ], Role::CONSTRAINT_PARAMETER_VALUE ) ) |
|
581 | + wfMessage('wbqc-violation-message-parameter-oneof') |
|
582 | + ->rawParams($this->constraintParameterRenderer->formatPropertyId($constraintStatusId, Role::CONSTRAINT_PARAMETER_PROPERTY)) |
|
583 | + ->numParams(1) |
|
584 | + ->rawParams($this->constraintParameterRenderer->formatItemIdList([$mandatoryId], Role::CONSTRAINT_PARAMETER_VALUE)) |
|
585 | 585 | ->escaped() |
586 | 586 | ); |
587 | 587 | } |
@@ -594,13 +594,13 @@ discard block |
||
594 | 594 | * @return void |
595 | 595 | * @throws ConstraintParameterException |
596 | 596 | */ |
597 | - private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) { |
|
598 | - if ( !( $dataValue instanceof MonolingualTextValue ) ) { |
|
597 | + private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) { |
|
598 | + if (!($dataValue instanceof MonolingualTextValue)) { |
|
599 | 599 | throw new ConstraintParameterException( |
600 | - wfMessage( 'wbqc-violation-message-parameter-monolingualtext' ) |
|
600 | + wfMessage('wbqc-violation-message-parameter-monolingualtext') |
|
601 | 601 | ->rawParams( |
602 | - $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ), |
|
603 | - $this->constraintParameterRenderer->formatDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE ) |
|
602 | + $this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY), |
|
603 | + $this->constraintParameterRenderer->formatDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE) |
|
604 | 604 | ) |
605 | 605 | ->escaped() |
606 | 606 | ); |
@@ -615,26 +615,26 @@ discard block |
||
615 | 615 | * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts |
616 | 616 | * @return string[] |
617 | 617 | */ |
618 | - private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) { |
|
618 | + private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) { |
|
619 | 619 | $result = []; |
620 | 620 | |
621 | - foreach ( $snakSerializations as $snakSerialization ) { |
|
622 | - $snak = $this->snakDeserializer->deserialize( $snakSerialization ); |
|
623 | - $this->requireValueParameter( $snak, $parameterId ); |
|
621 | + foreach ($snakSerializations as $snakSerialization) { |
|
622 | + $snak = $this->snakDeserializer->deserialize($snakSerialization); |
|
623 | + $this->requireValueParameter($snak, $parameterId); |
|
624 | 624 | |
625 | 625 | $value = $snak->getDataValue(); |
626 | - $this->requireMonolingualTextParameter( $value, $parameterId ); |
|
626 | + $this->requireMonolingualTextParameter($value, $parameterId); |
|
627 | 627 | /** @var MonolingualTextValue $value */ |
628 | 628 | |
629 | 629 | $code = $value->getLanguageCode(); |
630 | - if ( array_key_exists( $code, $result ) ) { |
|
630 | + if (array_key_exists($code, $result)) { |
|
631 | 631 | throw new ConstraintParameterException( |
632 | - wfMessage( 'wbqc-violation-message-parameter-single-per-language' ) |
|
632 | + wfMessage('wbqc-violation-message-parameter-single-per-language') |
|
633 | 633 | ->rawParams( |
634 | - $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) |
|
634 | + $this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY) |
|
635 | 635 | ) |
636 | 636 | ->plaintextParams( |
637 | - Language::fetchLanguageName( $code ), |
|
637 | + Language::fetchLanguageName($code), |
|
638 | 638 | $code |
639 | 639 | ) |
640 | 640 | ->escaped() |
@@ -653,23 +653,23 @@ discard block |
||
653 | 653 | * @throws ConstraintParameterException if the parameter is invalid |
654 | 654 | * @return string|null |
655 | 655 | */ |
656 | - public function parseSyntaxClarificationParameter( array $constraintParameters, Language $language ) { |
|
657 | - $syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' ); |
|
656 | + public function parseSyntaxClarificationParameter(array $constraintParameters, Language $language) { |
|
657 | + $syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId'); |
|
658 | 658 | |
659 | - if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) { |
|
659 | + if (!array_key_exists($syntaxClarificationId, $constraintParameters)) { |
|
660 | 660 | return null; |
661 | 661 | } |
662 | 662 | |
663 | 663 | $languageCodes = $language->getFallbackLanguages(); |
664 | - array_unshift( $languageCodes, $language->getCode() ); |
|
664 | + array_unshift($languageCodes, $language->getCode()); |
|
665 | 665 | |
666 | 666 | $syntaxClarifications = $this->parseMultilingualTextParameter( |
667 | 667 | $constraintParameters[$syntaxClarificationId], |
668 | 668 | $syntaxClarificationId |
669 | 669 | ); |
670 | 670 | |
671 | - foreach ( $languageCodes as $languageCode ) { |
|
672 | - if ( array_key_exists( $languageCode, $syntaxClarifications ) ) { |
|
671 | + foreach ($languageCodes as $languageCode) { |
|
672 | + if (array_key_exists($languageCode, $syntaxClarifications)) { |
|
673 | 673 | return $syntaxClarifications[$languageCode]; |
674 | 674 | } |
675 | 675 | } |
@@ -685,20 +685,20 @@ discard block |
||
685 | 685 | * @throws ConstraintParameterException if the parameter is invalid |
686 | 686 | * @return string[]|null Context::TYPE_* constants |
687 | 687 | */ |
688 | - public function parseConstraintScopeParameter( array $constraintParameters, $constraintTypeItemId, array $validScopes = null ) { |
|
689 | - $constraintScopeId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' ); |
|
690 | - $mainSnakId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' ); |
|
691 | - $qualifiersId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' ); |
|
692 | - $referencesId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' ); |
|
688 | + public function parseConstraintScopeParameter(array $constraintParameters, $constraintTypeItemId, array $validScopes = null) { |
|
689 | + $constraintScopeId = $this->config->get('WBQualityConstraintsConstraintScopeId'); |
|
690 | + $mainSnakId = $this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId'); |
|
691 | + $qualifiersId = $this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId'); |
|
692 | + $referencesId = $this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId'); |
|
693 | 693 | |
694 | - if ( !array_key_exists( $constraintScopeId, $constraintParameters ) ) { |
|
694 | + if (!array_key_exists($constraintScopeId, $constraintParameters)) { |
|
695 | 695 | return null; |
696 | 696 | } |
697 | 697 | |
698 | 698 | $contextTypes = []; |
699 | - foreach ( $constraintParameters[$constraintScopeId] as $snakSerialization ) { |
|
700 | - $scopeEntityId = $this->parseEntityIdParameter( $snakSerialization, $constraintScopeId ); |
|
701 | - switch ( $scopeEntityId->getSerialization() ) { |
|
699 | + foreach ($constraintParameters[$constraintScopeId] as $snakSerialization) { |
|
700 | + $scopeEntityId = $this->parseEntityIdParameter($snakSerialization, $constraintScopeId); |
|
701 | + switch ($scopeEntityId->getSerialization()) { |
|
702 | 702 | case $mainSnakId: |
703 | 703 | $contextTypes[] = Context::TYPE_STATEMENT; |
704 | 704 | break; |
@@ -710,14 +710,14 @@ discard block |
||
710 | 710 | break; |
711 | 711 | default: |
712 | 712 | throw new ConstraintParameterException( |
713 | - wfMessage( 'wbqc-violation-message-parameter-oneof' ) |
|
713 | + wfMessage('wbqc-violation-message-parameter-oneof') |
|
714 | 714 | ->rawParams( |
715 | 715 | $this->constraintParameterRenderer->formatPropertyId( |
716 | 716 | $constraintScopeId, |
717 | 717 | Role::CONSTRAINT_PARAMETER_PROPERTY |
718 | 718 | ) |
719 | 719 | ) |
720 | - ->numParams( 3 ) |
|
720 | + ->numParams(3) |
|
721 | 721 | ->rawParams( |
722 | 722 | $this->constraintParameterRenderer->formatItemIdList( |
723 | 723 | [ |
@@ -733,12 +733,12 @@ discard block |
||
733 | 733 | } |
734 | 734 | } |
735 | 735 | |
736 | - if ( $validScopes !== null ) { |
|
737 | - $invalidScopes = array_diff( $contextTypes, $validScopes ); |
|
738 | - if ( $invalidScopes !== [] ) { |
|
739 | - $invalidScope = array_pop( $invalidScopes ); |
|
736 | + if ($validScopes !== null) { |
|
737 | + $invalidScopes = array_diff($contextTypes, $validScopes); |
|
738 | + if ($invalidScopes !== []) { |
|
739 | + $invalidScope = array_pop($invalidScopes); |
|
740 | 740 | throw new ConstraintParameterException( |
741 | - wfMessage( 'wbqc-violation-message-invalid-scope' ) |
|
741 | + wfMessage('wbqc-violation-message-invalid-scope') |
|
742 | 742 | ->rawParams( |
743 | 743 | $this->constraintParameterRenderer->formatConstraintScope( |
744 | 744 | $invalidScope, |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | Role::CONSTRAINT_TYPE_ITEM |
750 | 750 | ) |
751 | 751 | ) |
752 | - ->numParams( count( $validScopes ) ) |
|
752 | + ->numParams(count($validScopes)) |
|
753 | 753 | ->rawParams( |
754 | 754 | $this->constraintParameterRenderer->formatConstraintScopeList( |
755 | 755 | $validScopes, |
@@ -83,55 +83,54 @@ discard block |
||
83 | 83 | ) { |
84 | 84 | $response = []; |
85 | 85 | $metadatas = []; |
86 | - $statusesFlipped = array_flip( $statuses ); |
|
87 | - foreach ( $entityIds as $entityId ) { |
|
86 | + $statusesFlipped = array_flip($statuses); |
|
87 | + foreach ($entityIds as $entityId) { |
|
88 | 88 | $results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnEntityId( |
89 | 89 | $entityId, |
90 | 90 | $constraintIds, |
91 | - [ $this, 'defaultResults' ] |
|
91 | + [$this, 'defaultResults'] |
|
92 | 92 | ); |
93 | 93 | /** @var CheckResult[] $results */ |
94 | - $results = array_filter( $results, $this->statusSelected( $statusesFlipped ) ); |
|
95 | - foreach ( $results as $result ) { |
|
94 | + $results = array_filter($results, $this->statusSelected($statusesFlipped)); |
|
95 | + foreach ($results as $result) { |
|
96 | 96 | $metadatas[] = $result->getMetadata(); |
97 | - $resultArray = $this->checkResultToArray( $result ); |
|
98 | - $result->getContext()->storeCheckResultInArray( $resultArray, $response ); |
|
97 | + $resultArray = $this->checkResultToArray($result); |
|
98 | + $result->getContext()->storeCheckResultInArray($resultArray, $response); |
|
99 | 99 | } |
100 | 100 | } |
101 | - foreach ( $claimIds as $claimId ) { |
|
101 | + foreach ($claimIds as $claimId) { |
|
102 | 102 | $results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnClaimId( |
103 | 103 | $claimId, |
104 | 104 | $constraintIds, |
105 | - [ $this, 'defaultResults' ] |
|
105 | + [$this, 'defaultResults'] |
|
106 | 106 | ); |
107 | - $results = array_filter( $results, $this->statusSelected( $statusesFlipped ) ); |
|
108 | - foreach ( $results as $result ) { |
|
107 | + $results = array_filter($results, $this->statusSelected($statusesFlipped)); |
|
108 | + foreach ($results as $result) { |
|
109 | 109 | $metadatas[] = $result->getMetadata(); |
110 | - $resultArray = $this->checkResultToArray( $result ); |
|
111 | - $result->getContext()->storeCheckResultInArray( $resultArray, $response ); |
|
110 | + $resultArray = $this->checkResultToArray($result); |
|
111 | + $result->getContext()->storeCheckResultInArray($resultArray, $response); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | return new CachedCheckConstraintsResponse( |
115 | 115 | $response, |
116 | - Metadata::merge( $metadatas ) |
|
116 | + Metadata::merge($metadatas) |
|
117 | 117 | ); |
118 | 118 | } |
119 | 119 | |
120 | - public function defaultResults( Context $context ) { |
|
120 | + public function defaultResults(Context $context) { |
|
121 | 121 | return $context->getType() === Context::TYPE_STATEMENT ? |
122 | - [ new NullResult( $context ) ] : |
|
123 | - []; |
|
122 | + [new NullResult($context)] : []; |
|
124 | 123 | } |
125 | 124 | |
126 | - public function statusSelected( array $statusesFlipped ) { |
|
127 | - return function( CheckResult $result ) use ( $statusesFlipped ) { |
|
128 | - return array_key_exists( $result->getStatus(), $statusesFlipped ) || |
|
125 | + public function statusSelected(array $statusesFlipped) { |
|
126 | + return function(CheckResult $result) use ($statusesFlipped) { |
|
127 | + return array_key_exists($result->getStatus(), $statusesFlipped) || |
|
129 | 128 | $result instanceof NullResult; |
130 | 129 | }; |
131 | 130 | } |
132 | 131 | |
133 | - public function checkResultToArray( CheckResult $checkResult ) { |
|
134 | - if ( $checkResult instanceof NullResult ) { |
|
132 | + public function checkResultToArray(CheckResult $checkResult) { |
|
133 | + if ($checkResult instanceof NullResult) { |
|
135 | 134 | return null; |
136 | 135 | } |
137 | 136 | |
@@ -139,10 +138,10 @@ discard block |
||
139 | 138 | $typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId(); |
140 | 139 | $constraintPropertyId = $checkResult->getContext()->getSnak()->getPropertyId(); |
141 | 140 | |
142 | - $title = $this->entityTitleLookup->getTitleForId( $constraintPropertyId ); |
|
143 | - $typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) ); |
|
141 | + $title = $this->entityTitleLookup->getTitleForId($constraintPropertyId); |
|
142 | + $typeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($typeItemId)); |
|
144 | 143 | // TODO link to the statement when possible (T169224) |
145 | - $link = $title->getFullURL() . '#' . $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
144 | + $link = $title->getFullURL().'#'.$this->config->get('WBQualityConstraintsPropertyConstraintId'); |
|
146 | 145 | |
147 | 146 | $constraint = [ |
148 | 147 | 'id' => $constraintId, |
@@ -151,11 +150,11 @@ discard block |
||
151 | 150 | 'link' => $link, |
152 | 151 | 'discussLink' => $title->getTalkPage()->getFullURL(), |
153 | 152 | ]; |
154 | - if ( $this->config->get( 'WBQualityConstraintsIncludeDetailInApi' ) ) { |
|
153 | + if ($this->config->get('WBQualityConstraintsIncludeDetailInApi')) { |
|
155 | 154 | $parameters = $checkResult->getParameters(); |
156 | 155 | $constraint += [ |
157 | 156 | 'detail' => $parameters, |
158 | - 'detailHTML' => $this->constraintParameterRenderer->formatParameters( $parameters ), |
|
157 | + 'detailHTML' => $this->constraintParameterRenderer->formatParameters($parameters), |
|
159 | 158 | ]; |
160 | 159 | } |
161 | 160 | |
@@ -165,14 +164,14 @@ discard block |
||
165 | 164 | 'constraint' => $constraint |
166 | 165 | ]; |
167 | 166 | $message = $checkResult->getMessage(); |
168 | - if ( $message ) { |
|
169 | - $result['message-html'] = $this->violationMessageRenderer->render( $message ); |
|
167 | + if ($message) { |
|
168 | + $result['message-html'] = $this->violationMessageRenderer->render($message); |
|
170 | 169 | } |
171 | - if ( $checkResult->getContext()->getType() === Context::TYPE_STATEMENT ) { |
|
170 | + if ($checkResult->getContext()->getType() === Context::TYPE_STATEMENT) { |
|
172 | 171 | $result['claim'] = $checkResult->getContext()->getSnakStatement()->getGuid(); |
173 | 172 | } |
174 | 173 | $cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray(); |
175 | - if ( $cachingMetadataArray !== null ) { |
|
174 | + if ($cachingMetadataArray !== null) { |
|
176 | 175 | $result['cached'] = $cachingMetadataArray; |
177 | 176 | } |
178 | 177 |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | public function __construct( |
73 | 73 | $messageKey |
74 | 74 | ) { |
75 | - if ( strpos( $messageKey, self::MESSAGE_KEY_PREFIX ) !== 0 ) { |
|
75 | + if (strpos($messageKey, self::MESSAGE_KEY_PREFIX) !== 0) { |
|
76 | 76 | throw new InvalidArgumentException( |
77 | - 'ViolationMessage key ⧼' . |
|
78 | - $messageKey . |
|
79 | - '⧽ should start with "' . |
|
80 | - self::MESSAGE_KEY_PREFIX . |
|
77 | + 'ViolationMessage key ⧼'. |
|
78 | + $messageKey. |
|
79 | + '⧽ should start with "'. |
|
80 | + self::MESSAGE_KEY_PREFIX. |
|
81 | 81 | '".' |
82 | 82 | ); |
83 | 83 | } |
84 | 84 | |
85 | - $this->messageKeySuffix = substr( $messageKey, strlen( self::MESSAGE_KEY_PREFIX ) ); |
|
85 | + $this->messageKeySuffix = substr($messageKey, strlen(self::MESSAGE_KEY_PREFIX)); |
|
86 | 86 | $this->arguments = []; |
87 | 87 | } |
88 | 88 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return string |
92 | 92 | */ |
93 | 93 | public function getMessageKey() { |
94 | - return self::MESSAGE_KEY_PREFIX . $this->messageKeySuffix; |
|
94 | + return self::MESSAGE_KEY_PREFIX.$this->messageKeySuffix; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | * @param mixed $value the value, which should match the $type |
110 | 110 | * @return ViolationMessage |
111 | 111 | */ |
112 | - private function withArgument( $type, $role, $value ) { |
|
112 | + private function withArgument($type, $role, $value) { |
|
113 | 113 | $ret = clone $this; |
114 | - $ret->arguments[] = [ 'type' => $type, 'role' => $role, 'value' => $value ]; |
|
114 | + $ret->arguments[] = ['type' => $type, 'role' => $role, 'value' => $value]; |
|
115 | 115 | return $ret; |
116 | 116 | } |
117 | 117 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * @param string|null $role one of the Role::* constants |
124 | 124 | * @return ViolationMessage |
125 | 125 | */ |
126 | - public function withEntityId( EntityId $entityId, $role = null ) { |
|
127 | - return $this->withArgument( self::TYPE_ENTITY_ID, $role, $entityId ); |
|
126 | + public function withEntityId(EntityId $entityId, $role = null) { |
|
127 | + return $this->withArgument(self::TYPE_ENTITY_ID, $role, $entityId); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | * @param string|null $role one of the Role::* constants |
142 | 142 | * @return ViolationMessage |
143 | 143 | */ |
144 | - public function withEntityIdList( array $entityIdList, $role = null ) { |
|
145 | - return $this->withArgument( self::TYPE_ENTITY_ID_LIST, $role, $entityIdList ); |
|
144 | + public function withEntityIdList(array $entityIdList, $role = null) { |
|
145 | + return $this->withArgument(self::TYPE_ENTITY_ID_LIST, $role, $entityIdList); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | * @param string|null $role one of the Role::* constants |
154 | 154 | * @return ViolationMessage |
155 | 155 | */ |
156 | - public function withItemIdSnakValue( ItemIdSnakValue $value, $role = null ) { |
|
157 | - return $this->withArgument( self::TYPE_ITEM_ID_SNAK_VALUE, $role, $value ); |
|
156 | + public function withItemIdSnakValue(ItemIdSnakValue $value, $role = null) { |
|
157 | + return $this->withArgument(self::TYPE_ITEM_ID_SNAK_VALUE, $role, $value); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | * @param string|null $role one of the Role::* constants |
172 | 172 | * @return ViolationMessage |
173 | 173 | */ |
174 | - public function withItemIdSnakValueList( array $valueList, $role = null ) { |
|
175 | - return $this->withArgument( self::TYPE_ITEM_ID_SNAK_VALUE_LIST, $role, $valueList ); |
|
174 | + public function withItemIdSnakValueList(array $valueList, $role = null) { |
|
175 | + return $this->withArgument(self::TYPE_ITEM_ID_SNAK_VALUE_LIST, $role, $valueList); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | * @param string|null $role one of the Role::* constants |
188 | 188 | * @return ViolationMessage |
189 | 189 | */ |
190 | - public function withDataValueType( $dataValueType, $role = null ) { |
|
191 | - return $this->withArgument( self::TYPE_DATA_VALUE_TYPE, $role, $dataValueType ); |
|
190 | + public function withDataValueType($dataValueType, $role = null) { |
|
191 | + return $this->withArgument(self::TYPE_DATA_VALUE_TYPE, $role, $dataValueType); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | } |
@@ -44,90 +44,90 @@ discard block |
||
44 | 44 | * (temporarily, pre-rendered strings are allowed and returned without changes) |
45 | 45 | * @return string |
46 | 46 | */ |
47 | - public function render( $violationMessage ) { |
|
48 | - if ( is_string( $violationMessage ) ) { |
|
47 | + public function render($violationMessage) { |
|
48 | + if (is_string($violationMessage)) { |
|
49 | 49 | // TODO remove this once all checkers produce ViolationMessage objects |
50 | 50 | return $violationMessage; |
51 | 51 | } |
52 | - $message = new Message( $violationMessage->getMessageKey() ); |
|
53 | - foreach ( $violationMessage->getArguments() as $argument ) { |
|
54 | - $this->renderArgument( $argument, $message ); |
|
52 | + $message = new Message($violationMessage->getMessageKey()); |
|
53 | + foreach ($violationMessage->getArguments() as $argument) { |
|
54 | + $this->renderArgument($argument, $message); |
|
55 | 55 | } |
56 | 56 | return $message->escaped(); |
57 | 57 | } |
58 | 58 | |
59 | - private function addRole( $value, $role ) { |
|
60 | - if ( $role === null ) { |
|
59 | + private function addRole($value, $role) { |
|
60 | + if ($role === null) { |
|
61 | 61 | return $value; |
62 | 62 | } |
63 | 63 | |
64 | - return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' . |
|
65 | - $value . |
|
64 | + return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'. |
|
65 | + $value. |
|
66 | 66 | '</span>'; |
67 | 67 | } |
68 | 68 | |
69 | - private function renderArgument( array $argument, Message $message ) { |
|
69 | + private function renderArgument(array $argument, Message $message) { |
|
70 | 70 | $type = $argument['type']; |
71 | 71 | $value = $argument['value']; |
72 | 72 | $role = $argument['role']; |
73 | - switch ( $type ) { |
|
73 | + switch ($type) { |
|
74 | 74 | case ViolationMessage::TYPE_ENTITY_ID: |
75 | - $params = $this->renderEntityId( $value, $role ); |
|
75 | + $params = $this->renderEntityId($value, $role); |
|
76 | 76 | break; |
77 | 77 | case ViolationMessage::TYPE_ENTITY_ID_LIST: |
78 | - $params = $this->renderEntityIdList( $value, $role ); |
|
78 | + $params = $this->renderEntityIdList($value, $role); |
|
79 | 79 | break; |
80 | 80 | case ViolationMessage::TYPE_ITEM_ID_SNAK_VALUE: |
81 | - $params = $this->renderItemIdSnakValue( $value, $role ); |
|
81 | + $params = $this->renderItemIdSnakValue($value, $role); |
|
82 | 82 | break; |
83 | 83 | case ViolationMessage::TYPE_ITEM_ID_SNAK_VALUE_LIST: |
84 | - $params = $this->renderItemIdSnakValueList( $value, $role ); |
|
84 | + $params = $this->renderItemIdSnakValueList($value, $role); |
|
85 | 85 | break; |
86 | 86 | case ViolationMessage::TYPE_DATA_VALUE_TYPE: |
87 | - $params = $this->renderDataValueType( $value, $role ); |
|
87 | + $params = $this->renderDataValueType($value, $role); |
|
88 | 88 | break; |
89 | 89 | default: |
90 | 90 | throw new InvalidArgumentException( |
91 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
91 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
92 | 92 | ); |
93 | 93 | } |
94 | - $message->params( $params ); |
|
94 | + $message->params($params); |
|
95 | 95 | } |
96 | 96 | |
97 | - private function renderList( array $list, $role, callable $render ) { |
|
98 | - if ( $list === [] ) { |
|
97 | + private function renderList(array $list, $role, callable $render) { |
|
98 | + if ($list === []) { |
|
99 | 99 | return [ |
100 | - Message::numParam( 0 ), |
|
101 | - Message::rawParam( '<ul></ul>' ), |
|
100 | + Message::numParam(0), |
|
101 | + Message::rawParam('<ul></ul>'), |
|
102 | 102 | ]; |
103 | 103 | } |
104 | 104 | |
105 | - if ( count( $list ) > $this->maxListLength ) { |
|
106 | - $list = array_slice( $list, 0, $this->maxListLength ); |
|
105 | + if (count($list) > $this->maxListLength) { |
|
106 | + $list = array_slice($list, 0, $this->maxListLength); |
|
107 | 107 | $truncated = true; |
108 | 108 | } |
109 | 109 | |
110 | 110 | $renderedParams = array_map( |
111 | 111 | $render, |
112 | 112 | $list, |
113 | - array_fill( 0, count( $list ), $role ) |
|
113 | + array_fill(0, count($list), $role) |
|
114 | 114 | ); |
115 | 115 | $renderedElements = array_map( |
116 | - function ( $param ) { |
|
116 | + function($param) { |
|
117 | 117 | return $param['raw']; |
118 | 118 | }, |
119 | 119 | $renderedParams |
120 | 120 | ); |
121 | - if ( isset( $truncated ) ) { |
|
122 | - $renderedElements[] = wfMessage( 'ellipsis' )->escaped(); |
|
121 | + if (isset($truncated)) { |
|
122 | + $renderedElements[] = wfMessage('ellipsis')->escaped(); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return array_merge( |
126 | 126 | [ |
127 | - Message::numParam( count( $list ) ), |
|
127 | + Message::numParam(count($list)), |
|
128 | 128 | Message::rawParam( |
129 | - '<ul><li>' . |
|
130 | - implode( '</li><li>', $renderedElements ) . |
|
129 | + '<ul><li>'. |
|
130 | + implode('</li><li>', $renderedElements). |
|
131 | 131 | '</li></ul>' |
132 | 132 | ), |
133 | 133 | ], |
@@ -135,35 +135,35 @@ discard block |
||
135 | 135 | ); |
136 | 136 | } |
137 | 137 | |
138 | - private function renderEntityId( EntityId $entityId, $role ) { |
|
139 | - return Message::rawParam( $this->addRole( |
|
140 | - $this->entityIdFormatter->formatEntityId( $entityId ), |
|
138 | + private function renderEntityId(EntityId $entityId, $role) { |
|
139 | + return Message::rawParam($this->addRole( |
|
140 | + $this->entityIdFormatter->formatEntityId($entityId), |
|
141 | 141 | $role |
142 | - ) ); |
|
142 | + )); |
|
143 | 143 | } |
144 | 144 | |
145 | - private function renderEntityIdList( array $entityIdList, $role ) { |
|
146 | - return $this->renderList( $entityIdList, $role, [ $this, 'renderEntityId' ] ); |
|
145 | + private function renderEntityIdList(array $entityIdList, $role) { |
|
146 | + return $this->renderList($entityIdList, $role, [$this, 'renderEntityId']); |
|
147 | 147 | } |
148 | 148 | |
149 | - private function renderItemIdSnakValue( ItemIdSnakValue $value, $role ) { |
|
150 | - switch ( true ) { |
|
149 | + private function renderItemIdSnakValue(ItemIdSnakValue $value, $role) { |
|
150 | + switch (true) { |
|
151 | 151 | case $value->isValue(): |
152 | - return $this->renderEntityId( $value->getItemId(), $role ); |
|
152 | + return $this->renderEntityId($value->getItemId(), $role); |
|
153 | 153 | case $value->isSomeValue(): |
154 | - return Message::rawParam( $this->addRole( |
|
155 | - '<span class="wikibase-snakview-variation-somevaluesnak">' . |
|
156 | - wfMessage( 'wikibase-snakview-snaktypeselector-somevalue' )->escaped() . |
|
154 | + return Message::rawParam($this->addRole( |
|
155 | + '<span class="wikibase-snakview-variation-somevaluesnak">'. |
|
156 | + wfMessage('wikibase-snakview-snaktypeselector-somevalue')->escaped(). |
|
157 | 157 | '</span>', |
158 | 158 | $role |
159 | - ) ); |
|
159 | + )); |
|
160 | 160 | case $value->isNoValue(): |
161 | - return Message::rawParam( $this->addRole( |
|
162 | - '<span class="wikibase-snakview-variation-novaluesnak">' . |
|
163 | - wfMessage( 'wikibase-snakview-snaktypeselector-novalue' )->escaped() . |
|
161 | + return Message::rawParam($this->addRole( |
|
162 | + '<span class="wikibase-snakview-variation-novaluesnak">'. |
|
163 | + wfMessage('wikibase-snakview-snaktypeselector-novalue')->escaped(). |
|
164 | 164 | '</span>', |
165 | 165 | $role |
166 | - ) ); |
|
166 | + )); |
|
167 | 167 | default: |
168 | 168 | // @codeCoverageIgnoreStart |
169 | 169 | throw new LogicException( |
@@ -173,26 +173,26 @@ discard block |
||
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - private function renderItemIdSnakValueList( array $valueList, $role ) { |
|
177 | - return $this->renderList( $valueList, $role, [ $this, 'renderItemIdSnakValue' ] ); |
|
176 | + private function renderItemIdSnakValueList(array $valueList, $role) { |
|
177 | + return $this->renderList($valueList, $role, [$this, 'renderItemIdSnakValue']); |
|
178 | 178 | } |
179 | 179 | |
180 | - private function renderDataValueType( $dataValueType, $role ) { |
|
180 | + private function renderDataValueType($dataValueType, $role) { |
|
181 | 181 | $messageKeys = [ |
182 | 182 | 'string' => 'datatypes-type-string', |
183 | 183 | 'monolingualtext' => 'datatypes-monolingualtext', |
184 | 184 | 'wikibase-entityid' => 'wbqc-dataValueType-wikibase-entityid', |
185 | 185 | ]; |
186 | 186 | |
187 | - if ( array_key_exists( $dataValueType, $messageKeys ) ) { |
|
188 | - return Message::rawParam( $this->addRole( |
|
189 | - wfMessage( $messageKeys[$dataValueType] )->escaped(), |
|
187 | + if (array_key_exists($dataValueType, $messageKeys)) { |
|
188 | + return Message::rawParam($this->addRole( |
|
189 | + wfMessage($messageKeys[$dataValueType])->escaped(), |
|
190 | 190 | $role |
191 | - ) ); |
|
191 | + )); |
|
192 | 192 | } else { |
193 | 193 | // @codeCoverageIgnoreStart |
194 | 194 | throw new LogicException( |
195 | - 'Unknown data value type ' . $dataValueType |
|
195 | + 'Unknown data value type '.$dataValueType |
|
196 | 196 | ); |
197 | 197 | // @codeCoverageIgnoreEnd |
198 | 198 | } |