Completed
Push — master ( 06ffb3...1e5bde )
by
unknown
02:34
created
src/ConstraintCheck/Context/ApiV2Context.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,29 +36,29 @@  discard block
 block discarded – undo
36 36
 		$propertyId,
37 37
 		$statementGuid
38 38
 	) {
39
-		if ( !array_key_exists( $entityId, $container ) ) {
39
+		if (!array_key_exists($entityId, $container)) {
40 40
 			$container[$entityId] = [];
41 41
 		}
42 42
 		$entityContainer = &$container[$entityId];
43 43
 
44
-		if ( !array_key_exists( 'claims', $entityContainer ) ) {
44
+		if (!array_key_exists('claims', $entityContainer)) {
45 45
 			$entityContainer['claims'] = [];
46 46
 		}
47 47
 		$claimsContainer = &$entityContainer['claims'];
48 48
 
49
-		if ( !array_key_exists( $propertyId, $claimsContainer ) ) {
49
+		if (!array_key_exists($propertyId, $claimsContainer)) {
50 50
 			$claimsContainer[$propertyId] = [];
51 51
 		}
52 52
 		$propertyContainer = &$claimsContainer[$propertyId];
53 53
 
54
-		foreach ( $propertyContainer as &$statement ) {
55
-			if ( $statement['id'] === $statementGuid ) {
54
+		foreach ($propertyContainer as &$statement) {
55
+			if ($statement['id'] === $statementGuid) {
56 56
 				$statementArray = &$statement;
57 57
 				break;
58 58
 			}
59 59
 		}
60
-		if ( !isset( $statementArray ) ) {
61
-			$statementArray = [ 'id' => $statementGuid ];
60
+		if (!isset($statementArray)) {
61
+			$statementArray = ['id' => $statementGuid];
62 62
 			$propertyContainer[] = &$statementArray;
63 63
 		}
64 64
 
@@ -73,19 +73,19 @@  discard block
 block discarded – undo
73 73
 	 * @param array[] &$container
74 74
 	 * @return array
75 75
 	 */
76
-	abstract protected function &getMainArray( array &$container );
76
+	abstract protected function &getMainArray(array &$container);
77 77
 
78 78
 	/**
79 79
 	 * @param array|null $result
80 80
 	 * @param array[] &$container
81 81
 	 */
82
-	public function storeCheckResultInArray( array $result = null, array &$container ) {
83
-		$mainArray = &$this->getMainArray( $container );
84
-		if ( !array_key_exists( 'results', $mainArray ) ) {
82
+	public function storeCheckResultInArray(array $result = null, array &$container) {
83
+		$mainArray = &$this->getMainArray($container);
84
+		if (!array_key_exists('results', $mainArray)) {
85 85
 			$mainArray['results'] = [];
86 86
 		}
87 87
 
88
-		if ( $result !== null ) {
88
+		if ($result !== null) {
89 89
 			$mainArray['results'][] = $result;
90 90
 		}
91 91
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/CachingMetadata.php 1 patch
Spacing   +11 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	 * @param int $maxAge The maximum age of the cached value (in seconds).
30 30
 	 * @return self Indication that a value is possibly outdated by up to this many seconds.
31 31
 	 */
32
-	public static function ofMaximumAgeInSeconds( $maxAge ) {
33
-		Assert::parameterType( 'integer', $maxAge, '$maxAge' );
34
-		Assert::parameter( $maxAge > 0, '$maxAge', '$maxage > 0' );
32
+	public static function ofMaximumAgeInSeconds($maxAge) {
33
+		Assert::parameterType('integer', $maxAge, '$maxAge');
34
+		Assert::parameter($maxAge > 0, '$maxAge', '$maxage > 0');
35 35
 		$ret = new self;
36 36
 		$ret->maxAge = $maxAge;
37 37
 		return $ret;
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 	 * @param array|null $array As returned by toArray.
43 43
 	 * @return self
44 44
 	 */
45
-	public static function ofArray( array $array = null ) {
45
+	public static function ofArray(array $array = null) {
46 46
 		$ret = new self;
47
-		if ( $array !== null ) {
47
+		if ($array !== null) {
48 48
 			$ret->maxAge = $array['maximumAgeInSeconds'];
49 49
 		}
50 50
 		return $ret;
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 	 * @param self[] $metadatas
55 55
 	 * @return self
56 56
 	 */
57
-	public static function merge( array $metadatas ) {
58
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
57
+	public static function merge(array $metadatas) {
58
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
59 59
 		$ret = new self;
60
-		foreach ( $metadatas as $metadata ) {
61
-			$ret->maxAge = max( $ret->maxAge, $metadata->maxAge );
60
+		foreach ($metadatas as $metadata) {
61
+			$ret->maxAge = max($ret->maxAge, $metadata->maxAge);
62 62
 		}
63 63
 		return $ret;
64 64
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * For a fresh value, returns 0.
77 77
 	 */
78 78
 	public function getMaximumAgeInSeconds() {
79
-		if ( is_int( $this->maxAge ) ) {
79
+		if (is_int($this->maxAge)) {
80 80
 			return $this->maxAge;
81 81
 		} else {
82 82
 			return 0;
@@ -91,8 +91,7 @@  discard block
 block discarded – undo
91 91
 		return $this->isCached() ?
92 92
 			[
93 93
 				'maximumAgeInSeconds' => $this->maxAge,
94
-			] :
95
-			null;
94
+			] : null;
96 95
 	}
97 96
 
98 97
 }
Please login to merge, or discard this patch.
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/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/SparqlHelper.php 1 patch
Spacing   +130 added lines, -132 removed lines patch added patch discarded remove patch
@@ -91,18 +91,18 @@  discard block
 block discarded – undo
91 91
 		$this->cache = $cache;
92 92
 		$this->dataFactory = $dataFactory;
93 93
 
94
-		$this->entityPrefix = $rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_ENTITY );
94
+		$this->entityPrefix = $rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_ENTITY);
95 95
 		$this->prefixes = <<<EOT
96
-PREFIX wd: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_ENTITY )}>
97
-PREFIX wds: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_STATEMENT )}>
98
-PREFIX wdt: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NSP_DIRECT_CLAIM )}>
99
-PREFIX wdv: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_VALUE )}>
100
-PREFIX p: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NSP_CLAIM )}>
101
-PREFIX ps: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NSP_CLAIM_STATEMENT )}>
102
-PREFIX pq: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NSP_QUALIFIER )}>
103
-PREFIX pqv: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NSP_QUALIFIER_VALUE )}>
104
-PREFIX pr: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NSP_REFERENCE )}>
105
-PREFIX prv: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NSP_REFERENCE_VALUE )}>
96
+PREFIX wd: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_ENTITY)}>
97
+PREFIX wds: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_STATEMENT)}>
98
+PREFIX wdt: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NSP_DIRECT_CLAIM)}>
99
+PREFIX wdv: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_VALUE)}>
100
+PREFIX p: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NSP_CLAIM)}>
101
+PREFIX ps: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NSP_CLAIM_STATEMENT)}>
102
+PREFIX pq: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NSP_QUALIFIER)}>
103
+PREFIX pqv: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NSP_QUALIFIER_VALUE)}>
104
+PREFIX pr: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NSP_REFERENCE)}>
105
+PREFIX prv: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NSP_REFERENCE_VALUE)}>
106 106
 PREFIX wikibase: <http://wikiba.se/ontology#>
