Completed
Push — master ( 4c5602...13c0ce )
by
unknown
06:07 queued 55s
created
src/ConstraintParameterRenderer.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -64,20 +64,20 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string HTML
66 66
 	 */
67
-	public function formatValue( $value ) {
68
-		if ( is_string( $value ) ) {
67
+	public function formatValue($value) {
68
+		if (is_string($value)) {
69 69
 			// Cases like 'Format' 'pattern' or 'minimum'/'maximum' values, which we have stored as
70 70
 			// strings
71
-			return htmlspecialchars( $value );
72
-		} elseif ( $value instanceof EntityId ) {
71
+			return htmlspecialchars($value);
72
+		} elseif ($value instanceof EntityId) {
73 73
 			// Cases like 'Conflicts with' 'property', to which we can link
74
-			return $this->formatEntityId( $value );
75
-		} elseif ( $value instanceof ItemIdSnakValue ) {
74
+			return $this->formatEntityId($value);
75
+		} elseif ($value instanceof ItemIdSnakValue) {
76 76
 			// Cases like EntityId but can also be somevalue or novalue
77
-			return $this->formatItemIdSnakValue( $value );
77
+			return $this->formatItemIdSnakValue($value);
78 78
 		} else {
79 79
 			// Cases where we format a DataValue
80
-			return $this->formatDataValue( $value );
80
+			return $this->formatDataValue($value);
81 81
 		}
82 82
 	}
83 83
 
@@ -88,23 +88,23 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return string HTML
90 90
 	 */
91
-	public function formatParameters( $parameters ) {
92
-		if ( $parameters === null || count( $parameters ) == 0 ) {
91
+	public function formatParameters($parameters) {
92
+		if ($parameters === null || count($parameters) == 0) {
93 93
 			return null;
94 94
 		}
95 95
 
96
-		$valueFormatter = function ( $value ) {
97
-			return $this->formatValue( $value );
96
+		$valueFormatter = function($value) {
97
+			return $this->formatValue($value);
98 98
 		};
99 99
 
100 100
 		$formattedParameters = [];
101
-		foreach ( $parameters as $parameterName => $parameterValue ) {
102
-			$formattedParameterValues = implode( ', ',
103
-				$this->limitArrayLength( array_map( $valueFormatter, $parameterValue ) ) );
104
-			$formattedParameters[] = sprintf( '%s: %s', $parameterName, $formattedParameterValues );
101
+		foreach ($parameters as $parameterName => $parameterValue) {
102
+			$formattedParameterValues = implode(', ',
103
+				$this->limitArrayLength(array_map($valueFormatter, $parameterValue)));
104
+			$formattedParameters[] = sprintf('%s: %s', $parameterName, $formattedParameterValues);
105 105
 		}
106 106
 
107
-		return implode( '; ', $formattedParameters );
107
+		return implode('; ', $formattedParameters);
108 108
 	}
109 109
 
110 110
 	/**
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @return array
116 116
 	 */
117
-	private function limitArrayLength( array $array ) {
118
-		if ( count( $array ) > self::MAX_PARAMETER_ARRAY_LENGTH ) {
119
-			$array = array_slice( $array, 0, self::MAX_PARAMETER_ARRAY_LENGTH );
120
-			array_push( $array, '...' );
117
+	private function limitArrayLength(array $array) {
118
+		if (count($array) > self::MAX_PARAMETER_ARRAY_LENGTH) {
119
+			$array = array_slice($array, 0, self::MAX_PARAMETER_ARRAY_LENGTH);
120
+			array_push($array, '...');
121 121
 		}
122 122
 
123 123
 		return $array;
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
 	 * @param string $value HTML
131 131
 	 * @return string HTML
132 132
 	 */
133
-	public static function formatByRole( $role, $value ) {
134
-		if ( $role === null ) {
133
+	public static function formatByRole($role, $value) {
134
+		if ($role === null) {
135 135
 			return $value;
136 136
 		}
137 137
 
138
-		return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">'
138
+		return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'
139 139
 			. $value
140 140
 			. '</span>';
141 141
 	}
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
 	 * @param string|null $role one of the Role constants or null
146 146
 	 * @return string HTML
147 147
 	 */
148
-	public function formatDataValue( DataValue $value, $role = null ) {
149
-		return self::formatByRole( $role,
150
-			$this->dataValueFormatter->format( $value ) );
148
+	public function formatDataValue(DataValue $value, $role = null) {
149
+		return self::formatByRole($role,
150
+			$this->dataValueFormatter->format($value));
151 151
 	}
152 152
 
153 153
 	/**
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 	 * @param string|null $role one of the Role constants or null
156 156
 	 * @return string HTML
157 157
 	 */
158
-	public function formatEntityId( EntityId $entityId, $role = null ) {
159
-		return self::formatByRole( $role,
160
-			$this->entityIdLabelFormatter->formatEntityId( $entityId ) );
158
+	public function formatEntityId(EntityId $entityId, $role = null) {
159
+		return self::formatByRole($role,
160
+			$this->entityIdLabelFormatter->formatEntityId($entityId));
161 161
 	}
162 162
 
163 163
 	/**
@@ -169,18 +169,18 @@  discard block
 block discarded – undo
169 169
 	 * @param string|null $role one of the Role constants or null
170 170
 	 * @return string HTML
171 171
 	 */
172
-	public function formatPropertyId( $propertyId, $role = null ) {
173
-		if ( $propertyId instanceof PropertyId ) {
174
-			return $this->formatEntityId( $propertyId, $role );
175
-		} elseif ( is_string( $propertyId ) ) {
172
+	public function formatPropertyId($propertyId, $role = null) {
173
+		if ($propertyId instanceof PropertyId) {
174
+			return $this->formatEntityId($propertyId, $role);
175
+		} elseif (is_string($propertyId)) {
176 176
 			try {
177
-				return $this->formatEntityId( new PropertyId( $propertyId ), $role );
178
-			} catch ( InvalidArgumentException $e ) {
179
-				return self::formatByRole( $role,
180
-					htmlspecialchars( $propertyId ) );
177
+				return $this->formatEntityId(new PropertyId($propertyId), $role);
178
+			} catch (InvalidArgumentException $e) {
179
+				return self::formatByRole($role,
180
+					htmlspecialchars($propertyId));
181 181
 			}
182 182
 		} else {
183
-			throw new InvalidArgumentException( '$propertyId must be either PropertyId or string' );
183
+			throw new InvalidArgumentException('$propertyId must be either PropertyId or string');
184 184
 		}
185 185
 	}
186 186
 
@@ -193,18 +193,18 @@  discard block
 block discarded – undo
193 193
 	 * @param string|null $role one of the Role constants or null
194 194
 	 * @return string HTML
195 195
 	 */
196
-	public function formatItemId( $itemId, $role = null ) {
197
-		if ( $itemId instanceof ItemId ) {
198
-			return $this->formatEntityId( $itemId, $role );
199
-		} elseif ( is_string( $itemId ) ) {
196
+	public function formatItemId($itemId, $role = null) {
197
+		if ($itemId instanceof ItemId) {
198
+			return $this->formatEntityId($itemId, $role);
199
+		} elseif (is_string($itemId)) {
200 200
 			try {
201
-				return $this->formatEntityId( new ItemId( $itemId ), $role );
202
-			} catch ( InvalidArgumentException $e ) {
203
-				return self::formatByRole( $role,
204
-					htmlspecialchars( $itemId ) );
201
+				return $this->formatEntityId(new ItemId($itemId), $role);
202
+			} catch (InvalidArgumentException $e) {
203
+				return self::formatByRole($role,
204
+					htmlspecialchars($itemId));
205 205
 			}
206 206
 		} else {
207
-			throw new InvalidArgumentException( '$itemId must be either ItemId or string' );
207
+			throw new InvalidArgumentException('$itemId must be either ItemId or string');
208 208
 		}
209 209
 	}
210 210
 
@@ -215,20 +215,20 @@  discard block
 block discarded – undo
215 215
 	 * @param string|null $role one of the Role constants or null
216 216
 	 * @return string HTML
217 217
 	 */
218
-	public function formatItemIdSnakValue( ItemIdSnakValue $value, $role = null ) {
219
-		switch ( true ) {
218
+	public function formatItemIdSnakValue(ItemIdSnakValue $value, $role = null) {
219
+		switch (true) {
220 220
 			case $value->isValue():
221
-				return $this->formatEntityId( $value->getItemId(), $role );
221
+				return $this->formatEntityId($value->getItemId(), $role);
222 222
 			case $value->isSomeValue():
223
-				return self::formatByRole( $role,
223
+				return self::formatByRole($role,
224 224
 					'<span class="wikibase-snakview-variation-somevaluesnak">'
225
-						. wfMessage( 'wikibase-snakview-snaktypeselector-somevalue' )->escaped()
226
-						. '</span>' );
225
+						. wfMessage('wikibase-snakview-snaktypeselector-somevalue')->escaped()
226
+						. '</span>');
227 227
 			case $value->isNoValue():
228
-				return self::formatByRole( $role,
228
+				return self::formatByRole($role,
229 229
 					'<span class="wikibase-snakview-variation-novaluesnak">'
230
-						. wfMessage( 'wikibase-snakview-snaktypeselector-novalue' )->escaped()
231
-						. '</span>' );
230
+						. wfMessage('wikibase-snakview-snaktypeselector-novalue')->escaped()
231
+						. '</span>');
232 232
 		}
233 233
 	}
234 234
 
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 	 * @param string|null $role one of the Role constants or null
240 240
 	 * @return string HTML
241 241
 	 */
242
-	public function formatConstraintScope( $scope, $role = null ) {
243
-		switch ( $scope ) {
242
+	public function formatConstraintScope($scope, $role = null) {
243
+		switch ($scope) {
244 244
 			case Context::TYPE_STATEMENT:
245 245
 				$itemId = $this->config->get(
246 246
 					'WBQualityConstraintsConstraintCheckedOnMainValueId'
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 				// callers should never let this happen, but if it does happen,
261 261
 				// showing “unknown value” seems reasonable
262 262
 				// @codeCoverageIgnoreStart
263
-				return $this->formatItemIdSnakValue( ItemIdSnakValue::someValue(), $role );
263
+				return $this->formatItemIdSnakValue(ItemIdSnakValue::someValue(), $role);
264 264
 				// @codeCoverageIgnoreEnd
265 265
 		}
266
-		return $this->formatItemId( $itemId, $role );
266
+		return $this->formatItemId($itemId, $role);
267 267
 	}
268 268
 
269 269
 	/**
@@ -276,15 +276,15 @@  discard block
 block discarded – undo
276 276
 	 * @param string|null $role one of the Role constants or null
277 277
 	 * @return string[] HTML
278 278
 	 */
279
-	public function formatPropertyIdList( array $propertyIds, $role = null ) {
280
-		if ( empty( $propertyIds ) ) {
281
-			return [ '<ul></ul>' ];
279
+	public function formatPropertyIdList(array $propertyIds, $role = null) {
280
+		if (empty($propertyIds)) {
281
+			return ['<ul></ul>'];
282 282
 		}
283
-		$propertyIds = $this->limitArrayLength( $propertyIds );
284
-		$formattedPropertyIds = array_map( [ $this, "formatPropertyId" ], $propertyIds, array_fill( 0, count( $propertyIds ), $role ) );
283
+		$propertyIds = $this->limitArrayLength($propertyIds);
284
+		$formattedPropertyIds = array_map([$this, "formatPropertyId"], $propertyIds, array_fill(0, count($propertyIds), $role));
285 285
 		array_unshift(
286 286
 			$formattedPropertyIds,
287
-			'<ul><li>' . implode( '</li><li>', $formattedPropertyIds ) . '</li></ul>'
287
+			'<ul><li>'.implode('</li><li>', $formattedPropertyIds).'</li></ul>'
288 288
 		);
289 289
 		return $formattedPropertyIds;
290 290
 	}
@@ -299,15 +299,15 @@  discard block
 block discarded – undo
299 299
 	 * @param string|null $role one of the Role constants or null
300 300
 	 * @return string[] HTML
301 301
 	 */
302
-	public function formatItemIdList( array $itemIds, $role = null ) {
303
-		if ( empty( $itemIds ) ) {
304
-			return [ '<ul></ul>' ];
302
+	public function formatItemIdList(array $itemIds, $role = null) {
303
+		if (empty($itemIds)) {
304
+			return ['<ul></ul>'];
305 305
 		}
306
-		$itemIds = $this->limitArrayLength( $itemIds );
307
-		$formattedItemIds = array_map( [ $this, "formatItemId" ], $itemIds, array_fill( 0, count( $itemIds ), $role ) );
306
+		$itemIds = $this->limitArrayLength($itemIds);
307
+		$formattedItemIds = array_map([$this, "formatItemId"], $itemIds, array_fill(0, count($itemIds), $role));
308 308
 		array_unshift(
309 309
 			$formattedItemIds,
310
-			'<ul><li>' . implode( '</li><li>', $formattedItemIds ) . '</li></ul>'
310
+			'<ul><li>'.implode('</li><li>', $formattedItemIds).'</li></ul>'
311 311
 		);
312 312
 		return $formattedItemIds;
313 313
 	}
@@ -322,23 +322,23 @@  discard block
 block discarded – undo
322 322
 	 * @param string|null $role one of the Role constants or null
323 323
 	 * @return string[] HTML
324 324
 	 */
325
-	public function formatEntityIdList( array $entityIds, $role = null ) {
326
-		if ( empty( $entityIds ) ) {
327
-			return [ '<ul></ul>' ];
325
+	public function formatEntityIdList(array $entityIds, $role = null) {
326
+		if (empty($entityIds)) {
327
+			return ['<ul></ul>'];
328 328
 		}
329 329
 		$formattedEntityIds = [];
330
-		foreach ( $entityIds as $entityId ) {
331
-			if ( count( $formattedEntityIds ) >= self::MAX_PARAMETER_ARRAY_LENGTH ) {
330
+		foreach ($entityIds as $entityId) {
331
+			if (count($formattedEntityIds) >= self::MAX_PARAMETER_ARRAY_LENGTH) {
332 332
 				$formattedEntityIds[] = '...';
333 333
 				break;
334 334
 			}
335
-			if ( $entityId !== null ) {
336
-				$formattedEntityIds[] = $this->formatEntityId( $entityId, $role );
335
+			if ($entityId !== null) {
336
+				$formattedEntityIds[] = $this->formatEntityId($entityId, $role);
337 337
 			}
338 338
 		}
339 339
 		array_unshift(
340 340
 			$formattedEntityIds,
341
-			'<ul><li>' . implode( '</li><li>', $formattedEntityIds ) . '</li></ul>'
341
+			'<ul><li>'.implode('</li><li>', $formattedEntityIds).'</li></ul>'
342 342
 		);
343 343
 		return $formattedEntityIds;
344 344
 	}
@@ -353,24 +353,24 @@  discard block
 block discarded – undo
353 353
 	 * @param string|null $role one of the Role constants or null
354 354
 	 * @return string[] HTML
355 355
 	 */
356
-	public function formatItemIdSnakValueList( array $values, $role = null ) {
357
-		if ( empty( $values ) ) {
358
-			return [ '<ul></ul>' ];
356
+	public function formatItemIdSnakValueList(array $values, $role = null) {
357
+		if (empty($values)) {
358
+			return ['<ul></ul>'];
359 359
 		}
360
-		$values = $this->limitArrayLength( $values );
360
+		$values = $this->limitArrayLength($values);
361 361
 		$formattedValues = array_map(
362
-			function( $value ) use ( $role ) {
363
-				if ( $value === '...' ) {
362
+			function($value) use ($role) {
363
+				if ($value === '...') {
364 364
 					return '...';
365 365
 				} else {
366
-					return $this->formatItemIdSnakValue( $value, $role );
366
+					return $this->formatItemIdSnakValue($value, $role);
367 367
 				}
368 368
 			},
369 369
 			$values
370 370
 		);
371 371
 		array_unshift(
372 372
 			$formattedValues,
373
-			'<ul><li>' . implode( '</li><li>', $formattedValues ) . '</li></ul>'
373
+			'<ul><li>'.implode('</li><li>', $formattedValues).'</li></ul>'
374 374
 		);
375 375
 		return $formattedValues;
376 376
 	}
@@ -385,24 +385,24 @@  discard block
 block discarded – undo
385 385
 	 * @param string|null $role one of the Role constants or null
386 386
 	 * @return string[] HTML
387 387
 	 */
388
-	public function formatConstraintScopeList( array $scopes, $role = null ) {
389
-		if ( empty( $scopes ) ) {
390
-			return [ '<ul></ul>' ];
388
+	public function formatConstraintScopeList(array $scopes, $role = null) {
389
+		if (empty($scopes)) {
390
+			return ['<ul></ul>'];
391 391
 		}
392
-		$scopes = $this->limitArrayLength( $scopes );
392
+		$scopes = $this->limitArrayLength($scopes);
393 393
 		$formattedScopes = array_map(
394
-			function( $scope ) use ( $role ) {
395
-				if ( $scope === '...' ) {
394
+			function($scope) use ($role) {
395
+				if ($scope === '...') {
396 396
 					return '...';
397 397
 				} else {
398
-					return $this->formatConstraintScope( $scope, $role );
398
+					return $this->formatConstraintScope($scope, $role);
399 399
 				}
400 400
 			},
401 401
 			$scopes
402 402
 		);
403 403
 		array_unshift(
404 404
 			$formattedScopes,
405
-			'<ul><li>' . implode( '</li><li>', $formattedScopes ) . '</li></ul>'
405
+			'<ul><li>'.implode('</li><li>', $formattedScopes).'</li></ul>'
406 406
 		);
407 407
 		return $formattedScopes;
408 408
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ConflictsWithChecker.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -92,18 +92,18 @@  discard block
 block discarded – undo
92 92
 	 * @throws ConstraintParameterException
93 93
 	 * @return CheckResult
94 94
 	 */
95
-	public function checkConstraint( Context $context, Constraint $constraint ) {
96
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
97
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
95
+	public function checkConstraint(Context $context, Constraint $constraint) {
96
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
97
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
98 98
 		}
99 99
 
100 100
 		$parameters = [];
101 101
 		$constraintParameters = $constraint->getConstraintParameters();
102 102
 
103
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
104
-		$parameters['property'] = [ $propertyId ];
103
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
104
+		$parameters['property'] = [$propertyId];
105 105
 
106
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
106
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
107 107
 		$parameters['items'] = $items;
108 108
 
109 109
 		/*
@@ -111,16 +111,16 @@  discard block
 block discarded – undo
111 111
 		 *   a) a property only
112 112
 		 *   b) a property and a number of items (each combination of property and item forming an individual claim)
113 113
 		 */
114
-		if ( $items === [] ) {
114
+		if ($items === []) {
115 115
 			$offendingStatement = $this->connectionCheckerHelper->findStatementWithProperty(
116 116
 				$context->getEntity()->getStatements(),
117 117
 				$propertyId
118 118
 			);
119
-			if ( $offendingStatement !== null ) {
120
-				$message = wfMessage( "wbqc-violation-message-conflicts-with-property" )
119
+			if ($offendingStatement !== null) {
120
+				$message = wfMessage("wbqc-violation-message-conflicts-with-property")
121 121
 						 ->rawParams(
122
-							 $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
123
-							 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE )
122
+							 $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
123
+							 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE)
124 124
 						 )
125 125
 						 ->escaped();
126 126
 				$status = CheckResult::STATUS_VIOLATION;
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 				$propertyId,
135 135
 				$items
136 136
 			);
137
-			if ( $offendingStatement !== null ) {
138
-				$offendingValue = ItemIdSnakValue::fromSnak( $offendingStatement->getMainSnak() );
139
-				$message = wfMessage( "wbqc-violation-message-conflicts-with-claim" )
137
+			if ($offendingStatement !== null) {
138
+				$offendingValue = ItemIdSnakValue::fromSnak($offendingStatement->getMainSnak());
139
+				$message = wfMessage("wbqc-violation-message-conflicts-with-claim")
140 140
 						 ->rawParams(
141
-							 $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
142
-							 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ),
143
-							 $this->constraintParameterRenderer->formatItemIdSnakValue( $offendingValue, Role::OBJECT )
141
+							 $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
142
+							 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE),
143
+							 $this->constraintParameterRenderer->formatItemIdSnakValue($offendingValue, Role::OBJECT)
144 144
 						 )
145 145
 						 ->escaped();
146 146
 				$status = CheckResult::STATUS_VIOLATION;
@@ -150,20 +150,20 @@  discard block
 block discarded – undo
150 150
 			}
151 151
 		}
152 152
 
153
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
153
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
154 154
 	}
155 155
 
156
-	public function checkConstraintParameters( Constraint $constraint ) {
156
+	public function checkConstraintParameters(Constraint $constraint) {
157 157
 		$constraintParameters = $constraint->getConstraintParameters();
158 158
 		$exceptions = [];
159 159
 		try {
160
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
161
-		} catch ( ConstraintParameterException $e ) {
160
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
161
+		} catch (ConstraintParameterException $e) {
162 162
 			$exceptions[] = $e;
163 163
 		}
164 164
 		try {
165
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
166
-		} catch ( ConstraintParameterException $e ) {
165
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
166
+		} catch (ConstraintParameterException $e) {
167 167
 			$exceptions[] = $e;
168 168
 		}
169 169
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/DelegatingConstraintChecker.php 1 patch
Spacing   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
 		callable $defaultResults = null
138 138
 	) {
139 139
 
140
-		$entity = $this->entityLookup->getEntity( $entityId );
141
-		if ( $entity instanceof StatementListProvider ) {
140
+		$entity = $this->entityLookup->getEntity($entityId);
141
+		if ($entity instanceof StatementListProvider) {
142 142
 			$result = $this->checkEveryStatement(
143
-				$this->entityLookup->getEntity( $entityId ),
143
+				$this->entityLookup->getEntity($entityId),
144 144
 				$constraintIds,
145 145
 				$defaultResults
146 146
 			);
147
-			$output = $this->sortResult( $result );
147
+			$output = $this->sortResult($result);
148 148
 			return $output;
149 149
 		}
150 150
 
@@ -170,19 +170,19 @@  discard block
 block discarded – undo
170 170
 		callable $defaultResults = null
171 171
 	) {
172 172
 
173
-		$parsedGuid = $this->statementGuidParser->parse( $guid );
173
+		$parsedGuid = $this->statementGuidParser->parse($guid);
174 174
 		$entityId = $parsedGuid->getEntityId();
175
-		$entity = $this->entityLookup->getEntity( $entityId );
176
-		if ( $entity instanceof StatementListProvider ) {
177
-			$statement = $entity->getStatements()->getFirstStatementWithGuid( $guid );
178
-			if ( $statement ) {
175
+		$entity = $this->entityLookup->getEntity($entityId);
176
+		if ($entity instanceof StatementListProvider) {
177
+			$statement = $entity->getStatements()->getFirstStatementWithGuid($guid);
178
+			if ($statement) {
179 179
 				$result = $this->checkStatement(
180 180
 					$entity,
181 181
 					$statement,
182 182
 					$constraintIds,
183 183
 					$defaultResults
184 184
 				);
185
-				$output = $this->sortResult( $result );
185
+				$output = $this->sortResult($result);
186 186
 				return $output;
187 187
 			}
188 188
 		}
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 		return [];
191 191
 	}
192 192
 
193
-	private function getAllowedContextTypes( Constraint $constraint ) {
194
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
193
+	private function getAllowedContextTypes(Constraint $constraint) {
194
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
195 195
 			return [
196 196
 				Context::TYPE_STATEMENT,
197 197
 				Context::TYPE_QUALIFIER,
@@ -199,12 +199,12 @@  discard block
 block discarded – undo
199 199
 			];
200 200
 		}
201 201
 
202
-		return array_keys( array_filter(
202
+		return array_keys(array_filter(
203 203
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedContextTypes(),
204
-			function ( $resultStatus ) {
204
+			function($resultStatus) {
205 205
 				return $resultStatus !== CheckResult::STATUS_NOT_IN_SCOPE;
206 206
 			}
207
-		) );
207
+		));
208 208
 	}
209 209
 
210 210
 	/**
@@ -215,32 +215,32 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return ConstraintParameterException[]
217 217
 	 */
218
-	private function checkCommonConstraintParameters( Constraint $constraint ) {
218
+	private function checkCommonConstraintParameters(Constraint $constraint) {
219 219
 		$constraintParameters = $constraint->getConstraintParameters();
220 220
 		try {
221
-			$this->constraintParameterParser->checkError( $constraintParameters );
222
-		} catch ( ConstraintParameterException $e ) {
223
-			return [ $e ];
221
+			$this->constraintParameterParser->checkError($constraintParameters);
222
+		} catch (ConstraintParameterException $e) {
223
+			return [$e];
224 224
 		}
225 225
 
226 226
 		$problems = [];
227 227
 		try {
228
-			$this->constraintParameterParser->parseExceptionParameter( $constraintParameters );
229
-		} catch ( ConstraintParameterException $e ) {
228
+			$this->constraintParameterParser->parseExceptionParameter($constraintParameters);
229
+		} catch (ConstraintParameterException $e) {
230 230
 			$problems[] = $e;
231 231
 		}
232 232
 		try {
233
-			$this->constraintParameterParser->parseConstraintStatusParameter( $constraintParameters );
234
-		} catch ( ConstraintParameterException $e ) {
233
+			$this->constraintParameterParser->parseConstraintStatusParameter($constraintParameters);
234
+		} catch (ConstraintParameterException $e) {
235 235
 			$problems[] = $e;
236 236
 		}
237 237
 		try {
238 238
 			$this->constraintParameterParser->parseConstraintScopeParameter(
239 239
 				$constraintParameters,
240 240
 				$constraint->getConstraintTypeItemId(),
241
-				$this->getAllowedContextTypes( $constraint )
241
+				$this->getAllowedContextTypes($constraint)
242 242
 			);
243
-		} catch ( ConstraintParameterException $e ) {
243
+		} catch (ConstraintParameterException $e) {
244 244
 			$problems[] = $e;
245 245
 		}
246 246
 		return $problems;
@@ -253,16 +253,16 @@  discard block
 block discarded – undo
253 253
 	 * @return ConstraintParameterException[][] first level indexed by constraint ID,
254 254
 	 * second level like checkConstraintParametersOnConstraintId (but without possibility of null)
255 255
 	 */
256
-	public function checkConstraintParametersOnPropertyId( PropertyId $propertyId ) {
257
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
256
+	public function checkConstraintParametersOnPropertyId(PropertyId $propertyId) {
257
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
258 258
 		$result = [];
259 259
 
260
-		foreach ( $constraints as $constraint ) {
261
-			$problems = $this->checkCommonConstraintParameters( $constraint );
260
+		foreach ($constraints as $constraint) {
261
+			$problems = $this->checkCommonConstraintParameters($constraint);
262 262
 
263
-			if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
263
+			if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
264 264
 				$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
265
-				$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
265
+				$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
266 266
 			}
267 267
 
268 268
 			$result[$constraint->getConstraintId()] = $problems;
@@ -279,17 +279,17 @@  discard block
 block discarded – undo
279 279
 	 * @return ConstraintParameterException[]|null list of constraint parameter exceptions
280 280
 	 * (empty means all parameters okay), or null if constraint is not found
281 281
 	 */
282
-	public function checkConstraintParametersOnConstraintId( $constraintId ) {
283
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
284
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
282
+	public function checkConstraintParametersOnConstraintId($constraintId) {
283
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
284
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
285 285
 
286
-		foreach ( $constraints as $constraint ) {
287
-			if ( $constraint->getConstraintId() === $constraintId ) {
288
-				$problems = $this->checkCommonConstraintParameters( $constraint );
286
+		foreach ($constraints as $constraint) {
287
+			if ($constraint->getConstraintId() === $constraintId) {
288
+				$problems = $this->checkCommonConstraintParameters($constraint);
289 289
 
290
-				if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
290
+				if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
291 291
 					$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
292
-					$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
292
+					$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
293 293
 				}
294 294
 
295 295
 				return $problems;
@@ -314,14 +314,14 @@  discard block
 block discarded – undo
314 314
 		$result = [];
315 315
 
316 316
 		/** @var Statement $statement */
317
-		foreach ( $entity->getStatements() as $statement ) {
318
-			$result = array_merge( $result,
317
+		foreach ($entity->getStatements() as $statement) {
318
+			$result = array_merge($result,
319 319
 				$this->checkStatement(
320 320
 					$entity,
321 321
 					$statement,
322 322
 					$constraintIds,
323 323
 					$defaultResults
324
-				) );
324
+				));
325 325
 		}
326 326
 
327 327
 		return $result;
@@ -343,32 +343,32 @@  discard block
 block discarded – undo
343 343
 	) {
344 344
 		$result = [];
345 345
 
346
-		$result = array_merge( $result,
346
+		$result = array_merge($result,
347 347
 			$this->checkConstraintsForMainSnak(
348 348
 				$entity,
349 349
 				$statement,
350 350
 				$constraintIds,
351 351
 				$defaultResults
352
-			) );
352
+			));
353 353
 
354
-		if ( $this->checkQualifiers ) {
355
-			$result = array_merge( $result,
354
+		if ($this->checkQualifiers) {
355
+			$result = array_merge($result,
356 356
 				$this->checkConstraintsForQualifiers(
357 357
 					$entity,
358 358
 					$statement,
359 359
 					$constraintIds,
360 360
 					$defaultResults
361
-				) );
361
+				));
362 362
 		}
363 363
 
364
-		if ( $this->checkReferences ) {
365
-			$result = array_merge( $result,
364
+		if ($this->checkReferences) {
365
+			$result = array_merge($result,
366 366
 				$this->checkConstraintsForReferences(
367 367
 					$entity,
368 368
 					$statement,
369 369
 					$constraintIds,
370 370
 					$defaultResults
371
-				) );
371
+				));
372 372
 		}
373 373
 
374 374
 		return $result;
@@ -383,12 +383,12 @@  discard block
 block discarded – undo
383 383
 	 * @param string[]|null $constraintIds
384 384
 	 * @return Constraint[]
385 385
 	 */
386
-	private function getConstraintsToUse( PropertyId $propertyId, array $constraintIds = null ) {
387
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
388
-		if ( $constraintIds !== null ) {
386
+	private function getConstraintsToUse(PropertyId $propertyId, array $constraintIds = null) {
387
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
388
+		if ($constraintIds !== null) {
389 389
 			$constraintsToUse = [];
390
-			foreach ( $constraints as $constraint ) {
391
-				if ( in_array( $constraint->getConstraintId(), $constraintIds ) ) {
390
+			foreach ($constraints as $constraint) {
391
+				if (in_array($constraint->getConstraintId(), $constraintIds)) {
392 392
 					$constraintsToUse[] = $constraint;
393 393
 				}
394 394
 			}
@@ -412,29 +412,29 @@  discard block
 block discarded – undo
412 412
 		array $constraintIds = null,
413 413
 		callable $defaultResults = null
414 414
 	) {
415
-		$context = new MainSnakContext( $entity, $statement );
415
+		$context = new MainSnakContext($entity, $statement);
416 416
 		$constraints = $this->getConstraintsToUse(
417 417
 			$statement->getPropertyId(),
418 418
 			$constraintIds
419 419
 		);
420
-		$result = $defaultResults !== null ? $defaultResults( $context ) : [];
420
+		$result = $defaultResults !== null ? $defaultResults($context) : [];
421 421
 
422
-		foreach ( $constraints as $constraint ) {
422
+		foreach ($constraints as $constraint) {
423 423
 			$parameters = $constraint->getConstraintParameters();
424 424
 			try {
425
-				$exceptions = $this->constraintParameterParser->parseExceptionParameter( $parameters );
426
-			} catch ( ConstraintParameterException $e ) {
427
-				$result[] = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage() );
425
+				$exceptions = $this->constraintParameterParser->parseExceptionParameter($parameters);
426
+			} catch (ConstraintParameterException $e) {
427
+				$result[] = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage());
428 428
 				continue;
429 429
 			}
430 430
 
431
-			if ( in_array( $entity->getId(), $exceptions ) ) {
432
-				$message = wfMessage( 'wbqc-exception-message' )->escaped();
433
-				$result[] = new CheckResult( $context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message );
431
+			if (in_array($entity->getId(), $exceptions)) {
432
+				$message = wfMessage('wbqc-exception-message')->escaped();
433
+				$result[] = new CheckResult($context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message);
434 434
 				continue;
435 435
 			}
436 436
 
437
-			$result[] = $this->getCheckResultFor( $context, $constraint );
437
+			$result[] = $this->getCheckResultFor($context, $constraint);
438 438
 		}
439 439
 
440 440
 		return $result;
@@ -456,24 +456,24 @@  discard block
 block discarded – undo
456 456
 	) {
457 457
 		$result = [];
458 458
 
459
-		if ( in_array(
459
+		if (in_array(
460 460
 			$statement->getPropertyId()->getSerialization(),
461 461
 			$this->propertiesWithViolatingQualifiers
462
-		) ) {
462
+		)) {
463 463
 			return $result;
464 464
 		}
465 465
 
466
-		foreach ( $statement->getQualifiers() as $qualifier ) {
467
-			$qualifierContext = new QualifierContext( $entity, $statement, $qualifier );
468
-			if ( $defaultResults !== null ) {
469
-				$result = array_merge( $result, $defaultResults( $qualifierContext ) );
466
+		foreach ($statement->getQualifiers() as $qualifier) {
467
+			$qualifierContext = new QualifierContext($entity, $statement, $qualifier);
468
+			if ($defaultResults !== null) {
469
+				$result = array_merge($result, $defaultResults($qualifierContext));
470 470
 			}
471 471
 			$qualifierConstraints = $this->getConstraintsToUse(
472 472
 				$qualifierContext->getSnak()->getPropertyId(),
473 473
 				$constraintIds
474 474
 			);
475
-			foreach ( $qualifierConstraints as $qualifierConstraint ) {
476
-				$result[] = $this->getCheckResultFor( $qualifierContext, $qualifierConstraint );
475
+			foreach ($qualifierConstraints as $qualifierConstraint) {
476
+				$result[] = $this->getCheckResultFor($qualifierContext, $qualifierConstraint);
477 477
 			}
478 478
 		}
479 479
 
@@ -497,19 +497,19 @@  discard block
 block discarded – undo
497 497
 		$result = [];
498 498
 
499 499
 		/** @var Reference $reference */
500
-		foreach ( $statement->getReferences() as $reference ) {
501
-			foreach ( $reference->getSnaks() as $snak ) {
500
+		foreach ($statement->getReferences() as $reference) {
501
+			foreach ($reference->getSnaks() as $snak) {
502 502
 				$referenceContext = new ReferenceContext(
503 503
 					$entity, $statement, $reference, $snak
504 504
 				);
505
-				if ( $defaultResults !== null ) {
506
-					$result = array_merge( $result, $defaultResults( $referenceContext ) );
505
+				if ($defaultResults !== null) {
506
+					$result = array_merge($result, $defaultResults($referenceContext));
507 507
 				}
508 508
 				$referenceConstraints = $this->getConstraintsToUse(
509 509
 					$referenceContext->getSnak()->getPropertyId(),
510 510
 					$constraintIds
511 511
 				);
512
-				foreach ( $referenceConstraints as $referenceConstraint ) {
512
+				foreach ($referenceConstraints as $referenceConstraint) {
513 513
 					$result[] = $this->getCheckResultFor(
514 514
 						$referenceContext,
515 515
 						$referenceConstraint
@@ -528,65 +528,65 @@  discard block
 block discarded – undo
528 528
 	 * @throws InvalidArgumentException
529 529
 	 * @return CheckResult
530 530
 	 */
531
-	private function getCheckResultFor( Context $context, Constraint $constraint ) {
532
-		if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
531
+	private function getCheckResultFor(Context $context, Constraint $constraint) {
532
+		if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
533 533
 			$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
534
-			$result = $this->handleScope( $checker, $context, $constraint );
534
+			$result = $this->handleScope($checker, $context, $constraint);
535 535
 
536
-			if ( $result !== null ) {
537
-				$this->addMetadata( $result );
536
+			if ($result !== null) {
537
+				$this->addMetadata($result);
538 538
 				return $result;
539 539
 			}
540 540
 
541
-			$startTime = microtime( true );
541
+			$startTime = microtime(true);
542 542
 			try {
543
-				$result = $checker->checkConstraint( $context, $constraint );
544
-			} catch ( ConstraintParameterException $e ) {
545
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage() );
546
-			} catch ( SparqlHelperException $e ) {
547
-				$message = wfMessage( 'wbqc-violation-message-sparql-error' )->escaped();
548
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
543
+				$result = $checker->checkConstraint($context, $constraint);
544
+			} catch (ConstraintParameterException $e) {
545
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage());
546
+			} catch (SparqlHelperException $e) {
547
+				$message = wfMessage('wbqc-violation-message-sparql-error')->escaped();
548
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
549 549
 			}
550
-			$endTime = microtime( true );
550
+			$endTime = microtime(true);
551 551
 
552
-			$this->addMetadata( $result );
552
+			$this->addMetadata($result);
553 553
 
554 554
 			try {
555 555
 				$constraintStatus = $this->constraintParameterParser
556
-					->parseConstraintStatusParameter( $constraint->getConstraintParameters() );
557
-			} catch ( ConstraintParameterException $e ) {
558
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage() );
556
+					->parseConstraintStatusParameter($constraint->getConstraintParameters());
557
+			} catch (ConstraintParameterException $e) {
558
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage());
559 559
 				$constraintStatus = null;
560 560
 			}
561
-			if ( $constraintStatus === null ) {
561
+			if ($constraintStatus === null) {
562 562
 				// downgrade violation to warning
563
-				if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
564
-					$result->setStatus( CheckResult::STATUS_WARNING );
563
+				if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
564
+					$result->setStatus(CheckResult::STATUS_WARNING);
565 565
 				}
566 566
 			} else {
567
-				if ( $constraintStatus !== 'mandatory' ) {
567
+				if ($constraintStatus !== 'mandatory') {
568 568
 					// @codeCoverageIgnoreStart
569 569
 					throw new LogicException(
570
-						"Unknown constraint status '$constraintStatus', " .
570
+						"Unknown constraint status '$constraintStatus', ".
571 571
 						"only known status is 'mandatory'"
572 572
 					);
573 573
 					// @codeCoverageIgnoreEnd
574 574
 				}
575
-				$result->addParameter( 'constraint_status', $constraintStatus );
575
+				$result->addParameter('constraint_status', $constraintStatus);
576 576
 			}
577 577
 
578 578
 			$this->loggingHelper->logConstraintCheck(
579 579
 				$context,
580 580
 				$constraint,
581 581
 				$result,
582
-				get_class( $checker ),
582
+				get_class($checker),
583 583
 				$endTime - $startTime,
584 584
 				__METHOD__
585 585
 			);
586 586
 
587 587
 			return $result;
588 588
 		} else {
589
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
589
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
590 590
 		}
591 591
 	}
592 592
 
@@ -600,29 +600,29 @@  discard block
 block discarded – undo
600 600
 				$constraint->getConstraintParameters(),
601 601
 				$constraint->getConstraintTypeItemId()
602 602
 			);
603
-		} catch ( ConstraintParameterException $e ) {
604
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage() );
603
+		} catch (ConstraintParameterException $e) {
604
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage());
605 605
 		}
606
-		if ( $checkedContextTypes === null ) {
606
+		if ($checkedContextTypes === null) {
607 607
 			$checkedContextTypes = $checker->getDefaultContextTypes();
608 608
 		}
609
-		if ( !in_array( $context->getType(), $checkedContextTypes ) ) {
610
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null );
609
+		if (!in_array($context->getType(), $checkedContextTypes)) {
610
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null);
611 611
 		}
612
-		if ( $checker->getSupportedContextTypes()[$context->getType()] === CheckResult::STATUS_TODO ) {
613
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
612
+		if ($checker->getSupportedContextTypes()[$context->getType()] === CheckResult::STATUS_TODO) {
613
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
614 614
 		}
615 615
 		return null;
616 616
 	}
617 617
 
618
-	private function addMetadata( CheckResult $result ) {
619
-		$result->withMetadata( Metadata::merge( [
618
+	private function addMetadata(CheckResult $result) {
619
+		$result->withMetadata(Metadata::merge([
620 620
 			$result->getMetadata(),
621
-			Metadata::ofDependencyMetadata( DependencyMetadata::merge( [
622
-				DependencyMetadata::ofEntityId( $result->getEntityId() ),
623
-				DependencyMetadata::ofEntityId( $result->getConstraint()->getPropertyId() ),
624
-			] ) ),
625
-		] ) );
621
+			Metadata::ofDependencyMetadata(DependencyMetadata::merge([
622
+				DependencyMetadata::ofEntityId($result->getEntityId()),
623
+				DependencyMetadata::ofEntityId($result->getConstraint()->getPropertyId()),
624
+			])),
625
+		]));
626 626
 	}
627 627
 
628 628
 	/**
@@ -630,12 +630,12 @@  discard block
 block discarded – undo
630 630
 	 *
631 631
 	 * @return CheckResult[]
632 632
 	 */
633
-	private function sortResult( array $result ) {
634
-		if ( count( $result ) < 2 ) {
633
+	private function sortResult(array $result) {
634
+		if (count($result) < 2) {
635 635
 			return $result;
636 636
 		}
637 637
 
638
-		$sortFunction = function ( CheckResult $a, CheckResult $b ) {
638
+		$sortFunction = function(CheckResult $a, CheckResult $b) {
639 639
 			$orderNum = 0;
640 640
 			$order = [
641 641
 				CheckResult::STATUS_BAD_PARAMETERS => $orderNum++,
@@ -651,45 +651,45 @@  discard block
 block discarded – undo
651 651
 			$statusA = $a->getStatus();
652 652
 			$statusB = $b->getStatus();
653 653
 
654
-			$orderA = array_key_exists( $statusA, $order ) ? $order[ $statusA ] : $order[ 'other' ];
655
-			$orderB = array_key_exists( $statusB, $order ) ? $order[ $statusB ] : $order[ 'other' ];
654
+			$orderA = array_key_exists($statusA, $order) ? $order[$statusA] : $order['other'];
655
+			$orderB = array_key_exists($statusB, $order) ? $order[$statusB] : $order['other'];
656 656
 
657
-			if ( $orderA === $orderB ) {
657
+			if ($orderA === $orderB) {
658 658
 				$pidA = $a->getContext()->getSnak()->getPropertyId()->getSerialization();
659 659
 				$pidB = $b->getContext()->getSnak()->getPropertyId()->getSerialization();
660 660
 
661
-				if ( $pidA === $pidB ) {
661
+				if ($pidA === $pidB) {
662 662
 					$hashA = $a->getContext()->getSnak()->getHash();
663 663
 					$hashB = $b->getContext()->getSnak()->getHash();
664 664
 
665
-					if ( $hashA === $hashB ) {
666
-						if ( $a instanceof NullResult ) {
665
+					if ($hashA === $hashB) {
666
+						if ($a instanceof NullResult) {
667 667
 							return $b instanceof NullResult ? 0 : -1;
668 668
 						}
669
-						if ( $b instanceof NullResult ) {
669
+						if ($b instanceof NullResult) {
670 670
 							return $a instanceof NullResult ? 0 : 1;
671 671
 						}
672 672
 
673 673
 						$typeA = $a->getConstraint()->getConstraintTypeItemId();
674 674
 						$typeB = $b->getConstraint()->getConstraintTypeItemId();
675 675
 
676
-						if ( $typeA == $typeB ) {
676
+						if ($typeA == $typeB) {
677 677
 							return 0;
678 678
 						} else {
679
-							return ( $typeA > $typeB ) ? 1 : -1;
679
+							return ($typeA > $typeB) ? 1 : -1;
680 680
 						}
681 681
 					} else {
682
-						return ( $hashA > $hashB ) ? 1 : -1;
682
+						return ($hashA > $hashB) ? 1 : -1;
683 683
 					}
684 684
 				} else {
685
-					return ( $pidA > $pidB ) ? 1 : -1;
685
+					return ($pidA > $pidB) ? 1 : -1;
686 686
 				}
687 687
 			} else {
688
-				return ( $orderA > $orderB ) ? 1 : -1;
688
+				return ($orderA > $orderB) ? 1 : -1;
689 689
 			}
690 690
 		};
691 691
 
692
-		uasort( $result, $sortFunction );
692
+		uasort($result, $sortFunction);
693 693
 
694 694
 		return $result;
695 695
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/ItemIdSnakValue.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param ItemId $itemId
45 45
 	 * @return self
46 46
 	 */
47
-	public static function fromItemId( ItemId $itemId ) {
47
+	public static function fromItemId(ItemId $itemId) {
48 48
 		$ret = new self;
49 49
 		$ret->itemId = $itemId;
50 50
 		return $ret;
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	 * @throws InvalidArgumentException
81 81
 	 * @return self
82 82
 	 */
83
-	public static function fromSnak( Snak $snak ) {
84
-		switch ( true ) {
83
+	public static function fromSnak(Snak $snak) {
84
+		switch (true) {
85 85
 			case $snak instanceof PropertyValueSnak:
86 86
 				$dataValue = $snak->getDataValue();
87
-				if ( $dataValue instanceof EntityIdValue
87
+				if ($dataValue instanceof EntityIdValue
88 88
 					&& $dataValue->getEntityId() instanceof ItemId
89 89
 				) {
90
-					return self::fromItemId( $dataValue->getEntityId() );
90
+					return self::fromItemId($dataValue->getEntityId());
91 91
 				}
92 92
 				break;
93 93
 			case $snak instanceof PropertySomeValueSnak:
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 				return self::noValue();
97 97
 		}
98 98
 
99
-		throw new InvalidArgumentException( 'Snak must contain item ID value or be a somevalue / novalue snak' );
99
+		throw new InvalidArgumentException('Snak must contain item ID value or be a somevalue / novalue snak');
100 100
 	}
101 101
 
102 102
 	/**
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 * @return ItemId
134 134
 	 */
135 135
 	public function getItemId() {
136
-		if ( ! $this->isValue() ) {
137
-			throw new DomainException( 'This value does not contain an item ID.' );
136
+		if (!$this->isValue()) {
137
+			throw new DomainException('This value does not contain an item ID.');
138 138
 		}
139 139
 		return $this->itemId;
140 140
 	}
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 	 * @param Snak $snak
147 147
 	 * @return bool
148 148
 	 */
149
-	public function matchesSnak( Snak $snak ) {
150
-		switch ( true ) {
149
+	public function matchesSnak(Snak $snak) {
150
+		switch (true) {
151 151
 			case $snak instanceof PropertyValueSnak:
152 152
 				return $this->isValue() &&
153 153
 					$snak->getDataValue() instanceof EntityIdValue &&
154 154
 					$snak->getDataValue()->getEntityId() instanceof ItemId &&
155
-					$snak->getDataValue()->getEntityId()->equals( $this->getItemId() );
155
+					$snak->getDataValue()->getEntityId()->equals($this->getItemId());
156 156
 			case $snak instanceof PropertySomeValueSnak:
157 157
 				return $this->isSomeValue();
158 158
 			case $snak instanceof PropertyNoValueSnak:
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConnectionCheckerHelper.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 		StatementList $statementList,
31 31
 		PropertyId $propertyId
32 32
 	) {
33
-		$statementListByPropertyId = $statementList->getByPropertyId( $propertyId );
34
-		if ( $statementListByPropertyId->isEmpty() ) {
33
+		$statementListByPropertyId = $statementList->getByPropertyId($propertyId);
34
+		if ($statementListByPropertyId->isEmpty()) {
35 35
 			return null;
36 36
 		} else {
37 37
 			return $statementListByPropertyId->toArray()[0];
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 		PropertyId $propertyId,
53 53
 		EntityId $value
54 54
 	) {
55
-		$statementListByPropertyId = $statementList->getByPropertyId( $propertyId );
55
+		$statementListByPropertyId = $statementList->getByPropertyId($propertyId);
56 56
 		/** @var Statement $statement */
57
-		foreach ( $statementListByPropertyId as $statement ) {
57
+		foreach ($statementListByPropertyId as $statement) {
58 58
 			$snak = $statement->getMainSnak();
59
-			if ( $snak instanceof PropertyValueSnak ) {
59
+			if ($snak instanceof PropertyValueSnak) {
60 60
 				$dataValue = $snak->getDataValue();
61
-				if ( $dataValue instanceof EntityIdValue &&
62
-					$dataValue->getEntityId()->equals( $value )
61
+				if ($dataValue instanceof EntityIdValue &&
62
+					$dataValue->getEntityId()->equals($value)
63 63
 				) {
64 64
 					return $statement;
65 65
 				}
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 		PropertyId $propertyId,
83 83
 		array $values
84 84
 	) {
85
-		$statementListByPropertyId = $statementList->getByPropertyId( $propertyId );
85
+		$statementListByPropertyId = $statementList->getByPropertyId($propertyId);
86 86
 		/** @var Statement $statement */
87
-		foreach ( $statementListByPropertyId as $statement ) {
87
+		foreach ($statementListByPropertyId as $statement) {
88 88
 			$snak = $statement->getMainSnak();
89
-			foreach ( $values as $value ) {
90
-				if ( $value->matchesSnak( $snak ) ) {
89
+			foreach ($values as $value) {
90
+				if ($value->matchesSnak($snak)) {
91 91
 					return $statement;
92 92
 				}
93 93
 			}
Please login to merge, or discard this patch.
src/UpdateConstraintsTableJob.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 
27 27
 	const BATCH_SIZE = 10;
28 28
 
29
-	public static function newFromGlobalState( Title $title, array $params ) {
30
-		Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' );
29
+	public static function newFromGlobalState(Title $title, array $params) {
30
+		Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]');
31 31
 		$repo = WikibaseRepo::getDefaultInstance();
32 32
 		return new UpdateConstraintsTableJob(
33 33
 			$title,
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		EntityLookup $entityLookup,
84 84
 		Serializer $snakSerializer
85 85
 	) {
86
-		parent::__construct( 'constraintsTableUpdate', $title, $params );
86
+		parent::__construct('constraintsTableUpdate', $title, $params);
87 87
 
88 88
 		$this->propertyId = $propertyId;
89 89
 		$this->config = $config;
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 		$this->snakSerializer = $snakSerializer;
93 93
 	}
94 94
 
95
-	public function extractParametersFromQualifiers( SnakList $qualifiers ) {
95
+	public function extractParametersFromQualifiers(SnakList $qualifiers) {
96 96
 		$parameters = [];
97
-		foreach ( $qualifiers as $qualifier ) {
97
+		foreach ($qualifiers as $qualifier) {
98 98
 			$qualifierId = $qualifier->getPropertyId()->getSerialization();
99
-			$paramSerialization = $this->snakSerializer->serialize( $qualifier );
99
+			$paramSerialization = $this->snakSerializer->serialize($qualifier);
100 100
 			$parameters[$qualifierId][] = $paramSerialization;
101 101
 		}
102 102
 		return $parameters;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	) {
109 109
 		$constraintId = $constraintStatement->getGuid();
110 110
 		$constraintTypeQid = $constraintStatement->getMainSnak()->getDataValue()->getEntityId()->getSerialization();
111
-		$parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() );
111
+		$parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers());
112 112
 		return new Constraint(
113 113
 			$constraintId,
114 114
 			$propertyId,
@@ -123,17 +123,17 @@  discard block
 block discarded – undo
123 123
 		PropertyId $propertyConstraintPropertyId
124 124
 	) {
125 125
 		$constraintsStatements = $property->getStatements()
126
-			->getByPropertyId( $propertyConstraintPropertyId )
127
-			->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] );
126
+			->getByPropertyId($propertyConstraintPropertyId)
127
+			->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]);
128 128
 		$constraints = [];
129
-		foreach ( $constraintsStatements->getIterator() as $constraintStatement ) {
130
-			$constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement );
131
-			if ( count( $constraints ) >= self::BATCH_SIZE ) {
132
-				$constraintRepo->insertBatch( $constraints );
129
+		foreach ($constraintsStatements->getIterator() as $constraintStatement) {
130
+			$constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement);
131
+			if (count($constraints) >= self::BATCH_SIZE) {
132
+				$constraintRepo->insertBatch($constraints);
133 133
 				$constraints = [];
134 134
 			}
135 135
 		}
136
-		$constraintRepo->insertBatch( $constraints );
136
+		$constraintRepo->insertBatch($constraints);
137 137
 	}
138 138
 
139 139
 	/**
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
 	public function run() {
145 145
 		// TODO in the future: only touch constraints affected by the edit (requires T163465)
146 146
 
147
-		$propertyId = new PropertyId( $this->propertyId );
148
-		$this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId( $propertyId );
147
+		$propertyId = new PropertyId($this->propertyId);
148
+		$this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId($propertyId);
149 149
 
150 150
 		/** @var Property $property */
151
-		$property = $this->entityLookup->getEntity( $propertyId );
151
+		$property = $this->entityLookup->getEntity($propertyId);
152 152
 		$this->importConstraintsForProperty(
153 153
 			$property,
154 154
 			$this->constraintRepo,
155
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) )
155
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId'))
156 156
 		);
157 157
 
158 158
 		return true;
Please login to merge, or discard this patch.
src/Api/CachingResultsBuilder.php 1 patch
Spacing   +50 added lines, -51 removed lines patch added patch discarded remove patch
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	) {
135 135
 		$results = [];
136 136
 		$metadatas = [];
137
-		if ( $this->canUseStoredResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
137
+		if ($this->canUseStoredResults($entityIds, $claimIds, $constraintIds, $statuses)) {
138 138
 			$storedEntityIds = [];
139
-			foreach ( $entityIds as $entityId ) {
140
-				$storedResults = $this->getStoredResults( $entityId );
141
-				if ( $storedResults !== null ) {
139
+			foreach ($entityIds as $entityId) {
140
+				$storedResults = $this->getStoredResults($entityId);
141
+				if ($storedResults !== null) {
142 142
 					$this->dataFactory->increment(
143 143
 						'wikibase.quality.constraints.cache.entity.hit'
144 144
 					);
@@ -147,20 +147,20 @@  discard block
 block discarded – undo
147 147
 					$storedEntityIds[] = $entityId;
148 148
 				}
149 149
 			}
150
-			$entityIds = array_values( array_diff( $entityIds, $storedEntityIds ) );
150
+			$entityIds = array_values(array_diff($entityIds, $storedEntityIds));
151 151
 		}
152
-		if ( $entityIds !== [] || $claimIds !== [] ) {
152
+		if ($entityIds !== [] || $claimIds !== []) {
153 153
 			$this->dataFactory->updateCount(
154 154
 				'wikibase.quality.constraints.cache.entity.miss',
155
-				count( $entityIds )
155
+				count($entityIds)
156 156
 			);
157
-			$response = $this->getAndStoreResults( $entityIds, $claimIds, $constraintIds, $statuses );
157
+			$response = $this->getAndStoreResults($entityIds, $claimIds, $constraintIds, $statuses);
158 158
 			$results += $response->getArray();
159 159
 			$metadatas[] = $response->getMetadata();
160 160
 		}
161 161
 		return new CachedCheckConstraintsResponse(
162 162
 			$results,
163
-			Metadata::merge( $metadatas )
163
+			Metadata::merge($metadatas)
164 164
 		);
165 165
 	}
166 166
 
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
 		array $constraintIds = null,
190 190
 		array $statuses
191 191
 	) {
192
-		if ( $claimIds !== [] ) {
192
+		if ($claimIds !== []) {
193 193
 			return false;
194 194
 		}
195
-		if ( $constraintIds !== null ) {
195
+		if ($constraintIds !== null) {
196 196
 			return false;
197 197
 		}
198
-		if ( $statuses != $this->cachedStatuses ) {
198
+		if ($statuses != $this->cachedStatuses) {
199 199
 			return false;
200 200
 		}
201 201
 		return true;
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
 		array $constraintIds = null,
215 215
 		array $statuses
216 216
 	) {
217
-		$results = $this->resultsBuilder->getResults( $entityIds, $claimIds, $constraintIds, $statuses );
217
+		$results = $this->resultsBuilder->getResults($entityIds, $claimIds, $constraintIds, $statuses);
218 218
 
219
-		if ( $this->canStoreResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
220
-			foreach ( $entityIds as $entityId ) {
219
+		if ($this->canStoreResults($entityIds, $claimIds, $constraintIds, $statuses)) {
220
+			foreach ($entityIds as $entityId) {
221 221
 				$value = [
222 222
 					'results' => $results->getArray()[$entityId->getSerialization()],
223 223
 					'latestRevisionIds' => $this->getLatestRevisionIds(
224 224
 						$results->getMetadata()->getDependencyMetadata()->getEntityIds()
225 225
 					),
226 226
 				];
227
-				$this->cache->set( $entityId, $value, $this->ttlInSeconds );
227
+				$this->cache->set($entityId, $value, $this->ttlInSeconds);
228 228
 			}
229 229
 		}
230 230
 
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
 		array $constraintIds = null,
257 257
 		array $statuses
258 258
 	) {
259
-		if ( $constraintIds !== null ) {
259
+		if ($constraintIds !== null) {
260 260
 			return false;
261 261
 		}
262
-		if ( $statuses != $this->cachedStatuses ) {
262
+		if ($statuses != $this->cachedStatuses) {
263 263
 			return false;
264 264
 		}
265 265
 		return true;
@@ -272,45 +272,44 @@  discard block
 block discarded – undo
272 272
 	public function getStoredResults(
273 273
 		EntityId $entityId
274 274
 	) {
275
-		$value = $this->cache->get( $entityId, $curTTL, [], $asOf );
276
-		$now = call_user_func( $this->microtime, true );
275
+		$value = $this->cache->get($entityId, $curTTL, [], $asOf);
276
+		$now = call_user_func($this->microtime, true);
277 277
 
278
-		if ( $value === false ) {
278
+		if ($value === false) {
279 279
 			return null;
280 280
 		}
281 281
 
282
-		$ageInSeconds = (int)ceil( $now - $asOf );
282
+		$ageInSeconds = (int) ceil($now - $asOf);
283 283
 
284 284
 		$dependedEntityIds = array_map(
285
-			[ $this->entityIdParser, "parse" ],
286
-			array_keys( $value['latestRevisionIds'] )
285
+			[$this->entityIdParser, "parse"],
286
+			array_keys($value['latestRevisionIds'])
287 287
 		);
288 288
 
289
-		if ( $value['latestRevisionIds'] !== $this->getLatestRevisionIds( $dependedEntityIds ) ) {
289
+		if ($value['latestRevisionIds'] !== $this->getLatestRevisionIds($dependedEntityIds)) {
290 290
 			return null;
291 291
 		}
292 292
 
293 293
 		$cachingMetadata = $ageInSeconds > 0 ?
294
-			CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) :
295
-			CachingMetadata::fresh();
294
+			CachingMetadata::ofMaximumAgeInSeconds($ageInSeconds) : CachingMetadata::fresh();
296 295
 
297
-		if ( is_array( $value['results'] ) ) {
298
-			array_walk( $value['results'], [ $this, 'updateCachingMetadata' ], $cachingMetadata );
296
+		if (is_array($value['results'])) {
297
+			array_walk($value['results'], [$this, 'updateCachingMetadata'], $cachingMetadata);
299 298
 		}
300 299
 
301 300
 		return new CachedCheckConstraintsResponse(
302
-			[ $entityId->getSerialization() => $value['results'] ],
301
+			[$entityId->getSerialization() => $value['results']],
303 302
 			array_reduce(
304 303
 				$dependedEntityIds,
305
-				function( Metadata $metadata, EntityId $entityId ) {
306
-					return Metadata::merge( [
304
+				function(Metadata $metadata, EntityId $entityId) {
305
+					return Metadata::merge([
307 306
 						$metadata,
308 307
 						Metadata::ofDependencyMetadata(
309
-							DependencyMetadata::ofEntityId( $entityId )
308
+							DependencyMetadata::ofEntityId($entityId)
310 309
 						)
311
-					] );
310
+					]);
312 311
 				},
313
-				Metadata::ofCachingMetadata( $cachingMetadata )
312
+				Metadata::ofCachingMetadata($cachingMetadata)
314 313
 			)
315 314
 		);
316 315
 	}
@@ -319,39 +318,39 @@  discard block
 block discarded – undo
319 318
 	 * @param EntityId[] $entityIds
320 319
 	 * @return int[]
321 320
 	 */
322
-	private function getLatestRevisionIds( array $entityIds ) {
321
+	private function getLatestRevisionIds(array $entityIds) {
323 322
 		$revisionInformations = $this->wikiPageEntityMetaDataAccessor->loadRevisionInformation(
324 323
 			$entityIds,
325 324
 			EntityRevisionLookup::LATEST_FROM_REPLICA
326 325
 		);
327 326
 		$latestRevisionIds = [];
328
-		foreach ( $revisionInformations as $serialization => $revisionInformation ) {
327
+		foreach ($revisionInformations as $serialization => $revisionInformation) {
329 328
 			$latestRevisionIds[$serialization] = $revisionInformation->page_latest;
330 329
 		}
331 330
 		return $latestRevisionIds;
332 331
 	}
333 332
 
334
-	public function updateCachingMetadata( &$element, $key, CachingMetadata $cachingMetadata ) {
335
-		if ( $key === 'cached' ) {
336
-			$element = CachingMetadata::merge( [
333
+	public function updateCachingMetadata(&$element, $key, CachingMetadata $cachingMetadata) {
334
+		if ($key === 'cached') {
335
+			$element = CachingMetadata::merge([
337 336
 				$cachingMetadata,
338
-				CachingMetadata::ofArray( $element ),
339
-			] )->toArray();
337
+				CachingMetadata::ofArray($element),
338
+			])->toArray();
340 339
 		}
341 340
 		if (
342
-			is_array( $element ) &&
343
-			array_key_exists( 'constraint', $element ) &&
344
-			in_array( $element['constraint']['type'], $this->possiblyStaleConstraintTypes, true )
341
+			is_array($element) &&
342
+			array_key_exists('constraint', $element) &&
343
+			in_array($element['constraint']['type'], $this->possiblyStaleConstraintTypes, true)
345 344
 		) {
346
-			$element['cached'] = CachingMetadata::merge( [
345
+			$element['cached'] = CachingMetadata::merge([
347 346
 				$cachingMetadata,
348 347
 				CachingMetadata::ofArray(
349
-					array_key_exists( 'cached', $element ) ? $element['cached'] : null
348
+					array_key_exists('cached', $element) ? $element['cached'] : null
350 349
 				),
351
-			] )->toArray();
350
+			])->toArray();
352 351
 		}
353
-		if ( is_array( $element ) ) {
354
-			array_walk( $element, [ $this, __FUNCTION__ ], $cachingMetadata );
352
+		if (is_array($element)) {
353
+			array_walk($element, [$this, __FUNCTION__], $cachingMetadata);
355 354
 		}
356 355
 	}
357 356
 
@@ -360,7 +359,7 @@  discard block
 block discarded – undo
360 359
 	 *
361 360
 	 * @param callable $microtime
362 361
 	 */
363
-	public function setMicrotimeFunction( callable $microtime ) {
362
+	public function setMicrotimeFunction(callable $microtime) {
364 363
 		$this->microtime = $microtime;
365 364
 	}
366 365
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +209 added lines, -209 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( wfMessage( $msg )->escaped() );
88
+			throw new ConstraintParameterException(wfMessage($msg)->escaped());
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
-				wfMessage( 'wbqc-violation-message-parameter-single' )
102
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
101
+				wfMessage('wbqc-violation-message-parameter-single')
102
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY))
103 103
 					->escaped()
104 104
 			);
105 105
 		}
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 	 * @return void
113 113
 	 * @throws ConstraintParameterException
114 114
 	 */
115
-	private function requireValueParameter( Snak $snak, $parameterId ) {
116
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
115
+	private function requireValueParameter(Snak $snak, $parameterId) {
116
+		if (!($snak instanceof PropertyValueSnak)) {
117 117
 			throw new ConstraintParameterException(
118
-				wfMessage( 'wbqc-violation-message-parameter-value' )
119
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
118
+				wfMessage('wbqc-violation-message-parameter-value')
119
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY))
120 120
 					->escaped()
121 121
 			);
122 122
 		}
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
 	 * @throws ConstraintParameterException
130 130
 	 * @return EntityId
131 131
 	 */
132
-	private function parseEntityIdParameter( array $snakSerialization, $parameterId ) {
133
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
134
-		$this->requireValueParameter( $snak, $parameterId );
132
+	private function parseEntityIdParameter(array $snakSerialization, $parameterId) {
133
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
134
+		$this->requireValueParameter($snak, $parameterId);
135 135
 		$value = $snak->getDataValue();
136
-		if ( $value instanceof EntityIdValue ) {
136
+		if ($value instanceof EntityIdValue) {
137 137
 			return $value->getEntityId();
138 138
 		} else {
139 139
 			throw new ConstraintParameterException(
140
-				wfMessage( 'wbqc-violation-message-parameter-entity' )
140
+				wfMessage('wbqc-violation-message-parameter-entity')
141 141
 					->rawParams(
142
-						$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
143
-						$this->constraintParameterRenderer->formatDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
142
+						$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
143
+						$this->constraintParameterRenderer->formatDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
144 144
 					)
145 145
 					->escaped()
146 146
 			);
@@ -153,21 +153,21 @@  discard block
 block discarded – undo
153 153
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
154 154
 	 * @return string[] class entity ID serializations
155 155
 	 */
156
-	public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) {
157
-		$this->checkError( $constraintParameters );
158
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
159
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
156
+	public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) {
157
+		$this->checkError($constraintParameters);
158
+		$classId = $this->config->get('WBQualityConstraintsClassId');
159
+		if (!array_key_exists($classId, $constraintParameters)) {
160 160
 			throw new ConstraintParameterException(
161
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
162
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
163
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $classId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
161
+				wfMessage('wbqc-violation-message-parameter-needed')
162
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
163
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($classId, Role::CONSTRAINT_PARAMETER_PROPERTY))
164 164
 					->escaped()
165 165
 			);
166 166
 		}
167 167
 
168 168
 		$classes = [];
169
-		foreach ( $constraintParameters[$classId] as $class ) {
170
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
169
+		foreach ($constraintParameters[$classId] as $class) {
170
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
171 171
 		}
172 172
 		return $classes;
173 173
 	}
@@ -178,24 +178,24 @@  discard block
 block discarded – undo
178 178
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
179 179
 	 * @return string 'instance', 'subclass', or 'instanceOrSubclass'
180 180
 	 */
181
-	public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) {
182
-		$this->checkError( $constraintParameters );
183
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
184
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
181
+	public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) {
182
+		$this->checkError($constraintParameters);
183
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
184
+		if (!array_key_exists($relationId, $constraintParameters)) {
185 185
 			throw new ConstraintParameterException(
186
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
187
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
188
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $relationId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
186
+				wfMessage('wbqc-violation-message-parameter-needed')
187
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
188
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($relationId, Role::CONSTRAINT_PARAMETER_PROPERTY))
189 189
 					->escaped()
190 190
 			);
191 191
 		}
192 192
 
193
-		$this->requireSingleParameter( $constraintParameters, $relationId );
194
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
195
-		$instanceId = $this->config->get( 'WBQualityConstraintsInstanceOfRelationId' );
196
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfRelationId' );
197
-		$instanceOrSubclassId = $this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' );
198
-		switch ( $relationEntityId ) {
193
+		$this->requireSingleParameter($constraintParameters, $relationId);
194
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
195
+		$instanceId = $this->config->get('WBQualityConstraintsInstanceOfRelationId');
196
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfRelationId');
197
+		$instanceOrSubclassId = $this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId');
198
+		switch ($relationEntityId) {
199 199
 			case $instanceId:
200 200
 				return 'instance';
201 201
 			case $subclassId:
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
 				return 'instanceOrSubclass';
205 205
 			default:
206 206
 				throw new ConstraintParameterException(
207
-					wfMessage( 'wbqc-violation-message-parameter-oneof' )
208
-						->rawParams( $this->constraintParameterRenderer->formatPropertyId( $relationId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
209
-						->numParams( 3 )
210
-						->rawParams( $this->constraintParameterRenderer->formatItemIdList(
211
-							[ $instanceId, $subclassId, $instanceOrSubclassId ],
207
+					wfMessage('wbqc-violation-message-parameter-oneof')
208
+						->rawParams($this->constraintParameterRenderer->formatPropertyId($relationId, Role::CONSTRAINT_PARAMETER_PROPERTY))
209
+						->numParams(3)
210
+						->rawParams($this->constraintParameterRenderer->formatItemIdList(
211
+							[$instanceId, $subclassId, $instanceOrSubclassId],
212 212
 							Role::CONSTRAINT_PARAMETER_VALUE
213
-						) )
213
+						))
214 214
 						->escaped()
215 215
 				);
216 216
 		}
@@ -223,21 +223,21 @@  discard block
 block discarded – undo
223 223
 	 * @throws ConstraintParameterException
224 224
 	 * @return PropertyId
225 225
 	 */
226
-	private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) {
227
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
228
-		$this->requireValueParameter( $snak, $parameterId );
226
+	private function parsePropertyIdParameter(array $snakSerialization, $parameterId) {
227
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
228
+		$this->requireValueParameter($snak, $parameterId);
229 229
 		$value = $snak->getDataValue();
230
-		if ( $value instanceof EntityIdValue ) {
230
+		if ($value instanceof EntityIdValue) {
231 231
 			$id = $value->getEntityId();
232
-			if ( $id instanceof PropertyId ) {
232
+			if ($id instanceof PropertyId) {
233 233
 				return $id;
234 234
 			}
235 235
 		}
236 236
 		throw new ConstraintParameterException(
237
-			wfMessage( 'wbqc-violation-message-parameter-property' )
237
+			wfMessage('wbqc-violation-message-parameter-property')
238 238
 				->rawParams(
239
-					$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
240
-					$this->constraintParameterRenderer->formatDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
239
+					$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
240
+					$this->constraintParameterRenderer->formatDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
241 241
 				)
242 242
 				->escaped()
243 243
 		);
@@ -250,34 +250,34 @@  discard block
 block discarded – undo
250 250
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
251 251
 	 * @return PropertyId
252 252
 	 */
253
-	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
254
-		$this->checkError( $constraintParameters );
255
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
256
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
253
+	public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) {
254
+		$this->checkError($constraintParameters);
255
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
256
+		if (!array_key_exists($propertyId, $constraintParameters)) {
257 257
 			throw new ConstraintParameterException(
258
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
259
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
260
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
258
+				wfMessage('wbqc-violation-message-parameter-needed')
259
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
260
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY))
261 261
 					->escaped()
262 262
 			);
263 263
 		}
264 264
 
265
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
266
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
265
+		$this->requireSingleParameter($constraintParameters, $propertyId);
266
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
267 267
 	}
268 268
 
269
-	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
269
+	private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) {
270 270
 		$dataValue = $snak->getDataValue();
271
-		if ( $dataValue instanceof EntityIdValue &&
271
+		if ($dataValue instanceof EntityIdValue &&
272 272
 			$dataValue->getEntityId() instanceof ItemId
273 273
 		) {
274
-			return ItemIdSnakValue::fromItemId( $dataValue->getEntityId() );
274
+			return ItemIdSnakValue::fromItemId($dataValue->getEntityId());
275 275
 		} else {
276 276
 			throw new ConstraintParameterException(
277
-				wfMessage( 'wbqc-violation-message-parameter-item' )
277
+				wfMessage('wbqc-violation-message-parameter-item')
278 278
 					->rawParams(
279
-						$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
280
-						$this->constraintParameterRenderer->formatDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
279
+						$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
280
+						$this->constraintParameterRenderer->formatDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
281 281
 					)
282 282
 					->escaped()
283 283
 			);
@@ -291,15 +291,15 @@  discard block
 block discarded – undo
291 291
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
292 292
 	 * @return ItemIdSnakValue[] array of values
293 293
 	 */
294
-	public function parseItemsParameter( array $constraintParameters, $constraintTypeItemId, $required ) {
295
-		$this->checkError( $constraintParameters );
296
-		$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
297
-		if ( !array_key_exists( $qualifierId, $constraintParameters ) ) {
298
-			if ( $required ) {
294
+	public function parseItemsParameter(array $constraintParameters, $constraintTypeItemId, $required) {
295
+		$this->checkError($constraintParameters);
296
+		$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
297
+		if (!array_key_exists($qualifierId, $constraintParameters)) {
298
+			if ($required) {
299 299
 				throw new ConstraintParameterException(
300
-					wfMessage( 'wbqc-violation-message-parameter-needed' )
301
-						->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
302
-						->rawParams( $this->constraintParameterRenderer->formatPropertyId( $qualifierId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
300
+					wfMessage('wbqc-violation-message-parameter-needed')
301
+						->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
302
+						->rawParams($this->constraintParameterRenderer->formatPropertyId($qualifierId, Role::CONSTRAINT_PARAMETER_PROPERTY))
303 303
 						->escaped()
304 304
 				);
305 305
 			} else {
@@ -308,11 +308,11 @@  discard block
 block discarded – undo
308 308
 		}
309 309
 
310 310
 		$values = [];
311
-		foreach ( $constraintParameters[$qualifierId] as $parameter ) {
312
-			$snak = $this->snakDeserializer->deserialize( $parameter );
313
-			switch ( true ) {
311
+		foreach ($constraintParameters[$qualifierId] as $parameter) {
312
+			$snak = $this->snakDeserializer->deserialize($parameter);
313
+			switch (true) {
314 314
 				case $snak instanceof PropertyValueSnak:
315
-					$values[] = $this->parseItemIdParameter( $snak, $qualifierId );
315
+					$values[] = $this->parseItemIdParameter($snak, $qualifierId);
316 316
 					break;
317 317
 				case $snak instanceof PropertySomeValueSnak:
318 318
 					$values[] = ItemIdSnakValue::someValue();
@@ -331,28 +331,28 @@  discard block
 block discarded – undo
331 331
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
332 332
 	 * @return PropertyId[]
333 333
 	 */
334
-	public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) {
335
-		$this->checkError( $constraintParameters );
336
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
337
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
334
+	public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) {
335
+		$this->checkError($constraintParameters);
336
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
337
+		if (!array_key_exists($propertyId, $constraintParameters)) {
338 338
 			throw new ConstraintParameterException(
339
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
340
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
341
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
339
+				wfMessage('wbqc-violation-message-parameter-needed')
340
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
341
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY))
342 342
 					->escaped()
343 343
 			);
344 344
 		}
345 345
 
346 346
 		$parameters = $constraintParameters[$propertyId];
347
-		if ( count( $parameters ) === 1 &&
348
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
347
+		if (count($parameters) === 1 &&
348
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
349 349
 		) {
350 350
 			return [];
351 351
 		}
352 352
 
353 353
 		$properties = [];
354
-		foreach ( $parameters as $parameter ) {
355
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
354
+		foreach ($parameters as $parameter) {
355
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
356 356
 		}
357 357
 		return $properties;
358 358
 	}
@@ -363,16 +363,16 @@  discard block
 block discarded – undo
363 363
 	 * @throws ConstraintParameterException
364 364
 	 * @return DataValue|null
365 365
 	 */
366
-	private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) {
367
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
368
-		if ( $snak instanceof PropertyValueSnak ) {
366
+	private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) {
367
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
368
+		if ($snak instanceof PropertyValueSnak) {
369 369
 			return $snak->getDataValue();
370
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
370
+		} elseif ($snak instanceof PropertyNoValueSnak) {
371 371
 			return null;
372 372
 		} else {
373 373
 			throw new ConstraintParameterException(
374
-				wfMessage( 'wbqc-violation-message-parameter-value-or-novalue' )
375
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
374
+				wfMessage('wbqc-violation-message-parameter-value-or-novalue')
375
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY))
376 376
 					->escaped()
377 377
 			);
378 378
 		}
@@ -383,13 +383,13 @@  discard block
 block discarded – undo
383 383
 	 * @param string $parameterId
384 384
 	 * @return DataValue|null
385 385
 	 */
386
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) {
386
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) {
387 387
 		try {
388
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
389
-		} catch ( ConstraintParameterException $e ) {
388
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
389
+		} catch (ConstraintParameterException $e) {
390 390
 			// unknown value means “now”
391
-			$timeParser = ( new TimeParserFactory() )->getTimeParser();
392
-			return $timeParser->parse( gmdate( '+Y-m-d\T00:00:00\Z' ) );
391
+			$timeParser = (new TimeParserFactory())->getTimeParser();
392
+			return $timeParser->parse(gmdate('+Y-m-d\T00:00:00\Z'));
393 393
 		}
394 394
 	}
395 395
 
@@ -400,14 +400,14 @@  discard block
 block discarded – undo
400 400
 	 * @param string $unit
401 401
 	 * @return bool
402 402
 	 */
403
-	private function exactlyOneQuantityWithUnit( DataValue $min = null, DataValue $max = null, $unit ) {
404
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
405
-			!( $max instanceof UnboundedQuantityValue )
403
+	private function exactlyOneQuantityWithUnit(DataValue $min = null, DataValue $max = null, $unit) {
404
+		if (!($min instanceof UnboundedQuantityValue) ||
405
+			!($max instanceof UnboundedQuantityValue)
406 406
 		) {
407 407
 			return false;
408 408
 		}
409 409
 
410
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
410
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
411 411
 	}
412 412
 
413 413
 	/**
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
419 419
 	 * @return DataValue[] a pair of two quantity-type data values, either of which may be null to signify an open range
420 420
 	 */
421
-	public function parseRangeParameter( array $constraintParameters, $constraintTypeItemId, $type ) {
422
-		$this->checkError( $constraintParameters );
423
-		switch ( $type ) {
421
+	public function parseRangeParameter(array $constraintParameters, $constraintTypeItemId, $type) {
422
+		$this->checkError($constraintParameters);
423
+		switch ($type) {
424 424
 			case 'quantity':
425 425
 				$configKey = 'Quantity';
426 426
 				break;
@@ -429,46 +429,46 @@  discard block
 block discarded – undo
429 429
 				break;
430 430
 			default:
431 431
 				throw new ConstraintParameterException(
432
-					wfMessage( 'wbqc-violation-message-value-needed-of-types-2' )
432
+					wfMessage('wbqc-violation-message-value-needed-of-types-2')
433 433
 						->rawParams(
434
-							wfMessage( 'datatypes-type-quantity' )->escaped(),
435
-							wfMessage( 'datatypes-type-time' )->escaped()
434
+							wfMessage('datatypes-type-quantity')->escaped(),
435
+							wfMessage('datatypes-type-time')->escaped()
436 436
 						)
437 437
 						->escaped()
438 438
 				);
439 439
 		}
440
-		$minimumId = $this->config->get( 'WBQualityConstraintsMinimum' . $configKey . 'Id' );
441
-		$maximumId = $this->config->get( 'WBQualityConstraintsMaximum' . $configKey . 'Id' );
442
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
443
-			!array_key_exists( $maximumId, $constraintParameters )
440
+		$minimumId = $this->config->get('WBQualityConstraintsMinimum'.$configKey.'Id');
441
+		$maximumId = $this->config->get('WBQualityConstraintsMaximum'.$configKey.'Id');
442
+		if (!array_key_exists($minimumId, $constraintParameters) ||
443
+			!array_key_exists($maximumId, $constraintParameters)
444 444
 		) {
445 445
 			throw new ConstraintParameterException(
446
-				wfMessage( 'wbqc-violation-message-range-parameters-needed' )
446
+				wfMessage('wbqc-violation-message-range-parameters-needed')
447 447
 					->rawParams(
448
-						wfMessage( 'datatypes-type-' . $type )->escaped(),
449
-						$this->constraintParameterRenderer->formatPropertyId( $minimumId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
450
-						$this->constraintParameterRenderer->formatPropertyId( $maximumId, Role::CONSTRAINT_PARAMETER_PROPERTY )
448
+						wfMessage('datatypes-type-'.$type)->escaped(),
449
+						$this->constraintParameterRenderer->formatPropertyId($minimumId, Role::CONSTRAINT_PARAMETER_PROPERTY),
450
+						$this->constraintParameterRenderer->formatPropertyId($maximumId, Role::CONSTRAINT_PARAMETER_PROPERTY)
451 451
 					)
452
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
452
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
453 453
 					->escaped()
454 454
 			);
455 455
 		}
456 456
 
457
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
458
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
457
+		$this->requireSingleParameter($constraintParameters, $minimumId);
458
+		$this->requireSingleParameter($constraintParameters, $maximumId);
459 459
 		$parseFunction = $configKey === 'Date' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
460
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
461
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
460
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
461
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
462 462
 
463
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
464
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
463
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
464
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
465 465
 			throw new ConstraintParameterException(
466
-				wfMessage( 'wbqc-violation-message-range-parameters-one-year' )
466
+				wfMessage('wbqc-violation-message-range-parameters-one-year')
467 467
 					->escaped()
468 468
 			);
469 469
 		}
470 470
 
471
-		return [ $min, $max ];
471
+		return [$min, $max];
472 472
 	}
473 473
 
474 474
 	/**
@@ -478,18 +478,18 @@  discard block
 block discarded – undo
478 478
 	 * @throws ConstraintParameterException
479 479
 	 * @return string
480 480
 	 */
481
-	private function parseStringParameter( array $snakSerialization, $parameterId ) {
482
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
483
-		$this->requireValueParameter( $snak, $parameterId );
481
+	private function parseStringParameter(array $snakSerialization, $parameterId) {
482
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
483
+		$this->requireValueParameter($snak, $parameterId);
484 484
 		$value = $snak->getDataValue();
485
-		if ( $value instanceof StringValue ) {
485
+		if ($value instanceof StringValue) {
486 486
 			return $value->getValue();
487 487
 		} else {
488 488
 			throw new ConstraintParameterException(
489
-				wfMessage( 'wbqc-violation-message-parameter-string' )
489
+				wfMessage('wbqc-violation-message-parameter-string')
490 490
 					->rawParams(
491
-						$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
492
-						$this->constraintParameterRenderer->formatDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
491
+						$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
492
+						$this->constraintParameterRenderer->formatDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
493 493
 					)
494 494
 					->escaped()
495 495
 			);
@@ -502,15 +502,15 @@  discard block
 block discarded – undo
502 502
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
503 503
 	 * @return string
504 504
 	 */
505
-	public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) {
506
-		$this->checkError( $constraintParameters );
507
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
508
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
505
+	public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) {
506
+		$this->checkError($constraintParameters);
507
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
508
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
509 509
 			return '';
510 510
 		}
511 511
 
512
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
513
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
512
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
513
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
514 514
 	}
515 515
 
516 516
 	/**
@@ -519,20 +519,20 @@  discard block
 block discarded – undo
519 519
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
520 520
 	 * @return string
521 521
 	 */
522
-	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
523
-		$this->checkError( $constraintParameters );
524
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
525
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
522
+	public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) {
523
+		$this->checkError($constraintParameters);
524
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
525
+		if (!array_key_exists($formatId, $constraintParameters)) {
526 526
 			throw new ConstraintParameterException(
527
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
528
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
529
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $formatId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
527
+				wfMessage('wbqc-violation-message-parameter-needed')
528
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
529
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($formatId, Role::CONSTRAINT_PARAMETER_PROPERTY))
530 530
 					->escaped()
531 531
 			);
532 532
 		}
533 533
 
534
-		$this->requireSingleParameter( $constraintParameters, $formatId );
535
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
534
+		$this->requireSingleParameter($constraintParameters, $formatId);
535
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
536 536
 	}
537 537
 
538 538
 	/**
@@ -540,16 +540,16 @@  discard block
 block discarded – undo
540 540
 	 * @throws ConstraintParameterException if the parameter is invalid
541 541
 	 * @return EntityId[]
542 542
 	 */
543
-	public function parseExceptionParameter( array $constraintParameters ) {
544
-		$this->checkError( $constraintParameters );
545
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
546
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
543
+	public function parseExceptionParameter(array $constraintParameters) {
544
+		$this->checkError($constraintParameters);
545
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
546
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
547 547
 			return [];
548 548
 		}
549 549
 
550 550
 		return array_map(
551
-			function( $snakSerialization ) use ( $exceptionId ) {
552
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
551
+			function($snakSerialization) use ($exceptionId) {
552
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
553 553
 			},
554 554
 			$constraintParameters[$exceptionId]
555 555
 		);
@@ -560,27 +560,27 @@  discard block
 block discarded – undo
560 560
 	 * @throws ConstraintParameterException if the parameter is invalid
561 561
 	 * @return string|null 'mandatory' or null
562 562
 	 */
563
-	public function parseConstraintStatusParameter( array $constraintParameters ) {
564
-		$this->checkError( $constraintParameters );
565
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
566
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
563
+	public function parseConstraintStatusParameter(array $constraintParameters) {
564
+		$this->checkError($constraintParameters);
565
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
566
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
567 567
 			return null;
568 568
 		}
569 569
 
570
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
571
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
572
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
573
-		$this->requireValueParameter( $snak, $constraintStatusId );
570
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
571
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
572
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
573
+		$this->requireValueParameter($snak, $constraintStatusId);
574 574
 		$statusId = $snak->getDataValue()->getEntityId()->getSerialization();
575 575
 
576
-		if ( $statusId === $mandatoryId ) {
576
+		if ($statusId === $mandatoryId) {
577 577
 			return 'mandatory';
578 578
 		} else {
579 579
 			throw new ConstraintParameterException(
580
-				wfMessage( 'wbqc-violation-message-parameter-oneof' )
581
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $constraintStatusId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
582
-					->numParams( 1 )
583
-					->rawParams( $this->constraintParameterRenderer->formatItemIdList( [ $mandatoryId ], Role::CONSTRAINT_PARAMETER_VALUE ) )
580
+				wfMessage('wbqc-violation-message-parameter-oneof')
581
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($constraintStatusId, Role::CONSTRAINT_PARAMETER_PROPERTY))
582
+					->numParams(1)
583
+					->rawParams($this->constraintParameterRenderer->formatItemIdList([$mandatoryId], Role::CONSTRAINT_PARAMETER_VALUE))
584 584
 					->escaped()
585 585
 			);
586 586
 		}
@@ -593,13 +593,13 @@  discard block
 block discarded – undo
593 593
 	 * @return void
594 594
 	 * @throws ConstraintParameterException
595 595
 	 */
596
-	private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) {
597
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
596
+	private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) {
597
+		if (!($dataValue instanceof MonolingualTextValue)) {
598 598
 			throw new ConstraintParameterException(
599
-				wfMessage( 'wbqc-violation-message-parameter-monolingualtext' )
599
+				wfMessage('wbqc-violation-message-parameter-monolingualtext')
600 600
 					->rawParams(
601
-						$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
602
-						$this->constraintParameterRenderer->formatDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
601
+						$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
602
+						$this->constraintParameterRenderer->formatDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
603 603
 					)
604 604
 					->escaped()
605 605
 			);
@@ -614,26 +614,26 @@  discard block
 block discarded – undo
614 614
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
615 615
 	 * @return string[]
616 616
 	 */
617
-	private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) {
617
+	private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) {
618 618
 		$result = [];
619 619
 
620
-		foreach ( $snakSerializations as $snakSerialization ) {
621
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
622
-			$this->requireValueParameter( $snak, $parameterId );
620
+		foreach ($snakSerializations as $snakSerialization) {
621
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
622
+			$this->requireValueParameter($snak, $parameterId);
623 623
 
624 624
 			$value = $snak->getDataValue();
625
-			$this->requireMonolingualTextParameter( $value, $parameterId );
625
+			$this->requireMonolingualTextParameter($value, $parameterId);
626 626
 			/** @var MonolingualTextValue $value */
627 627
 
628 628
 			$code = $value->getLanguageCode();
629
-			if ( array_key_exists( $code, $result ) ) {
629
+			if (array_key_exists($code, $result)) {
630 630
 				throw new ConstraintParameterException(
631
-					wfMessage( 'wbqc-violation-message-parameter-single-per-language' )
631
+					wfMessage('wbqc-violation-message-parameter-single-per-language')
632 632
 						->rawParams(
633
-							$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY )
633
+							$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY)
634 634
 						)
635 635
 						->plaintextParams(
636
-							Language::fetchLanguageName( $code ),
636
+							Language::fetchLanguageName($code),
637 637
 							$code
638 638
 						)
639 639
 						->escaped()
@@ -652,23 +652,23 @@  discard block
 block discarded – undo
652 652
 	 * @throws ConstraintParameterException if the parameter is invalid
653 653
 	 * @return string|null
654 654
 	 */
655
-	public function parseSyntaxClarificationParameter( array $constraintParameters, Language $language ) {
656
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
655
+	public function parseSyntaxClarificationParameter(array $constraintParameters, Language $language) {
656
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
657 657
 
658
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
658
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
659 659
 			return null;
660 660
 		}
661 661
 
662 662
 		$languageCodes = $language->getFallbackLanguages();
663
-		array_unshift( $languageCodes, $language->getCode() );
663
+		array_unshift($languageCodes, $language->getCode());
664 664
 
665 665
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
666 666
 			$constraintParameters[$syntaxClarificationId],
667 667
 			$syntaxClarificationId
668 668
 		);
669 669
 
670
-		foreach ( $languageCodes as $languageCode ) {
671
-			if ( array_key_exists( $languageCode, $syntaxClarifications ) ) {
670
+		foreach ($languageCodes as $languageCode) {
671
+			if (array_key_exists($languageCode, $syntaxClarifications)) {
672 672
 				return $syntaxClarifications[$languageCode];
673 673
 			}
674 674
 		}
@@ -684,20 +684,20 @@  discard block
 block discarded – undo
684 684
 	 * @throws ConstraintParameterException if the parameter is invalid
685 685
 	 * @return string[]|null Context::TYPE_* constants
686 686
 	 */
687
-	public function parseConstraintScopeParameter( array $constraintParameters, $constraintTypeItemId, array $validScopes = null ) {
688
-		$constraintScopeId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
689
-		$mainSnakId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' );
690
-		$qualifiersId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' );
691
-		$referencesId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' );
687
+	public function parseConstraintScopeParameter(array $constraintParameters, $constraintTypeItemId, array $validScopes = null) {
688
+		$constraintScopeId = $this->config->get('WBQualityConstraintsConstraintScopeId');
689
+		$mainSnakId = $this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId');
690
+		$qualifiersId = $this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId');
691
+		$referencesId = $this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId');
692 692
 
693
-		if ( !array_key_exists( $constraintScopeId, $constraintParameters ) ) {
693
+		if (!array_key_exists($constraintScopeId, $constraintParameters)) {
694 694
 			return null;
695 695
 		}
696 696
 
697 697
 		$contextTypes = [];
698
-		foreach ( $constraintParameters[$constraintScopeId] as $snakSerialization ) {
699
-			$scopeEntityId = $this->parseEntityIdParameter( $snakSerialization, $constraintScopeId );
700
-			switch ( $scopeEntityId->getSerialization() ) {
698
+		foreach ($constraintParameters[$constraintScopeId] as $snakSerialization) {
699
+			$scopeEntityId = $this->parseEntityIdParameter($snakSerialization, $constraintScopeId);
700
+			switch ($scopeEntityId->getSerialization()) {
701 701
 				case $mainSnakId:
702 702
 					$contextTypes[] = Context::TYPE_STATEMENT;
703 703
 					break;
@@ -709,14 +709,14 @@  discard block
 block discarded – undo
709 709
 					break;
710 710
 				default:
711 711
 					throw new ConstraintParameterException(
712
-						wfMessage( 'wbqc-violation-message-parameter-oneof' )
712
+						wfMessage('wbqc-violation-message-parameter-oneof')
713 713
 							->rawParams(
714 714
 								$this->constraintParameterRenderer->formatPropertyId(
715 715
 									$constraintScopeId,
716 716
 									Role::CONSTRAINT_PARAMETER_PROPERTY
717 717
 								)
718 718
 							)
719
-							->numParams( 3 )
719
+							->numParams(3)
720 720
 							->rawParams(
721 721
 								$this->constraintParameterRenderer->formatItemIdList(
722 722
 									[
@@ -732,12 +732,12 @@  discard block
 block discarded – undo
732 732
 			}
733 733
 		}
734 734
 
735
-		if ( $validScopes !== null ) {
736
-			$invalidScopes = array_diff( $contextTypes, $validScopes );
737
-			if ( $invalidScopes !== [] ) {
738
-				$invalidScope = array_pop( $invalidScopes );
735
+		if ($validScopes !== null) {
736
+			$invalidScopes = array_diff($contextTypes, $validScopes);
737
+			if ($invalidScopes !== []) {
738
+				$invalidScope = array_pop($invalidScopes);
739 739
 				throw new ConstraintParameterException(
740
-					wfMessage( 'wbqc-violation-message-invalid-scope' )
740
+					wfMessage('wbqc-violation-message-invalid-scope')
741 741
 						->rawParams(
742 742
 							$this->constraintParameterRenderer->formatConstraintScope(
743 743
 								$invalidScope,
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
 								Role::CONSTRAINT_TYPE_ITEM
749 749
 							)
750 750
 						)
751
-						->numParams( count( $validScopes ) )
751
+						->numParams(count($validScopes))
752 752
 						->rawParams(
753 753
 							$this->constraintParameterRenderer->formatConstraintScopeList(
754 754
 								$validScopes,
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/TypeCheckerHelper.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -87,23 +87,23 @@  discard block
 block discarded – undo
87 87
 	 * @return bool
88 88
 	 * @throws OverflowException if $entitiesChecked exceeds the configured limit
89 89
 	 */
90
-	private function isSubclassOf( EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0 ) {
91
-		$maxEntities = $this->config->get( 'WBQualityConstraintsTypeCheckMaxEntities' );
90
+	private function isSubclassOf(EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0) {
91
+		$maxEntities = $this->config->get('WBQualityConstraintsTypeCheckMaxEntities');
92 92
 		if ( ++$entitiesChecked > $maxEntities ) {
93
-			throw new OverflowException( 'Too many entities to check' );
93
+			throw new OverflowException('Too many entities to check');
94 94
 		}
95 95
 
96
-		$item = $this->entityLookup->getEntity( $comparativeClass );
97
-		if ( !( $item instanceof StatementListProvider ) ) {
96
+		$item = $this->entityLookup->getEntity($comparativeClass);
97
+		if (!($item instanceof StatementListProvider)) {
98 98
 			return false; // lookup failed, probably because item doesn't exist
99 99
 		}
100 100
 
101
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
101
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfId');
102 102
 		/** @var Statement $statement */
103
-		foreach ( $item->getStatements()->getByPropertyId( new PropertyId( $subclassId ) ) as $statement ) {
103
+		foreach ($item->getStatements()->getByPropertyId(new PropertyId($subclassId)) as $statement) {
104 104
 			$mainSnak = $statement->getMainSnak();
105 105
 
106
-			if ( !( $this->hasCorrectType( $mainSnak ) ) ) {
106
+			if (!($this->hasCorrectType($mainSnak))) {
107 107
 				continue;
108 108
 			}
109 109
 			/** @var PropertyValueSnak $mainSnak */
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 			$dataValue = $mainSnak->getDataValue();
113 113
 			$comparativeClass = $dataValue->getEntityId();
114 114
 
115
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
115
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
116 116
 				return true;
117 117
 			}
118 118
 
119
-			if ( $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ) ) {
119
+			if ($this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked)) {
120 120
 				return true;
121 121
 			}
122 122
 		}
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
 	 * @return CachedBool
138 138
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
139 139
 	 */
140
-	public function isSubclassOfWithSparqlFallback( EntityId $comparativeClass, array $classesToCheck ) {
140
+	public function isSubclassOfWithSparqlFallback(EntityId $comparativeClass, array $classesToCheck) {
141 141
 		try {
142 142
 			return new CachedBool(
143
-				$this->isSubclassOf( $comparativeClass, $classesToCheck ),
143
+				$this->isSubclassOf($comparativeClass, $classesToCheck),
144 144
 				Metadata::blank()
145 145
 			);
146
-		} catch ( OverflowException $e ) {
147
-			if ( $this->sparqlHelper !== null ) {
146
+		} catch (OverflowException $e) {
147
+			if ($this->sparqlHelper !== null) {
148 148
 				$this->dataFactory->increment(
149 149
 					'wikibase.quality.constraints.sparql.typeFallback'
150 150
 				);
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 					/* withInstance = */ false
155 155
 				);
156 156
 			} else {
157
-				return new CachedBool( false, Metadata::blank() );
157
+				return new CachedBool(false, Metadata::blank());
158 158
 			}
159 159
 		}
160 160
 	}
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 	 * @return CachedBool
173 173
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
174 174
 	 */
175
-	public function hasClassInRelation( StatementList $statements, array $relationIds, array $classesToCheck ) {
175
+	public function hasClassInRelation(StatementList $statements, array $relationIds, array $classesToCheck) {
176 176
 		$metadatas = [];
177 177
 
178 178
 		/** @var Statement $statement */
179
-		foreach ( $this->getStatementsByPropertyIds( $statements, $relationIds ) as $statement ) {
179
+		foreach ($this->getStatementsByPropertyIds($statements, $relationIds) as $statement) {
180 180
 			$mainSnak = $statement->getMainSnak();
181 181
 
182
-			if ( !$this->hasCorrectType( $mainSnak ) ) {
182
+			if (!$this->hasCorrectType($mainSnak)) {
183 183
 				continue;
184 184
 			}
185 185
 			/** @var PropertyValueSnak $mainSnak */
@@ -188,28 +188,28 @@  discard block
 block discarded – undo
188 188
 			$dataValue = $mainSnak->getDataValue();
189 189
 			$comparativeClass = $dataValue->getEntityId();
190 190
 
191
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
191
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
192 192
 				// discard $metadatas, we know this is fresh
193
-				return new CachedBool( true, Metadata::blank() );
193
+				return new CachedBool(true, Metadata::blank());
194 194
 			}
195 195
 
196
-			$result = $this->isSubclassOfWithSparqlFallback( $comparativeClass, $classesToCheck );
196
+			$result = $this->isSubclassOfWithSparqlFallback($comparativeClass, $classesToCheck);
197 197
 			$metadatas[] = $result->getMetadata();
198
-			if ( $result->getBool() ) {
198
+			if ($result->getBool()) {
199 199
 				return new CachedBool(
200 200
 					true,
201
-					Metadata::merge( $metadatas )
201
+					Metadata::merge($metadatas)
202 202
 				);
203 203
 			}
204 204
 		}
205 205
 
206 206
 		return new CachedBool(
207 207
 			false,
208
-			Metadata::merge( $metadatas )
208
+			Metadata::merge($metadatas)
209 209
 		);
210 210
 	}
211 211
 
212
-	private function hasCorrectType( Snak $mainSnak ) {
212
+	private function hasCorrectType(Snak $mainSnak) {
213 213
 		return $mainSnak instanceof PropertyValueSnak
214 214
 			&& $mainSnak->getDataValue()->getType() === 'wikibase-entityid';
215 215
 	}
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
 		array $propertyIdSerializations
225 225
 	) {
226 226
 		$statementArrays = [];
227
-		foreach ( $propertyIdSerializations as $propertyIdSerialization ) {
228
-			$propertyId = new PropertyId( $propertyIdSerialization );
229
-			$statementArrays[] = $statements->getByPropertyId( $propertyId )->toArray();
227
+		foreach ($propertyIdSerializations as $propertyIdSerialization) {
228
+			$propertyId = new PropertyId($propertyIdSerialization);
229
+			$statementArrays[] = $statements->getByPropertyId($propertyId)->toArray();
230 230
 		}
231 231
 		return new StatementList(
232
-			call_user_func_array( 'array_merge', $statementArrays )
232
+			call_user_func_array('array_merge', $statementArrays)
233 233
 		);
234 234
 	}
235 235
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @return string Localized HTML message
244 244
 	 */
245
-	public function getViolationMessage( PropertyId $propertyId, EntityId $entityId, array $classes, $checker, $relation ) {
245
+	public function getViolationMessage(PropertyId $propertyId, EntityId $entityId, array $classes, $checker, $relation) {
246 246
 		// Possible messages:
247 247
 		// wbqc-violation-message-type-instance
248 248
 		// wbqc-violation-message-type-subclass
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
 		// wbqc-violation-message-valueType-instance
251 251
 		// wbqc-violation-message-valueType-subclass
252 252
 		// wbqc-violation-message-valueType-instanceOrSubclass
253
-		$message = wfMessage( 'wbqc-violation-message-' . $checker . '-' . $relation );
253
+		$message = wfMessage('wbqc-violation-message-'.$checker.'-'.$relation);
254 254
 
255 255
 		$message->rawParams(
256
-			$this->constraintParameterRenderer->formatEntityId( $propertyId, Role::CONSTRAINT_PROPERTY ),
257
-			$this->constraintParameterRenderer->formatEntityId( $entityId, Role::SUBJECT )
256
+			$this->constraintParameterRenderer->formatEntityId($propertyId, Role::CONSTRAINT_PROPERTY),
257
+			$this->constraintParameterRenderer->formatEntityId($entityId, Role::SUBJECT)
258 258
 		);
259
-		$message->numParams( count( $classes ) );
260
-		$message->rawParams( $this->constraintParameterRenderer->formatItemIdList( $classes, Role::OBJECT ) );
259
+		$message->numParams(count($classes));
260
+		$message->rawParams($this->constraintParameterRenderer->formatItemIdList($classes, Role::OBJECT));
261 261
 
262 262
 		return $message->escaped();
263 263
 	}
Please login to merge, or discard this patch.