Completed
Push — master ( 6b7ae2...4e3989 )
by
unknown
33s
created
src/ServiceWiring-ConstraintCheckers.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -38,216 +38,216 @@
 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 ): ConflictsWithChecker {
41
+	ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => static function(MediaWikiServices $services): ConflictsWithChecker {
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 ): ItemChecker {
48
+	ConstraintCheckerServices::ITEM_CHECKER => static function(MediaWikiServices $services): ItemChecker {
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 (
55
+	ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => static function(
56 56
 		MediaWikiServices $services
57 57
 	): TargetRequiredClaimChecker {
58 58
 		return new TargetRequiredClaimChecker(
59
-			WikibaseServices::getEntityLookup( $services ),
60
-			ConstraintsServices::getConstraintParameterParser( $services ),
61
-			ConstraintsServices::getConnectionCheckerHelper( $services )
59
+			WikibaseServices::getEntityLookup($services),
60
+			ConstraintsServices::getConstraintParameterParser($services),
61
+			ConstraintsServices::getConnectionCheckerHelper($services)
62 62
 		);
63 63
 	},
64 64
 
65
-	ConstraintCheckerServices::SYMMETRIC_CHECKER => static function ( MediaWikiServices $services ): SymmetricChecker {
65
+	ConstraintCheckerServices::SYMMETRIC_CHECKER => static function(MediaWikiServices $services): SymmetricChecker {
66 66
 		return new SymmetricChecker(
67
-			WikibaseServices::getEntityLookupWithoutCache( $services ),
68
-			ConstraintsServices::getConnectionCheckerHelper( $services )
67
+			WikibaseServices::getEntityLookupWithoutCache($services),
68
+			ConstraintsServices::getConnectionCheckerHelper($services)
69 69
 		);
70 70
 	},
71 71
 
72
-	ConstraintCheckerServices::INVERSE_CHECKER => static function ( MediaWikiServices $services ): InverseChecker {
72
+	ConstraintCheckerServices::INVERSE_CHECKER => static function(MediaWikiServices $services): InverseChecker {
73 73
 		return new InverseChecker(
74
-			WikibaseServices::getEntityLookup( $services ),
75
-			ConstraintsServices::getConstraintParameterParser( $services ),
76
-			ConstraintsServices::getConnectionCheckerHelper( $services )
74
+			WikibaseServices::getEntityLookup($services),
75
+			ConstraintsServices::getConstraintParameterParser($services),
76
+			ConstraintsServices::getConnectionCheckerHelper($services)
77 77
 		);
78 78
 	},
79 79
 
80
-	ConstraintCheckerServices::QUALIFIER_CHECKER => static function ( MediaWikiServices $services ): QualifierChecker {
80
+	ConstraintCheckerServices::QUALIFIER_CHECKER => static function(MediaWikiServices $services): QualifierChecker {
81 81
 		return new QualifierChecker();
82 82
 	},
83 83
 
84
-	ConstraintCheckerServices::QUALIFIERS_CHECKER => static function ( MediaWikiServices $services ): QualifiersChecker {
84
+	ConstraintCheckerServices::QUALIFIERS_CHECKER => static function(MediaWikiServices $services): QualifiersChecker {
85 85
 		return new QualifiersChecker(
86
-			ConstraintsServices::getConstraintParameterParser( $services )
86
+			ConstraintsServices::getConstraintParameterParser($services)
87 87
 		);
88 88
 	},
89 89
 
90
-	ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => static function (
90
+	ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => static function(
91 91
 		MediaWikiServices $services
92 92
 	): MandatoryQualifiersChecker {
93 93
 		return new MandatoryQualifiersChecker(
94
-			ConstraintsServices::getConstraintParameterParser( $services )
94
+			ConstraintsServices::getConstraintParameterParser($services)
95 95
 		);
96 96
 	},
97 97
 
98
-	ConstraintCheckerServices::RANGE_CHECKER => static function ( MediaWikiServices $services ): RangeChecker {
98
+	ConstraintCheckerServices::RANGE_CHECKER => static function(MediaWikiServices $services): RangeChecker {
99 99
 		return new RangeChecker(
100
-			WikibaseRepo::getPropertyDataTypeLookup( $services ),
101
-			ConstraintsServices::getConstraintParameterParser( $services ),
102
-			ConstraintsServices::getRangeCheckerHelper( $services )
100
+			WikibaseRepo::getPropertyDataTypeLookup($services),
101
+			ConstraintsServices::getConstraintParameterParser($services),
102
+			ConstraintsServices::getRangeCheckerHelper($services)
103 103
 		);
104 104
 	},
105 105
 
106
-	ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => static function (
106
+	ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => static function(
107 107
 		MediaWikiServices $services
108 108
 	): DiffWithinRangeChecker {
109 109
 		return new DiffWithinRangeChecker(
110
-			ConstraintsServices::getConstraintParameterParser( $services ),
111
-			ConstraintsServices::getRangeCheckerHelper( $services ),
110
+			ConstraintsServices::getConstraintParameterParser($services),
111
+			ConstraintsServices::getRangeCheckerHelper($services),
112 112
 			$services->getMainConfig()
113 113
 		);
114 114
 	},
115 115
 
116
-	ConstraintCheckerServices::TYPE_CHECKER => static function ( MediaWikiServices $services ): TypeChecker {
116
+	ConstraintCheckerServices::TYPE_CHECKER => static function(MediaWikiServices $services): TypeChecker {
117 117
 		return new TypeChecker(
118
-			ConstraintsServices::getConstraintParameterParser( $services ),
119
-			ConstraintsServices::getTypeCheckerHelper( $services ),
118
+			ConstraintsServices::getConstraintParameterParser($services),
119
+			ConstraintsServices::getTypeCheckerHelper($services),
120 120
 			$services->getMainConfig()
121 121
 		);
122 122
 	},
123 123
 
124
-	ConstraintCheckerServices::VALUE_TYPE_CHECKER => static function ( MediaWikiServices $services ): ValueTypeChecker {
124
+	ConstraintCheckerServices::VALUE_TYPE_CHECKER => static function(MediaWikiServices $services): ValueTypeChecker {
125 125
 		return new ValueTypeChecker(
126
-			WikibaseServices::getEntityLookup( $services ),
127
-			ConstraintsServices::getConstraintParameterParser( $services ),
128
-			ConstraintsServices::getTypeCheckerHelper( $services ),
126
+			WikibaseServices::getEntityLookup($services),
127
+			ConstraintsServices::getConstraintParameterParser($services),
128
+			ConstraintsServices::getTypeCheckerHelper($services),
129 129
 			$services->getMainConfig()
130 130
 		);
131 131
 	},
132 132
 
133
-	ConstraintCheckerServices::SINGLE_VALUE_CHECKER => static function ( MediaWikiServices $services ): SingleValueChecker {
133
+	ConstraintCheckerServices::SINGLE_VALUE_CHECKER => static function(MediaWikiServices $services): SingleValueChecker {
134 134
 		return new SingleValueChecker(
135
-			ConstraintsServices::getConstraintParameterParser( $services )
135
+			ConstraintsServices::getConstraintParameterParser($services)
136 136
 		);
137 137
 	},
138 138
 
139
-	ConstraintCheckerServices::MULTI_VALUE_CHECKER => static function ( MediaWikiServices $services ): MultiValueChecker {
139
+	ConstraintCheckerServices::MULTI_VALUE_CHECKER => static function(MediaWikiServices $services): MultiValueChecker {
140 140
 		return new MultiValueChecker(
141
-			ConstraintsServices::getConstraintParameterParser( $services )
141
+			ConstraintsServices::getConstraintParameterParser($services)
142 142
 		);
143 143
 	},
144 144
 
145
-	ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => static function ( MediaWikiServices $services ): UniqueValueChecker {
145
+	ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => static function(MediaWikiServices $services): UniqueValueChecker {
146 146
 		// TODO return a different, dummy implementation if SPARQL is not available
147 147
 		return new UniqueValueChecker(
148
-			ConstraintsServices::getSparqlHelper( $services ),
149
-			ConstraintsServices::getConstraintParameterParser( $services )
148
+			ConstraintsServices::getSparqlHelper($services),
149
+			ConstraintsServices::getConstraintParameterParser($services)
150 150
 		);
151 151
 	},
152 152
 
153
-	ConstraintCheckerServices::FORMAT_CHECKER => static function ( MediaWikiServices $services ): FormatChecker {
153
+	ConstraintCheckerServices::FORMAT_CHECKER => static function(MediaWikiServices $services): FormatChecker {
154 154
 		// TODO return a different, dummy implementation if SPARQL is not available
155 155
 		return new FormatChecker(
156
-			ConstraintsServices::getConstraintParameterParser( $services ),
156
+			ConstraintsServices::getConstraintParameterParser($services),
157 157
 			$services->getMainConfig(),
158
-			ConstraintsServices::getSparqlHelper( $services ),
158
+			ConstraintsServices::getSparqlHelper($services),
159 159
 			$services->getShellboxClientFactory()
160 160
 		);
161 161
 	},
162 162
 
163
-	ConstraintCheckerServices::COMMONS_LINK_CHECKER => static function ( MediaWikiServices $services ): CommonsLinkChecker {
163
+	ConstraintCheckerServices::COMMONS_LINK_CHECKER => static function(MediaWikiServices $services): CommonsLinkChecker {
164 164
 		$pageNameNormalizer = new MediaWikiPageNameNormalizer();
165 165
 		return new CommonsLinkChecker(
166
-			ConstraintsServices::getConstraintParameterParser( $services ),
166
+			ConstraintsServices::getConstraintParameterParser($services),
167 167
 			$pageNameNormalizer,
168
-			WikibaseRepo::getPropertyDataTypeLookup( $services )
168
+			WikibaseRepo::getPropertyDataTypeLookup($services)
169 169
 		);
170 170
 	},
171 171
 
172
-	ConstraintCheckerServices::ONE_OF_CHECKER => static function ( MediaWikiServices $services ): OneOfChecker {
172
+	ConstraintCheckerServices::ONE_OF_CHECKER => static function(MediaWikiServices $services): OneOfChecker {
173 173
 		return new OneOfChecker(
174
-			ConstraintsServices::getConstraintParameterParser( $services )
174
+			ConstraintsServices::getConstraintParameterParser($services)
175 175
 		);
176 176
 	},
177 177
 
178
-	ConstraintCheckerServices::VALUE_ONLY_CHECKER => static function ( MediaWikiServices $services ): ValueOnlyChecker {
178
+	ConstraintCheckerServices::VALUE_ONLY_CHECKER => static function(MediaWikiServices $services): ValueOnlyChecker {
179 179
 		return new ValueOnlyChecker();
180 180
 	},
181 181
 
182
-	ConstraintCheckerServices::REFERENCE_CHECKER => static function ( MediaWikiServices $services ): ReferenceChecker {
182
+	ConstraintCheckerServices::REFERENCE_CHECKER => static function(MediaWikiServices $services): ReferenceChecker {
183 183
 		return new ReferenceChecker();
184 184
 	},
185 185
 
186
-	ConstraintCheckerServices::NO_BOUNDS_CHECKER => static function ( MediaWikiServices $services ): NoBoundsChecker {
186
+	ConstraintCheckerServices::NO_BOUNDS_CHECKER => static function(MediaWikiServices $services): NoBoundsChecker {
187 187
 		return new NoBoundsChecker();
188 188
 	},
189 189
 
190
-	ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => static function ( MediaWikiServices $services ): AllowedUnitsChecker {
190
+	ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => static function(MediaWikiServices $services): AllowedUnitsChecker {
191 191
 		return new AllowedUnitsChecker(
192
-			ConstraintsServices::getConstraintParameterParser( $services ),
193
-			WikibaseRepo::getUnitConverter( $services )
192
+			ConstraintsServices::getConstraintParameterParser($services),
193
+			WikibaseRepo::getUnitConverter($services)
194 194
 		);
195 195
 	},
196 196
 
197
-	ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => static function (
197
+	ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => static function(
198 198
 		MediaWikiServices $services
199 199
 	): SingleBestValueChecker {
200 200
 		return new SingleBestValueChecker(
201
-			ConstraintsServices::getConstraintParameterParser( $services )
201
+			ConstraintsServices::getConstraintParameterParser($services)
202 202
 		);
203 203
 	},
204 204
 
205
-	ConstraintCheckerServices::ENTITY_TYPE_CHECKER => static function ( MediaWikiServices $services ): EntityTypeChecker {
205
+	ConstraintCheckerServices::ENTITY_TYPE_CHECKER => static function(MediaWikiServices $services): EntityTypeChecker {
206 206
 		return new EntityTypeChecker(
207
-			ConstraintsServices::getConstraintParameterParser( $services )
207
+			ConstraintsServices::getConstraintParameterParser($services)
208 208
 		);
209 209
 	},
210 210
 
211
-	ConstraintCheckerServices::NONE_OF_CHECKER => static function ( MediaWikiServices $services ): NoneOfChecker {
211
+	ConstraintCheckerServices::NONE_OF_CHECKER => static function(MediaWikiServices $services): NoneOfChecker {
212 212
 		return new NoneOfChecker(
213
-			ConstraintsServices::getConstraintParameterParser( $services )
213
+			ConstraintsServices::getConstraintParameterParser($services)
214 214
 		);
215 215
 	},
216 216
 
217
-	ConstraintCheckerServices::INTEGER_CHECKER => static function ( MediaWikiServices $services ): IntegerChecker {
217
+	ConstraintCheckerServices::INTEGER_CHECKER => static function(MediaWikiServices $services): IntegerChecker {
218 218
 		return new IntegerChecker();
219 219
 	},
220 220
 
221
-	ConstraintCheckerServices::CITATION_NEEDED_CHECKER => static function ( MediaWikiServices $services ): CitationNeededChecker {
221
+	ConstraintCheckerServices::CITATION_NEEDED_CHECKER => static function(MediaWikiServices $services): CitationNeededChecker {
222 222
 		return new CitationNeededChecker();
223 223
 	},
224 224
 
225
-	ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => static function ( MediaWikiServices $services ): PropertyScopeChecker {
225
+	ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => static function(MediaWikiServices $services): PropertyScopeChecker {
226 226
 		return new PropertyScopeChecker(
227
-			ConstraintsServices::getConstraintParameterParser( $services )
227
+			ConstraintsServices::getConstraintParameterParser($services)
228 228
 		);
229 229
 	},
230 230
 
231
-	ConstraintCheckerServices::CONTEMPORARY_CHECKER => static function ( MediaWikiServices $services ): ContemporaryChecker {
231
+	ConstraintCheckerServices::CONTEMPORARY_CHECKER => static function(MediaWikiServices $services): ContemporaryChecker {
232 232
 		return new ContemporaryChecker(
233
-			WikibaseServices::getEntityLookup( $services ),
234
-			ConstraintsServices::getRangeCheckerHelper( $services ),
233
+			WikibaseServices::getEntityLookup($services),
234
+			ConstraintsServices::getRangeCheckerHelper($services),
235 235
 			$services->getMainConfig()
236 236
 		);
237 237
 	},
238 238
 
239
-	ConstraintCheckerServices::LEXEME_LANGUAGE_CHECKER => static function ( MediaWikiServices $services ): LanguageChecker {
239
+	ConstraintCheckerServices::LEXEME_LANGUAGE_CHECKER => static function(MediaWikiServices $services): LanguageChecker {
240 240
 		return new LanguageChecker(
241
-			ConstraintsServices::getConstraintParameterParser( $services ),
242
-			WikibaseServices::getEntityLookup( $services )
241
+			ConstraintsServices::getConstraintParameterParser($services),
242
+			WikibaseServices::getEntityLookup($services)
243 243
 		);
244 244
 	},
245 245
 
246
-	ConstraintCheckerServices::LABEL_IN_LANGUAGE_CHECKER => static function (
246
+	ConstraintCheckerServices::LABEL_IN_LANGUAGE_CHECKER => static function(
247 247
 		MediaWikiServices $services
248 248
 	): LabelInLanguageChecker {
249 249
 		return new LabelInLanguageChecker(
250
-			ConstraintsServices::getConstraintParameterParser( $services )
250
+			ConstraintsServices::getConstraintParameterParser($services)
251 251
 		);
252 252
 	},
253 253
 ];
Please login to merge, or discard this patch.
src/ConstraintCheck/DelegatingConstraintChecker.php 1 patch
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck;
6 6
 
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 		?callable $defaultResultsPerEntity = null
124 124
 	): array {
125 125
 		$checkResults = [];
126
-		$entity = $this->entityLookup->getEntity( $entityId );
126
+		$entity = $this->entityLookup->getEntity($entityId);
127 127
 
128
-		if ( $entity instanceof StatementListProvidingEntity ) {
129
-			$startTime = microtime( true );
128
+		if ($entity instanceof StatementListProvidingEntity) {
129
+			$startTime = microtime(true);
130 130
 
131 131
 			$checkResults = $this->checkEveryStatement(
132 132
 				$entity,
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 				$defaultResultsPerContext
135 135
 			);
136 136
 
137
-			$endTime = microtime( true );
137
+			$endTime = microtime(true);
138 138
 
139
-			if ( $constraintIds === null ) { // only log full constraint checks
139
+			if ($constraintIds === null) { // only log full constraint checks
140 140
 				$this->loggingHelper->logConstraintCheckOnEntity(
141 141
 					$entityId,
142 142
 					$checkResults,
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 		}
148 148
 
149
-		if ( $defaultResultsPerEntity !== null ) {
150
-			$checkResults = array_merge( $defaultResultsPerEntity( $entityId ), $checkResults );
149
+		if ($defaultResultsPerEntity !== null) {
150
+			$checkResults = array_merge($defaultResultsPerEntity($entityId), $checkResults);
151 151
 		}
152 152
 
153
-		return $this->sortResult( $checkResults );
153
+		return $this->sortResult($checkResults);
154 154
 	}
155 155
 
156 156
 	/**
@@ -172,19 +172,19 @@  discard block
 block discarded – undo
172 172
 		?callable $defaultResults = null
173 173
 	): array {
174 174
 
175
-		$parsedGuid = $this->statementGuidParser->parse( $guid );
175
+		$parsedGuid = $this->statementGuidParser->parse($guid);
176 176
 		$entityId = $parsedGuid->getEntityId();
177
-		$entity = $this->entityLookup->getEntity( $entityId );
178
-		if ( $entity instanceof StatementListProvidingEntity ) {
179
-			$statement = $entity->getStatements()->getFirstStatementWithGuid( $guid );
180
-			if ( $statement ) {
177
+		$entity = $this->entityLookup->getEntity($entityId);
178
+		if ($entity instanceof StatementListProvidingEntity) {
179
+			$statement = $entity->getStatements()->getFirstStatementWithGuid($guid);
180
+			if ($statement) {
181 181
 				$result = $this->checkStatement(
182 182
 					$entity,
183 183
 					$statement,
184 184
 					$constraintIds,
185 185
 					$defaultResults
186 186
 				);
187
-				$output = $this->sortResult( $result );
187
+				$output = $this->sortResult($result);
188 188
 				return $output;
189 189
 			}
190 190
 		}
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 		return [];
193 193
 	}
194 194
 
195
-	private function getValidContextTypes( Constraint $constraint ): array {
196
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
195
+	private function getValidContextTypes(Constraint $constraint): array {
196
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
197 197
 			return [
198 198
 				Context::TYPE_STATEMENT,
199 199
 				Context::TYPE_QUALIFIER,
@@ -201,21 +201,21 @@  discard block
 block discarded – undo
201 201
 			];
202 202
 		}
203 203
 
204
-		return array_keys( array_filter(
204
+		return array_keys(array_filter(
205 205
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedContextTypes(),
206
-			static fn ( $status ) => $status !== CheckResult::STATUS_NOT_IN_SCOPE
207
-		) );
206
+			static fn ($status) => $status !== CheckResult::STATUS_NOT_IN_SCOPE
207
+		));
208 208
 	}
209 209
 
210
-	private function getValidEntityTypes( Constraint $constraint ): array {
211
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
212
-			return array_keys( ConstraintChecker::ALL_ENTITY_TYPES_SUPPORTED );
210
+	private function getValidEntityTypes(Constraint $constraint): array {
211
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
212
+			return array_keys(ConstraintChecker::ALL_ENTITY_TYPES_SUPPORTED);
213 213
 		}
214 214
 
215
-		return array_keys( array_filter(
215
+		return array_keys(array_filter(
216 216
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedEntityTypes(),
217
-			static fn ( $status ) => $status !== CheckResult::STATUS_NOT_IN_SCOPE
218
-		) );
217
+			static fn ($status) => $status !== CheckResult::STATUS_NOT_IN_SCOPE
218
+		));
219 219
 	}
220 220
 
221 221
 	/**
@@ -226,38 +226,38 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @return ConstraintParameterException[]
228 228
 	 */
229
-	private function checkCommonConstraintParameters( Constraint $constraint ): array {
229
+	private function checkCommonConstraintParameters(Constraint $constraint): array {
230 230
 		$constraintParameters = $constraint->getConstraintParameters();
231 231
 		try {
232
-			$this->constraintParameterParser->checkError( $constraintParameters );
233
-		} catch ( ConstraintParameterException $e ) {
234
-			return [ $e ];
232
+			$this->constraintParameterParser->checkError($constraintParameters);
233
+		} catch (ConstraintParameterException $e) {
234
+			return [$e];
235 235
 		}
236 236
 
237 237
 		$problems = [];
238 238
 		try {
239
-			$this->constraintParameterParser->parseExceptionParameter( $constraintParameters );
240
-		} catch ( ConstraintParameterException $e ) {
239
+			$this->constraintParameterParser->parseExceptionParameter($constraintParameters);
240
+		} catch (ConstraintParameterException $e) {
241 241
 			$problems[] = $e;
242 242
 		}
243 243
 		try {
244
-			$this->constraintParameterParser->parseConstraintClarificationParameter( $constraintParameters );
245
-		} catch ( ConstraintParameterException $e ) {
244
+			$this->constraintParameterParser->parseConstraintClarificationParameter($constraintParameters);
245
+		} catch (ConstraintParameterException $e) {
246 246
 			$problems[] = $e;
247 247
 		}
248 248
 		try {
249
-			$this->constraintParameterParser->parseConstraintStatusParameter( $constraintParameters );
250
-		} catch ( ConstraintParameterException $e ) {
249
+			$this->constraintParameterParser->parseConstraintStatusParameter($constraintParameters);
250
+		} catch (ConstraintParameterException $e) {
251 251
 			$problems[] = $e;
252 252
 		}
253 253
 		try {
254 254
 			$this->constraintParameterParser->parseConstraintScopeParameters(
255 255
 				$constraintParameters,
256 256
 				$constraint->getConstraintTypeItemId(),
257
-				$this->getValidContextTypes( $constraint ),
258
-				$this->getValidEntityTypes( $constraint )
257
+				$this->getValidContextTypes($constraint),
258
+				$this->getValidEntityTypes($constraint)
259 259
 			);
260
-		} catch ( ConstraintParameterException $e ) {
260
+		} catch (ConstraintParameterException $e) {
261 261
 			$problems[] = $e;
262 262
 		}
263 263
 		return $problems;
@@ -270,16 +270,16 @@  discard block
 block discarded – undo
270 270
 	 * @return ConstraintParameterException[][] first level indexed by constraint ID,
271 271
 	 * second level like checkConstraintParametersOnConstraintId (but without possibility of null)
272 272
 	 */
273
-	public function checkConstraintParametersOnPropertyId( NumericPropertyId $propertyId ): array {
274
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
273
+	public function checkConstraintParametersOnPropertyId(NumericPropertyId $propertyId): array {
274
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
275 275
 		$result = [];
276 276
 
277
-		foreach ( $constraints as $constraint ) {
278
-			$problems = $this->checkCommonConstraintParameters( $constraint );
277
+		foreach ($constraints as $constraint) {
278
+			$problems = $this->checkCommonConstraintParameters($constraint);
279 279
 
280
-			if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
280
+			if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
281 281
 				$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
282
-				$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
282
+				$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
283 283
 			}
284 284
 
285 285
 			$result[$constraint->getConstraintId()] = $problems;
@@ -296,18 +296,18 @@  discard block
 block discarded – undo
296 296
 	 * @return ConstraintParameterException[]|null list of constraint parameter exceptions
297 297
 	 * (empty means all parameters okay), or null if constraint is not found
298 298
 	 */
299
-	public function checkConstraintParametersOnConstraintId( string $constraintId ): ?array {
300
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
299
+	public function checkConstraintParametersOnConstraintId(string $constraintId): ?array {
300
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
301 301
 		'@phan-var NumericPropertyId $propertyId';
302
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
302
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
303 303
 
304
-		foreach ( $constraints as $constraint ) {
305
-			if ( $constraint->getConstraintId() === $constraintId ) {
306
-				$problems = $this->checkCommonConstraintParameters( $constraint );
304
+		foreach ($constraints as $constraint) {
305
+			if ($constraint->getConstraintId() === $constraintId) {
306
+				$problems = $this->checkCommonConstraintParameters($constraint);
307 307
 
308
-				if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
308
+				if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
309 309
 					$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
310
-					$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
310
+					$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
311 311
 				}
312 312
 
313 313
 				return $problems;
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 		$result = [];
333 333
 
334 334
 		/** @var Statement $statement */
335
-		foreach ( $entity->getStatements() as $statement ) {
336
-			$result = array_merge( $result,
335
+		foreach ($entity->getStatements() as $statement) {
336
+			$result = array_merge($result,
337 337
 				$this->checkStatement(
338 338
 					$entity,
339 339
 					$statement,
340 340
 					$constraintIds,
341 341
 					$defaultResultsPerContext
342
-				) );
342
+				));
343 343
 		}
344 344
 
345 345
 		return $result;
@@ -361,32 +361,32 @@  discard block
 block discarded – undo
361 361
 	): array {
362 362
 		$result = [];
363 363
 
364
-		$result = array_merge( $result,
364
+		$result = array_merge($result,
365 365
 			$this->checkConstraintsForMainSnak(
366 366
 				$entity,
367 367
 				$statement,
368 368
 				$constraintIds,
369 369
 				$defaultResultsPerContext
370
-			) );
370
+			));
371 371
 
372
-		if ( $this->checkQualifiers ) {
373
-			$result = array_merge( $result,
372
+		if ($this->checkQualifiers) {
373
+			$result = array_merge($result,
374 374
 				$this->checkConstraintsForQualifiers(
375 375
 					$entity,
376 376
 					$statement,
377 377
 					$constraintIds,
378 378
 					$defaultResultsPerContext
379
-				) );
379
+				));
380 380
 		}
381 381
 
382
-		if ( $this->checkReferences ) {
383
-			$result = array_merge( $result,
382
+		if ($this->checkReferences) {
383
+			$result = array_merge($result,
384 384
 				$this->checkConstraintsForReferences(
385 385
 					$entity,
386 386
 					$statement,
387 387
 					$constraintIds,
388 388
 					$defaultResultsPerContext
389
-				) );
389
+				));
390 390
 		}
391 391
 
392 392
 		return $result;
@@ -401,17 +401,17 @@  discard block
 block discarded – undo
401 401
 	 * @param string[]|null $constraintIds
402 402
 	 * @return Constraint[]
403 403
 	 */
404
-	private function getConstraintsToUse( PropertyId $propertyId, ?array $constraintIds ): array {
405
-		if ( !( $propertyId instanceof NumericPropertyId ) ) {
404
+	private function getConstraintsToUse(PropertyId $propertyId, ?array $constraintIds): array {
405
+		if (!($propertyId instanceof NumericPropertyId)) {
406 406
 			throw new InvalidArgumentException(
407
-				'Non-numeric property ID not supported:' . $propertyId->getSerialization()
407
+				'Non-numeric property ID not supported:'.$propertyId->getSerialization()
408 408
 			);
409 409
 		}
410
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
411
-		if ( $constraintIds !== null ) {
410
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
411
+		if ($constraintIds !== null) {
412 412
 			$constraintsToUse = [];
413
-			foreach ( $constraints as $constraint ) {
414
-				if ( in_array( $constraint->getConstraintId(), $constraintIds ) ) {
413
+			foreach ($constraints as $constraint) {
414
+				if (in_array($constraint->getConstraintId(), $constraintIds)) {
415 415
 					$constraintsToUse[] = $constraint;
416 416
 				}
417 417
 			}
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
 		?array $constraintIds,
436 436
 		?callable $defaultResults
437 437
 	): array {
438
-		$context = new MainSnakContext( $entity, $statement );
438
+		$context = new MainSnakContext($entity, $statement);
439 439
 		$constraints = $this->getConstraintsToUse(
440 440
 			$statement->getPropertyId(),
441 441
 			$constraintIds
442 442
 		);
443
-		$result = $defaultResults !== null ? $defaultResults( $context ) : [];
443
+		$result = $defaultResults !== null ? $defaultResults($context) : [];
444 444
 
445
-		foreach ( $constraints as $constraint ) {
445
+		foreach ($constraints as $constraint) {
446 446
 			$parameters = $constraint->getConstraintParameters();
447 447
 			try {
448
-				$exceptions = $this->constraintParameterParser->parseExceptionParameter( $parameters );
449
-			} catch ( ConstraintParameterException $e ) {
448
+				$exceptions = $this->constraintParameterParser->parseExceptionParameter($parameters);
449
+			} catch (ConstraintParameterException $e) {
450 450
 				$result[] = new CheckResult(
451 451
 					$context,
452 452
 					$constraint,
@@ -456,13 +456,13 @@  discard block
 block discarded – undo
456 456
 				continue;
457 457
 			}
458 458
 
459
-			if ( in_array( $entity->getId(), $exceptions ) ) {
460
-				$message = new ViolationMessage( 'wbqc-violation-message-exception' );
461
-				$result[] = new CheckResult( $context, $constraint, CheckResult::STATUS_EXCEPTION, $message );
459
+			if (in_array($entity->getId(), $exceptions)) {
460
+				$message = new ViolationMessage('wbqc-violation-message-exception');
461
+				$result[] = new CheckResult($context, $constraint, CheckResult::STATUS_EXCEPTION, $message);
462 462
 				continue;
463 463
 			}
464 464
 
465
-			$result[] = $this->getCheckResultFor( $context, $constraint );
465
+			$result[] = $this->getCheckResultFor($context, $constraint);
466 466
 		}
467 467
 
468 468
 		return $result;
@@ -484,24 +484,24 @@  discard block
 block discarded – undo
484 484
 	): array {
485 485
 		$result = [];
486 486
 
487
-		if ( in_array(
487
+		if (in_array(
488 488
 			$statement->getPropertyId()->getSerialization(),
489 489
 			$this->propertiesWithViolatingQualifiers
490
-		) ) {
490
+		)) {
491 491
 			return $result;
492 492
 		}
493 493
 
494
-		foreach ( $statement->getQualifiers() as $qualifier ) {
495
-			$qualifierContext = new QualifierContext( $entity, $statement, $qualifier );
496
-			if ( $defaultResultsPerContext !== null ) {
497
-				$result = array_merge( $result, $defaultResultsPerContext( $qualifierContext ) );
494
+		foreach ($statement->getQualifiers() as $qualifier) {
495
+			$qualifierContext = new QualifierContext($entity, $statement, $qualifier);
496
+			if ($defaultResultsPerContext !== null) {
497
+				$result = array_merge($result, $defaultResultsPerContext($qualifierContext));
498 498
 			}
499 499
 			$qualifierConstraints = $this->getConstraintsToUse(
500 500
 				$qualifierContext->getSnak()->getPropertyId(),
501 501
 				$constraintIds
502 502
 			);
503
-			foreach ( $qualifierConstraints as $qualifierConstraint ) {
504
-				$result[] = $this->getCheckResultFor( $qualifierContext, $qualifierConstraint );
503
+			foreach ($qualifierConstraints as $qualifierConstraint) {
504
+				$result[] = $this->getCheckResultFor($qualifierContext, $qualifierConstraint);
505 505
 			}
506 506
 		}
507 507
 
@@ -525,19 +525,19 @@  discard block
 block discarded – undo
525 525
 		$result = [];
526 526
 
527 527
 		/** @var Reference $reference */
528
-		foreach ( $statement->getReferences() as $reference ) {
529
-			foreach ( $reference->getSnaks() as $snak ) {
528
+		foreach ($statement->getReferences() as $reference) {
529
+			foreach ($reference->getSnaks() as $snak) {
530 530
 				$referenceContext = new ReferenceContext(
531 531
 					$entity, $statement, $reference, $snak
532 532
 				);
533
-				if ( $defaultResultsPerContext !== null ) {
534
-					$result = array_merge( $result, $defaultResultsPerContext( $referenceContext ) );
533
+				if ($defaultResultsPerContext !== null) {
534
+					$result = array_merge($result, $defaultResultsPerContext($referenceContext));
535 535
 				}
536 536
 				$referenceConstraints = $this->getConstraintsToUse(
537 537
 					$referenceContext->getSnak()->getPropertyId(),
538 538
 					$constraintIds
539 539
 				);
540
-				foreach ( $referenceConstraints as $referenceConstraint ) {
540
+				foreach ($referenceConstraints as $referenceConstraint) {
541 541
 					$result[] = $this->getCheckResultFor(
542 542
 						$referenceContext,
543 543
 						$referenceConstraint
@@ -549,50 +549,50 @@  discard block
 block discarded – undo
549 549
 		return $result;
550 550
 	}
551 551
 
552
-	private function getCheckResultFor( Context $context, Constraint $constraint ): CheckResult {
553
-		if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
552
+	private function getCheckResultFor(Context $context, Constraint $constraint): CheckResult {
553
+		if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
554 554
 			$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
555
-			$result = $this->handleScope( $checker, $context, $constraint );
555
+			$result = $this->handleScope($checker, $context, $constraint);
556 556
 
557
-			if ( $result !== null ) {
558
-				$this->addMetadata( $context, $result );
557
+			if ($result !== null) {
558
+				$this->addMetadata($context, $result);
559 559
 				return $result;
560 560
 			}
561 561
 
562
-			$startTime = microtime( true );
562
+			$startTime = microtime(true);
563 563
 			try {
564
-				$result = $checker->checkConstraint( $context, $constraint );
565
-			} catch ( ConstraintParameterException $e ) {
564
+				$result = $checker->checkConstraint($context, $constraint);
565
+			} catch (ConstraintParameterException $e) {
566 566
 				$result = new CheckResult(
567 567
 					$context,
568 568
 					$constraint,
569 569
 					CheckResult::STATUS_BAD_PARAMETERS,
570 570
 					$e->getViolationMessage()
571 571
 				);
572
-			} catch ( SparqlHelperException $e ) {
573
-				$message = new ViolationMessage( 'wbqc-violation-message-sparql-error' );
574
-				$result = new CheckResult( $context, $constraint, CheckResult::STATUS_TODO, $message );
572
+			} catch (SparqlHelperException $e) {
573
+				$message = new ViolationMessage('wbqc-violation-message-sparql-error');
574
+				$result = new CheckResult($context, $constraint, CheckResult::STATUS_TODO, $message);
575 575
 			}
576
-			$endTime = microtime( true );
576
+			$endTime = microtime(true);
577 577
 
578
-			$this->addMetadata( $context, $result );
578
+			$this->addMetadata($context, $result);
579 579
 
580
-			$this->addConstraintClarification( $result );
580
+			$this->addConstraintClarification($result);
581 581
 
582
-			$this->downgradeResultStatus( $result );
582
+			$this->downgradeResultStatus($result);
583 583
 
584 584
 			$this->loggingHelper->logConstraintCheck(
585 585
 				$context,
586 586
 				$constraint,
587 587
 				$result,
588
-				get_class( $checker ),
588
+				get_class($checker),
589 589
 				$endTime - $startTime,
590 590
 				__METHOD__
591 591
 			);
592 592
 
593 593
 			return $result;
594 594
 		} else {
595
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_TODO, null );
595
+			return new CheckResult($context, $constraint, CheckResult::STATUS_TODO, null);
596 596
 		}
597 597
 	}
598 598
 
@@ -601,87 +601,87 @@  discard block
 block discarded – undo
601 601
 		Context $context,
602 602
 		Constraint $constraint
603 603
 	): ?CheckResult {
604
-		$validContextTypes = $this->getValidContextTypes( $constraint );
605
-		$validEntityTypes = $this->getValidEntityTypes( $constraint );
604
+		$validContextTypes = $this->getValidContextTypes($constraint);
605
+		$validEntityTypes = $this->getValidEntityTypes($constraint);
606 606
 		try {
607
-			[ $checkedContextTypes, $checkedEntityTypes ] = $this->constraintParameterParser->parseConstraintScopeParameters(
607
+			[$checkedContextTypes, $checkedEntityTypes] = $this->constraintParameterParser->parseConstraintScopeParameters(
608 608
 				$constraint->getConstraintParameters(),
609 609
 				$constraint->getConstraintTypeItemId(),
610 610
 				$validContextTypes,
611 611
 				$validEntityTypes
612 612
 			);
613
-		} catch ( ConstraintParameterException $e ) {
614
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
613
+		} catch (ConstraintParameterException $e) {
614
+			return new CheckResult($context, $constraint, CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
615 615
 		}
616 616
 
617 617
 		$checkedContextTypes ??= $checker->getDefaultContextTypes();
618 618
 		$contextType = $context->getType();
619
-		if ( !in_array( $contextType, $checkedContextTypes ) ) {
620
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE, null );
619
+		if (!in_array($contextType, $checkedContextTypes)) {
620
+			return new CheckResult($context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE, null);
621 621
 		}
622
-		if ( $checker->getSupportedContextTypes()[$contextType] === CheckResult::STATUS_TODO ) {
623
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_TODO, null );
622
+		if ($checker->getSupportedContextTypes()[$contextType] === CheckResult::STATUS_TODO) {
623
+			return new CheckResult($context, $constraint, CheckResult::STATUS_TODO, null);
624 624
 		}
625 625
 
626 626
 		$checkedEntityTypes ??= $validEntityTypes;
627 627
 		$entityType = $context->getEntity()->getType();
628
-		if ( !in_array( $entityType, $checkedEntityTypes ) ) {
629
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE, null );
628
+		if (!in_array($entityType, $checkedEntityTypes)) {
629
+			return new CheckResult($context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE, null);
630 630
 		}
631
-		if ( $checker->getSupportedEntityTypes()[$entityType] === CheckResult::STATUS_TODO ) {
632
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_TODO, null );
631
+		if ($checker->getSupportedEntityTypes()[$entityType] === CheckResult::STATUS_TODO) {
632
+			return new CheckResult($context, $constraint, CheckResult::STATUS_TODO, null);
633 633
 		}
634 634
 
635 635
 		return null;
636 636
 	}
637 637
 
638
-	private function addMetadata( Context $context, CheckResult $result ): void {
639
-		$result->withMetadata( Metadata::merge( [
638
+	private function addMetadata(Context $context, CheckResult $result): void {
639
+		$result->withMetadata(Metadata::merge([
640 640
 			$result->getMetadata(),
641
-			Metadata::ofDependencyMetadata( DependencyMetadata::merge( [
642
-				DependencyMetadata::ofEntityId( $context->getEntity()->getId() ),
643
-				DependencyMetadata::ofEntityId( $result->getConstraint()->getPropertyId() ),
644
-			] ) ),
645
-		] ) );
641
+			Metadata::ofDependencyMetadata(DependencyMetadata::merge([
642
+				DependencyMetadata::ofEntityId($context->getEntity()->getId()),
643
+				DependencyMetadata::ofEntityId($result->getConstraint()->getPropertyId()),
644
+			])),
645
+		]));
646 646
 	}
647 647
 
648
-	private function addConstraintClarification( CheckResult $result ): void {
648
+	private function addConstraintClarification(CheckResult $result): void {
649 649
 		$constraint = $result->getConstraint();
650 650
 		try {
651 651
 			$constraintClarification = $this->constraintParameterParser
652
-				->parseConstraintClarificationParameter( $constraint->getConstraintParameters() );
653
-			$result->setConstraintClarification( $constraintClarification );
654
-		} catch ( ConstraintParameterException $e ) {
655
-			$result->setStatus( CheckResult::STATUS_BAD_PARAMETERS );
656
-			$result->setMessage( $e->getViolationMessage() );
652
+				->parseConstraintClarificationParameter($constraint->getConstraintParameters());
653
+			$result->setConstraintClarification($constraintClarification);
654
+		} catch (ConstraintParameterException $e) {
655
+			$result->setStatus(CheckResult::STATUS_BAD_PARAMETERS);
656
+			$result->setMessage($e->getViolationMessage());
657 657
 		}
658 658
 	}
659 659
 
660
-	private function downgradeResultStatus( CheckResult $result ): void {
660
+	private function downgradeResultStatus(CheckResult $result): void {
661 661
 		$constraint = $result->getConstraint();
662 662
 		try {
663 663
 			$constraintStatus = $this->constraintParameterParser
664
-				->parseConstraintStatusParameter( $constraint->getConstraintParameters() );
665
-		} catch ( ConstraintParameterException $e ) {
666
-			$result->setStatus( CheckResult::STATUS_BAD_PARAMETERS );
667
-			$result->setMessage( $e->getViolationMessage() );
664
+				->parseConstraintStatusParameter($constraint->getConstraintParameters());
665
+		} catch (ConstraintParameterException $e) {
666
+			$result->setStatus(CheckResult::STATUS_BAD_PARAMETERS);
667
+			$result->setMessage($e->getViolationMessage());
668 668
 			return;
669 669
 		}
670
-		if ( $constraintStatus === null ) {
670
+		if ($constraintStatus === null) {
671 671
 			// downgrade violation to warning
672
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
673
-				$result->setStatus( CheckResult::STATUS_WARNING );
672
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
673
+				$result->setStatus(CheckResult::STATUS_WARNING);
674 674
 			}
675
-		} elseif ( $constraintStatus === 'suggestion' ) {
675
+		} elseif ($constraintStatus === 'suggestion') {
676 676
 			// downgrade violation to suggestion
677
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
678
-				$result->setStatus( CheckResult::STATUS_SUGGESTION );
677
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
678
+				$result->setStatus(CheckResult::STATUS_SUGGESTION);
679 679
 			}
680 680
 		} else {
681
-			if ( $constraintStatus !== 'mandatory' ) {
681
+			if ($constraintStatus !== 'mandatory') {
682 682
 				// @codeCoverageIgnoreStart
683 683
 				throw new LogicException(
684
-					"Unknown constraint status '$constraintStatus', " .
684
+					"Unknown constraint status '$constraintStatus', ".
685 685
 					"only known statuses are 'mandatory' and 'suggestion'"
686 686
 				);
687 687
 				// @codeCoverageIgnoreEnd
@@ -694,12 +694,12 @@  discard block
 block discarded – undo
694 694
 	 *
695 695
 	 * @return CheckResult[]
696 696
 	 */
697
-	private function sortResult( array $result ): array {
698
-		if ( count( $result ) < 2 ) {
697
+	private function sortResult(array $result): array {
698
+		if (count($result) < 2) {
699 699
 			return $result;
700 700
 		}
701 701
 
702
-		$sortFunction = static function ( CheckResult $a, CheckResult $b ) {
702
+		$sortFunction = static function(CheckResult $a, CheckResult $b) {
703 703
 			$orderNum = 0;
704 704
 			$order = [
705 705
 				CheckResult::STATUS_BAD_PARAMETERS => $orderNum++,
@@ -716,55 +716,55 @@  discard block
 block discarded – undo
716 716
 			$statusA = $a->getStatus();
717 717
 			$statusB = $b->getStatus();
718 718
 
719
-			$orderA = array_key_exists( $statusA, $order ) ? $order[ $statusA ] : $order[ 'other' ];
720
-			$orderB = array_key_exists( $statusB, $order ) ? $order[ $statusB ] : $order[ 'other' ];
719
+			$orderA = array_key_exists($statusA, $order) ? $order[$statusA] : $order['other'];
720
+			$orderB = array_key_exists($statusB, $order) ? $order[$statusB] : $order['other'];
721 721
 
722
-			if ( $orderA === $orderB ) {
722
+			if ($orderA === $orderB) {
723 723
 				$cursorA = $a->getContextCursor();
724 724
 				$cursorB = $b->getContextCursor();
725 725
 
726
-				if ( $cursorA instanceof EntityContextCursor ) {
726
+				if ($cursorA instanceof EntityContextCursor) {
727 727
 					return $cursorB instanceof EntityContextCursor ? 0 : -1;
728 728
 				}
729
-				if ( $cursorB instanceof EntityContextCursor ) {
729
+				if ($cursorB instanceof EntityContextCursor) {
730 730
 					return $cursorA instanceof EntityContextCursor ? 0 : 1;
731 731
 				}
732 732
 
733 733
 				$pidA = $cursorA->getSnakPropertyId();
734 734
 				$pidB = $cursorB->getSnakPropertyId();
735 735
 
736
-				if ( $pidA === $pidB ) {
736
+				if ($pidA === $pidB) {
737 737
 					$hashA = $cursorA->getSnakHash();
738 738
 					$hashB = $cursorB->getSnakHash();
739 739
 
740
-					if ( $hashA === $hashB ) {
741
-						if ( $a instanceof NullResult ) {
740
+					if ($hashA === $hashB) {
741
+						if ($a instanceof NullResult) {
742 742
 							return $b instanceof NullResult ? 0 : -1;
743 743
 						}
744
-						if ( $b instanceof NullResult ) {
744
+						if ($b instanceof NullResult) {
745 745
 							return $a instanceof NullResult ? 0 : 1;
746 746
 						}
747 747
 
748 748
 						$typeA = $a->getConstraint()->getConstraintTypeItemId();
749 749
 						$typeB = $b->getConstraint()->getConstraintTypeItemId();
750 750
 
751
-						if ( $typeA == $typeB ) {
751
+						if ($typeA == $typeB) {
752 752
 							return 0;
753 753
 						} else {
754
-							return ( $typeA > $typeB ) ? 1 : -1;
754
+							return ($typeA > $typeB) ? 1 : -1;
755 755
 						}
756 756
 					} else {
757
-						return ( $hashA > $hashB ) ? 1 : -1;
757
+						return ($hashA > $hashB) ? 1 : -1;
758 758
 					}
759 759
 				} else {
760
-					return ( $pidA > $pidB ) ? 1 : -1;
760
+					return ($pidA > $pidB) ? 1 : -1;
761 761
 				}
762 762
 			} else {
763
-				return ( $orderA > $orderB ) ? 1 : -1;
763
+				return ($orderA > $orderB) ? 1 : -1;
764 764
 			}
765 765
 		};
766 766
 
767
-		uasort( $result, $sortFunction );
767
+		uasort($result, $sortFunction);
768 768
 
769 769
 		return $result;
770 770
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Helper;
6 6
 
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
 	 * Check if any errors are recorded in the constraint parameters.
69 69
 	 * @throws ConstraintParameterException
70 70
 	 */
71
-	public function checkError( array $parameters ): void {
72
-		if ( array_key_exists( '@error', $parameters ) ) {
71
+	public function checkError(array $parameters): void {
72
+		if (array_key_exists('@error', $parameters)) {
73 73
 			$error = $parameters['@error'];
74
-			if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) {
74
+			if (array_key_exists('toolong', $error) && $error['toolong']) {
75 75
 				$msg = 'wbqc-violation-message-parameters-error-toolong';
76 76
 			} else {
77 77
 				$msg = 'wbqc-violation-message-parameters-error-unknown';
78 78
 			}
79
-			throw new ConstraintParameterException( new ViolationMessage( $msg ) );
79
+			throw new ConstraintParameterException(new ViolationMessage($msg));
80 80
 		}
81 81
 	}
82 82
 
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 	 * Require that $parameters contains exactly one $parameterId parameter.
85 85
 	 * @throws ConstraintParameterException
86 86
 	 */
87
-	private function requireSingleParameter( array $parameters, string $parameterId ): void {
88
-		if ( count( $parameters[$parameterId] ) !== 1 ) {
87
+	private function requireSingleParameter(array $parameters, string $parameterId): void {
88
+		if (count($parameters[$parameterId]) !== 1) {
89 89
 			throw new ConstraintParameterException(
90
-				( new ViolationMessage( 'wbqc-violation-message-parameter-single' ) )
91
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
90
+				(new ViolationMessage('wbqc-violation-message-parameter-single'))
91
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
92 92
 			);
93 93
 		}
94 94
 	}
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	 * Require that $snak is a {@link PropertyValueSnak}.
98 98
 	 * @throws ConstraintParameterException
99 99
 	 */
100
-	private function requireValueParameter( Snak $snak, string $parameterId ): void {
101
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
100
+	private function requireValueParameter(Snak $snak, string $parameterId): void {
101
+		if (!($snak instanceof PropertyValueSnak)) {
102 102
 			throw new ConstraintParameterException(
103
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
104
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
103
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
104
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
105 105
 			);
106 106
 		}
107 107
 	}
@@ -110,17 +110,17 @@  discard block
 block discarded – undo
110 110
 	 * Parse a single entity ID parameter.
111 111
 	 * @throws ConstraintParameterException
112 112
 	 */
113
-	private function parseEntityIdParameter( array $snakSerialization, string $parameterId ): EntityId {
114
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
115
-		$this->requireValueParameter( $snak, $parameterId );
113
+	private function parseEntityIdParameter(array $snakSerialization, string $parameterId): EntityId {
114
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
115
+		$this->requireValueParameter($snak, $parameterId);
116 116
 		$value = $snak->getDataValue();
117
-		if ( $value instanceof EntityIdValue ) {
117
+		if ($value instanceof EntityIdValue) {
118 118
 			return $value->getEntityId();
119 119
 		} else {
120 120
 			throw new ConstraintParameterException(
121
-				( new ViolationMessage( 'wbqc-violation-message-parameter-entity' ) )
122
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
123
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
121
+				(new ViolationMessage('wbqc-violation-message-parameter-entity'))
122
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
123
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
124 124
 			);
125 125
 		}
126 126
 	}
@@ -131,20 +131,20 @@  discard block
 block discarded – undo
131 131
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
132 132
 	 * @return string[] class entity ID serializations
133 133
 	 */
134
-	public function parseClassParameter( array $constraintParameters, string $constraintTypeItemId ): array {
135
-		$this->checkError( $constraintParameters );
136
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
137
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
134
+	public function parseClassParameter(array $constraintParameters, string $constraintTypeItemId): array {
135
+		$this->checkError($constraintParameters);
136
+		$classId = $this->config->get('WBQualityConstraintsClassId');
137
+		if (!array_key_exists($classId, $constraintParameters)) {
138 138
 			throw new ConstraintParameterException(
139
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
140
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
141
-					->withEntityId( new NumericPropertyId( $classId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
139
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
140
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
141
+					->withEntityId(new NumericPropertyId($classId), Role::CONSTRAINT_PARAMETER_PROPERTY)
142 142
 			);
143 143
 		}
144 144
 
145 145
 		$classes = [];
146
-		foreach ( $constraintParameters[$classId] as $class ) {
147
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
146
+		foreach ($constraintParameters[$classId] as $class) {
147
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
148 148
 		}
149 149
 		return $classes;
150 150
 	}
@@ -155,31 +155,31 @@  discard block
 block discarded – undo
155 155
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
156 156
 	 * @return string 'instance', 'subclass', or 'instanceOrSubclass'
157 157
 	 */
158
-	public function parseRelationParameter( array $constraintParameters, string $constraintTypeItemId ): string {
159
-		$this->checkError( $constraintParameters );
160
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
161
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
158
+	public function parseRelationParameter(array $constraintParameters, string $constraintTypeItemId): string {
159
+		$this->checkError($constraintParameters);
160
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
161
+		if (!array_key_exists($relationId, $constraintParameters)) {
162 162
 			throw new ConstraintParameterException(
163
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
164
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
165
-					->withEntityId( new NumericPropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
163
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
164
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
165
+					->withEntityId(new NumericPropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
166 166
 			);
167 167
 		}
168 168
 
169
-		$this->requireSingleParameter( $constraintParameters, $relationId );
170
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
171
-		if ( !( $relationEntityId instanceof ItemId ) ) {
169
+		$this->requireSingleParameter($constraintParameters, $relationId);
170
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
171
+		if (!($relationEntityId instanceof ItemId)) {
172 172
 			throw new ConstraintParameterException(
173
-				( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
174
-					->withEntityId( new NumericPropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
175
-					->withDataValue( new EntityIdValue( $relationEntityId ), Role::CONSTRAINT_PARAMETER_VALUE )
173
+				(new ViolationMessage('wbqc-violation-message-parameter-item'))
174
+					->withEntityId(new NumericPropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
175
+					->withDataValue(new EntityIdValue($relationEntityId), Role::CONSTRAINT_PARAMETER_VALUE)
176 176
 			);
177 177
 		}
178
-		return $this->mapItemId( $relationEntityId, [
179
-			$this->config->get( 'WBQualityConstraintsInstanceOfRelationId' ) => 'instance',
180
-			$this->config->get( 'WBQualityConstraintsSubclassOfRelationId' ) => 'subclass',
181
-			$this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' ) => 'instanceOrSubclass',
182
-		], $relationId );
178
+		return $this->mapItemId($relationEntityId, [
179
+			$this->config->get('WBQualityConstraintsInstanceOfRelationId') => 'instance',
180
+			$this->config->get('WBQualityConstraintsSubclassOfRelationId') => 'subclass',
181
+			$this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId') => 'instanceOrSubclass',
182
+		], $relationId);
183 183
 	}
184 184
 
185 185
 	/**
@@ -189,20 +189,20 @@  discard block
 block discarded – undo
189 189
 	 * @throws ConstraintParameterException
190 190
 	 * @return PropertyId
191 191
 	 */
192
-	private function parsePropertyIdParameter( array $snakSerialization, string $parameterId ): PropertyId {
193
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
194
-		$this->requireValueParameter( $snak, $parameterId );
192
+	private function parsePropertyIdParameter(array $snakSerialization, string $parameterId): PropertyId {
193
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
194
+		$this->requireValueParameter($snak, $parameterId);
195 195
 		$value = $snak->getDataValue();
196
-		if ( $value instanceof EntityIdValue ) {
196
+		if ($value instanceof EntityIdValue) {
197 197
 			$id = $value->getEntityId();
198
-			if ( $id instanceof PropertyId ) {
198
+			if ($id instanceof PropertyId) {
199 199
 				return $id;
200 200
 			}
201 201
 		}
202 202
 		throw new ConstraintParameterException(
203
-			( new ViolationMessage( 'wbqc-violation-message-parameter-property' ) )
204
-				->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
205
-				->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
203
+			(new ViolationMessage('wbqc-violation-message-parameter-property'))
204
+				->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
205
+				->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
206 206
 		);
207 207
 	}
208 208
 
@@ -213,33 +213,33 @@  discard block
 block discarded – undo
213 213
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
214 214
 	 * @return PropertyId
215 215
 	 */
216
-	public function parsePropertyParameter( array $constraintParameters, string $constraintTypeItemId ): PropertyId {
217
-		$this->checkError( $constraintParameters );
218
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
219
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
216
+	public function parsePropertyParameter(array $constraintParameters, string $constraintTypeItemId): PropertyId {
217
+		$this->checkError($constraintParameters);
218
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
219
+		if (!array_key_exists($propertyId, $constraintParameters)) {
220 220
 			throw new ConstraintParameterException(
221
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
222
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
223
-					->withEntityId( new NumericPropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
221
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
222
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
223
+					->withEntityId(new NumericPropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
224 224
 			);
225 225
 		}
226 226
 
227
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
228
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
227
+		$this->requireSingleParameter($constraintParameters, $propertyId);
228
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
229 229
 	}
230 230
 
231
-	private function parseItemIdParameter( PropertyValueSnak $snak, string $parameterId ): ItemIdSnakValue {
231
+	private function parseItemIdParameter(PropertyValueSnak $snak, string $parameterId): ItemIdSnakValue {
232 232
 		$dataValue = $snak->getDataValue();
233
-		if ( $dataValue instanceof EntityIdValue ) {
233
+		if ($dataValue instanceof EntityIdValue) {
234 234
 			$entityId = $dataValue->getEntityId();
235
-			if ( $entityId instanceof ItemId ) {
236
-				return ItemIdSnakValue::fromItemId( $entityId );
235
+			if ($entityId instanceof ItemId) {
236
+				return ItemIdSnakValue::fromItemId($entityId);
237 237
 			}
238 238
 		}
239 239
 		throw new ConstraintParameterException(
240
-			( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
241
-				->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
242
-				->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
240
+			(new ViolationMessage('wbqc-violation-message-parameter-item'))
241
+				->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
242
+				->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
243 243
 		);
244 244
 	}
245 245
 
@@ -257,14 +257,14 @@  discard block
 block discarded – undo
257 257
 		bool $required,
258 258
 		?string $parameterId = null
259 259
 	): array {
260
-		$this->checkError( $constraintParameters );
261
-		$parameterId ??= $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
262
-		if ( !array_key_exists( $parameterId, $constraintParameters ) ) {
263
-			if ( $required ) {
260
+		$this->checkError($constraintParameters);
261
+		$parameterId ??= $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
262
+		if (!array_key_exists($parameterId, $constraintParameters)) {
263
+			if ($required) {
264 264
 				throw new ConstraintParameterException(
265
-					( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
266
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
267
-						->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
265
+					(new ViolationMessage('wbqc-violation-message-parameter-needed'))
266
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
267
+						->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
268 268
 				);
269 269
 			} else {
270 270
 				return [];
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 		}
273 273
 
274 274
 		$values = [];
275
-		foreach ( $constraintParameters[$parameterId] as $parameter ) {
276
-			$snak = $this->snakDeserializer->deserialize( $parameter );
277
-			switch ( true ) {
275
+		foreach ($constraintParameters[$parameterId] as $parameter) {
276
+			$snak = $this->snakDeserializer->deserialize($parameter);
277
+			switch (true) {
278 278
 				case $snak instanceof PropertyValueSnak:
279
-					$values[] = $this->parseItemIdParameter( $snak, $parameterId );
279
+					$values[] = $this->parseItemIdParameter($snak, $parameterId);
280 280
 					break;
281 281
 				case $snak instanceof PropertySomeValueSnak:
282 282
 					$values[] = ItemIdSnakValue::someValue();
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
 		bool $required,
305 305
 		string $parameterId
306 306
 	): array {
307
-		return array_map( static function ( ItemIdSnakValue $value ) use ( $parameterId ): ItemId {
308
-			if ( $value->isValue() ) {
307
+		return array_map(static function(ItemIdSnakValue $value) use ($parameterId): ItemId {
308
+			if ($value->isValue()) {
309 309
 				return $value->getItemId();
310 310
 			} else {
311 311
 				throw new ConstraintParameterException(
312
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
313
-						->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
312
+					(new ViolationMessage('wbqc-violation-message-parameter-value'))
313
+						->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
314 314
 				);
315 315
 			}
316 316
 		}, $this->parseItemsParameter(
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 			$constraintTypeItemId,
319 319
 			$required,
320 320
 			$parameterId
321
-		) );
321
+		));
322 322
 	}
323 323
 
324 324
 	/**
@@ -326,18 +326,18 @@  discard block
 block discarded – undo
326 326
 	 * @throws ConstraintParameterException
327 327
 	 * @return mixed elements of $mapping
328 328
 	 */
329
-	private function mapItemId( ItemId $itemId, array $mapping, string $parameterId ) {
329
+	private function mapItemId(ItemId $itemId, array $mapping, string $parameterId) {
330 330
 		$serialization = $itemId->getSerialization();
331
-		if ( array_key_exists( $serialization, $mapping ) ) {
331
+		if (array_key_exists($serialization, $mapping)) {
332 332
 			return $mapping[$serialization];
333 333
 		} else {
334
-			$allowed = array_map( static function ( $id ) {
335
-				return new ItemId( $id );
336
-			}, array_keys( $mapping ) );
334
+			$allowed = array_map(static function($id) {
335
+				return new ItemId($id);
336
+			}, array_keys($mapping));
337 337
 			throw new ConstraintParameterException(
338
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
339
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
340
-					->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
338
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
339
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
340
+					->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
341 341
 			);
342 342
 		}
343 343
 	}
@@ -348,27 +348,27 @@  discard block
 block discarded – undo
348 348
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
349 349
 	 * @return PropertyId[]
350 350
 	 */
351
-	public function parsePropertiesParameter( array $constraintParameters, string $constraintTypeItemId ): array {
352
-		$this->checkError( $constraintParameters );
353
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
354
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
351
+	public function parsePropertiesParameter(array $constraintParameters, string $constraintTypeItemId): array {
352
+		$this->checkError($constraintParameters);
353
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
354
+		if (!array_key_exists($propertyId, $constraintParameters)) {
355 355
 			throw new ConstraintParameterException(
356
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
357
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
358
-					->withEntityId( new NumericPropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
356
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
357
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
358
+					->withEntityId(new NumericPropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
359 359
 			);
360 360
 		}
361 361
 
362 362
 		$parameters = $constraintParameters[$propertyId];
363
-		if ( count( $parameters ) === 1 &&
364
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
363
+		if (count($parameters) === 1 &&
364
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
365 365
 		) {
366 366
 			return [];
367 367
 		}
368 368
 
369 369
 		$properties = [];
370
-		foreach ( $parameters as $parameter ) {
371
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
370
+		foreach ($parameters as $parameter) {
371
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
372 372
 		}
373 373
 		return $properties;
374 374
 	}
@@ -376,24 +376,24 @@  discard block
 block discarded – undo
376 376
 	/**
377 377
 	 * @throws ConstraintParameterException
378 378
 	 */
379
-	private function parseValueOrNoValueParameter( array $snakSerialization, string $parameterId ): ?DataValue {
380
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
381
-		if ( $snak instanceof PropertyValueSnak ) {
379
+	private function parseValueOrNoValueParameter(array $snakSerialization, string $parameterId): ?DataValue {
380
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
381
+		if ($snak instanceof PropertyValueSnak) {
382 382
 			return $snak->getDataValue();
383
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
383
+		} elseif ($snak instanceof PropertyNoValueSnak) {
384 384
 			return null;
385 385
 		} else {
386 386
 			throw new ConstraintParameterException(
387
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
388
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
387
+				(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
388
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
389 389
 			);
390 390
 		}
391 391
 	}
392 392
 
393
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, string $parameterId ): ?DataValue {
393
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, string $parameterId): ?DataValue {
394 394
 		try {
395
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
396
-		} catch ( ConstraintParameterException $e ) {
395
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
396
+		} catch (ConstraintParameterException $e) {
397 397
 			// unknown value means “now”
398 398
 			return new NowValue();
399 399
 		}
@@ -402,14 +402,14 @@  discard block
 block discarded – undo
402 402
 	/**
403 403
 	 * Checks whether there is exactly one non-null quantity with the given unit.
404 404
 	 */
405
-	private function exactlyOneQuantityWithUnit( ?DataValue $min, ?DataValue $max, string $unit ): bool {
406
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
407
-			!( $max instanceof UnboundedQuantityValue )
405
+	private function exactlyOneQuantityWithUnit(?DataValue $min, ?DataValue $max, string $unit): bool {
406
+		if (!($min instanceof UnboundedQuantityValue) ||
407
+			!($max instanceof UnboundedQuantityValue)
408 408
 		) {
409 409
 			return false;
410 410
 		}
411 411
 
412
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
412
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
413 413
 	}
414 414
 
415 415
 	/**
@@ -429,42 +429,42 @@  discard block
 block discarded – undo
429 429
 		string $constraintTypeItemId,
430 430
 		string $type
431 431
 	): array {
432
-		$this->checkError( $constraintParameters );
433
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
434
-			!array_key_exists( $maximumId, $constraintParameters )
432
+		$this->checkError($constraintParameters);
433
+		if (!array_key_exists($minimumId, $constraintParameters) ||
434
+			!array_key_exists($maximumId, $constraintParameters)
435 435
 		) {
436 436
 			throw new ConstraintParameterException(
437
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-needed' ) )
438
-					->withDataValueType( $type )
439
-					->withEntityId( new NumericPropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
440
-					->withEntityId( new NumericPropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
441
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
437
+				(new ViolationMessage('wbqc-violation-message-range-parameters-needed'))
438
+					->withDataValueType($type)
439
+					->withEntityId(new NumericPropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
440
+					->withEntityId(new NumericPropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
441
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
442 442
 			);
443 443
 		}
444 444
 
445
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
446
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
445
+		$this->requireSingleParameter($constraintParameters, $minimumId);
446
+		$this->requireSingleParameter($constraintParameters, $maximumId);
447 447
 		$parseFunction = $type === 'time' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
448
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
449
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
448
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
449
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
450 450
 
451
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
452
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
451
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
452
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
453 453
 			throw new ConstraintParameterException(
454
-				new ViolationMessage( 'wbqc-violation-message-range-parameters-one-year' )
454
+				new ViolationMessage('wbqc-violation-message-range-parameters-one-year')
455 455
 			);
456 456
 		}
457
-		if ( ( $min === null && $max === null ) ||
458
-			( $min !== null && $max !== null && $min->equals( $max ) )
457
+		if (($min === null && $max === null) ||
458
+			($min !== null && $max !== null && $min->equals($max))
459 459
 		) {
460 460
 			throw new ConstraintParameterException(
461
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-same' ) )
462
-					->withEntityId( new NumericPropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
463
-					->withEntityId( new NumericPropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
461
+				(new ViolationMessage('wbqc-violation-message-range-parameters-same'))
462
+					->withEntityId(new NumericPropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
463
+					->withEntityId(new NumericPropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
464 464
 			);
465 465
 		}
466 466
 
467
-		return [ $min, $max ];
467
+		return [$min, $max];
468 468
 	}
469 469
 
470 470
 	/**
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
475 475
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
476 476
 	 */
477
-	public function parseQuantityRangeParameter( array $constraintParameters, string $constraintTypeItemId ): array {
477
+	public function parseQuantityRangeParameter(array $constraintParameters, string $constraintTypeItemId): array {
478 478
 		return $this->parseRangeParameter(
479 479
 			$constraintParameters,
480
-			$this->config->get( 'WBQualityConstraintsMinimumQuantityId' ),
481
-			$this->config->get( 'WBQualityConstraintsMaximumQuantityId' ),
480
+			$this->config->get('WBQualityConstraintsMinimumQuantityId'),
481
+			$this->config->get('WBQualityConstraintsMaximumQuantityId'),
482 482
 			$constraintTypeItemId,
483 483
 			'quantity'
484 484
 		);
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
492 492
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
493 493
 	 */
494
-	public function parseTimeRangeParameter( array $constraintParameters, string $constraintTypeItemId ): array {
494
+	public function parseTimeRangeParameter(array $constraintParameters, string $constraintTypeItemId): array {
495 495
 		return $this->parseRangeParameter(
496 496
 			$constraintParameters,
497
-			$this->config->get( 'WBQualityConstraintsMinimumDateId' ),
498
-			$this->config->get( 'WBQualityConstraintsMaximumDateId' ),
497
+			$this->config->get('WBQualityConstraintsMinimumDateId'),
498
+			$this->config->get('WBQualityConstraintsMaximumDateId'),
499 499
 			$constraintTypeItemId,
500 500
 			'time'
501 501
 		);
@@ -508,20 +508,20 @@  discard block
 block discarded – undo
508 508
 	 * @throws ConstraintParameterException
509 509
 	 * @return string[]
510 510
 	 */
511
-	public function parseLanguageParameter( array $constraintParameters, string $constraintTypeItemId ): array {
512
-		$this->checkError( $constraintParameters );
513
-		$languagePropertyId = $this->config->get( 'WBQualityConstraintsLanguagePropertyId' );
514
-		if ( !array_key_exists( $languagePropertyId, $constraintParameters ) ) {
511
+	public function parseLanguageParameter(array $constraintParameters, string $constraintTypeItemId): array {
512
+		$this->checkError($constraintParameters);
513
+		$languagePropertyId = $this->config->get('WBQualityConstraintsLanguagePropertyId');
514
+		if (!array_key_exists($languagePropertyId, $constraintParameters)) {
515 515
 			throw new ConstraintParameterException(
516
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
517
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
518
-					->withEntityId( new NumericPropertyId( $languagePropertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
516
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
517
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
518
+					->withEntityId(new NumericPropertyId($languagePropertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
519 519
 			);
520 520
 		}
521 521
 
522 522
 		$languages = [];
523
-		foreach ( $constraintParameters[$languagePropertyId] as $snak ) {
524
-			$languages[] = $this->parseStringParameter( $snak, $languagePropertyId );
523
+		foreach ($constraintParameters[$languagePropertyId] as $snak) {
524
+			$languages[] = $this->parseStringParameter($snak, $languagePropertyId);
525 525
 		}
526 526
 		return $languages;
527 527
 	}
@@ -530,17 +530,17 @@  discard block
 block discarded – undo
530 530
 	 * Parse a single string parameter.
531 531
 	 * @throws ConstraintParameterException
532 532
 	 */
533
-	private function parseStringParameter( array $snakSerialization, string $parameterId ): string {
534
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
535
-		$this->requireValueParameter( $snak, $parameterId );
533
+	private function parseStringParameter(array $snakSerialization, string $parameterId): string {
534
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
535
+		$this->requireValueParameter($snak, $parameterId);
536 536
 		$value = $snak->getDataValue();
537
-		if ( $value instanceof StringValue ) {
537
+		if ($value instanceof StringValue) {
538 538
 			return $value->getValue();
539 539
 		} else {
540 540
 			throw new ConstraintParameterException(
541
-				( new ViolationMessage( 'wbqc-violation-message-parameter-string' ) )
542
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
543
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
541
+				(new ViolationMessage('wbqc-violation-message-parameter-string'))
542
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
543
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
544 544
 			);
545 545
 		}
546 546
 	}
@@ -551,15 +551,15 @@  discard block
 block discarded – undo
551 551
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
552 552
 	 * @return string
553 553
 	 */
554
-	public function parseNamespaceParameter( array $constraintParameters, string $constraintTypeItemId ): string {
555
-		$this->checkError( $constraintParameters );
556
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
557
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
554
+	public function parseNamespaceParameter(array $constraintParameters, string $constraintTypeItemId): string {
555
+		$this->checkError($constraintParameters);
556
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
557
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
558 558
 			return '';
559 559
 		}
560 560
 
561
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
562
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
561
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
562
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
563 563
 	}
564 564
 
565 565
 	/**
@@ -568,19 +568,19 @@  discard block
 block discarded – undo
568 568
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
569 569
 	 * @return string
570 570
 	 */
571
-	public function parseFormatParameter( array $constraintParameters, string $constraintTypeItemId ): string {
572
-		$this->checkError( $constraintParameters );
573
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
574
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
571
+	public function parseFormatParameter(array $constraintParameters, string $constraintTypeItemId): string {
572
+		$this->checkError($constraintParameters);
573
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
574
+		if (!array_key_exists($formatId, $constraintParameters)) {
575 575
 			throw new ConstraintParameterException(
576
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
577
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
578
-					->withEntityId( new NumericPropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
576
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
577
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
578
+					->withEntityId(new NumericPropertyId($formatId), Role::CONSTRAINT_PARAMETER_PROPERTY)
579 579
 			);
580 580
 		}
581 581
 
582
-		$this->requireSingleParameter( $constraintParameters, $formatId );
583
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
582
+		$this->requireSingleParameter($constraintParameters, $formatId);
583
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
584 584
 	}
585 585
 
586 586
 	/**
@@ -588,16 +588,16 @@  discard block
 block discarded – undo
588 588
 	 * @throws ConstraintParameterException if the parameter is invalid
589 589
 	 * @return EntityId[]
590 590
 	 */
591
-	public function parseExceptionParameter( array $constraintParameters ): array {
592
-		$this->checkError( $constraintParameters );
593
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
594
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
591
+	public function parseExceptionParameter(array $constraintParameters): array {
592
+		$this->checkError($constraintParameters);
593
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
594
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
595 595
 			return [];
596 596
 		}
597 597
 
598 598
 		return array_map(
599
-			function ( $snakSerialization ) use ( $exceptionId ) {
600
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
599
+			function($snakSerialization) use ($exceptionId) {
600
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
601 601
 			},
602 602
 			$constraintParameters[$exceptionId]
603 603
 		);
@@ -608,39 +608,39 @@  discard block
 block discarded – undo
608 608
 	 * @throws ConstraintParameterException if the parameter is invalid
609 609
 	 * @return string|null 'mandatory', 'suggestion' or null
610 610
 	 */
611
-	public function parseConstraintStatusParameter( array $constraintParameters ): ?string {
612
-		$this->checkError( $constraintParameters );
613
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
614
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
611
+	public function parseConstraintStatusParameter(array $constraintParameters): ?string {
612
+		$this->checkError($constraintParameters);
613
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
614
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
615 615
 			return null;
616 616
 		}
617 617
 
618
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
619
-		$supportedStatuses = [ new ItemId( $mandatoryId ) ];
620
-		if ( $this->config->get( 'WBQualityConstraintsEnableSuggestionConstraintStatus' ) ) {
621
-			$suggestionId = $this->config->get( 'WBQualityConstraintsSuggestionConstraintId' );
622
-			$supportedStatuses[] = new ItemId( $suggestionId );
618
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
619
+		$supportedStatuses = [new ItemId($mandatoryId)];
620
+		if ($this->config->get('WBQualityConstraintsEnableSuggestionConstraintStatus')) {
621
+			$suggestionId = $this->config->get('WBQualityConstraintsSuggestionConstraintId');
622
+			$supportedStatuses[] = new ItemId($suggestionId);
623 623
 		} else {
624 624
 			$suggestionId = null;
625 625
 		}
626 626
 
627
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
628
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
629
-		$this->requireValueParameter( $snak, $constraintStatusId );
627
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
628
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
629
+		$this->requireValueParameter($snak, $constraintStatusId);
630 630
 		'@phan-var \Wikibase\DataModel\Snak\PropertyValueSnak $snak';
631 631
 		$dataValue = $snak->getDataValue();
632 632
 		'@phan-var EntityIdValue $dataValue';
633 633
 		$entityId = $dataValue->getEntityId();
634 634
 		$statusId = $entityId->getSerialization();
635 635
 
636
-		if ( $statusId === $mandatoryId ) {
636
+		if ($statusId === $mandatoryId) {
637 637
 			return 'mandatory';
638
-		} elseif ( $statusId === $suggestionId ) {
638
+		} elseif ($statusId === $suggestionId) {
639 639
 			return 'suggestion';
640 640
 		} else {
641 641
 			throw new ConstraintParameterException(
642
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
643
-					->withEntityId( new NumericPropertyId( $constraintStatusId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
642
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
643
+					->withEntityId(new NumericPropertyId($constraintStatusId), Role::CONSTRAINT_PARAMETER_PROPERTY)
644 644
 					->withEntityIdList(
645 645
 						$supportedStatuses,
646 646
 						Role::CONSTRAINT_PARAMETER_VALUE
@@ -653,12 +653,12 @@  discard block
 block discarded – undo
653 653
 	 * Require that $dataValue is a {@link MonolingualTextValue}.
654 654
 	 * @throws ConstraintParameterException
655 655
 	 */
656
-	private function requireMonolingualTextParameter( DataValue $dataValue, string $parameterId ): void {
657
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
656
+	private function requireMonolingualTextParameter(DataValue $dataValue, string $parameterId): void {
657
+		if (!($dataValue instanceof MonolingualTextValue)) {
658 658
 			throw new ConstraintParameterException(
659
-				( new ViolationMessage( 'wbqc-violation-message-parameter-monolingualtext' ) )
660
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
661
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
659
+				(new ViolationMessage('wbqc-violation-message-parameter-monolingualtext'))
660
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
661
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
662 662
 			);
663 663
 		}
664 664
 	}
@@ -668,31 +668,31 @@  discard block
 block discarded – undo
668 668
 	 *
669 669
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
670 670
 	 */
671
-	private function parseMultilingualTextParameter( array $snakSerializations, string $parameterId ): MultilingualTextValue {
671
+	private function parseMultilingualTextParameter(array $snakSerializations, string $parameterId): MultilingualTextValue {
672 672
 		$result = [];
673 673
 
674
-		foreach ( $snakSerializations as $snakSerialization ) {
675
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
676
-			$this->requireValueParameter( $snak, $parameterId );
674
+		foreach ($snakSerializations as $snakSerialization) {
675
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
676
+			$this->requireValueParameter($snak, $parameterId);
677 677
 
678 678
 			$value = $snak->getDataValue();
679
-			$this->requireMonolingualTextParameter( $value, $parameterId );
679
+			$this->requireMonolingualTextParameter($value, $parameterId);
680 680
 			/** @var MonolingualTextValue $value */
681 681
 			'@phan-var MonolingualTextValue $value';
682 682
 
683 683
 			$code = $value->getLanguageCode();
684
-			if ( array_key_exists( $code, $result ) ) {
684
+			if (array_key_exists($code, $result)) {
685 685
 				throw new ConstraintParameterException(
686
-					( new ViolationMessage( 'wbqc-violation-message-parameter-single-per-language' ) )
687
-						->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
688
-						->withLanguage( $code )
686
+					(new ViolationMessage('wbqc-violation-message-parameter-single-per-language'))
687
+						->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
688
+						->withLanguage($code)
689 689
 				);
690 690
 			}
691 691
 
692 692
 			$result[$code] = $value;
693 693
 		}
694 694
 
695
-		return new MultilingualTextValue( $result );
695
+		return new MultilingualTextValue($result);
696 696
 	}
697 697
 
698 698
 	/**
@@ -700,11 +700,11 @@  discard block
 block discarded – undo
700 700
 	 * @throws ConstraintParameterException if the parameter is invalid
701 701
 	 * @return MultilingualTextValue
702 702
 	 */
703
-	public function parseSyntaxClarificationParameter( array $constraintParameters ): MultilingualTextValue {
704
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
703
+	public function parseSyntaxClarificationParameter(array $constraintParameters): MultilingualTextValue {
704
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
705 705
 
706
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
707
-			return new MultilingualTextValue( [] );
706
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
707
+			return new MultilingualTextValue([]);
708 708
 		}
709 709
 
710 710
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
@@ -720,11 +720,11 @@  discard block
 block discarded – undo
720 720
 	 * @throws ConstraintParameterException if the parameter is invalid
721 721
 	 * @return MultilingualTextValue
722 722
 	 */
723
-	public function parseConstraintClarificationParameter( array $constraintParameters ): MultilingualTextValue {
724
-		$constraintClarificationId = $this->config->get( 'WBQualityConstraintsConstraintClarificationId' );
723
+	public function parseConstraintClarificationParameter(array $constraintParameters): MultilingualTextValue {
724
+		$constraintClarificationId = $this->config->get('WBQualityConstraintsConstraintClarificationId');
725 725
 
726
-		if ( !array_key_exists( $constraintClarificationId, $constraintParameters ) ) {
727
-			return new MultilingualTextValue( [] );
726
+		if (!array_key_exists($constraintClarificationId, $constraintParameters)) {
727
+			return new MultilingualTextValue([]);
728 728
 		}
729 729
 
730 730
 		$constraintClarifications = $this->parseMultilingualTextParameter(
@@ -757,14 +757,14 @@  discard block
 block discarded – undo
757 757
 		array $validContextTypes,
758 758
 		array $validEntityTypes
759 759
 	): array {
760
-		$contextTypeParameterId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
760
+		$contextTypeParameterId = $this->config->get('WBQualityConstraintsConstraintScopeId');
761 761
 		$contextTypeItemIds = $this->parseItemIdsParameter(
762 762
 			$constraintParameters,
763 763
 			$constraintTypeItemId,
764 764
 			false,
765 765
 			$contextTypeParameterId
766 766
 		);
767
-		$entityTypeParameterId = $this->config->get( 'WBQualityConstraintsConstraintEntityTypesId' );
767
+		$entityTypeParameterId = $this->config->get('WBQualityConstraintsConstraintEntityTypesId');
768 768
 		$entityTypeItemIds = $this->parseItemIdsParameter(
769 769
 			$constraintParameters,
770 770
 			$constraintTypeItemId,
@@ -780,26 +780,26 @@  discard block
 block discarded – undo
780 780
 		$contextTypes = null;
781 781
 		$entityTypes = null;
782 782
 
783
-		if ( $contextTypeParameterId === $entityTypeParameterId ) {
783
+		if ($contextTypeParameterId === $entityTypeParameterId) {
784 784
 			$itemIds = $contextTypeItemIds;
785 785
 			$mapping = $contextTypeMapping + $entityTypeMapping;
786
-			foreach ( $itemIds as $itemId ) {
787
-				$mapped = $this->mapItemId( $itemId, $mapping, $contextTypeParameterId );
788
-				if ( in_array( $mapped, $contextTypeMapping, true ) ) {
786
+			foreach ($itemIds as $itemId) {
787
+				$mapped = $this->mapItemId($itemId, $mapping, $contextTypeParameterId);
788
+				if (in_array($mapped, $contextTypeMapping, true)) {
789 789
 					$contextTypes[] = $mapped;
790 790
 				} else {
791 791
 					$entityTypes[] = $mapped;
792 792
 				}
793 793
 			}
794 794
 		} else {
795
-			foreach ( $contextTypeItemIds as $contextTypeItemId ) {
795
+			foreach ($contextTypeItemIds as $contextTypeItemId) {
796 796
 				$contextTypes[] = $this->mapItemId(
797 797
 					$contextTypeItemId,
798 798
 					$contextTypeMapping,
799 799
 					$contextTypeParameterId
800 800
 				);
801 801
 			}
802
-			foreach ( $entityTypeItemIds as $entityTypeItemId ) {
802
+			foreach ($entityTypeItemIds as $entityTypeItemId) {
803 803
 				$entityTypes[] = $this->mapItemId(
804 804
 					$entityTypeItemId,
805 805
 					$entityTypeMapping,
@@ -808,21 +808,21 @@  discard block
 block discarded – undo
808 808
 			}
809 809
 		}
810 810
 
811
-		$this->checkValidScope( $constraintTypeItemId, $contextTypes, $validContextTypes );
812
-		$this->checkValidScope( $constraintTypeItemId, $entityTypes, $validEntityTypes );
811
+		$this->checkValidScope($constraintTypeItemId, $contextTypes, $validContextTypes);
812
+		$this->checkValidScope($constraintTypeItemId, $entityTypes, $validEntityTypes);
813 813
 
814
-		return [ $contextTypes, $entityTypes ];
814
+		return [$contextTypes, $entityTypes];
815 815
 	}
816 816
 
817
-	private function checkValidScope( string $constraintTypeItemId, ?array $types, array $validTypes ): void {
818
-		$invalidTypes = array_diff( $types ?: [], $validTypes );
819
-		if ( $invalidTypes !== [] ) {
820
-			$invalidType = array_pop( $invalidTypes );
817
+	private function checkValidScope(string $constraintTypeItemId, ?array $types, array $validTypes): void {
818
+		$invalidTypes = array_diff($types ?: [], $validTypes);
819
+		if ($invalidTypes !== []) {
820
+			$invalidType = array_pop($invalidTypes);
821 821
 			throw new ConstraintParameterException(
822
-				( new ViolationMessage( 'wbqc-violation-message-invalid-scope' ) )
823
-					->withConstraintScope( $invalidType, Role::CONSTRAINT_PARAMETER_VALUE )
824
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
825
-					->withConstraintScopeList( $validTypes, Role::CONSTRAINT_PARAMETER_VALUE )
822
+				(new ViolationMessage('wbqc-violation-message-invalid-scope'))
823
+					->withConstraintScope($invalidType, Role::CONSTRAINT_PARAMETER_VALUE)
824
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
825
+					->withConstraintScopeList($validTypes, Role::CONSTRAINT_PARAMETER_VALUE)
826 826
 			);
827 827
 		}
828 828
 	}
@@ -830,8 +830,8 @@  discard block
 block discarded – undo
830 830
 	/**
831 831
 	 * Turn an item ID into a full unit string (using the concept URI).
832 832
 	 */
833
-	private function parseUnitParameter( ItemId $unitId ): string {
834
-		return $this->unitItemConceptBaseUri . $unitId->getSerialization();
833
+	private function parseUnitParameter(ItemId $unitId): string {
834
+		return $this->unitItemConceptBaseUri.$unitId->getSerialization();
835 835
 	}
836 836
 
837 837
 	/**
@@ -839,23 +839,23 @@  discard block
 block discarded – undo
839 839
 	 *
840 840
 	 * @throws ConstraintParameterException
841 841
 	 */
842
-	private function parseUnitItem( ItemIdSnakValue $item ): UnitsParameter {
843
-		switch ( true ) {
842
+	private function parseUnitItem(ItemIdSnakValue $item): UnitsParameter {
843
+		switch (true) {
844 844
 			case $item->isValue():
845
-				$unit = $this->parseUnitParameter( $item->getItemId() );
845
+				$unit = $this->parseUnitParameter($item->getItemId());
846 846
 				return new UnitsParameter(
847
-					[ $item->getItemId() ],
848
-					[ UnboundedQuantityValue::newFromNumber( 1, $unit ) ],
847
+					[$item->getItemId()],
848
+					[UnboundedQuantityValue::newFromNumber(1, $unit)],
849 849
 					false
850 850
 				);
851 851
 			case $item->isSomeValue():
852
-				$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
852
+				$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
853 853
 				throw new ConstraintParameterException(
854
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
855
-						->withEntityId( new NumericPropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
854
+					(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
855
+						->withEntityId(new NumericPropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
856 856
 				);
857 857
 			case $item->isNoValue():
858
-				return new UnitsParameter( [], [], true );
858
+				return new UnitsParameter([], [], true);
859 859
 		}
860 860
 	}
861 861
 
@@ -865,36 +865,36 @@  discard block
 block discarded – undo
865 865
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
866 866
 	 * @return UnitsParameter
867 867
 	 */
868
-	public function parseUnitsParameter( array $constraintParameters, string $constraintTypeItemId ): UnitsParameter {
869
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
868
+	public function parseUnitsParameter(array $constraintParameters, string $constraintTypeItemId): UnitsParameter {
869
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
870 870
 		$unitItems = [];
871 871
 		$unitQuantities = [];
872 872
 		$unitlessAllowed = false;
873 873
 
874
-		foreach ( $items as $item ) {
875
-			$unit = $this->parseUnitItem( $item );
876
-			$unitItems = array_merge( $unitItems, $unit->getUnitItemIds() );
877
-			$unitQuantities = array_merge( $unitQuantities, $unit->getUnitQuantities() );
874
+		foreach ($items as $item) {
875
+			$unit = $this->parseUnitItem($item);
876
+			$unitItems = array_merge($unitItems, $unit->getUnitItemIds());
877
+			$unitQuantities = array_merge($unitQuantities, $unit->getUnitQuantities());
878 878
 			$unitlessAllowed = $unitlessAllowed || $unit->getUnitlessAllowed();
879 879
 		}
880 880
 
881
-		if ( $unitQuantities === [] && !$unitlessAllowed ) {
881
+		if ($unitQuantities === [] && !$unitlessAllowed) {
882 882
 			throw new LogicException(
883 883
 				'The "units" parameter is required, and yet we seem to be missing any allowed unit'
884 884
 			);
885 885
 		}
886 886
 
887
-		return new UnitsParameter( $unitItems, $unitQuantities, $unitlessAllowed );
887
+		return new UnitsParameter($unitItems, $unitQuantities, $unitlessAllowed);
888 888
 	}
889 889
 
890 890
 	private function getEntityTypeMapping(): array {
891 891
 		return [
892
-			$this->config->get( 'WBQualityConstraintsWikibaseItemId' ) => 'item',
893
-			$this->config->get( 'WBQualityConstraintsWikibasePropertyId' ) => 'property',
894
-			$this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ) => 'lexeme',
895
-			$this->config->get( 'WBQualityConstraintsWikibaseFormId' ) => 'form',
896
-			$this->config->get( 'WBQualityConstraintsWikibaseSenseId' ) => 'sense',
897
-			$this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ) => 'mediainfo',
892
+			$this->config->get('WBQualityConstraintsWikibaseItemId') => 'item',
893
+			$this->config->get('WBQualityConstraintsWikibasePropertyId') => 'property',
894
+			$this->config->get('WBQualityConstraintsWikibaseLexemeId') => 'lexeme',
895
+			$this->config->get('WBQualityConstraintsWikibaseFormId') => 'form',
896
+			$this->config->get('WBQualityConstraintsWikibaseSenseId') => 'sense',
897
+			$this->config->get('WBQualityConstraintsWikibaseMediaInfoId') => 'mediainfo',
898 898
 		];
899 899
 	}
900 900
 
@@ -904,10 +904,10 @@  discard block
 block discarded – undo
904 904
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
905 905
 	 * @return EntityTypesParameter
906 906
 	 */
907
-	public function parseEntityTypesParameter( array $constraintParameters, string $constraintTypeItemId ): EntityTypesParameter {
907
+	public function parseEntityTypesParameter(array $constraintParameters, string $constraintTypeItemId): EntityTypesParameter {
908 908
 		$entityTypes = [];
909 909
 		$entityTypeItemIds = [];
910
-		$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
910
+		$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
911 911
 		$itemIds = $this->parseItemIdsParameter(
912 912
 			$constraintParameters,
913 913
 			$constraintTypeItemId,
@@ -916,22 +916,22 @@  discard block
 block discarded – undo
916 916
 		);
917 917
 
918 918
 		$mapping = $this->getEntityTypeMapping();
919
-		foreach ( $itemIds as $itemId ) {
920
-			$entityType = $this->mapItemId( $itemId, $mapping, $parameterId );
919
+		foreach ($itemIds as $itemId) {
920
+			$entityType = $this->mapItemId($itemId, $mapping, $parameterId);
921 921
 			$entityTypes[] = $entityType;
922 922
 			$entityTypeItemIds[] = $itemId;
923 923
 		}
924 924
 
925
-		if ( $entityTypes === [] ) {
925
+		if ($entityTypes === []) {
926 926
 			// @codeCoverageIgnoreStart
927 927
 			throw new LogicException(
928
-				'The "entity types" parameter is required, ' .
928
+				'The "entity types" parameter is required, '.
929 929
 				'and yet we seem to be missing any allowed entity type'
930 930
 			);
931 931
 			// @codeCoverageIgnoreEnd
932 932
 		}
933 933
 
934
-		return new EntityTypesParameter( $entityTypes, $entityTypeItemIds );
934
+		return new EntityTypesParameter($entityTypes, $entityTypeItemIds);
935 935
 	}
936 936
 
937 937
 	/**
@@ -939,18 +939,18 @@  discard block
 block discarded – undo
939 939
 	 * @throws ConstraintParameterException if the parameter is invalid
940 940
 	 * @return PropertyId[]
941 941
 	 */
942
-	public function parseSeparatorsParameter( array $constraintParameters ): array {
943
-		$separatorId = $this->config->get( 'WBQualityConstraintsSeparatorId' );
942
+	public function parseSeparatorsParameter(array $constraintParameters): array {
943
+		$separatorId = $this->config->get('WBQualityConstraintsSeparatorId');
944 944
 
945
-		if ( !array_key_exists( $separatorId, $constraintParameters ) ) {
945
+		if (!array_key_exists($separatorId, $constraintParameters)) {
946 946
 			return [];
947 947
 		}
948 948
 
949 949
 		$parameters = $constraintParameters[$separatorId];
950 950
 		$separators = [];
951 951
 
952
-		foreach ( $parameters as $parameter ) {
953
-			$separators[] = $this->parsePropertyIdParameter( $parameter, $separatorId );
952
+		foreach ($parameters as $parameter) {
953
+			$separators[] = $this->parsePropertyIdParameter($parameter, $separatorId);
954 954
 		}
955 955
 
956 956
 		return $separators;
@@ -958,17 +958,17 @@  discard block
 block discarded – undo
958 958
 
959 959
 	private function getConstraintScopeContextTypeMapping(): array {
960 960
 		return [
961
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' ) => Context::TYPE_STATEMENT,
962
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' ) => Context::TYPE_QUALIFIER,
963
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' ) => Context::TYPE_REFERENCE,
961
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId') => Context::TYPE_STATEMENT,
962
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId') => Context::TYPE_QUALIFIER,
963
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId') => Context::TYPE_REFERENCE,
964 964
 		];
965 965
 	}
966 966
 
967 967
 	private function getPropertyScopeContextTypeMapping(): array {
968 968
 		return [
969
-			$this->config->get( 'WBQualityConstraintsAsMainValueId' ) => Context::TYPE_STATEMENT,
970
-			$this->config->get( 'WBQualityConstraintsAsQualifiersId' ) => Context::TYPE_QUALIFIER,
971
-			$this->config->get( 'WBQualityConstraintsAsReferencesId' ) => Context::TYPE_REFERENCE,
969
+			$this->config->get('WBQualityConstraintsAsMainValueId') => Context::TYPE_STATEMENT,
970
+			$this->config->get('WBQualityConstraintsAsQualifiersId') => Context::TYPE_QUALIFIER,
971
+			$this->config->get('WBQualityConstraintsAsReferencesId') => Context::TYPE_REFERENCE,
972 972
 		];
973 973
 	}
974 974
 
@@ -978,9 +978,9 @@  discard block
 block discarded – undo
978 978
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
979 979
 	 * @return string[] list of Context::TYPE_* constants
980 980
 	 */
981
-	public function parsePropertyScopeParameter( array $constraintParameters, string $constraintTypeItemId ): array {
981
+	public function parsePropertyScopeParameter(array $constraintParameters, string $constraintTypeItemId): array {
982 982
 		$contextTypes = [];
983
-		$parameterId = $this->config->get( 'WBQualityConstraintsPropertyScopeId' );
983
+		$parameterId = $this->config->get('WBQualityConstraintsPropertyScopeId');
984 984
 		$itemIds = $this->parseItemIdsParameter(
985 985
 			$constraintParameters,
986 986
 			$constraintTypeItemId,
@@ -989,14 +989,14 @@  discard block
 block discarded – undo
989 989
 		);
990 990
 
991 991
 		$mapping = $this->getPropertyScopeContextTypeMapping();
992
-		foreach ( $itemIds as $itemId ) {
993
-			$contextTypes[] = $this->mapItemId( $itemId, $mapping, $parameterId );
992
+		foreach ($itemIds as $itemId) {
993
+			$contextTypes[] = $this->mapItemId($itemId, $mapping, $parameterId);
994 994
 		}
995 995
 
996
-		if ( $contextTypes === [] ) {
996
+		if ($contextTypes === []) {
997 997
 			// @codeCoverageIgnoreStart
998 998
 			throw new LogicException(
999
-				'The "property scope" parameter is required, ' .
999
+				'The "property scope" parameter is required, '.
1000 1000
 				'and yet we seem to be missing any allowed scope'
1001 1001
 			);
1002 1002
 			// @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.
src/ConstraintCheck/Result/CheckResult.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Result;
6 6
 
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
 		string $status = self::STATUS_TODO,
109 109
 		?ViolationMessage $message = null
110 110
 	) {
111
-		if ( $contextCursor instanceof Context ) {
111
+		if ($contextCursor instanceof Context) {
112 112
 			$context = $contextCursor;
113 113
 			$this->contextCursor = $context->getCursor();
114 114
 			$this->snakType = $context->getSnak()->getType();
115 115
 			$mainSnak = $context->getSnak();
116
-			if ( $mainSnak instanceof PropertyValueSnak ) {
116
+			if ($mainSnak instanceof PropertyValueSnak) {
117 117
 				$this->dataValue = $mainSnak->getDataValue();
118 118
 			} else {
119 119
 				$this->dataValue = null;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		$this->status = $status;
128 128
 		$this->message = $message;
129 129
 		$this->metadata = Metadata::blank();
130
-		$this->constraintClarification = new MultilingualTextValue( [] );
130
+		$this->constraintClarification = new MultilingualTextValue([]);
131 131
 	}
132 132
 
133 133
 	public function getContextCursor(): ContextCursor {
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		return $this->status;
164 164
 	}
165 165
 
166
-	public function setStatus( string $status ): void {
166
+	public function setStatus(string $status): void {
167 167
 		$this->status = $status;
168 168
 	}
169 169
 
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 		return $this->message;
172 172
 	}
173 173
 
174
-	public function setMessage( ?ViolationMessage $message ) {
174
+	public function setMessage(?ViolationMessage $message) {
175 175
 		$this->message = $message;
176 176
 	}
177 177
 
178
-	public function withMetadata( Metadata $metadata ): self {
178
+	public function withMetadata(Metadata $metadata): self {
179 179
 		$this->metadata = $metadata;
180 180
 		return $this;
181 181
 	}
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 		return $this->constraintClarification;
189 189
 	}
190 190
 
191
-	public function setConstraintClarification( MultilingualTextValue $constraintClarification ) {
191
+	public function setConstraintClarification(MultilingualTextValue $constraintClarification) {
192 192
 		$this->constraintClarification = $constraintClarification;
193 193
 	}
194 194
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/CachingMetadata.php 1 patch
Spacing   +9 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Cache;
6 6
 
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 	 * @param int $maxAge The maximum age of the cached value (in seconds).
32 32
 	 * @return self Indication that a value is possibly outdated by up to this many seconds.
33 33
 	 */
34
-	public static function ofMaximumAgeInSeconds( int $maxAge ): self {
35
-		Assert::parameter( $maxAge > 0, '$maxAge', '$maxage > 0' );
34
+	public static function ofMaximumAgeInSeconds(int $maxAge): self {
35
+		Assert::parameter($maxAge > 0, '$maxAge', '$maxage > 0');
36 36
 		$ret = new self;
37 37
 		$ret->maxAge = $maxAge;
38 38
 		return $ret;
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
 	 * @param self[] $metadatas
43 43
 	 * @return self
44 44
 	 */
45
-	public static function merge( array $metadatas ): self {
46
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
45
+	public static function merge(array $metadatas): self {
46
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
47 47
 		$ret = new self;
48
-		foreach ( $metadatas as $metadata ) {
49
-			$ret->maxAge = max( $ret->maxAge, $metadata->maxAge );
48
+		foreach ($metadatas as $metadata) {
49
+			$ret->maxAge = max($ret->maxAge, $metadata->maxAge);
50 50
 		}
51 51
 		return $ret;
52 52
 	}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * For a fresh value, returns 0.
65 65
 	 */
66 66
 	public function getMaximumAgeInSeconds(): int {
67
-		if ( is_int( $this->maxAge ) ) {
67
+		if (is_int($this->maxAge)) {
68 68
 			return $this->maxAge;
69 69
 		} else {
70 70
 			return 0;
@@ -79,8 +79,7 @@  discard block
 block discarded – undo
79 79
 		return $this->isCached() ?
80 80
 			[
81 81
 				'maximumAgeInSeconds' => $this->maxAge,
82
-			] :
83
-			null;
82
+			] : null;
84 83
 	}
85 84
 
86 85
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Cache/DependencyMetadata.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param EntityId $entityId An entity ID from which the value was derived.
38 38
 	 * @return self Indication that a value was derived from the entity with the given ID.
39 39
 	 */
40
-	public static function ofEntityId( EntityId $entityId ) {
40
+	public static function ofEntityId(EntityId $entityId) {
41 41
 		$ret = new self;
42 42
 		$ret->entityIds[] = $entityId;
43 43
 		return $ret;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @return self Indication that a value will only remain valid
50 50
 	 * as long as the given time value is in the future, not in the past.
51 51
 	 */
52
-	public static function ofFutureTime( TimeValue $timeValue ) {
52
+	public static function ofFutureTime(TimeValue $timeValue) {
53 53
 		$ret = new self;
54 54
 		$ret->timeValue = $timeValue;
55 55
 		return $ret;
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 	 * @param self[] $metadatas
60 60
 	 * @return self
61 61
 	 */
62
-	public static function merge( array $metadatas ) {
63
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
62
+	public static function merge(array $metadatas) {
63
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
64 64
 		$ret = new self;
65 65
 		$entityIds = [];
66
-		foreach ( $metadatas as $metadata ) {
67
-			foreach ( $metadata->entityIds as $entityId ) {
66
+		foreach ($metadatas as $metadata) {
67
+			foreach ($metadata->entityIds as $entityId) {
68 68
 				$entityIds[$entityId->getSerialization()] = $entityId;
69 69
 			}
70
-			$ret->timeValue = self::minTimeValue( $ret->timeValue, $metadata->timeValue );
70
+			$ret->timeValue = self::minTimeValue($ret->timeValue, $metadata->timeValue);
71 71
 		}
72
-		$ret->entityIds = array_values( $entityIds );
72
+		$ret->entityIds = array_values($entityIds);
73 73
 		return $ret;
74 74
 	}
75 75
 
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 	 * @param TimeValue|null $t2
79 79
 	 * @return TimeValue|null
80 80
 	 */
81
-	private static function minTimeValue( ?TimeValue $t1, ?TimeValue $t2 ) {
82
-		if ( $t1 === null ) {
81
+	private static function minTimeValue(?TimeValue $t1, ?TimeValue $t2) {
82
+		if ($t1 === null) {
83 83
 			return $t2;
84 84
 		}
85
-		if ( $t2 === null ) {
85
+		if ($t2 === null) {
86 86
 			return $t1;
87 87
 		}
88
-		return ( new TimeValueComparer() )->getMinimum( $t1, $t2 );
88
+		return (new TimeValueComparer())->getMinimum($t1, $t2);
89 89
 	}
90 90
 
91 91
 	/**
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/FormatCheckerHelper.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@
 block discarded – undo
21 21
 	 * @return false|int (from the preg_match documentation) returns 1 if the pattern
22 22
 	 * matches given subject, 0 if it does not, or FALSE if an error occurred.
23 23
 	 */
24
-	public static function runRegexCheck( string $regex, string $text ) {
25
-		$pattern = '(^(?:' . $regex . ')$)u';
24
+	public static function runRegexCheck(string $regex, string $text) {
25
+		$pattern = '(^(?:'.$regex.')$)u';
26 26
 
27 27
 		// `preg_match` emits an E_WARNING when the pattern is not valid regex.
28 28
 		// Silence this warning to avoid throwing a ShellboxError.
29 29
 		// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
30
-		return @preg_match( $pattern, $text );
30
+		return @preg_match($pattern, $text);
31 31
 	}
32 32
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/TypeCheckerHelper.php 1 patch
Spacing   +54 added lines, -54 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,40 +135,40 @@  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 ) {
139
-		$timing = $this->statsFactory->getTiming( 'isSubclassOf_duration_seconds' )
140
-			->setLabel( 'result', 'success' )
141
-			->setLabel( 'TypeCheckerImplementation', 'php' )
142
-			->copyToStatsdAt( 'wikibase.quality.constraints.type.php.success.timing' );
138
+	public function isSubclassOfWithSparqlFallback(EntityId $comparativeClass, array $classesToCheck) {
139
+		$timing = $this->statsFactory->getTiming('isSubclassOf_duration_seconds')
140
+			->setLabel('result', 'success')
141
+			->setLabel('TypeCheckerImplementation', 'php')
142
+			->copyToStatsdAt('wikibase.quality.constraints.type.php.success.timing');
143 143
 		$timing->start();
144 144
 
145 145
 		try {
146 146
 			$entitiesChecked = 0;
147
-			$isSubclass = $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked );
147
+			$isSubclass = $this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked);
148 148
 			$timing->stop();
149 149
 
150 150
 			// not really a timing, but works like one (we want percentiles etc.)
151 151
 			// TODO: probably a good candidate for T348796
152
-			$this->statsFactory->getTiming( 'isSubclassOf_entities_total' )
153
-				->setLabel( 'TypeCheckerImplementation', 'php' )
154
-				->setLabel( 'result', 'success' )
155
-				->copyToStatsdAt( 'wikibase.quality.constraints.type.php.success.entities' )
156
-				->observe( $entitiesChecked );
157
-
158
-			return new CachedBool( $isSubclass, Metadata::blank() );
159
-		} catch ( OverflowException $e ) {
160
-			$timing->setLabel( 'result', 'overflow' )
161
-				->copyToStatsdAt( 'wikibase.quality.constraints.type.php.overflow.timing' )
152
+			$this->statsFactory->getTiming('isSubclassOf_entities_total')
153
+				->setLabel('TypeCheckerImplementation', 'php')
154
+				->setLabel('result', 'success')
155
+				->copyToStatsdAt('wikibase.quality.constraints.type.php.success.entities')
156
+				->observe($entitiesChecked);
157
+
158
+			return new CachedBool($isSubclass, Metadata::blank());
159
+		} catch (OverflowException $e) {
160
+			$timing->setLabel('result', 'overflow')
161
+				->copyToStatsdAt('wikibase.quality.constraints.type.php.overflow.timing')
162 162
 				->stop();
163 163
 
164
-			if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) {
165
-				$this->statsFactory->getCounter( 'sparql_typeFallback_total' )
166
-					->copyToStatsdAt( 'wikibase.quality.constraints.sparql.typeFallback' )
164
+			if (!($this->sparqlHelper instanceof DummySparqlHelper)) {
165
+				$this->statsFactory->getCounter('sparql_typeFallback_total')
166
+					->copyToStatsdAt('wikibase.quality.constraints.sparql.typeFallback')
167 167
 					->increment();
168 168
 
169
-				$timing->setLabel( 'TypeCheckerImplementation', 'sparql' )
170
-					->setLabel( 'result', 'success' )
171
-					->copyToStatsdAt( 'wikibase.quality.constraints.type.sparql.success.timing' )
169
+				$timing->setLabel('TypeCheckerImplementation', 'sparql')
170
+					->setLabel('result', 'success')
171
+					->copyToStatsdAt('wikibase.quality.constraints.type.sparql.success.timing')
172 172
 					->start();
173 173
 
174 174
 				$hasType = $this->sparqlHelper->hasType(
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
 				return $hasType;
182 182
 			} else {
183
-				return new CachedBool( false, Metadata::blank() );
183
+				return new CachedBool(false, Metadata::blank());
184 184
 			}
185 185
 		}
186 186
 	}
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
 	 * @return CachedBool
199 199
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
200 200
 	 */
201
-	public function hasClassInRelation( StatementList $statements, array $relationIds, array $classesToCheck ) {
201
+	public function hasClassInRelation(StatementList $statements, array $relationIds, array $classesToCheck) {
202 202
 		$metadatas = [];
203 203
 
204
-		foreach ( $this->getBestStatementsByPropertyIds( $statements, $relationIds ) as $statement ) {
204
+		foreach ($this->getBestStatementsByPropertyIds($statements, $relationIds) as $statement) {
205 205
 			$mainSnak = $statement->getMainSnak();
206 206
 
207
-			if ( !$this->hasCorrectType( $mainSnak ) ) {
207
+			if (!$this->hasCorrectType($mainSnak)) {
208 208
 				continue;
209 209
 			}
210 210
 			/** @var PropertyValueSnak $mainSnak */
@@ -214,24 +214,24 @@  discard block
 block discarded – undo
214 214
 			'@phan-var EntityIdValue $dataValue';
215 215
 			$comparativeClass = $dataValue->getEntityId();
216 216
 
217
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
217
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
218 218
 				// discard $metadatas, we know this is fresh
219
-				return new CachedBool( true, Metadata::blank() );
219
+				return new CachedBool(true, Metadata::blank());
220 220
 			}
221 221
 
222
-			$result = $this->isSubclassOfWithSparqlFallback( $comparativeClass, $classesToCheck );
222
+			$result = $this->isSubclassOfWithSparqlFallback($comparativeClass, $classesToCheck);
223 223
 			$metadatas[] = $result->getMetadata();
224
-			if ( $result->getBool() ) {
224
+			if ($result->getBool()) {
225 225
 				return new CachedBool(
226 226
 					true,
227
-					Metadata::merge( $metadatas )
227
+					Metadata::merge($metadatas)
228 228
 				);
229 229
 			}
230 230
 		}
231 231
 
232 232
 		return new CachedBool(
233 233
 			false,
234
-			Metadata::merge( $metadatas )
234
+			Metadata::merge($metadatas)
235 235
 		);
236 236
 	}
237 237
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 * @return bool
241 241
 	 * @phan-assert PropertyValueSnak $mainSnak
242 242
 	 */
243
-	private function hasCorrectType( Snak $mainSnak ) {
243
+	private function hasCorrectType(Snak $mainSnak) {
244 244
 		return $mainSnak instanceof PropertyValueSnak
245 245
 			&& $mainSnak->getDataValue()->getType() === 'wikibase-entityid';
246 246
 	}
@@ -257,15 +257,15 @@  discard block
 block discarded – undo
257 257
 	) {
258 258
 		$statementArrays = [];
259 259
 
260
-		foreach ( $propertyIdSerializations as $propertyIdSerialization ) {
261
-			$propertyId = new NumericPropertyId( $propertyIdSerialization );
260
+		foreach ($propertyIdSerializations as $propertyIdSerialization) {
261
+			$propertyId = new NumericPropertyId($propertyIdSerialization);
262 262
 			$statementArrays[] = $statements
263
-				->getByPropertyId( $propertyId )
263
+				->getByPropertyId($propertyId)
264 264
 				->getBestStatements()
265 265
 				->toArray();
266 266
 		}
267 267
 
268
-		return array_merge( ...$statementArrays );
268
+		return array_merge(...$statementArrays);
269 269
 	}
270 270
 
271 271
 	/**
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 		$relation
286 286
 	) {
287 287
 		$classes = array_map(
288
-			static function ( $itemIdSerialization ) {
289
-				return new ItemId( $itemIdSerialization );
288
+			static function($itemIdSerialization) {
289
+				return new ItemId($itemIdSerialization);
290 290
 			},
291 291
 			$classes
292 292
 		);
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 		// wbqc-violation-message-valueType-instance
299 299
 		// wbqc-violation-message-valueType-subclass
300 300
 		// wbqc-violation-message-valueType-instanceOrSubclass
301
-		return ( new ViolationMessage( 'wbqc-violation-message-' . $checker . '-' . $relation ) )
302
-			->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY )
303
-			->withEntityId( $entityId, Role::SUBJECT )
304
-			->withEntityIdList( $classes, Role::OBJECT );
301
+		return (new ViolationMessage('wbqc-violation-message-'.$checker.'-'.$relation))
302
+			->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY)
303
+			->withEntityId($entityId, Role::SUBJECT)
304
+			->withEntityIdList($classes, Role::OBJECT);
305 305
 	}
306 306
 
307 307
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/MultilingualTextViolationMessageRenderer.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Message;
6 6
 
@@ -28,13 +28,13 @@  discard block
 block discarded – undo
28 28
 		'wbqc-violation-message-format-clarification' => 'wbqc-violation-message-format',
29 29
 	];
30 30
 
31
-	public function render( ViolationMessage $violationMessage ): string {
32
-		if ( !array_key_exists( $violationMessage->getMessageKey(), self::ALTERNATIVE_MESSAGE_KEYS ) ) {
33
-			return parent::render( $violationMessage );
31
+	public function render(ViolationMessage $violationMessage): string {
32
+		if (!array_key_exists($violationMessage->getMessageKey(), self::ALTERNATIVE_MESSAGE_KEYS)) {
33
+			return parent::render($violationMessage);
34 34
 		}
35 35
 
36 36
 		$arguments = $violationMessage->getArguments();
37
-		$multilingualTextArgument = array_pop( $arguments );
37
+		$multilingualTextArgument = array_pop($arguments);
38 38
 		$multilingualTextParams = $this->renderMultilingualText(
39 39
 			// @phan-suppress-next-line PhanTypeArraySuspiciousNullable TODO Ensure this is not an actual issue
40 40
 			$multilingualTextArgument['value'],
@@ -42,22 +42,22 @@  discard block
 block discarded – undo
42 42
 			$multilingualTextArgument['role']
43 43
 		);
44 44
 
45
-		$paramsLists = [ [] ];
46
-		foreach ( $arguments as $argument ) {
47
-			$paramsLists[] = $this->renderArgument( $argument );
45
+		$paramsLists = [[]];
46
+		foreach ($arguments as $argument) {
47
+			$paramsLists[] = $this->renderArgument($argument);
48 48
 		}
49
-		$regularParams = array_merge( ...$paramsLists );
49
+		$regularParams = array_merge(...$paramsLists);
50 50
 
51
-		if ( $multilingualTextParams === null ) {
51
+		if ($multilingualTextParams === null) {
52 52
 			return $this->messageLocalizer
53
-				->msg( self::ALTERNATIVE_MESSAGE_KEYS[$violationMessage->getMessageKey()] )
54
-				->params( $regularParams )
53
+				->msg(self::ALTERNATIVE_MESSAGE_KEYS[$violationMessage->getMessageKey()])
54
+				->params($regularParams)
55 55
 				->escaped();
56 56
 		} else {
57 57
 			return $this->messageLocalizer
58
-				->msg( $violationMessage->getMessageKey() )
59
-				->params( $regularParams )
60
-				->params( $multilingualTextParams )
58
+				->msg($violationMessage->getMessageKey())
59
+				->params($regularParams)
60
+				->params($multilingualTextParams)
61 61
 				->escaped();
62 62
 		}
63 63
 	}
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	 * @return MessageParam[]|null list of parameters as accepted by Message::params(),
69 69
 	 * or null if the text is not available in the user’s language
70 70
 	 */
71
-	protected function renderMultilingualText( MultilingualTextValue $text, ?string $role ): ?array {
71
+	protected function renderMultilingualText(MultilingualTextValue $text, ?string $role): ?array {
72 72
 		$texts = $text->getTexts();
73
-		foreach ( $this->languageFallbackChain->getFetchLanguageCodes() as $languageCode ) {
74
-			if ( array_key_exists( $languageCode, $texts ) ) {
75
-				return [ Message::rawParam( $this->addRole(
76
-					htmlspecialchars( $texts[$languageCode]->getText() ),
73
+		foreach ($this->languageFallbackChain->getFetchLanguageCodes() as $languageCode) {
74
+			if (array_key_exists($languageCode, $texts)) {
75
+				return [Message::rawParam($this->addRole(
76
+					htmlspecialchars($texts[$languageCode]->getText()),
77 77
 					$role
78
-				) ) ];
78
+				))];
79 79
 			}
80 80
 		}
81 81
 
Please login to merge, or discard this patch.