Completed
Push — master ( 602e87...498003 )
by
unknown
01:47
created
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +287 added lines, -287 removed lines patch added patch discarded remove patch
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
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( new ViolationMessage( $msg ) );
88
+			throw new ConstraintParameterException(new ViolationMessage($msg));
89 89
 		}
90 90
 	}
91 91
 
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
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
-				( new ViolationMessage( 'wbqc-violation-message-parameter-single' ) )
102
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
101
+				(new ViolationMessage('wbqc-violation-message-parameter-single'))
102
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
103 103
 			);
104 104
 		}
105 105
 	}
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	 * @return void
112 112
 	 * @throws ConstraintParameterException
113 113
 	 */
114
-	private function requireValueParameter( Snak $snak, $parameterId ) {
115
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
114
+	private function requireValueParameter(Snak $snak, $parameterId) {
115
+		if (!($snak instanceof PropertyValueSnak)) {
116 116
 			throw new ConstraintParameterException(
117
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
118
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
117
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
118
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
119 119
 			);
120 120
 		}
121 121
 	}
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
 	 * @throws ConstraintParameterException
128 128
 	 * @return EntityId
129 129
 	 */
130
-	private function parseEntityIdParameter( array $snakSerialization, $parameterId ) {
131
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
132
-		$this->requireValueParameter( $snak, $parameterId );
130
+	private function parseEntityIdParameter(array $snakSerialization, $parameterId) {
131
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
132
+		$this->requireValueParameter($snak, $parameterId);
133 133
 		$value = $snak->getDataValue();
134
-		if ( $value instanceof EntityIdValue ) {
134
+		if ($value instanceof EntityIdValue) {
135 135
 			return $value->getEntityId();
136 136
 		} else {
137 137
 			throw new ConstraintParameterException(
138
-				( new ViolationMessage( 'wbqc-violation-message-parameter-entity' ) )
139
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
140
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
138
+				(new ViolationMessage('wbqc-violation-message-parameter-entity'))
139
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
140
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
141 141
 			);
142 142
 		}
143 143
 	}
@@ -148,20 +148,20 @@  discard block
 block discarded – undo
148 148
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
149 149
 	 * @return string[] class entity ID serializations
150 150
 	 */
151
-	public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) {
152
-		$this->checkError( $constraintParameters );
153
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
154
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
151
+	public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) {
152
+		$this->checkError($constraintParameters);
153
+		$classId = $this->config->get('WBQualityConstraintsClassId');
154
+		if (!array_key_exists($classId, $constraintParameters)) {
155 155
 			throw new ConstraintParameterException(
156
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
157
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
158
-					->withEntityId( new PropertyId( $classId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
156
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
157
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
158
+					->withEntityId(new PropertyId($classId), Role::CONSTRAINT_PARAMETER_PROPERTY)
159 159
 			);
160 160
 		}
161 161
 
162 162
 		$classes = [];
163
-		foreach ( $constraintParameters[$classId] as $class ) {
164
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
163
+		foreach ($constraintParameters[$classId] as $class) {
164
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
165 165
 		}
166 166
 		return $classes;
167 167
 	}
@@ -172,23 +172,23 @@  discard block
 block discarded – undo
172 172
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
173 173
 	 * @return string 'instance', 'subclass', or 'instanceOrSubclass'
174 174
 	 */
175
-	public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) {
176
-		$this->checkError( $constraintParameters );
177
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
178
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
175
+	public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) {
176
+		$this->checkError($constraintParameters);
177
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
178
+		if (!array_key_exists($relationId, $constraintParameters)) {
179 179
 			throw new ConstraintParameterException(
180
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
181
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
182
-					->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
180
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
181
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
182
+					->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
183 183
 			);
184 184
 		}
185 185
 
186
-		$this->requireSingleParameter( $constraintParameters, $relationId );
187
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
188
-		$instanceId = $this->config->get( 'WBQualityConstraintsInstanceOfRelationId' );
189
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfRelationId' );
190
-		$instanceOrSubclassId = $this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' );
191
-		switch ( $relationEntityId ) {
186
+		$this->requireSingleParameter($constraintParameters, $relationId);
187
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
188
+		$instanceId = $this->config->get('WBQualityConstraintsInstanceOfRelationId');
189
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfRelationId');
190
+		$instanceOrSubclassId = $this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId');
191
+		switch ($relationEntityId) {
192 192
 			case $instanceId:
193 193
 				return 'instance';
194 194
 			case $subclassId:
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
 				return 'instanceOrSubclass';
198 198
 			default:
199 199
 				throw new ConstraintParameterException(
200
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
201
-						->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
200
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
201
+						->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
202 202
 						->withEntityIdList(
203 203
 							[
204
-								new ItemId( $instanceId ),
205
-								new ItemId( $subclassId ),
206
-								new ItemId( $instanceOrSubclassId ),
204
+								new ItemId($instanceId),
205
+								new ItemId($subclassId),
206
+								new ItemId($instanceOrSubclassId),
207 207
 							],
208 208
 							Role::CONSTRAINT_PARAMETER_VALUE
209 209
 						)
@@ -218,20 +218,20 @@  discard block
 block discarded – undo
218 218
 	 * @throws ConstraintParameterException
219 219
 	 * @return PropertyId
220 220
 	 */
221
-	private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) {
222
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
223
-		$this->requireValueParameter( $snak, $parameterId );
221
+	private function parsePropertyIdParameter(array $snakSerialization, $parameterId) {
222
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
223
+		$this->requireValueParameter($snak, $parameterId);
224 224
 		$value = $snak->getDataValue();
225
-		if ( $value instanceof EntityIdValue ) {
225
+		if ($value instanceof EntityIdValue) {
226 226
 			$id = $value->getEntityId();
227
-			if ( $id instanceof PropertyId ) {
227
+			if ($id instanceof PropertyId) {
228 228
 				return $id;
229 229
 			}
230 230
 		}
231 231
 		throw new ConstraintParameterException(
232
-			( new ViolationMessage( 'wbqc-violation-message-parameter-property' ) )
233
-				->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
234
-				->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
232
+			(new ViolationMessage('wbqc-violation-message-parameter-property'))
233
+				->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
234
+				->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
235 235
 		);
236 236
 	}
237 237
 
@@ -242,33 +242,33 @@  discard block
 block discarded – undo
242 242
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
243 243
 	 * @return PropertyId
244 244
 	 */
245
-	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
246
-		$this->checkError( $constraintParameters );
247
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
248
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
245
+	public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) {
246
+		$this->checkError($constraintParameters);
247
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
248
+		if (!array_key_exists($propertyId, $constraintParameters)) {
249 249
 			throw new ConstraintParameterException(
250
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
251
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
252
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
250
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
251
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
252
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
253 253
 			);
254 254
 		}
255 255
 
256
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
257
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
256
+		$this->requireSingleParameter($constraintParameters, $propertyId);
257
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
258 258
 	}
259 259
 
260
-	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
260
+	private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) {
261 261
 		$dataValue = $snak->getDataValue();
262
-		if ( $dataValue instanceof EntityIdValue ) {
262
+		if ($dataValue instanceof EntityIdValue) {
263 263
 			$entityId = $dataValue->getEntityId();
264
-			if ( $entityId instanceof ItemId ) {
265
-				return ItemIdSnakValue::fromItemId( $entityId );
264
+			if ($entityId instanceof ItemId) {
265
+				return ItemIdSnakValue::fromItemId($entityId);
266 266
 			}
267 267
 		}
268 268
 		throw new ConstraintParameterException(
269
-			( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
270
-				->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
271
-				->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
269
+			(new ViolationMessage('wbqc-violation-message-parameter-item'))
270
+				->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
271
+				->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
272 272
 		);
273 273
 	}
274 274
 
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
 		$required,
287 287
 		$parameterId = null
288 288
 	) {
289
-		$this->checkError( $constraintParameters );
290
-		if ( $parameterId === null ) {
291
-			$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
289
+		$this->checkError($constraintParameters);
290
+		if ($parameterId === null) {
291
+			$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
292 292
 		}
293
-		if ( !array_key_exists( $parameterId, $constraintParameters ) ) {
294
-			if ( $required ) {
293
+		if (!array_key_exists($parameterId, $constraintParameters)) {
294
+			if ($required) {
295 295
 				throw new ConstraintParameterException(
296
-					( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
297
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
298
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
296
+					(new ViolationMessage('wbqc-violation-message-parameter-needed'))
297
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
298
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
299 299
 				);
300 300
 			} else {
301 301
 				return [];
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 		}
304 304
 
305 305
 		$values = [];
306
-		foreach ( $constraintParameters[$parameterId] as $parameter ) {
307
-			$snak = $this->snakDeserializer->deserialize( $parameter );
308
-			switch ( true ) {
306
+		foreach ($constraintParameters[$parameterId] as $parameter) {
307
+			$snak = $this->snakDeserializer->deserialize($parameter);
308
+			switch (true) {
309 309
 				case $snak instanceof PropertyValueSnak:
310
-					$values[] = $this->parseItemIdParameter( $snak, $parameterId );
310
+					$values[] = $this->parseItemIdParameter($snak, $parameterId);
311 311
 					break;
312 312
 				case $snak instanceof PropertySomeValueSnak:
313 313
 					$values[] = ItemIdSnakValue::someValue();
@@ -326,27 +326,27 @@  discard block
 block discarded – undo
326 326
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
327 327
 	 * @return PropertyId[]
328 328
 	 */
329
-	public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) {
330
-		$this->checkError( $constraintParameters );
331
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
332
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
329
+	public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) {
330
+		$this->checkError($constraintParameters);
331
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
332
+		if (!array_key_exists($propertyId, $constraintParameters)) {
333 333
 			throw new ConstraintParameterException(
334
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
335
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
336
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
334
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
335
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
336
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
337 337
 			);
338 338
 		}
339 339
 
340 340
 		$parameters = $constraintParameters[$propertyId];
341
-		if ( count( $parameters ) === 1 &&
342
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
341
+		if (count($parameters) === 1 &&
342
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
343 343
 		) {
344 344
 			return [];
345 345
 		}
346 346
 
347 347
 		$properties = [];
348
-		foreach ( $parameters as $parameter ) {
349
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
348
+		foreach ($parameters as $parameter) {
349
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
350 350
 		}
351 351
 		return $properties;
352 352
 	}
@@ -357,16 +357,16 @@  discard block
 block discarded – undo
357 357
 	 * @throws ConstraintParameterException
358 358
 	 * @return DataValue|null
359 359
 	 */
360
-	private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) {
361
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
362
-		if ( $snak instanceof PropertyValueSnak ) {
360
+	private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) {
361
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
362
+		if ($snak instanceof PropertyValueSnak) {
363 363
 			return $snak->getDataValue();
364
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
364
+		} elseif ($snak instanceof PropertyNoValueSnak) {
365 365
 			return null;
366 366
 		} else {
367 367
 			throw new ConstraintParameterException(
368
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
369
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
368
+				(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
369
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
370 370
 			);
371 371
 		}
372 372
 	}
@@ -376,10 +376,10 @@  discard block
 block discarded – undo
376 376
 	 * @param string $parameterId
377 377
 	 * @return DataValue|null
378 378
 	 */
379
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) {
379
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) {
380 380
 		try {
381
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
382
-		} catch ( ConstraintParameterException $e ) {
381
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
382
+		} catch (ConstraintParameterException $e) {
383 383
 			// unknown value means “now”
384 384
 			return new NowValue();
385 385
 		}
@@ -392,14 +392,14 @@  discard block
 block discarded – undo
392 392
 	 * @param string $unit
393 393
 	 * @return bool
394 394
 	 */
395
-	private function exactlyOneQuantityWithUnit( ?DataValue $min, ?DataValue $max, $unit ) {
396
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
397
-			!( $max instanceof UnboundedQuantityValue )
395
+	private function exactlyOneQuantityWithUnit(?DataValue $min, ?DataValue $max, $unit) {
396
+		if (!($min instanceof UnboundedQuantityValue) ||
397
+			!($max instanceof UnboundedQuantityValue)
398 398
 		) {
399 399
 			return false;
400 400
 		}
401 401
 
402
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
402
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
403 403
 	}
404 404
 
405 405
 	/**
@@ -412,42 +412,42 @@  discard block
 block discarded – undo
412 412
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
413 413
 	 * @return DataValue[] if the parameter is invalid or missing
414 414
 	 */
415
-	private function parseRangeParameter( array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type ) {
416
-		$this->checkError( $constraintParameters );
417
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
418
-			!array_key_exists( $maximumId, $constraintParameters )
415
+	private function parseRangeParameter(array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type) {
416
+		$this->checkError($constraintParameters);
417
+		if (!array_key_exists($minimumId, $constraintParameters) ||
418
+			!array_key_exists($maximumId, $constraintParameters)
419 419
 		) {
420 420
 			throw new ConstraintParameterException(
421
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-needed' ) )
422
-					->withDataValueType( $type )
423
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
424
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
425
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
421
+				(new ViolationMessage('wbqc-violation-message-range-parameters-needed'))
422
+					->withDataValueType($type)
423
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
424
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
425
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
426 426
 			);
427 427
 		}
428 428
 
429
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
430
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
429
+		$this->requireSingleParameter($constraintParameters, $minimumId);
430
+		$this->requireSingleParameter($constraintParameters, $maximumId);
431 431
 		$parseFunction = $type === 'time' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
432
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
433
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
432
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
433
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
434 434
 
435
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
436
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
435
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
436
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
437 437
 			throw new ConstraintParameterException(
438
-				new ViolationMessage( 'wbqc-violation-message-range-parameters-one-year' )
438
+				new ViolationMessage('wbqc-violation-message-range-parameters-one-year')
439 439
 			);
440 440
 		}
441
-		if ( $min === null && $max === null ||
442
-			$min !== null && $max !== null && $min->equals( $max ) ) {
441
+		if ($min === null && $max === null ||
442
+			$min !== null && $max !== null && $min->equals($max)) {
443 443
 			throw new ConstraintParameterException(
444
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-same' ) )
445
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
446
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
444
+				(new ViolationMessage('wbqc-violation-message-range-parameters-same'))
445
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
446
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
447 447
 			);
448 448
 		}
449 449
 
450
-		return [ $min, $max ];
450
+		return [$min, $max];
451 451
 	}
452 452
 
453 453
 	/**
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
458 458
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
459 459
 	 */
460
-	public function parseQuantityRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
460
+	public function parseQuantityRangeParameter(array $constraintParameters, $constraintTypeItemId) {
461 461
 		return $this->parseRangeParameter(
462 462
 			$constraintParameters,
463
-			$this->config->get( 'WBQualityConstraintsMinimumQuantityId' ),
464
-			$this->config->get( 'WBQualityConstraintsMaximumQuantityId' ),
463
+			$this->config->get('WBQualityConstraintsMinimumQuantityId'),
464
+			$this->config->get('WBQualityConstraintsMaximumQuantityId'),
465 465
 			$constraintTypeItemId,
466 466
 			'quantity'
467 467
 		);
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
475 475
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
476 476
 	 */
477
-	public function parseTimeRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
477
+	public function parseTimeRangeParameter(array $constraintParameters, $constraintTypeItemId) {
478 478
 		return $this->parseRangeParameter(
479 479
 			$constraintParameters,
480
-			$this->config->get( 'WBQualityConstraintsMinimumDateId' ),
481
-			$this->config->get( 'WBQualityConstraintsMaximumDateId' ),
480
+			$this->config->get('WBQualityConstraintsMinimumDateId'),
481
+			$this->config->get('WBQualityConstraintsMaximumDateId'),
482 482
 			$constraintTypeItemId,
483 483
 			'time'
484 484
 		);
@@ -491,17 +491,17 @@  discard block
 block discarded – undo
491 491
 	 * @throws ConstraintParameterException
492 492
 	 * @return string
493 493
 	 */
494
-	private function parseStringParameter( array $snakSerialization, $parameterId ) {
495
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
496
-		$this->requireValueParameter( $snak, $parameterId );
494
+	private function parseStringParameter(array $snakSerialization, $parameterId) {
495
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
496
+		$this->requireValueParameter($snak, $parameterId);
497 497
 		$value = $snak->getDataValue();
498
-		if ( $value instanceof StringValue ) {
498
+		if ($value instanceof StringValue) {
499 499
 			return $value->getValue();
500 500
 		} else {
501 501
 			throw new ConstraintParameterException(
502
-				( new ViolationMessage( 'wbqc-violation-message-parameter-string' ) )
503
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
504
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
502
+				(new ViolationMessage('wbqc-violation-message-parameter-string'))
503
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
504
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
505 505
 			);
506 506
 		}
507 507
 	}
@@ -512,15 +512,15 @@  discard block
 block discarded – undo
512 512
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
513 513
 	 * @return string
514 514
 	 */
515
-	public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) {
516
-		$this->checkError( $constraintParameters );
517
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
518
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
515
+	public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) {
516
+		$this->checkError($constraintParameters);
517
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
518
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
519 519
 			return '';
520 520
 		}
521 521
 
522
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
523
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
522
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
523
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
524 524
 	}
525 525
 
526 526
 	/**
@@ -529,19 +529,19 @@  discard block
 block discarded – undo
529 529
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
530 530
 	 * @return string
531 531
 	 */
532
-	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
533
-		$this->checkError( $constraintParameters );
534
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
535
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
532
+	public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) {
533
+		$this->checkError($constraintParameters);
534
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
535
+		if (!array_key_exists($formatId, $constraintParameters)) {
536 536
 			throw new ConstraintParameterException(
537
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
538
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
539
-					->withEntityId( new PropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
537
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
538
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
539
+					->withEntityId(new PropertyId($formatId), Role::CONSTRAINT_PARAMETER_PROPERTY)
540 540
 			);
541 541
 		}
542 542
 
543
-		$this->requireSingleParameter( $constraintParameters, $formatId );
544
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
543
+		$this->requireSingleParameter($constraintParameters, $formatId);
544
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
545 545
 	}
546 546
 
547 547
 	/**
@@ -549,16 +549,16 @@  discard block
 block discarded – undo
549 549
 	 * @throws ConstraintParameterException if the parameter is invalid
550 550
 	 * @return EntityId[]
551 551
 	 */
552
-	public function parseExceptionParameter( array $constraintParameters ) {
553
-		$this->checkError( $constraintParameters );
554
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
555
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
552
+	public function parseExceptionParameter(array $constraintParameters) {
553
+		$this->checkError($constraintParameters);
554
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
555
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
556 556
 			return [];
557 557
 		}
558 558
 
559 559
 		return array_map(
560
-			function( $snakSerialization ) use ( $exceptionId ) {
561
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
560
+			function($snakSerialization) use ($exceptionId) {
561
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
562 562
 			},
563 563
 			$constraintParameters[$exceptionId]
564 564
 		);
@@ -569,39 +569,39 @@  discard block
 block discarded – undo
569 569
 	 * @throws ConstraintParameterException if the parameter is invalid
570 570
 	 * @return string|null 'mandatory', 'suggestion' or null
571 571
 	 */
572
-	public function parseConstraintStatusParameter( array $constraintParameters ) {
573
-		$this->checkError( $constraintParameters );
574
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
575
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
572
+	public function parseConstraintStatusParameter(array $constraintParameters) {
573
+		$this->checkError($constraintParameters);
574
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
575
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
576 576
 			return null;
577 577
 		}
578 578
 
579
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
580
-		$supportedStatuses = [ new ItemId( $mandatoryId ) ];
581
-		if ( $this->config->get( 'WBQualityConstraintsEnableSuggestionConstraintStatus' ) ) {
582
-			$suggestionId = $this->config->get( 'WBQualityConstraintsSuggestionConstraintId' );
583
-			$supportedStatuses[] = new ItemId( $suggestionId );
579
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
580
+		$supportedStatuses = [new ItemId($mandatoryId)];
581
+		if ($this->config->get('WBQualityConstraintsEnableSuggestionConstraintStatus')) {
582
+			$suggestionId = $this->config->get('WBQualityConstraintsSuggestionConstraintId');
583
+			$supportedStatuses[] = new ItemId($suggestionId);
584 584
 		} else {
585 585
 			$suggestionId = null;
586 586
 		}
587 587
 
588
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
589
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
590
-		$this->requireValueParameter( $snak, $constraintStatusId );
588
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
589
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
590
+		$this->requireValueParameter($snak, $constraintStatusId);
591 591
 		'@phan-var \Wikibase\DataModel\Snak\PropertyValueSnak $snak';
592 592
 		$dataValue = $snak->getDataValue();
593 593
 		'@phan-var EntityIdValue $dataValue';
594 594
 		$entityId = $dataValue->getEntityId();
595 595
 		$statusId = $entityId->getSerialization();
596 596
 
597
-		if ( $statusId === $mandatoryId ) {
597
+		if ($statusId === $mandatoryId) {
598 598
 			return 'mandatory';
599
-		} elseif ( $statusId === $suggestionId ) {
599
+		} elseif ($statusId === $suggestionId) {
600 600
 			return 'suggestion';
601 601
 		} else {
602 602
 			throw new ConstraintParameterException(
603
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
604
-					->withEntityId( new PropertyId( $constraintStatusId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
603
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
604
+					->withEntityId(new PropertyId($constraintStatusId), Role::CONSTRAINT_PARAMETER_PROPERTY)
605 605
 					->withEntityIdList(
606 606
 						$supportedStatuses,
607 607
 						Role::CONSTRAINT_PARAMETER_VALUE
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
 	 * @return void
618 618
 	 * @throws ConstraintParameterException
619 619
 	 */
620
-	private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) {
621
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
620
+	private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) {
621
+		if (!($dataValue instanceof MonolingualTextValue)) {
622 622
 			throw new ConstraintParameterException(
623
-				( new ViolationMessage( 'wbqc-violation-message-parameter-monolingualtext' ) )
624
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
625
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
623
+				(new ViolationMessage('wbqc-violation-message-parameter-monolingualtext'))
624
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
625
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
626 626
 			);
627 627
 		}
628 628
 	}
@@ -635,31 +635,31 @@  discard block
 block discarded – undo
635 635
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
636 636
 	 * @return MultilingualTextValue
637 637
 	 */
638
-	private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) {
638
+	private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) {
639 639
 		$result = [];
640 640
 
641
-		foreach ( $snakSerializations as $snakSerialization ) {
642
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
643
-			$this->requireValueParameter( $snak, $parameterId );
641
+		foreach ($snakSerializations as $snakSerialization) {
642
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
643
+			$this->requireValueParameter($snak, $parameterId);
644 644
 
645 645
 			$value = $snak->getDataValue();
646
-			$this->requireMonolingualTextParameter( $value, $parameterId );
646
+			$this->requireMonolingualTextParameter($value, $parameterId);
647 647
 			/** @var MonolingualTextValue $value */
648 648
 			'@phan-var MonolingualTextValue $value';
649 649
 
650 650
 			$code = $value->getLanguageCode();
651
-			if ( array_key_exists( $code, $result ) ) {
651
+			if (array_key_exists($code, $result)) {
652 652
 				throw new ConstraintParameterException(
653
-					( new ViolationMessage( 'wbqc-violation-message-parameter-single-per-language' ) )
654
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
655
-						->withLanguage( $code )
653
+					(new ViolationMessage('wbqc-violation-message-parameter-single-per-language'))
654
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
655
+						->withLanguage($code)
656 656
 				);
657 657
 			}
658 658
 
659 659
 			$result[$code] = $value;
660 660
 		}
661 661
 
662
-		return new MultilingualTextValue( $result );
662
+		return new MultilingualTextValue($result);
663 663
 	}
664 664
 
665 665
 	/**
@@ -667,11 +667,11 @@  discard block
 block discarded – undo
667 667
 	 * @throws ConstraintParameterException if the parameter is invalid
668 668
 	 * @return MultilingualTextValue
669 669
 	 */
670
-	public function parseSyntaxClarificationParameter( array $constraintParameters ) {
671
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
670
+	public function parseSyntaxClarificationParameter(array $constraintParameters) {
671
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
672 672
 
673
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
674
-			return new MultilingualTextValue( [] );
673
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
674
+			return new MultilingualTextValue([]);
675 675
 		}
676 676
 
677 677
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
@@ -690,9 +690,9 @@  discard block
 block discarded – undo
690 690
 	 * @throws ConstraintParameterException if the parameter is invalid
691 691
 	 * @return string[]|null Context::TYPE_* constants
692 692
 	 */
693
-	public function parseConstraintScopeParameter( array $constraintParameters, $constraintTypeItemId, array $validScopes = null ) {
693
+	public function parseConstraintScopeParameter(array $constraintParameters, $constraintTypeItemId, array $validScopes = null) {
694 694
 		$contextTypes = [];
695
-		$parameterId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
695
+		$parameterId = $this->config->get('WBQualityConstraintsConstraintScopeId');
696 696
 		$items = $this->parseItemsParameter(
697 697
 			$constraintParameters,
698 698
 			$constraintTypeItemId,
@@ -700,23 +700,23 @@  discard block
 block discarded – undo
700 700
 			$parameterId
701 701
 		);
702 702
 
703
-		if ( $items === [] ) {
703
+		if ($items === []) {
704 704
 			return null;
705 705
 		}
706 706
 
707
-		foreach ( $items as $item ) {
708
-			$contextTypes[] = $this->parseContextTypeItem( $item, 'constraint scope', $parameterId );
707
+		foreach ($items as $item) {
708
+			$contextTypes[] = $this->parseContextTypeItem($item, 'constraint scope', $parameterId);
709 709
 		}
710 710
 
711
-		if ( $validScopes !== null ) {
712
-			$invalidScopes = array_diff( $contextTypes, $validScopes );
713
-			if ( $invalidScopes !== [] ) {
714
-				$invalidScope = array_pop( $invalidScopes );
711
+		if ($validScopes !== null) {
712
+			$invalidScopes = array_diff($contextTypes, $validScopes);
713
+			if ($invalidScopes !== []) {
714
+				$invalidScope = array_pop($invalidScopes);
715 715
 				throw new ConstraintParameterException(
716
-					( new ViolationMessage( 'wbqc-violation-message-invalid-scope' ) )
717
-						->withConstraintScope( $invalidScope, Role::CONSTRAINT_PARAMETER_VALUE )
718
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
719
-						->withConstraintScopeList( $validScopes, Role::CONSTRAINT_PARAMETER_VALUE )
716
+					(new ViolationMessage('wbqc-violation-message-invalid-scope'))
717
+						->withConstraintScope($invalidScope, Role::CONSTRAINT_PARAMETER_VALUE)
718
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
719
+						->withConstraintScopeList($validScopes, Role::CONSTRAINT_PARAMETER_VALUE)
720 720
 				);
721 721
 			}
722 722
 		}
@@ -730,8 +730,8 @@  discard block
 block discarded – undo
730 730
 	 * @param ItemId $unitId
731 731
 	 * @return string unit
732 732
 	 */
733
-	private function parseUnitParameter( ItemId $unitId ) {
734
-		return $this->unitItemConceptBaseUri . $unitId->getSerialization();
733
+	private function parseUnitParameter(ItemId $unitId) {
734
+		return $this->unitItemConceptBaseUri.$unitId->getSerialization();
735 735
 	}
736 736
 
737 737
 	/**
@@ -741,23 +741,23 @@  discard block
 block discarded – undo
741 741
 	 * @return UnitsParameter
742 742
 	 * @throws ConstraintParameterException
743 743
 	 */
744
-	private function parseUnitItem( ItemIdSnakValue $item ) {
745
-		switch ( true ) {
744
+	private function parseUnitItem(ItemIdSnakValue $item) {
745
+		switch (true) {
746 746
 			case $item->isValue():
747
-				$unit = $this->parseUnitParameter( $item->getItemId() );
747
+				$unit = $this->parseUnitParameter($item->getItemId());
748 748
 				return new UnitsParameter(
749
-					[ $item->getItemId() ],
750
-					[ UnboundedQuantityValue::newFromNumber( 1, $unit ) ],
749
+					[$item->getItemId()],
750
+					[UnboundedQuantityValue::newFromNumber(1, $unit)],
751 751
 					false
752 752
 				);
753 753
 			case $item->isSomeValue():
754
-				$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
754
+				$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
755 755
 				throw new ConstraintParameterException(
756
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
757
-						->withEntityId( new PropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
756
+					(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
757
+						->withEntityId(new PropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
758 758
 				);
759 759
 			case $item->isNoValue():
760
-				return new UnitsParameter( [], [], true );
760
+				return new UnitsParameter([], [], true);
761 761
 		}
762 762
 	}
763 763
 
@@ -767,26 +767,26 @@  discard block
 block discarded – undo
767 767
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
768 768
 	 * @return UnitsParameter
769 769
 	 */
770
-	public function parseUnitsParameter( array $constraintParameters, $constraintTypeItemId ) {
771
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
770
+	public function parseUnitsParameter(array $constraintParameters, $constraintTypeItemId) {
771
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
772 772
 		$unitItems = [];
773 773
 		$unitQuantities = [];
774 774
 		$unitlessAllowed = false;
775 775
 
776
-		foreach ( $items as $item ) {
777
-			$unit = $this->parseUnitItem( $item );
778
-			$unitItems = array_merge( $unitItems, $unit->getUnitItemIds() );
779
-			$unitQuantities = array_merge( $unitQuantities, $unit->getUnitQuantities() );
776
+		foreach ($items as $item) {
777
+			$unit = $this->parseUnitItem($item);
778
+			$unitItems = array_merge($unitItems, $unit->getUnitItemIds());
779
+			$unitQuantities = array_merge($unitQuantities, $unit->getUnitQuantities());
780 780
 			$unitlessAllowed = $unitlessAllowed || $unit->getUnitlessAllowed();
781 781
 		}
782 782
 
783
-		if ( $unitQuantities === [] && !$unitlessAllowed ) {
783
+		if ($unitQuantities === [] && !$unitlessAllowed) {
784 784
 			throw new LogicException(
785 785
 				'The "units" parameter is required, and yet we seem to be missing any allowed unit'
786 786
 			);
787 787
 		}
788 788
 
789
-		return new UnitsParameter( $unitItems, $unitQuantities, $unitlessAllowed );
789
+		return new UnitsParameter($unitItems, $unitQuantities, $unitlessAllowed);
790 790
 	}
791 791
 
792 792
 	/**
@@ -796,53 +796,53 @@  discard block
 block discarded – undo
796 796
 	 * @return EntityTypesParameter
797 797
 	 * @throws ConstraintParameterException
798 798
 	 */
799
-	private function parseEntityTypeItem( ItemIdSnakValue $item ) {
800
-		$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
799
+	private function parseEntityTypeItem(ItemIdSnakValue $item) {
800
+		$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
801 801
 
802
-		if ( !$item->isValue() ) {
802
+		if (!$item->isValue()) {
803 803
 			throw new ConstraintParameterException(
804
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
805
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
804
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
805
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
806 806
 			);
807 807
 		}
808 808
 
809 809
 		$itemId = $item->getItemId();
810
-		switch ( $itemId->getSerialization() ) {
811
-			case $this->config->get( 'WBQualityConstraintsWikibaseItemId' ):
810
+		switch ($itemId->getSerialization()) {
811
+			case $this->config->get('WBQualityConstraintsWikibaseItemId'):
812 812
 				$entityType = 'item';
813 813
 				break;
814
-			case $this->config->get( 'WBQualityConstraintsWikibasePropertyId' ):
814
+			case $this->config->get('WBQualityConstraintsWikibasePropertyId'):
815 815
 				$entityType = 'property';
816 816
 				break;
817
-			case $this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ):
817
+			case $this->config->get('WBQualityConstraintsWikibaseLexemeId'):
818 818
 				$entityType = 'lexeme';
819 819
 				break;
820
-			case $this->config->get( 'WBQualityConstraintsWikibaseFormId' ):
820
+			case $this->config->get('WBQualityConstraintsWikibaseFormId'):
821 821
 				$entityType = 'form';
822 822
 				break;
823
-			case $this->config->get( 'WBQualityConstraintsWikibaseSenseId' ):
823
+			case $this->config->get('WBQualityConstraintsWikibaseSenseId'):
824 824
 				$entityType = 'sense';
825 825
 				break;
826
-			case $this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ):
826
+			case $this->config->get('WBQualityConstraintsWikibaseMediaInfoId'):
827 827
 				$entityType = 'mediainfo';
828 828
 				break;
829 829
 			default:
830 830
 				$allowed = [
831
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseItemId' ) ),
832
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibasePropertyId' ) ),
833
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ) ),
834
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseFormId' ) ),
835
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseSenseId' ) ),
836
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ) ),
831
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseItemId')),
832
+					new ItemId($this->config->get('WBQualityConstraintsWikibasePropertyId')),
833
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseLexemeId')),
834
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseFormId')),
835
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseSenseId')),
836
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseMediaInfoId')),
837 837
 				];
838 838
 				throw new ConstraintParameterException(
839
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
840
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
841
-						->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
839
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
840
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
841
+						->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
842 842
 				);
843 843
 		}
844 844
 
845
-		return new EntityTypesParameter( [ $entityType ], [ $itemId ] );
845
+		return new EntityTypesParameter([$entityType], [$itemId]);
846 846
 	}
847 847
 
848 848
 	/**
@@ -851,27 +851,27 @@  discard block
 block discarded – undo
851 851
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
852 852
 	 * @return EntityTypesParameter
853 853
 	 */
854
-	public function parseEntityTypesParameter( array $constraintParameters, $constraintTypeItemId ) {
854
+	public function parseEntityTypesParameter(array $constraintParameters, $constraintTypeItemId) {
855 855
 		$entityTypes = [];
856 856
 		$entityTypeItemIds = [];
857
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
857
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
858 858
 
859
-		foreach ( $items as $item ) {
860
-			$entityType = $this->parseEntityTypeItem( $item );
861
-			$entityTypes = array_merge( $entityTypes, $entityType->getEntityTypes() );
862
-			$entityTypeItemIds = array_merge( $entityTypeItemIds, $entityType->getEntityTypeItemIds() );
859
+		foreach ($items as $item) {
860
+			$entityType = $this->parseEntityTypeItem($item);
861
+			$entityTypes = array_merge($entityTypes, $entityType->getEntityTypes());
862
+			$entityTypeItemIds = array_merge($entityTypeItemIds, $entityType->getEntityTypeItemIds());
863 863
 		}
864 864
 
865
-		if ( empty( $entityTypes ) ) {
865
+		if (empty($entityTypes)) {
866 866
 			// @codeCoverageIgnoreStart
867 867
 			throw new LogicException(
868
-				'The "entity types" parameter is required, ' .
868
+				'The "entity types" parameter is required, '.
869 869
 				'and yet we seem to be missing any allowed entity type'
870 870
 			);
871 871
 			// @codeCoverageIgnoreEnd
872 872
 		}
873 873
 
874
-		return new EntityTypesParameter( $entityTypes, $entityTypeItemIds );
874
+		return new EntityTypesParameter($entityTypes, $entityTypeItemIds);
875 875
 	}
876 876
 
877 877
 	/**
@@ -879,18 +879,18 @@  discard block
 block discarded – undo
879 879
 	 * @throws ConstraintParameterException if the parameter is invalid
880 880
 	 * @return PropertyId[]
881 881
 	 */
882
-	public function parseSeparatorsParameter( array $constraintParameters ) {
883
-		$separatorId = $this->config->get( 'WBQualityConstraintsSeparatorId' );
882
+	public function parseSeparatorsParameter(array $constraintParameters) {
883
+		$separatorId = $this->config->get('WBQualityConstraintsSeparatorId');
884 884
 
885
-		if ( !array_key_exists( $separatorId, $constraintParameters ) ) {
885
+		if (!array_key_exists($separatorId, $constraintParameters)) {
886 886
 			return [];
887 887
 		}
888 888
 
889 889
 		$parameters = $constraintParameters[$separatorId];
890 890
 		$separators = [];
891 891
 
892
-		foreach ( $parameters as $parameter ) {
893
-			$separators[] = $this->parsePropertyIdParameter( $parameter, $separatorId );
892
+		foreach ($parameters as $parameter) {
893
+			$separators[] = $this->parsePropertyIdParameter($parameter, $separatorId);
894 894
 		}
895 895
 
896 896
 		return $separators;
@@ -905,26 +905,26 @@  discard block
 block discarded – undo
905 905
 	 * @return string one of the Context::TYPE_* constants
906 906
 	 * @throws ConstraintParameterException
907 907
 	 */
908
-	private function parseContextTypeItem( ItemIdSnakValue $item, $use, $parameterId ) {
909
-		if ( !$item->isValue() ) {
908
+	private function parseContextTypeItem(ItemIdSnakValue $item, $use, $parameterId) {
909
+		if (!$item->isValue()) {
910 910
 			throw new ConstraintParameterException(
911
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
912
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
911
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
912
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
913 913
 			);
914 914
 		}
915 915
 
916
-		if ( $use === 'constraint scope' ) {
917
-			$mainSnakId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' );
918
-			$qualifiersId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' );
919
-			$referencesId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' );
916
+		if ($use === 'constraint scope') {
917
+			$mainSnakId = $this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId');
918
+			$qualifiersId = $this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId');
919
+			$referencesId = $this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId');
920 920
 		} else {
921
-			$mainSnakId = $this->config->get( 'WBQualityConstraintsAsMainValueId' );
922
-			$qualifiersId = $this->config->get( 'WBQualityConstraintsAsQualifiersId' );
923
-			$referencesId = $this->config->get( 'WBQualityConstraintsAsReferencesId' );
921
+			$mainSnakId = $this->config->get('WBQualityConstraintsAsMainValueId');
922
+			$qualifiersId = $this->config->get('WBQualityConstraintsAsQualifiersId');
923
+			$referencesId = $this->config->get('WBQualityConstraintsAsReferencesId');
924 924
 		}
925 925
 
926 926
 		$itemId = $item->getItemId();
927
-		switch ( $itemId->getSerialization() ) {
927
+		switch ($itemId->getSerialization()) {
928 928
 			case $mainSnakId:
929 929
 				return Context::TYPE_STATEMENT;
930 930
 			case $qualifiersId:
@@ -932,11 +932,11 @@  discard block
 block discarded – undo
932 932
 			case $referencesId:
933 933
 				return Context::TYPE_REFERENCE;
934 934
 			default:
935
-				$allowed = [ $mainSnakId, $qualifiersId, $referencesId ];
935
+				$allowed = [$mainSnakId, $qualifiersId, $referencesId];
936 936
 				throw new ConstraintParameterException(
937
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
938
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
939
-						->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
937
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
938
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
939
+						->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
940 940
 				);
941 941
 		}
942 942
 	}
@@ -947,9 +947,9 @@  discard block
 block discarded – undo
947 947
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
948 948
 	 * @return string[] list of Context::TYPE_* constants
949 949
 	 */
950
-	public function parsePropertyScopeParameter( array $constraintParameters, $constraintTypeItemId ) {
950
+	public function parsePropertyScopeParameter(array $constraintParameters, $constraintTypeItemId) {
951 951
 		$contextTypes = [];
952
-		$parameterId = $this->config->get( 'WBQualityConstraintsPropertyScopeId' );
952
+		$parameterId = $this->config->get('WBQualityConstraintsPropertyScopeId');
953 953
 		$items = $this->parseItemsParameter(
954 954
 			$constraintParameters,
955 955
 			$constraintTypeItemId,
@@ -957,14 +957,14 @@  discard block
 block discarded – undo
957 957
 			$parameterId
958 958
 		);
959 959
 
960
-		foreach ( $items as $item ) {
961
-			$contextTypes[] = $this->parseContextTypeItem( $item, 'property scope', $parameterId );
960
+		foreach ($items as $item) {
961
+			$contextTypes[] = $this->parseContextTypeItem($item, 'property scope', $parameterId);
962 962
 		}
963 963
 
964
-		if ( empty( $contextTypes ) ) {
964
+		if (empty($contextTypes)) {
965 965
 			// @codeCoverageIgnoreStart
966 966
 			throw new LogicException(
967
-				'The "property scope" parameter is required, ' .
967
+				'The "property scope" parameter is required, '.
968 968
 				'and yet we seem to be missing any allowed scope'
969 969
 			);
970 970
 			// @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.
src/Api/CheckConstraintsRdf.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		EntityIdLookup $entityIdLookup,
48 48
 		RdfVocabulary $rdfVocabulary
49 49
 	) {
50
-		parent::__construct( $page, $context );
50
+		parent::__construct($page, $context);
51 51
 		$this->resultsSource = $resultsSource;
52 52
 		$this->entityIdLookup = $entityIdLookup;
53 53
 		$this->rdfVocabulary = $rdfVocabulary;
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	 * @param string $guid
109 109
 	 * @return string
110 110
 	 */
111
-	private function cleanupGuid( $guid ) {
112
-		return preg_replace( '/[^\w-]/', '-', $guid );
111
+	private function cleanupGuid($guid) {
112
+		return preg_replace('/[^\w-]/', '-', $guid);
113 113
 	}
114 114
 
115 115
 	/**
@@ -121,60 +121,60 @@  discard block
 block discarded – undo
121 121
 		$response = $this->getRequest()->response();
122 122
 		$this->getOutput()->disable();
123 123
 
124
-		if ( !$this->resultsSource instanceof CachingResultsSource ) {
124
+		if (!$this->resultsSource instanceof CachingResultsSource) {
125 125
 			// TODO: make configurable whether only cached results are returned
126
-			$response->statusHeader( 501 ); // Not Implemented
126
+			$response->statusHeader(501); // Not Implemented
127 127
 			return null;
128 128
 		}
129 129
 
130
-		$entityId = $this->entityIdLookup->getEntityIdForTitle( $this->getTitle() );
131
-		if ( $entityId === null ) {
132
-			$response->statusHeader( 404 ); // Not Found
130
+		$entityId = $this->entityIdLookup->getEntityIdForTitle($this->getTitle());
131
+		if ($entityId === null) {
132
+			$response->statusHeader(404); // Not Found
133 133
 			return null;
134 134
 		}
135
-		$revId = $this->getRequest()->getInt( 'revision' );
135
+		$revId = $this->getRequest()->getInt('revision');
136 136
 
137
-		$results = $this->resultsSource->getStoredResults( $entityId, $revId );
138
-		if ( $results === null ) {
139
-			$response->statusHeader( 204 ); // No Content
137
+		$results = $this->resultsSource->getStoredResults($entityId, $revId);
138
+		if ($results === null) {
139
+			$response->statusHeader(204); // No Content
140 140
 			return null;
141 141
 		}
142 142
 
143 143
 		$format = 'ttl'; // TODO: make format an option
144 144
 
145 145
 		$writerFactory = new RdfWriterFactory();
146
-		$formatName = $writerFactory->getFormatName( $format );
147
-		$contentType = $writerFactory->getMimeTypes( $formatName )[0];
146
+		$formatName = $writerFactory->getFormatName($format);
147
+		$contentType = $writerFactory->getMimeTypes($formatName)[0];
148 148
 
149
-		$writer = $writerFactory->getWriter( $formatName );
150
-		foreach ( [ RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY ] as $ns ) {
151
-			$writer->prefix( $ns, $this->rdfVocabulary->getNamespaceURI( $ns ) );
149
+		$writer = $writerFactory->getWriter($formatName);
150
+		foreach ([RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY] as $ns) {
151
+			$writer->prefix($ns, $this->rdfVocabulary->getNamespaceURI($ns));
152 152
 		}
153 153
 		$writer->start();
154 154
 		$writtenAny = false;
155 155
 
156
-		foreach ( $results->getArray() as $checkResult ) {
157
-			if ( $checkResult instanceof NullResult ) {
156
+		foreach ($results->getArray() as $checkResult) {
157
+			if ($checkResult instanceof NullResult) {
158 158
 				continue;
159 159
 			}
160
-			if ( $checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS ) {
160
+			if ($checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS) {
161 161
 				continue;
162 162
 			}
163 163
 			$writtenAny = true;
164
-			$writer->about( RdfVocabulary::NS_STATEMENT,
165
-				$this->cleanupGuid( $checkResult->getContextCursor()->getStatementGuid() ) )
166
-				->say( RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint' )
167
-				->is( RdfVocabulary::NS_STATEMENT,
168
-					$this->cleanupGuid( $checkResult->getConstraint()->getConstraintId() ) );
164
+			$writer->about(RdfVocabulary::NS_STATEMENT,
165
+				$this->cleanupGuid($checkResult->getContextCursor()->getStatementGuid()))
166
+				->say(RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint')
167
+				->is(RdfVocabulary::NS_STATEMENT,
168
+					$this->cleanupGuid($checkResult->getConstraint()->getConstraintId()));
169 169
 		}
170 170
 		$writer->finish();
171
-		if ( $writtenAny ) {
172
-			$response->header( "Content-Type: $contentType; charset=UTF-8" );
171
+		if ($writtenAny) {
172
+			$response->header("Content-Type: $contentType; charset=UTF-8");
173 173
 			echo $writer->drain();
174 174
 		} else {
175 175
 			// Do not output RDF if we haven't written any actual statements. Output 204 instead
176 176
 			$writer->drain();
177
-			$response->statusHeader( 204 ); // No Content
177
+			$response->statusHeader(204); // No Content
178 178
 		}
179 179
 		return null;
180 180
 	}
Please login to merge, or discard this patch.
src/Api/CheckResultsRenderer.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 	 * @param CachedCheckResults $checkResults
52 52
 	 * @return CachedCheckConstraintsResponse
53 53
 	 */
54
-	public function render( CachedCheckResults $checkResults ) {
54
+	public function render(CachedCheckResults $checkResults) {
55 55
 		$response = [];
56
-		foreach ( $checkResults->getArray() as $checkResult ) {
57
-			$resultArray = $this->checkResultToArray( $checkResult );
58
-			$checkResult->getContextCursor()->storeCheckResultInArray( $resultArray, $response );
56
+		foreach ($checkResults->getArray() as $checkResult) {
57
+			$resultArray = $this->checkResultToArray($checkResult);
58
+			$checkResult->getContextCursor()->storeCheckResultInArray($resultArray, $response);
59 59
 		}
60 60
 		return new CachedCheckConstraintsResponse(
61 61
 			$response,
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 		);
64 64
 	}
65 65
 
66
-	public function checkResultToArray( CheckResult $checkResult ) {
67
-		if ( $checkResult instanceof NullResult ) {
66
+	public function checkResultToArray(CheckResult $checkResult) {
67
+		if ($checkResult instanceof NullResult) {
68 68
 			return null;
69 69
 		}
70 70
 
71 71
 		$constraintId = $checkResult->getConstraint()->getConstraintId();
72 72
 		$typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId();
73
-		$constraintPropertyId = new PropertyId( $checkResult->getContextCursor()->getSnakPropertyId() );
73
+		$constraintPropertyId = new PropertyId($checkResult->getContextCursor()->getSnakPropertyId());
74 74
 
75
-		$title = $this->entityTitleLookup->getTitleForId( $constraintPropertyId );
75
+		$title = $this->entityTitleLookup->getTitleForId($constraintPropertyId);
76 76
 		$talkTitle = $title->getTalkPageIfDefined();
77
-		$typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) );
78
-		$link = $title->getFullURL() . '#' . $constraintId;
77
+		$typeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($typeItemId));
78
+		$link = $title->getFullURL().'#'.$constraintId;
79 79
 
80 80
 		$constraint = [
81 81
 			'id' => $constraintId,
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 			'constraint' => $constraint
92 92
 		];
93 93
 		$message = $checkResult->getMessage();
94
-		if ( $message ) {
95
-			$result['message-html'] = $this->violationMessageRenderer->render( $message );
94
+		if ($message) {
95
+			$result['message-html'] = $this->violationMessageRenderer->render($message);
96 96
 		}
97
-		if ( $checkResult->getContextCursor()->getType() === Context::TYPE_STATEMENT ) {
97
+		if ($checkResult->getContextCursor()->getType() === Context::TYPE_STATEMENT) {
98 98
 			$result['claim'] = $checkResult->getContextCursor()->getStatementGuid();
99 99
 		}
100 100
 		$cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray();
101
-		if ( $cachingMetadataArray !== null ) {
101
+		if ($cachingMetadataArray !== null) {
102 102
 			$result['cached'] = $cachingMetadataArray;
103 103
 		}
104 104
 
Please login to merge, or discard this patch.
maintenance/ImportConstraintStatements.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 use WikibaseQuality\ConstraintReport\Job\UpdateConstraintsTableJob;
10 10
 
11 11
 // @codeCoverageIgnoreStart
12
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
13
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
12
+$basePath = getenv("MW_INSTALL_PATH") !== false
13
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
14 14
 
15
-require_once $basePath . "/maintenance/Maintenance.php";
15
+require_once $basePath."/maintenance/Maintenance.php";
16 16
 // @codeCoverageIgnoreEnd
17 17
 
18 18
 /**
@@ -37,39 +37,39 @@  discard block
 block discarded – undo
37 37
 
38 38
 	public function __construct() {
39 39
 		parent::__construct();
40
-		$this->newUpdateConstraintsTableJob = function ( $propertyIdSerialization ) {
40
+		$this->newUpdateConstraintsTableJob = function($propertyIdSerialization) {
41 41
 			return UpdateConstraintsTableJob::newFromGlobalState(
42 42
 				Title::newMainPage(),
43
-				[ 'propertyId' => $propertyIdSerialization ]
43
+				['propertyId' => $propertyIdSerialization]
44 44
 			);
45 45
 		};
46 46
 
47
-		$this->addDescription( 'Imports property constraints from statements on properties' );
48
-		$this->requireExtension( 'WikibaseQualityConstraints' );
47
+		$this->addDescription('Imports property constraints from statements on properties');
48
+		$this->requireExtension('WikibaseQualityConstraints');
49 49
 
50 50
 		// Wikibase classes are not yet loaded, so setup services in a callback run in execute
51 51
 		// that can be overridden in tests.
52
-		$this->setupServices = function () {
52
+		$this->setupServices = function() {
53 53
 			$repo = WikibaseRepo::getDefaultInstance();
54 54
 			$this->propertyInfoLookup = $repo->getStore()->getPropertyInfoLookup();
55 55
 		};
56 56
 	}
57 57
 
58 58
 	public function execute() {
59
-		( $this->setupServices )();
60
-		if ( !$this->getConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
61
-			$this->error( 'Constraint statements are not enabled. Aborting.' );
59
+		($this->setupServices)();
60
+		if (!$this->getConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) {
61
+			$this->error('Constraint statements are not enabled. Aborting.');
62 62
 			return;
63 63
 		}
64 64
 
65
-		foreach ( $this->propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info ) {
66
-			$this->output( sprintf( 'Importing constraint statements for % 6s... ', $propertyIdSerialization ), $propertyIdSerialization );
67
-			$startTime = microtime( true );
68
-			$job = call_user_func( $this->newUpdateConstraintsTableJob, $propertyIdSerialization );
65
+		foreach ($this->propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info) {
66
+			$this->output(sprintf('Importing constraint statements for % 6s... ', $propertyIdSerialization), $propertyIdSerialization);
67
+			$startTime = microtime(true);
68
+			$job = call_user_func($this->newUpdateConstraintsTableJob, $propertyIdSerialization);
69 69
 			$job->run();
70
-			$endTime = microtime( true );
71
-			$millis = ( $endTime - $startTime ) * 1000;
72
-			$this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization );
70
+			$endTime = microtime(true);
71
+			$millis = ($endTime - $startTime) * 1000;
72
+			$this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization);
73 73
 		}
74 74
 	}
75 75
 
Please login to merge, or discard this patch.
src/ServiceWiring.php 1 patch
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -28,47 +28,47 @@  discard block
 block discarded – undo
28 28
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer;
29 29
 
30 30
 return [
31
-	ConstraintsServices::EXPIRY_LOCK => function( MediaWikiServices $services ) {
32
-		return new ExpiryLock( ObjectCache::getInstance( CACHE_ANYTHING ) );
31
+	ConstraintsServices::EXPIRY_LOCK => function(MediaWikiServices $services) {
32
+		return new ExpiryLock(ObjectCache::getInstance(CACHE_ANYTHING));
33 33
 	},
34 34
 
35
-	ConstraintsServices::LOGGING_HELPER => function( MediaWikiServices $services ) {
35
+	ConstraintsServices::LOGGING_HELPER => function(MediaWikiServices $services) {
36 36
 		return new LoggingHelper(
37 37
 			$services->getStatsdDataFactory(),
38
-			LoggerFactory::getInstance( 'WikibaseQualityConstraints' ),
38
+			LoggerFactory::getInstance('WikibaseQualityConstraints'),
39 39
 			$services->getMainConfig()
40 40
 		);
41 41
 	},
42 42
 
43
-	ConstraintsServices::CONSTRAINT_STORE => function( MediaWikiServices $services ) {
43
+	ConstraintsServices::CONSTRAINT_STORE => function(MediaWikiServices $services) {
44 44
 		$wbRepo = WikibaseRepo::getDefaultInstance();
45 45
 		$sourceDefinitions = $wbRepo->getEntitySourceDefinitions();
46
-		$propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE );
46
+		$propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE);
47 47
 		$dbName = $propertySource->getDatabaseName();
48 48
 
49
-		if ( $propertySource->getSourceName() !== $wbRepo->getLocalEntitySource()->getSourceName() ) {
50
-			throw new \RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' );
49
+		if ($propertySource->getSourceName() !== $wbRepo->getLocalEntitySource()->getSourceName()) {
50
+			throw new \RuntimeException('Can\'t get a ConstraintStore for a non local entity source.');
51 51
 		}
52 52
 
53 53
 		return new ConstraintRepositoryStore(
54
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
54
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
55 55
 			$dbName
56 56
 		);
57 57
 	},
58 58
 
59
-	ConstraintsServices::CONSTRAINT_LOOKUP => function( MediaWikiServices $services ) {
59
+	ConstraintsServices::CONSTRAINT_LOOKUP => function(MediaWikiServices $services) {
60 60
 		$wbRepo = WikibaseRepo::getDefaultInstance();
61 61
 		$sourceDefinitions = $wbRepo->getEntitySourceDefinitions();
62
-		$propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE );
62
+		$propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE);
63 63
 		$dbName = $propertySource->getDatabaseName();
64 64
 		$rawLookup = new ConstraintRepositoryLookup(
65
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
65
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
66 66
 			$dbName
67 67
 		);
68
-		return new CachingConstraintLookup( $rawLookup );
68
+		return new CachingConstraintLookup($rawLookup);
69 69
 	},
70 70
 
71
-	ConstraintsServices::CHECK_RESULT_SERIALIZER => function( MediaWikiServices $services ) {
71
+	ConstraintsServices::CHECK_RESULT_SERIALIZER => function(MediaWikiServices $services) {
72 72
 		return new CheckResultSerializer(
73 73
 			new ConstraintSerializer(
74 74
 				false // constraint parameters are not exposed
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 		);
80 80
 	},
81 81
 
82
-	ConstraintsServices::CHECK_RESULT_DESERIALIZER => function( MediaWikiServices $services ) {
82
+	ConstraintsServices::CHECK_RESULT_DESERIALIZER => function(MediaWikiServices $services) {
83 83
 		// TODO in the future, get EntityIdParser and DataValueFactory from $services?
84 84
 		$repo = WikibaseRepo::getDefaultInstance();
85 85
 		$entityIdParser = $repo->getEntityIdParser();
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 		);
97 97
 	},
98 98
 
99
-	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function( MediaWikiServices $services ) {
99
+	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function(MediaWikiServices $services) {
100 100
 		return new ViolationMessageSerializer();
101 101
 	},
102 102
 
103
-	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function( MediaWikiServices $services ) {
103
+	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function(MediaWikiServices $services) {
104 104
 		// TODO in the future, get EntityIdParser and DataValueFactory from $services?
105 105
 		$repo = WikibaseRepo::getDefaultInstance();
106 106
 		$entityIdParser = $repo->getEntityIdParser();
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		);
113 113
 	},
114 114
 
115
-	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function( MediaWikiServices $services ) {
115
+	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) {
116 116
 		// TODO in the future, get DeserializerFactory and entity source definitions from $services?
117 117
 		$repo = WikibaseRepo::getDefaultInstance();
118 118
 		$deserializerFactory = $repo->getBaseDataModelDeserializerFactory();
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
 		return new ConstraintParameterParser(
122 122
 			$services->getMainConfig(),
123 123
 			$deserializerFactory,
124
-			$entitySourceDefinitions->getSourceForEntityType( 'item' )->getConceptBaseUri()
124
+			$entitySourceDefinitions->getSourceForEntityType('item')->getConceptBaseUri()
125 125
 		);
126 126
 	},
127 127
 
128
-	ConstraintsServices::CONNECTION_CHECKER_HELPER => function( MediaWikiServices $services ) {
128
+	ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) {
129 129
 		return new ConnectionCheckerHelper();
130 130
 	},
131 131
 
132
-	ConstraintsServices::RANGE_CHECKER_HELPER => function( MediaWikiServices $services ) {
132
+	ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) {
133 133
 		// TODO in the future, get UnitConverter from $services?
134 134
 		$repo = WikibaseRepo::getDefaultInstance();
135 135
 		$unitConverter = $repo->getUnitConverter();
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 		);
141 141
 	},
142 142
 
143
-	ConstraintsServices::SPARQL_HELPER => function( MediaWikiServices $services ) {
144
-		$endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' );
145
-		if ( $endpoint === '' ) {
143
+	ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) {
144
+		$endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint');
145
+		if ($endpoint === '') {
146 146
 			return new DummySparqlHelper();
147 147
 		}
148 148
 
@@ -158,122 +158,122 @@  discard block
 block discarded – undo
158 158
 			$entityIdParser,
159 159
 			$propertyDataTypeLookup,
160 160
 			$services->getMainWANObjectCache(),
161
-			ConstraintsServices::getViolationMessageSerializer( $services ),
162
-			ConstraintsServices::getViolationMessageDeserializer( $services ),
161
+			ConstraintsServices::getViolationMessageSerializer($services),
162
+			ConstraintsServices::getViolationMessageDeserializer($services),
163 163
 			$services->getStatsdDataFactory(),
164
-			ConstraintsServices::getExpiryLock( $services ),
164
+			ConstraintsServices::getExpiryLock($services),
165 165
 			ConstraintsServices::getLoggingHelper(),
166
-			wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(),
166
+			wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(),
167 167
 			$services->getHttpRequestFactory()
168 168
 		);
169 169
 	},
170 170
 
171
-	ConstraintsServices::TYPE_CHECKER_HELPER => function( MediaWikiServices $services ) {
171
+	ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) {
172 172
 		return new TypeCheckerHelper(
173
-			WikibaseServices::getEntityLookup( $services ),
173
+			WikibaseServices::getEntityLookup($services),
174 174
 			$services->getMainConfig(),
175
-			ConstraintsServices::getSparqlHelper( $services ),
175
+			ConstraintsServices::getSparqlHelper($services),
176 176
 			$services->getStatsdDataFactory()
177 177
 		);
178 178
 	},
179 179
 
180
-	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function( MediaWikiServices $services ) {
180
+	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) {
181 181
 		// TODO in the future, get StatementGuidParser from $services?
182 182
 		$repo = WikibaseRepo::getDefaultInstance();
183 183
 		$statementGuidParser = $repo->getStatementGuidParser();
184 184
 
185 185
 		$config = $services->getMainConfig();
186 186
 		$checkerMap = [
187
-			$config->get( 'WBQualityConstraintsConflictsWithConstraintId' )
188
-				=> ConstraintCheckerServices::getConflictsWithChecker( $services ),
189
-			$config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' )
190
-				=> ConstraintCheckerServices::getItemChecker( $services ),
191
-			$config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' )
192
-				=> ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ),
193
-			$config->get( 'WBQualityConstraintsSymmetricConstraintId' )
194
-				=> ConstraintCheckerServices::getSymmetricChecker( $services ),
195
-			$config->get( 'WBQualityConstraintsInverseConstraintId' )
196
-				=> ConstraintCheckerServices::getInverseChecker( $services ),
197
-			$config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' )
198
-				=> ConstraintCheckerServices::getQualifierChecker( $services ),
199
-			$config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' )
200
-				=> ConstraintCheckerServices::getQualifiersChecker( $services ),
201
-			$config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' )
202
-				=> ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ),
203
-			$config->get( 'WBQualityConstraintsRangeConstraintId' )
204
-				=> ConstraintCheckerServices::getRangeChecker( $services ),
205
-			$config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' )
206
-				=> ConstraintCheckerServices::getDiffWithinRangeChecker( $services ),
207
-			$config->get( 'WBQualityConstraintsTypeConstraintId' )
208
-				=> ConstraintCheckerServices::getTypeChecker( $services ),
209
-			$config->get( 'WBQualityConstraintsValueTypeConstraintId' )
210
-				=> ConstraintCheckerServices::getValueTypeChecker( $services ),
211
-			$config->get( 'WBQualityConstraintsSingleValueConstraintId' )
212
-				=> ConstraintCheckerServices::getSingleValueChecker( $services ),
213
-			$config->get( 'WBQualityConstraintsMultiValueConstraintId' )
214
-				=> ConstraintCheckerServices::getMultiValueChecker( $services ),
215
-			$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' )
216
-				=> ConstraintCheckerServices::getUniqueValueChecker( $services ),
217
-			$config->get( 'WBQualityConstraintsFormatConstraintId' )
218
-				=> ConstraintCheckerServices::getFormatChecker( $services ),
219
-			$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' )
220
-				=> ConstraintCheckerServices::getCommonsLinkChecker( $services ),
221
-			$config->get( 'WBQualityConstraintsOneOfConstraintId' )
222
-				=> ConstraintCheckerServices::getOneOfChecker( $services ),
223
-			$config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' )
224
-				=> ConstraintCheckerServices::getValueOnlyChecker( $services ),
225
-			$config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' )
226
-				=> ConstraintCheckerServices::getReferenceChecker( $services ),
227
-			$config->get( 'WBQualityConstraintsNoBoundsConstraintId' )
228
-				=> ConstraintCheckerServices::getNoBoundsChecker( $services ),
229
-			$config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' )
230
-				=> ConstraintCheckerServices::getAllowedUnitsChecker( $services ),
231
-			$config->get( 'WBQualityConstraintsSingleBestValueConstraintId' )
232
-				=> ConstraintCheckerServices::getSingleBestValueChecker( $services ),
233
-			$config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' )
234
-				=> ConstraintCheckerServices::getEntityTypeChecker( $services ),
235
-			$config->get( 'WBQualityConstraintsNoneOfConstraintId' )
236
-				=> ConstraintCheckerServices::getNoneOfChecker( $services ),
237
-			$config->get( 'WBQualityConstraintsIntegerConstraintId' )
238
-				=> ConstraintCheckerServices::getIntegerChecker( $services ),
239
-			$config->get( 'WBQualityConstraintsCitationNeededConstraintId' )
240
-				=> ConstraintCheckerServices::getCitationNeededChecker( $services ),
241
-			$config->get( 'WBQualityConstraintsPropertyScopeConstraintId' )
242
-				=> ConstraintCheckerServices::getPropertyScopeChecker( $services ),
243
-			$config->get( 'WBQualityConstraintsContemporaryConstraintId' )
244
-				=> ConstraintCheckerServices::getContemporaryChecker( $services ),
187
+			$config->get('WBQualityConstraintsConflictsWithConstraintId')
188
+				=> ConstraintCheckerServices::getConflictsWithChecker($services),
189
+			$config->get('WBQualityConstraintsItemRequiresClaimConstraintId')
190
+				=> ConstraintCheckerServices::getItemChecker($services),
191
+			$config->get('WBQualityConstraintsValueRequiresClaimConstraintId')
192
+				=> ConstraintCheckerServices::getTargetRequiredClaimChecker($services),
193
+			$config->get('WBQualityConstraintsSymmetricConstraintId')
194
+				=> ConstraintCheckerServices::getSymmetricChecker($services),
195
+			$config->get('WBQualityConstraintsInverseConstraintId')
196
+				=> ConstraintCheckerServices::getInverseChecker($services),
197
+			$config->get('WBQualityConstraintsUsedAsQualifierConstraintId')
198
+				=> ConstraintCheckerServices::getQualifierChecker($services),
199
+			$config->get('WBQualityConstraintsAllowedQualifiersConstraintId')
200
+				=> ConstraintCheckerServices::getQualifiersChecker($services),
201
+			$config->get('WBQualityConstraintsMandatoryQualifierConstraintId')
202
+				=> ConstraintCheckerServices::getMandatoryQualifiersChecker($services),
203
+			$config->get('WBQualityConstraintsRangeConstraintId')
204
+				=> ConstraintCheckerServices::getRangeChecker($services),
205
+			$config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId')
206
+				=> ConstraintCheckerServices::getDiffWithinRangeChecker($services),
207
+			$config->get('WBQualityConstraintsTypeConstraintId')
208
+				=> ConstraintCheckerServices::getTypeChecker($services),
209
+			$config->get('WBQualityConstraintsValueTypeConstraintId')
210
+				=> ConstraintCheckerServices::getValueTypeChecker($services),
211
+			$config->get('WBQualityConstraintsSingleValueConstraintId')
212
+				=> ConstraintCheckerServices::getSingleValueChecker($services),
213
+			$config->get('WBQualityConstraintsMultiValueConstraintId')
214
+				=> ConstraintCheckerServices::getMultiValueChecker($services),
215
+			$config->get('WBQualityConstraintsDistinctValuesConstraintId')
216
+				=> ConstraintCheckerServices::getUniqueValueChecker($services),
217
+			$config->get('WBQualityConstraintsFormatConstraintId')
218
+				=> ConstraintCheckerServices::getFormatChecker($services),
219
+			$config->get('WBQualityConstraintsCommonsLinkConstraintId')
220
+				=> ConstraintCheckerServices::getCommonsLinkChecker($services),
221
+			$config->get('WBQualityConstraintsOneOfConstraintId')
222
+				=> ConstraintCheckerServices::getOneOfChecker($services),
223
+			$config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId')
224
+				=> ConstraintCheckerServices::getValueOnlyChecker($services),
225
+			$config->get('WBQualityConstraintsUsedAsReferenceConstraintId')
226
+				=> ConstraintCheckerServices::getReferenceChecker($services),
227
+			$config->get('WBQualityConstraintsNoBoundsConstraintId')
228
+				=> ConstraintCheckerServices::getNoBoundsChecker($services),
229
+			$config->get('WBQualityConstraintsAllowedUnitsConstraintId')
230
+				=> ConstraintCheckerServices::getAllowedUnitsChecker($services),
231
+			$config->get('WBQualityConstraintsSingleBestValueConstraintId')
232
+				=> ConstraintCheckerServices::getSingleBestValueChecker($services),
233
+			$config->get('WBQualityConstraintsAllowedEntityTypesConstraintId')
234
+				=> ConstraintCheckerServices::getEntityTypeChecker($services),
235
+			$config->get('WBQualityConstraintsNoneOfConstraintId')
236
+				=> ConstraintCheckerServices::getNoneOfChecker($services),
237
+			$config->get('WBQualityConstraintsIntegerConstraintId')
238
+				=> ConstraintCheckerServices::getIntegerChecker($services),
239
+			$config->get('WBQualityConstraintsCitationNeededConstraintId')
240
+				=> ConstraintCheckerServices::getCitationNeededChecker($services),
241
+			$config->get('WBQualityConstraintsPropertyScopeConstraintId')
242
+				=> ConstraintCheckerServices::getPropertyScopeChecker($services),
243
+			$config->get('WBQualityConstraintsContemporaryConstraintId')
244
+				=> ConstraintCheckerServices::getContemporaryChecker($services),
245 245
 		];
246 246
 
247 247
 		return new DelegatingConstraintChecker(
248
-			WikibaseServices::getEntityLookup( $services ),
248
+			WikibaseServices::getEntityLookup($services),
249 249
 			$checkerMap,
250
-			ConstraintsServices::getConstraintLookup( $services ),
251
-			ConstraintsServices::getConstraintParameterParser( $services ),
250
+			ConstraintsServices::getConstraintLookup($services),
251
+			ConstraintsServices::getConstraintParameterParser($services),
252 252
 			$statementGuidParser,
253
-			ConstraintsServices::getLoggingHelper( $services ),
254
-			$config->get( 'WBQualityConstraintsCheckQualifiers' ),
255
-			$config->get( 'WBQualityConstraintsCheckReferences' ),
256
-			$config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' )
253
+			ConstraintsServices::getLoggingHelper($services),
254
+			$config->get('WBQualityConstraintsCheckQualifiers'),
255
+			$config->get('WBQualityConstraintsCheckReferences'),
256
+			$config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers')
257 257
 		);
258 258
 	},
259 259
 
260
-	ConstraintsServices::RESULTS_SOURCE => function( MediaWikiServices $services ) {
260
+	ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) {
261 261
 		$config = $services->getMainConfig();
262 262
 		$resultsSource = new CheckingResultsSource(
263
-			ConstraintsServices::getDelegatingConstraintChecker( $services )
263
+			ConstraintsServices::getDelegatingConstraintChecker($services)
264 264
 		);
265 265
 
266 266
 		$cacheCheckConstraintsResults = false;
267 267
 
268
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
268
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
269 269
 			$cacheCheckConstraintsResults = true;
270 270
 			// check that we can use getLocalRepoWikiPageMetaDataAccessor()
271 271
 			// TODO we should always be able to cache constraint check results (T244726)
272 272
 			$repo = WikibaseRepo::getDefaultInstance();
273
-			foreach ( $repo->getEntitySourceDefinitions()->getSources() as $entitySource ) {
274
-				if ( $entitySource->getSourceName() !== $repo->getLocalEntitySource()->getSourceName() ) {
275
-					LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning(
276
-						'Cannot cache constraint check results for non-local source: ' .
273
+			foreach ($repo->getEntitySourceDefinitions()->getSources() as $entitySource) {
274
+				if ($entitySource->getSourceName() !== $repo->getLocalEntitySource()->getSourceName()) {
275
+					LoggerFactory::getInstance('WikibaseQualityConstraints')->warning(
276
+						'Cannot cache constraint check results for non-local source: '.
277 277
 						$entitySource->getSourceName()
278 278
 					);
279 279
 					$cacheCheckConstraintsResults = false;
@@ -282,12 +282,12 @@  discard block
 block discarded – undo
282 282
 			}
283 283
 		}
284 284
 
285
-		if ( $cacheCheckConstraintsResults ) {
285
+		if ($cacheCheckConstraintsResults) {
286 286
 			$possiblyStaleConstraintTypes = [
287
-				$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
288
-				$config->get( 'WBQualityConstraintsTypeConstraintId' ),
289
-				$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
290
-				$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
287
+				$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
288
+				$config->get('WBQualityConstraintsTypeConstraintId'),
289
+				$config->get('WBQualityConstraintsValueTypeConstraintId'),
290
+				$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
291 291
 			];
292 292
 			// TODO in the future, get EntityIdParser and WikiPageEntityMetaDataAccessor from $services?
293 293
 			$repo = WikibaseRepo::getDefaultInstance();
@@ -297,14 +297,14 @@  discard block
 block discarded – undo
297 297
 			$resultsSource = new CachingResultsSource(
298 298
 				$resultsSource,
299 299
 				ResultsCache::getDefaultInstance(),
300
-				ConstraintsServices::getCheckResultSerializer( $services ),
301
-				ConstraintsServices::getCheckResultDeserializer( $services ),
300
+				ConstraintsServices::getCheckResultSerializer($services),
301
+				ConstraintsServices::getCheckResultDeserializer($services),
302 302
 				$wikiPageEntityMetaDataAccessor,
303 303
 				$entityIdParser,
304
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
304
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
305 305
 				$possiblyStaleConstraintTypes,
306
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ),
307
-				ConstraintsServices::getLoggingHelper( $services )
306
+				$config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'),
307
+				ConstraintsServices::getLoggingHelper($services)
308 308
 			);
309 309
 		}
310 310
 
Please login to merge, or discard this patch.
src/ConstraintsServices.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -38,90 +38,90 @@
 block discarded – undo
38 38
 	const RESULTS_SOURCE = 'WBQC_ResultsSource';
39 39
 	const EXPIRY_LOCK = 'WBQC_ExpiryLock';
40 40
 
41
-	private static function getService( ?MediaWikiServices $services, $name ) {
42
-		if ( $services === null ) {
41
+	private static function getService(?MediaWikiServices $services, $name) {
42
+		if ($services === null) {
43 43
 			$services = MediaWikiServices::getInstance();
44 44
 		}
45
-		return $services->getService( $name );
45
+		return $services->getService($name);
46 46
 	}
47 47
 
48
-	public static function getLoggingHelper( MediaWikiServices $services = null ): LoggingHelper {
49
-		return self::getService( $services, self::LOGGING_HELPER );
48
+	public static function getLoggingHelper(MediaWikiServices $services = null): LoggingHelper {
49
+		return self::getService($services, self::LOGGING_HELPER);
50 50
 	}
51 51
 
52 52
 	public static function getConstraintStore(
53 53
 		MediaWikiServices $services = null
54 54
 	): ConstraintStore {
55
-		return self::getService( $services, self::CONSTRAINT_STORE );
55
+		return self::getService($services, self::CONSTRAINT_STORE);
56 56
 	}
57 57
 
58
-	public static function getConstraintLookup( MediaWikiServices $services = null ): ConstraintLookup {
59
-		return self::getService( $services, self::CONSTRAINT_LOOKUP );
58
+	public static function getConstraintLookup(MediaWikiServices $services = null): ConstraintLookup {
59
+		return self::getService($services, self::CONSTRAINT_LOOKUP);
60 60
 	}
61 61
 
62 62
 	public static function getCheckResultSerializer(
63 63
 		MediaWikiServices $services = null
64 64
 	): CheckResultSerializer {
65
-		return self::getService( $services, self::CHECK_RESULT_SERIALIZER );
65
+		return self::getService($services, self::CHECK_RESULT_SERIALIZER);
66 66
 	}
67 67
 
68 68
 	public static function getCheckResultDeserializer(
69 69
 		MediaWikiServices $services = null
70 70
 	): CheckResultDeserializer {
71
-		return self::getService( $services, self::CHECK_RESULT_DESERIALIZER );
71
+		return self::getService($services, self::CHECK_RESULT_DESERIALIZER);
72 72
 	}
73 73
 
74 74
 	public static function getViolationMessageSerializer(
75 75
 		MediaWikiServices $services = null
76 76
 	): ViolationMessageSerializer {
77
-		return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER );
77
+		return self::getService($services, self::VIOLATION_MESSAGE_SERIALIZER);
78 78
 	}
79 79
 
80 80
 	public static function getViolationMessageDeserializer(
81 81
 		MediaWikiServices $services = null
82 82
 	): ViolationMessageDeserializer {
83
-		return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER );
83
+		return self::getService($services, self::VIOLATION_MESSAGE_DESERIALIZER);
84 84
 	}
85 85
 
86 86
 	public static function getConstraintParameterParser(
87 87
 		MediaWikiServices $services = null
88 88
 	): ConstraintParameterParser {
89
-		return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER );
89
+		return self::getService($services, self::CONSTRAINT_PARAMETER_PARSER);
90 90
 	}
91 91
 
92 92
 	public static function getConnectionCheckerHelper(
93 93
 		MediaWikiServices $services = null
94 94
 	): ConnectionCheckerHelper {
95
-		return self::getService( $services, self::CONNECTION_CHECKER_HELPER );
95
+		return self::getService($services, self::CONNECTION_CHECKER_HELPER);
96 96
 	}
97 97
 
98
-	public static function getRangeCheckerHelper( MediaWikiServices $services = null ): RangeCheckerHelper {
99
-		return self::getService( $services, self::RANGE_CHECKER_HELPER );
98
+	public static function getRangeCheckerHelper(MediaWikiServices $services = null): RangeCheckerHelper {
99
+		return self::getService($services, self::RANGE_CHECKER_HELPER);
100 100
 	}
101 101
 
102
-	public static function getSparqlHelper( MediaWikiServices $services = null ): SparqlHelper {
103
-		return self::getService( $services, self::SPARQL_HELPER );
102
+	public static function getSparqlHelper(MediaWikiServices $services = null): SparqlHelper {
103
+		return self::getService($services, self::SPARQL_HELPER);
104 104
 	}
105 105
 
106
-	public static function getTypeCheckerHelper( MediaWikiServices $services = null ): TypeCheckerHelper {
107
-		return self::getService( $services, self::TYPE_CHECKER_HELPER );
106
+	public static function getTypeCheckerHelper(MediaWikiServices $services = null): TypeCheckerHelper {
107
+		return self::getService($services, self::TYPE_CHECKER_HELPER);
108 108
 	}
109 109
 
110 110
 	public static function getDelegatingConstraintChecker(
111 111
 		MediaWikiServices $services = null
112 112
 	): DelegatingConstraintChecker {
113
-		return self::getService( $services, self::DELEGATING_CONSTRAINT_CHECKER );
113
+		return self::getService($services, self::DELEGATING_CONSTRAINT_CHECKER);
114 114
 	}
115 115
 
116
-	public static function getResultsSource( MediaWikiServices $services = null ): ResultsSource {
117
-		return self::getService( $services, self::RESULTS_SOURCE );
116
+	public static function getResultsSource(MediaWikiServices $services = null): ResultsSource {
117
+		return self::getService($services, self::RESULTS_SOURCE);
118 118
 	}
119 119
 
120 120
 	/**
121 121
 	 * @return ExpiryLock
122 122
 	 */
123
-	public static function getExpiryLock( MediaWikiServices $services = null ) {
124
-		return self::getService( $services, self::EXPIRY_LOCK );
123
+	public static function getExpiryLock(MediaWikiServices $services = null) {
124
+		return self::getService($services, self::EXPIRY_LOCK);
125 125
 	}
126 126
 
127 127
 }
Please login to merge, or discard this patch.
src/ConstraintStore.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	 * @return bool
17 17
 	 * @throws DBUnexpectedError
18 18
 	 */
19
-	public function insertBatch( array $constraints );
19
+	public function insertBatch(array $constraints);
20 20
 
21 21
 	/**
22 22
 	 * Delete all constraints for the property ID.
@@ -25,6 +25,6 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @throws DBUnexpectedError
27 27
 	 */
28
-	public function deleteForProperty( PropertyId $propertyId );
28
+	public function deleteForProperty(PropertyId $propertyId);
29 29
 
30 30
 }
Please login to merge, or discard this patch.
src/Api/CachingResultsSource.php 1 patch
Spacing   +77 added lines, -78 removed lines patch added patch discarded remove patch
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
 	) {
144 144
 		$results = [];
145 145
 		$metadatas = [];
146
-		if ( $this->canUseStoredResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
146
+		if ($this->canUseStoredResults($entityIds, $claimIds, $constraintIds, $statuses)) {
147 147
 			$storedEntityIds = [];
148
-			foreach ( $entityIds as $entityId ) {
149
-				$storedResults = $this->getStoredResults( $entityId );
150
-				if ( $storedResults !== null ) {
151
-					$this->loggingHelper->logCheckConstraintsCacheHit( $entityId );
152
-					foreach ( $storedResults->getArray() as $checkResult ) {
153
-						if ( $this->statusSelected( $statuses, $checkResult ) ) {
148
+			foreach ($entityIds as $entityId) {
149
+				$storedResults = $this->getStoredResults($entityId);
150
+				if ($storedResults !== null) {
151
+					$this->loggingHelper->logCheckConstraintsCacheHit($entityId);
152
+					foreach ($storedResults->getArray() as $checkResult) {
153
+						if ($this->statusSelected($statuses, $checkResult)) {
154 154
 							$results[] = $checkResult;
155 155
 						}
156 156
 					}
@@ -158,19 +158,19 @@  discard block
 block discarded – undo
158 158
 					$storedEntityIds[] = $entityId;
159 159
 				}
160 160
 			}
161
-			$entityIds = array_values( array_diff( $entityIds, $storedEntityIds ) );
161
+			$entityIds = array_values(array_diff($entityIds, $storedEntityIds));
162 162
 		}
163
-		if ( $entityIds !== [] || $claimIds !== [] ) {
164
-			if ( $entityIds !== [] ) {
165
-				$this->loggingHelper->logCheckConstraintsCacheMisses( $entityIds );
163
+		if ($entityIds !== [] || $claimIds !== []) {
164
+			if ($entityIds !== []) {
165
+				$this->loggingHelper->logCheckConstraintsCacheMisses($entityIds);
166 166
 			}
167
-			$response = $this->getAndStoreResults( $entityIds, $claimIds, $constraintIds, $statuses );
168
-			$results = array_merge( $results, $response->getArray() );
167
+			$response = $this->getAndStoreResults($entityIds, $claimIds, $constraintIds, $statuses);
168
+			$results = array_merge($results, $response->getArray());
169 169
 			$metadatas[] = $response->getMetadata();
170 170
 		}
171 171
 		return new CachedCheckResults(
172 172
 			$results,
173
-			Metadata::merge( $metadatas )
173
+			Metadata::merge($metadatas)
174 174
 		);
175 175
 	}
176 176
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 		?array $constraintIds,
194 194
 		array $statuses
195 195
 	) {
196
-		if ( $claimIds !== [] ) {
196
+		if ($claimIds !== []) {
197 197
 			return false;
198 198
 		}
199
-		if ( $constraintIds !== null ) {
199
+		if ($constraintIds !== null) {
200 200
 			return false;
201 201
 		}
202
-		if ( array_diff( $statuses, self::CACHED_STATUSES ) !== [] ) {
202
+		if (array_diff($statuses, self::CACHED_STATUSES) !== []) {
203 203
 			return false;
204 204
 		}
205 205
 		return true;
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 * @param CheckResult $result
215 215
 	 * @return bool
216 216
 	 */
217
-	private function statusSelected( array $statuses, CheckResult $result ) {
218
-		return in_array( $result->getStatus(), $statuses, true ) ||
217
+	private function statusSelected(array $statuses, CheckResult $result) {
218
+		return in_array($result->getStatus(), $statuses, true) ||
219 219
 			$result instanceof NullResult;
220 220
 	}
221 221
 
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
 		?array $constraintIds,
233 233
 		array $statuses
234 234
 	) {
235
-		$results = $this->resultsSource->getResults( $entityIds, $claimIds, $constraintIds, $statuses );
235
+		$results = $this->resultsSource->getResults($entityIds, $claimIds, $constraintIds, $statuses);
236 236
 
237
-		if ( $this->canStoreResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
238
-			foreach ( $entityIds as $entityId ) {
239
-				$this->storeResults( $entityId, $results );
237
+		if ($this->canStoreResults($entityIds, $claimIds, $constraintIds, $statuses)) {
238
+			foreach ($entityIds as $entityId) {
239
+				$this->storeResults($entityId, $results);
240 240
 			}
241 241
 		}
242 242
 
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 		?array $constraintIds,
268 268
 		array $statuses
269 269
 	) {
270
-		if ( $constraintIds !== null ) {
270
+		if ($constraintIds !== null) {
271 271
 			return false;
272 272
 		}
273
-		if ( array_diff( self::CACHED_STATUSES, $statuses ) !== [] ) {
273
+		if (array_diff(self::CACHED_STATUSES, $statuses) !== []) {
274 274
 			return false;
275 275
 		}
276 276
 		return true;
@@ -284,21 +284,21 @@  discard block
 block discarded – undo
284 284
 	 * May include check results for other entity IDs as well,
285 285
 	 * or check results with statuses that we’re not interested in caching.
286 286
 	 */
287
-	private function storeResults( EntityId $entityId, CachedCheckResults $results ) {
287
+	private function storeResults(EntityId $entityId, CachedCheckResults $results) {
288 288
 		$latestRevisionIds = $this->getLatestRevisionIds(
289 289
 			$results->getMetadata()->getDependencyMetadata()->getEntityIds()
290 290
 		);
291
-		if ( $latestRevisionIds === null ) {
291
+		if ($latestRevisionIds === null) {
292 292
 			return;
293 293
 		}
294 294
 
295 295
 		$resultSerializations = [];
296
-		foreach ( $results->getArray() as $checkResult ) {
297
-			if ( $checkResult->getContextCursor()->getEntityId() !== $entityId->getSerialization() ) {
296
+		foreach ($results->getArray() as $checkResult) {
297
+			if ($checkResult->getContextCursor()->getEntityId() !== $entityId->getSerialization()) {
298 298
 				continue;
299 299
 			}
300
-			if ( $this->statusSelected( self::CACHED_STATUSES, $checkResult ) ) {
301
-				$resultSerializations[] = $this->checkResultSerializer->serialize( $checkResult );
300
+			if ($this->statusSelected(self::CACHED_STATUSES, $checkResult)) {
301
+				$resultSerializations[] = $this->checkResultSerializer->serialize($checkResult);
302 302
 			}
303 303
 		}
304 304
 
@@ -307,11 +307,11 @@  discard block
 block discarded – undo
307 307
 			'latestRevisionIds' => $latestRevisionIds,
308 308
 		];
309 309
 		$futureTime = $results->getMetadata()->getDependencyMetadata()->getFutureTime();
310
-		if ( $futureTime !== null ) {
310
+		if ($futureTime !== null) {
311 311
 			$value['futureTime'] = $futureTime->getArrayValue();
312 312
 		}
313 313
 
314
-		$this->cache->set( $entityId, $value, $this->ttlInSeconds );
314
+		$this->cache->set($entityId, $value, $this->ttlInSeconds);
315 315
 	}
316 316
 
317 317
 	/**
@@ -325,31 +325,30 @@  discard block
 block discarded – undo
325 325
 		EntityId $entityId,
326 326
 		$forRevision = 0
327 327
 	) {
328
-		$value = $this->cache->get( $entityId, $curTTL, [], $asOf );
329
-		$now = call_user_func( $this->microtime, true );
328
+		$value = $this->cache->get($entityId, $curTTL, [], $asOf);
329
+		$now = call_user_func($this->microtime, true);
330 330
 
331
-		$dependencyMetadata = $this->checkDependencyMetadata( $value,
332
-			[ $entityId->getSerialization() => $forRevision ] );
333
-		if ( $dependencyMetadata === null ) {
331
+		$dependencyMetadata = $this->checkDependencyMetadata($value,
332
+			[$entityId->getSerialization() => $forRevision]);
333
+		if ($dependencyMetadata === null) {
334 334
 			return null;
335 335
 		}
336 336
 
337
-		$ageInSeconds = (int)ceil( $now - $asOf );
337
+		$ageInSeconds = (int) ceil($now - $asOf);
338 338
 		$cachingMetadata = $ageInSeconds > 0 ?
339
-			CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) :
340
-			CachingMetadata::fresh();
339
+			CachingMetadata::ofMaximumAgeInSeconds($ageInSeconds) : CachingMetadata::fresh();
341 340
 
342 341
 		$results = [];
343
-		foreach ( $value['results'] as $resultSerialization ) {
344
-			$results[] = $this->deserializeCheckResult( $resultSerialization, $cachingMetadata );
342
+		foreach ($value['results'] as $resultSerialization) {
343
+			$results[] = $this->deserializeCheckResult($resultSerialization, $cachingMetadata);
345 344
 		}
346 345
 
347 346
 		return new CachedCheckResults(
348 347
 			$results,
349
-			Metadata::merge( [
350
-				Metadata::ofCachingMetadata( $cachingMetadata ),
351
-				Metadata::ofDependencyMetadata( $dependencyMetadata ),
352
-			] )
348
+			Metadata::merge([
349
+				Metadata::ofCachingMetadata($cachingMetadata),
350
+				Metadata::ofDependencyMetadata($dependencyMetadata),
351
+			])
353 352
 		);
354 353
 	}
355 354
 
@@ -365,43 +364,43 @@  discard block
 block discarded – undo
365 364
 	 * @return DependencyMetadata|null the dependency metadata,
366 365
 	 * or null if $value should no longer be used
367 366
 	 */
368
-	private function checkDependencyMetadata( $value, $paramRevs ) {
369
-		if ( $value === false ) {
367
+	private function checkDependencyMetadata($value, $paramRevs) {
368
+		if ($value === false) {
370 369
 			return null;
371 370
 		}
372 371
 
373
-		if ( array_key_exists( 'futureTime', $value ) ) {
374
-			$futureTime = TimeValue::newFromArray( $value['futureTime'] );
375
-			if ( !$this->timeValueComparer->isFutureTime( $futureTime ) ) {
372
+		if (array_key_exists('futureTime', $value)) {
373
+			$futureTime = TimeValue::newFromArray($value['futureTime']);
374
+			if (!$this->timeValueComparer->isFutureTime($futureTime)) {
376 375
 				return null;
377 376
 			}
378
-			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime( $futureTime );
377
+			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime($futureTime);
379 378
 		} else {
380 379
 			$futureTimeDependencyMetadata = DependencyMetadata::blank();
381 380
 		}
382 381
 
383
-		foreach ( $paramRevs as $id => $revision ) {
384
-			if ( $revision > 0 ) {
385
-				$value['latestRevisionIds'][$id] = min( $revision, $value['latestRevisionIds'][$id] ?? PHP_INT_MAX );
382
+		foreach ($paramRevs as $id => $revision) {
383
+			if ($revision > 0) {
384
+				$value['latestRevisionIds'][$id] = min($revision, $value['latestRevisionIds'][$id] ?? PHP_INT_MAX);
386 385
 			}
387 386
 		}
388 387
 
389 388
 		$dependedEntityIds = array_map(
390
-			[ $this->entityIdParser, "parse" ],
391
-			array_keys( $value['latestRevisionIds'] )
389
+			[$this->entityIdParser, "parse"],
390
+			array_keys($value['latestRevisionIds'])
392 391
 		);
393 392
 
394
-		if ( $value['latestRevisionIds'] !== $this->getLatestRevisionIds( $dependedEntityIds ) ) {
393
+		if ($value['latestRevisionIds'] !== $this->getLatestRevisionIds($dependedEntityIds)) {
395 394
 			return null;
396 395
 		}
397 396
 
398 397
 		return array_reduce(
399 398
 			$dependedEntityIds,
400
-			function( DependencyMetadata $metadata, EntityId $entityId ) {
401
-				return DependencyMetadata::merge( [
399
+			function(DependencyMetadata $metadata, EntityId $entityId) {
400
+				return DependencyMetadata::merge([
402 401
 					$metadata,
403
-					DependencyMetadata::ofEntityId( $entityId )
404
-				] );
402
+					DependencyMetadata::ofEntityId($entityId)
403
+				]);
405 404
 			},
406 405
 			$futureTimeDependencyMetadata
407 406
 		);
@@ -421,13 +420,13 @@  discard block
 block discarded – undo
421 420
 		array $resultSerialization,
422 421
 		CachingMetadata $cachingMetadata
423 422
 	) {
424
-		$result = $this->checkResultDeserializer->deserialize( $resultSerialization );
425
-		if ( $this->isPossiblyStaleResult( $result ) ) {
423
+		$result = $this->checkResultDeserializer->deserialize($resultSerialization);
424
+		if ($this->isPossiblyStaleResult($result)) {
426 425
 			$result->withMetadata(
427
-				Metadata::merge( [
426
+				Metadata::merge([
428 427
 					$result->getMetadata(),
429
-					Metadata::ofCachingMetadata( $cachingMetadata ),
430
-				] )
428
+					Metadata::ofCachingMetadata($cachingMetadata),
429
+				])
431 430
 			);
432 431
 		}
433 432
 		return $result;
@@ -437,8 +436,8 @@  discard block
 block discarded – undo
437 436
 	 * @param CheckResult $result
438 437
 	 * @return bool
439 438
 	 */
440
-	private function isPossiblyStaleResult( CheckResult $result ) {
441
-		if ( $result instanceof NullResult ) {
439
+	private function isPossiblyStaleResult(CheckResult $result) {
440
+		if ($result instanceof NullResult) {
442 441
 			return false;
443 442
 		}
444 443
 
@@ -453,14 +452,14 @@  discard block
 block discarded – undo
453 452
 	 * @return int[]|null array from entity ID serializations to revision ID,
454 453
 	 * or null to indicate that not all revision IDs could be loaded
455 454
 	 */
456
-	private function getLatestRevisionIds( array $entityIds ) {
457
-		if ( $entityIds === [] ) {
455
+	private function getLatestRevisionIds(array $entityIds) {
456
+		if ($entityIds === []) {
458 457
 			$this->loggingHelper->logEmptyDependencyMetadata();
459 458
 			return [];
460 459
 		}
461
-		if ( count( $entityIds ) > $this->maxRevisionIds ) {
460
+		if (count($entityIds) > $this->maxRevisionIds) {
462 461
 			// one of those entities will probably be edited soon, so might as well skip caching
463
-			$this->loggingHelper->logHugeDependencyMetadata( $entityIds, $this->maxRevisionIds );
462
+			$this->loggingHelper->logHugeDependencyMetadata($entityIds, $this->maxRevisionIds);
464 463
 			return null;
465 464
 		}
466 465
 
@@ -468,7 +467,7 @@  discard block
 block discarded – undo
468 467
 			$entityIds,
469 468
 			LookupConstants::LATEST_FROM_REPLICA
470 469
 		);
471
-		if ( $this->hasFalseElements( $latestRevisionIds ) ) {
470
+		if ($this->hasFalseElements($latestRevisionIds)) {
472 471
 			return null;
473 472
 		}
474 473
 		return $latestRevisionIds;
@@ -478,8 +477,8 @@  discard block
 block discarded – undo
478 477
 	 * @param array $array
479 478
 	 * @return bool
480 479
 	 */
481
-	private function hasFalseElements( array $array ) {
482
-		return in_array( false, $array, true );
480
+	private function hasFalseElements(array $array) {
481
+		return in_array(false, $array, true);
483 482
 	}
484 483
 
485 484
 	/**
@@ -487,7 +486,7 @@  discard block
 block discarded – undo
487 486
 	 *
488 487
 	 * @param callable $microtime
489 488
 	 */
490
-	public function setMicrotimeFunction( callable $microtime ) {
489
+	public function setMicrotimeFunction(callable $microtime) {
491 490
 		$this->microtime = $microtime;
492 491
 	}
493 492
 
Please login to merge, or discard this patch.
src/Job/UpdateConstraintsTableJob.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 
33 33
 	const BATCH_SIZE = 10;
34 34
 
35
-	public static function newFromGlobalState( Title $title, array $params ) {
36
-		Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' );
35
+	public static function newFromGlobalState(Title $title, array $params) {
36
+		Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]');
37 37
 		$repo = WikibaseRepo::getDefaultInstance();
38 38
 		return new UpdateConstraintsTableJob(
39 39
 			$title,
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 			$params['revisionId'] ?? null,
43 43
 			MediaWikiServices::getInstance()->getMainConfig(),
44 44
 			ConstraintsServices::getConstraintStore(),
45
-			$repo->getEntityRevisionLookup( Store::LOOKUP_CACHING_DISABLED ),
45
+			$repo->getEntityRevisionLookup(Store::LOOKUP_CACHING_DISABLED),
46 46
 			$repo->getBaseDataModelSerializerFactory()->newSnakSerializer()
47 47
 		);
48 48
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		EntityRevisionLookup $entityRevisionLookup,
98 98
 		Serializer $snakSerializer
99 99
 	) {
100
-		parent::__construct( 'constraintsTableUpdate', $title, $params );
100
+		parent::__construct('constraintsTableUpdate', $title, $params);
101 101
 
102 102
 		$this->propertyId = $propertyId;
103 103
 		$this->revisionId = $revisionId;
@@ -107,11 +107,11 @@  discard block
 block discarded – undo
107 107
 		$this->snakSerializer = $snakSerializer;
108 108
 	}
109 109
 
110
-	public function extractParametersFromQualifiers( SnakList $qualifiers ) {
110
+	public function extractParametersFromQualifiers(SnakList $qualifiers) {
111 111
 		$parameters = [];
112
-		foreach ( $qualifiers as $qualifier ) {
112
+		foreach ($qualifiers as $qualifier) {
113 113
 			$qualifierId = $qualifier->getPropertyId()->getSerialization();
114
-			$paramSerialization = $this->snakSerializer->serialize( $qualifier );
114
+			$paramSerialization = $this->snakSerializer->serialize($qualifier);
115 115
 			$parameters[$qualifierId][] = $paramSerialization;
116 116
 		}
117 117
 		return $parameters;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 		'@phan-var \Wikibase\DataModel\Entity\EntityIdValue $dataValue';
129 129
 		$entityId = $dataValue->getEntityId();
130 130
 		$constraintTypeQid = $entityId->getSerialization();
131
-		$parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() );
131
+		$parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers());
132 132
 		return new Constraint(
133 133
 			$constraintId,
134 134
 			$propertyId,
@@ -143,17 +143,17 @@  discard block
 block discarded – undo
143 143
 		PropertyId $propertyConstraintPropertyId
144 144
 	) {
145 145
 		$constraintsStatements = $property->getStatements()
146
-			->getByPropertyId( $propertyConstraintPropertyId )
147
-			->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] );
146
+			->getByPropertyId($propertyConstraintPropertyId)
147
+			->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]);
148 148
 		$constraints = [];
149
-		foreach ( $constraintsStatements->getIterator() as $constraintStatement ) {
150
-			$constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement );
151
-			if ( count( $constraints ) >= self::BATCH_SIZE ) {
152
-				$constraintStore->insertBatch( $constraints );
149
+		foreach ($constraintsStatements->getIterator() as $constraintStatement) {
150
+			$constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement);
151
+			if (count($constraints) >= self::BATCH_SIZE) {
152
+				$constraintStore->insertBatch($constraints);
153 153
 				$constraints = [];
154 154
 			}
155 155
 		}
156
-		$constraintStore->insertBatch( $constraints );
156
+		$constraintStore->insertBatch($constraints);
157 157
 	}
158 158
 
159 159
 	/**
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
 	public function run() {
165 165
 		// TODO in the future: only touch constraints affected by the edit (requires T163465)
166 166
 
167
-		$propertyId = new PropertyId( $this->propertyId );
167
+		$propertyId = new PropertyId($this->propertyId);
168 168
 		$propertyRevision = $this->entityRevisionLookup->getEntityRevision(
169 169
 			$propertyId,
170 170
 			0, // latest
171 171
 			LookupConstants::LATEST_FROM_REPLICA
172 172
 		);
173 173
 
174
-		if ( $this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId ) {
175
-			JobQueueGroup::singleton()->push( $this );
174
+		if ($this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId) {
175
+			JobQueueGroup::singleton()->push($this);
176 176
 			return true;
177 177
 		}
178 178
 
179
-		$this->constraintStore->deleteForProperty( $propertyId );
179
+		$this->constraintStore->deleteForProperty($propertyId);
180 180
 
181 181
 		/** @var Property $property */
182 182
 		$property = $propertyRevision->getEntity();
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		$this->importConstraintsForProperty(
185 185
 			$property,
186 186
 			$this->constraintStore,
187
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) )
187
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId'))
188 188
 		);
189 189
 
190 190
 		return true;
Please login to merge, or discard this patch.