Completed
Pull Request — master (#82)
by
unknown
16s
created
src/ConstraintsServices.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -40,93 +40,93 @@
 block discarded – undo
40 40
 	public const EXPIRY_LOCK = 'WBQC_ExpiryLock';
41 41
 	public const VIOLATION_MESSAGE_RENDERER_FACTORY = 'WBQC_ViolationMessageRendererFactory';
42 42
 
43
-	private static function getService( ?MediaWikiServices $services, $name ) {
44
-		if ( $services === null ) {
43
+	private static function getService(?MediaWikiServices $services, $name) {
44
+		if ($services === null) {
45 45
 			$services = MediaWikiServices::getInstance();
46 46
 		}
47
-		return $services->getService( $name );
47
+		return $services->getService($name);
48 48
 	}
49 49
 
50
-	public static function getLoggingHelper( MediaWikiServices $services = null ): LoggingHelper {
51
-		return self::getService( $services, self::LOGGING_HELPER );
50
+	public static function getLoggingHelper(MediaWikiServices $services = null): LoggingHelper {
51
+		return self::getService($services, self::LOGGING_HELPER);
52 52
 	}
53 53
 
54 54
 	public static function getConstraintStore(
55 55
 		MediaWikiServices $services = null
56 56
 	): ConstraintStore {
57
-		return self::getService( $services, self::CONSTRAINT_STORE );
57
+		return self::getService($services, self::CONSTRAINT_STORE);
58 58
 	}
59 59
 
60
-	public static function getConstraintLookup( MediaWikiServices $services = null ): ConstraintLookup {
61
-		return self::getService( $services, self::CONSTRAINT_LOOKUP );
60
+	public static function getConstraintLookup(MediaWikiServices $services = null): ConstraintLookup {
61
+		return self::getService($services, self::CONSTRAINT_LOOKUP);
62 62
 	}
63 63
 
64 64
 	public static function getCheckResultSerializer(
65 65
 		MediaWikiServices $services = null
66 66
 	): CheckResultSerializer {
67
-		return self::getService( $services, self::CHECK_RESULT_SERIALIZER );
67
+		return self::getService($services, self::CHECK_RESULT_SERIALIZER);
68 68
 	}
69 69
 
70 70
 	public static function getCheckResultDeserializer(
71 71
 		MediaWikiServices $services = null
72 72
 	): CheckResultDeserializer {
73
-		return self::getService( $services, self::CHECK_RESULT_DESERIALIZER );
73
+		return self::getService($services, self::CHECK_RESULT_DESERIALIZER);
74 74
 	}
75 75
 
76 76
 	public static function getViolationMessageSerializer(
77 77
 		MediaWikiServices $services = null
78 78
 	): ViolationMessageSerializer {
79
-		return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER );
79
+		return self::getService($services, self::VIOLATION_MESSAGE_SERIALIZER);
80 80
 	}
81 81
 
82 82
 	public static function getViolationMessageDeserializer(
83 83
 		MediaWikiServices $services = null
84 84
 	): ViolationMessageDeserializer {
85
-		return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER );
85
+		return self::getService($services, self::VIOLATION_MESSAGE_DESERIALIZER);
86 86
 	}
87 87
 
88 88
 	public static function getConstraintParameterParser(
89 89
 		MediaWikiServices $services = null
90 90
 	): ConstraintParameterParser {
91
-		return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER );
91
+		return self::getService($services, self::CONSTRAINT_PARAMETER_PARSER);
92 92
 	}
93 93
 
94 94
 	public static function getConnectionCheckerHelper(
95 95
 		MediaWikiServices $services = null
96 96
 	): ConnectionCheckerHelper {
97
-		return self::getService( $services, self::CONNECTION_CHECKER_HELPER );
97
+		return self::getService($services, self::CONNECTION_CHECKER_HELPER);
98 98
 	}
99 99
 
100
-	public static function getRangeCheckerHelper( MediaWikiServices $services = null ): RangeCheckerHelper {
101
-		return self::getService( $services, self::RANGE_CHECKER_HELPER );
100
+	public static function getRangeCheckerHelper(MediaWikiServices $services = null): RangeCheckerHelper {
101
+		return self::getService($services, self::RANGE_CHECKER_HELPER);
102 102
 	}
103 103
 
104
-	public static function getSparqlHelper( MediaWikiServices $services = null ): SparqlHelper {
105
-		return self::getService( $services, self::SPARQL_HELPER );
104
+	public static function getSparqlHelper(MediaWikiServices $services = null): SparqlHelper {
105
+		return self::getService($services, self::SPARQL_HELPER);
106 106
 	}
107 107
 
108
-	public static function getTypeCheckerHelper( MediaWikiServices $services = null ): TypeCheckerHelper {
109
-		return self::getService( $services, self::TYPE_CHECKER_HELPER );
108
+	public static function getTypeCheckerHelper(MediaWikiServices $services = null): TypeCheckerHelper {
109
+		return self::getService($services, self::TYPE_CHECKER_HELPER);
110 110
 	}
111 111
 
112 112
 	public static function getDelegatingConstraintChecker(
113 113
 		MediaWikiServices $services = null
114 114
 	): DelegatingConstraintChecker {
115
-		return self::getService( $services, self::DELEGATING_CONSTRAINT_CHECKER );
115
+		return self::getService($services, self::DELEGATING_CONSTRAINT_CHECKER);
116 116
 	}
117 117
 
118
-	public static function getResultsSource( MediaWikiServices $services = null ): ResultsSource {
119
-		return self::getService( $services, self::RESULTS_SOURCE );
118
+	public static function getResultsSource(MediaWikiServices $services = null): ResultsSource {
119
+		return self::getService($services, self::RESULTS_SOURCE);
120 120
 	}
121 121
 
122
-	public static function getExpiryLock( MediaWikiServices $services = null ): ExpiryLock {
123
-		return self::getService( $services, self::EXPIRY_LOCK );
122
+	public static function getExpiryLock(MediaWikiServices $services = null): ExpiryLock {
123
+		return self::getService($services, self::EXPIRY_LOCK);
124 124
 	}
125 125
 
126 126
 	public static function getViolationMessageRendererFactory(
127 127
 		MediaWikiServices $services = null
128 128
 	): ViolationMessageRendererFactory {
129
-		return self::getService( $services, self::VIOLATION_MESSAGE_RENDERER_FACTORY );
129
+		return self::getService($services, self::VIOLATION_MESSAGE_RENDERER_FACTORY);
130 130
 	}
131 131
 
132 132
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/ViolationMessageRenderer.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Message;
6 6
 
@@ -62,17 +62,17 @@  discard block
 block discarded – undo
62 62
 		$this->maxListLength = $maxListLength;
63 63
 	}
64 64
 
65
-	public function render( ViolationMessage $violationMessage ): string {
65
+	public function render(ViolationMessage $violationMessage): string {
66 66
 		$messageKey = $violationMessage->getMessageKey();
67
-		$paramsLists = [ [] ];
68
-		foreach ( $violationMessage->getArguments() as $argument ) {
69
-			$params = $this->renderArgument( $argument );
67
+		$paramsLists = [[]];
68
+		foreach ($violationMessage->getArguments() as $argument) {
69
+			$params = $this->renderArgument($argument);
70 70
 			$paramsLists[] = $params;
71 71
 		}
72
-		$allParams = call_user_func_array( 'array_merge', $paramsLists );
72
+		$allParams = call_user_func_array('array_merge', $paramsLists);
73 73
 		return $this->messageLocalizer
74
-			->msg( $messageKey )
75
-			->params( $allParams )
74
+			->msg($messageKey)
75
+			->params($allParams)
76 76
 			->escaped();
77 77
 	}
78 78
 
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 	 * @param string|null $role one of the Role::* constants
82 82
 	 * @return string HTML
83 83
 	 */
84
-	protected function addRole( string $value, ?string $role ): string {
85
-		if ( $role === null ) {
84
+	protected function addRole(string $value, ?string $role): string {
85
+		if ($role === null) {
86 86
 			return $value;
87 87
 		}
88 88
 
89
-		return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' .
90
-			$value .
89
+		return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'.
90
+			$value.
91 91
 			'</span>';
92 92
 	}
93 93
 
@@ -95,15 +95,15 @@  discard block
 block discarded – undo
95 95
 	 * @param string $key message key
96 96
 	 * @return string HTML
97 97
 	 */
98
-	protected function msgEscaped( string $key ): string {
99
-		return $this->messageLocalizer->msg( $key )->escaped();
98
+	protected function msgEscaped(string $key): string {
99
+		return $this->messageLocalizer->msg($key)->escaped();
100 100
 	}
101 101
 
102 102
 	/**
103 103
 	 * @param array $argument
104 104
 	 * @return array[] params (for Message::params)
105 105
 	 */
106
-	protected function renderArgument( array $argument ): array {
106
+	protected function renderArgument(array $argument): array {
107 107
 		$methods = [
108 108
 			ViolationMessage::TYPE_ENTITY_ID => 'renderEntityId',
109 109
 			ViolationMessage::TYPE_ENTITY_ID_LIST => 'renderEntityIdList',
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 		$value = $argument['value'];
125 125
 		$role = $argument['role'];
126 126
 
127
-		if ( array_key_exists( $type, $methods ) ) {
127
+		if (array_key_exists($type, $methods)) {
128 128
 			$method = $methods[$type];
129
-			$params = $this->$method( $value, $role );
129
+			$params = $this->$method($value, $role);
130 130
 		} else {
131 131
 			throw new InvalidArgumentException(
132
-				'Unknown ViolationMessage argument type ' . $type . '!'
132
+				'Unknown ViolationMessage argument type '.$type.'!'
133 133
 			);
134 134
 		}
135 135
 
@@ -143,36 +143,36 @@  discard block
 block discarded – undo
143 143
 	 * and return a single-element array with a raw message param (i. e. [ Message::rawParam( … ) ])
144 144
 	 * @return array[] list of parameters as accepted by Message::params()
145 145
 	 */
146
-	private function renderList( array $list, ?string $role, callable $render ): array {
147
-		if ( $list === [] ) {
146
+	private function renderList(array $list, ?string $role, callable $render): array {
147
+		if ($list === []) {
148 148
 			return [
149
-				Message::numParam( 0 ),
150
-				Message::rawParam( '<ul></ul>' ),
149
+				Message::numParam(0),
150
+				Message::rawParam('<ul></ul>'),
151 151
 			];
152 152
 		}
153 153
 
154
-		if ( count( $list ) > $this->maxListLength ) {
155
-			$list = array_slice( $list, 0, $this->maxListLength );
154
+		if (count($list) > $this->maxListLength) {
155
+			$list = array_slice($list, 0, $this->maxListLength);
156 156
 			$truncated = true;
157 157
 		}
158 158
 
159 159
 		$renderedParamsLists = array_map(
160 160
 			$render,
161 161
 			$list,
162
-			array_fill( 0, count( $list ), $role )
162
+			array_fill(0, count($list), $role)
163 163
 		);
164
-		$renderedParams = array_column( $renderedParamsLists, 0 );
165
-		$renderedElements = array_column( $renderedParams, 'raw' );
166
-		if ( isset( $truncated ) ) {
167
-			$renderedElements[] = $this->msgEscaped( 'ellipsis' );
164
+		$renderedParams = array_column($renderedParamsLists, 0);
165
+		$renderedElements = array_column($renderedParams, 'raw');
166
+		if (isset($truncated)) {
167
+			$renderedElements[] = $this->msgEscaped('ellipsis');
168 168
 		}
169 169
 
170 170
 		return array_merge(
171 171
 			[
172
-				Message::numParam( count( $list ) ),
172
+				Message::numParam(count($list)),
173 173
 				Message::rawParam(
174
-					'<ul><li>' .
175
-					implode( '</li><li>', $renderedElements ) .
174
+					'<ul><li>'.
175
+					implode('</li><li>', $renderedElements).
176 176
 					'</li></ul>'
177 177
 				),
178 178
 			],
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 	 * @param string|null $role one of the Role::* constants
186 186
 	 * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ])
187 187
 	 */
188
-	private function renderEntityId( EntityId $entityId, ?string $role ): array {
189
-		return [ Message::rawParam( $this->addRole(
190
-			$this->entityIdFormatter->formatEntityId( $entityId ),
188
+	private function renderEntityId(EntityId $entityId, ?string $role): array {
189
+		return [Message::rawParam($this->addRole(
190
+			$this->entityIdFormatter->formatEntityId($entityId),
191 191
 			$role
192
-		) ) ];
192
+		))];
193 193
 	}
194 194
 
195 195
 	/**
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @param string|null $role one of the Role::* constants
198 198
 	 * @return array[] list of parameters as accepted by Message::params()
199 199
 	 */
200
-	private function renderEntityIdList( array $entityIdList, ?string $role ): array {
201
-		return $this->renderList( $entityIdList, $role, [ $this, 'renderEntityId' ] );
200
+	private function renderEntityIdList(array $entityIdList, ?string $role): array {
201
+		return $this->renderList($entityIdList, $role, [$this, 'renderEntityId']);
202 202
 	}
203 203
 
204 204
 	/**
@@ -206,24 +206,24 @@  discard block
 block discarded – undo
206 206
 	 * @param string|null $role one of the Role::* constants
207 207
 	 * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ])
208 208
 	 */
209
-	private function renderItemIdSnakValue( ItemIdSnakValue $value, ?string $role ): array {
210
-		switch ( true ) {
209
+	private function renderItemIdSnakValue(ItemIdSnakValue $value, ?string $role): array {
210
+		switch (true) {
211 211
 			case $value->isValue():
212
-				return $this->renderEntityId( $value->getItemId(), $role );
212
+				return $this->renderEntityId($value->getItemId(), $role);
213 213
 			case $value->isSomeValue():
214
-				return [ Message::rawParam( $this->addRole(
215
-					'<span class="wikibase-snakview-variation-somevaluesnak">' .
216
-						$this->msgEscaped( 'wikibase-snakview-snaktypeselector-somevalue' ) .
214
+				return [Message::rawParam($this->addRole(
215
+					'<span class="wikibase-snakview-variation-somevaluesnak">'.
216
+						$this->msgEscaped('wikibase-snakview-snaktypeselector-somevalue').
217 217
 						'</span>',
218 218
 					$role
219
-				) ) ];
219
+				))];
220 220
 			case $value->isNoValue():
221
-				return [ Message::rawParam( $this->addRole(
222
-					'<span class="wikibase-snakview-variation-novaluesnak">' .
223
-					$this->msgEscaped( 'wikibase-snakview-snaktypeselector-novalue' ) .
221
+				return [Message::rawParam($this->addRole(
222
+					'<span class="wikibase-snakview-variation-novaluesnak">'.
223
+					$this->msgEscaped('wikibase-snakview-snaktypeselector-novalue').
224 224
 						'</span>',
225 225
 					$role
226
-				) ) ];
226
+				))];
227 227
 			default:
228 228
 				// @codeCoverageIgnoreStart
229 229
 				throw new LogicException(
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 	 * @param string|null $role one of the Role::* constants
239 239
 	 * @return array[] list of parameters as accepted by Message::params()
240 240
 	 */
241
-	private function renderItemIdSnakValueList( array $valueList, ?string $role ): array {
242
-		return $this->renderList( $valueList, $role, [ $this, 'renderItemIdSnakValue' ] );
241
+	private function renderItemIdSnakValueList(array $valueList, ?string $role): array {
242
+		return $this->renderList($valueList, $role, [$this, 'renderItemIdSnakValue']);
243 243
 	}
244 244
 
245 245
 	/**
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
 	 * @param string|null $role one of the Role::* constants
248 248
 	 * @return array[] list of parameters as accepted by Message::params()
249 249
 	 */
250
-	private function renderDataValue( DataValue $dataValue, ?string $role ): array {
251
-		return [ Message::rawParam( $this->addRole(
252
-			$this->dataValueFormatter->format( $dataValue ),
250
+	private function renderDataValue(DataValue $dataValue, ?string $role): array {
251
+		return [Message::rawParam($this->addRole(
252
+			$this->dataValueFormatter->format($dataValue),
253 253
 			$role
254
-		) ) ];
254
+		))];
255 255
 	}
256 256
 
257 257
 	/**
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * @param string|null $role one of the Role::* constants
260 260
 	 * @return array[] list of parameters as accepted by Message::params()
261 261
 	 */
262
-	private function renderDataValueType( string $dataValueType, ?string $role ): array {
262
+	private function renderDataValueType(string $dataValueType, ?string $role): array {
263 263
 		$messageKeys = [
264 264
 			'string' => 'datatypes-type-string',
265 265
 			'monolingualtext' => 'datatypes-type-monolingualtext',
@@ -268,15 +268,15 @@  discard block
 block discarded – undo
268 268
 			'wikibase-entityid' => 'wbqc-dataValueType-wikibase-entityid',
269 269
 		];
270 270
 
271
-		if ( array_key_exists( $dataValueType, $messageKeys ) ) {
272
-			return [ Message::rawParam( $this->addRole(
273
-				$this->msgEscaped( $messageKeys[$dataValueType] ),
271
+		if (array_key_exists($dataValueType, $messageKeys)) {
272
+			return [Message::rawParam($this->addRole(
273
+				$this->msgEscaped($messageKeys[$dataValueType]),
274 274
 				$role
275
-			) ) ];
275
+			))];
276 276
 		} else {
277 277
 			// @codeCoverageIgnoreStart
278 278
 			throw new LogicException(
279
-				'Unknown data value type ' . $dataValueType
279
+				'Unknown data value type '.$dataValueType
280 280
 			);
281 281
 			// @codeCoverageIgnoreEnd
282 282
 		}
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
 	 * @param string|null $role one of the Role::* constants
288 288
 	 * @return array[] list of parameters as accepted by Message::params()
289 289
 	 */
290
-	private function renderInlineCode( string $code, ?string $role ): array {
291
-		return [ Message::rawParam( $this->addRole(
292
-			'<code>' . htmlspecialchars( $code ) . '</code>',
290
+	private function renderInlineCode(string $code, ?string $role): array {
291
+		return [Message::rawParam($this->addRole(
292
+			'<code>'.htmlspecialchars($code).'</code>',
293 293
 			$role
294
-		) ) ];
294
+		))];
295 295
 	}
296 296
 
297 297
 	/**
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
 	 * @param string|null $role one of the Role::* constants
300 300
 	 * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ])
301 301
 	 */
302
-	private function renderConstraintScope( string $scope, ?string $role ): array {
303
-		switch ( $scope ) {
302
+	private function renderConstraintScope(string $scope, ?string $role): array {
303
+		switch ($scope) {
304 304
 			case Context::TYPE_STATEMENT:
305 305
 				$itemId = $this->config->get(
306 306
 					'WBQualityConstraintsConstraintCheckedOnMainValueId'
@@ -320,10 +320,10 @@  discard block
 block discarded – undo
320 320
 				// callers should never let this happen, but if it does happen,
321 321
 				// showing “unknown value” seems reasonable
322 322
 				// @codeCoverageIgnoreStart
323
-				return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role );
323
+				return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role);
324 324
 				// @codeCoverageIgnoreEnd
325 325
 		}
326
-		return $this->renderEntityId( new ItemId( $itemId ), $role );
326
+		return $this->renderEntityId(new ItemId($itemId), $role);
327 327
 	}
328 328
 
329 329
 	/**
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 	 * @param string|null $role one of the Role::* constants
332 332
 	 * @return array[] list of parameters as accepted by Message::params()
333 333
 	 */
334
-	private function renderConstraintScopeList( array $scopeList, ?string $role ): array {
335
-		return $this->renderList( $scopeList, $role, [ $this, 'renderConstraintScope' ] );
334
+	private function renderConstraintScopeList(array $scopeList, ?string $role): array {
335
+		return $this->renderList($scopeList, $role, [$this, 'renderConstraintScope']);
336 336
 	}
337 337
 
338 338
 	/**
@@ -340,25 +340,25 @@  discard block
 block discarded – undo
340 340
 	 * @param string|null $role one of the Role::* constants
341 341
 	 * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ])
342 342
 	 */
343
-	private function renderPropertyScope( string $scope, ?string $role ): array {
344
-		switch ( $scope ) {
343
+	private function renderPropertyScope(string $scope, ?string $role): array {
344
+		switch ($scope) {
345 345
 			case Context::TYPE_STATEMENT:
346
-				$itemId = $this->config->get( 'WBQualityConstraintsAsMainValueId' );
346
+				$itemId = $this->config->get('WBQualityConstraintsAsMainValueId');
347 347
 				break;
348 348
 			case Context::TYPE_QUALIFIER:
349
-				$itemId = $this->config->get( 'WBQualityConstraintsAsQualifiersId' );
349
+				$itemId = $this->config->get('WBQualityConstraintsAsQualifiersId');
350 350
 				break;
351 351
 			case Context::TYPE_REFERENCE:
352
-				$itemId = $this->config->get( 'WBQualityConstraintsAsReferencesId' );
352
+				$itemId = $this->config->get('WBQualityConstraintsAsReferencesId');
353 353
 				break;
354 354
 			default:
355 355
 				// callers should never let this happen, but if it does happen,
356 356
 				// showing “unknown value” seems reasonable
357 357
 				// @codeCoverageIgnoreStart
358
-				return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role );
358
+				return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role);
359 359
 				// @codeCoverageIgnoreEnd
360 360
 		}
361
-		return $this->renderEntityId( new ItemId( $itemId ), $role );
361
+		return $this->renderEntityId(new ItemId($itemId), $role);
362 362
 	}
363 363
 
364 364
 	/**
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 	 * @param string|null $role one of the Role::* constants
367 367
 	 * @return array[] list of parameters as accepted by Message::params()
368 368
 	 */
369
-	private function renderPropertyScopeList( array $scopeList, ?string $role ): array {
370
-		return $this->renderList( $scopeList, $role, [ $this, 'renderPropertyScope' ] );
369
+	private function renderPropertyScopeList(array $scopeList, ?string $role): array {
370
+		return $this->renderList($scopeList, $role, [$this, 'renderPropertyScope']);
371 371
 	}
372 372
 
373 373
 	/**
@@ -375,14 +375,14 @@  discard block
 block discarded – undo
375 375
 	 * @param string|null $role one of the Role::* constants
376 376
 	 * @return array[] list of parameters as accepted by Message::params()
377 377
 	 */
378
-	private function renderLanguage( string $languageCode, ?string $role ): array {
378
+	private function renderLanguage(string $languageCode, ?string $role): array {
379 379
 		return [
380 380
 			// ::renderList (through ::renderLanguageList) requires 'raw' parameter
381 381
 			// so we effectively build Message::plaintextParam here
382
-			Message::rawParam( htmlspecialchars(
383
-				$this->languageNameUtils->getLanguageName( $languageCode, $this->userLanguageCode )
384
-			) ),
385
-			Message::plaintextParam( $languageCode ),
382
+			Message::rawParam(htmlspecialchars(
383
+				$this->languageNameUtils->getLanguageName($languageCode, $this->userLanguageCode)
384
+			)),
385
+			Message::plaintextParam($languageCode),
386 386
 		];
387 387
 	}
388 388
 
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 	 * @param string|null $role one of the Role::* constants
392 392
 	 * @return array[] list of parameters as accepted by Message::params()
393 393
 	 */
394
-	private function renderLanguageList( array $languageCodes, ?string $role ): array {
395
-		return $this->renderList( $languageCodes, $role, [ $this, 'renderLanguage' ] );
394
+	private function renderLanguageList(array $languageCodes, ?string $role): array {
395
+		return $this->renderList($languageCodes, $role, [$this, 'renderLanguage']);
396 396
 	}
397 397
 
398 398
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Result/NullResult.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Result;
6 6
 
@@ -27,22 +27,22 @@  discard block
 block discarded – undo
27 27
 	 */
28 28
 	private const NULL_PROPERTY_ID = 'P2147483647';
29 29
 
30
-	public function __construct( ContextCursor $contextCursor ) {
30
+	public function __construct(ContextCursor $contextCursor) {
31 31
 		$constraint = new Constraint(
32 32
 			'null',
33
-			new NumericPropertyId( self::NULL_PROPERTY_ID ),
33
+			new NumericPropertyId(self::NULL_PROPERTY_ID),
34 34
 			'none',
35 35
 			[]
36 36
 		);
37
-		parent::__construct( $contextCursor, $constraint );
37
+		parent::__construct($contextCursor, $constraint);
38 38
 	}
39 39
 
40 40
 	public function getConstraint(): Constraint {
41
-		throw new DomainException( 'NullResult holds no constraint' );
41
+		throw new DomainException('NullResult holds no constraint');
42 42
 	}
43 43
 
44 44
 	public function getConstraintId(): string {
45
-		throw new DomainException( 'NullResult holds no constraint' );
45
+		throw new DomainException('NullResult holds no constraint');
46 46
 	}
47 47
 
48 48
 }
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\Api;
6 6
 
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 		CheckResultsRendererFactory $checkResultsRendererFactory,
82 82
 		IBufferingStatsdDataFactory $dataFactory
83 83
 	) {
84
-		parent::__construct( $main, $name );
84
+		parent::__construct($main, $name);
85 85
 		$this->entityIdParser = $entityIdParser;
86 86
 		$this->statementGuidValidator = $statementGuidValidator;
87
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
88
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
87
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
88
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
89 89
 		$this->resultsSource = $resultsSource;
90 90
 		$this->checkResultsRendererFactory = $checkResultsRendererFactory;
91 91
 		$this->dataFactory = $dataFactory;
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 
102 102
 		$params = $this->extractRequestParams();
103 103
 
104
-		$this->validateParameters( $params );
105
-		$entityIds = $this->parseEntityIds( $params );
106
-		$claimIds = $this->parseClaimIds( $params );
104
+		$this->validateParameters($params);
105
+		$entityIds = $this->parseEntityIds($params);
106
+		$claimIds = $this->parseClaimIds($params);
107 107
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
108 108
 		$statuses = $params[self::PARAM_STATUS];
109 109
 
110 110
 		$checkResultsRenderer = $this->checkResultsRendererFactory
111
-			->getCheckResultsRenderer( $this->getLanguage(), $this );
111
+			->getCheckResultsRenderer($this->getLanguage(), $this);
112 112
 
113 113
 		$this->getResult()->addValue(
114 114
 			null,
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 				)
123 123
 			)->getArray()
124 124
 		);
125
-		$this->resultBuilder->markSuccess( 1 );
125
+		$this->resultBuilder->markSuccess(1);
126 126
 	}
127 127
 
128 128
 	/**
@@ -130,24 +130,24 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @return EntityId[]
132 132
 	 */
133
-	private function parseEntityIds( array $params ): array {
133
+	private function parseEntityIds(array $params): array {
134 134
 		$ids = $params[self::PARAM_ID];
135 135
 
136
-		if ( $ids === null ) {
136
+		if ($ids === null) {
137 137
 			return [];
138
-		} elseif ( $ids === [] ) {
138
+		} elseif ($ids === []) {
139 139
 			$this->errorReporter->dieError(
140
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
140
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
141 141
 		}
142 142
 
143
-		return array_map( function ( $id ) {
143
+		return array_map(function($id) {
144 144
 			try {
145
-				return $this->entityIdParser->parse( $id );
146
-			} catch ( EntityIdParsingException $e ) {
145
+				return $this->entityIdParser->parse($id);
146
+			} catch (EntityIdParsingException $e) {
147 147
 				$this->errorReporter->dieError(
148
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
148
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
149 149
 			}
150
-		}, $ids );
150
+		}, $ids);
151 151
 	}
152 152
 
153 153
 	/**
@@ -155,35 +155,35 @@  discard block
 block discarded – undo
155 155
 	 *
156 156
 	 * @return string[]
157 157
 	 */
158
-	private function parseClaimIds( array $params ): array {
158
+	private function parseClaimIds(array $params): array {
159 159
 		$ids = $params[self::PARAM_CLAIM_ID];
160 160
 
161
-		if ( $ids === null ) {
161
+		if ($ids === null) {
162 162
 			return [];
163
-		} elseif ( $ids === [] ) {
163
+		} elseif ($ids === []) {
164 164
 			$this->errorReporter->dieError(
165
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
165
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
166 166
 		}
167 167
 
168
-		foreach ( $ids as $id ) {
169
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
168
+		foreach ($ids as $id) {
169
+			if (!$this->statementGuidValidator->validate($id)) {
170 170
 				$this->errorReporter->dieError(
171
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
171
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
172 172
 			}
173 173
 		}
174 174
 
175 175
 		return $ids;
176 176
 	}
177 177
 
178
-	private function validateParameters( array $params ): void {
179
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
180
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
178
+	private function validateParameters(array $params): void {
179
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
180
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
181 181
 		) {
182 182
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
183 183
 			$this->errorReporter->dieError(
184 184
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
185 185
 		}
186
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
186
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
187 187
 			$paramId = self::PARAM_ID;
188 188
 			$paramClaimId = self::PARAM_CLAIM_ID;
189 189
 			$this->errorReporter->dieError(
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 				],
225 225
 				ParamValidator::PARAM_ISMULTI => true,
226 226
 				ParamValidator::PARAM_ALL => true,
227
-				ParamValidator::PARAM_DEFAULT => implode( '|', CachingResultsSource::CACHED_STATUSES ),
227
+				ParamValidator::PARAM_DEFAULT => implode('|', CachingResultsSource::CACHED_STATUSES),
228 228
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
229 229
 			],
230 230
 		];
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/MultilingualTextViolationMessageRenderer.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Message;
6 6
 
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 		'wbqc-violation-message-format-clarification' => 'wbqc-violation-message-format',
28 28
 	];
29 29
 
30
-	public function render( ViolationMessage $violationMessage ): string {
31
-		if ( !array_key_exists( $violationMessage->getMessageKey(), self::ALTERNATIVE_MESSAGE_KEYS ) ) {
32
-			return parent::render( $violationMessage );
30
+	public function render(ViolationMessage $violationMessage): string {
31
+		if (!array_key_exists($violationMessage->getMessageKey(), self::ALTERNATIVE_MESSAGE_KEYS)) {
32
+			return parent::render($violationMessage);
33 33
 		}
34 34
 
35 35
 		$arguments = $violationMessage->getArguments();
36
-		$multilingualTextArgument = array_pop( $arguments );
36
+		$multilingualTextArgument = array_pop($arguments);
37 37
 		$multilingualTextParams = $this->renderMultilingualText(
38 38
 			// @phan-suppress-next-line PhanTypeArraySuspiciousNullable TODO Ensure this is not an actual issue
39 39
 			$multilingualTextArgument['value'],
@@ -41,22 +41,22 @@  discard block
 block discarded – undo
41 41
 			$multilingualTextArgument['role']
42 42
 		);
43 43
 
44
-		$paramsLists = [ [] ];
45
-		foreach ( $arguments as $argument ) {
46
-			$paramsLists[] = $this->renderArgument( $argument );
44
+		$paramsLists = [[]];
45
+		foreach ($arguments as $argument) {
46
+			$paramsLists[] = $this->renderArgument($argument);
47 47
 		}
48
-		$regularParams = call_user_func_array( 'array_merge', $paramsLists );
48
+		$regularParams = call_user_func_array('array_merge', $paramsLists);
49 49
 
50
-		if ( $multilingualTextParams === null ) {
50
+		if ($multilingualTextParams === null) {
51 51
 			return $this->messageLocalizer
52
-				->msg( self::ALTERNATIVE_MESSAGE_KEYS[$violationMessage->getMessageKey()] )
53
-				->params( $regularParams )
52
+				->msg(self::ALTERNATIVE_MESSAGE_KEYS[$violationMessage->getMessageKey()])
53
+				->params($regularParams)
54 54
 				->escaped();
55 55
 		} else {
56 56
 			return $this->messageLocalizer
57
-				->msg( $violationMessage->getMessageKey() )
58
-				->params( $regularParams )
59
-				->params( $multilingualTextParams )
57
+				->msg($violationMessage->getMessageKey())
58
+				->params($regularParams)
59
+				->params($multilingualTextParams)
60 60
 				->escaped();
61 61
 		}
62 62
 	}
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
 	 * @return array[]|null list of parameters as accepted by Message::params(),
68 68
 	 * or null if the text is not available in the user’s language
69 69
 	 */
70
-	protected function renderMultilingualText( MultilingualTextValue $text, ?string $role ): ?array {
70
+	protected function renderMultilingualText(MultilingualTextValue $text, ?string $role): ?array {
71 71
 		$texts = $text->getTexts();
72
-		foreach ( $this->languageFallbackChain->getFetchLanguageCodes() as $languageCode ) {
73
-			if ( array_key_exists( $languageCode, $texts ) ) {
74
-				return [ Message::rawParam( $this->addRole(
75
-					htmlspecialchars( $texts[$languageCode]->getText() ),
72
+		foreach ($this->languageFallbackChain->getFetchLanguageCodes() as $languageCode) {
73
+			if (array_key_exists($languageCode, $texts)) {
74
+				return [Message::rawParam($this->addRole(
75
+					htmlspecialchars($texts[$languageCode]->getText()),
76 76
 					$role
77
-				) ) ];
77
+				))];
78 78
 			}
79 79
 		}
80 80
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/ViolationMessageRendererFactory.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Message;
6 6
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
 	): ViolationMessageRenderer {
44 44
 		$userLanguageCode = $userLanguage->getCode();
45 45
 		$formatterOptions = new FormatterOptions();
46
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $userLanguageCode );
46
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $userLanguageCode);
47 47
 		return new MultilingualTextViolationMessageRenderer(
48 48
 			$this->entityIdHtmlLinkFormatterFactory
49
-				->getEntityIdFormatter( $userLanguage ),
49
+				->getEntityIdFormatter($userLanguage),
50 50
 			$this->valueFormatterFactory
51
-				->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ),
51
+				->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions),
52 52
 			$this->languageNameUtils,
53 53
 			$userLanguageCode,
54 54
 			$languageFallbackChain,
Please login to merge, or discard this patch.
src/Api/ResultsCache.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param WANObjectCache $cache
37 37
 	 * @param string $formatVersion The version of the API response format.
38 38
 	 */
39
-	public function __construct( WANObjectCache $cache, $formatVersion ) {
39
+	public function __construct(WANObjectCache $cache, $formatVersion) {
40 40
 		$this->cache = $cache;
41 41
 		$this->formatVersion = $formatVersion;
42 42
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param EntityId $entityId
46 46
 	 * @return string cache key
47 47
 	 */
48
-	public function makeKey( EntityId $entityId ) {
48
+	public function makeKey(EntityId $entityId) {
49 49
 		return $this->cache->makeKey(
50 50
 			'WikibaseQualityConstraints', // extension
51 51
 			'checkConstraints', // action
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 * @param array &$info
62 62
 	 * @return mixed
63 63
 	 */
64
-	public function get( EntityId $key, &$curTTL = null, array $checkKeys = [], array &$info = [] ) {
65
-		return $this->cache->get( $this->makeKey( $key ), $curTTL, $checkKeys, $info );
64
+	public function get(EntityId $key, &$curTTL = null, array $checkKeys = [], array &$info = []) {
65
+		return $this->cache->get($this->makeKey($key), $curTTL, $checkKeys, $info);
66 66
 	}
67 67
 
68 68
 	/**
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
 	 * @param array $opts
73 73
 	 * @return bool
74 74
 	 */
75
-	public function set( EntityId $key, $value, $ttl = 0, array $opts = [] ) {
76
-		return $this->cache->set( $this->makeKey( $key ), $value, $ttl, $opts );
75
+	public function set(EntityId $key, $value, $ttl = 0, array $opts = []) {
76
+		return $this->cache->set($this->makeKey($key), $value, $ttl, $opts);
77 77
 	}
78 78
 
79 79
 	/**
80 80
 	 * @param EntityId $key
81 81
 	 * @return bool
82 82
 	 */
83
-	public function delete( EntityId $key ) {
84
-		return $this->cache->delete( $this->makeKey( $key ) );
83
+	public function delete(EntityId $key) {
84
+		return $this->cache->delete($this->makeKey($key));
85 85
 	}
86 86
 
87 87
 }
Please login to merge, or discard this patch.
src/Api/CheckResultsRendererFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\Api;
6 6
 
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 		Language $userLanguage,
38 38
 		MessageLocalizer $messageLocalizer
39 39
 	): CheckResultsRenderer {
40
-		$languageFallbackChain = $this->languageFallbackChainFactory->newFromLanguage( $userLanguage );
40
+		$languageFallbackChain = $this->languageFallbackChainFactory->newFromLanguage($userLanguage);
41 41
 
42 42
 		return new CheckResultsRenderer(
43 43
 			$this->entityTitleLookup,
44 44
 			$this->entityIdLabelFormatterFactory
45
-				->getEntityIdFormatter( $userLanguage ),
45
+				->getEntityIdFormatter($userLanguage),
46 46
 			$languageFallbackChain,
47 47
 			$this->violationMessageRendererFactory
48 48
 				->getViolationMessageRenderer(
Please login to merge, or discard this patch.
src/ConstraintCheck/Result/CheckResultSerializer.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Result;
6 6
 
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 		$this->serializeDependencyMetadata = $serializeDependencyMetadata;
61 61
 	}
62 62
 
63
-	public function serialize( CheckResult $checkResult ): array {
63
+	public function serialize(CheckResult $checkResult): array {
64 64
 		$contextCursor = $checkResult->getContextCursor();
65 65
 
66 66
 		$serialization = [
67
-			self::KEY_CONTEXT_CURSOR => $this->contextCursorSerializer->serialize( $contextCursor ),
67
+			self::KEY_CONTEXT_CURSOR => $this->contextCursorSerializer->serialize($contextCursor),
68 68
 		];
69 69
 
70
-		if ( $checkResult instanceof NullResult ) {
70
+		if ($checkResult instanceof NullResult) {
71 71
 			$serialization[self::KEY_NULL_RESULT] = 1;
72 72
 		} else {
73 73
 			$constraint = $checkResult->getConstraint();
@@ -76,57 +76,57 @@  discard block
 block discarded – undo
76 76
 			$clarification = $checkResult->getConstraintClarification();
77 77
 
78 78
 			$serialization[self::KEY_CONSTRAINT] =
79
-				$this->constraintSerializer->serialize( $constraint );
79
+				$this->constraintSerializer->serialize($constraint);
80 80
 			$serialization[self::KEY_CHECK_RESULT_STATUS] =
81 81
 				$checkResult->getStatus();
82 82
 			$serialization[self::KEY_CACHING_METADATA] =
83
-				$this->serializeCachingMetadata( $cachingMetadata );
83
+				$this->serializeCachingMetadata($cachingMetadata);
84 84
 
85
-			if ( $violationMessage !== null ) {
85
+			if ($violationMessage !== null) {
86 86
 				$serialization[self::KEY_VIOLATION_MESSAGE] =
87
-					$this->violationMessageSerializer->serialize( $violationMessage );
87
+					$this->violationMessageSerializer->serialize($violationMessage);
88 88
 			}
89
-			if ( $clarification->getTexts() !== [] ) {
89
+			if ($clarification->getTexts() !== []) {
90 90
 				$serialization[self::KEY_CONSTRAINT_CLARIFICATION] =
91 91
 					$clarification->getArrayValue();
92 92
 			}
93 93
 		}
94 94
 
95
-		if ( $this->serializeDependencyMetadata ) {
95
+		if ($this->serializeDependencyMetadata) {
96 96
 			$serialization[self::KEY_DEPENDENCY_METADATA] =
97
-				$this->serializeDependencyMetadata( $checkResult );
97
+				$this->serializeDependencyMetadata($checkResult);
98 98
 		}
99 99
 
100 100
 		return $serialization;
101 101
 	}
102 102
 
103
-	private function serializeCachingMetadata( CachingMetadata $cachingMetadata ): array {
103
+	private function serializeCachingMetadata(CachingMetadata $cachingMetadata): array {
104 104
 		$maximumAge = $cachingMetadata->getMaximumAgeInSeconds();
105 105
 
106 106
 		$serialization = [];
107 107
 
108
-		if ( $maximumAge > 0 ) {
108
+		if ($maximumAge > 0) {
109 109
 			$serialization[self::KEY_CACHING_METADATA_MAX_AGE] = $maximumAge;
110 110
 		}
111 111
 
112 112
 		return $serialization;
113 113
 	}
114 114
 
115
-	private function serializeDependencyMetadata( CheckResult $checkResult ): array {
115
+	private function serializeDependencyMetadata(CheckResult $checkResult): array {
116 116
 		$dependencyMetadata = $checkResult->getMetadata()->getDependencyMetadata();
117 117
 		$entityIds = $dependencyMetadata->getEntityIds();
118 118
 		$futureTime = $dependencyMetadata->getFutureTime();
119 119
 
120 120
 		$serialization = [
121 121
 			self::KEY_DEPENDENCY_METADATA_ENTITY_IDS => array_map(
122
-				static function ( EntityId $entityId ) {
122
+				static function(EntityId $entityId) {
123 123
 					return $entityId->getSerialization();
124 124
 				},
125 125
 				$entityIds
126 126
 			),
127 127
 		];
128 128
 
129
-		if ( $futureTime !== null ) {
129
+		if ($futureTime !== null) {
130 130
 			$serialization[self::KEY_DEPENDENCY_METADATA_FUTURE_TIME] =
131 131
 				$futureTime->getArrayValue();
132 132
 		}
Please login to merge, or discard this patch.