Completed
Push — master ( ddba35...6bf92b )
by
unknown
56s queued 12s
created
src/ServiceWiring-ConstraintCheckers.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -38,206 +38,206 @@
 block discarded – undo
38 38
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker;
39 39
 
40 40
 return [
41
-	ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => static function ( MediaWikiServices $services ) {
41
+	ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => static function(MediaWikiServices $services) {
42 42
 		return new ConflictsWithChecker(
43
-			ConstraintsServices::getConstraintParameterParser( $services ),
44
-			ConstraintsServices::getConnectionCheckerHelper( $services )
43
+			ConstraintsServices::getConstraintParameterParser($services),
44
+			ConstraintsServices::getConnectionCheckerHelper($services)
45 45
 		);
46 46
 	},
47 47
 
48
-	ConstraintCheckerServices::ITEM_CHECKER => static function ( MediaWikiServices $services ) {
48
+	ConstraintCheckerServices::ITEM_CHECKER => static function(MediaWikiServices $services) {
49 49
 		return new ItemChecker(
50
-			ConstraintsServices::getConstraintParameterParser( $services ),
51
-			ConstraintsServices::getConnectionCheckerHelper( $services )
50
+			ConstraintsServices::getConstraintParameterParser($services),
51
+			ConstraintsServices::getConnectionCheckerHelper($services)
52 52
 		);
53 53
 	},
54 54
 
55
-	ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => static function ( MediaWikiServices $services ) {
55
+	ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => static function(MediaWikiServices $services) {
56 56
 		return new TargetRequiredClaimChecker(
57
-			WikibaseServices::getEntityLookup( $services ),
58
-			ConstraintsServices::getConstraintParameterParser( $services ),
59
-			ConstraintsServices::getConnectionCheckerHelper( $services )
57
+			WikibaseServices::getEntityLookup($services),
58
+			ConstraintsServices::getConstraintParameterParser($services),
59
+			ConstraintsServices::getConnectionCheckerHelper($services)
60 60
 		);
61 61
 	},
62 62
 
63
-	ConstraintCheckerServices::SYMMETRIC_CHECKER => static function ( MediaWikiServices $services ) {
63
+	ConstraintCheckerServices::SYMMETRIC_CHECKER => static function(MediaWikiServices $services) {
64 64
 		return new SymmetricChecker(
65
-			WikibaseServices::getEntityLookupWithoutCache( $services ),
66
-			ConstraintsServices::getConnectionCheckerHelper( $services )
65
+			WikibaseServices::getEntityLookupWithoutCache($services),
66
+			ConstraintsServices::getConnectionCheckerHelper($services)
67 67
 		);
68 68
 	},
69 69
 
70
-	ConstraintCheckerServices::INVERSE_CHECKER => static function ( MediaWikiServices $services ) {
70
+	ConstraintCheckerServices::INVERSE_CHECKER => static function(MediaWikiServices $services) {
71 71
 		return new InverseChecker(
72
-			WikibaseServices::getEntityLookup( $services ),
73
-			ConstraintsServices::getConstraintParameterParser( $services ),
74
-			ConstraintsServices::getConnectionCheckerHelper( $services )
72
+			WikibaseServices::getEntityLookup($services),
73
+			ConstraintsServices::getConstraintParameterParser($services),
74
+			ConstraintsServices::getConnectionCheckerHelper($services)
75 75
 		);
76 76
 	},
77 77
 
78
-	ConstraintCheckerServices::QUALIFIER_CHECKER => static function ( MediaWikiServices $services ) {
78
+	ConstraintCheckerServices::QUALIFIER_CHECKER => static function(MediaWikiServices $services) {
79 79
 		return new QualifierChecker();
80 80
 	},
81 81
 
82
-	ConstraintCheckerServices::QUALIFIERS_CHECKER => static function ( MediaWikiServices $services ) {
82
+	ConstraintCheckerServices::QUALIFIERS_CHECKER => static function(MediaWikiServices $services) {
83 83
 		return new QualifiersChecker(
84
-			ConstraintsServices::getConstraintParameterParser( $services )
84
+			ConstraintsServices::getConstraintParameterParser($services)
85 85
 		);
86 86
 	},
87 87
 
88
-	ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => static function ( MediaWikiServices $services ) {
88
+	ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => static function(MediaWikiServices $services) {
89 89
 		return new MandatoryQualifiersChecker(
90
-			ConstraintsServices::getConstraintParameterParser( $services )
90
+			ConstraintsServices::getConstraintParameterParser($services)
91 91
 		);
92 92
 	},
93 93
 
94
-	ConstraintCheckerServices::RANGE_CHECKER => static function ( MediaWikiServices $services ) {
94
+	ConstraintCheckerServices::RANGE_CHECKER => static function(MediaWikiServices $services) {
95 95
 		return new RangeChecker(
96
-			WikibaseServices::getPropertyDataTypeLookup( $services ),
97
-			ConstraintsServices::getConstraintParameterParser( $services ),
98
-			ConstraintsServices::getRangeCheckerHelper( $services )
96
+			WikibaseServices::getPropertyDataTypeLookup($services),
97
+			ConstraintsServices::getConstraintParameterParser($services),
98
+			ConstraintsServices::getRangeCheckerHelper($services)
99 99
 		);
100 100
 	},
101 101
 
102
-	ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => static function ( MediaWikiServices $services ) {
102
+	ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => static function(MediaWikiServices $services) {
103 103
 		return new DiffWithinRangeChecker(
104
-			ConstraintsServices::getConstraintParameterParser( $services ),
105
-			ConstraintsServices::getRangeCheckerHelper( $services ),
104
+			ConstraintsServices::getConstraintParameterParser($services),
105
+			ConstraintsServices::getRangeCheckerHelper($services),
106 106
 			$services->getMainConfig()
107 107
 		);
108 108
 	},
109 109
 
110
-	ConstraintCheckerServices::TYPE_CHECKER => static function ( MediaWikiServices $services ) {
110
+	ConstraintCheckerServices::TYPE_CHECKER => static function(MediaWikiServices $services) {
111 111
 		return new TypeChecker(
112
-			ConstraintsServices::getConstraintParameterParser( $services ),
113
-			ConstraintsServices::getTypeCheckerHelper( $services ),
112
+			ConstraintsServices::getConstraintParameterParser($services),
113
+			ConstraintsServices::getTypeCheckerHelper($services),
114 114
 			$services->getMainConfig()
115 115
 		);
116 116
 	},
117 117
 
118
-	ConstraintCheckerServices::VALUE_TYPE_CHECKER => static function ( MediaWikiServices $services ) {
118
+	ConstraintCheckerServices::VALUE_TYPE_CHECKER => static function(MediaWikiServices $services) {
119 119
 		return new ValueTypeChecker(
120
-			WikibaseServices::getEntityLookup( $services ),
121
-			ConstraintsServices::getConstraintParameterParser( $services ),
122
-			ConstraintsServices::getTypeCheckerHelper( $services ),
120
+			WikibaseServices::getEntityLookup($services),
121
+			ConstraintsServices::getConstraintParameterParser($services),
122
+			ConstraintsServices::getTypeCheckerHelper($services),
123 123
 			$services->getMainConfig()
124 124
 		);
125 125
 	},
126 126
 
127
-	ConstraintCheckerServices::SINGLE_VALUE_CHECKER => static function ( MediaWikiServices $services ) {
127
+	ConstraintCheckerServices::SINGLE_VALUE_CHECKER => static function(MediaWikiServices $services) {
128 128
 		return new SingleValueChecker(
129
-			ConstraintsServices::getConstraintParameterParser( $services )
129
+			ConstraintsServices::getConstraintParameterParser($services)
130 130
 		);
131 131
 	},
132 132
 
133
-	ConstraintCheckerServices::MULTI_VALUE_CHECKER => static function ( MediaWikiServices $services ) {
133
+	ConstraintCheckerServices::MULTI_VALUE_CHECKER => static function(MediaWikiServices $services) {
134 134
 		return new MultiValueChecker(
135
-			ConstraintsServices::getConstraintParameterParser( $services )
135
+			ConstraintsServices::getConstraintParameterParser($services)
136 136
 		);
137 137
 	},
138 138
 
139
-	ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => static function ( MediaWikiServices $services ) {
139
+	ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => static function(MediaWikiServices $services) {
140 140
 		// TODO return a different, dummy implementation if SPARQL is not available
141 141
 		return new UniqueValueChecker(
142
-			ConstraintsServices::getSparqlHelper( $services ),
143
-			ConstraintsServices::getConstraintParameterParser( $services )
142
+			ConstraintsServices::getSparqlHelper($services),
143
+			ConstraintsServices::getConstraintParameterParser($services)
144 144
 		);
145 145
 	},
146 146
 
147
-	ConstraintCheckerServices::FORMAT_CHECKER => static function ( MediaWikiServices $services ) {
147
+	ConstraintCheckerServices::FORMAT_CHECKER => static function(MediaWikiServices $services) {
148 148
 		// TODO return a different, dummy implementation if SPARQL is not available
149 149
 		return new FormatChecker(
150
-			ConstraintsServices::getConstraintParameterParser( $services ),
150
+			ConstraintsServices::getConstraintParameterParser($services),
151 151
 			$services->getMainConfig(),
152
-			ConstraintsServices::getSparqlHelper( $services ),
152
+			ConstraintsServices::getSparqlHelper($services),
153 153
 			$services->getShellboxClientFactory()
154 154
 		);
155 155
 	},
156 156
 
157
-	ConstraintCheckerServices::COMMONS_LINK_CHECKER => static function ( MediaWikiServices $services ) {
157
+	ConstraintCheckerServices::COMMONS_LINK_CHECKER => static function(MediaWikiServices $services) {
158 158
 		$pageNameNormalizer = new MediaWikiPageNameNormalizer();
159 159
 		return new CommonsLinkChecker(
160
-			ConstraintsServices::getConstraintParameterParser( $services ),
160
+			ConstraintsServices::getConstraintParameterParser($services),
161 161
 			$pageNameNormalizer,
162
-			WikibaseRepo::getPropertyDataTypeLookup( $services )
162
+			WikibaseRepo::getPropertyDataTypeLookup($services)
163 163
 		);
164 164
 	},
165 165
 
166
-	ConstraintCheckerServices::ONE_OF_CHECKER => static function ( MediaWikiServices $services ) {
166
+	ConstraintCheckerServices::ONE_OF_CHECKER => static function(MediaWikiServices $services) {
167 167
 		return new OneOfChecker(
168
-			ConstraintsServices::getConstraintParameterParser( $services )
168
+			ConstraintsServices::getConstraintParameterParser($services)
169 169
 		);
170 170
 	},
171 171
 
172
-	ConstraintCheckerServices::VALUE_ONLY_CHECKER => static function ( MediaWikiServices $services ) {
172
+	ConstraintCheckerServices::VALUE_ONLY_CHECKER => static function(MediaWikiServices $services) {
173 173
 		return new ValueOnlyChecker();
174 174
 	},
175 175
 
176
-	ConstraintCheckerServices::REFERENCE_CHECKER => static function ( MediaWikiServices $services ) {
176
+	ConstraintCheckerServices::REFERENCE_CHECKER => static function(MediaWikiServices $services) {
177 177
 		return new ReferenceChecker();
178 178
 	},
179 179
 
180
-	ConstraintCheckerServices::NO_BOUNDS_CHECKER => static function ( MediaWikiServices $services ) {
180
+	ConstraintCheckerServices::NO_BOUNDS_CHECKER => static function(MediaWikiServices $services) {
181 181
 		return new NoBoundsChecker();
182 182
 	},
183 183
 
184
-	ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => static function ( MediaWikiServices $services ) {
184
+	ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => static function(MediaWikiServices $services) {
185 185
 		return new AllowedUnitsChecker(
186
-			ConstraintsServices::getConstraintParameterParser( $services ),
187
-			WikibaseRepo::getUnitConverter( $services )
186
+			ConstraintsServices::getConstraintParameterParser($services),
187
+			WikibaseRepo::getUnitConverter($services)
188 188
 		);
189 189
 	},
190 190
 
191
-	ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => static function ( MediaWikiServices $services ) {
191
+	ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => static function(MediaWikiServices $services) {
192 192
 		return new SingleBestValueChecker(
193
-			ConstraintsServices::getConstraintParameterParser( $services )
193
+			ConstraintsServices::getConstraintParameterParser($services)
194 194
 		);
195 195
 	},
196 196
 
197
-	ConstraintCheckerServices::ENTITY_TYPE_CHECKER => static function ( MediaWikiServices $services ) {
197
+	ConstraintCheckerServices::ENTITY_TYPE_CHECKER => static function(MediaWikiServices $services) {
198 198
 		return new EntityTypeChecker(
199
-			ConstraintsServices::getConstraintParameterParser( $services )
199
+			ConstraintsServices::getConstraintParameterParser($services)
200 200
 		);
201 201
 	},
202 202
 
203
-	ConstraintCheckerServices::NONE_OF_CHECKER => static function ( MediaWikiServices $services ) {
203
+	ConstraintCheckerServices::NONE_OF_CHECKER => static function(MediaWikiServices $services) {
204 204
 		return new NoneOfChecker(
205
-			ConstraintsServices::getConstraintParameterParser( $services )
205
+			ConstraintsServices::getConstraintParameterParser($services)
206 206
 		);
207 207
 	},
208 208
 
209
-	ConstraintCheckerServices::INTEGER_CHECKER => static function ( MediaWikiServices $services ) {
209
+	ConstraintCheckerServices::INTEGER_CHECKER => static function(MediaWikiServices $services) {
210 210
 		return new IntegerChecker();
211 211
 	},
212 212
 
213
-	ConstraintCheckerServices::CITATION_NEEDED_CHECKER => static function ( MediaWikiServices $services ) {
213
+	ConstraintCheckerServices::CITATION_NEEDED_CHECKER => static function(MediaWikiServices $services) {
214 214
 		return new CitationNeededChecker();
215 215
 	},
216 216
 
217
-	ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => static function ( MediaWikiServices $services ) {
217
+	ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => static function(MediaWikiServices $services) {
218 218
 		return new PropertyScopeChecker(
219
-			ConstraintsServices::getConstraintParameterParser( $services )
219
+			ConstraintsServices::getConstraintParameterParser($services)
220 220
 		);
221 221
 	},
222 222
 
223
-	ConstraintCheckerServices::CONTEMPORARY_CHECKER => static function ( MediaWikiServices $services ) {
223
+	ConstraintCheckerServices::CONTEMPORARY_CHECKER => static function(MediaWikiServices $services) {
224 224
 		return new ContemporaryChecker(
225
-			WikibaseServices::getEntityLookup( $services ),
226
-			ConstraintsServices::getRangeCheckerHelper( $services ),
225
+			WikibaseServices::getEntityLookup($services),
226
+			ConstraintsServices::getRangeCheckerHelper($services),
227 227
 			$services->getMainConfig()
228 228
 		);
229 229
 	},
230 230
 
231
-	ConstraintCheckerServices::LEXEME_LANGUAGE_CHECKER => static function ( MediaWikiServices $services ) {
231
+	ConstraintCheckerServices::LEXEME_LANGUAGE_CHECKER => static function(MediaWikiServices $services) {
232 232
 		return new LanguageChecker(
233
-			ConstraintsServices::getConstraintParameterParser( $services ),
234
-			WikibaseServices::getEntityLookup( $services )
233
+			ConstraintsServices::getConstraintParameterParser($services),
234
+			WikibaseServices::getEntityLookup($services)
235 235
 		);
236 236
 	},
237 237
 
238
-	ConstraintCheckerServices::LABEL_IN_LANGUAGE_CHECKER => static function ( MediaWikiServices $services ) {
238
+	ConstraintCheckerServices::LABEL_IN_LANGUAGE_CHECKER => static function(MediaWikiServices $services) {
239 239
 		return new LabelInLanguageChecker(
240
-			ConstraintsServices::getConstraintParameterParser( $services )
240
+			ConstraintsServices::getConstraintParameterParser($services)
241 241
 		);
242 242
 	},
243 243
 ];
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/SparqlHelper.php 1 patch
Spacing   +176 added lines, -179 removed lines patch added patch discarded remove patch
@@ -200,73 +200,73 @@  discard block
 block discarded – undo
200 200
 		$this->defaultUserAgent = $defaultUserAgent;
201 201
 		$this->requestFactory = $requestFactory;
202 202
 		$this->entityPrefixes = [];
203
-		foreach ( $rdfVocabulary->entityNamespaceNames as $namespaceName ) {
204
-			$this->entityPrefixes[] = $rdfVocabulary->getNamespaceURI( $namespaceName );
203
+		foreach ($rdfVocabulary->entityNamespaceNames as $namespaceName) {
204
+			$this->entityPrefixes[] = $rdfVocabulary->getNamespaceURI($namespaceName);
205 205
 		}
206 206
 
207
-		$this->endpoint = $config->get( 'WBQualityConstraintsSparqlEndpoint' );
208
-		$this->maxQueryTimeMillis = $config->get( 'WBQualityConstraintsSparqlMaxMillis' );
209
-		$this->instanceOfId = $config->get( 'WBQualityConstraintsInstanceOfId' );
210
-		$this->subclassOfId = $config->get( 'WBQualityConstraintsSubclassOfId' );
211
-		$this->cacheMapSize = $config->get( 'WBQualityConstraintsFormatCacheMapSize' );
207
+		$this->endpoint = $config->get('WBQualityConstraintsSparqlEndpoint');
208
+		$this->maxQueryTimeMillis = $config->get('WBQualityConstraintsSparqlMaxMillis');
209
+		$this->instanceOfId = $config->get('WBQualityConstraintsInstanceOfId');
210
+		$this->subclassOfId = $config->get('WBQualityConstraintsSubclassOfId');
211
+		$this->cacheMapSize = $config->get('WBQualityConstraintsFormatCacheMapSize');
212 212
 		$this->timeoutExceptionClasses = $config->get(
213 213
 			'WBQualityConstraintsSparqlTimeoutExceptionClasses'
214 214
 		);
215 215
 		$this->sparqlHasWikibaseSupport = $config->get(
216 216
 			'WBQualityConstraintsSparqlHasWikibaseSupport'
217 217
 		);
218
-		$this->sparqlThrottlingFallbackDuration = (int)$config->get(
218
+		$this->sparqlThrottlingFallbackDuration = (int) $config->get(
219 219
 			'WBQualityConstraintsSparqlThrottlingFallbackDuration'
220 220
 		);
221 221
 
222
-		$this->prefixes = $this->getQueryPrefixes( $rdfVocabulary );
222
+		$this->prefixes = $this->getQueryPrefixes($rdfVocabulary);
223 223
 	}
224 224
 
225
-	private function getQueryPrefixes( RdfVocabulary $rdfVocabulary ) {
225
+	private function getQueryPrefixes(RdfVocabulary $rdfVocabulary) {
226 226
 		// TODO: it would probably be smarter that RdfVocubulary exposed these prefixes somehow
227 227
 		$prefixes = '';
228
-		foreach ( $rdfVocabulary->entityNamespaceNames as $sourceName => $namespaceName ) {
228
+		foreach ($rdfVocabulary->entityNamespaceNames as $sourceName => $namespaceName) {
229 229
 			$prefixes .= <<<END
230
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
230
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
231 231
 END;
232 232
 		}
233 233
 		$prefixes .= <<<END
234
-PREFIX wds: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_STATEMENT )}>
235
-PREFIX wdv: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_VALUE )}>\n
234
+PREFIX wds: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_STATEMENT)}>
235
+PREFIX wdv: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_VALUE)}>\n
236 236
 END;
237 237
 
238
-		foreach ( $rdfVocabulary->propertyNamespaceNames as $sourceName => $sourceNamespaces ) {
238
+		foreach ($rdfVocabulary->propertyNamespaceNames as $sourceName => $sourceNamespaces) {
239 239
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_DIRECT_CLAIM];
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_CLAIM];
244 244
 			$prefixes .= <<<END
245
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
245
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
246 246
 END;
247 247
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM_STATEMENT];
248 248
 			$prefixes .= <<<END
249
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
249
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
250 250
 END;
251 251
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_QUALIFIER];
252 252
 			$prefixes .= <<<END
253
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
253
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
254 254
 END;
255 255
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_QUALIFIER_VALUE];
256 256
 			$prefixes .= <<<END
257
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
257
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
258 258
 END;
259 259
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_REFERENCE];
260 260
 			$prefixes .= <<<END
261
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
261
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
262 262
 END;
263 263
 			$namespaceName = $sourceNamespaces[RdfVocabulary::NSP_REFERENCE_VALUE];
264 264
 			$prefixes .= <<<END
265
-PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n
265
+PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n
266 266
 END;
267 267
 		}
268 268
 		$prefixes .= <<<END
269
-PREFIX wikibase: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_ONTOLOGY )}>\n
269
+PREFIX wikibase: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_ONTOLOGY)}>\n
270 270
 END;
271 271
 		return $prefixes;
272 272
 	}
@@ -278,21 +278,20 @@  discard block
 block discarded – undo
278 278
 	 * @return CachedBool
279 279
 	 * @throws SparqlHelperException if the query times out or some other error occurs
280 280
 	 */
281
-	public function hasType( $id, array $classes ) {
281
+	public function hasType($id, array $classes) {
282 282
 		// TODO hint:gearing is a workaround for T168973 and can hopefully be removed eventually
283 283
 		$gearingHint = $this->sparqlHasWikibaseSupport ?
284
-			' hint:Prior hint:gearing "forward".' :
285
-			'';
284
+			' hint:Prior hint:gearing "forward".' : '';
286 285
 
287 286
 		$metadatas = [];
288 287
 
289
-		foreach ( array_chunk( $classes, 20 ) as $classesChunk ) {
290
-			$classesValues = implode( ' ', array_map(
291
-				static function ( $class ) {
292
-					return 'wd:' . $class;
288
+		foreach (array_chunk($classes, 20) as $classesChunk) {
289
+			$classesValues = implode(' ', array_map(
290
+				static function($class) {
291
+					return 'wd:'.$class;
293 292
 				},
294 293
 				$classesChunk
295
-			) );
294
+			));
296 295
 
297 296
 			$query = <<<EOF
298 297
 ASK {
@@ -302,19 +301,19 @@  discard block
 block discarded – undo
302 301
 }
303 302
 EOF;
304 303
 
305
-			$result = $this->runQuery( $query );
304
+			$result = $this->runQuery($query);
306 305
 			$metadatas[] = $result->getMetadata();
307
-			if ( $result->getArray()['boolean'] ) {
306
+			if ($result->getArray()['boolean']) {
308 307
 				return new CachedBool(
309 308
 					true,
310
-					Metadata::merge( $metadatas )
309
+					Metadata::merge($metadatas)
311 310
 				);
312 311
 			}
313 312
 		}
314 313
 
315 314
 		return new CachedBool(
316 315
 			false,
317
-			Metadata::merge( $metadatas )
316
+			Metadata::merge($metadatas)
318 317
 		);
319 318
 	}
320 319
 
@@ -325,7 +324,7 @@  discard block
 block discarded – undo
325 324
 	 * @param PropertyId $separator
326 325
 	 * @return string
327 326
 	 */
328
-	private function nestedSeparatorFilter( PropertyId $separator ) {
327
+	private function nestedSeparatorFilter(PropertyId $separator) {
329 328
 		$filter = <<<EOF
330 329
   MINUS {
331 330
     ?statement pq:$separator ?qualifier.
@@ -367,10 +366,10 @@  discard block
 block discarded – undo
367 366
 		array $separators
368 367
 	) {
369 368
 		$pid = $statement->getPropertyId()->serialize();
370
-		$guid = str_replace( '$', '-', $statement->getGuid() );
369
+		$guid = str_replace('$', '-', $statement->getGuid());
371 370
 
372
-		$separatorFilters = array_map( [ $this, 'nestedSeparatorFilter' ], $separators );
373
-		$finalSeparatorFilter = implode( "\n", $separatorFilters );
371
+		$separatorFilters = array_map([$this, 'nestedSeparatorFilter'], $separators);
372
+		$finalSeparatorFilter = implode("\n", $separatorFilters);
374 373
 
375 374
 		$query = <<<EOF
376 375
 SELECT DISTINCT ?otherEntity WHERE {
@@ -388,9 +387,9 @@  discard block
 block discarded – undo
388 387
 LIMIT 10
389 388
 EOF;
390 389
 
391
-		$result = $this->runQuery( $query );
390
+		$result = $this->runQuery($query);
392 391
 
393
-		return $this->getOtherEntities( $result );
392
+		return $this->getOtherEntities($result);
394 393
 	}
395 394
 
396 395
 	/**
@@ -415,16 +414,15 @@  discard block
 block discarded – undo
415 414
 		$dataType = $this->propertyDataTypeLookup->getDataTypeIdForProperty(
416 415
 			$snak->getPropertyId()
417 416
 		);
418
-		list( $value, $isFullValue ) = $this->getRdfLiteral( $dataType, $dataValue );
419
-		if ( $isFullValue ) {
417
+		list($value, $isFullValue) = $this->getRdfLiteral($dataType, $dataValue);
418
+		if ($isFullValue) {
420 419
 			$prefix .= 'v';
421 420
 		}
422 421
 		$path = $type === Context::TYPE_QUALIFIER ?
423
-			"$prefix:$pid" :
424
-			"prov:wasDerivedFrom/$prefix:$pid";
422
+			"$prefix:$pid" : "prov:wasDerivedFrom/$prefix:$pid";
425 423
 
426 424
 		$deprecatedFilter = '';
427
-		if ( $ignoreDeprecatedStatements ) {
425
+		if ($ignoreDeprecatedStatements) {
428 426
 			$deprecatedFilter = <<< EOF
429 427
   MINUS { ?otherStatement wikibase:rank wikibase:DeprecatedRank. }
430 428
 EOF;
@@ -444,9 +442,9 @@  discard block
 block discarded – undo
444 442
 LIMIT 10
445 443
 EOF;
446 444
 
447
-		$result = $this->runQuery( $query );
445
+		$result = $this->runQuery($query);
448 446
 
449
-		return $this->getOtherEntities( $result );
447
+		return $this->getOtherEntities($result);
450 448
 	}
451 449
 
452 450
 	/**
@@ -456,8 +454,8 @@  discard block
 block discarded – undo
456 454
 	 *
457 455
 	 * @return string
458 456
 	 */
459
-	private function stringLiteral( $text ) {
460
-		return '"' . strtr( $text, [ '"' => '\\"', '\\' => '\\\\' ] ) . '"';
457
+	private function stringLiteral($text) {
458
+		return '"'.strtr($text, ['"' => '\\"', '\\' => '\\\\']).'"';
461 459
 	}
462 460
 
463 461
 	/**
@@ -467,18 +465,18 @@  discard block
 block discarded – undo
467 465
 	 *
468 466
 	 * @return CachedEntityIds
469 467
 	 */
470
-	private function getOtherEntities( CachedQueryResults $results ) {
471
-		return new CachedEntityIds( array_map(
472
-			function ( $resultBindings ) {
468
+	private function getOtherEntities(CachedQueryResults $results) {
469
+		return new CachedEntityIds(array_map(
470
+			function($resultBindings) {
473 471
 				$entityIRI = $resultBindings['otherEntity']['value'];
474
-				foreach ( $this->entityPrefixes as $entityPrefix ) {
475
-					$entityPrefixLength = strlen( $entityPrefix );
476
-					if ( substr( $entityIRI, 0, $entityPrefixLength ) === $entityPrefix ) {
472
+				foreach ($this->entityPrefixes as $entityPrefix) {
473
+					$entityPrefixLength = strlen($entityPrefix);
474
+					if (substr($entityIRI, 0, $entityPrefixLength) === $entityPrefix) {
477 475
 						try {
478 476
 							return $this->entityIdParser->parse(
479
-								substr( $entityIRI, $entityPrefixLength )
477
+								substr($entityIRI, $entityPrefixLength)
480 478
 							);
481
-						} catch ( EntityIdParsingException $e ) {
479
+						} catch (EntityIdParsingException $e) {
482 480
 							// fall through
483 481
 						}
484 482
 					}
@@ -489,7 +487,7 @@  discard block
 block discarded – undo
489 487
 				return null;
490 488
 			},
491 489
 			$results->getArray()['results']['bindings']
492
-		), $results->getMetadata() );
490
+		), $results->getMetadata());
493 491
 	}
494 492
 
495 493
 	// phpcs:disable Generic.Metrics.CyclomaticComplexity,Squiz.WhiteSpace.FunctionSpacing
@@ -502,50 +500,50 @@  discard block
 block discarded – undo
502 500
 	 * @return array the literal or IRI as a string in SPARQL syntax,
503 501
 	 * and a boolean indicating whether it refers to a full value node or not
504 502
 	 */
505
-	private function getRdfLiteral( $dataType, DataValue $dataValue ) {
506
-		switch ( $dataType ) {
503
+	private function getRdfLiteral($dataType, DataValue $dataValue) {
504
+		switch ($dataType) {
507 505
 			case 'string':
508 506
 			case 'external-id':
509
-				return [ $this->stringLiteral( $dataValue->getValue() ), false ];
507
+				return [$this->stringLiteral($dataValue->getValue()), false];
510 508
 			case 'commonsMedia':
511
-				$url = $this->rdfVocabulary->getMediaFileURI( $dataValue->getValue() );
512
-				return [ '<' . $url . '>', false ];
509
+				$url = $this->rdfVocabulary->getMediaFileURI($dataValue->getValue());
510
+				return ['<'.$url.'>', false];
513 511
 			case 'geo-shape':
514
-				$url = $this->rdfVocabulary->getGeoShapeURI( $dataValue->getValue() );
515
-				return [ '<' . $url . '>', false ];
512
+				$url = $this->rdfVocabulary->getGeoShapeURI($dataValue->getValue());
513
+				return ['<'.$url.'>', false];
516 514
 			case 'tabular-data':
517
-				$url = $this->rdfVocabulary->getTabularDataURI( $dataValue->getValue() );
518
-				return [ '<' . $url . '>', false ];
515
+				$url = $this->rdfVocabulary->getTabularDataURI($dataValue->getValue());
516
+				return ['<'.$url.'>', false];
519 517
 			case 'url':
520 518
 				$url = $dataValue->getValue();
521
-				if ( !preg_match( '/^[^<>"{}\\\\|^`\\x00-\\x20]*$/D', $url ) ) {
519
+				if (!preg_match('/^[^<>"{}\\\\|^`\\x00-\\x20]*$/D', $url)) {
522 520
 					// not a valid URL for SPARQL (see SPARQL spec, production 139 IRIREF)
523 521
 					// such an URL should never reach us, so just throw
524
-					throw new InvalidArgumentException( 'invalid URL: ' . $url );
522
+					throw new InvalidArgumentException('invalid URL: '.$url);
525 523
 				}
526
-				return [ '<' . $url . '>', false ];
524
+				return ['<'.$url.'>', false];
527 525
 			case 'wikibase-item':
528 526
 			case 'wikibase-property':
529 527
 				/** @var EntityIdValue $dataValue */
530 528
 				'@phan-var EntityIdValue $dataValue';
531
-				return [ 'wd:' . $dataValue->getEntityId()->getSerialization(), false ];
529
+				return ['wd:'.$dataValue->getEntityId()->getSerialization(), false];
532 530
 			case 'monolingualtext':
533 531
 				/** @var MonolingualTextValue $dataValue */
534 532
 				'@phan-var MonolingualTextValue $dataValue';
535 533
 				$lang = $dataValue->getLanguageCode();
536
-				if ( !preg_match( '/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/D', $lang ) ) {
534
+				if (!preg_match('/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/D', $lang)) {
537 535
 					// not a valid language tag for SPARQL (see SPARQL spec, production 145 LANGTAG)
538 536
 					// such a language tag should never reach us, so just throw
539
-					throw new InvalidArgumentException( 'invalid language tag: ' . $lang );
537
+					throw new InvalidArgumentException('invalid language tag: '.$lang);
540 538
 				}
541
-				return [ $this->stringLiteral( $dataValue->getText() ) . '@' . $lang, false ];
539
+				return [$this->stringLiteral($dataValue->getText()).'@'.$lang, false];
542 540
 			case 'globe-coordinate':
543 541
 			case 'quantity':
544 542
 			case 'time':
545 543
 				// @phan-suppress-next-line PhanUndeclaredMethod
546
-				return [ 'wdv:' . $dataValue->getHash(), true ];
544
+				return ['wdv:'.$dataValue->getHash(), true];
547 545
 			default:
548
-				throw new InvalidArgumentException( 'unknown data type: ' . $dataType );
546
+				throw new InvalidArgumentException('unknown data type: '.$dataType);
549 547
 		}
550 548
 	}
551 549
 	// phpcs:enable
@@ -558,43 +556,43 @@  discard block
 block discarded – undo
558 556
 	 * @throws SparqlHelperException if the query times out or some other error occurs
559 557
 	 * @throws ConstraintParameterException if the $regex is invalid
560 558
 	 */
561
-	public function matchesRegularExpression( $text, $regex ) {
559
+	public function matchesRegularExpression($text, $regex) {
562 560
 		// caching wrapper around matchesRegularExpressionWithSparql
563 561
 
564
-		$textHash = hash( 'sha256', $text );
562
+		$textHash = hash('sha256', $text);
565 563
 		$cacheKey = $this->cache->makeKey(
566 564
 			'WikibaseQualityConstraints', // extension
567 565
 			'regex', // action
568 566
 			'WDQS-Java', // regex flavor
569
-			hash( 'sha256', $regex )
567
+			hash('sha256', $regex)
570 568
 		);
571 569
 
572 570
 		$cacheMapArray = $this->cache->getWithSetCallback(
573 571
 			$cacheKey,
574 572
 			WANObjectCache::TTL_DAY,
575
-			function ( $cacheMapArray ) use ( $text, $regex, $textHash ) {
573
+			function($cacheMapArray) use ($text, $regex, $textHash) {
576 574
 				// Initialize the cache map if not set
577
-				if ( $cacheMapArray === false ) {
575
+				if ($cacheMapArray === false) {
578 576
 					$key = 'wikibase.quality.constraints.regex.cache.refresh.init';
579
-					$this->dataFactory->increment( $key );
577
+					$this->dataFactory->increment($key);
580 578
 					return [];
581 579
 				}
582 580
 
583 581
 				$key = 'wikibase.quality.constraints.regex.cache.refresh';
584
-				$this->dataFactory->increment( $key );
585
-				$cacheMap = MapCacheLRU::newFromArray( $cacheMapArray, $this->cacheMapSize );
586
-				if ( $cacheMap->has( $textHash ) ) {
582
+				$this->dataFactory->increment($key);
583
+				$cacheMap = MapCacheLRU::newFromArray($cacheMapArray, $this->cacheMapSize);
584
+				if ($cacheMap->has($textHash)) {
587 585
 					$key = 'wikibase.quality.constraints.regex.cache.refresh.hit';
588
-					$this->dataFactory->increment( $key );
589
-					$cacheMap->get( $textHash ); // ping cache
586
+					$this->dataFactory->increment($key);
587
+					$cacheMap->get($textHash); // ping cache
590 588
 				} else {
591 589
 					$key = 'wikibase.quality.constraints.regex.cache.refresh.miss';
592
-					$this->dataFactory->increment( $key );
590
+					$this->dataFactory->increment($key);
593 591
 					try {
594
-						$matches = $this->matchesRegularExpressionWithSparql( $text, $regex );
595
-					} catch ( ConstraintParameterException $e ) {
596
-						$matches = $this->serializeConstraintParameterException( $e );
597
-					} catch ( SparqlHelperException $e ) {
592
+						$matches = $this->matchesRegularExpressionWithSparql($text, $regex);
593
+					} catch (ConstraintParameterException $e) {
594
+						$matches = $this->serializeConstraintParameterException($e);
595
+					} catch (SparqlHelperException $e) {
598 596
 						// don’t cache this
599 597
 						return $cacheMap->toArray();
600 598
 					}
@@ -618,42 +616,42 @@  discard block
 block discarded – undo
618 616
 			]
619 617
 		);
620 618
 
621
-		if ( isset( $cacheMapArray[$textHash] ) ) {
619
+		if (isset($cacheMapArray[$textHash])) {
622 620
 			$key = 'wikibase.quality.constraints.regex.cache.hit';
623
-			$this->dataFactory->increment( $key );
621
+			$this->dataFactory->increment($key);
624 622
 			$matches = $cacheMapArray[$textHash];
625
-			if ( is_bool( $matches ) ) {
623
+			if (is_bool($matches)) {
626 624
 				return $matches;
627
-			} elseif ( is_array( $matches ) &&
628
-				$matches['type'] == ConstraintParameterException::class ) {
629
-				throw $this->deserializeConstraintParameterException( $matches );
625
+			} elseif (is_array($matches) &&
626
+				$matches['type'] == ConstraintParameterException::class) {
627
+				throw $this->deserializeConstraintParameterException($matches);
630 628
 			} else {
631 629
 				throw new MWException(
632
-					'Value of unknown type in object cache (' .
633
-					'cache key: ' . $cacheKey . ', ' .
634
-					'cache map key: ' . $textHash . ', ' .
635
-					'value type: ' . gettype( $matches ) . ')'
630
+					'Value of unknown type in object cache ('.
631
+					'cache key: '.$cacheKey.', '.
632
+					'cache map key: '.$textHash.', '.
633
+					'value type: '.gettype($matches).')'
636 634
 				);
637 635
 			}
638 636
 		} else {
639 637
 			$key = 'wikibase.quality.constraints.regex.cache.miss';
640
-			$this->dataFactory->increment( $key );
641
-			return $this->matchesRegularExpressionWithSparql( $text, $regex );
638
+			$this->dataFactory->increment($key);
639
+			return $this->matchesRegularExpressionWithSparql($text, $regex);
642 640
 		}
643 641
 	}
644 642
 
645
-	private function serializeConstraintParameterException( ConstraintParameterException $cpe ) {
643
+	private function serializeConstraintParameterException(ConstraintParameterException $cpe) {
646 644
 		return [
647 645
 			'type' => ConstraintParameterException::class,
648
-			'violationMessage' => $this->violationMessageSerializer->serialize( $cpe->getViolationMessage() ),
646
+			'violationMessage' => $this->violationMessageSerializer->serialize($cpe->getViolationMessage()),
649 647
 		];
650 648
 	}
651 649
 
652
-	private function deserializeConstraintParameterException( array $serialization ) {
650
+	private function deserializeConstraintParameterException(array $serialization) {
653 651
 		$message = $this->violationMessageDeserializer->deserialize(
654 652
 			$serialization['violationMessage']
655 653
 		);
656
-		return new ConstraintParameterException( $message );
654
+		return new ConstraintParameterException($message);
657 655
 	}
658 656
 
659 657
 	/**
@@ -667,25 +665,25 @@  discard block
 block discarded – undo
667 665
 	 * @throws SparqlHelperException if the query times out or some other error occurs
668 666
 	 * @throws ConstraintParameterException if the $regex is invalid
669 667
 	 */
670
-	public function matchesRegularExpressionWithSparql( $text, $regex ) {
671
-		$textStringLiteral = $this->stringLiteral( $text );
672
-		$regexStringLiteral = $this->stringLiteral( '^(?:' . $regex . ')$' );
668
+	public function matchesRegularExpressionWithSparql($text, $regex) {
669
+		$textStringLiteral = $this->stringLiteral($text);
670
+		$regexStringLiteral = $this->stringLiteral('^(?:'.$regex.')$');
673 671
 
674 672
 		$query = <<<EOF
675 673
 SELECT (REGEX($textStringLiteral, $regexStringLiteral) AS ?matches) {}
676 674
 EOF;
677 675
 
678
-		$result = $this->runQuery( $query, false );
676
+		$result = $this->runQuery($query, false);
679 677
 
680 678
 		$vars = $result->getArray()['results']['bindings'][0];
681
-		if ( array_key_exists( 'matches', $vars ) ) {
679
+		if (array_key_exists('matches', $vars)) {
682 680
 			// true or false ⇒ regex okay, text matches or not
683 681
 			return $vars['matches']['value'] === 'true';
684 682
 		} else {
685 683
 			// empty result: regex broken
686 684
 			throw new ConstraintParameterException(
687
-				( new ViolationMessage( 'wbqc-violation-message-parameter-regex' ) )
688
-					->withInlineCode( $regex, Role::CONSTRAINT_PARAMETER_VALUE )
685
+				(new ViolationMessage('wbqc-violation-message-parameter-regex'))
686
+					->withInlineCode($regex, Role::CONSTRAINT_PARAMETER_VALUE)
689 687
 			);
690 688
 		}
691 689
 	}
@@ -697,14 +695,14 @@  discard block
 block discarded – undo
697 695
 	 *
698 696
 	 * @return boolean
699 697
 	 */
700
-	public function isTimeout( $responseContent ) {
701
-		$timeoutRegex = implode( '|', array_map(
702
-			static function ( $fqn ) {
703
-				return preg_quote( $fqn, '/' );
698
+	public function isTimeout($responseContent) {
699
+		$timeoutRegex = implode('|', array_map(
700
+			static function($fqn) {
701
+				return preg_quote($fqn, '/');
704 702
 			},
705 703
 			$this->timeoutExceptionClasses
706
-		) );
707
-		return (bool)preg_match( '/' . $timeoutRegex . '/', $responseContent );
704
+		));
705
+		return (bool) preg_match('/'.$timeoutRegex.'/', $responseContent);
708 706
 	}
709 707
 
710 708
 	/**
@@ -716,17 +714,17 @@  discard block
 block discarded – undo
716 714
 	 * @return int|boolean the max-age (in seconds)
717 715
 	 * or a plain boolean if no max-age can be determined
718 716
 	 */
719
-	public function getCacheMaxAge( $responseHeaders ) {
717
+	public function getCacheMaxAge($responseHeaders) {
720 718
 		if (
721
-			array_key_exists( 'x-cache-status', $responseHeaders ) &&
722
-			preg_match( '/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0] )
719
+			array_key_exists('x-cache-status', $responseHeaders) &&
720
+			preg_match('/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0])
723 721
 		) {
724 722
 			$maxage = [];
725 723
 			if (
726
-				array_key_exists( 'cache-control', $responseHeaders ) &&
727
-				preg_match( '/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage )
724
+				array_key_exists('cache-control', $responseHeaders) &&
725
+				preg_match('/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage)
728 726
 			) {
729
-				return intval( $maxage[1] );
727
+				return intval($maxage[1]);
730 728
 			} else {
731 729
 				return true;
732 730
 			}
@@ -747,34 +745,34 @@  discard block
 block discarded – undo
747 745
 	 * or SparlHelper::EMPTY_RETRY_AFTER if there is an empty Retry-After
748 746
 	 * or SparlHelper::INVALID_RETRY_AFTER if there is something wrong with the format
749 747
 	 */
750
-	public function getThrottling( MWHttpRequest $request ) {
751
-		$retryAfterValue = $request->getResponseHeader( 'Retry-After' );
752
-		if ( $retryAfterValue === null ) {
748
+	public function getThrottling(MWHttpRequest $request) {
749
+		$retryAfterValue = $request->getResponseHeader('Retry-After');
750
+		if ($retryAfterValue === null) {
753 751
 			return self::NO_RETRY_AFTER;
754 752
 		}
755 753
 
756
-		$trimmedRetryAfterValue = trim( $retryAfterValue );
757
-		if ( empty( $trimmedRetryAfterValue ) ) {
754
+		$trimmedRetryAfterValue = trim($retryAfterValue);
755
+		if (empty($trimmedRetryAfterValue)) {
758 756
 			return self::EMPTY_RETRY_AFTER;
759 757
 		}
760 758
 
761
-		if ( is_numeric( $trimmedRetryAfterValue ) ) {
762
-			$delaySeconds = (int)$trimmedRetryAfterValue;
763
-			if ( $delaySeconds >= 0 ) {
764
-				return $this->getTimestampInFuture( new DateInterval( 'PT' . $delaySeconds . 'S' ) );
759
+		if (is_numeric($trimmedRetryAfterValue)) {
760
+			$delaySeconds = (int) $trimmedRetryAfterValue;
761
+			if ($delaySeconds >= 0) {
762
+				return $this->getTimestampInFuture(new DateInterval('PT'.$delaySeconds.'S'));
765 763
 			}
766 764
 		} else {
767
-			$return = strtotime( $trimmedRetryAfterValue );
768
-			if ( !empty( $return ) ) {
769
-				return new ConvertibleTimestamp( $return );
765
+			$return = strtotime($trimmedRetryAfterValue);
766
+			if (!empty($return)) {
767
+				return new ConvertibleTimestamp($return);
770 768
 			}
771 769
 		}
772 770
 		return self::INVALID_RETRY_AFTER;
773 771
 	}
774 772
 
775
-	private function getTimestampInFuture( DateInterval $delta ) {
773
+	private function getTimestampInFuture(DateInterval $delta) {
776 774
 		$now = new ConvertibleTimestamp();
777
-		return new ConvertibleTimestamp( $now->timestamp->add( $delta ) );
775
+		return new ConvertibleTimestamp($now->timestamp->add($delta));
778 776
 	}
779 777
 
780 778
 	/**
@@ -788,65 +786,64 @@  discard block
 block discarded – undo
788 786
 	 *
789 787
 	 * @throws SparqlHelperException if the query times out or some other error occurs
790 788
 	 */
791
-	public function runQuery( $query, $needsPrefixes = true ) {
789
+	public function runQuery($query, $needsPrefixes = true) {
792 790
 
793
-		if ( $this->throttlingLock->isLocked( self::EXPIRY_LOCK_ID ) ) {
794
-			$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.throttling' );
791
+		if ($this->throttlingLock->isLocked(self::EXPIRY_LOCK_ID)) {
792
+			$this->dataFactory->increment('wikibase.quality.constraints.sparql.throttling');
795 793
 			throw new TooManySparqlRequestsException();
796 794
 		}
797 795
 
798
-		if ( $this->sparqlHasWikibaseSupport ) {
796
+		if ($this->sparqlHasWikibaseSupport) {
799 797
 			$needsPrefixes = false;
800 798
 		}
801 799
 
802
-		if ( $needsPrefixes ) {
803
-			$query = $this->prefixes . $query;
800
+		if ($needsPrefixes) {
801
+			$query = $this->prefixes.$query;
804 802
 		}
805
-		$query = "#wbqc\n" . $query;
803
+		$query = "#wbqc\n".$query;
806 804
 
807
-		$url = $this->endpoint . '?' . http_build_query(
805
+		$url = $this->endpoint.'?'.http_build_query(
808 806
 			[
809 807
 				'query' => $query,
810 808
 				'format' => 'json',
811 809
 				'maxQueryTimeMillis' => $this->maxQueryTimeMillis,
812 810
 			],
813
-			null, ini_get( 'arg_separator.output' ),
811
+			null, ini_get('arg_separator.output'),
814 812
 			// encode spaces with %20, not +
815 813
 			PHP_QUERY_RFC3986
816 814
 		);
817 815
 
818 816
 		$options = [
819 817
 			'method' => 'GET',
820
-			'timeout' => (int)round( ( $this->maxQueryTimeMillis + 1000 ) / 1000 ),
818
+			'timeout' => (int) round(($this->maxQueryTimeMillis + 1000) / 1000),
821 819
 			'connectTimeout' => 'default',
822 820
 			'userAgent' => $this->defaultUserAgent,
823 821
 		];
824
-		$request = $this->requestFactory->create( $url, $options, __METHOD__ );
825
-		$startTime = microtime( true );
822
+		$request = $this->requestFactory->create($url, $options, __METHOD__);
823
+		$startTime = microtime(true);
826 824
 		$requestStatus = $request->execute();
827
-		$endTime = microtime( true );
825
+		$endTime = microtime(true);
828 826
 		$this->dataFactory->timing(
829 827
 			'wikibase.quality.constraints.sparql.timing',
830
-			( $endTime - $startTime ) * 1000
828
+			($endTime - $startTime) * 1000
831 829
 		);
832 830
 
833
-		$this->guardAgainstTooManyRequestsError( $request );
831
+		$this->guardAgainstTooManyRequestsError($request);
834 832
 
835
-		$maxAge = $this->getCacheMaxAge( $request->getResponseHeaders() );
836
-		if ( $maxAge ) {
837
-			$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.cached' );
833
+		$maxAge = $this->getCacheMaxAge($request->getResponseHeaders());
834
+		if ($maxAge) {
835
+			$this->dataFactory->increment('wikibase.quality.constraints.sparql.cached');
838 836
 		}
839 837
 
840
-		if ( $requestStatus->isOK() ) {
838
+		if ($requestStatus->isOK()) {
841 839
 			$json = $request->getContent();
842
-			$jsonStatus = FormatJson::parse( $json, FormatJson::FORCE_ASSOC );
843
-			if ( $jsonStatus->isOK() ) {
840
+			$jsonStatus = FormatJson::parse($json, FormatJson::FORCE_ASSOC);
841
+			if ($jsonStatus->isOK()) {
844 842
 				return new CachedQueryResults(
845 843
 					$jsonStatus->getValue(),
846 844
 					Metadata::ofCachingMetadata(
847 845
 						$maxAge ?
848
-							CachingMetadata::ofMaximumAgeInSeconds( $maxAge ) :
849
-							CachingMetadata::fresh()
846
+							CachingMetadata::ofMaximumAgeInSeconds($maxAge) : CachingMetadata::fresh()
850 847
 					)
851 848
 				);
852 849
 			} else {
@@ -863,9 +860,9 @@  discard block
 block discarded – undo
863 860
 			// fall through to general error handling
864 861
 		}
865 862
 
866
-		$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.error' );
863
+		$this->dataFactory->increment('wikibase.quality.constraints.sparql.error');
867 864
 
868
-		if ( $this->isTimeout( $request->getContent() ) ) {
865
+		if ($this->isTimeout($request->getContent())) {
869 866
 			$this->dataFactory->increment(
870 867
 				'wikibase.quality.constraints.sparql.error.timeout'
871 868
 			);
@@ -880,29 +877,29 @@  discard block
 block discarded – undo
880 877
 	 * @param MWHttpRequest $request
881 878
 	 * @throws TooManySparqlRequestsException
882 879
 	 */
883
-	private function guardAgainstTooManyRequestsError( MWHttpRequest $request ): void {
884
-		if ( $request->getStatus() !== self::HTTP_TOO_MANY_REQUESTS ) {
880
+	private function guardAgainstTooManyRequestsError(MWHttpRequest $request): void {
881
+		if ($request->getStatus() !== self::HTTP_TOO_MANY_REQUESTS) {
885 882
 			return;
886 883
 		}
887 884
 
888 885
 		$fallbackBlockDuration = $this->sparqlThrottlingFallbackDuration;
889 886
 
890
-		if ( $fallbackBlockDuration < 0 ) {
891
-			throw new InvalidArgumentException( 'Fallback duration must be positive int but is: ' .
892
-				$fallbackBlockDuration );
887
+		if ($fallbackBlockDuration < 0) {
888
+			throw new InvalidArgumentException('Fallback duration must be positive int but is: '.
889
+				$fallbackBlockDuration);
893 890
 		}
894 891
 
895
-		$this->dataFactory->increment( 'wikibase.quality.constraints.sparql.throttling' );
896
-		$throttlingUntil = $this->getThrottling( $request );
897
-		if ( !( $throttlingUntil instanceof ConvertibleTimestamp ) ) {
898
-			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterInvalid( $request );
892
+		$this->dataFactory->increment('wikibase.quality.constraints.sparql.throttling');
893
+		$throttlingUntil = $this->getThrottling($request);
894
+		if (!($throttlingUntil instanceof ConvertibleTimestamp)) {
895
+			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterInvalid($request);
899 896
 			$this->throttlingLock->lock(
900 897
 				self::EXPIRY_LOCK_ID,
901
-				$this->getTimestampInFuture( new DateInterval( 'PT' . $fallbackBlockDuration . 'S' ) )
898
+				$this->getTimestampInFuture(new DateInterval('PT'.$fallbackBlockDuration.'S'))
902 899
 			);
903 900
 		} else {
904
-			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterPresent( $throttlingUntil, $request );
905
-			$this->throttlingLock->lock( self::EXPIRY_LOCK_ID, $throttlingUntil );
901
+			$this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterPresent($throttlingUntil, $request);
902
+			$this->throttlingLock->lock(self::EXPIRY_LOCK_ID, $throttlingUntil);
906 903
 		}
907 904
 		throw new TooManySparqlRequestsException();
908 905
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/DummySparqlHelper.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
 		// no parent::__construct() call
24 24
 	}
25 25
 
26
-	public function hasType( $id, array $classes ) {
27
-		throw new LogicException( 'methods of this class should never be called' );
26
+	public function hasType($id, array $classes) {
27
+		throw new LogicException('methods of this class should never be called');
28 28
 	}
29 29
 
30 30
 	public function findEntitiesWithSameStatement(
31 31
 		Statement $statement,
32 32
 		array $separators
33 33
 	) {
34
-		throw new LogicException( 'methods of this class should never be called' );
34
+		throw new LogicException('methods of this class should never be called');
35 35
 	}
36 36
 
37 37
 	public function findEntitiesWithSameQualifierOrReference(
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
 		$type,
41 41
 		$ignoreDeprecatedStatements
42 42
 	) {
43
-		throw new LogicException( 'methods of this class should never be called' );
43
+		throw new LogicException('methods of this class should never be called');
44 44
 	}
45 45
 
46
-	public function matchesRegularExpression( $text, $regex ) {
47
-		throw new LogicException( 'methods of this class should never be called' );
46
+	public function matchesRegularExpression($text, $regex) {
47
+		throw new LogicException('methods of this class should never be called');
48 48
 	}
49 49
 
50
-	public function runQuery( $query, $needsPrefixes = true ) {
51
-		throw new LogicException( 'methods of this class should never be called' );
50
+	public function runQuery($query, $needsPrefixes = true) {
51
+		throw new LogicException('methods of this class should never be called');
52 52
 	}
53 53
 
54 54
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/UniqueValueChecker.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -76,29 +76,29 @@  discard block
 block discarded – undo
76 76
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
77 77
 	 * @return CheckResult
78 78
 	 */
79
-	public function checkConstraint( Context $context, Constraint $constraint ) {
80
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
81
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
79
+	public function checkConstraint(Context $context, Constraint $constraint) {
80
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
81
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
82 82
 		}
83 83
 		$parameters = [];
84 84
 
85
-		if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) {
85
+		if (!($this->sparqlHelper instanceof DummySparqlHelper)) {
86 86
 
87 87
 			$separators = $this->constraintParameterParser->parseSeparatorsParameter(
88 88
 				$constraint->getConstraintParameters()
89 89
 			);
90 90
 			$parameters['separator'] = $separators;
91 91
 
92
-			if ( $context->getType() === 'statement' ) {
92
+			if ($context->getType() === 'statement') {
93 93
 				$result = $this->sparqlHelper->findEntitiesWithSameStatement(
94 94
 					$context->getSnakStatement(),
95 95
 					$separators
96 96
 				);
97 97
 			} else {
98 98
 				$snak = $context->getSnak();
99
-				if ( !$snak instanceof PropertyValueSnak ) {
99
+				if (!$snak instanceof PropertyValueSnak) {
100 100
 					// nothing to check
101
-					return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
101
+					return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
102 102
 				}
103 103
 				$result = $this->sparqlHelper->findEntitiesWithSameQualifierOrReference(
104 104
 					$context->getEntity()->getId(),
@@ -111,32 +111,32 @@  discard block
 block discarded – undo
111 111
 			$otherEntities = $result->getArray();
112 112
 			$metadata = $result->getMetadata();
113 113
 
114
-			if ( $otherEntities === [] ) {
114
+			if ($otherEntities === []) {
115 115
 				$status = CheckResult::STATUS_COMPLIANCE;
116 116
 				$message = null;
117 117
 			} else {
118
-				$otherEntities = array_values( array_filter( $otherEntities ) ); // remove nulls
118
+				$otherEntities = array_values(array_filter($otherEntities)); // remove nulls
119 119
 				$status = CheckResult::STATUS_VIOLATION;
120
-				$message = ( new ViolationMessage( 'wbqc-violation-message-unique-value' ) )
121
-					->withEntityIdList( $otherEntities, Role::SUBJECT );
120
+				$message = (new ViolationMessage('wbqc-violation-message-unique-value'))
121
+					->withEntityIdList($otherEntities, Role::SUBJECT);
122 122
 			}
123 123
 		} else {
124 124
 			$status = CheckResult::STATUS_TODO;
125
-			$message = ( new ViolationMessage( 'wbqc-violation-message-not-yet-implemented' ) )
126
-				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM );
125
+			$message = (new ViolationMessage('wbqc-violation-message-not-yet-implemented'))
126
+				->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM);
127 127
 			$metadata = Metadata::blank();
128 128
 		}
129 129
 
130
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
131
-			->withMetadata( $metadata );
130
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
131
+			->withMetadata($metadata);
132 132
 	}
133 133
 
134
-	public function checkConstraintParameters( Constraint $constraint ) {
134
+	public function checkConstraintParameters(Constraint $constraint) {
135 135
 		$constraintParameters = $constraint->getConstraintParameters();
136 136
 		$exceptions = [];
137 137
 		try {
138
-			$this->constraintParameterParser->parseSeparatorsParameter( $constraintParameters );
139
-		} catch ( ConstraintParameterException $e ) {
138
+			$this->constraintParameterParser->parseSeparatorsParameter($constraintParameters);
139
+		} catch (ConstraintParameterException $e) {
140 140
 			$exceptions[] = $e;
141 141
 		}
142 142
 		return $exceptions;
Please login to merge, or discard this patch.
src/Specials/SpecialConstraintReport.php 1 patch
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		Config $config,
135 135
 		IBufferingStatsdDataFactory $dataFactory
136 136
 	) {
137
-		parent::__construct( 'ConstraintReport' );
137
+		parent::__construct('ConstraintReport');
138 138
 
139 139
 		$this->entityLookup = $entityLookup;
140 140
 		$this->entityTitleLookup = $entityTitleLookup;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		$language = $this->getLanguage();
144 144
 
145 145
 		$formatterOptions = new FormatterOptions();
146
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
146
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
147 147
 		$this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(
148 148
 			SnakFormatter::FORMAT_HTML,
149 149
 			$formatterOptions
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @return string
204 204
 	 */
205 205
 	public function getDescription() {
206
-		return $this->msg( 'wbqc-constraintreport' )->escaped();
206
+		return $this->msg('wbqc-constraintreport')->escaped();
207 207
 	}
208 208
 
209 209
 	/**
@@ -215,43 +215,43 @@  discard block
 block discarded – undo
215 215
 	 * @throws EntityIdParsingException
216 216
 	 * @throws UnexpectedValueException
217 217
 	 */
218
-	public function execute( $subPage ) {
218
+	public function execute($subPage) {
219 219
 		$out = $this->getOutput();
220 220
 
221
-		$postRequest = $this->getContext()->getRequest()->getVal( 'entityid' );
222
-		if ( $postRequest ) {
223
-			$out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() );
221
+		$postRequest = $this->getContext()->getRequest()->getVal('entityid');
222
+		if ($postRequest) {
223
+			$out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL());
224 224
 			return;
225 225
 		}
226 226
 
227 227
 		$out->enableOOUI();
228
-		$out->addModules( $this->getModules() );
228
+		$out->addModules($this->getModules());
229 229
 
230 230
 		$this->setHeaders();
231 231
 
232
-		$out->addHTML( $this->getExplanationText() );
232
+		$out->addHTML($this->getExplanationText());
233 233
 		$this->buildEntityIdForm();
234 234
 
235
-		if ( !$subPage ) {
235
+		if (!$subPage) {
236 236
 			return;
237 237
 		}
238 238
 
239
-		if ( !is_string( $subPage ) ) {
240
-			throw new InvalidArgumentException( '$subPage must be string.' );
239
+		if (!is_string($subPage)) {
240
+			throw new InvalidArgumentException('$subPage must be string.');
241 241
 		}
242 242
 
243 243
 		try {
244
-			$entityId = $this->entityIdParser->parse( $subPage );
245
-		} catch ( EntityIdParsingException $e ) {
244
+			$entityId = $this->entityIdParser->parse($subPage);
245
+		} catch (EntityIdParsingException $e) {
246 246
 			$out->addHTML(
247
-				$this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true )
247
+				$this->buildNotice('wbqc-constraintreport-invalid-entity-id', true)
248 248
 			);
249 249
 			return;
250 250
 		}
251 251
 
252
-		if ( !$this->entityLookup->hasEntity( $entityId ) ) {
252
+		if (!$this->entityLookup->hasEntity($entityId)) {
253 253
 			$out->addHTML(
254
-				$this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true )
254
+				$this->buildNotice('wbqc-constraintreport-not-existent-entity', true)
255 255
 			);
256 256
 			return;
257 257
 		}
@@ -259,18 +259,18 @@  discard block
 block discarded – undo
259 259
 		$this->dataFactory->increment(
260 260
 			'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck'
261 261
 		);
262
-		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId );
262
+		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId);
263 263
 
264
-		if ( $results !== [] ) {
264
+		if ($results !== []) {
265 265
 			$out->addHTML(
266
-				$this->buildResultHeader( $entityId )
267
-				. $this->buildSummary( $results )
268
-				. $this->buildResultTable( $entityId, $results )
266
+				$this->buildResultHeader($entityId)
267
+				. $this->buildSummary($results)
268
+				. $this->buildResultTable($entityId, $results)
269 269
 			);
270 270
 		} else {
271 271
 			$out->addHTML(
272
-				$this->buildResultHeader( $entityId )
273
-				. $this->buildNotice( 'wbqc-constraintreport-empty-result' )
272
+				$this->buildResultHeader($entityId)
273
+				. $this->buildNotice('wbqc-constraintreport-empty-result')
274 274
 			);
275 275
 		}
276 276
 	}
@@ -286,15 +286,15 @@  discard block
 block discarded – undo
286 286
 				'name' => 'entityid',
287 287
 				'label-message' => 'wbqc-constraintreport-form-entityid-label',
288 288
 				'cssclass' => 'wbqc-constraintreport-form-entity-id',
289
-				'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped()
289
+				'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped()
290 290
 			]
291 291
 		];
292
-		$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' );
293
-		$htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() );
294
-		$htmlForm->setSubmitCallback( static function () {
292
+		$htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form');
293
+		$htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped());
294
+		$htmlForm->setSubmitCallback(static function() {
295 295
 			return false;
296 296
 		} );
297
-		$htmlForm->setMethod( 'post' );
297
+		$htmlForm->setMethod('post');
298 298
 		$htmlForm->show();
299 299
 	}
300 300
 
@@ -308,16 +308,16 @@  discard block
 block discarded – undo
308 308
 	 *
309 309
 	 * @return string HTML
310 310
 	 */
311
-	private function buildNotice( $messageKey, $error = false ) {
312
-		if ( !is_string( $messageKey ) ) {
313
-			throw new InvalidArgumentException( '$message must be string.' );
311
+	private function buildNotice($messageKey, $error = false) {
312
+		if (!is_string($messageKey)) {
313
+			throw new InvalidArgumentException('$message must be string.');
314 314
 		}
315
-		if ( !is_bool( $error ) ) {
316
-			throw new InvalidArgumentException( '$error must be bool.' );
315
+		if (!is_bool($error)) {
316
+			throw new InvalidArgumentException('$error must be bool.');
317 317
 		}
318 318
 
319 319
 		$cssClasses = 'wbqc-constraintreport-notice';
320
-		if ( $error ) {
320
+		if ($error) {
321 321
 			$cssClasses .= ' wbqc-constraintreport-notice-error';
322 322
 		}
323 323
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 				[
327 327
 					'class' => $cssClasses
328 328
 				],
329
-				$this->msg( $messageKey )->escaped()
329
+				$this->msg($messageKey)->escaped()
330 330
 			);
331 331
 	}
332 332
 
@@ -336,16 +336,16 @@  discard block
 block discarded – undo
336 336
 	private function getExplanationText() {
337 337
 		return Html::rawElement(
338 338
 			'div',
339
-			[ 'class' => 'wbqc-explanation' ],
339
+			['class' => 'wbqc-explanation'],
340 340
 			Html::rawElement(
341 341
 				'p',
342 342
 				[],
343
-				$this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped()
343
+				$this->msg('wbqc-constraintreport-explanation-part-one')->escaped()
344 344
 			)
345 345
 			. Html::rawElement(
346 346
 				'p',
347 347
 				[],
348
-				$this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped()
348
+				$this->msg('wbqc-constraintreport-explanation-part-two')->escaped()
349 349
 			)
350 350
 		);
351 351
 	}
@@ -357,72 +357,72 @@  discard block
 block discarded – undo
357 357
 	 * @return string HTML
358 358
 	 * @suppress SecurityCheck-DoubleEscaped
359 359
 	 */
360
-	private function buildResultTable( EntityId $entityId, array $results ) {
360
+	private function buildResultTable(EntityId $entityId, array $results) {
361 361
 		// Set table headers
362 362
 		$table = new HtmlTableBuilder(
363 363
 			[
364 364
 				new HtmlTableHeaderBuilder(
365
-					$this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(),
365
+					$this->msg('wbqc-constraintreport-result-table-header-status')->escaped(),
366 366
 					true
367 367
 				),
368 368
 				new HtmlTableHeaderBuilder(
369
-					$this->msg( 'wbqc-constraintreport-result-table-header-property' )->escaped(),
369
+					$this->msg('wbqc-constraintreport-result-table-header-property')->escaped(),
370 370
 					true
371 371
 				),
372 372
 				new HtmlTableHeaderBuilder(
373
-					$this->msg( 'wbqc-constraintreport-result-table-header-message' )->escaped(),
373
+					$this->msg('wbqc-constraintreport-result-table-header-message')->escaped(),
374 374
 					true
375 375
 				),
376 376
 				new HtmlTableHeaderBuilder(
377
-					$this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(),
377
+					$this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(),
378 378
 					true
379 379
 				)
380 380
 			]
381 381
 		);
382 382
 
383
-		foreach ( $results as $result ) {
384
-			$table = $this->appendToResultTable( $table, $entityId, $result );
383
+		foreach ($results as $result) {
384
+			$table = $this->appendToResultTable($table, $entityId, $result);
385 385
 		}
386 386
 
387 387
 		return $table->toHtml();
388 388
 	}
389 389
 
390
-	private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) {
390
+	private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) {
391 391
 		$message = $result->getMessage();
392
-		if ( $message === null ) {
392
+		if ($message === null) {
393 393
 			// no row for this result
394 394
 			return $table;
395 395
 		}
396 396
 
397 397
 		// Status column
398
-		$statusColumn = $this->formatStatus( $result->getStatus() );
398
+		$statusColumn = $this->formatStatus($result->getStatus());
399 399
 
400 400
 		// Property column
401
-		$propertyId = new NumericPropertyId( $result->getContextCursor()->getSnakPropertyId() );
401
+		$propertyId = new NumericPropertyId($result->getContextCursor()->getSnakPropertyId());
402 402
 		$propertyColumn = $this->getClaimLink(
403 403
 			$entityId,
404 404
 			$propertyId,
405
-			$this->entityIdLabelFormatter->formatEntityId( $propertyId )
405
+			$this->entityIdLabelFormatter->formatEntityId($propertyId)
406 406
 		);
407 407
 
408 408
 		// Message column
409
-		$messageColumn = $this->violationMessageRenderer->render( $message );
409
+		$messageColumn = $this->violationMessageRenderer->render($message);
410 410
 
411 411
 		// Constraint column
412 412
 		$constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId();
413 413
 		try {
414
-			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) );
415
-		} catch ( InvalidArgumentException $e ) {
416
-			$constraintTypeLabel = htmlspecialchars( $constraintTypeItemId );
414
+			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId));
415
+		} catch (InvalidArgumentException $e) {
416
+			$constraintTypeLabel = htmlspecialchars($constraintTypeItemId);
417 417
 		}
418 418
 		$constraintLink = $this->getClaimLink(
419 419
 			$propertyId,
420
-			new NumericPropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ),
420
+			new NumericPropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')),
421 421
 			$constraintTypeLabel
422 422
 		);
423 423
 		$constraintColumn = $this->buildExpandableElement(
424 424
 			$constraintLink,
425
-			$this->constraintParameterRenderer->formatParameters( $result->getParameters() ),
425
+			$this->constraintParameterRenderer->formatParameters($result->getParameters()),
426 426
 			'[...]'
427 427
 		);
428 428
 
@@ -462,15 +462,15 @@  discard block
 block discarded – undo
462 462
 	 *
463 463
 	 * @return string HTML
464 464
 	 */
465
-	protected function buildResultHeader( EntityId $entityId ) {
466
-		$entityLink = sprintf( '%s (%s)',
467
-							   $this->entityIdLinkFormatter->formatEntityId( $entityId ),
468
-							   htmlspecialchars( $entityId->getSerialization() ) );
465
+	protected function buildResultHeader(EntityId $entityId) {
466
+		$entityLink = sprintf('%s (%s)',
467
+							   $this->entityIdLinkFormatter->formatEntityId($entityId),
468
+							   htmlspecialchars($entityId->getSerialization()));
469 469
 
470 470
 		return Html::rawElement(
471 471
 			'h3',
472 472
 			[],
473
-			sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
473
+			sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink)
474 474
 		);
475 475
 	}
476 476
 
@@ -481,24 +481,24 @@  discard block
 block discarded – undo
481 481
 	 *
482 482
 	 * @return string HTML
483 483
 	 */
484
-	protected function buildSummary( array $results ) {
484
+	protected function buildSummary(array $results) {
485 485
 		$statuses = [];
486
-		foreach ( $results as $result ) {
487
-			$status = strtolower( $result->getStatus() );
488
-			$statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1;
486
+		foreach ($results as $result) {
487
+			$status = strtolower($result->getStatus());
488
+			$statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1;
489 489
 		}
490 490
 
491 491
 		$statusElements = [];
492
-		foreach ( $statuses as $status => $count ) {
493
-			if ( $count > 0 ) {
492
+		foreach ($statuses as $status => $count) {
493
+			if ($count > 0) {
494 494
 				$statusElements[] =
495
-					$this->formatStatus( $status )
495
+					$this->formatStatus($status)
496 496
 					. ': '
497 497
 					. $count;
498 498
 			}
499 499
 		}
500 500
 
501
-		return Html::rawElement( 'p', [], implode( ', ', $statusElements ) );
501
+		return Html::rawElement('p', [], implode(', ', $statusElements));
502 502
 	}
503 503
 
504 504
 	/**
@@ -513,15 +513,15 @@  discard block
 block discarded – undo
513 513
 	 *
514 514
 	 * @return string HTML
515 515
 	 */
516
-	protected function buildExpandableElement( $content, $expandableContent, $indicator ) {
517
-		if ( !is_string( $content ) ) {
518
-			throw new InvalidArgumentException( '$content has to be string.' );
516
+	protected function buildExpandableElement($content, $expandableContent, $indicator) {
517
+		if (!is_string($content)) {
518
+			throw new InvalidArgumentException('$content has to be string.');
519 519
 		}
520
-		if ( $expandableContent && ( !is_string( $expandableContent ) ) ) {
521
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
520
+		if ($expandableContent && (!is_string($expandableContent))) {
521
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
522 522
 		}
523 523
 
524
-		if ( empty( $expandableContent ) ) {
524
+		if (empty($expandableContent)) {
525 525
 			return $content;
526 526
 		}
527 527
 
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 			$expandableContent
542 542
 		);
543 543
 
544
-		return sprintf( '%s %s %s', $content, $tooltipIndicator, $wrappedExpandableContent );
544
+		return sprintf('%s %s %s', $content, $tooltipIndicator, $wrappedExpandableContent);
545 545
 	}
546 546
 
547 547
 	/**
@@ -553,8 +553,8 @@  discard block
 block discarded – undo
553 553
 	 *
554 554
 	 * @return string HTML
555 555
 	 */
556
-	private function formatStatus( $status ) {
557
-		$messageName = "wbqc-constraintreport-status-" . strtolower( $status );
556
+	private function formatStatus($status) {
557
+		$messageName = "wbqc-constraintreport-status-".strtolower($status);
558 558
 		$statusIcons = [
559 559
 			CheckResult::STATUS_SUGGESTION => [
560 560
 				'icon' => 'suggestion-constraint-violation',
@@ -571,25 +571,25 @@  discard block
 block discarded – undo
571 571
 			],
572 572
 		];
573 573
 
574
-		if ( array_key_exists( $status, $statusIcons ) ) {
575
-			$iconWidget = new IconWidget( $statusIcons[$status] );
576
-			$iconHtml = $iconWidget->toString() . ' ';
574
+		if (array_key_exists($status, $statusIcons)) {
575
+			$iconWidget = new IconWidget($statusIcons[$status]);
576
+			$iconHtml = $iconWidget->toString().' ';
577 577
 		} else {
578 578
 			$iconHtml = '';
579 579
 		}
580 580
 
581
-		$labelWidget = new LabelWidget( [
582
-			'label' => $this->msg( $messageName )->text(),
583
-		] );
581
+		$labelWidget = new LabelWidget([
582
+			'label' => $this->msg($messageName)->text(),
583
+		]);
584 584
 		$labelHtml = $labelWidget->toString();
585 585
 
586 586
 		$formattedStatus =
587 587
 			Html::rawElement(
588 588
 				'span',
589 589
 				[
590
-					'class' => 'wbqc-status wbqc-status-' . $status
590
+					'class' => 'wbqc-status wbqc-status-'.$status
591 591
 				],
592
-				$iconHtml . $labelHtml
592
+				$iconHtml.$labelHtml
593 593
 			);
594 594
 
595 595
 		return $formattedStatus;
@@ -605,26 +605,26 @@  discard block
 block discarded – undo
605 605
 	 *
606 606
 	 * @return string HTML
607 607
 	 */
608
-	protected function formatDataValues( $dataValues, $separator = ', ' ) {
609
-		if ( $dataValues instanceof DataValue ) {
610
-			$dataValues = [ $dataValues ];
611
-		} elseif ( !is_array( $dataValues ) ) {
612
-			throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
608
+	protected function formatDataValues($dataValues, $separator = ', ') {
609
+		if ($dataValues instanceof DataValue) {
610
+			$dataValues = [$dataValues];
611
+		} elseif (!is_array($dataValues)) {
612
+			throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
613 613
 		}
614 614
 
615 615
 		$formattedDataValues = [];
616
-		foreach ( $dataValues as $dataValue ) {
617
-			if ( !( $dataValue instanceof DataValue ) ) {
618
-				throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
616
+		foreach ($dataValues as $dataValue) {
617
+			if (!($dataValue instanceof DataValue)) {
618
+				throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
619 619
 			}
620
-			if ( $dataValue instanceof EntityIdValue ) {
621
-				$formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() );
620
+			if ($dataValue instanceof EntityIdValue) {
621
+				$formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId());
622 622
 			} else {
623
-				$formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue );
623
+				$formattedDataValues[] = $this->dataValueFormatter->format($dataValue);
624 624
 			}
625 625
 		}
626 626
 
627
-		return implode( $separator, $formattedDataValues );
627
+		return implode($separator, $formattedDataValues);
628 628
 	}
629 629
 
630 630
 	/**
@@ -636,11 +636,11 @@  discard block
 block discarded – undo
636 636
 	 *
637 637
 	 * @return string HTML
638 638
 	 */
639
-	private function getClaimLink( EntityId $entityId, NumericPropertyId $propertyId, $text ) {
639
+	private function getClaimLink(EntityId $entityId, NumericPropertyId $propertyId, $text) {
640 640
 		return Html::rawElement(
641 641
 			'a',
642 642
 			[
643
-				'href' => $this->getClaimUrl( $entityId, $propertyId ),
643
+				'href' => $this->getClaimUrl($entityId, $propertyId),
644 644
 				'target' => '_blank'
645 645
 			],
646 646
 			$text
@@ -655,9 +655,9 @@  discard block
 block discarded – undo
655 655
 	 *
656 656
 	 * @return string
657 657
 	 */
658
-	private function getClaimUrl( EntityId $entityId, NumericPropertyId $propertyId ) {
659
-		$title = $this->entityTitleLookup->getTitleForId( $entityId );
660
-		$entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() );
658
+	private function getClaimUrl(EntityId $entityId, NumericPropertyId $propertyId) {
659
+		$title = $this->entityTitleLookup->getTitleForId($entityId);
660
+		$entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization());
661 661
 
662 662
 		return $entityUrl;
663 663
 	}
Please login to merge, or discard this patch.
src/Job/UpdateConstraintsTableJob.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	private const BATCH_SIZE = 50;
40 40
 
41
-	public static function newFromGlobalState( Title $title, array $params ) {
42
-		Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' );
41
+	public static function newFromGlobalState(Title $title, array $params) {
42
+		Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]');
43 43
 		$services = MediaWikiServices::getInstance();
44 44
 		return new UpdateConstraintsTableJob(
45 45
 			$title,
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 			$services->getMainConfig(),
50 50
 			ConstraintsServices::getConstraintStore(),
51 51
 			$services->getDBLoadBalancerFactory(),
52
-			WikibaseRepo::getStore()->getEntityRevisionLookup( Store::LOOKUP_CACHING_DISABLED ),
53
-			WikibaseRepo::getBaseDataModelSerializerFactory( $services )
52
+			WikibaseRepo::getStore()->getEntityRevisionLookup(Store::LOOKUP_CACHING_DISABLED),
53
+			WikibaseRepo::getBaseDataModelSerializerFactory($services)
54 54
 				->newSnakSerializer()
55 55
 		);
56 56
 	}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		EntityRevisionLookup $entityRevisionLookup,
111 111
 		Serializer $snakSerializer
112 112
 	) {
113
-		parent::__construct( 'constraintsTableUpdate', $title, $params );
113
+		parent::__construct('constraintsTableUpdate', $title, $params);
114 114
 
115 115
 		$this->propertyId = $propertyId;
116 116
 		$this->revisionId = $revisionId;
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
 		$this->snakSerializer = $snakSerializer;
122 122
 	}
123 123
 
124
-	public function extractParametersFromQualifiers( SnakList $qualifiers ) {
124
+	public function extractParametersFromQualifiers(SnakList $qualifiers) {
125 125
 		$parameters = [];
126
-		foreach ( $qualifiers as $qualifier ) {
126
+		foreach ($qualifiers as $qualifier) {
127 127
 			$qualifierId = $qualifier->getPropertyId()->getSerialization();
128
-			$paramSerialization = $this->snakSerializer->serialize( $qualifier );
128
+			$paramSerialization = $this->snakSerializer->serialize($qualifier);
129 129
 			$parameters[$qualifierId][] = $paramSerialization;
130 130
 		}
131 131
 		return $parameters;
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		'@phan-var \Wikibase\DataModel\Entity\EntityIdValue $dataValue';
143 143
 		$entityId = $dataValue->getEntityId();
144 144
 		$constraintTypeQid = $entityId->getSerialization();
145
-		$parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() );
145
+		$parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers());
146 146
 		return new Constraint(
147 147
 			$constraintId,
148 148
 			$propertyId,
@@ -157,24 +157,24 @@  discard block
 block discarded – undo
157 157
 		NumericPropertyId $propertyConstraintPropertyId
158 158
 	) {
159 159
 		$constraintsStatements = $property->getStatements()
160
-			->getByPropertyId( $propertyConstraintPropertyId )
161
-			->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] );
160
+			->getByPropertyId($propertyConstraintPropertyId)
161
+			->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]);
162 162
 		$constraints = [];
163
-		foreach ( $constraintsStatements->getIterator() as $constraintStatement ) {
164
-			$constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement );
165
-			if ( count( $constraints ) >= self::BATCH_SIZE ) {
166
-				$constraintStore->insertBatch( $constraints );
163
+		foreach ($constraintsStatements->getIterator() as $constraintStatement) {
164
+			$constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement);
165
+			if (count($constraints) >= self::BATCH_SIZE) {
166
+				$constraintStore->insertBatch($constraints);
167 167
 				// interrupt transaction and wait for replication
168
-				$connection = $this->lbFactory->getMainLB()->getConnection( DB_PRIMARY );
169
-				$connection->endAtomic( __CLASS__ );
170
-				if ( !$connection->explicitTrxActive() ) {
168
+				$connection = $this->lbFactory->getMainLB()->getConnection(DB_PRIMARY);
169
+				$connection->endAtomic(__CLASS__);
170
+				if (!$connection->explicitTrxActive()) {
171 171
 					$this->lbFactory->waitForReplication();
172 172
 				}
173
-				$connection->startAtomic( __CLASS__ );
173
+				$connection->startAtomic(__CLASS__);
174 174
 				$constraints = [];
175 175
 			}
176 176
 		}
177
-		$constraintStore->insertBatch( $constraints );
177
+		$constraintStore->insertBatch($constraints);
178 178
 	}
179 179
 
180 180
 	/**
@@ -185,24 +185,24 @@  discard block
 block discarded – undo
185 185
 	public function run() {
186 186
 		// TODO in the future: only touch constraints affected by the edit (requires T163465)
187 187
 
188
-		$propertyId = new NumericPropertyId( $this->propertyId );
188
+		$propertyId = new NumericPropertyId($this->propertyId);
189 189
 		$propertyRevision = $this->entityRevisionLookup->getEntityRevision(
190 190
 			$propertyId,
191 191
 			0, // latest
192 192
 			LookupConstants::LATEST_FROM_REPLICA
193 193
 		);
194 194
 
195
-		if ( $this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId ) {
196
-			JobQueueGroup::singleton()->push( $this );
195
+		if ($this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId) {
196
+			JobQueueGroup::singleton()->push($this);
197 197
 			return true;
198 198
 		}
199 199
 
200
-		$connection = $this->lbFactory->getMainLB()->getConnection( DB_PRIMARY );
200
+		$connection = $this->lbFactory->getMainLB()->getConnection(DB_PRIMARY);
201 201
 		// start transaction (if not started yet) – using __CLASS__, not __METHOD__,
202 202
 		// because importConstraintsForProperty() can interrupt the transaction
203
-		$connection->startAtomic( __CLASS__ );
203
+		$connection->startAtomic(__CLASS__);
204 204
 
205
-		$this->constraintStore->deleteForProperty( $propertyId );
205
+		$this->constraintStore->deleteForProperty($propertyId);
206 206
 
207 207
 		/** @var Property $property */
208 208
 		$property = $propertyRevision->getEntity();
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
 		$this->importConstraintsForProperty(
211 211
 			$property,
212 212
 			$this->constraintStore,
213
-			new NumericPropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) )
213
+			new NumericPropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId'))
214 214
 		);
215 215
 
216
-		$connection->endAtomic( __CLASS__ );
216
+		$connection->endAtomic(__CLASS__);
217 217
 
218 218
 		return true;
219 219
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/DelegatingConstraintChecker.php 1 patch
Spacing   +158 added lines, -158 removed lines patch added patch discarded remove patch
@@ -144,10 +144,10 @@  discard block
 block discarded – undo
144 144
 		callable $defaultResultsPerEntity = null
145 145
 	) {
146 146
 		$checkResults = [];
147
-		$entity = $this->entityLookup->getEntity( $entityId );
147
+		$entity = $this->entityLookup->getEntity($entityId);
148 148
 
149
-		if ( $entity instanceof StatementListProvidingEntity ) {
150
-			$startTime = microtime( true );
149
+		if ($entity instanceof StatementListProvidingEntity) {
150
+			$startTime = microtime(true);
151 151
 
152 152
 			$checkResults = $this->checkEveryStatement(
153 153
 				$entity,
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 				$defaultResultsPerContext
156 156
 			);
157 157
 
158
-			$endTime = microtime( true );
158
+			$endTime = microtime(true);
159 159
 
160
-			if ( $constraintIds === null ) { // only log full constraint checks
160
+			if ($constraintIds === null) { // only log full constraint checks
161 161
 				$this->loggingHelper->logConstraintCheckOnEntity(
162 162
 					$entityId,
163 163
 					$checkResults,
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 			}
168 168
 		}
169 169
 
170
-		if ( $defaultResultsPerEntity !== null ) {
171
-			$checkResults = array_merge( $defaultResultsPerEntity( $entityId ), $checkResults );
170
+		if ($defaultResultsPerEntity !== null) {
171
+			$checkResults = array_merge($defaultResultsPerEntity($entityId), $checkResults);
172 172
 		}
173 173
 
174
-		return $this->sortResult( $checkResults );
174
+		return $this->sortResult($checkResults);
175 175
 	}
176 176
 
177 177
 	/**
@@ -193,19 +193,19 @@  discard block
 block discarded – undo
193 193
 		callable $defaultResults = null
194 194
 	) {
195 195
 
196
-		$parsedGuid = $this->statementGuidParser->parse( $guid );
196
+		$parsedGuid = $this->statementGuidParser->parse($guid);
197 197
 		$entityId = $parsedGuid->getEntityId();
198
-		$entity = $this->entityLookup->getEntity( $entityId );
199
-		if ( $entity instanceof StatementListProvidingEntity ) {
200
-			$statement = $entity->getStatements()->getFirstStatementWithGuid( $guid );
201
-			if ( $statement ) {
198
+		$entity = $this->entityLookup->getEntity($entityId);
199
+		if ($entity instanceof StatementListProvidingEntity) {
200
+			$statement = $entity->getStatements()->getFirstStatementWithGuid($guid);
201
+			if ($statement) {
202 202
 				$result = $this->checkStatement(
203 203
 					$entity,
204 204
 					$statement,
205 205
 					$constraintIds,
206 206
 					$defaultResults
207 207
 				);
208
-				$output = $this->sortResult( $result );
208
+				$output = $this->sortResult($result);
209 209
 				return $output;
210 210
 			}
211 211
 		}
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 		return [];
214 214
 	}
215 215
 
216
-	private function getValidContextTypes( Constraint $constraint ) {
217
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
216
+	private function getValidContextTypes(Constraint $constraint) {
217
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
218 218
 			return [
219 219
 				Context::TYPE_STATEMENT,
220 220
 				Context::TYPE_QUALIFIER,
@@ -222,25 +222,25 @@  discard block
 block discarded – undo
222 222
 			];
223 223
 		}
224 224
 
225
-		return array_keys( array_filter(
225
+		return array_keys(array_filter(
226 226
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedContextTypes(),
227
-			static function ( $resultStatus ) {
227
+			static function($resultStatus) {
228 228
 				return $resultStatus !== CheckResult::STATUS_NOT_IN_SCOPE;
229 229
 			}
230
-		) );
230
+		));
231 231
 	}
232 232
 
233
-	private function getValidEntityTypes( Constraint $constraint ) {
234
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
235
-			return array_keys( ConstraintChecker::ALL_ENTITY_TYPES_SUPPORTED );
233
+	private function getValidEntityTypes(Constraint $constraint) {
234
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
235
+			return array_keys(ConstraintChecker::ALL_ENTITY_TYPES_SUPPORTED);
236 236
 		}
237 237
 
238
-		return array_keys( array_filter(
238
+		return array_keys(array_filter(
239 239
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedEntityTypes(),
240
-			static function ( $resultStatus ) {
240
+			static function($resultStatus) {
241 241
 				return $resultStatus !== CheckResult::STATUS_NOT_IN_SCOPE;
242 242
 			}
243
-		) );
243
+		));
244 244
 	}
245 245
 
246 246
 	/**
@@ -251,33 +251,33 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @return ConstraintParameterException[]
253 253
 	 */
254
-	private function checkCommonConstraintParameters( Constraint $constraint ) {
254
+	private function checkCommonConstraintParameters(Constraint $constraint) {
255 255
 		$constraintParameters = $constraint->getConstraintParameters();
256 256
 		try {
257
-			$this->constraintParameterParser->checkError( $constraintParameters );
258
-		} catch ( ConstraintParameterException $e ) {
259
-			return [ $e ];
257
+			$this->constraintParameterParser->checkError($constraintParameters);
258
+		} catch (ConstraintParameterException $e) {
259
+			return [$e];
260 260
 		}
261 261
 
262 262
 		$problems = [];
263 263
 		try {
264
-			$this->constraintParameterParser->parseExceptionParameter( $constraintParameters );
265
-		} catch ( ConstraintParameterException $e ) {
264
+			$this->constraintParameterParser->parseExceptionParameter($constraintParameters);
265
+		} catch (ConstraintParameterException $e) {
266 266
 			$problems[] = $e;
267 267
 		}
268 268
 		try {
269
-			$this->constraintParameterParser->parseConstraintStatusParameter( $constraintParameters );
270
-		} catch ( ConstraintParameterException $e ) {
269
+			$this->constraintParameterParser->parseConstraintStatusParameter($constraintParameters);
270
+		} catch (ConstraintParameterException $e) {
271 271
 			$problems[] = $e;
272 272
 		}
273 273
 		try {
274 274
 			$this->constraintParameterParser->parseConstraintScopeParameters(
275 275
 				$constraintParameters,
276 276
 				$constraint->getConstraintTypeItemId(),
277
-				$this->getValidContextTypes( $constraint ),
278
-				$this->getValidEntityTypes( $constraint )
277
+				$this->getValidContextTypes($constraint),
278
+				$this->getValidEntityTypes($constraint)
279 279
 			);
280
-		} catch ( ConstraintParameterException $e ) {
280
+		} catch (ConstraintParameterException $e) {
281 281
 			$problems[] = $e;
282 282
 		}
283 283
 		return $problems;
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
 	 * @return ConstraintParameterException[][] first level indexed by constraint ID,
291 291
 	 * second level like checkConstraintParametersOnConstraintId (but without possibility of null)
292 292
 	 */
293
-	public function checkConstraintParametersOnPropertyId( PropertyId $propertyId ) {
294
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
293
+	public function checkConstraintParametersOnPropertyId(PropertyId $propertyId) {
294
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
295 295
 		$result = [];
296 296
 
297
-		foreach ( $constraints as $constraint ) {
298
-			$problems = $this->checkCommonConstraintParameters( $constraint );
297
+		foreach ($constraints as $constraint) {
298
+			$problems = $this->checkCommonConstraintParameters($constraint);
299 299
 
300
-			if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
300
+			if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
301 301
 				$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
302
-				$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
302
+				$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
303 303
 			}
304 304
 
305 305
 			$result[$constraint->getConstraintId()] = $problems;
@@ -316,18 +316,18 @@  discard block
 block discarded – undo
316 316
 	 * @return ConstraintParameterException[]|null list of constraint parameter exceptions
317 317
 	 * (empty means all parameters okay), or null if constraint is not found
318 318
 	 */
319
-	public function checkConstraintParametersOnConstraintId( $constraintId ) {
320
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
319
+	public function checkConstraintParametersOnConstraintId($constraintId) {
320
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
321 321
 		'@phan-var NumericPropertyId $propertyId';
322
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
322
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
323 323
 
324
-		foreach ( $constraints as $constraint ) {
325
-			if ( $constraint->getConstraintId() === $constraintId ) {
326
-				$problems = $this->checkCommonConstraintParameters( $constraint );
324
+		foreach ($constraints as $constraint) {
325
+			if ($constraint->getConstraintId() === $constraintId) {
326
+				$problems = $this->checkCommonConstraintParameters($constraint);
327 327
 
328
-				if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
328
+				if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
329 329
 					$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
330
-					$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
330
+					$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
331 331
 				}
332 332
 
333 333
 				return $problems;
@@ -352,14 +352,14 @@  discard block
 block discarded – undo
352 352
 		$result = [];
353 353
 
354 354
 		/** @var Statement $statement */
355
-		foreach ( $entity->getStatements() as $statement ) {
356
-			$result = array_merge( $result,
355
+		foreach ($entity->getStatements() as $statement) {
356
+			$result = array_merge($result,
357 357
 				$this->checkStatement(
358 358
 					$entity,
359 359
 					$statement,
360 360
 					$constraintIds,
361 361
 					$defaultResultsPerContext
362
-				) );
362
+				));
363 363
 		}
364 364
 
365 365
 		return $result;
@@ -381,32 +381,32 @@  discard block
 block discarded – undo
381 381
 	) {
382 382
 		$result = [];
383 383
 
384
-		$result = array_merge( $result,
384
+		$result = array_merge($result,
385 385
 			$this->checkConstraintsForMainSnak(
386 386
 				$entity,
387 387
 				$statement,
388 388
 				$constraintIds,
389 389
 				$defaultResultsPerContext
390
-			) );
390
+			));
391 391
 
392
-		if ( $this->checkQualifiers ) {
393
-			$result = array_merge( $result,
392
+		if ($this->checkQualifiers) {
393
+			$result = array_merge($result,
394 394
 				$this->checkConstraintsForQualifiers(
395 395
 					$entity,
396 396
 					$statement,
397 397
 					$constraintIds,
398 398
 					$defaultResultsPerContext
399
-				) );
399
+				));
400 400
 		}
401 401
 
402
-		if ( $this->checkReferences ) {
403
-			$result = array_merge( $result,
402
+		if ($this->checkReferences) {
403
+			$result = array_merge($result,
404 404
 				$this->checkConstraintsForReferences(
405 405
 					$entity,
406 406
 					$statement,
407 407
 					$constraintIds,
408 408
 					$defaultResultsPerContext
409
-				) );
409
+				));
410 410
 		}
411 411
 
412 412
 		return $result;
@@ -421,12 +421,12 @@  discard block
 block discarded – undo
421 421
 	 * @param string[]|null $constraintIds
422 422
 	 * @return Constraint[]
423 423
 	 */
424
-	private function getConstraintsToUse( PropertyId $propertyId, array $constraintIds = null ) {
425
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
426
-		if ( $constraintIds !== null ) {
424
+	private function getConstraintsToUse(PropertyId $propertyId, array $constraintIds = null) {
425
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
426
+		if ($constraintIds !== null) {
427 427
 			$constraintsToUse = [];
428
-			foreach ( $constraints as $constraint ) {
429
-				if ( in_array( $constraint->getConstraintId(), $constraintIds ) ) {
428
+			foreach ($constraints as $constraint) {
429
+				if (in_array($constraint->getConstraintId(), $constraintIds)) {
430 430
 					$constraintsToUse[] = $constraint;
431 431
 				}
432 432
 			}
@@ -450,18 +450,18 @@  discard block
 block discarded – undo
450 450
 		array $constraintIds = null,
451 451
 		callable $defaultResults = null
452 452
 	) {
453
-		$context = new MainSnakContext( $entity, $statement );
453
+		$context = new MainSnakContext($entity, $statement);
454 454
 		$constraints = $this->getConstraintsToUse(
455 455
 			$statement->getPropertyId(),
456 456
 			$constraintIds
457 457
 		);
458
-		$result = $defaultResults !== null ? $defaultResults( $context ) : [];
458
+		$result = $defaultResults !== null ? $defaultResults($context) : [];
459 459
 
460
-		foreach ( $constraints as $constraint ) {
460
+		foreach ($constraints as $constraint) {
461 461
 			$parameters = $constraint->getConstraintParameters();
462 462
 			try {
463
-				$exceptions = $this->constraintParameterParser->parseExceptionParameter( $parameters );
464
-			} catch ( ConstraintParameterException $e ) {
463
+				$exceptions = $this->constraintParameterParser->parseExceptionParameter($parameters);
464
+			} catch (ConstraintParameterException $e) {
465 465
 				$result[] = new CheckResult(
466 466
 					$context,
467 467
 					$constraint,
@@ -471,13 +471,13 @@  discard block
 block discarded – undo
471 471
 				continue;
472 472
 			}
473 473
 
474
-			if ( in_array( $entity->getId(), $exceptions ) ) {
475
-				$message = new ViolationMessage( 'wbqc-violation-message-exception' );
476
-				$result[] = new CheckResult( $context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message );
474
+			if (in_array($entity->getId(), $exceptions)) {
475
+				$message = new ViolationMessage('wbqc-violation-message-exception');
476
+				$result[] = new CheckResult($context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message);
477 477
 				continue;
478 478
 			}
479 479
 
480
-			$result[] = $this->getCheckResultFor( $context, $constraint );
480
+			$result[] = $this->getCheckResultFor($context, $constraint);
481 481
 		}
482 482
 
483 483
 		return $result;
@@ -499,24 +499,24 @@  discard block
 block discarded – undo
499 499
 	) {
500 500
 		$result = [];
501 501
 
502
-		if ( in_array(
502
+		if (in_array(
503 503
 			$statement->getPropertyId()->getSerialization(),
504 504
 			$this->propertiesWithViolatingQualifiers
505
-		) ) {
505
+		)) {
506 506
 			return $result;
507 507
 		}
508 508
 
509
-		foreach ( $statement->getQualifiers() as $qualifier ) {
510
-			$qualifierContext = new QualifierContext( $entity, $statement, $qualifier );
511
-			if ( $defaultResultsPerContext !== null ) {
512
-				$result = array_merge( $result, $defaultResultsPerContext( $qualifierContext ) );
509
+		foreach ($statement->getQualifiers() as $qualifier) {
510
+			$qualifierContext = new QualifierContext($entity, $statement, $qualifier);
511
+			if ($defaultResultsPerContext !== null) {
512
+				$result = array_merge($result, $defaultResultsPerContext($qualifierContext));
513 513
 			}
514 514
 			$qualifierConstraints = $this->getConstraintsToUse(
515 515
 				$qualifierContext->getSnak()->getPropertyId(),
516 516
 				$constraintIds
517 517
 			);
518
-			foreach ( $qualifierConstraints as $qualifierConstraint ) {
519
-				$result[] = $this->getCheckResultFor( $qualifierContext, $qualifierConstraint );
518
+			foreach ($qualifierConstraints as $qualifierConstraint) {
519
+				$result[] = $this->getCheckResultFor($qualifierContext, $qualifierConstraint);
520 520
 			}
521 521
 		}
522 522
 
@@ -540,19 +540,19 @@  discard block
 block discarded – undo
540 540
 		$result = [];
541 541
 
542 542
 		/** @var Reference $reference */
543
-		foreach ( $statement->getReferences() as $reference ) {
544
-			foreach ( $reference->getSnaks() as $snak ) {
543
+		foreach ($statement->getReferences() as $reference) {
544
+			foreach ($reference->getSnaks() as $snak) {
545 545
 				$referenceContext = new ReferenceContext(
546 546
 					$entity, $statement, $reference, $snak
547 547
 				);
548
-				if ( $defaultResultsPerContext !== null ) {
549
-					$result = array_merge( $result, $defaultResultsPerContext( $referenceContext ) );
548
+				if ($defaultResultsPerContext !== null) {
549
+					$result = array_merge($result, $defaultResultsPerContext($referenceContext));
550 550
 				}
551 551
 				$referenceConstraints = $this->getConstraintsToUse(
552 552
 					$referenceContext->getSnak()->getPropertyId(),
553 553
 					$constraintIds
554 554
 				);
555
-				foreach ( $referenceConstraints as $referenceConstraint ) {
555
+				foreach ($referenceConstraints as $referenceConstraint) {
556 556
 					$result[] = $this->getCheckResultFor(
557 557
 						$referenceContext,
558 558
 						$referenceConstraint
@@ -571,20 +571,20 @@  discard block
 block discarded – undo
571 571
 	 * @throws InvalidArgumentException
572 572
 	 * @return CheckResult
573 573
 	 */
574
-	private function getCheckResultFor( Context $context, Constraint $constraint ) {
575
-		if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
574
+	private function getCheckResultFor(Context $context, Constraint $constraint) {
575
+		if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
576 576
 			$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
577
-			$result = $this->handleScope( $checker, $context, $constraint );
577
+			$result = $this->handleScope($checker, $context, $constraint);
578 578
 
579
-			if ( $result !== null ) {
580
-				$this->addMetadata( $context, $result );
579
+			if ($result !== null) {
580
+				$this->addMetadata($context, $result);
581 581
 				return $result;
582 582
 			}
583 583
 
584
-			$startTime = microtime( true );
584
+			$startTime = microtime(true);
585 585
 			try {
586
-				$result = $checker->checkConstraint( $context, $constraint );
587
-			} catch ( ConstraintParameterException $e ) {
586
+				$result = $checker->checkConstraint($context, $constraint);
587
+			} catch (ConstraintParameterException $e) {
588 588
 				$result = new CheckResult(
589 589
 					$context,
590 590
 					$constraint,
@@ -592,28 +592,28 @@  discard block
 block discarded – undo
592 592
 					CheckResult::STATUS_BAD_PARAMETERS,
593 593
 					$e->getViolationMessage()
594 594
 				);
595
-			} catch ( SparqlHelperException $e ) {
596
-				$message = new ViolationMessage( 'wbqc-violation-message-sparql-error' );
597
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, $message );
595
+			} catch (SparqlHelperException $e) {
596
+				$message = new ViolationMessage('wbqc-violation-message-sparql-error');
597
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, $message);
598 598
 			}
599
-			$endTime = microtime( true );
599
+			$endTime = microtime(true);
600 600
 
601
-			$this->addMetadata( $context, $result );
601
+			$this->addMetadata($context, $result);
602 602
 
603
-			$this->downgradeResultStatus( $context, $result );
603
+			$this->downgradeResultStatus($context, $result);
604 604
 
605 605
 			$this->loggingHelper->logConstraintCheck(
606 606
 				$context,
607 607
 				$constraint,
608 608
 				$result,
609
-				get_class( $checker ),
609
+				get_class($checker),
610 610
 				$endTime - $startTime,
611 611
 				__METHOD__
612 612
 			);
613 613
 
614 614
 			return $result;
615 615
 		} else {
616
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
616
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
617 617
 		}
618 618
 	}
619 619
 
@@ -622,84 +622,84 @@  discard block
 block discarded – undo
622 622
 		Context $context,
623 623
 		Constraint $constraint
624 624
 	): ?CheckResult {
625
-		$validContextTypes = $this->getValidContextTypes( $constraint );
626
-		$validEntityTypes = $this->getValidEntityTypes( $constraint );
625
+		$validContextTypes = $this->getValidContextTypes($constraint);
626
+		$validEntityTypes = $this->getValidEntityTypes($constraint);
627 627
 		try {
628
-			[ $checkedContextTypes, $checkedEntityTypes ] = $this->constraintParameterParser->parseConstraintScopeParameters(
628
+			[$checkedContextTypes, $checkedEntityTypes] = $this->constraintParameterParser->parseConstraintScopeParameters(
629 629
 				$constraint->getConstraintParameters(),
630 630
 				$constraint->getConstraintTypeItemId(),
631 631
 				$validContextTypes,
632 632
 				$validEntityTypes
633 633
 			);
634
-		} catch ( ConstraintParameterException $e ) {
635
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
634
+		} catch (ConstraintParameterException $e) {
635
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
636 636
 		}
637 637
 
638
-		if ( $checkedContextTypes === null ) {
638
+		if ($checkedContextTypes === null) {
639 639
 			$checkedContextTypes = $checker->getDefaultContextTypes();
640 640
 		}
641 641
 		$contextType = $context->getType();
642
-		if ( !in_array( $contextType, $checkedContextTypes ) ) {
643
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null );
642
+		if (!in_array($contextType, $checkedContextTypes)) {
643
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null);
644 644
 		}
645
-		if ( $checker->getSupportedContextTypes()[$contextType] === CheckResult::STATUS_TODO ) {
646
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
645
+		if ($checker->getSupportedContextTypes()[$contextType] === CheckResult::STATUS_TODO) {
646
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
647 647
 		}
648 648
 
649
-		if ( $checkedEntityTypes === null ) {
649
+		if ($checkedEntityTypes === null) {
650 650
 			$checkedEntityTypes = $validEntityTypes;
651 651
 		}
652 652
 		$entityType = $context->getEntity()->getType();
653
-		if ( !in_array( $entityType, $checkedEntityTypes ) ) {
654
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null );
653
+		if (!in_array($entityType, $checkedEntityTypes)) {
654
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null);
655 655
 		}
656
-		if ( $checker->getSupportedEntityTypes()[$entityType] === CheckResult::STATUS_TODO ) {
657
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
656
+		if ($checker->getSupportedEntityTypes()[$entityType] === CheckResult::STATUS_TODO) {
657
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
658 658
 		}
659 659
 
660 660
 		return null;
661 661
 	}
662 662
 
663
-	private function addMetadata( Context $context, CheckResult $result ) {
664
-		$result->withMetadata( Metadata::merge( [
663
+	private function addMetadata(Context $context, CheckResult $result) {
664
+		$result->withMetadata(Metadata::merge([
665 665
 			$result->getMetadata(),
666
-			Metadata::ofDependencyMetadata( DependencyMetadata::merge( [
667
-				DependencyMetadata::ofEntityId( $context->getEntity()->getId() ),
668
-				DependencyMetadata::ofEntityId( $result->getConstraint()->getPropertyId() ),
669
-			] ) ),
670
-		] ) );
666
+			Metadata::ofDependencyMetadata(DependencyMetadata::merge([
667
+				DependencyMetadata::ofEntityId($context->getEntity()->getId()),
668
+				DependencyMetadata::ofEntityId($result->getConstraint()->getPropertyId()),
669
+			])),
670
+		]));
671 671
 	}
672 672
 
673
-	private function downgradeResultStatus( Context $context, CheckResult &$result ) {
673
+	private function downgradeResultStatus(Context $context, CheckResult &$result) {
674 674
 		$constraint = $result->getConstraint();
675 675
 		try {
676 676
 			$constraintStatus = $this->constraintParameterParser
677
-				->parseConstraintStatusParameter( $constraint->getConstraintParameters() );
678
-		} catch ( ConstraintParameterException $e ) {
679
-			$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
677
+				->parseConstraintStatusParameter($constraint->getConstraintParameters());
678
+		} catch (ConstraintParameterException $e) {
679
+			$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
680 680
 			$constraintStatus = null;
681 681
 		}
682
-		if ( $constraintStatus === null ) {
682
+		if ($constraintStatus === null) {
683 683
 			// downgrade violation to warning
684
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
685
-				$result->setStatus( CheckResult::STATUS_WARNING );
684
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
685
+				$result->setStatus(CheckResult::STATUS_WARNING);
686 686
 			}
687
-		} elseif ( $constraintStatus === 'suggestion' ) {
687
+		} elseif ($constraintStatus === 'suggestion') {
688 688
 			// downgrade violation to suggestion
689
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
690
-				$result->setStatus( CheckResult::STATUS_SUGGESTION );
689
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
690
+				$result->setStatus(CheckResult::STATUS_SUGGESTION);
691 691
 			}
692
-			$result->addParameter( 'constraint_status', $constraintStatus );
692
+			$result->addParameter('constraint_status', $constraintStatus);
693 693
 		} else {
694
-			if ( $constraintStatus !== 'mandatory' ) {
694
+			if ($constraintStatus !== 'mandatory') {
695 695
 				// @codeCoverageIgnoreStart
696 696
 				throw new LogicException(
697
-					"Unknown constraint status '$constraintStatus', " .
697
+					"Unknown constraint status '$constraintStatus', ".
698 698
 					"only known statuses are 'mandatory' and 'suggestion'"
699 699
 				);
700 700
 				// @codeCoverageIgnoreEnd
701 701
 			}
702
-			$result->addParameter( 'constraint_status', $constraintStatus );
702
+			$result->addParameter('constraint_status', $constraintStatus);
703 703
 		}
704 704
 	}
705 705
 
@@ -708,12 +708,12 @@  discard block
 block discarded – undo
708 708
 	 *
709 709
 	 * @return CheckResult[]
710 710
 	 */
711
-	private function sortResult( array $result ) {
712
-		if ( count( $result ) < 2 ) {
711
+	private function sortResult(array $result) {
712
+		if (count($result) < 2) {
713 713
 			return $result;
714 714
 		}
715 715
 
716
-		$sortFunction = static function ( CheckResult $a, CheckResult $b ) {
716
+		$sortFunction = static function(CheckResult $a, CheckResult $b) {
717 717
 			$orderNum = 0;
718 718
 			$order = [
719 719
 				CheckResult::STATUS_BAD_PARAMETERS => $orderNum++,
@@ -730,55 +730,55 @@  discard block
 block discarded – undo
730 730
 			$statusA = $a->getStatus();
731 731
 			$statusB = $b->getStatus();
732 732
 
733
-			$orderA = array_key_exists( $statusA, $order ) ? $order[ $statusA ] : $order[ 'other' ];
734
-			$orderB = array_key_exists( $statusB, $order ) ? $order[ $statusB ] : $order[ 'other' ];
733
+			$orderA = array_key_exists($statusA, $order) ? $order[$statusA] : $order['other'];
734
+			$orderB = array_key_exists($statusB, $order) ? $order[$statusB] : $order['other'];
735 735
 
736
-			if ( $orderA === $orderB ) {
736
+			if ($orderA === $orderB) {
737 737
 				$cursorA = $a->getContextCursor();
738 738
 				$cursorB = $b->getContextCursor();
739 739
 
740
-				if ( $cursorA instanceof EntityContextCursor ) {
740
+				if ($cursorA instanceof EntityContextCursor) {
741 741
 					return $cursorB instanceof EntityContextCursor ? 0 : -1;
742 742
 				}
743
-				if ( $cursorB instanceof EntityContextCursor ) {
743
+				if ($cursorB instanceof EntityContextCursor) {
744 744
 					return $cursorA instanceof EntityContextCursor ? 0 : 1;
745 745
 				}
746 746
 
747 747
 				$pidA = $cursorA->getSnakPropertyId();
748 748
 				$pidB = $cursorB->getSnakPropertyId();
749 749
 
750
-				if ( $pidA === $pidB ) {
750
+				if ($pidA === $pidB) {
751 751
 					$hashA = $cursorA->getSnakHash();
752 752
 					$hashB = $cursorB->getSnakHash();
753 753
 
754
-					if ( $hashA === $hashB ) {
755
-						if ( $a instanceof NullResult ) {
754
+					if ($hashA === $hashB) {
755
+						if ($a instanceof NullResult) {
756 756
 							return $b instanceof NullResult ? 0 : -1;
757 757
 						}
758
-						if ( $b instanceof NullResult ) {
758
+						if ($b instanceof NullResult) {
759 759
 							return $a instanceof NullResult ? 0 : 1;
760 760
 						}
761 761
 
762 762
 						$typeA = $a->getConstraint()->getConstraintTypeItemId();
763 763
 						$typeB = $b->getConstraint()->getConstraintTypeItemId();
764 764
 
765
-						if ( $typeA == $typeB ) {
765
+						if ($typeA == $typeB) {
766 766
 							return 0;
767 767
 						} else {
768
-							return ( $typeA > $typeB ) ? 1 : -1;
768
+							return ($typeA > $typeB) ? 1 : -1;
769 769
 						}
770 770
 					} else {
771
-						return ( $hashA > $hashB ) ? 1 : -1;
771
+						return ($hashA > $hashB) ? 1 : -1;
772 772
 					}
773 773
 				} else {
774
-					return ( $pidA > $pidB ) ? 1 : -1;
774
+					return ($pidA > $pidB) ? 1 : -1;
775 775
 				}
776 776
 			} else {
777
-				return ( $orderA > $orderB ) ? 1 : -1;
777
+				return ($orderA > $orderB) ? 1 : -1;
778 778
 			}
779 779
 		};
780 780
 
781
-		uasort( $result, $sortFunction );
781
+		uasort($result, $sortFunction);
782 782
 
783 783
 		return $result;
784 784
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/TypeCheckerHelper.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -81,26 +81,26 @@  discard block
 block discarded – undo
81 81
 	 * @return bool
82 82
 	 * @throws OverflowException if $entitiesChecked exceeds the configured limit
83 83
 	 */
84
-	private function isSubclassOf( EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0 ) {
85
-		$maxEntities = $this->config->get( 'WBQualityConstraintsTypeCheckMaxEntities' );
84
+	private function isSubclassOf(EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0) {
85
+		$maxEntities = $this->config->get('WBQualityConstraintsTypeCheckMaxEntities');
86 86
 		if ( ++$entitiesChecked > $maxEntities ) {
87
-			throw new OverflowException( 'Too many entities to check' );
87
+			throw new OverflowException('Too many entities to check');
88 88
 		}
89 89
 
90
-		$item = $this->entityLookup->getEntity( $comparativeClass );
91
-		if ( !( $item instanceof StatementListProvider ) ) {
90
+		$item = $this->entityLookup->getEntity($comparativeClass);
91
+		if (!($item instanceof StatementListProvider)) {
92 92
 			return false; // lookup failed, probably because item doesn't exist
93 93
 		}
94 94
 
95
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
95
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfId');
96 96
 		$statements = $item->getStatements()
97
-			->getByPropertyId( new NumericPropertyId( $subclassId ) )
97
+			->getByPropertyId(new NumericPropertyId($subclassId))
98 98
 			->getBestStatements();
99 99
 		/** @var Statement $statement */
100
-		foreach ( $statements as $statement ) {
100
+		foreach ($statements as $statement) {
101 101
 			$mainSnak = $statement->getMainSnak();
102 102
 
103
-			if ( !$this->hasCorrectType( $mainSnak ) ) {
103
+			if (!$this->hasCorrectType($mainSnak)) {
104 104
 				continue;
105 105
 			}
106 106
 			/** @var PropertyValueSnak $mainSnak */
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 			'@phan-var EntityIdValue $dataValue';
111 111
 			$comparativeClass = $dataValue->getEntityId();
112 112
 
113
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
113
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
114 114
 				return true;
115 115
 			}
116 116
 
117
-			if ( $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ) ) {
117
+			if ($this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked)) {
118 118
 				return true;
119 119
 			}
120 120
 		}
@@ -135,48 +135,48 @@  discard block
 block discarded – undo
135 135
 	 * @return CachedBool
136 136
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
137 137
 	 */
138
-	public function isSubclassOfWithSparqlFallback( EntityId $comparativeClass, array $classesToCheck ) {
138
+	public function isSubclassOfWithSparqlFallback(EntityId $comparativeClass, array $classesToCheck) {
139 139
 		try {
140 140
 			$entitiesChecked = 0;
141
-			$start1 = microtime( true );
142
-			$isSubclass = $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked );
143
-			$end1 = microtime( true );
141
+			$start1 = microtime(true);
142
+			$isSubclass = $this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked);
143
+			$end1 = microtime(true);
144 144
 			$this->dataFactory->timing(
145 145
 				'wikibase.quality.constraints.type.php.success.timing',
146
-				( $end1 - $start1 ) * 1000
146
+				($end1 - $start1) * 1000
147 147
 			);
148 148
 			$this->dataFactory->timing( // not really a timing, but works like one (we want percentiles etc.)
149 149
 				'wikibase.quality.constraints.type.php.success.entities',
150 150
 				$entitiesChecked
151 151
 			);
152 152
 
153
-			return new CachedBool( $isSubclass, Metadata::blank() );
154
-		} catch ( OverflowException $e ) {
155
-			$end1 = microtime( true );
153
+			return new CachedBool($isSubclass, Metadata::blank());
154
+		} catch (OverflowException $e) {
155
+			$end1 = microtime(true);
156 156
 			$this->dataFactory->timing(
157 157
 				'wikibase.quality.constraints.type.php.overflow.timing',
158
-				( $end1 - $start1 ) * 1000
158
+				($end1 - $start1) * 1000
159 159
 			);
160 160
 
161
-			if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) {
161
+			if (!($this->sparqlHelper instanceof DummySparqlHelper)) {
162 162
 				$this->dataFactory->increment(
163 163
 					'wikibase.quality.constraints.sparql.typeFallback'
164 164
 				);
165 165
 
166
-				$start2 = microtime( true );
166
+				$start2 = microtime(true);
167 167
 				$hasType = $this->sparqlHelper->hasType(
168 168
 					$comparativeClass->getSerialization(),
169 169
 					$classesToCheck
170 170
 				);
171
-				$end2 = microtime( true );
171
+				$end2 = microtime(true);
172 172
 				$this->dataFactory->timing(
173 173
 					'wikibase.quality.constraints.type.sparql.success.timing',
174
-					( $end2 - $start2 ) * 1000
174
+					($end2 - $start2) * 1000
175 175
 				);
176 176
 
177 177
 				return $hasType;
178 178
 			} else {
179
-				return new CachedBool( false, Metadata::blank() );
179
+				return new CachedBool(false, Metadata::blank());
180 180
 			}
181 181
 		}
182 182
 	}
@@ -194,13 +194,13 @@  discard block
 block discarded – undo
194 194
 	 * @return CachedBool
195 195
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
196 196
 	 */
197
-	public function hasClassInRelation( StatementList $statements, array $relationIds, array $classesToCheck ) {
197
+	public function hasClassInRelation(StatementList $statements, array $relationIds, array $classesToCheck) {
198 198
 		$metadatas = [];
199 199
 
200
-		foreach ( $this->getBestStatementsByPropertyIds( $statements, $relationIds ) as $statement ) {
200
+		foreach ($this->getBestStatementsByPropertyIds($statements, $relationIds) as $statement) {
201 201
 			$mainSnak = $statement->getMainSnak();
202 202
 
203
-			if ( !$this->hasCorrectType( $mainSnak ) ) {
203
+			if (!$this->hasCorrectType($mainSnak)) {
204 204
 				continue;
205 205
 			}
206 206
 			/** @var PropertyValueSnak $mainSnak */
@@ -210,24 +210,24 @@  discard block
 block discarded – undo
210 210
 			'@phan-var EntityIdValue $dataValue';
211 211
 			$comparativeClass = $dataValue->getEntityId();
212 212
 
213
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
213
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
214 214
 				// discard $metadatas, we know this is fresh
215
-				return new CachedBool( true, Metadata::blank() );
215
+				return new CachedBool(true, Metadata::blank());
216 216
 			}
217 217
 
218
-			$result = $this->isSubclassOfWithSparqlFallback( $comparativeClass, $classesToCheck );
218
+			$result = $this->isSubclassOfWithSparqlFallback($comparativeClass, $classesToCheck);
219 219
 			$metadatas[] = $result->getMetadata();
220
-			if ( $result->getBool() ) {
220
+			if ($result->getBool()) {
221 221
 				return new CachedBool(
222 222
 					true,
223
-					Metadata::merge( $metadatas )
223
+					Metadata::merge($metadatas)
224 224
 				);
225 225
 			}
226 226
 		}
227 227
 
228 228
 		return new CachedBool(
229 229
 			false,
230
-			Metadata::merge( $metadatas )
230
+			Metadata::merge($metadatas)
231 231
 		);
232 232
 	}
233 233
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 * @return bool
237 237
 	 * @phan-assert PropertyValueSnak $mainSnak
238 238
 	 */
239
-	private function hasCorrectType( Snak $mainSnak ) {
239
+	private function hasCorrectType(Snak $mainSnak) {
240 240
 		return $mainSnak instanceof PropertyValueSnak
241 241
 			&& $mainSnak->getDataValue()->getType() === 'wikibase-entityid';
242 242
 	}
@@ -253,15 +253,15 @@  discard block
 block discarded – undo
253 253
 	) {
254 254
 		$statementArrays = [];
255 255
 
256
-		foreach ( $propertyIdSerializations as $propertyIdSerialization ) {
257
-			$propertyId = new NumericPropertyId( $propertyIdSerialization );
256
+		foreach ($propertyIdSerializations as $propertyIdSerialization) {
257
+			$propertyId = new NumericPropertyId($propertyIdSerialization);
258 258
 			$statementArrays[] = $statements
259
-				->getByPropertyId( $propertyId )
259
+				->getByPropertyId($propertyId)
260 260
 				->getBestStatements()
261 261
 				->toArray();
262 262
 		}
263 263
 
264
-		return call_user_func_array( 'array_merge', $statementArrays );
264
+		return call_user_func_array('array_merge', $statementArrays);
265 265
 	}
266 266
 
267 267
 	/**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 		$relation
282 282
 	) {
283 283
 		$classes = array_map(
284
-			static function ( $itemIdSerialization ) {
285
-				return new ItemId( $itemIdSerialization );
284
+			static function($itemIdSerialization) {
285
+				return new ItemId($itemIdSerialization);
286 286
 			},
287 287
 			$classes
288 288
 		);
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 		// wbqc-violation-message-valueType-instance
295 295
 		// wbqc-violation-message-valueType-subclass
296 296
 		// wbqc-violation-message-valueType-instanceOrSubclass
297
-		return ( new ViolationMessage( 'wbqc-violation-message-' . $checker . '-' . $relation ) )
298
-			->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY )
299
-			->withEntityId( $entityId, Role::SUBJECT )
300
-			->withEntityIdList( $classes, Role::OBJECT );
297
+		return (new ViolationMessage('wbqc-violation-message-'.$checker.'-'.$relation))
298
+			->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY)
299
+			->withEntityId($entityId, Role::SUBJECT)
300
+			->withEntityIdList($classes, Role::OBJECT);
301 301
 	}
302 302
 
303 303
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +287 added lines, -287 removed lines patch added patch discarded remove patch
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 	 * @param array $parameters
79 79
 	 * @throws ConstraintParameterException
80 80
 	 */
81
-	public function checkError( array $parameters ) {
82
-		if ( array_key_exists( '@error', $parameters ) ) {
81
+	public function checkError(array $parameters) {
82
+		if (array_key_exists('@error', $parameters)) {
83 83
 			$error = $parameters['@error'];
84
-			if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) {
84
+			if (array_key_exists('toolong', $error) && $error['toolong']) {
85 85
 				$msg = 'wbqc-violation-message-parameters-error-toolong';
86 86
 			} else {
87 87
 				$msg = 'wbqc-violation-message-parameters-error-unknown';
88 88
 			}
89
-			throw new ConstraintParameterException( new ViolationMessage( $msg ) );
89
+			throw new ConstraintParameterException(new ViolationMessage($msg));
90 90
 		}
91 91
 	}
92 92
 
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 	 * @param string $parameterId
97 97
 	 * @throws ConstraintParameterException
98 98
 	 */
99
-	private function requireSingleParameter( array $parameters, $parameterId ) {
100
-		if ( count( $parameters[$parameterId] ) !== 1 ) {
99
+	private function requireSingleParameter(array $parameters, $parameterId) {
100
+		if (count($parameters[$parameterId]) !== 1) {
101 101
 			throw new ConstraintParameterException(
102
-				( new ViolationMessage( 'wbqc-violation-message-parameter-single' ) )
103
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
102
+				(new ViolationMessage('wbqc-violation-message-parameter-single'))
103
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
104 104
 			);
105 105
 		}
106 106
 	}
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 	 * @return void
113 113
 	 * @throws ConstraintParameterException
114 114
 	 */
115
-	private function requireValueParameter( Snak $snak, $parameterId ) {
116
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
115
+	private function requireValueParameter(Snak $snak, $parameterId) {
116
+		if (!($snak instanceof PropertyValueSnak)) {
117 117
 			throw new ConstraintParameterException(
118
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
119
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
118
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
119
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
120 120
 			);
121 121
 		}
122 122
 	}
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
 	 * @throws ConstraintParameterException
129 129
 	 * @return EntityId
130 130
 	 */
131
-	private function parseEntityIdParameter( array $snakSerialization, $parameterId ) {
132
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
133
-		$this->requireValueParameter( $snak, $parameterId );
131
+	private function parseEntityIdParameter(array $snakSerialization, $parameterId) {
132
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
133
+		$this->requireValueParameter($snak, $parameterId);
134 134
 		$value = $snak->getDataValue();
135
-		if ( $value instanceof EntityIdValue ) {
135
+		if ($value instanceof EntityIdValue) {
136 136
 			return $value->getEntityId();
137 137
 		} else {
138 138
 			throw new ConstraintParameterException(
139
-				( new ViolationMessage( 'wbqc-violation-message-parameter-entity' ) )
140
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
141
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
139
+				(new ViolationMessage('wbqc-violation-message-parameter-entity'))
140
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
141
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
142 142
 			);
143 143
 		}
144 144
 	}
@@ -149,20 +149,20 @@  discard block
 block discarded – undo
149 149
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
150 150
 	 * @return string[] class entity ID serializations
151 151
 	 */
152
-	public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) {
153
-		$this->checkError( $constraintParameters );
154
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
155
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
152
+	public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) {
153
+		$this->checkError($constraintParameters);
154
+		$classId = $this->config->get('WBQualityConstraintsClassId');
155
+		if (!array_key_exists($classId, $constraintParameters)) {
156 156
 			throw new ConstraintParameterException(
157
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
158
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
159
-					->withEntityId( new NumericPropertyId( $classId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
157
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
158
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
159
+					->withEntityId(new NumericPropertyId($classId), Role::CONSTRAINT_PARAMETER_PROPERTY)
160 160
 			);
161 161
 		}
162 162
 
163 163
 		$classes = [];
164
-		foreach ( $constraintParameters[$classId] as $class ) {
165
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
164
+		foreach ($constraintParameters[$classId] as $class) {
165
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
166 166
 		}
167 167
 		return $classes;
168 168
 	}
@@ -173,31 +173,31 @@  discard block
 block discarded – undo
173 173
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
174 174
 	 * @return string 'instance', 'subclass', or 'instanceOrSubclass'
175 175
 	 */
176
-	public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) {
177
-		$this->checkError( $constraintParameters );
178
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
179
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
176
+	public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) {
177
+		$this->checkError($constraintParameters);
178
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
179
+		if (!array_key_exists($relationId, $constraintParameters)) {
180 180
 			throw new ConstraintParameterException(
181
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
182
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
183
-					->withEntityId( new NumericPropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
181
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
182
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
183
+					->withEntityId(new NumericPropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
184 184
 			);
185 185
 		}
186 186
 
187
-		$this->requireSingleParameter( $constraintParameters, $relationId );
188
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
189
-		if ( !( $relationEntityId instanceof ItemId ) ) {
187
+		$this->requireSingleParameter($constraintParameters, $relationId);
188
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
189
+		if (!($relationEntityId instanceof ItemId)) {
190 190
 			throw new ConstraintParameterException(
191
-				( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
192
-					->withEntityId( new NumericPropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
193
-					->withDataValue( new EntityIdValue( $relationEntityId ), Role::CONSTRAINT_PARAMETER_VALUE )
191
+				(new ViolationMessage('wbqc-violation-message-parameter-item'))
192
+					->withEntityId(new NumericPropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
193
+					->withDataValue(new EntityIdValue($relationEntityId), Role::CONSTRAINT_PARAMETER_VALUE)
194 194
 			);
195 195
 		}
196
-		return $this->mapItemId( $relationEntityId, [
197
-			$this->config->get( 'WBQualityConstraintsInstanceOfRelationId' ) => 'instance',
198
-			$this->config->get( 'WBQualityConstraintsSubclassOfRelationId' ) => 'subclass',
199
-			$this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' ) => 'instanceOrSubclass',
200
-		], $relationId );
196
+		return $this->mapItemId($relationEntityId, [
197
+			$this->config->get('WBQualityConstraintsInstanceOfRelationId') => 'instance',
198
+			$this->config->get('WBQualityConstraintsSubclassOfRelationId') => 'subclass',
199
+			$this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId') => 'instanceOrSubclass',
200
+		], $relationId);
201 201
 	}
202 202
 
203 203
 	/**
@@ -207,20 +207,20 @@  discard block
 block discarded – undo
207 207
 	 * @throws ConstraintParameterException
208 208
 	 * @return PropertyId
209 209
 	 */
210
-	private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) {
211
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
212
-		$this->requireValueParameter( $snak, $parameterId );
210
+	private function parsePropertyIdParameter(array $snakSerialization, $parameterId) {
211
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
212
+		$this->requireValueParameter($snak, $parameterId);
213 213
 		$value = $snak->getDataValue();
214
-		if ( $value instanceof EntityIdValue ) {
214
+		if ($value instanceof EntityIdValue) {
215 215
 			$id = $value->getEntityId();
216
-			if ( $id instanceof PropertyId ) {
216
+			if ($id instanceof PropertyId) {
217 217
 				return $id;
218 218
 			}
219 219
 		}
220 220
 		throw new ConstraintParameterException(
221
-			( new ViolationMessage( 'wbqc-violation-message-parameter-property' ) )
222
-				->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
223
-				->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
221
+			(new ViolationMessage('wbqc-violation-message-parameter-property'))
222
+				->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
223
+				->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
224 224
 		);
225 225
 	}
226 226
 
@@ -231,33 +231,33 @@  discard block
 block discarded – undo
231 231
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
232 232
 	 * @return PropertyId
233 233
 	 */
234
-	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
235
-		$this->checkError( $constraintParameters );
236
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
237
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
234
+	public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) {
235
+		$this->checkError($constraintParameters);
236
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
237
+		if (!array_key_exists($propertyId, $constraintParameters)) {
238 238
 			throw new ConstraintParameterException(
239
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
240
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
241
-					->withEntityId( new NumericPropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
239
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
240
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
241
+					->withEntityId(new NumericPropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
242 242
 			);
243 243
 		}
244 244
 
245
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
246
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
245
+		$this->requireSingleParameter($constraintParameters, $propertyId);
246
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
247 247
 	}
248 248
 
249
-	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
249
+	private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) {
250 250
 		$dataValue = $snak->getDataValue();
251
-		if ( $dataValue instanceof EntityIdValue ) {
251
+		if ($dataValue instanceof EntityIdValue) {
252 252
 			$entityId = $dataValue->getEntityId();
253
-			if ( $entityId instanceof ItemId ) {
254
-				return ItemIdSnakValue::fromItemId( $entityId );
253
+			if ($entityId instanceof ItemId) {
254
+				return ItemIdSnakValue::fromItemId($entityId);
255 255
 			}
256 256
 		}
257 257
 		throw new ConstraintParameterException(
258
-			( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
259
-				->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
260
-				->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
258
+			(new ViolationMessage('wbqc-violation-message-parameter-item'))
259
+				->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
260
+				->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
261 261
 		);
262 262
 	}
263 263
 
@@ -275,16 +275,16 @@  discard block
 block discarded – undo
275 275
 		$required,
276 276
 		$parameterId = null
277 277
 	) {
278
-		$this->checkError( $constraintParameters );
279
-		if ( $parameterId === null ) {
280
-			$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
278
+		$this->checkError($constraintParameters);
279
+		if ($parameterId === null) {
280
+			$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
281 281
 		}
282
-		if ( !array_key_exists( $parameterId, $constraintParameters ) ) {
283
-			if ( $required ) {
282
+		if (!array_key_exists($parameterId, $constraintParameters)) {
283
+			if ($required) {
284 284
 				throw new ConstraintParameterException(
285
-					( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
286
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
287
-						->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
285
+					(new ViolationMessage('wbqc-violation-message-parameter-needed'))
286
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
287
+						->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
288 288
 				);
289 289
 			} else {
290 290
 				return [];
@@ -292,11 +292,11 @@  discard block
 block discarded – undo
292 292
 		}
293 293
 
294 294
 		$values = [];
295
-		foreach ( $constraintParameters[$parameterId] as $parameter ) {
296
-			$snak = $this->snakDeserializer->deserialize( $parameter );
297
-			switch ( true ) {
295
+		foreach ($constraintParameters[$parameterId] as $parameter) {
296
+			$snak = $this->snakDeserializer->deserialize($parameter);
297
+			switch (true) {
298 298
 				case $snak instanceof PropertyValueSnak:
299
-					$values[] = $this->parseItemIdParameter( $snak, $parameterId );
299
+					$values[] = $this->parseItemIdParameter($snak, $parameterId);
300 300
 					break;
301 301
 				case $snak instanceof PropertySomeValueSnak:
302 302
 					$values[] = ItemIdSnakValue::someValue();
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
 		bool $required,
325 325
 		string $parameterId
326 326
 	): array {
327
-		return array_map( static function ( ItemIdSnakValue $value ) use ( $parameterId ): ItemId {
328
-			if ( $value->isValue() ) {
327
+		return array_map(static function(ItemIdSnakValue $value) use ($parameterId): ItemId {
328
+			if ($value->isValue()) {
329 329
 				return $value->getItemId();
330 330
 			} else {
331 331
 				throw new ConstraintParameterException(
332
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
333
-						->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
332
+					(new ViolationMessage('wbqc-violation-message-parameter-value'))
333
+						->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
334 334
 				);
335 335
 			}
336 336
 		}, $this->parseItemsParameter(
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 			$constraintTypeItemId,
339 339
 			$required,
340 340
 			$parameterId
341
-		) );
341
+		));
342 342
 	}
343 343
 
344 344
 	/**
@@ -346,18 +346,18 @@  discard block
 block discarded – undo
346 346
 	 * @throws ConstraintParameterException
347 347
 	 * @return mixed elements of $mapping
348 348
 	 */
349
-	private function mapItemId( ItemId $itemId, array $mapping, string $parameterId ) {
349
+	private function mapItemId(ItemId $itemId, array $mapping, string $parameterId) {
350 350
 		$serialization = $itemId->getSerialization();
351
-		if ( array_key_exists( $serialization, $mapping ) ) {
351
+		if (array_key_exists($serialization, $mapping)) {
352 352
 			return $mapping[$serialization];
353 353
 		} else {
354
-			$allowed = array_map( static function ( $id ) {
355
-				return new ItemId( $id );
356
-			}, array_keys( $mapping ) );
354
+			$allowed = array_map(static function($id) {
355
+				return new ItemId($id);
356
+			}, array_keys($mapping));
357 357
 			throw new ConstraintParameterException(
358
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
359
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
360
-					->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
358
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
359
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
360
+					->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
361 361
 			);
362 362
 		}
363 363
 	}
@@ -368,27 +368,27 @@  discard block
 block discarded – undo
368 368
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
369 369
 	 * @return PropertyId[]
370 370
 	 */
371
-	public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) {
372
-		$this->checkError( $constraintParameters );
373
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
374
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
371
+	public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) {
372
+		$this->checkError($constraintParameters);
373
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
374
+		if (!array_key_exists($propertyId, $constraintParameters)) {
375 375
 			throw new ConstraintParameterException(
376
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
377
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
378
-					->withEntityId( new NumericPropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
376
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
377
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
378
+					->withEntityId(new NumericPropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
379 379
 			);
380 380
 		}
381 381
 
382 382
 		$parameters = $constraintParameters[$propertyId];
383
-		if ( count( $parameters ) === 1 &&
384
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
383
+		if (count($parameters) === 1 &&
384
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
385 385
 		) {
386 386
 			return [];
387 387
 		}
388 388
 
389 389
 		$properties = [];
390
-		foreach ( $parameters as $parameter ) {
391
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
390
+		foreach ($parameters as $parameter) {
391
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
392 392
 		}
393 393
 		return $properties;
394 394
 	}
@@ -399,16 +399,16 @@  discard block
 block discarded – undo
399 399
 	 * @throws ConstraintParameterException
400 400
 	 * @return DataValue|null
401 401
 	 */
402
-	private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) {
403
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
404
-		if ( $snak instanceof PropertyValueSnak ) {
402
+	private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) {
403
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
404
+		if ($snak instanceof PropertyValueSnak) {
405 405
 			return $snak->getDataValue();
406
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
406
+		} elseif ($snak instanceof PropertyNoValueSnak) {
407 407
 			return null;
408 408
 		} else {
409 409
 			throw new ConstraintParameterException(
410
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
411
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
410
+				(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
411
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
412 412
 			);
413 413
 		}
414 414
 	}
@@ -418,10 +418,10 @@  discard block
 block discarded – undo
418 418
 	 * @param string $parameterId
419 419
 	 * @return DataValue|null
420 420
 	 */
421
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) {
421
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) {
422 422
 		try {
423
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
424
-		} catch ( ConstraintParameterException $e ) {
423
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
424
+		} catch (ConstraintParameterException $e) {
425 425
 			// unknown value means “now”
426 426
 			return new NowValue();
427 427
 		}
@@ -434,14 +434,14 @@  discard block
 block discarded – undo
434 434
 	 * @param string $unit
435 435
 	 * @return bool
436 436
 	 */
437
-	private function exactlyOneQuantityWithUnit( ?DataValue $min, ?DataValue $max, $unit ) {
438
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
439
-			!( $max instanceof UnboundedQuantityValue )
437
+	private function exactlyOneQuantityWithUnit(?DataValue $min, ?DataValue $max, $unit) {
438
+		if (!($min instanceof UnboundedQuantityValue) ||
439
+			!($max instanceof UnboundedQuantityValue)
440 440
 		) {
441 441
 			return false;
442 442
 		}
443 443
 
444
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
444
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
445 445
 	}
446 446
 
447 447
 	/**
@@ -454,42 +454,42 @@  discard block
 block discarded – undo
454 454
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
455 455
 	 * @return DataValue[] if the parameter is invalid or missing
456 456
 	 */
457
-	private function parseRangeParameter( array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type ) {
458
-		$this->checkError( $constraintParameters );
459
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
460
-			!array_key_exists( $maximumId, $constraintParameters )
457
+	private function parseRangeParameter(array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type) {
458
+		$this->checkError($constraintParameters);
459
+		if (!array_key_exists($minimumId, $constraintParameters) ||
460
+			!array_key_exists($maximumId, $constraintParameters)
461 461
 		) {
462 462
 			throw new ConstraintParameterException(
463
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-needed' ) )
464
-					->withDataValueType( $type )
465
-					->withEntityId( new NumericPropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
466
-					->withEntityId( new NumericPropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
467
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
463
+				(new ViolationMessage('wbqc-violation-message-range-parameters-needed'))
464
+					->withDataValueType($type)
465
+					->withEntityId(new NumericPropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
466
+					->withEntityId(new NumericPropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
467
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
468 468
 			);
469 469
 		}
470 470
 
471
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
472
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
471
+		$this->requireSingleParameter($constraintParameters, $minimumId);
472
+		$this->requireSingleParameter($constraintParameters, $maximumId);
473 473
 		$parseFunction = $type === 'time' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
474
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
475
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
474
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
475
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
476 476
 
477
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
478
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
477
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
478
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
479 479
 			throw new ConstraintParameterException(
480
-				new ViolationMessage( 'wbqc-violation-message-range-parameters-one-year' )
480
+				new ViolationMessage('wbqc-violation-message-range-parameters-one-year')
481 481
 			);
482 482
 		}
483
-		if ( $min === null && $max === null ||
484
-			$min !== null && $max !== null && $min->equals( $max ) ) {
483
+		if ($min === null && $max === null ||
484
+			$min !== null && $max !== null && $min->equals($max)) {
485 485
 			throw new ConstraintParameterException(
486
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-same' ) )
487
-					->withEntityId( new NumericPropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
488
-					->withEntityId( new NumericPropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
486
+				(new ViolationMessage('wbqc-violation-message-range-parameters-same'))
487
+					->withEntityId(new NumericPropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
488
+					->withEntityId(new NumericPropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
489 489
 			);
490 490
 		}
491 491
 
492
-		return [ $min, $max ];
492
+		return [$min, $max];
493 493
 	}
494 494
 
495 495
 	/**
@@ -499,11 +499,11 @@  discard block
 block discarded – undo
499 499
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
500 500
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
501 501
 	 */
502
-	public function parseQuantityRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
502
+	public function parseQuantityRangeParameter(array $constraintParameters, $constraintTypeItemId) {
503 503
 		return $this->parseRangeParameter(
504 504
 			$constraintParameters,
505
-			$this->config->get( 'WBQualityConstraintsMinimumQuantityId' ),
506
-			$this->config->get( 'WBQualityConstraintsMaximumQuantityId' ),
505
+			$this->config->get('WBQualityConstraintsMinimumQuantityId'),
506
+			$this->config->get('WBQualityConstraintsMaximumQuantityId'),
507 507
 			$constraintTypeItemId,
508 508
 			'quantity'
509 509
 		);
@@ -516,11 +516,11 @@  discard block
 block discarded – undo
516 516
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
517 517
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
518 518
 	 */
519
-	public function parseTimeRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
519
+	public function parseTimeRangeParameter(array $constraintParameters, $constraintTypeItemId) {
520 520
 		return $this->parseRangeParameter(
521 521
 			$constraintParameters,
522
-			$this->config->get( 'WBQualityConstraintsMinimumDateId' ),
523
-			$this->config->get( 'WBQualityConstraintsMaximumDateId' ),
522
+			$this->config->get('WBQualityConstraintsMinimumDateId'),
523
+			$this->config->get('WBQualityConstraintsMaximumDateId'),
524 524
 			$constraintTypeItemId,
525 525
 			'time'
526 526
 		);
@@ -532,20 +532,20 @@  discard block
 block discarded – undo
532 532
 	 * @throws ConstraintParameterException
533 533
 	 * @return string[]
534 534
 	 */
535
-	public function parseLanguageParameter( array $constraintParameters, $constraintTypeItemId ): array {
536
-		$this->checkError( $constraintParameters );
537
-		$languagePropertyId = $this->config->get( 'WBQualityConstraintsLanguagePropertyId' );
538
-		if ( !array_key_exists( $languagePropertyId, $constraintParameters ) ) {
535
+	public function parseLanguageParameter(array $constraintParameters, $constraintTypeItemId): array {
536
+		$this->checkError($constraintParameters);
537
+		$languagePropertyId = $this->config->get('WBQualityConstraintsLanguagePropertyId');
538
+		if (!array_key_exists($languagePropertyId, $constraintParameters)) {
539 539
 			throw new ConstraintParameterException(
540
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
541
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
542
-					->withEntityId( new NumericPropertyId( $languagePropertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
540
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
541
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
542
+					->withEntityId(new NumericPropertyId($languagePropertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
543 543
 			);
544 544
 		}
545 545
 
546 546
 		$languages = [];
547
-		foreach ( $constraintParameters[$languagePropertyId] as $snak ) {
548
-			$languages[] = $this->parseStringParameter( $snak, $languagePropertyId );
547
+		foreach ($constraintParameters[$languagePropertyId] as $snak) {
548
+			$languages[] = $this->parseStringParameter($snak, $languagePropertyId);
549 549
 		}
550 550
 		return $languages;
551 551
 	}
@@ -557,17 +557,17 @@  discard block
 block discarded – undo
557 557
 	 * @throws ConstraintParameterException
558 558
 	 * @return string
559 559
 	 */
560
-	private function parseStringParameter( array $snakSerialization, $parameterId ) {
561
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
562
-		$this->requireValueParameter( $snak, $parameterId );
560
+	private function parseStringParameter(array $snakSerialization, $parameterId) {
561
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
562
+		$this->requireValueParameter($snak, $parameterId);
563 563
 		$value = $snak->getDataValue();
564
-		if ( $value instanceof StringValue ) {
564
+		if ($value instanceof StringValue) {
565 565
 			return $value->getValue();
566 566
 		} else {
567 567
 			throw new ConstraintParameterException(
568
-				( new ViolationMessage( 'wbqc-violation-message-parameter-string' ) )
569
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
570
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
568
+				(new ViolationMessage('wbqc-violation-message-parameter-string'))
569
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
570
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
571 571
 			);
572 572
 		}
573 573
 	}
@@ -578,15 +578,15 @@  discard block
 block discarded – undo
578 578
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
579 579
 	 * @return string
580 580
 	 */
581
-	public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) {
582
-		$this->checkError( $constraintParameters );
583
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
584
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
581
+	public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) {
582
+		$this->checkError($constraintParameters);
583
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
584
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
585 585
 			return '';
586 586
 		}
587 587
 
588
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
589
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
588
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
589
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
590 590
 	}
591 591
 
592 592
 	/**
@@ -595,19 +595,19 @@  discard block
 block discarded – undo
595 595
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
596 596
 	 * @return string
597 597
 	 */
598
-	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
599
-		$this->checkError( $constraintParameters );
600
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
601
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
598
+	public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) {
599
+		$this->checkError($constraintParameters);
600
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
601
+		if (!array_key_exists($formatId, $constraintParameters)) {
602 602
 			throw new ConstraintParameterException(
603
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
604
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
605
-					->withEntityId( new NumericPropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
603
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
604
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
605
+					->withEntityId(new NumericPropertyId($formatId), Role::CONSTRAINT_PARAMETER_PROPERTY)
606 606
 			);
607 607
 		}
608 608
 
609
-		$this->requireSingleParameter( $constraintParameters, $formatId );
610
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
609
+		$this->requireSingleParameter($constraintParameters, $formatId);
610
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
611 611
 	}
612 612
 
613 613
 	/**
@@ -615,16 +615,16 @@  discard block
 block discarded – undo
615 615
 	 * @throws ConstraintParameterException if the parameter is invalid
616 616
 	 * @return EntityId[]
617 617
 	 */
618
-	public function parseExceptionParameter( array $constraintParameters ) {
619
-		$this->checkError( $constraintParameters );
620
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
621
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
618
+	public function parseExceptionParameter(array $constraintParameters) {
619
+		$this->checkError($constraintParameters);
620
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
621
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
622 622
 			return [];
623 623
 		}
624 624
 
625 625
 		return array_map(
626
-			function ( $snakSerialization ) use ( $exceptionId ) {
627
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
626
+			function($snakSerialization) use ($exceptionId) {
627
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
628 628
 			},
629 629
 			$constraintParameters[$exceptionId]
630 630
 		);
@@ -635,39 +635,39 @@  discard block
 block discarded – undo
635 635
 	 * @throws ConstraintParameterException if the parameter is invalid
636 636
 	 * @return string|null 'mandatory', 'suggestion' or null
637 637
 	 */
638
-	public function parseConstraintStatusParameter( array $constraintParameters ) {
639
-		$this->checkError( $constraintParameters );
640
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
641
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
638
+	public function parseConstraintStatusParameter(array $constraintParameters) {
639
+		$this->checkError($constraintParameters);
640
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
641
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
642 642
 			return null;
643 643
 		}
644 644
 
645
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
646
-		$supportedStatuses = [ new ItemId( $mandatoryId ) ];
647
-		if ( $this->config->get( 'WBQualityConstraintsEnableSuggestionConstraintStatus' ) ) {
648
-			$suggestionId = $this->config->get( 'WBQualityConstraintsSuggestionConstraintId' );
649
-			$supportedStatuses[] = new ItemId( $suggestionId );
645
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
646
+		$supportedStatuses = [new ItemId($mandatoryId)];
647
+		if ($this->config->get('WBQualityConstraintsEnableSuggestionConstraintStatus')) {
648
+			$suggestionId = $this->config->get('WBQualityConstraintsSuggestionConstraintId');
649
+			$supportedStatuses[] = new ItemId($suggestionId);
650 650
 		} else {
651 651
 			$suggestionId = null;
652 652
 		}
653 653
 
654
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
655
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
656
-		$this->requireValueParameter( $snak, $constraintStatusId );
654
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
655
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
656
+		$this->requireValueParameter($snak, $constraintStatusId);
657 657
 		'@phan-var \Wikibase\DataModel\Snak\PropertyValueSnak $snak';
658 658
 		$dataValue = $snak->getDataValue();
659 659
 		'@phan-var EntityIdValue $dataValue';
660 660
 		$entityId = $dataValue->getEntityId();
661 661
 		$statusId = $entityId->getSerialization();
662 662
 
663
-		if ( $statusId === $mandatoryId ) {
663
+		if ($statusId === $mandatoryId) {
664 664
 			return 'mandatory';
665
-		} elseif ( $statusId === $suggestionId ) {
665
+		} elseif ($statusId === $suggestionId) {
666 666
 			return 'suggestion';
667 667
 		} else {
668 668
 			throw new ConstraintParameterException(
669
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
670
-					->withEntityId( new NumericPropertyId( $constraintStatusId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
669
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
670
+					->withEntityId(new NumericPropertyId($constraintStatusId), Role::CONSTRAINT_PARAMETER_PROPERTY)
671 671
 					->withEntityIdList(
672 672
 						$supportedStatuses,
673 673
 						Role::CONSTRAINT_PARAMETER_VALUE
@@ -683,12 +683,12 @@  discard block
 block discarded – undo
683 683
 	 * @return void
684 684
 	 * @throws ConstraintParameterException
685 685
 	 */
686
-	private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) {
687
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
686
+	private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) {
687
+		if (!($dataValue instanceof MonolingualTextValue)) {
688 688
 			throw new ConstraintParameterException(
689
-				( new ViolationMessage( 'wbqc-violation-message-parameter-monolingualtext' ) )
690
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
691
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
689
+				(new ViolationMessage('wbqc-violation-message-parameter-monolingualtext'))
690
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
691
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
692 692
 			);
693 693
 		}
694 694
 	}
@@ -701,31 +701,31 @@  discard block
 block discarded – undo
701 701
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
702 702
 	 * @return MultilingualTextValue
703 703
 	 */
704
-	private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) {
704
+	private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) {
705 705
 		$result = [];
706 706
 
707
-		foreach ( $snakSerializations as $snakSerialization ) {
708
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
709
-			$this->requireValueParameter( $snak, $parameterId );
707
+		foreach ($snakSerializations as $snakSerialization) {
708
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
709
+			$this->requireValueParameter($snak, $parameterId);
710 710
 
711 711
 			$value = $snak->getDataValue();
712
-			$this->requireMonolingualTextParameter( $value, $parameterId );
712
+			$this->requireMonolingualTextParameter($value, $parameterId);
713 713
 			/** @var MonolingualTextValue $value */
714 714
 			'@phan-var MonolingualTextValue $value';
715 715
 
716 716
 			$code = $value->getLanguageCode();
717
-			if ( array_key_exists( $code, $result ) ) {
717
+			if (array_key_exists($code, $result)) {
718 718
 				throw new ConstraintParameterException(
719
-					( new ViolationMessage( 'wbqc-violation-message-parameter-single-per-language' ) )
720
-						->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
721
-						->withLanguage( $code )
719
+					(new ViolationMessage('wbqc-violation-message-parameter-single-per-language'))
720
+						->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
721
+						->withLanguage($code)
722 722
 				);
723 723
 			}
724 724
 
725 725
 			$result[$code] = $value;
726 726
 		}
727 727
 
728
-		return new MultilingualTextValue( $result );
728
+		return new MultilingualTextValue($result);
729 729
 	}
730 730
 
731 731
 	/**
@@ -733,11 +733,11 @@  discard block
 block discarded – undo
733 733
 	 * @throws ConstraintParameterException if the parameter is invalid
734 734
 	 * @return MultilingualTextValue
735 735
 	 */
736
-	public function parseSyntaxClarificationParameter( array $constraintParameters ) {
737
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
736
+	public function parseSyntaxClarificationParameter(array $constraintParameters) {
737
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
738 738
 
739
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
740
-			return new MultilingualTextValue( [] );
739
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
740
+			return new MultilingualTextValue([]);
741 741
 		}
742 742
 
743 743
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
@@ -770,14 +770,14 @@  discard block
 block discarded – undo
770 770
 		array $validContextTypes,
771 771
 		array $validEntityTypes
772 772
 	): array {
773
-		$contextTypeParameterId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
773
+		$contextTypeParameterId = $this->config->get('WBQualityConstraintsConstraintScopeId');
774 774
 		$contextTypeItemIds = $this->parseItemIdsParameter(
775 775
 			$constraintParameters,
776 776
 			$constraintTypeItemId,
777 777
 			false,
778 778
 			$contextTypeParameterId
779 779
 		);
780
-		$entityTypeParameterId = $this->config->get( 'WBQualityConstraintsConstraintEntityTypesId' );
780
+		$entityTypeParameterId = $this->config->get('WBQualityConstraintsConstraintEntityTypesId');
781 781
 		$entityTypeItemIds = $this->parseItemIdsParameter(
782 782
 			$constraintParameters,
783 783
 			$constraintTypeItemId,
@@ -793,26 +793,26 @@  discard block
 block discarded – undo
793 793
 		$contextTypes = null;
794 794
 		$entityTypes = null;
795 795
 
796
-		if ( $contextTypeParameterId === $entityTypeParameterId ) {
796
+		if ($contextTypeParameterId === $entityTypeParameterId) {
797 797
 			$itemIds = $contextTypeItemIds;
798 798
 			$mapping = $contextTypeMapping + $entityTypeMapping;
799
-			foreach ( $itemIds as $itemId ) {
800
-				$mapped = $this->mapItemId( $itemId, $mapping, $contextTypeParameterId );
801
-				if ( in_array( $mapped, $contextTypeMapping, true ) ) {
799
+			foreach ($itemIds as $itemId) {
800
+				$mapped = $this->mapItemId($itemId, $mapping, $contextTypeParameterId);
801
+				if (in_array($mapped, $contextTypeMapping, true)) {
802 802
 					$contextTypes[] = $mapped;
803 803
 				} else {
804 804
 					$entityTypes[] = $mapped;
805 805
 				}
806 806
 			}
807 807
 		} else {
808
-			foreach ( $contextTypeItemIds as $contextTypeItemId ) {
808
+			foreach ($contextTypeItemIds as $contextTypeItemId) {
809 809
 				$contextTypes[] = $this->mapItemId(
810 810
 					$contextTypeItemId,
811 811
 					$contextTypeMapping,
812 812
 					$contextTypeParameterId
813 813
 				);
814 814
 			}
815
-			foreach ( $entityTypeItemIds as $entityTypeItemId ) {
815
+			foreach ($entityTypeItemIds as $entityTypeItemId) {
816 816
 				$entityTypes[] = $this->mapItemId(
817 817
 					$entityTypeItemId,
818 818
 					$entityTypeMapping,
@@ -821,21 +821,21 @@  discard block
 block discarded – undo
821 821
 			}
822 822
 		}
823 823
 
824
-		$this->checkValidScope( $constraintTypeItemId, $contextTypes, $validContextTypes );
825
-		$this->checkValidScope( $constraintTypeItemId, $entityTypes, $validEntityTypes );
824
+		$this->checkValidScope($constraintTypeItemId, $contextTypes, $validContextTypes);
825
+		$this->checkValidScope($constraintTypeItemId, $entityTypes, $validEntityTypes);
826 826
 
827
-		return [ $contextTypes, $entityTypes ];
827
+		return [$contextTypes, $entityTypes];
828 828
 	}
829 829
 
830
-	private function checkValidScope( string $constraintTypeItemId, ?array $types, array $validTypes ): void {
831
-		$invalidTypes = array_diff( $types ?: [], $validTypes );
832
-		if ( $invalidTypes !== [] ) {
833
-			$invalidType = array_pop( $invalidTypes );
830
+	private function checkValidScope(string $constraintTypeItemId, ?array $types, array $validTypes): void {
831
+		$invalidTypes = array_diff($types ?: [], $validTypes);
832
+		if ($invalidTypes !== []) {
833
+			$invalidType = array_pop($invalidTypes);
834 834
 			throw new ConstraintParameterException(
835
-				( new ViolationMessage( 'wbqc-violation-message-invalid-scope' ) )
836
-					->withConstraintScope( $invalidType, Role::CONSTRAINT_PARAMETER_VALUE )
837
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
838
-					->withConstraintScopeList( $validTypes, Role::CONSTRAINT_PARAMETER_VALUE )
835
+				(new ViolationMessage('wbqc-violation-message-invalid-scope'))
836
+					->withConstraintScope($invalidType, Role::CONSTRAINT_PARAMETER_VALUE)
837
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
838
+					->withConstraintScopeList($validTypes, Role::CONSTRAINT_PARAMETER_VALUE)
839 839
 			);
840 840
 		}
841 841
 	}
@@ -846,8 +846,8 @@  discard block
 block discarded – undo
846 846
 	 * @param ItemId $unitId
847 847
 	 * @return string unit
848 848
 	 */
849
-	private function parseUnitParameter( ItemId $unitId ) {
850
-		return $this->unitItemConceptBaseUri . $unitId->getSerialization();
849
+	private function parseUnitParameter(ItemId $unitId) {
850
+		return $this->unitItemConceptBaseUri.$unitId->getSerialization();
851 851
 	}
852 852
 
853 853
 	/**
@@ -857,23 +857,23 @@  discard block
 block discarded – undo
857 857
 	 * @return UnitsParameter
858 858
 	 * @throws ConstraintParameterException
859 859
 	 */
860
-	private function parseUnitItem( ItemIdSnakValue $item ) {
861
-		switch ( true ) {
860
+	private function parseUnitItem(ItemIdSnakValue $item) {
861
+		switch (true) {
862 862
 			case $item->isValue():
863
-				$unit = $this->parseUnitParameter( $item->getItemId() );
863
+				$unit = $this->parseUnitParameter($item->getItemId());
864 864
 				return new UnitsParameter(
865
-					[ $item->getItemId() ],
866
-					[ UnboundedQuantityValue::newFromNumber( 1, $unit ) ],
865
+					[$item->getItemId()],
866
+					[UnboundedQuantityValue::newFromNumber(1, $unit)],
867 867
 					false
868 868
 				);
869 869
 			case $item->isSomeValue():
870
-				$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
870
+				$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
871 871
 				throw new ConstraintParameterException(
872
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
873
-						->withEntityId( new NumericPropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
872
+					(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
873
+						->withEntityId(new NumericPropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
874 874
 				);
875 875
 			case $item->isNoValue():
876
-				return new UnitsParameter( [], [], true );
876
+				return new UnitsParameter([], [], true);
877 877
 		}
878 878
 	}
879 879
 
@@ -883,36 +883,36 @@  discard block
 block discarded – undo
883 883
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
884 884
 	 * @return UnitsParameter
885 885
 	 */
886
-	public function parseUnitsParameter( array $constraintParameters, $constraintTypeItemId ) {
887
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
886
+	public function parseUnitsParameter(array $constraintParameters, $constraintTypeItemId) {
887
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
888 888
 		$unitItems = [];
889 889
 		$unitQuantities = [];
890 890
 		$unitlessAllowed = false;
891 891
 
892
-		foreach ( $items as $item ) {
893
-			$unit = $this->parseUnitItem( $item );
894
-			$unitItems = array_merge( $unitItems, $unit->getUnitItemIds() );
895
-			$unitQuantities = array_merge( $unitQuantities, $unit->getUnitQuantities() );
892
+		foreach ($items as $item) {
893
+			$unit = $this->parseUnitItem($item);
894
+			$unitItems = array_merge($unitItems, $unit->getUnitItemIds());
895
+			$unitQuantities = array_merge($unitQuantities, $unit->getUnitQuantities());
896 896
 			$unitlessAllowed = $unitlessAllowed || $unit->getUnitlessAllowed();
897 897
 		}
898 898
 
899
-		if ( $unitQuantities === [] && !$unitlessAllowed ) {
899
+		if ($unitQuantities === [] && !$unitlessAllowed) {
900 900
 			throw new LogicException(
901 901
 				'The "units" parameter is required, and yet we seem to be missing any allowed unit'
902 902
 			);
903 903
 		}
904 904
 
905
-		return new UnitsParameter( $unitItems, $unitQuantities, $unitlessAllowed );
905
+		return new UnitsParameter($unitItems, $unitQuantities, $unitlessAllowed);
906 906
 	}
907 907
 
908 908
 	private function getEntityTypeMapping(): array {
909 909
 		return [
910
-			$this->config->get( 'WBQualityConstraintsWikibaseItemId' ) => 'item',
911
-			$this->config->get( 'WBQualityConstraintsWikibasePropertyId' ) => 'property',
912
-			$this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ) => 'lexeme',
913
-			$this->config->get( 'WBQualityConstraintsWikibaseFormId' ) => 'form',
914
-			$this->config->get( 'WBQualityConstraintsWikibaseSenseId' ) => 'sense',
915
-			$this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ) => 'mediainfo',
910
+			$this->config->get('WBQualityConstraintsWikibaseItemId') => 'item',
911
+			$this->config->get('WBQualityConstraintsWikibasePropertyId') => 'property',
912
+			$this->config->get('WBQualityConstraintsWikibaseLexemeId') => 'lexeme',
913
+			$this->config->get('WBQualityConstraintsWikibaseFormId') => 'form',
914
+			$this->config->get('WBQualityConstraintsWikibaseSenseId') => 'sense',
915
+			$this->config->get('WBQualityConstraintsWikibaseMediaInfoId') => 'mediainfo',
916 916
 		];
917 917
 	}
918 918
 
@@ -922,10 +922,10 @@  discard block
 block discarded – undo
922 922
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
923 923
 	 * @return EntityTypesParameter
924 924
 	 */
925
-	public function parseEntityTypesParameter( array $constraintParameters, $constraintTypeItemId ) {
925
+	public function parseEntityTypesParameter(array $constraintParameters, $constraintTypeItemId) {
926 926
 		$entityTypes = [];
927 927
 		$entityTypeItemIds = [];
928
-		$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
928
+		$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
929 929
 		$itemIds = $this->parseItemIdsParameter(
930 930
 			$constraintParameters,
931 931
 			$constraintTypeItemId,
@@ -934,22 +934,22 @@  discard block
 block discarded – undo
934 934
 		);
935 935
 
936 936
 		$mapping = $this->getEntityTypeMapping();
937
-		foreach ( $itemIds as $itemId ) {
938
-			$entityType = $this->mapItemId( $itemId, $mapping, $parameterId );
937
+		foreach ($itemIds as $itemId) {
938
+			$entityType = $this->mapItemId($itemId, $mapping, $parameterId);
939 939
 			$entityTypes[] = $entityType;
940 940
 			$entityTypeItemIds[] = $itemId;
941 941
 		}
942 942
 
943
-		if ( empty( $entityTypes ) ) {
943
+		if (empty($entityTypes)) {
944 944
 			// @codeCoverageIgnoreStart
945 945
 			throw new LogicException(
946
-				'The "entity types" parameter is required, ' .
946
+				'The "entity types" parameter is required, '.
947 947
 				'and yet we seem to be missing any allowed entity type'
948 948
 			);
949 949
 			// @codeCoverageIgnoreEnd
950 950
 		}
951 951
 
952
-		return new EntityTypesParameter( $entityTypes, $entityTypeItemIds );
952
+		return new EntityTypesParameter($entityTypes, $entityTypeItemIds);
953 953
 	}
954 954
 
955 955
 	/**
@@ -957,18 +957,18 @@  discard block
 block discarded – undo
957 957
 	 * @throws ConstraintParameterException if the parameter is invalid
958 958
 	 * @return PropertyId[]
959 959
 	 */
960
-	public function parseSeparatorsParameter( array $constraintParameters ) {
961
-		$separatorId = $this->config->get( 'WBQualityConstraintsSeparatorId' );
960
+	public function parseSeparatorsParameter(array $constraintParameters) {
961
+		$separatorId = $this->config->get('WBQualityConstraintsSeparatorId');
962 962
 
963
-		if ( !array_key_exists( $separatorId, $constraintParameters ) ) {
963
+		if (!array_key_exists($separatorId, $constraintParameters)) {
964 964
 			return [];
965 965
 		}
966 966
 
967 967
 		$parameters = $constraintParameters[$separatorId];
968 968
 		$separators = [];
969 969
 
970
-		foreach ( $parameters as $parameter ) {
971
-			$separators[] = $this->parsePropertyIdParameter( $parameter, $separatorId );
970
+		foreach ($parameters as $parameter) {
971
+			$separators[] = $this->parsePropertyIdParameter($parameter, $separatorId);
972 972
 		}
973 973
 
974 974
 		return $separators;
@@ -976,17 +976,17 @@  discard block
 block discarded – undo
976 976
 
977 977
 	private function getConstraintScopeContextTypeMapping(): array {
978 978
 		return [
979
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' ) => Context::TYPE_STATEMENT,
980
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' ) => Context::TYPE_QUALIFIER,
981
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' ) => Context::TYPE_REFERENCE,
979
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId') => Context::TYPE_STATEMENT,
980
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId') => Context::TYPE_QUALIFIER,
981
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId') => Context::TYPE_REFERENCE,
982 982
 		];
983 983
 	}
984 984
 
985 985
 	private function getPropertyScopeContextTypeMapping(): array {
986 986
 		return [
987
-			$this->config->get( 'WBQualityConstraintsAsMainValueId' ) => Context::TYPE_STATEMENT,
988
-			$this->config->get( 'WBQualityConstraintsAsQualifiersId' ) => Context::TYPE_QUALIFIER,
989
-			$this->config->get( 'WBQualityConstraintsAsReferencesId' ) => Context::TYPE_REFERENCE,
987
+			$this->config->get('WBQualityConstraintsAsMainValueId') => Context::TYPE_STATEMENT,
988
+			$this->config->get('WBQualityConstraintsAsQualifiersId') => Context::TYPE_QUALIFIER,
989
+			$this->config->get('WBQualityConstraintsAsReferencesId') => Context::TYPE_REFERENCE,
990 990
 		];
991 991
 	}
992 992
 
@@ -996,9 +996,9 @@  discard block
 block discarded – undo
996 996
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
997 997
 	 * @return string[] list of Context::TYPE_* constants
998 998
 	 */
999
-	public function parsePropertyScopeParameter( array $constraintParameters, $constraintTypeItemId ) {
999
+	public function parsePropertyScopeParameter(array $constraintParameters, $constraintTypeItemId) {
1000 1000
 		$contextTypes = [];
1001
-		$parameterId = $this->config->get( 'WBQualityConstraintsPropertyScopeId' );
1001
+		$parameterId = $this->config->get('WBQualityConstraintsPropertyScopeId');
1002 1002
 		$itemIds = $this->parseItemIdsParameter(
1003 1003
 			$constraintParameters,
1004 1004
 			$constraintTypeItemId,
@@ -1007,14 +1007,14 @@  discard block
 block discarded – undo
1007 1007
 		);
1008 1008
 
1009 1009
 		$mapping = $this->getPropertyScopeContextTypeMapping();
1010
-		foreach ( $itemIds as $itemId ) {
1011
-			$contextTypes[] = $this->mapItemId( $itemId, $mapping, $parameterId );
1010
+		foreach ($itemIds as $itemId) {
1011
+			$contextTypes[] = $this->mapItemId($itemId, $mapping, $parameterId);
1012 1012
 		}
1013 1013
 
1014
-		if ( empty( $contextTypes ) ) {
1014
+		if (empty($contextTypes)) {
1015 1015
 			// @codeCoverageIgnoreStart
1016 1016
 			throw new LogicException(
1017
-				'The "property scope" parameter is required, ' .
1017
+				'The "property scope" parameter is required, '.
1018 1018
 				'and yet we seem to be missing any allowed scope'
1019 1019
 			);
1020 1020
 			// @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.