@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | * @param ViolationMessage $violationMessage |
78 | 78 | * @return string |
79 | 79 | */ |
80 | - public function render( ViolationMessage $violationMessage ) { |
|
80 | + public function render(ViolationMessage $violationMessage) { |
|
81 | 81 | $messageKey = $violationMessage->getMessageKey(); |
82 | - $paramsLists = [ [] ]; |
|
83 | - foreach ( $violationMessage->getArguments() as $argument ) { |
|
84 | - $params = $this->renderArgument( $argument ); |
|
82 | + $paramsLists = [[]]; |
|
83 | + foreach ($violationMessage->getArguments() as $argument) { |
|
84 | + $params = $this->renderArgument($argument); |
|
85 | 85 | $paramsLists[] = $params; |
86 | 86 | } |
87 | - $allParams = call_user_func_array( 'array_merge', $paramsLists ); |
|
87 | + $allParams = call_user_func_array('array_merge', $paramsLists); |
|
88 | 88 | return $this->messageLocalizer |
89 | - ->msg( $messageKey ) |
|
90 | - ->params( $allParams ) |
|
89 | + ->msg($messageKey) |
|
90 | + ->params($allParams) |
|
91 | 91 | ->escaped(); |
92 | 92 | } |
93 | 93 | |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | * @param string|null $role one of the Role::* constants |
97 | 97 | * @return string HTML |
98 | 98 | */ |
99 | - protected function addRole( $value, $role ) { |
|
100 | - if ( $role === null ) { |
|
99 | + protected function addRole($value, $role) { |
|
100 | + if ($role === null) { |
|
101 | 101 | return $value; |
102 | 102 | } |
103 | 103 | |
104 | - return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' . |
|
105 | - $value . |
|
104 | + return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'. |
|
105 | + $value. |
|
106 | 106 | '</span>'; |
107 | 107 | } |
108 | 108 | |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | * @param string $key message key |
111 | 111 | * @return string HTML |
112 | 112 | */ |
113 | - protected function msgEscaped( $key ) { |
|
114 | - return $this->messageLocalizer->msg( $key )->escaped(); |
|
113 | + protected function msgEscaped($key) { |
|
114 | + return $this->messageLocalizer->msg($key)->escaped(); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | 118 | * @param array $argument |
119 | 119 | * @return array[] params (for Message::params) |
120 | 120 | */ |
121 | - protected function renderArgument( array $argument ) { |
|
121 | + protected function renderArgument(array $argument) { |
|
122 | 122 | $methods = [ |
123 | 123 | ViolationMessage::TYPE_ENTITY_ID => 'renderEntityId', |
124 | 124 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'renderEntityIdList', |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | $value = $argument['value']; |
139 | 139 | $role = $argument['role']; |
140 | 140 | |
141 | - if ( array_key_exists( $type, $methods ) ) { |
|
141 | + if (array_key_exists($type, $methods)) { |
|
142 | 142 | $method = $methods[$type]; |
143 | - $params = $this->$method( $value, $role ); |
|
143 | + $params = $this->$method($value, $role); |
|
144 | 144 | } else { |
145 | 145 | throw new InvalidArgumentException( |
146 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
146 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
147 | 147 | ); |
148 | 148 | } |
149 | 149 | |
@@ -157,46 +157,46 @@ discard block |
||
157 | 157 | * and return a single-element array with a raw message param (i. e. [ Message::rawParam( … ) ]) |
158 | 158 | * @return array[] list of parameters as accepted by Message::params() |
159 | 159 | */ |
160 | - private function renderList( array $list, $role, callable $render ) { |
|
161 | - if ( $list === [] ) { |
|
160 | + private function renderList(array $list, $role, callable $render) { |
|
161 | + if ($list === []) { |
|
162 | 162 | return [ |
163 | - Message::numParam( 0 ), |
|
164 | - Message::rawParam( '<ul></ul>' ), |
|
163 | + Message::numParam(0), |
|
164 | + Message::rawParam('<ul></ul>'), |
|
165 | 165 | ]; |
166 | 166 | } |
167 | 167 | |
168 | - if ( count( $list ) > $this->maxListLength ) { |
|
169 | - $list = array_slice( $list, 0, $this->maxListLength ); |
|
168 | + if (count($list) > $this->maxListLength) { |
|
169 | + $list = array_slice($list, 0, $this->maxListLength); |
|
170 | 170 | $truncated = true; |
171 | 171 | } |
172 | 172 | |
173 | 173 | $renderedParamsLists = array_map( |
174 | 174 | $render, |
175 | 175 | $list, |
176 | - array_fill( 0, count( $list ), $role ) |
|
176 | + array_fill(0, count($list), $role) |
|
177 | 177 | ); |
178 | 178 | $renderedParams = array_map( |
179 | - function ( $params ) { |
|
179 | + function($params) { |
|
180 | 180 | return $params[0]; |
181 | 181 | }, |
182 | 182 | $renderedParamsLists |
183 | 183 | ); |
184 | 184 | $renderedElements = array_map( |
185 | - function ( $param ) { |
|
185 | + function($param) { |
|
186 | 186 | return $param['raw']; |
187 | 187 | }, |
188 | 188 | $renderedParams |
189 | 189 | ); |
190 | - if ( isset( $truncated ) ) { |
|
191 | - $renderedElements[] = $this->msgEscaped( 'ellipsis' ); |
|
190 | + if (isset($truncated)) { |
|
191 | + $renderedElements[] = $this->msgEscaped('ellipsis'); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | return array_merge( |
195 | 195 | [ |
196 | - Message::numParam( count( $list ) ), |
|
196 | + Message::numParam(count($list)), |
|
197 | 197 | Message::rawParam( |
198 | - '<ul><li>' . |
|
199 | - implode( '</li><li>', $renderedElements ) . |
|
198 | + '<ul><li>'. |
|
199 | + implode('</li><li>', $renderedElements). |
|
200 | 200 | '</li></ul>' |
201 | 201 | ), |
202 | 202 | ], |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | * @param string|null $role one of the Role::* constants |
210 | 210 | * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
211 | 211 | */ |
212 | - private function renderEntityId( EntityId $entityId, $role ) { |
|
213 | - return [ Message::rawParam( $this->addRole( |
|
214 | - $this->entityIdFormatter->formatEntityId( $entityId ), |
|
212 | + private function renderEntityId(EntityId $entityId, $role) { |
|
213 | + return [Message::rawParam($this->addRole( |
|
214 | + $this->entityIdFormatter->formatEntityId($entityId), |
|
215 | 215 | $role |
216 | - ) ) ]; |
|
216 | + ))]; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @param string|null $role one of the Role::* constants |
222 | 222 | * @return array[] list of parameters as accepted by Message::params() |
223 | 223 | */ |
224 | - private function renderEntityIdList( array $entityIdList, $role ) { |
|
225 | - return $this->renderList( $entityIdList, $role, [ $this, 'renderEntityId' ] ); |
|
224 | + private function renderEntityIdList(array $entityIdList, $role) { |
|
225 | + return $this->renderList($entityIdList, $role, [$this, 'renderEntityId']); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -230,24 +230,24 @@ discard block |
||
230 | 230 | * @param string|null $role one of the Role::* constants |
231 | 231 | * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
232 | 232 | */ |
233 | - private function renderItemIdSnakValue( ItemIdSnakValue $value, $role ) { |
|
234 | - switch ( true ) { |
|
233 | + private function renderItemIdSnakValue(ItemIdSnakValue $value, $role) { |
|
234 | + switch (true) { |
|
235 | 235 | case $value->isValue(): |
236 | - return $this->renderEntityId( $value->getItemId(), $role ); |
|
236 | + return $this->renderEntityId($value->getItemId(), $role); |
|
237 | 237 | case $value->isSomeValue(): |
238 | - return [ Message::rawParam( $this->addRole( |
|
239 | - '<span class="wikibase-snakview-variation-somevaluesnak">' . |
|
240 | - $this->msgEscaped( 'wikibase-snakview-snaktypeselector-somevalue' ) . |
|
238 | + return [Message::rawParam($this->addRole( |
|
239 | + '<span class="wikibase-snakview-variation-somevaluesnak">'. |
|
240 | + $this->msgEscaped('wikibase-snakview-snaktypeselector-somevalue'). |
|
241 | 241 | '</span>', |
242 | 242 | $role |
243 | - ) ) ]; |
|
243 | + ))]; |
|
244 | 244 | case $value->isNoValue(): |
245 | - return [ Message::rawParam( $this->addRole( |
|
246 | - '<span class="wikibase-snakview-variation-novaluesnak">' . |
|
247 | - $this->msgEscaped( 'wikibase-snakview-snaktypeselector-novalue' ) . |
|
245 | + return [Message::rawParam($this->addRole( |
|
246 | + '<span class="wikibase-snakview-variation-novaluesnak">'. |
|
247 | + $this->msgEscaped('wikibase-snakview-snaktypeselector-novalue'). |
|
248 | 248 | '</span>', |
249 | 249 | $role |
250 | - ) ) ]; |
|
250 | + ))]; |
|
251 | 251 | default: |
252 | 252 | // @codeCoverageIgnoreStart |
253 | 253 | throw new LogicException( |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | * @param string|null $role one of the Role::* constants |
263 | 263 | * @return array[] list of parameters as accepted by Message::params() |
264 | 264 | */ |
265 | - private function renderItemIdSnakValueList( array $valueList, $role ) { |
|
266 | - return $this->renderList( $valueList, $role, [ $this, 'renderItemIdSnakValue' ] ); |
|
265 | + private function renderItemIdSnakValueList(array $valueList, $role) { |
|
266 | + return $this->renderList($valueList, $role, [$this, 'renderItemIdSnakValue']); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | * @param string|null $role one of the Role::* constants |
272 | 272 | * @return array[] list of parameters as accepted by Message::params() |
273 | 273 | */ |
274 | - private function renderDataValue( DataValue $dataValue, $role ) { |
|
275 | - return [ Message::rawParam( $this->addRole( |
|
276 | - $this->dataValueFormatter->format( $dataValue ), |
|
274 | + private function renderDataValue(DataValue $dataValue, $role) { |
|
275 | + return [Message::rawParam($this->addRole( |
|
276 | + $this->dataValueFormatter->format($dataValue), |
|
277 | 277 | $role |
278 | - ) ) ]; |
|
278 | + ))]; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @param string|null $role one of the Role::* constants |
284 | 284 | * @return array[] list of parameters as accepted by Message::params() |
285 | 285 | */ |
286 | - private function renderDataValueType( $dataValueType, $role ) { |
|
286 | + private function renderDataValueType($dataValueType, $role) { |
|
287 | 287 | $messageKeys = [ |
288 | 288 | 'string' => 'datatypes-type-string', |
289 | 289 | 'monolingualtext' => 'datatypes-type-monolingualtext', |
@@ -292,15 +292,15 @@ discard block |
||
292 | 292 | 'wikibase-entityid' => 'wbqc-dataValueType-wikibase-entityid', |
293 | 293 | ]; |
294 | 294 | |
295 | - if ( array_key_exists( $dataValueType, $messageKeys ) ) { |
|
296 | - return [ Message::rawParam( $this->addRole( |
|
297 | - $this->msgEscaped( $messageKeys[$dataValueType] ), |
|
295 | + if (array_key_exists($dataValueType, $messageKeys)) { |
|
296 | + return [Message::rawParam($this->addRole( |
|
297 | + $this->msgEscaped($messageKeys[$dataValueType]), |
|
298 | 298 | $role |
299 | - ) ) ]; |
|
299 | + ))]; |
|
300 | 300 | } else { |
301 | 301 | // @codeCoverageIgnoreStart |
302 | 302 | throw new LogicException( |
303 | - 'Unknown data value type ' . $dataValueType |
|
303 | + 'Unknown data value type '.$dataValueType |
|
304 | 304 | ); |
305 | 305 | // @codeCoverageIgnoreEnd |
306 | 306 | } |
@@ -311,11 +311,11 @@ discard block |
||
311 | 311 | * @param string|null $role one of the Role::* constants |
312 | 312 | * @return array[] list of parameters as accepted by Message::params() |
313 | 313 | */ |
314 | - private function renderInlineCode( $code, $role ) { |
|
315 | - return [ Message::rawParam( $this->addRole( |
|
316 | - '<code>' . htmlspecialchars( $code ) . '</code>', |
|
314 | + private function renderInlineCode($code, $role) { |
|
315 | + return [Message::rawParam($this->addRole( |
|
316 | + '<code>'.htmlspecialchars($code).'</code>', |
|
317 | 317 | $role |
318 | - ) ) ]; |
|
318 | + ))]; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param string|null $role one of the Role::* constants |
324 | 324 | * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
325 | 325 | */ |
326 | - private function renderConstraintScope( $scope, $role ) { |
|
327 | - switch ( $scope ) { |
|
326 | + private function renderConstraintScope($scope, $role) { |
|
327 | + switch ($scope) { |
|
328 | 328 | case Context::TYPE_STATEMENT: |
329 | 329 | $itemId = $this->config->get( |
330 | 330 | 'WBQualityConstraintsConstraintCheckedOnMainValueId' |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | // callers should never let this happen, but if it does happen, |
345 | 345 | // showing “unknown value” seems reasonable |
346 | 346 | // @codeCoverageIgnoreStart |
347 | - return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
347 | + return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
348 | 348 | // @codeCoverageIgnoreEnd |
349 | 349 | } |
350 | - return $this->renderEntityId( new ItemId( $itemId ), $role ); |
|
350 | + return $this->renderEntityId(new ItemId($itemId), $role); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param string|null $role one of the Role::* constants |
356 | 356 | * @return array[] list of parameters as accepted by Message::params() |
357 | 357 | */ |
358 | - private function renderConstraintScopeList( array $scopeList, $role ) { |
|
359 | - return $this->renderList( $scopeList, $role, [ $this, 'renderConstraintScope' ] ); |
|
358 | + private function renderConstraintScopeList(array $scopeList, $role) { |
|
359 | + return $this->renderList($scopeList, $role, [$this, 'renderConstraintScope']); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -364,25 +364,25 @@ discard block |
||
364 | 364 | * @param string|null $role one of the Role::* constants |
365 | 365 | * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
366 | 366 | */ |
367 | - private function renderPropertyScope( $scope, $role ) { |
|
368 | - switch ( $scope ) { |
|
367 | + private function renderPropertyScope($scope, $role) { |
|
368 | + switch ($scope) { |
|
369 | 369 | case Context::TYPE_STATEMENT: |
370 | - $itemId = $this->config->get( 'WBQualityConstraintsAsMainValueId' ); |
|
370 | + $itemId = $this->config->get('WBQualityConstraintsAsMainValueId'); |
|
371 | 371 | break; |
372 | 372 | case Context::TYPE_QUALIFIER: |
373 | - $itemId = $this->config->get( 'WBQualityConstraintsAsQualifiersId' ); |
|
373 | + $itemId = $this->config->get('WBQualityConstraintsAsQualifiersId'); |
|
374 | 374 | break; |
375 | 375 | case Context::TYPE_REFERENCE: |
376 | - $itemId = $this->config->get( 'WBQualityConstraintsAsReferencesId' ); |
|
376 | + $itemId = $this->config->get('WBQualityConstraintsAsReferencesId'); |
|
377 | 377 | break; |
378 | 378 | default: |
379 | 379 | // callers should never let this happen, but if it does happen, |
380 | 380 | // showing “unknown value” seems reasonable |
381 | 381 | // @codeCoverageIgnoreStart |
382 | - return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
382 | + return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
383 | 383 | // @codeCoverageIgnoreEnd |
384 | 384 | } |
385 | - return $this->renderEntityId( new ItemId( $itemId ), $role ); |
|
385 | + return $this->renderEntityId(new ItemId($itemId), $role); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | * @param string|null $role one of the Role::* constants |
391 | 391 | * @return array[] list of parameters as accepted by Message::params() |
392 | 392 | */ |
393 | - private function renderPropertyScopeList( array $scopeList, $role ) { |
|
394 | - return $this->renderList( $scopeList, $role, [ $this, 'renderPropertyScope' ] ); |
|
393 | + private function renderPropertyScopeList(array $scopeList, $role) { |
|
394 | + return $this->renderList($scopeList, $role, [$this, 'renderPropertyScope']); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | * @param string|null $role one of the Role::* constants |
400 | 400 | * @return array[] list of parameters as accepted by Message::params() |
401 | 401 | */ |
402 | - private function renderLanguage( $languageCode, $role ) { |
|
402 | + private function renderLanguage($languageCode, $role) { |
|
403 | 403 | return [ |
404 | - Message::plaintextParam( Language::fetchLanguageName( $languageCode ) ), |
|
405 | - Message::plaintextParam( $languageCode ), |
|
404 | + Message::plaintextParam(Language::fetchLanguageName($languageCode)), |
|
405 | + Message::plaintextParam($languageCode), |
|
406 | 406 | ]; |
407 | 407 | } |
408 | 408 |
@@ -54,34 +54,34 @@ discard block |
||
54 | 54 | * @param ViolationMessage $violationMessage |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - public function render( ViolationMessage $violationMessage ) { |
|
58 | - if ( !array_key_exists( $violationMessage->getMessageKey(), $this->alternativeMessageKeys ) ) { |
|
59 | - return parent::render( $violationMessage ); |
|
57 | + public function render(ViolationMessage $violationMessage) { |
|
58 | + if (!array_key_exists($violationMessage->getMessageKey(), $this->alternativeMessageKeys)) { |
|
59 | + return parent::render($violationMessage); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $arguments = $violationMessage->getArguments(); |
63 | - $multilingualTextArgument = array_pop( $arguments ); |
|
63 | + $multilingualTextArgument = array_pop($arguments); |
|
64 | 64 | $multilingualTextParams = $this->renderMultilingualText( |
65 | 65 | $multilingualTextArgument['value'], |
66 | 66 | $multilingualTextArgument['role'] |
67 | 67 | ); |
68 | 68 | |
69 | - $paramsLists = [ [] ]; |
|
70 | - foreach ( $arguments as $argument ) { |
|
71 | - $paramsLists[] = $this->renderArgument( $argument ); |
|
69 | + $paramsLists = [[]]; |
|
70 | + foreach ($arguments as $argument) { |
|
71 | + $paramsLists[] = $this->renderArgument($argument); |
|
72 | 72 | } |
73 | - $regularParams = call_user_func_array( 'array_merge', $paramsLists ); |
|
73 | + $regularParams = call_user_func_array('array_merge', $paramsLists); |
|
74 | 74 | |
75 | - if ( $multilingualTextParams === null ) { |
|
75 | + if ($multilingualTextParams === null) { |
|
76 | 76 | return $this->messageLocalizer |
77 | - ->msg( $this->alternativeMessageKeys[$violationMessage->getMessageKey()] ) |
|
78 | - ->params( $regularParams ) |
|
77 | + ->msg($this->alternativeMessageKeys[$violationMessage->getMessageKey()]) |
|
78 | + ->params($regularParams) |
|
79 | 79 | ->escaped(); |
80 | 80 | } else { |
81 | 81 | return $this->messageLocalizer |
82 | - ->msg( $violationMessage->getMessageKey() ) |
|
83 | - ->params( $regularParams ) |
|
84 | - ->params( $multilingualTextParams ) |
|
82 | + ->msg($violationMessage->getMessageKey()) |
|
83 | + ->params($regularParams) |
|
84 | + ->params($multilingualTextParams) |
|
85 | 85 | ->escaped(); |
86 | 86 | } |
87 | 87 | } |
@@ -92,18 +92,18 @@ discard block |
||
92 | 92 | * @return array[]|null list of parameters as accepted by Message::params(), |
93 | 93 | * or null if the text is not available in the user’s language |
94 | 94 | */ |
95 | - protected function renderMultilingualText( MultilingualTextValue $text, $role ) { |
|
95 | + protected function renderMultilingualText(MultilingualTextValue $text, $role) { |
|
96 | 96 | global $wgLang; |
97 | 97 | $languageCodes = $wgLang->getFallbackLanguages(); |
98 | - array_unshift( $languageCodes, $wgLang->getCode() ); |
|
98 | + array_unshift($languageCodes, $wgLang->getCode()); |
|
99 | 99 | |
100 | 100 | $texts = $text->getTexts(); |
101 | - foreach ( $languageCodes as $languageCode ) { |
|
102 | - if ( array_key_exists( $languageCode, $texts ) ) { |
|
103 | - return [ Message::rawParam( $this->addRole( |
|
104 | - htmlspecialchars( $texts[$languageCode]->getText() ), |
|
101 | + foreach ($languageCodes as $languageCode) { |
|
102 | + if (array_key_exists($languageCode, $texts)) { |
|
103 | + return [Message::rawParam($this->addRole( |
|
104 | + htmlspecialchars($texts[$languageCode]->getText()), |
|
105 | 105 | $role |
106 | - ) ) ]; |
|
106 | + ))]; |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 |