107 107
 PREFIX wikibase-beta: <http://wikiba.se/ontology-beta#>
108 108
 EOT;
@@ -117,21 +117,21 @@  discard block
 block discarded – undo
117 117
 	 * @return CachedBool
118 118
 	 * @throws SparqlHelperException if the query times out or some other error occurs
119 119
 	 */
120
-	public function hasType( $id, array $classes, $withInstance ) {
121
-		$instanceOfId = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
122
-		$subclassOfId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
120
+	public function hasType($id, array $classes, $withInstance) {
121
+		$instanceOfId = $this->config->get('WBQualityConstraintsInstanceOfId');
122
+		$subclassOfId = $this->config->get('WBQualityConstraintsSubclassOfId');
123 123
 
124
-		$path = ( $withInstance ? "wdt:$instanceOfId/" : "" ) . "wdt:$subclassOfId*";
124
+		$path = ($withInstance ? "wdt:$instanceOfId/" : "")."wdt:$subclassOfId*";
125 125
 
126 126
 		$metadatas = [];
127 127
 
128
-		foreach ( array_chunk( $classes, 20 ) as $classesChunk ) {
129
-			$classesValues = implode( ' ', array_map(
130
-				function( $class ) {
131
-					return 'wd:' . $class;
128
+		foreach (array_chunk($classes, 20) as $classesChunk) {
129
+			$classesValues = implode(' ', array_map(
130
+				function($class) {
131
+					return 'wd:'.$class;
132 132
 				},
133 133
 				$classesChunk
134
-			) );
134
+			));
135 135
 
136 136
 			$query = <<<EOF
137 137
 ASK {
@@ -142,19 +142,19 @@  discard block
 block discarded – undo
142 142
 EOF;
143 143
 			// TODO hint:gearing is a workaround for T168973 and can hopefully be removed eventually
144 144
 
145
-			$result = $this->runQuery( $query );
145
+			$result = $this->runQuery($query);
146 146
 			$metadatas[] = $result->getMetadata();
147
-			if ( $result->getArray()['boolean'] ) {
147
+			if ($result->getArray()['boolean']) {
148 148
 				return new CachedBool(
149 149
 					true,
150
-					Metadata::merge( $metadatas )
150
+					Metadata::merge($metadatas)
151 151
 				);
152 152
 			}
153 153
 		}
154 154
 
155 155
 		return new CachedBool(
156 156
 			false,
157
-			Metadata::merge( $metadatas )
157
+			Metadata::merge($metadatas)
158 158
 		);
159 159
 	}
160 160
 
@@ -170,10 +170,10 @@  discard block
 block discarded – undo
170 170
 		$ignoreDeprecatedStatements
171 171
 	) {
172 172
 		$pid = $statement->getPropertyId()->serialize();
173
-		$guid = str_replace( '$', '-', $statement->getGuid() );
173
+		$guid = str_replace('$', '-', $statement->getGuid());
174 174
 
175 175
 		$deprecatedFilter = '';
176
-		if ( $ignoreDeprecatedStatements ) {
176
+		if ($ignoreDeprecatedStatements) {
177 177
 			$deprecatedFilter .= 'MINUS { ?otherStatement wikibase:rank wikibase:DeprecatedRank. }';
178 178
 			$deprecatedFilter .= 'MINUS { ?otherStatement wikibase-beta:rank wikibase-beta:DeprecatedRank. }';
179 179
 		}
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 LIMIT 10
194 194
 EOF;
195 195
 
196
-		$result = $this->runQuery( $query );
196
+		$result = $this->runQuery($query);
197 197
 
198
-		return $this->getOtherEntities( $result );
198
+		return $this->getOtherEntities($result);
199 199
 	}
200 200
 
201 201
 	/**
@@ -220,16 +220,15 @@  discard block
 block discarded – undo
220 220
 		$dataType = $this->propertyDataTypeLookup->getDataTypeIdForProperty(
221 221
 			$snak->getPropertyId()
222 222
 		);
223
-		list( $value, $isFullValue ) = $this->getRdfLiteral( $dataType, $dataValue );
224
-		if ( $isFullValue ) {
223
+		list($value, $isFullValue) = $this->getRdfLiteral($dataType, $dataValue);
224
+		if ($isFullValue) {
225 225
 			$prefix .= 'v';
226 226
 		}
227 227
 		$path = $type === Context::TYPE_QUALIFIER ?
228
-			"$prefix:$pid" :
229
-			"prov:wasDerivedFrom/$prefix:$pid";
228
+			"$prefix:$pid" : "prov:wasDerivedFrom/$prefix:$pid";
230 229
 
231 230
 		$deprecatedFilter = '';
232
-		if ( $ignoreDeprecatedStatements ) {
231
+		if ($ignoreDeprecatedStatements) {
233 232
 			$deprecatedFilter = <<< EOF
234 233
   MINUS { ?otherStatement wikibase:rank wikibase:DeprecatedRank. }
235 234
   MINUS { ?otherStatement wikibase-beta:rank wikibase-beta:DeprecatedRank. }
@@ -250,9 +249,9 @@  discard block
 block discarded – undo
250 249
 LIMIT 10
251 250
 EOF;
252 251
 
253
-		$result = $this->runQuery( $query );
252
+		$result = $this->runQuery($query);
254 253
 
255
-		return $this->getOtherEntities( $result );
254
+		return $this->getOtherEntities($result);
256 255
 	}
257 256
 
258 257
 	/**
@@ -262,8 +261,8 @@  discard block
 block discarded – undo
262 261
 	 *
263 262
 	 * @return string
264 263
 	 */
265
-	private function stringLiteral( $text ) {
266
-		return '"' . strtr( $text, [ '"' => '\\"', '\\' => '\\\\' ] ) . '"';
264
+	private function stringLiteral($text) {
265
+		return '"'.strtr($text, ['"' => '\\"', '\\' => '\\\\']).'"';
267 266
 	}
268 267
 
269 268
 	/**
@@ -273,17 +272,17 @@  discard block
 block discarded – undo
273 272
 	 *
274 273
 	 * @return CachedEntityIds
275 274
 	 */
276
-	private function getOtherEntities( CachedQueryResults $results ) {
277
-		return new CachedEntityIds( array_map(
278
-			function ( $resultBindings ) {
275
+	private function getOtherEntities(CachedQueryResults $results) {
276
+		return new CachedEntityIds(array_map(
277
+			function($resultBindings) {
279 278
 				$entityIRI = $resultBindings['otherEntity']['value'];
280
-				$entityPrefixLength = strlen( $this->entityPrefix );
281
-				if ( substr( $entityIRI, 0, $entityPrefixLength ) === $this->entityPrefix ) {
279
+				$entityPrefixLength = strlen($this->entityPrefix);
280
+				if (substr($entityIRI, 0, $entityPrefixLength) === $this->entityPrefix) {
282 281
 					try {
283 282
 						return $this->entityIdParser->parse(
284
-							substr( $entityIRI, $entityPrefixLength )
283
+							substr($entityIRI, $entityPrefixLength)
285 284
 						);
286
-					} catch ( EntityIdParsingException $e ) {
285
+					} catch (EntityIdParsingException $e) {
287 286
 						// fall through
288 287
 					}
289 288
 				}
@@ -291,7 +290,7 @@  discard block
 block discarded – undo
291 290
 				return null;
292 291
 			},
293 292
 			$results->getArray()['results']['bindings']
294
-		), $results->getMetadata() );
293
+		), $results->getMetadata());
295 294
 	}
296 295
 
297 296
 	// @codingStandardsIgnoreStart cyclomatic complexity of this function is too high
@@ -304,47 +303,47 @@  discard block
 block discarded – undo
304 303
 	 * @return array the literal or IRI as a string in SPARQL syntax,
305 304
 	 * and a boolean indicating whether it refers to a full value node or not
306 305
 	 */
307
-	private function getRdfLiteral( $dataType, DataValue $dataValue ) {
308
-		switch ( $dataType ) {
306
+	private function getRdfLiteral($dataType, DataValue $dataValue) {
307
+		switch ($dataType) {
309 308
 			case 'string':
310 309
 			case 'external-id':
311
-				return [ $this->stringLiteral( $dataValue->getValue() ), false ];
310
+				return [$this->stringLiteral($dataValue->getValue()), false];
312 311
 			case 'commonsMedia':
313
-				$url = $this->rdfVocabulary->getMediaFileURI( $dataValue->getValue() );
314
-				return [ '<' . $url . '>', false ];
312
+				$url = $this->rdfVocabulary->getMediaFileURI($dataValue->getValue());
313
+				return ['<'.$url.'>', false];
315 314
 			case 'geo-shape':
316
-				$url = $this->rdfVocabulary->getGeoShapeURI( $dataValue->getValue() );
317
-				return [ '<' . $url . '>', false ];
315
+				$url = $this->rdfVocabulary->getGeoShapeURI($dataValue->getValue());
316
+				return ['<'.$url.'>', false];
318 317
 			case 'tabular-data':
319
-				$url = $this->rdfVocabulary->getTabularDataURI( $dataValue->getValue() );
320
-				return [ '<' . $url . '>', false ];
318
+				$url = $this->rdfVocabulary->getTabularDataURI($dataValue->getValue());
319
+				return ['<'.$url.'>', false];
321 320
 			case 'url':
322 321
 				$url = $dataValue->getValue();
323
-				if ( !preg_match( '/^[^<>"{}\\\\|^`\\x00-\\x20]*$/D', $url ) ) {
322
+				if (!preg_match('/^[^<>"{}\\\\|^`\\x00-\\x20]*$/D', $url)) {
324 323
 					// not a valid URL for SPARQL (see SPARQL spec, production 139 IRIREF)
325 324
 					// such an URL should never reach us, so just throw
326
-					throw new InvalidArgumentException( 'invalid URL: ' . $url );
325
+					throw new InvalidArgumentException('invalid URL: '.$url);
327 326
 				}
328
-				return [ '<' . $url . '>', false ];
327
+				return ['<'.$url.'>', false];
329 328
 			case 'wikibase-item':
330 329
 			case 'wikibase-property':
331 330
 				/** @var EntityIdValue $dataValue */
332
-				return [ 'wd:' . $dataValue->getEntityId()->getSerialization(), false ];
331
+				return ['wd:'.$dataValue->getEntityId()->getSerialization(), false];
333 332
 			case 'monolingualtext':
334 333
 				/** @var MonolingualTextValue $dataValue */
335 334
 				$lang = $dataValue->getLanguageCode();
336
-				if ( !preg_match( '/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/D', $lang ) ) {
335
+				if (!preg_match('/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/D', $lang)) {
337 336
 					// not a valid language tag for SPARQL (see SPARQL spec, production 145 LANGTAG)
338 337
 					// such a language tag should never reach us, so just throw
339
-					throw new InvalidArgumentException( 'invalid language tag: ' . $lang );
338
+					throw new InvalidArgumentException('invalid language tag: '.$lang);
340 339
 				}
341
-				return [ $this->stringLiteral( $dataValue->getText() ) . '@' . $lang, false ];
340
+				return [$this->stringLiteral($dataValue->getText()).'@'.$lang, false];
342 341
 			case 'globe-coordinate':
343 342
 			case 'quantity':
344 343
 			case 'time':
345
-				return [ 'wdv:' . $dataValue->getHash(), true ];
344
+				return ['wdv:'.$dataValue->getHash(), true];
346 345
 			default:
347
-				throw new InvalidArgumentException( 'unknown data type: ' . $dataType );
346
+				throw new InvalidArgumentException('unknown data type: '.$dataType);
348 347
 		}
349 348
 	}
350 349
 	// @codingStandardsIgnoreEnd
@@ -357,47 +356,47 @@  discard block
 block discarded – undo
357 356
 	 * @throws SparqlHelperException if the query times out or some other error occurs
358 357
 	 * @throws ConstraintParameterException if the $regex is invalid
359 358
 	 */
360
-	public function matchesRegularExpression( $text, $regex ) {
359
+	public function matchesRegularExpression($text, $regex) {
361 360
 		// caching wrapper around matchesRegularExpressionWithSparql
362 361
 
363
-		$textHash = hash( 'sha256', $text );
362
+		$textHash = hash('sha256', $text);
364 363
 		$cacheKey = $this->cache->makeKey(
365 364
 			'WikibaseQualityConstraints', // extension
366 365
 			'regex', // action
367 366
 			'WDQS-Java', // regex flavor
368
-			hash( 'sha256', $regex )
367
+			hash('sha256', $regex)
369 368
 		);
370
-		$cacheMapSize = $this->config->get( 'WBQualityConstraintsFormatCacheMapSize' );
369
+		$cacheMapSize = $this->config->get('WBQualityConstraintsFormatCacheMapSize');
371 370
 
372 371
 		$cacheMapArray = $this->cache->getWithSetCallback(
373 372
 			$cacheKey,
374 373
 			WANObjectCache::TTL_DAY,
375
-			function( $cacheMapArray ) use ( $text, $regex, $textHash, $cacheMapSize ) {
374
+			function($cacheMapArray) use ($text, $regex, $textHash, $cacheMapSize) {
376 375
 				// Initialize the cache map if not set
377
-				if ( $cacheMapArray === false ) {
376
+				if ($cacheMapArray === false) {
378 377
 					$key = 'wikibase.quality.constraints.regex.cache.refresh.init';
379
-					$this->dataFactory->increment( $key );
378
+					$this->dataFactory->increment($key);
380 379
 					return [];
381 380
 				}
382 381
 
383 382
 				$key = 'wikibase.quality.constraints.regex.cache.refresh';
384
-				$this->dataFactory->increment( $key );
385
-				$cacheMap = MapCacheLRU::newFromArray( $cacheMapArray, $cacheMapSize );
386
-				if ( $cacheMap->has( $textHash ) ) {
383
+				$this->dataFactory->increment($key);
384
+				$cacheMap = MapCacheLRU::newFromArray($cacheMapArray, $cacheMapSize);
385
+				if ($cacheMap->has($textHash)) {
387 386
 					$key = 'wikibase.quality.constraints.regex.cache.refresh.hit';
388
-					$this->dataFactory->increment( $key );
389
-					$cacheMap->get( $textHash ); // ping cache
387
+					$this->dataFactory->increment($key);
388
+					$cacheMap->get($textHash); // ping cache
390 389
 				} else {
391 390
 					$key = 'wikibase.quality.constraints.regex.cache.refresh.miss';
392
-					$this->dataFactory->increment( $key );
391
+					$this->dataFactory->increment($key);
393 392
 					try {
394
-						$matches = $this->matchesRegularExpressionWithSparql( $text, $regex );
395
-					} catch ( ConstraintParameterException $e ) {
393
+						$matches = $this->matchesRegularExpressionWithSparql($text, $regex);
394
+					} catch (ConstraintParameterException $e) {
396 395
 						$matches = [
397 396
 							'type' => ConstraintParameterException::class,
398 397
 							'message' => $e->getMessage(),
399 398
 						];
400
-					} catch ( SparqlHelperException $e ) {
399
+					} catch (SparqlHelperException $e) {
401 400
 						// don’t cache this
402 401
 						return $cacheMap->toArray();
403 402
 					}
@@ -421,27 +420,27 @@  discard block
 block discarded – undo
421 420
 			]
422 421
 		);
423 422
 
424
-		if ( isset( $cacheMapArray[$textHash] ) ) {
423
+		if (isset($cacheMapArray[$textHash])) {
425 424
 			$key = 'wikibase.quality.constraints.regex.cache.hit';
426
-			$this->dataFactory->increment( $key );
425
+			$this->dataFactory->increment($key);
427 426
 			$matches = $cacheMapArray[$textHash];
428
-			if ( is_bool( $matches ) ) {
427
+			if (is_bool($matches)) {
429 428
 				return $matches;
430
-			} elseif ( is_array( $matches ) &&
431
-				$matches['type'] == ConstraintParameterException::class ) {
432
-				throw new ConstraintParameterException( $matches['message'] );
429
+			} elseif (is_array($matches) &&
430
+				$matches['type'] == ConstraintParameterException::class) {
431
+				throw new ConstraintParameterException($matches['message']);
433 432
 			} else {
434 433
 				throw new MWException(
435
-					'Value of unknown type in object cache (' .
436
-					'cache key: ' . $cacheKey . ', ' .
437
-					'cache map key: ' . $textHash . ', ' .
438
-					'value type: ' . gettype( $matches ) . ')'
434
+					'Value of unknown type in object cache ('.
435
+					'cache key: '.$cacheKey.', '.
436
+					'cache map key: '.$textHash.', '.
437
+					'value type: '.gettype($matches).')'
439 438
 				);
440 439
 			}
441 440
 		} else {
442 441
 			$key = 'wikibase.quality.constraints.regex.cache.miss';
443
-			$this->dataFactory->increment( $key );
444
-			return $this->matchesRegularExpressionWithSparql( $text, $regex );
442
+			$this->dataFactory->increment($key);
443
+			return $this->matchesRegularExpressionWithSparql($text, $regex);
445 444
 		}
446 445
 	}
447 446
 
@@ -456,26 +455,26 @@  discard block
 block discarded – undo
456 455
 	 * @throws SparqlHelperException if the query times out or some other error occurs
457 456
 	 * @throws ConstraintParameterException if the $regex is invalid
458 457
 	 */
459
-	public function matchesRegularExpressionWithSparql( $text, $regex ) {
460
-		$textStringLiteral = $this->stringLiteral( $text );
461
-		$regexStringLiteral = $this->stringLiteral( '^' . $regex . '$' );
458
+	public function matchesRegularExpressionWithSparql($text, $regex) {
459
+		$textStringLiteral = $this->stringLiteral($text);
460
+		$regexStringLiteral = $this->stringLiteral('^'.$regex.'$');
462 461
 
463 462
 		$query = <<<EOF
464 463
 SELECT (REGEX($textStringLiteral, $regexStringLiteral) AS ?matches) {}
465 464
 EOF;
466 465
 
467
-		$result = $this->runQuery( $query );
466
+		$result = $this->runQuery($query);
468 467
 
469 468
 		$vars = $result->getArray()['results']['bindings'][0];
470
-		if ( array_key_exists( 'matches', $vars ) ) {
469
+		if (array_key_exists('matches', $vars)) {
471 470
 			// true or false ⇒ regex okay, text matches or not
472 471
 			return $vars['matches']['value'] === 'true';
473 472
 		} else {
474 473
 			// empty result: regex broken
475 474
 			throw new ConstraintParameterException(
476
-				wfMessage( 'wbqc-violation-message-parameter-regex' )
477
-					->rawParams( ConstraintParameterRenderer::formatByRole( Role::CONSTRAINT_PARAMETER_VALUE,
478
-						'<code><nowiki>' . htmlspecialchars( $regex ) . '</nowiki></code>' ) )
475
+				wfMessage('wbqc-violation-message-parameter-regex')
476
+					->rawParams(ConstraintParameterRenderer::formatByRole(Role::CONSTRAINT_PARAMETER_VALUE,
477
+						'<code><nowiki>'.htmlspecialchars($regex).'</nowiki></code>'))
479 478
 					->escaped()
480 479
 			);
481 480
 		}
@@ -488,14 +487,14 @@  discard block
 block discarded – undo
488 487
 	 *
489 488
 	 * @return boolean
490 489
 	 */
491
-	public function isTimeout( $responseContent ) {
492
-		$timeoutRegex = implode( '|', array_map(
493
-			function ( $fqn ) {
494
-				return preg_quote( $fqn, '/' );
490
+	public function isTimeout($responseContent) {
491
+		$timeoutRegex = implode('|', array_map(
492
+			function($fqn) {
493
+				return preg_quote($fqn, '/');
495 494
 			},
496
-			$this->config->get( 'WBQualityConstraintsSparqlTimeoutExceptionClasses' )
497
-		) );
498
-		return (bool)preg_match( '/' . $timeoutRegex . '/', $responseContent );
495
+			$this->config->get('WBQualityConstraintsSparqlTimeoutExceptionClasses')
496
+		));
497
+		return (bool) preg_match('/'.$timeoutRegex.'/', $responseContent);
499 498
 	}
500 499
 
501 500
 	/**
@@ -507,17 +506,17 @@  discard block
 block discarded – undo
507 506
 	 * @return integer|boolean the max-age (in seconds)
508 507
 	 * or a plain boolean if no max-age can be determined
509 508
 	 */
510
-	public function getCacheMaxAge( $responseHeaders ) {
509
+	public function getCacheMaxAge($responseHeaders) {
511 510
 		if (
512
-			array_key_exists( 'x-cache-status', $responseHeaders ) &&
513
-			preg_match( '/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0] )
511
+			array_key_exists('x-cache-status', $responseHeaders) &&
512
+			preg_match('/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0])
514 513
 		) {
515 514
 			$maxage = [];
516 515
 			if (
517
-				array_key_exists( 'cache-control', $responseHeaders ) &&
518
-				preg_match( '/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage )
516
+				array_key_exists('cache-control', $responseHeaders) &&
517
+				preg_match('/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage)
519 518
 			) {
520
-				return intval( $maxage[1] );
519
+				return intval($maxage[1]);
521 520
 			} else {
522 521
 				return true;
523 522
 			}
@@ -535,59 +534,58 @@  discard block
 block discarded – undo
535 534
 	 *
536 535
 	 * @throws SparqlHelperException if the query times out or some other error occurs
537 536
 	 */
538
-	public function runQuery( $query ) {
537
+	public function runQuery($query) {
539 538
 
540
-		$endpoint = $this->config->get( 'WBQualityConstraintsSparqlEndpoint' );
541
-		$maxQueryTimeMillis = $this->config->get( 'WBQualityConstraintsSparqlMaxMillis' );
542
-		$url = $endpoint . '?' . http_build_query(
539
+		$endpoint = $this->config->get('WBQualityConstraintsSparqlEndpoint');
540
+		$maxQueryTimeMillis = $this->config->get('WBQualityConstraintsSparqlMaxMillis');
541
+		$url = $endpoint.'?'.http_build_query(
543 542
 			[
544
-				'query' => "#wbqc\n" . $this->prefixes . $query,
543
+				'query' => "#wbqc\n".$this->prefixes.$query,
545 544
 				'format' => 'json',
546 545
 				'maxQueryTimeMillis' => $maxQueryTimeMillis,
547 546
 			],
548
-			null, ini_get( 'arg_separator.output' ),
547
+			null, ini_get('arg_separator.output'),
549 548
 			// encode spaces with %20, not +
550 549
 			PHP_QUERY_RFC3986
551 550
 		);
552 551
 
553 552
 		$options = [
554 553
 			'method' => 'GET',
555
-			'timeout' => (int)round( ( $maxQueryTimeMillis + 1000 ) / 1000 ),
554
+			'timeout' => (int) round(($maxQueryTimeMillis + 1000) / 1000),
556 555
 			'connectTimeout' => 'default',
557 556
 		];
558
-		$request = MWHttpRequest::factory( $url, $options );
559
-		$startTime = microtime( true );
557
+		$request = MWHttpRequest::factory($url, $options);
558
+		$startTime = microtime(true);
560 559
 		$status = $request->execute();
561
-		$endTime = microtime( true );
560
+		$endTime = microtime(true);
562 561
 		$this->dataFactory->timing(
563 562
 			'wikibase.quality.constraints.sparql.timing',
564
-			( $endTime - $startTime ) * 1000
563
+			($endTime - $startTime) * 1000
565 564
 		);
566 565
 
567
-		$maxAge = $this->getCacheMaxAge( $request->getResponseHeaders() );
568
-		if ( $maxAge ) {
569
-			$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.cached' );
566
+		$maxAge = $this->getCacheMaxAge($request->getResponseHeaders());
567
+		if ($maxAge) {
568
+			$this->dataFactory->increment('wikibase.quality.constraints.sparql.cached');
570 569
 		}
571 570
 
572
-		if ( $status->isOK() ) {
571
+		if ($status->isOK()) {
573 572
 			$json = $request->getContent();
574
-			$arr = json_decode( $json, true );
573
+			$arr = json_decode($json, true);
575 574
 			return new CachedQueryResults(
576 575
 				$arr,
577 576
 				Metadata::ofCachingMetadata(
578 577
 					$maxAge ?
579
-						CachingMetadata::ofMaximumAgeInSeconds( $maxAge ) :
580
-						CachingMetadata::fresh()
578
+						CachingMetadata::ofMaximumAgeInSeconds($maxAge) : CachingMetadata::fresh()
581 579
 				)
582 580
 			);
583 581
 		} else {
584
-			$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.error' );
582
+			$this->dataFactory->increment('wikibase.quality.constraints.sparql.error');
585 583
 
586 584
 			$this->dataFactory->increment(
587 585
 				"wikibase.quality.constraints.sparql.error.http.{$request->getStatus()}"
588 586
 			);
589 587
 
590
-			if ( $this->isTimeout( $request->getContent() ) ) {
588
+			if ($this->isTimeout($request->getContent())) {
591 589
 				$this->dataFactory->increment(
592 590
 					'wikibase.quality.constraints.sparql.error.timeout'
593 591
 				);
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/AbstractContext.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@
 block discarded – undo
23 23
 	 */
24 24
 	protected $snak;
25 25
 
26
-	public function __construct( EntityDocument $entity, Snak $snak ) {
26
+	public function __construct(EntityDocument $entity, Snak $snak) {
27 27
 		$this->entity = $entity;
28 28
 		$this->snak = $snak;
29 29
 	}
Please login to merge, or discard this patch.