Completed
Push — master ( 6b7ae2...4e3989 )
by
unknown
33s
created
src/ConstraintCheck/Context/EntityContextCursor.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context;
6 6
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @codeCoverageIgnore This method is not supported.
33 33
 	 */
34 34
 	public function getType(): string {
35
-		throw new LogicException( 'EntityContextCursor has no full associated context' );
35
+		throw new LogicException('EntityContextCursor has no full associated context');
36 36
 	}
37 37
 
38 38
 	public function getEntityId(): string {
@@ -43,35 +43,35 @@  discard block
 block discarded – undo
43 43
 	 * @codeCoverageIgnore This method is not supported.
44 44
 	 */
45 45
 	public function getStatementPropertyId(): string {
46
-		throw new LogicException( 'EntityContextCursor has no full associated context' );
46
+		throw new LogicException('EntityContextCursor has no full associated context');
47 47
 	}
48 48
 
49 49
 	/**
50 50
 	 * @codeCoverageIgnore This method is not supported.
51 51
 	 */
52 52
 	public function getStatementGuid(): string {
53
-		throw new LogicException( 'EntityContextCursor has no full associated context' );
53
+		throw new LogicException('EntityContextCursor has no full associated context');
54 54
 	}
55 55
 
56 56
 	/**
57 57
 	 * @codeCoverageIgnore This method is not supported.
58 58
 	 */
59 59
 	public function getSnakPropertyId(): string {
60
-		throw new LogicException( 'EntityContextCursor has no full associated context' );
60
+		throw new LogicException('EntityContextCursor has no full associated context');
61 61
 	}
62 62
 
63 63
 	/**
64 64
 	 * @codeCoverageIgnore This method is not supported.
65 65
 	 */
66 66
 	public function getSnakHash(): string {
67
-		throw new LogicException( 'EntityContextCursor has no full associated context' );
67
+		throw new LogicException('EntityContextCursor has no full associated context');
68 68
 	}
69 69
 
70 70
 	/**
71 71
 	 * @codeCoverageIgnore This method is not supported.
72 72
 	 */
73
-	public function &getMainArray( array &$container ): array {
74
-		throw new LogicException( 'EntityContextCursor cannot store check results' );
73
+	public function &getMainArray(array &$container): array {
74
+		throw new LogicException('EntityContextCursor cannot store check results');
75 75
 	}
76 76
 
77 77
 	/**
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	 * @param ?array $result must be null
81 81
 	 * @param array[] &$container
82 82
 	 */
83
-	public function storeCheckResultInArray( ?array $result, array &$container ): void {
84
-		if ( $result !== null ) {
85
-			throw new LogicException( 'EntityContextCursor cannot store check results' );
83
+	public function storeCheckResultInArray(?array $result, array &$container): void {
84
+		if ($result !== null) {
85
+			throw new LogicException('EntityContextCursor cannot store check results');
86 86
 		}
87 87
 
88 88
 		// this ensures that the claims array is present in the $container,
89 89
 		// populating it if necessary, even though we ignore the return value
90
-		$this->getClaimsArray( $container );
90
+		$this->getClaimsArray($container);
91 91
 	}
92 92
 
93 93
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ApiV2ContextCursor.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context;
6 6
 
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
 	 * @param array[] &$container
30 30
 	 * @return array
31 31
 	 */
32
-	protected function &getClaimsArray( array &$container ): array {
32
+	protected function &getClaimsArray(array &$container): array {
33 33
 		$entityId = $this->getEntityId();
34 34
 
35
-		if ( !array_key_exists( $entityId, $container ) ) {
35
+		if (!array_key_exists($entityId, $container)) {
36 36
 			$container[$entityId] = [];
37 37
 		}
38 38
 		$entityContainer = &$container[$entityId];
39 39
 
40
-		if ( !array_key_exists( 'claims', $entityContainer ) ) {
40
+		if (!array_key_exists('claims', $entityContainer)) {
41 41
 			$entityContainer['claims'] = [];
42 42
 		}
43 43
 		$claimsArray = &$entityContainer['claims'];
@@ -51,25 +51,25 @@  discard block
 block discarded – undo
51 51
 	 * @param array[] &$container
52 52
 	 * @return array
53 53
 	 */
54
-	protected function &getStatementArray( array &$container ): array {
54
+	protected function &getStatementArray(array &$container): array {
55 55
 		$statementPropertyId = $this->getStatementPropertyId();
56 56
 		$statementGuid = $this->getStatementGuid();
57 57
 
58
-		$claimsContainer = &$this->getClaimsArray( $container );
58
+		$claimsContainer = &$this->getClaimsArray($container);
59 59
 
60
-		if ( !array_key_exists( $statementPropertyId, $claimsContainer ) ) {
60
+		if (!array_key_exists($statementPropertyId, $claimsContainer)) {
61 61
 			$claimsContainer[$statementPropertyId] = [];
62 62
 		}
63 63
 		$propertyContainer = &$claimsContainer[$statementPropertyId];
64 64
 
65
-		foreach ( $propertyContainer as &$statement ) {
66
-			if ( $statement['id'] === $statementGuid ) {
65
+		foreach ($propertyContainer as &$statement) {
66
+			if ($statement['id'] === $statementGuid) {
67 67
 				$statementArray = &$statement;
68 68
 				break;
69 69
 			}
70 70
 		}
71
-		if ( !isset( $statementArray ) ) {
72
-			$statementArray = [ 'id' => $statementGuid ];
71
+		if (!isset($statementArray)) {
72
+			$statementArray = ['id' => $statementGuid];
73 73
 			$propertyContainer[] = &$statementArray;
74 74
 		}
75 75
 
@@ -84,19 +84,19 @@  discard block
 block discarded – undo
84 84
 	 * @param array[] &$container
85 85
 	 * @return array
86 86
 	 */
87
-	abstract protected function &getMainArray( array &$container ): array;
87
+	abstract protected function &getMainArray(array &$container): array;
88 88
 
89 89
 	/**
90 90
 	 * @param ?array $result
91 91
 	 * @param array[] &$container
92 92
 	 */
93
-	public function storeCheckResultInArray( ?array $result, array &$container ): void {
94
-		$mainArray = &$this->getMainArray( $container );
95
-		if ( !array_key_exists( 'results', $mainArray ) ) {
93
+	public function storeCheckResultInArray(?array $result, array &$container): void {
94
+		$mainArray = &$this->getMainArray($container);
95
+		if (!array_key_exists('results', $mainArray)) {
96 96
 			$mainArray['results'] = [];
97 97
 		}
98 98
 
99
-		if ( $result !== null ) {
99
+		if ($result !== null) {
100 100
 			$mainArray['results'][] = $result;
101 101
 		}
102 102
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/MainSnakContextCursor.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context;
6 6
 
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
 		return $this->snakHash;
57 57
 	}
58 58
 
59
-	protected function &getMainArray( array &$container ): array {
60
-		$statementArray = &$this->getStatementArray( $container );
59
+	protected function &getMainArray(array &$container): array {
60
+		$statementArray = &$this->getStatementArray($container);
61 61
 
62
-		if ( !array_key_exists( 'mainsnak', $statementArray ) ) {
62
+		if (!array_key_exists('mainsnak', $statementArray)) {
63 63
 			$snakHash = $this->getSnakHash();
64
-			$statementArray['mainsnak'] = [ 'hash' => $snakHash ];
64
+			$statementArray['mainsnak'] = ['hash' => $snakHash];
65 65
 		}
66 66
 		$mainsnakArray = &$statementArray['mainsnak'];
67 67
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ReferenceContextCursor.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context;
6 6
 
@@ -68,43 +68,43 @@  discard block
 block discarded – undo
68 68
 		return $this->referenceHash;
69 69
 	}
70 70
 
71
-	protected function &getMainArray( array &$container ): array {
72
-		$statementArray = &$this->getStatementArray( $container );
71
+	protected function &getMainArray(array &$container): array {
72
+		$statementArray = &$this->getStatementArray($container);
73 73
 
74
-		if ( !array_key_exists( 'references', $statementArray ) ) {
74
+		if (!array_key_exists('references', $statementArray)) {
75 75
 			$statementArray['references'] = [];
76 76
 		}
77 77
 		$referencesArray = &$statementArray['references'];
78 78
 
79 79
 		$referenceHash = $this->getReferenceHash();
80
-		foreach ( $referencesArray as &$potentialReferenceArray ) {
81
-			if ( $potentialReferenceArray['hash'] === $referenceHash ) {
80
+		foreach ($referencesArray as &$potentialReferenceArray) {
81
+			if ($potentialReferenceArray['hash'] === $referenceHash) {
82 82
 				$referenceArray = &$potentialReferenceArray;
83 83
 				break;
84 84
 			}
85 85
 		}
86
-		if ( !isset( $referenceArray ) ) {
87
-			$referenceArray = [ 'hash' => $referenceHash, 'snaks' => [] ];
86
+		if (!isset($referenceArray)) {
87
+			$referenceArray = ['hash' => $referenceHash, 'snaks' => []];
88 88
 			$referencesArray[] = &$referenceArray;
89 89
 		}
90 90
 
91 91
 		$snaksArray = &$referenceArray['snaks'];
92 92
 
93 93
 		$snakPropertyId = $this->getSnakPropertyId();
94
-		if ( !array_key_exists( $snakPropertyId, $snaksArray ) ) {
94
+		if (!array_key_exists($snakPropertyId, $snaksArray)) {
95 95
 			$snaksArray[$snakPropertyId] = [];
96 96
 		}
97 97
 		$propertyArray = &$snaksArray[$snakPropertyId];
98 98
 
99 99
 		$snakHash = $this->getSnakHash();
100
-		foreach ( $propertyArray as &$potentialSnakArray ) {
101
-			if ( $potentialSnakArray['hash'] === $snakHash ) {
100
+		foreach ($propertyArray as &$potentialSnakArray) {
101
+			if ($potentialSnakArray['hash'] === $snakHash) {
102 102
 				$snakArray = &$potentialSnakArray;
103 103
 				break;
104 104
 			}
105 105
 		}
106
-		if ( !isset( $snakArray ) ) {
107
-			$snakArray = [ 'hash' => $snakHash ];
106
+		if (!isset($snakArray)) {
107
+			$snakArray = ['hash' => $snakHash];
108 108
 			$propertyArray[] = &$snakArray;
109 109
 		}
110 110
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/SparqlHelper.php 1 patch
Spacing   +232 added lines, -236 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Helper;
6 6
 
@@ -166,143 +166,143 @@  discard block
 block discarded – undo
166 166
 		$this->defaultUserAgent = $defaultUserAgent;
167 167
 		$this->requestFactory = $requestFactory;
168 168
 		$this->entityPrefixes = [];
169
-		foreach ( $rdfVocabulary->entityNamespaceNames as $namespaceName ) {
170
-			$this->entityPrefixes[] = $rdfVocabulary->getNamespaceURI( $namespaceName );
169
+		foreach ($rdfVocabulary->entityNamespaceNames as $namespaceName) {
170
+			$this->entityPrefixes[] = $rdfVocabulary->getNamespaceURI($namespaceName);
171 171
 		}
172 172
 
173
-		$this->primaryEndpoint = $config->get( 'WBQualityConstraintsSparqlEndpoint' );
174
-		$this->additionalEndpoints = $config->get( 'WBQualityConstraintsAdditionalSparqlEndpoints' ) ?: [];
175
-		$this->maxQueryTimeMillis = $config->get( 'WBQualityConstraintsSparqlMaxMillis' );
176
-		$this->subclassOfId = new NumericPropertyId( $config->get( 'WBQualityConstraintsSubclassOfId' ) );
177
-		$this->cacheMapSize = $config->get( 'WBQualityConstraintsFormatCacheMapSize' );
173
+		$this->primaryEndpoint = $config->get('WBQualityConstraintsSparqlEndpoint');
174
+		$this->additionalEndpoints = $config->get('WBQualityConstraintsAdditionalSparqlEndpoints') ?: [];
175
+		$this->maxQueryTimeMillis = $config->get('WBQualityConstraintsSparqlMaxMillis');
176
+		$this->subclassOfId = new NumericPropertyId($config->get('WBQualityConstraintsSubclassOfId'));
177
+		$this->cacheMapSize = $config->get('WBQualityConstraintsFormatCacheMapSize');
178 178
 		$this->timeoutExceptionClasses = $config->get(
179 179
 			'WBQualityConstraintsSparqlTimeoutExceptionClasses'
180 180
 		);
181 181
 		$this->sparqlHasWikibaseSupport = $config->get(
182 182
 			'WBQualityConstraintsSparqlHasWikibaseSupport'
183 183
 		);
184
-		$this->sparqlThrottlingFallbackDuration = (int)$config->get(
184
+		$this->sparqlThrottlingFallbackDuration = (int) $config->get(
185 185
 			'WBQualityConstraintsSparqlThrottlingFallbackDuration'
186 186
 		);
187 187
 
188
-		$this->prefixes = $this->getQueryPrefixes( $rdfVocabulary );
188
+		$this->prefixes = $this->getQueryPrefixes($rdfVocabulary);
189 189
 
190 190
 		$this->rdfVocabularyWithoutNormalization = clone $rdfVocabulary;
191 191
 		// @phan-suppress-next-line PhanTypeMismatchProperty
192 192
 		$this->rdfVocabularyWithoutNormalization->normalizedPropertyValueNamespace = array_fill_keys(
193
-			array_keys( $rdfVocabulary->normalizedPropertyValueNamespace ),
193
+			array_keys($rdfVocabulary->normalizedPropertyValueNamespace),
194 194
 			null
195 195
 		);
196 196
 	}
197 197
 
198
-	private function getQueryPrefixes( RdfVocabulary $rdfVocabulary ): string {
198
+	private function getQueryPrefixes(RdfVocabulary $rdfVocabulary): string {
199 199
 		// TODO: it would probably be smarter that RdfVocabulary exposed these prefixes somehow
200 200
 		$prefixes = '';
201
-		foreach ( $rdfVocabulary->entityNamespaceNames as $sourceName => $namespaceName ) {
201
+		foreach ($rdfVocabulary->entityNamespaceNames as $sourceName => $namespaceName) {
202 202
 			$prefixes .= <<<END
203
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
203
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
204 204
 END;
205 205
 		}
206 206
 
207
-		foreach ( $rdfVocabulary->statementNamespaceNames as $sourceName => $sourceNamespaces ) {
207
+		foreach ($rdfVocabulary->statementNamespaceNames as $sourceName => $sourceNamespaces) {
208 208
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NS_VALUE];
209 209
 			$prefixes .= <<<END
210
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
210
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
211 211
 END;
212 212
 		}
213 213
 
214
-		foreach ( $rdfVocabulary->propertyNamespaceNames as $sourceName => $sourceNamespaces ) {
214
+		foreach ($rdfVocabulary->propertyNamespaceNames as $sourceName => $sourceNamespaces) {
215 215
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_DIRECT_CLAIM];
216 216
 			$prefixes .= <<<END
217
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
217
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
218 218
 END;
219 219
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM];
220 220
 			$prefixes .= <<<END
221
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
221
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
222 222
 END;
223 223
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM_STATEMENT];
224 224
 			$prefixes .= <<<END
225
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
225
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
226 226
 END;
227 227
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM_VALUE];
228 228
 			$prefixes .= <<<END
229
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
229
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
230 230
 END;
231 231
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_QUALIFIER];
232 232
 			$prefixes .= <<<END
233
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
233
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
234 234
 END;
235 235
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_QUALIFIER_VALUE];
236 236
 			$prefixes .= <<<END
237
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
237
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
238 238
 END;
239 239
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_REFERENCE];
240 240
 			$prefixes .= <<<END
241
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
241
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
242 242
 END;
243 243
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_REFERENCE_VALUE];
244 244
 			$prefixes .= <<<END
245
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
245
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
246 246
 END;
247 247
 		}
248 248
 		$namespaceName = RdfVocabulary::NS_ONTOLOGY;
249 249
 		$prefixes .= <<<END
250
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
250
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
251 251
 END;
252 252
 		return $prefixes;
253 253
 	}
254 254
 
255 255
 	/** Return a SPARQL term like `wd:Q123` for the given ID. */
256
-	private function wd( EntityId $id ): string {
257
-		$repository = $this->rdfVocabulary->getEntityRepositoryName( $id );
256
+	private function wd(EntityId $id): string {
257
+		$repository = $this->rdfVocabulary->getEntityRepositoryName($id);
258 258
 		$prefix = $this->rdfVocabulary->entityNamespaceNames[$repository];
259 259
 		return "$prefix:{$id->getSerialization()}";
260 260
 	}
261 261
 
262 262
 	/** Return a SPARQL term like `wdt:P123` for the given ID. */
263
-	private function wdt( PropertyId $id ): string {
264
-		$repository = $this->rdfVocabulary->getEntityRepositoryName( $id );
263
+	private function wdt(PropertyId $id): string {
264
+		$repository = $this->rdfVocabulary->getEntityRepositoryName($id);
265 265
 		$prefix = $this->rdfVocabulary->propertyNamespaceNames[$repository][RdfVocabulary::NSP_DIRECT_CLAIM];
266 266
 		return "$prefix:{$id->getSerialization()}";
267 267
 	}
268 268
 
269 269
 	/** Return a SPARQL term like `p:P123` for the given ID. */
270
-	private function p( PropertyId $id ): string {
271
-		$repository = $this->rdfVocabulary->getEntityRepositoryName( $id );
270
+	private function p(PropertyId $id): string {
271
+		$repository = $this->rdfVocabulary->getEntityRepositoryName($id);
272 272
 		$prefix = $this->rdfVocabulary->propertyNamespaceNames[$repository][RdfVocabulary::NSP_CLAIM];
273 273
 		return "$prefix:{$id->getSerialization()}";
274 274
 	}
275 275
 
276 276
 	/** Return a SPARQL term like `pq:P123` for the given ID. */
277
-	private function pq( PropertyId $id ): string {
278
-		$repository = $this->rdfVocabulary->getEntityRepositoryName( $id );
277
+	private function pq(PropertyId $id): string {
278
+		$repository = $this->rdfVocabulary->getEntityRepositoryName($id);
279 279
 		$prefix = $this->rdfVocabulary->propertyNamespaceNames[$repository][RdfVocabulary::NSP_QUALIFIER];
280 280
 		return "$prefix:{$id->getSerialization()}";
281 281
 	}
282 282
 
283 283
 	/** Return a SPARQL term like `wdno:P123` for the given ID. */
284
-	private function wdno( PropertyId $id ): string {
285
-		$repository = $this->rdfVocabulary->getEntityRepositoryName( $id );
284
+	private function wdno(PropertyId $id): string {
285
+		$repository = $this->rdfVocabulary->getEntityRepositoryName($id);
286 286
 		$prefix = $this->rdfVocabulary->propertyNamespaceNames[$repository][RdfVocabulary::NSP_NOVALUE];
287 287
 		return "$prefix:{$id->getSerialization()}";
288 288
 	}
289 289
 
290 290
 	/** Return a SPARQL term like `prov:NAME` for the given name. */
291
-	private function prov( string $name ): string {
291
+	private function prov(string $name): string {
292 292
 		$prefix = RdfVocabulary::NS_PROV;
293 293
 		return "$prefix:$name";
294 294
 	}
295 295
 
296 296
 	/** Return a SPARQL term like `wikibase:NAME` for the given name. */
297
-	private function wikibase( string $name ): string {
297
+	private function wikibase(string $name): string {
298 298
 		$prefix = RdfVocabulary::NS_ONTOLOGY;
299 299
 		return "$prefix:$name";
300 300
 	}
301 301
 
302 302
 	/** Return a SPARQL snippet like `MINUS { ?var wikibase:rank wikibase:DeprecatedRank. }`. */
303
-	private function minusDeprecatedRank( string $varName ): string {
303
+	private function minusDeprecatedRank(string $varName): string {
304 304
 		$deprecatedRank = RdfVocabulary::RANK_MAP[Statement::RANK_DEPRECATED];
305
-		return "MINUS { $varName {$this->wikibase( 'rank' )} {$this->wikibase( $deprecatedRank )}. }";
305
+		return "MINUS { $varName {$this->wikibase('rank')} {$this->wikibase($deprecatedRank)}. }";
306 306
 	}
307 307
 
308 308
 	/**
@@ -312,43 +312,42 @@  discard block
 block discarded – undo
312 312
 	 * @return CachedBool
313 313
 	 * @throws SparqlHelperException if the query times out or some other error occurs
314 314
 	 */
315
-	public function hasType( EntityId $id, array $classes ): CachedBool {
315
+	public function hasType(EntityId $id, array $classes): CachedBool {
316 316
 		// TODO hint:gearing is a workaround for T168973 and can hopefully be removed eventually
317 317
 		$gearingHint = $this->sparqlHasWikibaseSupport ?
318
-			' hint:Prior hint:gearing "forward".' :
319
-			'';
318
+			' hint:Prior hint:gearing "forward".' : '';
320 319
 
321 320
 		$metadatas = [];
322 321
 
323
-		foreach ( array_chunk( $classes, 20 ) as $classesChunk ) {
324
-			$classesValues = implode( ' ', array_map(
325
-				function ( string $class ) {
326
-					return $this->wd( new ItemId( $class ) );
322
+		foreach (array_chunk($classes, 20) as $classesChunk) {
323
+			$classesValues = implode(' ', array_map(
324
+				function(string $class) {
325
+					return $this->wd(new ItemId($class));
327 326
 				},
328 327
 				$classesChunk
329
-			) );
328
+			));
330 329
 
331 330
 			$query = <<<EOF
332 331
 ASK {
333
-  BIND({$this->wd( $id )} AS ?item)
332
+  BIND({$this->wd($id)} AS ?item)
334 333
   VALUES ?class { $classesValues }
335
-  ?item {$this->wdt( $this->subclassOfId )}* ?class.$gearingHint
334
+  ?item {$this->wdt($this->subclassOfId)}* ?class.$gearingHint
336 335
 }
337 336
 EOF;
338 337
 
339
-			$result = $this->runQuery( $query, $this->primaryEndpoint );
338
+			$result = $this->runQuery($query, $this->primaryEndpoint);
340 339
 			$metadatas[] = $result->getMetadata();
341
-			if ( $result->getArray()['boolean'] ) {
340
+			if ($result->getArray()['boolean']) {
342 341
 				return new CachedBool(
343 342
 					true,
344
-					Metadata::merge( $metadatas )
343
+					Metadata::merge($metadatas)
345 344
 				);
346 345
 			}
347 346
 		}
348 347
 
349 348
 		return new CachedBool(
350 349
 			false,
351
-			Metadata::merge( $metadatas )
350
+			Metadata::merge($metadatas)
352 351
 		);
353 352
 	}
354 353
 
@@ -366,12 +365,12 @@  discard block
 block discarded – undo
366 365
 		array $separators
367 366
 	): CachedEntityIds {
368 367
 		$mainSnak = $statement->getMainSnak();
369
-		if ( !( $mainSnak instanceof PropertyValueSnak ) ) {
370
-			return new CachedEntityIds( [], Metadata::blank() );
368
+		if (!($mainSnak instanceof PropertyValueSnak)) {
369
+			return new CachedEntityIds([], Metadata::blank());
371 370
 		}
372 371
 
373 372
 		$propertyId = $statement->getPropertyId();
374
-		$pPredicateAndObject = "{$this->p( $propertyId )} ?otherStatement."; // p:P123 ?otherStatement.
373
+		$pPredicateAndObject = "{$this->p($propertyId)} ?otherStatement."; // p:P123 ?otherStatement.
375 374
 		$otherStatementPredicateAndObject = $this->getSnakPredicateAndObject(
376 375
 			$entityId,
377 376
 			$mainSnak,
@@ -380,57 +379,57 @@  discard block
 block discarded – undo
380 379
 
381 380
 		$isSeparator = [];
382 381
 		$unusedSeparators = [];
383
-		foreach ( $separators as $separator ) {
382
+		foreach ($separators as $separator) {
384 383
 			$isSeparator[$separator->getSerialization()] = true;
385 384
 			$unusedSeparators[$separator->getSerialization()] = $separator;
386 385
 		}
387 386
 		$separatorFilters = '';
388
-		foreach ( $statement->getQualifiers() as $qualifier ) {
387
+		foreach ($statement->getQualifiers() as $qualifier) {
389 388
 			$qualPropertyId = $qualifier->getPropertyId();
390
-			if ( !( $isSeparator[$qualPropertyId->getSerialization()] ?? false ) ) {
389
+			if (!($isSeparator[$qualPropertyId->getSerialization()] ?? false)) {
391 390
 				continue;
392 391
 			}
393
-			unset( $unusedSeparators[$qualPropertyId->getSerialization()] );
392
+			unset($unusedSeparators[$qualPropertyId->getSerialization()]);
394 393
 			// only look for other statements with the same qualifier
395
-			if ( $qualifier instanceof PropertyValueSnak ) {
394
+			if ($qualifier instanceof PropertyValueSnak) {
396 395
 				$sepPredicateAndObject = $this->getSnakPredicateAndObject(
397 396
 					$entityId,
398 397
 					$qualifier,
399 398
 					RdfVocabulary::NSP_QUALIFIER
400 399
 				);
401 400
 				$separatorFilters .= "  ?otherStatement $sepPredicateAndObject\n";
402
-			} elseif ( $qualifier instanceof PropertyNoValueSnak ) {
403
-				$sepPredicateAndObject = "a {$this->wdno( $qualPropertyId )}."; // a wdno:P123.
401
+			} elseif ($qualifier instanceof PropertyNoValueSnak) {
402
+				$sepPredicateAndObject = "a {$this->wdno($qualPropertyId)}."; // a wdno:P123.
404 403
 				$separatorFilters .= "  ?otherStatement $sepPredicateAndObject\n";
405 404
 			} else {
406 405
 				// "some value" / "unknown value" is always different from everything else,
407 406
 				// therefore the whole statement has no duplicates and we can return immediately
408
-				return new CachedEntityIds( [], Metadata::blank() );
407
+				return new CachedEntityIds([], Metadata::blank());
409 408
 			}
410 409
 		}
411
-		foreach ( $unusedSeparators as $unusedSeparator ) {
410
+		foreach ($unusedSeparators as $unusedSeparator) {
412 411
 			// exclude other statements which have a separator that this one lacks
413
-			$separatorFilters .= "  MINUS { ?otherStatement {$this->pq( $unusedSeparator )} []. }\n";
414
-			$separatorFilters .= "  MINUS { ?otherStatement a {$this->wdno( $unusedSeparator )}. }\n";
412
+			$separatorFilters .= "  MINUS { ?otherStatement {$this->pq($unusedSeparator)} []. }\n";
413
+			$separatorFilters .= "  MINUS { ?otherStatement a {$this->wdno($unusedSeparator)}. }\n";
415 414
 		}
416 415
 
417 416
 		$query = <<<SPARQL
418 417
 SELECT DISTINCT ?otherEntity WHERE {
419 418
   ?otherEntity $pPredicateAndObject
420 419
   ?otherStatement $otherStatementPredicateAndObject
421
-  {$this->minusDeprecatedRank( '?otherStatement' )}
422
-  FILTER(?otherEntity != {$this->wd( $entityId )})
420
+  {$this->minusDeprecatedRank('?otherStatement')}
421
+  FILTER(?otherEntity != {$this->wd($entityId)})
423 422
 $separatorFilters
424 423
 }
425 424
 LIMIT 10
426 425
 SPARQL;
427 426
 
428
-		$results = [ $this->runQuery( $query, $this->primaryEndpoint ) ];
429
-		foreach ( $this->additionalEndpoints as $endpoint ) {
430
-			$results[] = $this->runQuery( $query, $endpoint );
427
+		$results = [$this->runQuery($query, $this->primaryEndpoint)];
428
+		foreach ($this->additionalEndpoints as $endpoint) {
429
+			$results[] = $this->runQuery($query, $endpoint);
431 430
 		}
432 431
 
433
-		return $this->getOtherEntities( $results );
432
+		return $this->getOtherEntities($results);
434 433
 	}
435 434
 
436 435
 	/**
@@ -449,40 +448,38 @@  discard block
 block discarded – undo
449 448
 		bool $ignoreDeprecatedStatements
450 449
 	): CachedEntityIds {
451 450
 		$propertyId = $snak->getPropertyId();
452
-		$pPredicateAndObject = "{$this->p( $propertyId )} ?otherStatement."; // p:P123 ?otherStatement.
451
+		$pPredicateAndObject = "{$this->p($propertyId)} ?otherStatement."; // p:P123 ?otherStatement.
453 452
 
454 453
 		$otherSubject = $type === Context::TYPE_QUALIFIER ?
455
-			'?otherStatement' :
456
-			"?otherStatement {$this->prov( 'wasDerivedFrom' )} ?reference.\n  ?reference";
454
+			'?otherStatement' : "?otherStatement {$this->prov('wasDerivedFrom')} ?reference.\n  ?reference";
457 455
 		$otherPredicateAndObject = $this->getSnakPredicateAndObject(
458 456
 			$entityId,
459 457
 			$snak,
460 458
 			$type === Context::TYPE_QUALIFIER ?
461
-				RdfVocabulary::NSP_QUALIFIER :
462
-				RdfVocabulary::NSP_REFERENCE
459
+				RdfVocabulary::NSP_QUALIFIER : RdfVocabulary::NSP_REFERENCE
463 460
 		);
464 461
 
465 462
 		$deprecatedFilter = '';
466
-		if ( $ignoreDeprecatedStatements ) {
467
-			$deprecatedFilter = '  ' . $this->minusDeprecatedRank( '?otherStatement' );
463
+		if ($ignoreDeprecatedStatements) {
464
+			$deprecatedFilter = '  '.$this->minusDeprecatedRank('?otherStatement');
468 465
 		}
469 466
 
470 467
 		$query = <<<SPARQL
471 468
 SELECT DISTINCT ?otherEntity WHERE {
472 469
   ?otherEntity $pPredicateAndObject
473 470
   $otherSubject $otherPredicateAndObject
474
-  FILTER(?otherEntity != {$this->wd( $entityId )})
471
+  FILTER(?otherEntity != {$this->wd($entityId)})
475 472
 $deprecatedFilter
476 473
 }
477 474
 LIMIT 10
478 475
 SPARQL;
479 476
 
480
-		$results = [ $this->runQuery( $query, $this->primaryEndpoint ) ];
481
-		foreach ( $this->additionalEndpoints as $endpoint ) {
482
-			$results[] = $this->runQuery( $query, $endpoint );
477
+		$results = [$this->runQuery($query, $this->primaryEndpoint)];
478
+		foreach ($this->additionalEndpoints as $endpoint) {
479
+			$results[] = $this->runQuery($query, $endpoint);
483 480
 		}
484 481
 
485
-		return $this->getOtherEntities( $results );
482
+		return $this->getOtherEntities($results);
486 483
 	}
487 484
 
488 485
 	/**
@@ -513,13 +510,13 @@  discard block
 block discarded – undo
513 510
 		$writer->start();
514 511
 		$writer->drain();
515 512
 		$placeholder1 = 'wbqc';
516
-		$placeholder2 = 'x' . wfRandomString( 32 );
517
-		$writer->about( $placeholder1, $placeholder2 );
513
+		$placeholder2 = 'x'.wfRandomString(32);
514
+		$writer->about($placeholder1, $placeholder2);
518 515
 
519 516
 		$propertyId = $snak->getPropertyId();
520 517
 		$pid = $propertyId->getSerialization();
521
-		$propertyRepository = $this->rdfVocabulary->getEntityRepositoryName( $propertyId );
522
-		$entityRepository = $this->rdfVocabulary->getEntityRepositoryName( $entityId );
518
+		$propertyRepository = $this->rdfVocabulary->getEntityRepositoryName($propertyId);
519
+		$entityRepository = $this->rdfVocabulary->getEntityRepositoryName($entityId);
523 520
 		$propertyNamespace = $this->rdfVocabulary->propertyNamespaceNames[$propertyRepository][$namespace];
524 521
 		$value = $snak->getDataValue();
525 522
 		if (
@@ -550,21 +547,21 @@  discard block
 block discarded – undo
550 547
 				$writer,
551 548
 				$propertyNamespace,
552 549
 				$pid,
553
-				$this->propertyDataTypeLookup->getDataTypeIdForProperty( $propertyId ),
550
+				$this->propertyDataTypeLookup->getDataTypeIdForProperty($propertyId),
554 551
 				$this->rdfVocabulary->statementNamespaceNames[$entityRepository][RdfVocabulary::NS_VALUE], // should be unused
555 552
 				$snak
556 553
 			);
557 554
 		}
558 555
 
559 556
 		$triple = $writer->drain(); // wbqc:xRANDOM ps:PID "value". or similar
560
-		return trim( str_replace( "$placeholder1:$placeholder2", '', $triple ) );
557
+		return trim(str_replace("$placeholder1:$placeholder2", '', $triple));
561 558
 	}
562 559
 
563 560
 	/**
564 561
 	 * Return SPARQL code for a string literal with $text as content.
565 562
 	 */
566
-	private function stringLiteral( string $text ): string {
567
-		return '"' . strtr( $text, [ '"' => '\\"', '\\' => '\\\\' ] ) . '"';
563
+	private function stringLiteral(string $text): string {
564
+		return '"'.strtr($text, ['"' => '\\"', '\\' => '\\\\']).'"';
568 565
 	}
569 566
 
570 567
 	/**
@@ -574,26 +571,26 @@  discard block
 block discarded – undo
574 571
 	 *
575 572
 	 * @return CachedEntityIds
576 573
 	 */
577
-	private function getOtherEntities( array $results ): CachedEntityIds {
574
+	private function getOtherEntities(array $results): CachedEntityIds {
578 575
 		$allResultBindings = [];
579 576
 		$metadatas = [];
580 577
 
581
-		foreach ( $results as $result ) {
578
+		foreach ($results as $result) {
582 579
 			$metadatas[] = $result->getMetadata();
583
-			$allResultBindings = array_merge( $allResultBindings, $result->getArray()['results']['bindings'] );
580
+			$allResultBindings = array_merge($allResultBindings, $result->getArray()['results']['bindings']);
584 581
 		}
585 582
 
586 583
 		$entityIds = array_map(
587
-			function ( $resultBindings ) {
584
+			function($resultBindings) {
588 585
 				$entityIRI = $resultBindings['otherEntity']['value'];
589
-				foreach ( $this->entityPrefixes as $entityPrefix ) {
590
-					$entityPrefixLength = strlen( $entityPrefix );
591
-					if ( substr( $entityIRI, 0, $entityPrefixLength ) === $entityPrefix ) {
586
+				foreach ($this->entityPrefixes as $entityPrefix) {
587
+					$entityPrefixLength = strlen($entityPrefix);
588
+					if (substr($entityIRI, 0, $entityPrefixLength) === $entityPrefix) {
592 589
 						try {
593 590
 							return $this->entityIdParser->parse(
594
-								substr( $entityIRI, $entityPrefixLength )
591
+								substr($entityIRI, $entityPrefixLength)
595 592
 							);
596
-						} catch ( EntityIdParsingException $e ) {
593
+						} catch (EntityIdParsingException $e) {
597 594
 							// fall through
598 595
 						}
599 596
 					}
@@ -607,8 +604,8 @@  discard block
 block discarded – undo
607 604
 		);
608 605
 
609 606
 		return new CachedEntityIds(
610
-			array_values( array_filter( array_unique( $entityIds ) ) ),
611
-			Metadata::merge( $metadatas )
607
+			array_values(array_filter(array_unique($entityIds))),
608
+			Metadata::merge($metadatas)
612 609
 		);
613 610
 	}
614 611
 
@@ -616,63 +613,63 @@  discard block
 block discarded – undo
616 613
 	 * @throws SparqlHelperException if the query times out or some other error occurs
617 614
 	 * @throws ConstraintParameterException if the $regex is invalid
618 615
 	 */
619
-	public function matchesRegularExpression( string $text, string $regex ): bool {
616
+	public function matchesRegularExpression(string $text, string $regex): bool {
620 617
 		// caching wrapper around matchesRegularExpressionWithSparql
621 618
 
622
-		$textHash = hash( 'sha256', $text );
619
+		$textHash = hash('sha256', $text);
623 620
 		$cacheKey = $this->cache->makeKey(
624 621
 			'WikibaseQualityConstraints', // extension
625 622
 			'regex', // action
626 623
 			'WDQS-Java', // regex flavor
627
-			hash( 'sha256', $regex )
624
+			hash('sha256', $regex)
628 625
 		);
629 626
 
630 627
 		$baseRegexCacheKey = 'wikibase.quality.constraints.regex.cache';
631
-		$metric = $this->statsFactory->getCounter( 'regex_cache_total' );
628
+		$metric = $this->statsFactory->getCounter('regex_cache_total');
632 629
 
633 630
 		$cacheMapArray = $this->cache->getWithSetCallback(
634 631
 			$cacheKey,
635 632
 			WANObjectCache::TTL_DAY,
636
-			function ( $cacheMapArray ) use ( $text, $regex, $textHash, $metric, $baseRegexCacheKey ) {
633
+			function($cacheMapArray) use ($text, $regex, $textHash, $metric, $baseRegexCacheKey) {
637 634
 				// Initialize the cache map if not set
638
-				if ( $cacheMapArray === false ) {
635
+				if ($cacheMapArray === false) {
639 636
 					$metric
640
-						->setLabel( 'operation', 'refresh' )
641
-						->setLabel( 'status', 'init' )
642
-						->copyToStatsdAt( [
637
+						->setLabel('operation', 'refresh')
638
+						->setLabel('status', 'init')
639
+						->copyToStatsdAt([
643 640
 							"$baseRegexCacheKey.refresh.init",
644
-						] )->increment();
641
+						])->increment();
645 642
 
646 643
 					return [];
647 644
 				}
648 645
 
649
-				$cacheMap = MapCacheLRU::newFromArray( $cacheMapArray, $this->cacheMapSize );
650
-				if ( $cacheMap->has( $textHash ) ) {
646
+				$cacheMap = MapCacheLRU::newFromArray($cacheMapArray, $this->cacheMapSize);
647
+				if ($cacheMap->has($textHash)) {
651 648
 					$metric
652
-						->setLabel( 'operation', 'refresh' )
653
-						->setLabel( 'status', 'hit' )
654
-						->copyToStatsdAt( [
649
+						->setLabel('operation', 'refresh')
650
+						->setLabel('status', 'hit')
651
+						->copyToStatsdAt([
655 652
 							"$baseRegexCacheKey.refresh",
656 653
 							"$baseRegexCacheKey.refresh.hit",
657
-						] )
654
+						])
658 655
 						->increment();
659 656
 
660
-					$cacheMap->get( $textHash ); // ping cache
657
+					$cacheMap->get($textHash); // ping cache
661 658
 				} else {
662 659
 					$metric
663
-						->setLabel( 'operation', 'refresh' )
664
-						->setLabel( 'status', 'miss' )
665
-						->copyToStatsdAt( [
660
+						->setLabel('operation', 'refresh')
661
+						->setLabel('status', 'miss')
662
+						->copyToStatsdAt([
666 663
 							"$baseRegexCacheKey.refresh",
667 664
 							"$baseRegexCacheKey.refresh.miss",
668
-						] )
665
+						])
669 666
 						->increment();
670 667
 
671 668
 					try {
672
-						$matches = $this->matchesRegularExpressionWithSparql( $text, $regex );
673
-					} catch ( ConstraintParameterException $e ) {
674
-						$matches = $this->serializeConstraintParameterException( $e );
675
-					} catch ( SparqlHelperException $e ) {
669
+						$matches = $this->matchesRegularExpressionWithSparql($text, $regex);
670
+					} catch (ConstraintParameterException $e) {
671
+						$matches = $this->serializeConstraintParameterException($e);
672
+					} catch (SparqlHelperException $e) {
676 673
 						// don’t cache this
677 674
 						return $cacheMap->toArray();
678 675
 					}
@@ -696,54 +693,54 @@  discard block
 block discarded – undo
696 693
 			]
697 694
 		);
698 695
 
699
-		if ( isset( $cacheMapArray[$textHash] ) ) {
696
+		if (isset($cacheMapArray[$textHash])) {
700 697
 			$metric
701
-				->setLabel( 'operation', 'none' )
702
-				->setLabel( 'status', 'hit' )
703
-				->copyToStatsdAt( [
698
+				->setLabel('operation', 'none')
699
+				->setLabel('status', 'hit')
700
+				->copyToStatsdAt([
704 701
 					"$baseRegexCacheKey.hit",
705
-				] )
702
+				])
706 703
 				->increment();
707 704
 
708 705
 			$matches = $cacheMapArray[$textHash];
709
-			if ( is_bool( $matches ) ) {
706
+			if (is_bool($matches)) {
710 707
 				return $matches;
711
-			} elseif ( is_array( $matches ) &&
712
-				$matches['type'] == ConstraintParameterException::class ) {
713
-				throw $this->deserializeConstraintParameterException( $matches );
708
+			} elseif (is_array($matches) &&
709
+				$matches['type'] == ConstraintParameterException::class) {
710
+				throw $this->deserializeConstraintParameterException($matches);
714 711
 			} else {
715 712
 				throw new UnexpectedValueException(
716
-					'Value of unknown type in object cache (' .
717
-					'cache key: ' . $cacheKey . ', ' .
718
-					'cache map key: ' . $textHash . ', ' .
719
-					'value type: ' . get_debug_type( $matches ) . ')'
713
+					'Value of unknown type in object cache ('.
714
+					'cache key: '.$cacheKey.', '.
715
+					'cache map key: '.$textHash.', '.
716
+					'value type: '.get_debug_type($matches).')'
720 717
 				);
721 718
 			}
722 719
 		} else {
723 720
 			$metric
724
-				->setLabel( 'operation', 'none' )
725
-				->setLabel( 'status', 'miss' )
726
-				->copyToStatsdAt( [
721
+				->setLabel('operation', 'none')
722
+				->setLabel('status', 'miss')
723
+				->copyToStatsdAt([
727 724
 					"$baseRegexCacheKey.miss",
728
-				] )
725
+				])
729 726
 				->increment();
730 727
 
731
-			return $this->matchesRegularExpressionWithSparql( $text, $regex );
728
+			return $this->matchesRegularExpressionWithSparql($text, $regex);
732 729
 		}
733 730
 	}
734 731
 
735
-	private function serializeConstraintParameterException( ConstraintParameterException $cpe ): array {
732
+	private function serializeConstraintParameterException(ConstraintParameterException $cpe): array {
736 733
 		return [
737 734
 			'type' => ConstraintParameterException::class,
738
-			'violationMessage' => $this->violationMessageSerializer->serialize( $cpe->getViolationMessage() ),
735
+			'violationMessage' => $this->violationMessageSerializer->serialize($cpe->getViolationMessage()),
739 736
 		];
740 737
 	}
741 738
 
742
-	private function deserializeConstraintParameterException( array $serialization ): ConstraintParameterException {
739
+	private function deserializeConstraintParameterException(array $serialization): ConstraintParameterException {
743 740
 		$message = $this->violationMessageDeserializer->deserialize(
744 741
 			$serialization['violationMessage']
745 742
 		);
746
-		return new ConstraintParameterException( $message );
743
+		return new ConstraintParameterException($message);
747 744
 	}
748 745
 
749 746
 	/**
@@ -753,25 +750,25 @@  discard block
 block discarded – undo
753 750
 	 * @throws SparqlHelperException if the query times out or some other error occurs
754 751
 	 * @throws ConstraintParameterException if the $regex is invalid
755 752
 	 */
756
-	public function matchesRegularExpressionWithSparql( string $text, string $regex ): bool {
757
-		$textStringLiteral = $this->stringLiteral( $text );
758
-		$regexStringLiteral = $this->stringLiteral( '^(?:' . $regex . ')$' );
753
+	public function matchesRegularExpressionWithSparql(string $text, string $regex): bool {
754
+		$textStringLiteral = $this->stringLiteral($text);
755
+		$regexStringLiteral = $this->stringLiteral('^(?:'.$regex.')$');
759 756
 
760 757
 		$query = <<<EOF
761 758
 SELECT (REGEX($textStringLiteral, $regexStringLiteral) AS ?matches) {}
762 759
 EOF;
763 760
 
764
-		$result = $this->runQuery( $query, $this->primaryEndpoint, false );
761
+		$result = $this->runQuery($query, $this->primaryEndpoint, false);
765 762
 
766 763
 		$vars = $result->getArray()['results']['bindings'][0];
767
-		if ( array_key_exists( 'matches', $vars ) ) {
764
+		if (array_key_exists('matches', $vars)) {
768 765
 			// true or false ⇒ regex okay, text matches or not
769 766
 			return $vars['matches']['value'] === 'true';
770 767
 		} else {
771 768
 			// empty result: regex broken
772 769
 			throw new ConstraintParameterException(
773
-				( new ViolationMessage( 'wbqc-violation-message-parameter-regex' ) )
774
-					->withInlineCode( $regex, Role::CONSTRAINT_PARAMETER_VALUE )
770
+				(new ViolationMessage('wbqc-violation-message-parameter-regex'))
771
+					->withInlineCode($regex, Role::CONSTRAINT_PARAMETER_VALUE)
775 772
 			);
776 773
 		}
777 774
 	}
@@ -779,14 +776,14 @@  discard block
 block discarded – undo
779 776
 	/**
780 777
 	 * Check whether the text content of an error response indicates a query timeout.
781 778
 	 */
782
-	public function isTimeout( string $responseContent ): bool {
783
-		$timeoutRegex = implode( '|', array_map(
784
-			static function ( $fqn ) {
785
-				return preg_quote( $fqn, '/' );
779
+	public function isTimeout(string $responseContent): bool {
780
+		$timeoutRegex = implode('|', array_map(
781
+			static function($fqn) {
782
+				return preg_quote($fqn, '/');
786 783
 			},
787 784
 			$this->timeoutExceptionClasses
788
-		) );
789
-		return (bool)preg_match( '/' . $timeoutRegex . '/', $responseContent );
785
+		));
786
+		return (bool) preg_match('/'.$timeoutRegex.'/', $responseContent);
790 787
 	}
791 788
 
792 789
 	/**
@@ -798,17 +795,17 @@  discard block
 block discarded – undo
798 795
 	 * @return int|bool the max-age (in seconds)
799 796
 	 * or a plain boolean if no max-age can be determined
800 797
 	 */
801
-	public function getCacheMaxAge( array $responseHeaders ) {
798
+	public function getCacheMaxAge(array $responseHeaders) {
802 799
 		if (
803
-			array_key_exists( 'x-cache-status', $responseHeaders ) &&
804
-			preg_match( '/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0] )
800
+			array_key_exists('x-cache-status', $responseHeaders) &&
801
+			preg_match('/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0])
805 802
 		) {
806 803
 			$maxage = [];
807 804
 			if (
808
-				array_key_exists( 'cache-control', $responseHeaders ) &&
809
-				preg_match( '/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage )
805
+				array_key_exists('cache-control', $responseHeaders) &&
806
+				preg_match('/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage)
810 807
 			) {
811
-				return intval( $maxage[1] );
808
+				return intval($maxage[1]);
812 809
 			} else {
813 810
 				return true;
814 811
 			}
@@ -829,34 +826,34 @@  discard block
 block discarded – undo
829 826
 	 * or SparlHelper::EMPTY_RETRY_AFTER if there is an empty Retry-After
830 827
 	 * or SparlHelper::INVALID_RETRY_AFTER if there is something wrong with the format
831 828
 	 */
832
-	public function getThrottling( MWHttpRequest $request ) {
833
-		$retryAfterValue = $request->getResponseHeader( 'Retry-After' );
834
-		if ( $retryAfterValue === null ) {
829
+	public function getThrottling(MWHttpRequest $request) {
830
+		$retryAfterValue = $request->getResponseHeader('Retry-After');
831
+		if ($retryAfterValue === null) {
835 832
 			return self::NO_RETRY_AFTER;
836 833
 		}
837 834
 
838
-		$trimmedRetryAfterValue = trim( $retryAfterValue );
839
-		if ( $trimmedRetryAfterValue === '' ) {
835
+		$trimmedRetryAfterValue = trim($retryAfterValue);
836
+		if ($trimmedRetryAfterValue === '') {
840 837
 			return self::EMPTY_RETRY_AFTER;
841 838
 		}
842 839
 
843
-		if ( is_numeric( $trimmedRetryAfterValue ) ) {
844
-			$delaySeconds = (int)$trimmedRetryAfterValue;
845
-			if ( $delaySeconds >= 0 ) {
846
-				return $this->getTimestampInFuture( new DateInterval( 'PT' . $delaySeconds . 'S' ) );
840
+		if (is_numeric($trimmedRetryAfterValue)) {
841
+			$delaySeconds = (int) $trimmedRetryAfterValue;
842
+			if ($delaySeconds >= 0) {
843
+				return $this->getTimestampInFuture(new DateInterval('PT'.$delaySeconds.'S'));
847 844
 			}
848 845
 		} else {
849
-			$return = strtotime( $trimmedRetryAfterValue );
850
-			if ( $return !== false ) {
851
-				return new ConvertibleTimestamp( $return );
846
+			$return = strtotime($trimmedRetryAfterValue);
847
+			if ($return !== false) {
848
+				return new ConvertibleTimestamp($return);
852 849
 			}
853 850
 		}
854 851
 		return self::INVALID_RETRY_AFTER;
855 852
 	}
856 853
 
857
-	private function getTimestampInFuture( DateInterval $delta ): ConvertibleTimestamp {
854
+	private function getTimestampInFuture(DateInterval $delta): ConvertibleTimestamp {
858 855
 		$now = new ConvertibleTimestamp();
859
-		return new ConvertibleTimestamp( $now->timestamp->add( $delta ) );
856
+		return new ConvertibleTimestamp($now->timestamp->add($delta));
860 857
 	}
861 858
 
862 859
 	/**
@@ -871,109 +868,108 @@  discard block
 block discarded – undo
871 868
 	 *
872 869
 	 * @throws SparqlHelperException if the query times out or some other error occurs
873 870
 	 */
874
-	protected function runQuery( string $query, string $endpoint, bool $needsPrefixes = true ): CachedQueryResults {
871
+	protected function runQuery(string $query, string $endpoint, bool $needsPrefixes = true): CachedQueryResults {
875 872
 		$baseSPARQLKey = 'wikibase.quality.constraints.sparql';
876 873
 
877
-		if ( $this->throttlingLock->isLocked( self::EXPIRY_LOCK_ID ) ) {
874
+		if ($this->throttlingLock->isLocked(self::EXPIRY_LOCK_ID)) {
878 875
 			$this->statsFactory
879
-				->getCounter( 'sparql_throttling_total' )
880
-				->copyToStatsdAt( "$baseSPARQLKey.throttling" )
876
+				->getCounter('sparql_throttling_total')
877
+				->copyToStatsdAt("$baseSPARQLKey.throttling")
881 878
 				->increment();
882 879
 
883 880
 			throw new TooManySparqlRequestsException();
884 881
 		}
885 882
 
886
-		if ( $this->sparqlHasWikibaseSupport ) {
883
+		if ($this->sparqlHasWikibaseSupport) {
887 884
 			$needsPrefixes = false;
888 885
 		}
889 886
 
890
-		if ( $needsPrefixes ) {
891
-			$query = $this->prefixes . $query;
887
+		if ($needsPrefixes) {
888
+			$query = $this->prefixes.$query;
892 889
 		}
893
-		$query = "#wbqc\n" . $query;
890
+		$query = "#wbqc\n".$query;
894 891
 
895
-		$url = $endpoint . '?' . http_build_query(
892
+		$url = $endpoint.'?'.http_build_query(
896 893
 			[
897 894
 				'query' => $query,
898 895
 				'format' => 'json',
899 896
 				'maxQueryTimeMillis' => $this->maxQueryTimeMillis,
900 897
 			],
901
-			'', ini_get( 'arg_separator.output' ),
898
+			'', ini_get('arg_separator.output'),
902 899
 			// encode spaces with %20, not +
903 900
 			PHP_QUERY_RFC3986
904 901
 		);
905 902
 
906 903
 		$options = [
907 904
 			'method' => 'GET',
908
-			'timeout' => (int)round( ( $this->maxQueryTimeMillis + 1000 ) / 1000 ),
905
+			'timeout' => (int) round(($this->maxQueryTimeMillis + 1000) / 1000),
909 906
 			'connectTimeout' => 'default',
910 907
 			'userAgent' => $this->defaultUserAgent,
911 908
 		];
912
-		$request = $this->requestFactory->create( $url, $options, __METHOD__ );
909
+		$request = $this->requestFactory->create($url, $options, __METHOD__);
913 910
 
914 911
 		$timing = $this->statsFactory
915
-			->getTiming( 'sparql_runQuery_duration_seconds' )
916
-			->copyToStatsdAt( "$baseSPARQLKey.timing" );
912
+			->getTiming('sparql_runQuery_duration_seconds')
913
+			->copyToStatsdAt("$baseSPARQLKey.timing");
917 914
 
918 915
 		$timing->start();
919 916
 		$requestStatus = $request->execute();
920 917
 		$timing->stop();
921 918
 
922
-		$this->guardAgainstTooManyRequestsError( $request );
919
+		$this->guardAgainstTooManyRequestsError($request);
923 920
 
924
-		$maxAge = $this->getCacheMaxAge( $request->getResponseHeaders() );
925
-		if ( $maxAge ) {
926
-			$this->statsFactory->getCounter( 'sparql_cached_total' )
927
-				->copyToStatsdAt( "$baseSPARQLKey.cached" )
921
+		$maxAge = $this->getCacheMaxAge($request->getResponseHeaders());
922
+		if ($maxAge) {
923
+			$this->statsFactory->getCounter('sparql_cached_total')
924
+				->copyToStatsdAt("$baseSPARQLKey.cached")
928 925
 				->increment();
929 926
 		}
930 927
 
931 928
 		$sparqlErrorKey = "$baseSPARQLKey.error";
932
-		$metric = $this->statsFactory->getCounter( 'sparql_error_total' );
933
-		if ( $requestStatus->isOK() ) {
929
+		$metric = $this->statsFactory->getCounter('sparql_error_total');
930
+		if ($requestStatus->isOK()) {
934 931
 			$json = $request->getContent();
935
-			$jsonStatus = FormatJson::parse( $json, FormatJson::FORCE_ASSOC );
936
-			if ( $jsonStatus->isOK() ) {
932
+			$jsonStatus = FormatJson::parse($json, FormatJson::FORCE_ASSOC);
933
+			if ($jsonStatus->isOK()) {
937 934
 				return new CachedQueryResults(
938 935
 					$jsonStatus->getValue(),
939 936
 					Metadata::ofCachingMetadata(
940 937
 						$maxAge ?
941
-							CachingMetadata::ofMaximumAgeInSeconds( $maxAge ) :
942
-							CachingMetadata::fresh()
938
+							CachingMetadata::ofMaximumAgeInSeconds($maxAge) : CachingMetadata::fresh()
943 939
 					)
944 940
 				);
945 941
 			} else {
946 942
 				$jsonErrorCode = $jsonStatus->getErrors()[0]['message'];
947 943
 				$metric
948
-					->setLabel( 'type', 'json' )
949
-					->setLabel( 'code', "$jsonErrorCode" )
950
-					->copyToStatsdAt( [
944
+					->setLabel('type', 'json')
945
+					->setLabel('code', "$jsonErrorCode")
946
+					->copyToStatsdAt([
951 947
 						"$sparqlErrorKey",
952 948
 						"$sparqlErrorKey.json.$jsonErrorCode",
953
-					] )
949
+					])
954 950
 					->increment();
955 951
 				// fall through to general error handling
956 952
 			}
957 953
 		} else {
958 954
 			$metric
959
-				->setLabel( 'type', 'http' )
960
-				->setLabel( 'code', "{$request->getStatus()}" )
961
-				->copyToStatsdAt( [
955
+				->setLabel('type', 'http')
956
+				->setLabel('code', "{$request->getStatus()}")
957
+				->copyToStatsdAt([
962 958
 					"$sparqlErrorKey",
963 959
 					"$sparqlErrorKey.http.{$request->getStatus()}",
964
-				] )
960
+				])
965 961
 				->increment();
966 962
 			// fall through to general error handling
967 963
 		}
968 964
 
969
-		if ( $this->isTimeout( $request->getContent() ) ) {
965
+		if ($this->isTimeout($request->getContent())) {
970 966
 			$metric
971
-				->setLabel( 'type', 'timeout' )
972
-				->setLabel( 'code', 'none' )
973
-				->copyToStatsdAt( [
967
+				->setLabel('type', 'timeout')
968
+				->setLabel('code', 'none')
969
+				->copyToStatsdAt([
974 970
 					"$sparqlErrorKey",
975 971
 					"$sparqlErrorKey.timeout",
976
-				] )
972
+				])
977 973
 				->increment();
978 974
 		}
979 975
 
@@ -986,33 +982,33 @@  discard block
 block discarded – undo
986 982
 	 * @param MWHttpRequest $request
987 983
 	 * @throws TooManySparqlRequestsException
988 984
 	 */
989
-	private function guardAgainstTooManyRequestsError( MWHttpRequest $request ): void {
990
-		if ( $request->getStatus() !== self::HTTP_TOO_MANY_REQUESTS ) {
985
+	private function guardAgainstTooManyRequestsError(MWHttpRequest $request): void {
986
+		if ($request->getStatus() !== self::HTTP_TOO_MANY_REQUESTS) {
991 987
 			return;
992 988
 		}
993 989
 
994 990
 		$fallbackBlockDuration = $this->sparqlThrottlingFallbackDuration;
995 991
 
996
-		if ( $fallbackBlockDuration < 0 ) {
997
-			throw new InvalidArgumentException( 'Fallback duration must be positive int but is: ' .
998
-				$fallbackBlockDuration );
992
+		if ($fallbackBlockDuration < 0) {
993
+			throw new InvalidArgumentException('Fallback duration must be positive int but is: '.
994
+				$fallbackBlockDuration);
999 995
 		}
1000 996
 
1001 997
 		$throttlingKey = "wikibase.quality.constraints.sparql.throttling";
1002
-		$this->statsFactory->getCounter( 'sparql_throttling_total' )
1003
-			->copyToStatsdAt( $throttlingKey )
998
+		$this->statsFactory->getCounter('sparql_throttling_total')
999
+			->copyToStatsdAt($throttlingKey)
1004 1000
 			->increment();
1005 1001
 
1006
-		$throttlingUntil = $this->getThrottling( $request );
1007
-		if ( !( $throttlingUntil instanceof ConvertibleTimestamp ) ) {
1008
-			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterInvalid( $request );
1002
+		$throttlingUntil = $this->getThrottling($request);
1003
+		if (!($throttlingUntil instanceof ConvertibleTimestamp)) {
1004
+			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterInvalid($request);
1009 1005
 			$this->throttlingLock->lock(
1010 1006
 				self::EXPIRY_LOCK_ID,
1011
-				$this->getTimestampInFuture( new DateInterval( 'PT' . $fallbackBlockDuration . 'S' ) )
1007
+				$this->getTimestampInFuture(new DateInterval('PT'.$fallbackBlockDuration.'S'))
1012 1008
 			);
1013 1009
 		} else {
1014
-			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterPresent( $throttlingUntil, $request );
1015
-			$this->throttlingLock->lock( self::EXPIRY_LOCK_ID, $throttlingUntil );
1010
+			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterPresent($throttlingUntil, $request);
1011
+			$this->throttlingLock->lock(self::EXPIRY_LOCK_ID, $throttlingUntil);
1016 1012
 		}
1017 1013
 		throw new TooManySparqlRequestsException();
1018 1014
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/FormatChecker.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		$this->sparqlHelper = $sparqlHelper;
75 75
 		$this->shellboxClientFactory = $shellboxClientFactory;
76 76
 		$this->knownGoodPatternsAsKeys = array_fill_keys(
77
-			$this->config->get( 'WBQualityConstraintsFormatCheckerKnownGoodRegexPatterns' ),
77
+			$this->config->get('WBQualityConstraintsFormatCheckerKnownGoodRegexPatterns'),
78 78
 			null
79 79
 		);
80 80
 		$this->logger = $logger ?? new NullLogger();
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * @throws ConstraintParameterException
109 109
 	 * @return CheckResult
110 110
 	 */
111
-	public function checkConstraint( Context $context, Constraint $constraint ): CheckResult {
111
+	public function checkConstraint(Context $context, Constraint $constraint): CheckResult {
112 112
 		$constraintParameters = $constraint->getConstraintParameters();
113 113
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
114 114
 
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 
124 124
 		$snak = $context->getSnak();
125 125
 
126
-		if ( !$snak instanceof PropertyValueSnak ) {
126
+		if (!$snak instanceof PropertyValueSnak) {
127 127
 			// nothing to check
128
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE );
128
+			return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE);
129 129
 		}
130 130
 
131 131
 		$dataValue = $snak->getDataValue();
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		 * error handling:
135 135
 		 *   type of $dataValue for properties with 'Format' constraint has to be 'string' or 'monolingualtext'
136 136
 		 */
137
-		switch ( $dataValue->getType() ) {
137
+		switch ($dataValue->getType()) {
138 138
 			case 'string':
139 139
 				$text = $dataValue->getValue();
140 140
 				break;
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 				$text = $dataValue->getText();
145 145
 				break;
146 146
 			default:
147
-				$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-types-2' ) )
148
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
149
-					->withDataValueType( 'string' )
150
-					->withDataValueType( 'monolingualtext' );
151
-				return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message );
147
+				$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-types-2'))
148
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
149
+					->withDataValueType('string')
150
+					->withDataValueType('monolingualtext');
151
+				return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message);
152 152
 		}
153
-		$status = $this->runRegexCheck( $text, $format );
153
+		$status = $this->runRegexCheck($text, $format);
154 154
 		$message = $this->formatMessage(
155 155
 			$status,
156 156
 			$text,
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			$syntaxClarifications,
160 160
 			$constraintTypeItemId
161 161
 		);
162
-		return new CheckResult( $context, $constraint, $status, $message );
162
+		return new CheckResult($context, $constraint, $status, $message);
163 163
 	}
164 164
 
165 165
 	private function formatMessage(
@@ -171,42 +171,42 @@  discard block
 block discarded – undo
171 171
 		string $constraintTypeItemId
172 172
 	): ?ViolationMessage {
173 173
 		$message = null;
174
-		if ( $status === CheckResult::STATUS_VIOLATION ) {
175
-			$message = ( new ViolationMessage( 'wbqc-violation-message-format-clarification' ) )
176
-				->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY )
177
-				->withDataValue( new StringValue( $text ), Role::OBJECT )
178
-				->withInlineCode( $format, Role::CONSTRAINT_PARAMETER_VALUE )
179
-				->withMultilingualText( $syntaxClarifications, Role::CONSTRAINT_PARAMETER_VALUE );
180
-		} elseif ( $status === CheckResult::STATUS_TODO ) {
181
-			$message = ( new ViolationMessage( 'wbqc-violation-message-security-reason' ) )
182
-				->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM );
174
+		if ($status === CheckResult::STATUS_VIOLATION) {
175
+			$message = (new ViolationMessage('wbqc-violation-message-format-clarification'))
176
+				->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY)
177
+				->withDataValue(new StringValue($text), Role::OBJECT)
178
+				->withInlineCode($format, Role::CONSTRAINT_PARAMETER_VALUE)
179
+				->withMultilingualText($syntaxClarifications, Role::CONSTRAINT_PARAMETER_VALUE);
180
+		} elseif ($status === CheckResult::STATUS_TODO) {
181
+			$message = (new ViolationMessage('wbqc-violation-message-security-reason'))
182
+				->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM);
183 183
 		}
184 184
 
185 185
 		return $message;
186 186
 	}
187 187
 
188
-	private function runRegexCheck( string $text, string $format ): string {
189
-		if ( !$this->config->get( 'WBQualityConstraintsCheckFormatConstraint' ) ) {
188
+	private function runRegexCheck(string $text, string $format): string {
189
+		if (!$this->config->get('WBQualityConstraintsCheckFormatConstraint')) {
190 190
 			return CheckResult::STATUS_TODO;
191 191
 		}
192
-		if ( \array_key_exists( $format, $this->knownGoodPatternsAsKeys ) ) {
193
-			$checkResult = FormatCheckerHelper::runRegexCheck( $format, $text );
192
+		if (\array_key_exists($format, $this->knownGoodPatternsAsKeys)) {
193
+			$checkResult = FormatCheckerHelper::runRegexCheck($format, $text);
194 194
 		} elseif (
195
-			$this->config->get( 'WBQualityConstraintsFormatCheckerShellboxRatio' ) > (float)wfRandom()
195
+			$this->config->get('WBQualityConstraintsFormatCheckerShellboxRatio') > (float) wfRandom()
196 196
 		) {
197
-			$checkResult = $this->runRegexCheckUsingShellbox( $text, $format );
197
+			$checkResult = $this->runRegexCheckUsingShellbox($text, $format);
198 198
 		} else {
199
-			return $this->runRegexCheckUsingSparql( $text, $format );
199
+			return $this->runRegexCheckUsingSparql($text, $format);
200 200
 		}
201 201
 
202
-		if ( $checkResult === 1 ) {
202
+		if ($checkResult === 1) {
203 203
 			return CheckResult::STATUS_COMPLIANCE;
204
-		} elseif ( $checkResult === 0 ) {
204
+		} elseif ($checkResult === 0) {
205 205
 			return CheckResult::STATUS_VIOLATION;
206
-		} elseif ( $checkResult === false ) {
206
+		} elseif ($checkResult === false) {
207 207
 			throw new ConstraintParameterException(
208
-				( new ViolationMessage( 'wbqc-violation-message-parameter-regex' ) )
209
-					->withInlineCode( $format, Role::CONSTRAINT_PARAMETER_VALUE )
208
+				(new ViolationMessage('wbqc-violation-message-parameter-regex'))
209
+					->withInlineCode($format, Role::CONSTRAINT_PARAMETER_VALUE)
210 210
 			);
211 211
 		} else {
212 212
 			return $checkResult;
@@ -220,51 +220,51 @@  discard block
 block discarded – undo
220 220
 	 *   - FALSE if $format is invalid regex
221 221
 	 *   - CheckResult::STATUS_TODO if Shellbox is not enabled
222 222
 	 */
223
-	private function runRegexCheckUsingShellbox( string $text, string $format ) {
224
-		if ( !$this->shellboxClientFactory->isEnabled( 'constraint-regex-checker' ) ) {
223
+	private function runRegexCheckUsingShellbox(string $text, string $format) {
224
+		if (!$this->shellboxClientFactory->isEnabled('constraint-regex-checker')) {
225 225
 			return CheckResult::STATUS_TODO;
226 226
 		}
227 227
 
228 228
 		try {
229
-			return $this->shellboxClientFactory->getClient( [
230
-				'timeout' => $this->config->get( 'WBQualityConstraintsSparqlMaxMillis' ) / 1000,
229
+			return $this->shellboxClientFactory->getClient([
230
+				'timeout' => $this->config->get('WBQualityConstraintsSparqlMaxMillis') / 1000,
231 231
 				'service' => 'constraint-regex-checker',
232
-			] )->call(
232
+			])->call(
233 233
 				'constraint-regex-checker',
234
-				[ FormatCheckerHelper::class, 'runRegexCheck' ],
235
-				[ $format, $text ],
236
-				[ 'classes' => [ FormatCheckerHelper::class ] ],
234
+				[FormatCheckerHelper::class, 'runRegexCheck'],
235
+				[$format, $text],
236
+				['classes' => [FormatCheckerHelper::class]],
237 237
 			);
238
-		} catch ( ClientExceptionInterface $ce ) {
239
-			$this->logger->notice( __METHOD__ . ': Network error, skipping check: {exception}', [
238
+		} catch (ClientExceptionInterface $ce) {
239
+			$this->logger->notice(__METHOD__.': Network error, skipping check: {exception}', [
240 240
 				'exception' => $ce,
241 241
 				'text' => $text,
242 242
 				'format' => $format,
243
-			] );
243
+			]);
244 244
 			return CheckResult::STATUS_TODO;
245
-		} catch ( ShellboxError $e ) {
246
-			$this->logger->error( __METHOD__ . ': Shellbox error, skipping check: {exception}', [
245
+		} catch (ShellboxError $e) {
246
+			$this->logger->error(__METHOD__.': Shellbox error, skipping check: {exception}', [
247 247
 				'exception' => $e,
248 248
 				'text' => $text,
249 249
 				'format' => $format,
250
-			] );
250
+			]);
251 251
 			return CheckResult::STATUS_TODO;
252 252
 		}
253 253
 	}
254 254
 
255
-	private function runRegexCheckUsingSparql( string $text, string $format ): string {
256
-		if ( $this->sparqlHelper instanceof DummySparqlHelper ) {
255
+	private function runRegexCheckUsingSparql(string $text, string $format): string {
256
+		if ($this->sparqlHelper instanceof DummySparqlHelper) {
257 257
 			return CheckResult::STATUS_TODO;
258 258
 		}
259 259
 
260
-		if ( $this->sparqlHelper->matchesRegularExpression( $text, $format ) ) {
260
+		if ($this->sparqlHelper->matchesRegularExpression($text, $format)) {
261 261
 			return CheckResult::STATUS_COMPLIANCE;
262 262
 		} else {
263 263
 			return CheckResult::STATUS_VIOLATION;
264 264
 		}
265 265
 	}
266 266
 
267
-	public function checkConstraintParameters( Constraint $constraint ): array {
267
+	public function checkConstraintParameters(Constraint $constraint): array {
268 268
 		$constraintParameters = $constraint->getConstraintParameters();
269 269
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
270 270
 		$exceptions = [];
@@ -273,14 +273,14 @@  discard block
 block discarded – undo
273 273
 				$constraintParameters,
274 274
 				$constraintTypeItemId
275 275
 			);
276
-		} catch ( ConstraintParameterException $e ) {
276
+		} catch (ConstraintParameterException $e) {
277 277
 			$exceptions[] = $e;
278 278
 		}
279 279
 		try {
280 280
 			$this->constraintParameterParser->parseSyntaxClarificationParameter(
281 281
 				$constraintParameters
282 282
 			);
283
-		} catch ( ConstraintParameterException $e ) {
283
+		} catch (ConstraintParameterException $e) {
284 284
 			$exceptions[] = $e;
285 285
 		}
286 286
 		return $exceptions;
Please login to merge, or discard this patch.
src/Specials/SpecialConstraintReport.php 1 patch
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\Specials;
6 6
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		Config $config,
92 92
 		StatsFactory $statsFactory
93 93
 	) {
94
-		parent::__construct( 'ConstraintReport' );
94
+		parent::__construct('ConstraintReport');
95 95
 
96 96
 		$this->entityLookup = $entityLookup;
97 97
 		$this->entityTitleLookup = $entityTitleLookup;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 
112 112
 		$this->violationMessageRenderer = $violationMessageRendererFactory->getViolationMessageRenderer(
113 113
 			$language,
114
-			$languageFallbackChainFactory->newFromLanguage( $language ),
114
+			$languageFallbackChainFactory->newFromLanguage($language),
115 115
 			$this->getContext()
116 116
 		);
117 117
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @inheritDoc
146 146
 	 */
147 147
 	public function getDescription() {
148
-		return $this->msg( 'wbqc-constraintreport' );
148
+		return $this->msg('wbqc-constraintreport');
149 149
 	}
150 150
 
151 151
 	/**
@@ -157,75 +157,75 @@  discard block
 block discarded – undo
157 157
 	 * @throws EntityIdParsingException
158 158
 	 * @throws UnexpectedValueException
159 159
 	 */
160
-	public function execute( $subPage ) {
160
+	public function execute($subPage) {
161 161
 		$out = $this->getOutput();
162 162
 
163
-		$postRequest = $this->getContext()->getRequest()->getVal( 'entityid' );
164
-		if ( $postRequest ) {
163
+		$postRequest = $this->getContext()->getRequest()->getVal('entityid');
164
+		if ($postRequest) {
165 165
 			try {
166
-				$entityId = $this->entityIdParser->parse( $postRequest );
167
-				$out->redirect( $this->getPageTitle( $entityId->getSerialization() )->getLocalURL() );
166
+				$entityId = $this->entityIdParser->parse($postRequest);
167
+				$out->redirect($this->getPageTitle($entityId->getSerialization())->getLocalURL());
168 168
 				return;
169
-			} catch ( EntityIdParsingException $e ) {
169
+			} catch (EntityIdParsingException $e) {
170 170
 				// fall through, error is shown later
171 171
 			}
172 172
 		}
173 173
 
174 174
 		$out->enableOOUI();
175
-		$out->addModules( $this->getModules() );
175
+		$out->addModules($this->getModules());
176 176
 
177 177
 		$this->setHeaders();
178 178
 
179
-		$out->addHTML( $this->getExplanationText() );
179
+		$out->addHTML($this->getExplanationText());
180 180
 		$this->buildEntityIdForm();
181 181
 
182
-		if ( $postRequest ) {
182
+		if ($postRequest) {
183 183
 			// must be an invalid entity ID (otherwise we would have redirected and returned above)
184 184
 			$out->addHTML(
185
-				$this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true )
185
+				$this->buildNotice('wbqc-constraintreport-invalid-entity-id', true)
186 186
 			);
187 187
 			return;
188 188
 		}
189 189
 
190
-		if ( !$subPage ) {
190
+		if (!$subPage) {
191 191
 			return;
192 192
 		}
193 193
 
194
-		if ( !is_string( $subPage ) ) {
195
-			throw new InvalidArgumentException( '$subPage must be string.' );
194
+		if (!is_string($subPage)) {
195
+			throw new InvalidArgumentException('$subPage must be string.');
196 196
 		}
197 197
 
198 198
 		try {
199
-			$entityId = $this->entityIdParser->parse( $subPage );
200
-		} catch ( EntityIdParsingException $e ) {
199
+			$entityId = $this->entityIdParser->parse($subPage);
200
+		} catch (EntityIdParsingException $e) {
201 201
 			$out->addHTML(
202
-				$this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true )
202
+				$this->buildNotice('wbqc-constraintreport-invalid-entity-id', true)
203 203
 			);
204 204
 			return;
205 205
 		}
206 206
 
207
-		if ( !$this->entityLookup->hasEntity( $entityId ) ) {
207
+		if (!$this->entityLookup->hasEntity($entityId)) {
208 208
 			$out->addHTML(
209
-				$this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true )
209
+				$this->buildNotice('wbqc-constraintreport-not-existent-entity', true)
210 210
 			);
211 211
 			return;
212 212
 		}
213 213
 
214 214
 		$baseKey = 'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck';
215
-		$metric = $this->statsFactory->getCounter( 'special_constraint_report_execute_check_total' );
216
-		$metric->copyToStatsdAt( $baseKey )->increment();
217
-		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId );
215
+		$metric = $this->statsFactory->getCounter('special_constraint_report_execute_check_total');
216
+		$metric->copyToStatsdAt($baseKey)->increment();
217
+		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId);
218 218
 
219
-		if ( $results !== [] ) {
219
+		if ($results !== []) {
220 220
 			$out->addHTML(
221
-				$this->buildResultHeader( $entityId )
222
-				. $this->buildSummary( $results )
223
-				. $this->buildResultTable( $entityId, $results )
221
+				$this->buildResultHeader($entityId)
222
+				. $this->buildSummary($results)
223
+				. $this->buildResultTable($entityId, $results)
224 224
 			);
225 225
 		} else {
226 226
 			$out->addHTML(
227
-				$this->buildResultHeader( $entityId )
228
-				. $this->buildNotice( 'wbqc-constraintreport-empty-result' )
227
+				$this->buildResultHeader($entityId)
228
+				. $this->buildNotice('wbqc-constraintreport-empty-result')
229 229
 			);
230 230
 		}
231 231
 	}
@@ -241,16 +241,16 @@  discard block
 block discarded – undo
241 241
 				'name' => 'entityid',
242 242
 				'label-message' => 'wbqc-constraintreport-form-entityid-label',
243 243
 				'cssclass' => 'wbqc-constraintreport-form-entity-id',
244
-				'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped(),
244
+				'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped(),
245 245
 				'required' => true,
246 246
 			],
247 247
 		];
248
-		$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' );
249
-		$htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() );
250
-		$htmlForm->setSubmitCallback( static function () {
248
+		$htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form');
249
+		$htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped());
250
+		$htmlForm->setSubmitCallback(static function() {
251 251
 			return false;
252 252
 		} );
253
-		$htmlForm->setMethod( 'post' );
253
+		$htmlForm->setMethod('post');
254 254
 		$htmlForm->show();
255 255
 	}
256 256
 
@@ -264,9 +264,9 @@  discard block
 block discarded – undo
264 264
 	 *
265 265
 	 * @return string HTML
266 266
 	 */
267
-	private function buildNotice( string $messageKey, bool $error = false ): string {
267
+	private function buildNotice(string $messageKey, bool $error = false): string {
268 268
 		$cssClasses = 'wbqc-constraintreport-notice';
269
-		if ( $error ) {
269
+		if ($error) {
270 270
 			$cssClasses .= ' wbqc-constraintreport-notice-error';
271 271
 		}
272 272
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 				[
276 276
 					'class' => $cssClasses,
277 277
 				],
278
-				$this->msg( $messageKey )->escaped()
278
+				$this->msg($messageKey)->escaped()
279 279
 			);
280 280
 	}
281 281
 
@@ -285,16 +285,16 @@  discard block
 block discarded – undo
285 285
 	private function getExplanationText(): string {
286 286
 		return Html::rawElement(
287 287
 			'div',
288
-			[ 'class' => 'wbqc-explanation' ],
288
+			['class' => 'wbqc-explanation'],
289 289
 			Html::rawElement(
290 290
 				'p',
291 291
 				[],
292
-				$this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped()
292
+				$this->msg('wbqc-constraintreport-explanation-part-one')->escaped()
293 293
 			)
294 294
 			. Html::rawElement(
295 295
 				'p',
296 296
 				[],
297
-				$this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped()
297
+				$this->msg('wbqc-constraintreport-explanation-part-two')->escaped()
298 298
 			)
299 299
 		);
300 300
 	}
@@ -305,31 +305,31 @@  discard block
 block discarded – undo
305 305
 	 *
306 306
 	 * @return string HTML
307 307
 	 */
308
-	private function buildResultTable( EntityId $entityId, array $results ): string {
308
+	private function buildResultTable(EntityId $entityId, array $results): string {
309 309
 		// Set table headers
310 310
 		$table = new HtmlTableBuilder(
311 311
 			[
312 312
 				new HtmlTableHeaderBuilder(
313
-					$this->msg( 'wbqc-constraintreport-result-table-header-status' )->text(),
313
+					$this->msg('wbqc-constraintreport-result-table-header-status')->text(),
314 314
 					true
315 315
 				),
316 316
 				new HtmlTableHeaderBuilder(
317
-					$this->msg( 'wbqc-constraintreport-result-table-header-property' )->text(),
317
+					$this->msg('wbqc-constraintreport-result-table-header-property')->text(),
318 318
 					true
319 319
 				),
320 320
 				new HtmlTableHeaderBuilder(
321
-					$this->msg( 'wbqc-constraintreport-result-table-header-message' )->text(),
321
+					$this->msg('wbqc-constraintreport-result-table-header-message')->text(),
322 322
 					true
323 323
 				),
324 324
 				new HtmlTableHeaderBuilder(
325
-					$this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->text(),
325
+					$this->msg('wbqc-constraintreport-result-table-header-constraint')->text(),
326 326
 					true
327 327
 				),
328 328
 			]
329 329
 		);
330 330
 
331
-		foreach ( $results as $result ) {
332
-			$table = $this->appendToResultTable( $table, $entityId, $result );
331
+		foreach ($results as $result) {
332
+			$table = $this->appendToResultTable($table, $entityId, $result);
333 333
 		}
334 334
 
335 335
 		return $table->toHtml();
@@ -341,35 +341,35 @@  discard block
 block discarded – undo
341 341
 		CheckResult $result
342 342
 	): HtmlTableBuilder {
343 343
 		$message = $result->getMessage();
344
-		if ( $message === null ) {
344
+		if ($message === null) {
345 345
 			// no row for this result
346 346
 			return $table;
347 347
 		}
348 348
 
349 349
 		// Status column
350
-		$statusColumn = $this->formatStatus( $result->getStatus() );
350
+		$statusColumn = $this->formatStatus($result->getStatus());
351 351
 
352 352
 		// Property column
353
-		$propertyId = new NumericPropertyId( $result->getContextCursor()->getSnakPropertyId() );
353
+		$propertyId = new NumericPropertyId($result->getContextCursor()->getSnakPropertyId());
354 354
 		$propertyColumn = $this->getClaimLink(
355 355
 			$entityId,
356 356
 			$propertyId,
357
-			$this->entityIdLabelFormatter->formatEntityId( $propertyId )
357
+			$this->entityIdLabelFormatter->formatEntityId($propertyId)
358 358
 		);
359 359
 
360 360
 		// Message column
361
-		$messageColumn = $this->violationMessageRenderer->render( $message );
361
+		$messageColumn = $this->violationMessageRenderer->render($message);
362 362
 
363 363
 		// Constraint column
364 364
 		$constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId();
365 365
 		try {
366
-			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) );
367
-		} catch ( InvalidArgumentException $e ) {
368
-			$constraintTypeLabel = htmlspecialchars( $constraintTypeItemId );
366
+			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId));
367
+		} catch (InvalidArgumentException $e) {
368
+			$constraintTypeLabel = htmlspecialchars($constraintTypeItemId);
369 369
 		}
370 370
 		$constraintColumn = $this->getClaimLink(
371 371
 			$propertyId,
372
-			new NumericPropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ),
372
+			new NumericPropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')),
373 373
 			$constraintTypeLabel
374 374
 		);
375 375
 
@@ -377,16 +377,16 @@  discard block
 block discarded – undo
377 377
 		$table->appendRow(
378 378
 			[
379 379
 				new HtmlTableCellBuilder(
380
-					new HtmlArmor( $statusColumn )
380
+					new HtmlArmor($statusColumn)
381 381
 				),
382 382
 				new HtmlTableCellBuilder(
383
-					new HtmlArmor( $propertyColumn )
383
+					new HtmlArmor($propertyColumn)
384 384
 				),
385 385
 				new HtmlTableCellBuilder(
386
-					new HtmlArmor( $messageColumn )
386
+					new HtmlArmor($messageColumn)
387 387
 				),
388 388
 				new HtmlTableCellBuilder(
389
-					new HtmlArmor( $constraintColumn )
389
+					new HtmlArmor($constraintColumn)
390 390
 				),
391 391
 			]
392 392
 		);
@@ -401,15 +401,15 @@  discard block
 block discarded – undo
401 401
 	 *
402 402
 	 * @return string HTML
403 403
 	 */
404
-	protected function buildResultHeader( EntityId $entityId ): string {
405
-		$entityLink = sprintf( '%s (%s)',
406
-							   $this->entityIdLinkFormatter->formatEntityId( $entityId ),
407
-							   htmlspecialchars( $entityId->getSerialization() ) );
404
+	protected function buildResultHeader(EntityId $entityId): string {
405
+		$entityLink = sprintf('%s (%s)',
406
+							   $this->entityIdLinkFormatter->formatEntityId($entityId),
407
+							   htmlspecialchars($entityId->getSerialization()));
408 408
 
409 409
 		return Html::rawElement(
410 410
 			'h3',
411 411
 			[],
412
-			sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
412
+			sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink)
413 413
 		);
414 414
 	}
415 415
 
@@ -420,24 +420,24 @@  discard block
 block discarded – undo
420 420
 	 *
421 421
 	 * @return string HTML
422 422
 	 */
423
-	protected function buildSummary( array $results ): string {
423
+	protected function buildSummary(array $results): string {
424 424
 		$statuses = [];
425
-		foreach ( $results as $result ) {
426
-			$status = strtolower( $result->getStatus() );
427
-			$statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1;
425
+		foreach ($results as $result) {
426
+			$status = strtolower($result->getStatus());
427
+			$statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1;
428 428
 		}
429 429
 
430 430
 		$statusElements = [];
431
-		foreach ( $statuses as $status => $count ) {
432
-			if ( $count > 0 ) {
431
+		foreach ($statuses as $status => $count) {
432
+			if ($count > 0) {
433 433
 				$statusElements[] =
434
-					$this->formatStatus( $status )
434
+					$this->formatStatus($status)
435 435
 					. ': '
436 436
 					. $count;
437 437
 			}
438 438
 		}
439 439
 
440
-		return Html::rawElement( 'p', [], implode( ', ', $statusElements ) );
440
+		return Html::rawElement('p', [], implode(', ', $statusElements));
441 441
 	}
442 442
 
443 443
 	/**
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
 	 *
450 450
 	 * @return string HTML
451 451
 	 */
452
-	private function formatStatus( string $status ): string {
453
-		$messageName = "wbqc-constraintreport-status-" . strtolower( $status );
452
+	private function formatStatus(string $status): string {
453
+		$messageName = "wbqc-constraintreport-status-".strtolower($status);
454 454
 		$statusIcons = [
455 455
 			CheckResult::STATUS_SUGGESTION => [
456 456
 				'icon' => 'suggestion-constraint-violation',
@@ -467,25 +467,25 @@  discard block
 block discarded – undo
467 467
 			],
468 468
 		];
469 469
 
470
-		if ( array_key_exists( $status, $statusIcons ) ) {
471
-			$iconWidget = new IconWidget( $statusIcons[$status] );
472
-			$iconHtml = $iconWidget->toString() . ' ';
470
+		if (array_key_exists($status, $statusIcons)) {
471
+			$iconWidget = new IconWidget($statusIcons[$status]);
472
+			$iconHtml = $iconWidget->toString().' ';
473 473
 		} else {
474 474
 			$iconHtml = '';
475 475
 		}
476 476
 
477
-		$labelWidget = new LabelWidget( [
478
-			'label' => $this->msg( $messageName )->text(),
479
-		] );
477
+		$labelWidget = new LabelWidget([
478
+			'label' => $this->msg($messageName)->text(),
479
+		]);
480 480
 		$labelHtml = $labelWidget->toString();
481 481
 
482 482
 		$formattedStatus =
483 483
 			Html::rawElement(
484 484
 				'span',
485 485
 				[
486
-					'class' => 'wbqc-status wbqc-status-' . $status,
486
+					'class' => 'wbqc-status wbqc-status-'.$status,
487 487
 				],
488
-				$iconHtml . $labelHtml
488
+				$iconHtml.$labelHtml
489 489
 			);
490 490
 
491 491
 		return $formattedStatus;
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 		return Html::rawElement(
509 509
 			'a',
510 510
 			[
511
-				'href' => $this->getClaimUrl( $entityId, $propertyId ),
511
+				'href' => $this->getClaimUrl($entityId, $propertyId),
512 512
 				'target' => '_blank',
513 513
 			],
514 514
 			$text
@@ -522,8 +522,8 @@  discard block
 block discarded – undo
522 522
 		EntityId $entityId,
523 523
 		NumericPropertyId $propertyId
524 524
 	): string {
525
-		$title = $this->entityTitleLookup->getTitleForId( $entityId );
526
-		$entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() );
525
+		$title = $this->entityTitleLookup->getTitleForId($entityId);
526
+		$entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization());
527 527
 
528 528
 		return $entityUrl;
529 529
 	}
Please login to merge, or discard this patch.
src/ServiceWiring.php 1 patch
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -31,58 +31,58 @@  discard block
 block discarded – undo
31 31
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer;
32 32
 
33 33
 return [
34
-	ConstraintsServices::EXPIRY_LOCK => static function ( MediaWikiServices $services ): ExpiryLock {
35
-		return new ExpiryLock( $services->getObjectCacheFactory()->getInstance( CACHE_ANYTHING ) );
34
+	ConstraintsServices::EXPIRY_LOCK => static function(MediaWikiServices $services): ExpiryLock {
35
+		return new ExpiryLock($services->getObjectCacheFactory()->getInstance(CACHE_ANYTHING));
36 36
 	},
37 37
 
38
-	ConstraintsServices::LOGGER => static function ( MediaWikiServices $services ): LoggerInterface {
39
-		return LoggerFactory::getInstance( 'WikibaseQualityConstraints' );
38
+	ConstraintsServices::LOGGER => static function(MediaWikiServices $services): LoggerInterface {
39
+		return LoggerFactory::getInstance('WikibaseQualityConstraints');
40 40
 	},
41 41
 
42
-	ConstraintsServices::LOGGING_HELPER => static function ( MediaWikiServices $services ): LoggingHelper {
42
+	ConstraintsServices::LOGGING_HELPER => static function(MediaWikiServices $services): LoggingHelper {
43 43
 		return new LoggingHelper(
44
-			$services->getStatsFactory()->withComponent( 'WikibaseQualityConstraints' ),
45
-			LoggerFactory::getInstance( 'WikibaseQualityConstraints' ),
44
+			$services->getStatsFactory()->withComponent('WikibaseQualityConstraints'),
45
+			LoggerFactory::getInstance('WikibaseQualityConstraints'),
46 46
 			$services->getMainConfig()
47 47
 		);
48 48
 	},
49 49
 
50
-	ConstraintsServices::CONSTRAINT_STORE => static function ( MediaWikiServices $services ): ConstraintRepositoryStore {
51
-		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services );
52
-		$propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE );
53
-		if ( $propertySource === null ) {
54
-			throw new RuntimeException( 'Can\'t get a ConstraintStore for properties not stored in a database.' );
50
+	ConstraintsServices::CONSTRAINT_STORE => static function(MediaWikiServices $services): ConstraintRepositoryStore {
51
+		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services);
52
+		$propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE);
53
+		if ($propertySource === null) {
54
+			throw new RuntimeException('Can\'t get a ConstraintStore for properties not stored in a database.');
55 55
 		}
56 56
 
57
-		$localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName();
58
-		if ( $propertySource->getSourceName() !== $localEntitySourceName ) {
59
-			throw new RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' );
57
+		$localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName();
58
+		if ($propertySource->getSourceName() !== $localEntitySourceName) {
59
+			throw new RuntimeException('Can\'t get a ConstraintStore for a non local entity source.');
60 60
 		}
61 61
 
62 62
 		$dbName = $propertySource->getDatabaseName();
63 63
 		return new ConstraintRepositoryStore(
64
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
64
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
65 65
 			$dbName
66 66
 		);
67 67
 	},
68 68
 
69
-	ConstraintsServices::CONSTRAINT_LOOKUP => static function ( MediaWikiServices $services ): ConstraintLookup {
70
-		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services );
71
-		$propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE );
72
-		if ( $propertySource === null ) {
73
-			throw new RuntimeException( 'Can\'t get a ConstraintStore for properties not stored in a database.' );
69
+	ConstraintsServices::CONSTRAINT_LOOKUP => static function(MediaWikiServices $services): ConstraintLookup {
70
+		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services);
71
+		$propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE);
72
+		if ($propertySource === null) {
73
+			throw new RuntimeException('Can\'t get a ConstraintStore for properties not stored in a database.');
74 74
 		}
75 75
 
76 76
 		$dbName = $propertySource->getDatabaseName();
77 77
 		$rawLookup = new ConstraintRepositoryLookup(
78
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
78
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
79 79
 			$dbName,
80
-			ConstraintsServices::getLogger( $services )
80
+			ConstraintsServices::getLogger($services)
81 81
 		);
82
-		return new CachingConstraintLookup( $rawLookup );
82
+		return new CachingConstraintLookup($rawLookup);
83 83
 	},
84 84
 
85
-	ConstraintsServices::CHECK_RESULT_SERIALIZER => static function ( MediaWikiServices $services ): CheckResultSerializer {
85
+	ConstraintsServices::CHECK_RESULT_SERIALIZER => static function(MediaWikiServices $services): CheckResultSerializer {
86 86
 		return new CheckResultSerializer(
87 87
 			new ConstraintSerializer(
88 88
 				false // constraint parameters are not exposed
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
 		);
94 94
 	},
95 95
 
96
-	ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function ( MediaWikiServices $services ): CheckResultDeserializer {
97
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
98
-		$dataValueFactory = WikibaseRepo::getDataValueFactory( $services );
96
+	ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function(MediaWikiServices $services): CheckResultDeserializer {
97
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
98
+		$dataValueFactory = WikibaseRepo::getDataValueFactory($services);
99 99
 
100 100
 		return new CheckResultDeserializer(
101 101
 			new ConstraintDeserializer(),
@@ -108,17 +108,17 @@  discard block
 block discarded – undo
108 108
 		);
109 109
 	},
110 110
 
111
-	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function (
111
+	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function(
112 112
 		MediaWikiServices $services
113 113
 	): ViolationMessageSerializer {
114 114
 		return new ViolationMessageSerializer();
115 115
 	},
116 116
 
117
-	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function (
117
+	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function(
118 118
 		MediaWikiServices $services
119 119
 	): ViolationMessageDeserializer {
120
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
121
-		$dataValueFactory = WikibaseRepo::getDataValueFactory( $services );
120
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
121
+		$dataValueFactory = WikibaseRepo::getDataValueFactory($services);
122 122
 
123 123
 		return new ViolationMessageDeserializer(
124 124
 			$entityIdParser,
@@ -126,40 +126,40 @@  discard block
 block discarded – undo
126 126
 		);
127 127
 	},
128 128
 
129
-	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function (
129
+	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function(
130 130
 		MediaWikiServices $services
131 131
 	): ConstraintParameterParser {
132
-		$deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory( $services );
133
-		$entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services );
132
+		$deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory($services);
133
+		$entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services);
134 134
 
135 135
 		return new ConstraintParameterParser(
136 136
 			$services->getMainConfig(),
137 137
 			$deserializerFactory,
138
-			$entitySourceDefinitions->getDatabaseSourceForEntityType( 'item' )->getConceptBaseUri()
138
+			$entitySourceDefinitions->getDatabaseSourceForEntityType('item')->getConceptBaseUri()
139 139
 		);
140 140
 	},
141 141
 
142
-	ConstraintsServices::CONNECTION_CHECKER_HELPER => static function ( MediaWikiServices $services ): ConnectionCheckerHelper {
142
+	ConstraintsServices::CONNECTION_CHECKER_HELPER => static function(MediaWikiServices $services): ConnectionCheckerHelper {
143 143
 		return new ConnectionCheckerHelper();
144 144
 	},
145 145
 
146
-	ConstraintsServices::RANGE_CHECKER_HELPER => static function ( MediaWikiServices $services ): RangeCheckerHelper {
146
+	ConstraintsServices::RANGE_CHECKER_HELPER => static function(MediaWikiServices $services): RangeCheckerHelper {
147 147
 		return new RangeCheckerHelper(
148 148
 			$services->getMainConfig(),
149
-			WikibaseRepo::getUnitConverter( $services )
149
+			WikibaseRepo::getUnitConverter($services)
150 150
 		);
151 151
 	},
152 152
 
153
-	ConstraintsServices::SPARQL_HELPER => static function ( MediaWikiServices $services ): SparqlHelper {
154
-		$endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' );
155
-		if ( $endpoint === '' ) {
153
+	ConstraintsServices::SPARQL_HELPER => static function(MediaWikiServices $services): SparqlHelper {
154
+		$endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint');
155
+		if ($endpoint === '') {
156 156
 			return new DummySparqlHelper();
157 157
 		}
158 158
 
159
-		$rdfVocabulary = WikibaseRepo::getRdfVocabulary( $services );
160
-		$valueSnakRdfBuilderFactory = WikibaseRepo::getValueSnakRdfBuilderFactory( $services );
161
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
162
-		$propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup( $services );
159
+		$rdfVocabulary = WikibaseRepo::getRdfVocabulary($services);
160
+		$valueSnakRdfBuilderFactory = WikibaseRepo::getValueSnakRdfBuilderFactory($services);
161
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
162
+		$propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup($services);
163 163
 
164 164
 		return new SparqlHelper(
165 165
 			$services->getMainConfig(),
@@ -168,128 +168,128 @@  discard block
 block discarded – undo
168 168
 			$entityIdParser,
169 169
 			$propertyDataTypeLookup,
170 170
 			$services->getMainWANObjectCache(),
171
-			ConstraintsServices::getViolationMessageSerializer( $services ),
172
-			ConstraintsServices::getViolationMessageDeserializer( $services ),
173
-			$services->getStatsFactory()->withComponent( 'WikibaseQualityConstraints' ),
174
-			ConstraintsServices::getExpiryLock( $services ),
175
-			ConstraintsServices::getLoggingHelper( $services ),
176
-			WikiMap::getCurrentWikiId() . ' WikibaseQualityConstraints ' . $services->getHttpRequestFactory()->getUserAgent(),
171
+			ConstraintsServices::getViolationMessageSerializer($services),
172
+			ConstraintsServices::getViolationMessageDeserializer($services),
173
+			$services->getStatsFactory()->withComponent('WikibaseQualityConstraints'),
174
+			ConstraintsServices::getExpiryLock($services),
175
+			ConstraintsServices::getLoggingHelper($services),
176
+			WikiMap::getCurrentWikiId().' WikibaseQualityConstraints '.$services->getHttpRequestFactory()->getUserAgent(),
177 177
 			$services->getHttpRequestFactory()
178 178
 		);
179 179
 	},
180 180
 
181
-	ConstraintsServices::TYPE_CHECKER_HELPER => static function ( MediaWikiServices $services ): TypeCheckerHelper {
181
+	ConstraintsServices::TYPE_CHECKER_HELPER => static function(MediaWikiServices $services): TypeCheckerHelper {
182 182
 		return new TypeCheckerHelper(
183
-			WikibaseServices::getEntityLookup( $services ),
183
+			WikibaseServices::getEntityLookup($services),
184 184
 			$services->getMainConfig(),
185
-			ConstraintsServices::getSparqlHelper( $services ),
186
-			$services->getStatsFactory()->withComponent( 'WikibaseQualityConstraints' )
185
+			ConstraintsServices::getSparqlHelper($services),
186
+			$services->getStatsFactory()->withComponent('WikibaseQualityConstraints')
187 187
 		);
188 188
 	},
189 189
 
190
-	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function (
190
+	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function(
191 191
 		MediaWikiServices $services
192 192
 	): DelegatingConstraintChecker {
193
-		$statementGuidParser = WikibaseRepo::getStatementGuidParser( $services );
193
+		$statementGuidParser = WikibaseRepo::getStatementGuidParser($services);
194 194
 
195 195
 		$config = $services->getMainConfig();
196 196
 		$checkerMap = [
197
-			$config->get( 'WBQualityConstraintsConflictsWithConstraintId' )
198
-				=> ConstraintCheckerServices::getConflictsWithChecker( $services ),
199
-			$config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' )
200
-				=> ConstraintCheckerServices::getItemChecker( $services ),
201
-			$config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' )
202
-				=> ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ),
203
-			$config->get( 'WBQualityConstraintsSymmetricConstraintId' )
204
-				=> ConstraintCheckerServices::getSymmetricChecker( $services ),
205
-			$config->get( 'WBQualityConstraintsInverseConstraintId' )
206
-				=> ConstraintCheckerServices::getInverseChecker( $services ),
207
-			$config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' )
208
-				=> ConstraintCheckerServices::getQualifierChecker( $services ),
209
-			$config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' )
210
-				=> ConstraintCheckerServices::getQualifiersChecker( $services ),
211
-			$config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' )
212
-				=> ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ),
213
-			$config->get( 'WBQualityConstraintsRangeConstraintId' )
214
-				=> ConstraintCheckerServices::getRangeChecker( $services ),
215
-			$config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' )
216
-				=> ConstraintCheckerServices::getDiffWithinRangeChecker( $services ),
217
-			$config->get( 'WBQualityConstraintsTypeConstraintId' )
218
-				=> ConstraintCheckerServices::getTypeChecker( $services ),
219
-			$config->get( 'WBQualityConstraintsValueTypeConstraintId' )
220
-				=> ConstraintCheckerServices::getValueTypeChecker( $services ),
221
-			$config->get( 'WBQualityConstraintsSingleValueConstraintId' )
222
-				=> ConstraintCheckerServices::getSingleValueChecker( $services ),
223
-			$config->get( 'WBQualityConstraintsMultiValueConstraintId' )
224
-				=> ConstraintCheckerServices::getMultiValueChecker( $services ),
225
-			$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' )
226
-				=> ConstraintCheckerServices::getUniqueValueChecker( $services ),
227
-			$config->get( 'WBQualityConstraintsFormatConstraintId' )
228
-				=> ConstraintCheckerServices::getFormatChecker( $services ),
229
-			$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' )
230
-				=> ConstraintCheckerServices::getCommonsLinkChecker( $services ),
231
-			$config->get( 'WBQualityConstraintsOneOfConstraintId' )
232
-				=> ConstraintCheckerServices::getOneOfChecker( $services ),
233
-			$config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' )
234
-				=> ConstraintCheckerServices::getValueOnlyChecker( $services ),
235
-			$config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' )
236
-				=> ConstraintCheckerServices::getReferenceChecker( $services ),
237
-			$config->get( 'WBQualityConstraintsNoBoundsConstraintId' )
238
-				=> ConstraintCheckerServices::getNoBoundsChecker( $services ),
239
-			$config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' )
240
-				=> ConstraintCheckerServices::getAllowedUnitsChecker( $services ),
241
-			$config->get( 'WBQualityConstraintsSingleBestValueConstraintId' )
242
-				=> ConstraintCheckerServices::getSingleBestValueChecker( $services ),
243
-			$config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' )
244
-				=> ConstraintCheckerServices::getEntityTypeChecker( $services ),
245
-			$config->get( 'WBQualityConstraintsNoneOfConstraintId' )
246
-				=> ConstraintCheckerServices::getNoneOfChecker( $services ),
247
-			$config->get( 'WBQualityConstraintsIntegerConstraintId' )
248
-				=> ConstraintCheckerServices::getIntegerChecker( $services ),
249
-			$config->get( 'WBQualityConstraintsCitationNeededConstraintId' )
250
-				=> ConstraintCheckerServices::getCitationNeededChecker( $services ),
251
-			$config->get( 'WBQualityConstraintsPropertyScopeConstraintId' )
252
-				=> ConstraintCheckerServices::getPropertyScopeChecker( $services ),
253
-			$config->get( 'WBQualityConstraintsContemporaryConstraintId' )
254
-				=> ConstraintCheckerServices::getContemporaryChecker( $services ),
255
-			$config->get( 'WBQualityConstraintsLexemeLanguageConstraintId' )
256
-				=> ConstraintCheckerServices::getLexemeLanguageChecker( $services ),
257
-			$config->get( 'WBQualityConstraintsLabelInLanguageConstraintId' )
258
-				=> ConstraintCheckerServices::getLabelInLanguageChecker( $services ),
197
+			$config->get('WBQualityConstraintsConflictsWithConstraintId')
198
+				=> ConstraintCheckerServices::getConflictsWithChecker($services),
199
+			$config->get('WBQualityConstraintsItemRequiresClaimConstraintId')
200
+				=> ConstraintCheckerServices::getItemChecker($services),
201
+			$config->get('WBQualityConstraintsValueRequiresClaimConstraintId')
202
+				=> ConstraintCheckerServices::getTargetRequiredClaimChecker($services),
203
+			$config->get('WBQualityConstraintsSymmetricConstraintId')
204
+				=> ConstraintCheckerServices::getSymmetricChecker($services),
205
+			$config->get('WBQualityConstraintsInverseConstraintId')
206
+				=> ConstraintCheckerServices::getInverseChecker($services),
207
+			$config->get('WBQualityConstraintsUsedAsQualifierConstraintId')
208
+				=> ConstraintCheckerServices::getQualifierChecker($services),
209
+			$config->get('WBQualityConstraintsAllowedQualifiersConstraintId')
210
+				=> ConstraintCheckerServices::getQualifiersChecker($services),
211
+			$config->get('WBQualityConstraintsMandatoryQualifierConstraintId')
212
+				=> ConstraintCheckerServices::getMandatoryQualifiersChecker($services),
213
+			$config->get('WBQualityConstraintsRangeConstraintId')
214
+				=> ConstraintCheckerServices::getRangeChecker($services),
215
+			$config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId')
216
+				=> ConstraintCheckerServices::getDiffWithinRangeChecker($services),
217
+			$config->get('WBQualityConstraintsTypeConstraintId')
218
+				=> ConstraintCheckerServices::getTypeChecker($services),
219
+			$config->get('WBQualityConstraintsValueTypeConstraintId')
220
+				=> ConstraintCheckerServices::getValueTypeChecker($services),
221
+			$config->get('WBQualityConstraintsSingleValueConstraintId')
222
+				=> ConstraintCheckerServices::getSingleValueChecker($services),
223
+			$config->get('WBQualityConstraintsMultiValueConstraintId')
224
+				=> ConstraintCheckerServices::getMultiValueChecker($services),
225
+			$config->get('WBQualityConstraintsDistinctValuesConstraintId')
226
+				=> ConstraintCheckerServices::getUniqueValueChecker($services),
227
+			$config->get('WBQualityConstraintsFormatConstraintId')
228
+				=> ConstraintCheckerServices::getFormatChecker($services),
229
+			$config->get('WBQualityConstraintsCommonsLinkConstraintId')
230
+				=> ConstraintCheckerServices::getCommonsLinkChecker($services),
231
+			$config->get('WBQualityConstraintsOneOfConstraintId')
232
+				=> ConstraintCheckerServices::getOneOfChecker($services),
233
+			$config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId')
234
+				=> ConstraintCheckerServices::getValueOnlyChecker($services),
235
+			$config->get('WBQualityConstraintsUsedAsReferenceConstraintId')
236
+				=> ConstraintCheckerServices::getReferenceChecker($services),
237
+			$config->get('WBQualityConstraintsNoBoundsConstraintId')
238
+				=> ConstraintCheckerServices::getNoBoundsChecker($services),
239
+			$config->get('WBQualityConstraintsAllowedUnitsConstraintId')
240
+				=> ConstraintCheckerServices::getAllowedUnitsChecker($services),
241
+			$config->get('WBQualityConstraintsSingleBestValueConstraintId')
242
+				=> ConstraintCheckerServices::getSingleBestValueChecker($services),
243
+			$config->get('WBQualityConstraintsAllowedEntityTypesConstraintId')
244
+				=> ConstraintCheckerServices::getEntityTypeChecker($services),
245
+			$config->get('WBQualityConstraintsNoneOfConstraintId')
246
+				=> ConstraintCheckerServices::getNoneOfChecker($services),
247
+			$config->get('WBQualityConstraintsIntegerConstraintId')
248
+				=> ConstraintCheckerServices::getIntegerChecker($services),
249
+			$config->get('WBQualityConstraintsCitationNeededConstraintId')
250
+				=> ConstraintCheckerServices::getCitationNeededChecker($services),
251
+			$config->get('WBQualityConstraintsPropertyScopeConstraintId')
252
+				=> ConstraintCheckerServices::getPropertyScopeChecker($services),
253
+			$config->get('WBQualityConstraintsContemporaryConstraintId')
254
+				=> ConstraintCheckerServices::getContemporaryChecker($services),
255
+			$config->get('WBQualityConstraintsLexemeLanguageConstraintId')
256
+				=> ConstraintCheckerServices::getLexemeLanguageChecker($services),
257
+			$config->get('WBQualityConstraintsLabelInLanguageConstraintId')
258
+				=> ConstraintCheckerServices::getLabelInLanguageChecker($services),
259 259
 		];
260 260
 
261 261
 		return new DelegatingConstraintChecker(
262
-			WikibaseServices::getEntityLookup( $services ),
262
+			WikibaseServices::getEntityLookup($services),
263 263
 			$checkerMap,
264
-			ConstraintsServices::getConstraintLookup( $services ),
265
-			ConstraintsServices::getConstraintParameterParser( $services ),
264
+			ConstraintsServices::getConstraintLookup($services),
265
+			ConstraintsServices::getConstraintParameterParser($services),
266 266
 			$statementGuidParser,
267
-			ConstraintsServices::getLoggingHelper( $services ),
268
-			$config->get( 'WBQualityConstraintsCheckQualifiers' ),
269
-			$config->get( 'WBQualityConstraintsCheckReferences' ),
270
-			$config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' )
267
+			ConstraintsServices::getLoggingHelper($services),
268
+			$config->get('WBQualityConstraintsCheckQualifiers'),
269
+			$config->get('WBQualityConstraintsCheckReferences'),
270
+			$config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers')
271 271
 		);
272 272
 	},
273 273
 
274
-	ConstraintsServices::RESULTS_SOURCE => static function ( MediaWikiServices $services ): ResultsSource {
274
+	ConstraintsServices::RESULTS_SOURCE => static function(MediaWikiServices $services): ResultsSource {
275 275
 		$config = $services->getMainConfig();
276 276
 		$resultsSource = new CheckingResultsSource(
277
-			ConstraintsServices::getDelegatingConstraintChecker( $services )
277
+			ConstraintsServices::getDelegatingConstraintChecker($services)
278 278
 		);
279 279
 
280 280
 		$cacheCheckConstraintsResults = false;
281 281
 
282
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
282
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
283 283
 			$cacheCheckConstraintsResults = true;
284 284
 			// check that we can use getLocalRepoWikiPageMetaDataAccessor()
285 285
 			// TODO we should always be able to cache constraint check results (T244726)
286
-			$entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources();
287
-			$localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName();
286
+			$entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources();
287
+			$localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName();
288 288
 
289
-			foreach ( $entitySources as $entitySource ) {
290
-				if ( $entitySource->getSourceName() !== $localEntitySourceName ) {
291
-					ConstraintsServices::getLogger( $services )->warning(
292
-						'Cannot cache constraint check results for non-local source: ' .
289
+			foreach ($entitySources as $entitySource) {
290
+				if ($entitySource->getSourceName() !== $localEntitySourceName) {
291
+					ConstraintsServices::getLogger($services)->warning(
292
+						'Cannot cache constraint check results for non-local source: '.
293 293
 						$entitySource->getSourceName()
294 294
 					);
295 295
 					$cacheCheckConstraintsResults = false;
@@ -298,42 +298,42 @@  discard block
 block discarded – undo
298 298
 			}
299 299
 		}
300 300
 
301
-		if ( $cacheCheckConstraintsResults ) {
301
+		if ($cacheCheckConstraintsResults) {
302 302
 			$possiblyStaleConstraintTypes = [
303
-				$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
304
-				$config->get( 'WBQualityConstraintsTypeConstraintId' ),
305
-				$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
306
-				$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
303
+				$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
304
+				$config->get('WBQualityConstraintsTypeConstraintId'),
305
+				$config->get('WBQualityConstraintsValueTypeConstraintId'),
306
+				$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
307 307
 			];
308
-			$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
308
+			$entityIdParser = WikibaseRepo::getEntityIdParser($services);
309 309
 			$wikiPageEntityMetaDataAccessor = WikibaseRepo::getLocalRepoWikiPageMetaDataAccessor(
310 310
 				$services );
311 311
 
312 312
 			$resultsSource = new CachingResultsSource(
313 313
 				$resultsSource,
314 314
 				ResultsCache::getDefaultInstance(),
315
-				ConstraintsServices::getCheckResultSerializer( $services ),
316
-				ConstraintsServices::getCheckResultDeserializer( $services ),
315
+				ConstraintsServices::getCheckResultSerializer($services),
316
+				ConstraintsServices::getCheckResultDeserializer($services),
317 317
 				$wikiPageEntityMetaDataAccessor,
318 318
 				$entityIdParser,
319
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
319
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
320 320
 				$possiblyStaleConstraintTypes,
321
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ),
322
-				ConstraintsServices::getLoggingHelper( $services )
321
+				$config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'),
322
+				ConstraintsServices::getLoggingHelper($services)
323 323
 			);
324 324
 		}
325 325
 
326 326
 		return $resultsSource;
327 327
 	},
328 328
 
329
-	ConstraintsServices::VIOLATION_MESSAGE_RENDERER_FACTORY => static function (
329
+	ConstraintsServices::VIOLATION_MESSAGE_RENDERER_FACTORY => static function(
330 330
 		MediaWikiServices $services
331 331
 	): ViolationMessageRendererFactory {
332 332
 		return new ViolationMessageRendererFactory(
333 333
 			$services->getMainConfig(),
334 334
 			$services->getLanguageNameUtils(),
335
-			WikibaseRepo::getEntityIdHtmlLinkFormatterFactory( $services ),
336
-			WikibaseRepo::getValueFormatterFactory( $services )
335
+			WikibaseRepo::getEntityIdHtmlLinkFormatterFactory($services),
336
+			WikibaseRepo::getValueFormatterFactory($services)
337 337
 		);
338 338
 	},
339 339
 ];
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/LoggingHelper.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 		$this->statsFactory = $statsFactory;
54 54
 		$this->logger = $logger;
55 55
 		$this->constraintCheckDurationLimits = [
56
-			'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ),
57
-			'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ),
56
+			'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'),
57
+			'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'),
58 58
 		];
59 59
 		$this->constraintCheckOnEntityDurationLimits = [
60
-			'info' => $config->get( 'WBQualityConstraintsCheckOnEntityDurationInfoSeconds' ),
61
-			'warning' => $config->get( 'WBQualityConstraintsCheckOnEntityDurationWarningSeconds' ),
60
+			'info' => $config->get('WBQualityConstraintsCheckOnEntityDurationInfoSeconds'),
61
+			'warning' => $config->get('WBQualityConstraintsCheckOnEntityDurationWarningSeconds'),
62 62
 		];
63 63
 	}
64 64
 
@@ -70,23 +70,23 @@  discard block
 block discarded – undo
70 70
 	 * @param float $durationSeconds
71 71
 	 * @return array [ $limitSeconds, $logLevel ]
72 72
 	 */
73
-	private function findLimit( $limits, $durationSeconds ) {
73
+	private function findLimit($limits, $durationSeconds) {
74 74
 		$limitSeconds = null;
75 75
 		$logLevel = null;
76 76
 
77
-		foreach ( $limits as $level => $limit ) {
77
+		foreach ($limits as $level => $limit) {
78 78
 			if (
79 79
 				// duration exceeds this limit
80 80
 				$limit !== null && $durationSeconds > $limit &&
81 81
 				// this limit is longer than previous longest limit
82
-				( $limitSeconds === null || $limit > $limitSeconds )
82
+				($limitSeconds === null || $limit > $limitSeconds)
83 83
 			) {
84 84
 				$limitSeconds = $limit;
85 85
 				$logLevel = $level;
86 86
 			}
87 87
 		}
88 88
 
89
-		return [ $limitSeconds, $logLevel ];
89
+		return [$limitSeconds, $logLevel];
90 90
 	}
91 91
 
92 92
 	/**
@@ -111,30 +111,30 @@  discard block
 block discarded – undo
111 111
 		$durationSeconds,
112 112
 		$method
113 113
 	) {
114
-		$constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 );
114
+		$constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1);
115 115
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
116 116
 
117 117
 		$baseCheckTimingKey = 'wikibase.quality.constraints.check.timing';
118 118
 		$this->statsFactory
119
-			->getTiming( 'check_constraint_duration_seconds' )
120
-			->copyToStatsdAt( "$baseCheckTimingKey.$constraintTypeItemId-$constraintCheckerClassShortName" )
121
-			->observe( $durationSeconds * 1000 );
119
+			->getTiming('check_constraint_duration_seconds')
120
+			->copyToStatsdAt("$baseCheckTimingKey.$constraintTypeItemId-$constraintCheckerClassShortName")
121
+			->observe($durationSeconds * 1000);
122 122
 
123 123
 		// find the longest limit (and associated log level) that the duration exceeds
124
-		[ $limitSeconds, $logLevel ] = $this->findLimit(
124
+		[$limitSeconds, $logLevel] = $this->findLimit(
125 125
 			$this->constraintCheckDurationLimits,
126 126
 			$durationSeconds
127 127
 		);
128
-		if ( $limitSeconds === null ) {
128
+		if ($limitSeconds === null) {
129 129
 			return;
130 130
 		}
131
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
131
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
132 132
 			// TODO log less details but still log something
133 133
 			return;
134 134
 		}
135 135
 
136 136
 		$resultMessage = $result->getMessage();
137
-		if ( $resultMessage !== null ) {
137
+		if ($resultMessage !== null) {
138 138
 			$resultMessageKey = $resultMessage->getMessageKey();
139 139
 		} else {
140 140
 			$resultMessageKey = null;
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 
143 143
 		$this->logger->log(
144 144
 			$logLevel,
145
-			'Constraint check with {constraintCheckerClassShortName} ' .
146
-			'took longer than {limitSeconds} second(s) ' .
145
+			'Constraint check with {constraintCheckerClassShortName} '.
146
+			'took longer than {limitSeconds} second(s) '.
147 147
 			'(duration: {durationSeconds} seconds).',
148 148
 			[
149 149
 				'method' => $method,
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 				'constraintId' => $constraint->getConstraintId(),
154 154
 				'constraintPropertyId' => $constraint->getPropertyId()->getSerialization(),
155 155
 				'constraintTypeItemId' => $constraintTypeItemId,
156
-				'constraintParameters' => json_encode( $constraint->getConstraintParameters() ),
156
+				'constraintParameters' => json_encode($constraint->getConstraintParameters()),
157 157
 				'constraintCheckerClass' => $constraintCheckerClass,
158 158
 				'constraintCheckerClassShortName' => $constraintCheckerClassShortName,
159 159
 				'entityId' => $context->getEntity()->getId()->getSerialization(),
@@ -185,23 +185,23 @@  discard block
 block discarded – undo
185 185
 	) {
186 186
 		$checkEntityTimingKey = 'wikibase.quality.constraints.check.entity.timing';
187 187
 		$this->statsFactory
188
-			->getTiming( 'check_entity_constraint_duration_seconds' )
189
-			->copyToStatsdAt( $checkEntityTimingKey )
190
-			->observe( $durationSeconds * 1000 );
188
+			->getTiming('check_entity_constraint_duration_seconds')
189
+			->copyToStatsdAt($checkEntityTimingKey)
190
+			->observe($durationSeconds * 1000);
191 191
 
192 192
 		// find the longest limit (and associated log level) that the duration exceeds
193
-		[ $limitSeconds, $logLevel ] = $this->findLimit(
193
+		[$limitSeconds, $logLevel] = $this->findLimit(
194 194
 			$this->constraintCheckOnEntityDurationLimits,
195 195
 			$durationSeconds
196 196
 		);
197
-		if ( $limitSeconds === null ) {
197
+		if ($limitSeconds === null) {
198 198
 			return;
199 199
 		}
200 200
 
201 201
 		$this->logger->log(
202 202
 			$logLevel,
203
-			'Full constraint check on {entityId} ' .
204
-			'took longer than {limitSeconds} second(s) ' .
203
+			'Full constraint check on {entityId} '.
204
+			'took longer than {limitSeconds} second(s) '.
205 205
 			'(duration: {durationSeconds} seconds).',
206 206
 			[
207 207
 				'method' => $method,
@@ -219,9 +219,9 @@  discard block
 block discarded – undo
219 219
 	 *
220 220
 	 * @param EntityId $entityId
221 221
 	 */
222
-	public function logCheckConstraintsCacheHit( EntityId $entityId ) {
222
+	public function logCheckConstraintsCacheHit(EntityId $entityId) {
223 223
 		$cacheEntityHitKey = 'wikibase.quality.constraints.cache.entity.hit';
224
-		$metric = $this->statsFactory->getCounter( 'cache_entity_hit_total' );
224
+		$metric = $this->statsFactory->getCounter('cache_entity_hit_total');
225 225
 		$metric->copyToStatsdAt(
226 226
 				$cacheEntityHitKey,
227 227
 			)->increment();
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @param EntityId[] $entityIds
234 234
 	 */
235
-	public function logCheckConstraintsCacheMisses( array $entityIds ) {
235
+	public function logCheckConstraintsCacheMisses(array $entityIds) {
236 236
 		$cacheEntityMissKey = 'wikibase.quality.constraints.cache.entity.miss';
237
-		$metric = $this->statsFactory->getCounter( 'cache_entity_miss_total' );
237
+		$metric = $this->statsFactory->getCounter('cache_entity_miss_total');
238 238
 		$metric->copyToStatsdAt(
239 239
 				$cacheEntityMissKey,
240
-			)->incrementBy( count( $entityIds ) );
240
+			)->incrementBy(count($entityIds));
241 241
 	}
242 242
 
243 243
 	/**
@@ -263,17 +263,17 @@  discard block
 block discarded – undo
263 263
 	 * @param EntityId[] $entityIds
264 264
 	 * @param int $maxRevisionIds
265 265
 	 */
266
-	public function logHugeDependencyMetadata( array $entityIds, $maxRevisionIds ) {
266
+	public function logHugeDependencyMetadata(array $entityIds, $maxRevisionIds) {
267 267
 		$this->logger->log(
268 268
 			'warning',
269
-			'Dependency metadata for constraint check result has huge set of entity IDs ' .
270
-			'(count ' . count( $entityIds ) . ', limit ' . $maxRevisionIds . '); ' .
269
+			'Dependency metadata for constraint check result has huge set of entity IDs '.
270
+			'(count '.count($entityIds).', limit '.$maxRevisionIds.'); '.
271 271
 			'caching disabled for this check result.',
272 272
 			[
273 273
 				'loggingMethod' => __METHOD__,
274 274
 				'entityIds' => json_encode(
275 275
 					array_map(
276
-						static function ( EntityId $entityId ) {
276
+						static function(EntityId $entityId) {
277 277
 							return $entityId->getSerialization();
278 278
 						},
279 279
 						$entityIds
@@ -292,17 +292,17 @@  discard block
 block discarded – undo
292 292
 			'Sparql API replied with status 429 and a retry-after header. Requesting to retry after {retryAfterTime}',
293 293
 			[
294 294
 				'retryAfterTime' => $retryAfterTime,
295
-				'responseHeaders' => json_encode( $request->getResponseHeaders() ),
295
+				'responseHeaders' => json_encode($request->getResponseHeaders()),
296 296
 				'responseContent' => $request->getContent(),
297 297
 			]
298 298
 		);
299 299
 	}
300 300
 
301
-	public function logSparqlHelperTooManyRequestsRetryAfterInvalid( MWHttpRequest $request ) {
301
+	public function logSparqlHelperTooManyRequestsRetryAfterInvalid(MWHttpRequest $request) {
302 302
 		$this->logger->warning(
303 303
 			'Sparql API replied with status 429 and no valid retry-after header.',
304 304
 			[
305
-				'responseHeaders' => json_encode( $request->getResponseHeaders() ),
305
+				'responseHeaders' => json_encode($request->getResponseHeaders()),
306 306
 				'responseContent' => $request->getContent(),
307 307
 			]
308 308
 		);
Please login to merge, or discard this patch.