Completed
Push — master ( 12a9a3...d22875 )
by
unknown
02:45
created
src/ConstraintCheck/Checker/DiffWithinRangeChecker.php 1 patch
Spacing   +43 added lines, -44 removed lines patch added patch discarded remove patch
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 	 * @throws ConstraintParameterException
92 92
 	 * @return array [ DataValue|null $min, DataValue|null $max, PropertyId $property, array $parameters ]
93 93
 	 */
94
-	private function parseConstraintParameters( Constraint $constraint ) {
95
-		list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter(
94
+	private function parseConstraintParameters(Constraint $constraint) {
95
+		list($min, $max) = $this->constraintParameterParser->parseRangeParameter(
96 96
 			$constraint->getConstraintParameters(),
97 97
 			$constraint->getConstraintTypeItemId(),
98 98
 			'quantity'
@@ -102,15 +102,15 @@  discard block
 block discarded – undo
102 102
 			$constraint->getConstraintTypeItemId()
103 103
 		);
104 104
 
105
-		if ( $min !== null ) {
106
-			$parameters['minimum_quantity'] = [ $min ];
105
+		if ($min !== null) {
106
+			$parameters['minimum_quantity'] = [$min];
107 107
 		}
108
-		if ( $max !== null ) {
109
-			$parameters['maximum_quantity'] = [ $max ];
108
+		if ($max !== null) {
109
+			$parameters['maximum_quantity'] = [$max];
110 110
 		}
111
-		$parameters['property'] = [ $property ];
111
+		$parameters['property'] = [$property];
112 112
 
113
-		return [ $min, $max, $property, $parameters ];
113
+		return [$min, $max, $property, $parameters];
114 114
 	}
115 115
 
116 116
 	/**
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @return bool
122 122
 	 */
123
-	private function rangeInYears( $min, $max ) {
124
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
123
+	private function rangeInYears($min, $max) {
124
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
125 125
 
126
-		if ( $min !== null && $min->getUnit() === $yearUnit ) {
126
+		if ($min !== null && $min->getUnit() === $yearUnit) {
127 127
 			return true;
128 128
 		}
129
-		if ( $max !== null && $max->getUnit() === $yearUnit ) {
129
+		if ($max !== null && $max->getUnit() === $yearUnit) {
130 130
 			return true;
131 131
 		}
132 132
 
@@ -142,32 +142,32 @@  discard block
 block discarded – undo
142 142
 	 * @throws ConstraintParameterException
143 143
 	 * @return CheckResult
144 144
 	 */
145
-	public function checkConstraint( Context $context, Constraint $constraint ) {
146
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
147
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
145
+	public function checkConstraint(Context $context, Constraint $constraint) {
146
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
147
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
148 148
 		}
149 149
 
150 150
 		$parameters = [];
151 151
 
152 152
 		$snak = $context->getSnak();
153 153
 
154
-		if ( !$snak instanceof PropertyValueSnak ) {
154
+		if (!$snak instanceof PropertyValueSnak) {
155 155
 			// nothing to check
156
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' );
156
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '');
157 157
 		}
158 158
 
159 159
 		$minuend = $snak->getDataValue();
160 160
 
161 161
 		/** @var PropertyId $property */
162
-		list ( $min, $max, $property, $parameters ) = $this->parseConstraintParameters( $constraint );
162
+		list ($min, $max, $property, $parameters) = $this->parseConstraintParameters($constraint);
163 163
 
164 164
 		// checks only the first occurrence of the referenced property (this constraint implies a single value constraint on that property)
165 165
 		/** @var Statement $otherStatement */
166
-		foreach ( $context->getEntity()->getStatements() as $otherStatement ) {
166
+		foreach ($context->getEntity()->getStatements() as $otherStatement) {
167 167
 			$otherMainSnak = $otherStatement->getMainSnak();
168 168
 
169 169
 			if (
170
-				!$property->equals( $otherStatement->getPropertyId() ) ||
170
+				!$property->equals($otherStatement->getPropertyId()) ||
171 171
 				$otherStatement->getRank() === Statement::RANK_DEPRECATED ||
172 172
 				!$otherMainSnak instanceof PropertyValueSnak
173 173
 			) {
@@ -175,28 +175,27 @@  discard block
 block discarded – undo
175 175
 			}
176 176
 
177 177
 			$subtrahend = $otherMainSnak->getDataValue();
178
-			if ( $subtrahend->getType() === $minuend->getType() ) {
179
-				$diff = $this->rangeInYears( $min, $max ) ?
180
-					$this->rangeCheckerHelper->getDifferenceInYears( $minuend, $subtrahend ) :
181
-					$this->rangeCheckerHelper->getDifference( $minuend, $subtrahend );
178
+			if ($subtrahend->getType() === $minuend->getType()) {
179
+				$diff = $this->rangeInYears($min, $max) ?
180
+					$this->rangeCheckerHelper->getDifferenceInYears($minuend, $subtrahend) : $this->rangeCheckerHelper->getDifference($minuend, $subtrahend);
182 181
 
183
-				if ( $this->rangeCheckerHelper->getComparison( $min, $diff ) > 0 ||
184
-					$this->rangeCheckerHelper->getComparison( $diff, $max ) > 0
182
+				if ($this->rangeCheckerHelper->getComparison($min, $diff) > 0 ||
183
+					$this->rangeCheckerHelper->getComparison($diff, $max) > 0
185 184
 				) {
186 185
 					// at least one of $min, $max is set at this point, otherwise there could be no violation
187
-					$openness = $min !== null ? ( $max !== null ? '' : '-rightopen' ) : '-leftopen';
188
-					$message = wfMessage( "wbqc-violation-message-diff-within-range$openness" );
186
+					$openness = $min !== null ? ($max !== null ? '' : '-rightopen') : '-leftopen';
187
+					$message = wfMessage("wbqc-violation-message-diff-within-range$openness");
189 188
 					$message->rawParams(
190
-						$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ),
191
-						$this->constraintParameterRenderer->formatDataValue( $minuend, Role::OBJECT ),
192
-						$this->constraintParameterRenderer->formatEntityId( $otherStatement->getPropertyId(), Role::PREDICATE ),
193
-						$this->constraintParameterRenderer->formatDataValue( $subtrahend, Role::OBJECT )
189
+						$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE),
190
+						$this->constraintParameterRenderer->formatDataValue($minuend, Role::OBJECT),
191
+						$this->constraintParameterRenderer->formatEntityId($otherStatement->getPropertyId(), Role::PREDICATE),
192
+						$this->constraintParameterRenderer->formatDataValue($subtrahend, Role::OBJECT)
194 193
 					);
195
-					if ( $min !== null ) {
196
-						$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) );
194
+					if ($min !== null) {
195
+						$message->rawParams($this->constraintParameterRenderer->formatDataValue($min, Role::OBJECT));
197 196
 					}
198
-					if ( $max !== null ) {
199
-						$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) );
197
+					if ($max !== null) {
198
+						$message->rawParams($this->constraintParameterRenderer->formatDataValue($max, Role::OBJECT));
200 199
 					}
201 200
 					$message = $message->escaped();
202 201
 					$status = CheckResult::STATUS_VIOLATION;
@@ -205,19 +204,19 @@  discard block
 block discarded – undo
205 204
 					$status = CheckResult::STATUS_COMPLIANCE;
206 205
 				}
207 206
 			} else {
208
-				$message = wfMessage( "wbqc-violation-message-diff-within-range-must-have-equal-types" )->escaped();
207
+				$message = wfMessage("wbqc-violation-message-diff-within-range-must-have-equal-types")->escaped();
209 208
 				$status = CheckResult::STATUS_VIOLATION;
210 209
 			}
211 210
 
212
-			return new CheckResult( $context, $constraint, $parameters, $status, $message );
211
+			return new CheckResult($context, $constraint, $parameters, $status, $message);
213 212
 		}
214 213
 
215
-		$message = wfMessage( "wbqc-violation-message-diff-within-range-property-must-exist" )->escaped();
214
+		$message = wfMessage("wbqc-violation-message-diff-within-range-property-must-exist")->escaped();
216 215
 		$status = CheckResult::STATUS_VIOLATION;
217
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
216
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
218 217
 	}
219 218
 
220
-	public function checkConstraintParameters( Constraint $constraint ) {
219
+	public function checkConstraintParameters(Constraint $constraint) {
221 220
 		$constraintParameters = $constraint->getConstraintParameters();
222 221
 		$exceptions = [];
223 222
 		try {
@@ -226,12 +225,12 @@  discard block
 block discarded – undo
226 225
 				$constraint->getConstraintTypeItemId(),
227 226
 				'quantity'
228 227
 			);
229
-		} catch ( ConstraintParameterException $e ) {
228
+		} catch (ConstraintParameterException $e) {
230 229
 			$exceptions[] = $e;
231 230
 		}
232 231
 		try {
233
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
234
-		} catch ( ConstraintParameterException $e ) {
232
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
233
+		} catch (ConstraintParameterException $e) {
235 234
 			$exceptions[] = $e;
236 235
 		}
237 236
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/MandatoryQualifiersChecker.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -70,43 +70,43 @@
 block discarded – undo
70 70
 	 * @throws ConstraintParameterException
71 71
 	 * @return CheckResult
72 72
 	 */
73
-	public function checkConstraint( Context $context, Constraint $constraint ) {
74
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
75
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
73
+	public function checkConstraint(Context $context, Constraint $constraint) {
74
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
75
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
76 76
 		}
77 77
 
78 78
 		$parameters = [];
79 79
 		$constraintParameters = $constraint->getConstraintParameters();
80 80
 
81
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
82
-		$parameters['property'] = [ $propertyId ];
81
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
82
+		$parameters['property'] = [$propertyId];
83 83
 
84
-		$message = wfMessage( "wbqc-violation-message-mandatory-qualifier" )
84
+		$message = wfMessage("wbqc-violation-message-mandatory-qualifier")
85 85
 				 ->rawParams(
86
-					 $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
87
-					 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::QUALIFIER_PREDICATE )
86
+					 $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
87
+					 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::QUALIFIER_PREDICATE)
88 88
 				 )
89 89
 				 ->escaped();
90 90
 		$status = CheckResult::STATUS_VIOLATION;
91 91
 
92 92
 		/** @var Snak $qualifier */
93
-		foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) {
94
-			if ( $propertyId->equals( $qualifier->getPropertyId() ) ) {
93
+		foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) {
94
+			if ($propertyId->equals($qualifier->getPropertyId())) {
95 95
 				$message = '';
96 96
 				$status = CheckResult::STATUS_COMPLIANCE;
97 97
 				break;
98 98
 			}
99 99
 		}
100 100
 
101
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
101
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
102 102
 	}
103 103
 
104
-	public function checkConstraintParameters( Constraint $constraint ) {
104
+	public function checkConstraintParameters(Constraint $constraint) {
105 105
 		$constraintParameters = $constraint->getConstraintParameters();
106 106
 		$exceptions = [];
107 107
 		try {
108
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
109
-		} catch ( ConstraintParameterException $e ) {
108
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
109
+		} catch (ConstraintParameterException $e) {
110 110
 			$exceptions[] = $e;
111 111
 		}
112 112
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/DelegatingConstraintChecker.php 1 patch
Spacing   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
 		callable $defaultResults = null
138 138
 	) {
139 139
 
140
-		$entity = $this->entityLookup->getEntity( $entityId );
141
-		if ( $entity instanceof StatementListProvider ) {
140
+		$entity = $this->entityLookup->getEntity($entityId);
141
+		if ($entity instanceof StatementListProvider) {
142 142
 			$result = $this->checkEveryStatement(
143
-				$this->entityLookup->getEntity( $entityId ),
143
+				$this->entityLookup->getEntity($entityId),
144 144
 				$constraintIds,
145 145
 				$defaultResults
146 146
 			);
147
-			$output = $this->sortResult( $result );
147
+			$output = $this->sortResult($result);
148 148
 			return $output;
149 149
 		}
150 150
 
@@ -170,19 +170,19 @@  discard block
 block discarded – undo
170 170
 		callable $defaultResults = null
171 171
 	) {
172 172
 
173
-		$parsedGuid = $this->statementGuidParser->parse( $guid );
173
+		$parsedGuid = $this->statementGuidParser->parse($guid);
174 174
 		$entityId = $parsedGuid->getEntityId();
175
-		$entity = $this->entityLookup->getEntity( $entityId );
176
-		if ( $entity instanceof StatementListProvider ) {
177
-			$statement = $entity->getStatements()->getFirstStatementWithGuid( $guid );
178
-			if ( $statement ) {
175
+		$entity = $this->entityLookup->getEntity($entityId);
176
+		if ($entity instanceof StatementListProvider) {
177
+			$statement = $entity->getStatements()->getFirstStatementWithGuid($guid);
178
+			if ($statement) {
179 179
 				$result = $this->checkStatement(
180 180
 					$entity,
181 181
 					$statement,
182 182
 					$constraintIds,
183 183
 					$defaultResults
184 184
 				);
185
-				$output = $this->sortResult( $result );
185
+				$output = $this->sortResult($result);
186 186
 				return $output;
187 187
 			}
188 188
 		}
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 		return [];
191 191
 	}
192 192
 
193
-	private function getAllowedContextTypes( Constraint $constraint ) {
194
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
193
+	private function getAllowedContextTypes(Constraint $constraint) {
194
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
195 195
 			return [
196 196
 				Context::TYPE_STATEMENT,
197 197
 				Context::TYPE_QUALIFIER,
@@ -199,12 +199,12 @@  discard block
 block discarded – undo
199 199
 			];
200 200
 		}
201 201
 
202
-		return array_keys( array_filter(
202
+		return array_keys(array_filter(
203 203
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedContextTypes(),
204
-			function ( $resultStatus ) {
204
+			function($resultStatus) {
205 205
 				return $resultStatus !== CheckResult::STATUS_NOT_IN_SCOPE;
206 206
 			}
207
-		) );
207
+		));
208 208
 	}
209 209
 
210 210
 	/**
@@ -215,32 +215,32 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return ConstraintParameterException[]
217 217
 	 */
218
-	private function checkCommonConstraintParameters( Constraint $constraint ) {
218
+	private function checkCommonConstraintParameters(Constraint $constraint) {
219 219
 		$constraintParameters = $constraint->getConstraintParameters();
220 220
 		try {
221
-			$this->constraintParameterParser->checkError( $constraintParameters );
222
-		} catch ( ConstraintParameterException $e ) {
223
-			return [ $e ];
221
+			$this->constraintParameterParser->checkError($constraintParameters);
222
+		} catch (ConstraintParameterException $e) {
223
+			return [$e];
224 224
 		}
225 225
 
226 226
 		$problems = [];
227 227
 		try {
228
-			$this->constraintParameterParser->parseExceptionParameter( $constraintParameters );
229
-		} catch ( ConstraintParameterException $e ) {
228
+			$this->constraintParameterParser->parseExceptionParameter($constraintParameters);
229
+		} catch (ConstraintParameterException $e) {
230 230
 			$problems[] = $e;
231 231
 		}
232 232
 		try {
233
-			$this->constraintParameterParser->parseConstraintStatusParameter( $constraintParameters );
234
-		} catch ( ConstraintParameterException $e ) {
233
+			$this->constraintParameterParser->parseConstraintStatusParameter($constraintParameters);
234
+		} catch (ConstraintParameterException $e) {
235 235
 			$problems[] = $e;
236 236
 		}
237 237
 		try {
238 238
 			$this->constraintParameterParser->parseConstraintScopeParameter(
239 239
 				$constraintParameters,
240 240
 				$constraint->getConstraintTypeItemId(),
241
-				$this->getAllowedContextTypes( $constraint )
241
+				$this->getAllowedContextTypes($constraint)
242 242
 			);
243
-		} catch ( ConstraintParameterException $e ) {
243
+		} catch (ConstraintParameterException $e) {
244 244
 			$problems[] = $e;
245 245
 		}
246 246
 		return $problems;
@@ -253,16 +253,16 @@  discard block
 block discarded – undo
253 253
 	 * @return ConstraintParameterException[][] first level indexed by constraint ID,
254 254
 	 * second level like checkConstraintParametersOnConstraintId (but without possibility of null)
255 255
 	 */
256
-	public function checkConstraintParametersOnPropertyId( PropertyId $propertyId ) {
257
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
256
+	public function checkConstraintParametersOnPropertyId(PropertyId $propertyId) {
257
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
258 258
 		$result = [];
259 259
 
260
-		foreach ( $constraints as $constraint ) {
261
-			$problems = $this->checkCommonConstraintParameters( $constraint );
260
+		foreach ($constraints as $constraint) {
261
+			$problems = $this->checkCommonConstraintParameters($constraint);
262 262
 
263
-			if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
263
+			if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
264 264
 				$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
265
-				$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
265
+				$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
266 266
 			}
267 267
 
268 268
 			$result[$constraint->getConstraintId()] = $problems;
@@ -279,17 +279,17 @@  discard block
 block discarded – undo
279 279
 	 * @return ConstraintParameterException[]|null list of constraint parameter exceptions
280 280
 	 * (empty means all parameters okay), or null if constraint is not found
281 281
 	 */
282
-	public function checkConstraintParametersOnConstraintId( $constraintId ) {
283
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
284
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
282
+	public function checkConstraintParametersOnConstraintId($constraintId) {
283
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
284
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
285 285
 
286
-		foreach ( $constraints as $constraint ) {
287
-			if ( $constraint->getConstraintId() === $constraintId ) {
288
-				$problems = $this->checkCommonConstraintParameters( $constraint );
286
+		foreach ($constraints as $constraint) {
287
+			if ($constraint->getConstraintId() === $constraintId) {
288
+				$problems = $this->checkCommonConstraintParameters($constraint);
289 289
 
290
-				if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
290
+				if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
291 291
 					$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
292
-					$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
292
+					$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
293 293
 				}
294 294
 
295 295
 				return $problems;
@@ -314,14 +314,14 @@  discard block
 block discarded – undo
314 314
 		$result = [];
315 315
 
316 316
 		/** @var Statement $statement */
317
-		foreach ( $entity->getStatements() as $statement ) {
318
-			$result = array_merge( $result,
317
+		foreach ($entity->getStatements() as $statement) {
318
+			$result = array_merge($result,
319 319
 				$this->checkStatement(
320 320
 					$entity,
321 321
 					$statement,
322 322
 					$constraintIds,
323 323
 					$defaultResults
324
-				) );
324
+				));
325 325
 		}
326 326
 
327 327
 		return $result;
@@ -343,32 +343,32 @@  discard block
 block discarded – undo
343 343
 	) {
344 344
 		$result = [];
345 345
 
346
-		$result = array_merge( $result,
346
+		$result = array_merge($result,
347 347
 			$this->checkConstraintsForMainSnak(
348 348
 				$entity,
349 349
 				$statement,
350 350
 				$constraintIds,
351 351
 				$defaultResults
352
-			) );
352
+			));
353 353
 
354
-		if ( $this->checkQualifiers ) {
355
-			$result = array_merge( $result,
354
+		if ($this->checkQualifiers) {
355
+			$result = array_merge($result,
356 356
 				$this->checkConstraintsForQualifiers(
357 357
 					$entity,
358 358
 					$statement,
359 359
 					$constraintIds,
360 360
 					$defaultResults
361
-				) );
361
+				));
362 362
 		}
363 363
 
364
-		if ( $this->checkReferences ) {
365
-			$result = array_merge( $result,
364
+		if ($this->checkReferences) {
365
+			$result = array_merge($result,
366 366
 				$this->checkConstraintsForReferences(
367 367
 					$entity,
368 368
 					$statement,
369 369
 					$constraintIds,
370 370
 					$defaultResults
371
-				) );
371
+				));
372 372
 		}
373 373
 
374 374
 		return $result;
@@ -383,12 +383,12 @@  discard block
 block discarded – undo
383 383
 	 * @param string[]|null $constraintIds
384 384
 	 * @return Constraint[]
385 385
 	 */
386
-	private function getConstraintsToUse( PropertyId $propertyId, array $constraintIds = null ) {
387
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
388
-		if ( $constraintIds !== null ) {
386
+	private function getConstraintsToUse(PropertyId $propertyId, array $constraintIds = null) {
387
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
388
+		if ($constraintIds !== null) {
389 389
 			$constraintsToUse = [];
390
-			foreach ( $constraints as $constraint ) {
391
-				if ( in_array( $constraint->getConstraintId(), $constraintIds ) ) {
390
+			foreach ($constraints as $constraint) {
391
+				if (in_array($constraint->getConstraintId(), $constraintIds)) {
392 392
 					$constraintsToUse[] = $constraint;
393 393
 				}
394 394
 			}
@@ -412,29 +412,29 @@  discard block
 block discarded – undo
412 412
 		array $constraintIds = null,
413 413
 		callable $defaultResults = null
414 414
 	) {
415
-		$context = new MainSnakContext( $entity, $statement );
415
+		$context = new MainSnakContext($entity, $statement);
416 416
 		$constraints = $this->getConstraintsToUse(
417 417
 			$statement->getPropertyId(),
418 418
 			$constraintIds
419 419
 		);
420
-		$result = $defaultResults !== null ? $defaultResults( $context ) : [];
420
+		$result = $defaultResults !== null ? $defaultResults($context) : [];
421 421
 
422
-		foreach ( $constraints as $constraint ) {
422
+		foreach ($constraints as $constraint) {
423 423
 			$parameters = $constraint->getConstraintParameters();
424 424
 			try {
425
-				$exceptions = $this->constraintParameterParser->parseExceptionParameter( $parameters );
426
-			} catch ( ConstraintParameterException $e ) {
427
-				$result[] = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage() );
425
+				$exceptions = $this->constraintParameterParser->parseExceptionParameter($parameters);
426
+			} catch (ConstraintParameterException $e) {
427
+				$result[] = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage());
428 428
 				continue;
429 429
 			}
430 430
 
431
-			if ( in_array( $entity->getId(), $exceptions ) ) {
432
-				$message = wfMessage( 'wbqc-exception-message' )->escaped();
433
-				$result[] = new CheckResult( $context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message );
431
+			if (in_array($entity->getId(), $exceptions)) {
432
+				$message = wfMessage('wbqc-exception-message')->escaped();
433
+				$result[] = new CheckResult($context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message);
434 434
 				continue;
435 435
 			}
436 436
 
437
-			$result[] = $this->getCheckResultFor( $context, $constraint );
437
+			$result[] = $this->getCheckResultFor($context, $constraint);
438 438
 		}
439 439
 
440 440
 		return $result;
@@ -456,24 +456,24 @@  discard block
 block discarded – undo
456 456
 	) {
457 457
 		$result = [];
458 458
 
459
-		if ( in_array(
459
+		if (in_array(
460 460
 			$statement->getPropertyId()->getSerialization(),
461 461
 			$this->propertiesWithViolatingQualifiers
462
-		) ) {
462
+		)) {
463 463
 			return $result;
464 464
 		}
465 465
 
466
-		foreach ( $statement->getQualifiers() as $qualifier ) {
467
-			$qualifierContext = new QualifierContext( $entity, $statement, $qualifier );
468
-			if ( $defaultResults !== null ) {
469
-				$result = array_merge( $result, $defaultResults( $qualifierContext ) );
466
+		foreach ($statement->getQualifiers() as $qualifier) {
467
+			$qualifierContext = new QualifierContext($entity, $statement, $qualifier);
468
+			if ($defaultResults !== null) {
469
+				$result = array_merge($result, $defaultResults($qualifierContext));
470 470
 			}
471 471
 			$qualifierConstraints = $this->getConstraintsToUse(
472 472
 				$qualifierContext->getSnak()->getPropertyId(),
473 473
 				$constraintIds
474 474
 			);
475
-			foreach ( $qualifierConstraints as $qualifierConstraint ) {
476
-				$result[] = $this->getCheckResultFor( $qualifierContext, $qualifierConstraint );
475
+			foreach ($qualifierConstraints as $qualifierConstraint) {
476
+				$result[] = $this->getCheckResultFor($qualifierContext, $qualifierConstraint);
477 477
 			}
478 478
 		}
479 479
 
@@ -497,19 +497,19 @@  discard block
 block discarded – undo
497 497
 		$result = [];
498 498
 
499 499
 		/** @var Reference $reference */
500
-		foreach ( $statement->getReferences() as $reference ) {
501
-			foreach ( $reference->getSnaks() as $snak ) {
500
+		foreach ($statement->getReferences() as $reference) {
501
+			foreach ($reference->getSnaks() as $snak) {
502 502
 				$referenceContext = new ReferenceContext(
503 503
 					$entity, $statement, $reference, $snak
504 504
 				);
505
-				if ( $defaultResults !== null ) {
506
-					$result = array_merge( $result, $defaultResults( $referenceContext ) );
505
+				if ($defaultResults !== null) {
506
+					$result = array_merge($result, $defaultResults($referenceContext));
507 507
 				}
508 508
 				$referenceConstraints = $this->getConstraintsToUse(
509 509
 					$referenceContext->getSnak()->getPropertyId(),
510 510
 					$constraintIds
511 511
 				);
512
-				foreach ( $referenceConstraints as $referenceConstraint ) {
512
+				foreach ($referenceConstraints as $referenceConstraint) {
513 513
 					$result[] = $this->getCheckResultFor(
514 514
 						$referenceContext,
515 515
 						$referenceConstraint
@@ -528,65 +528,65 @@  discard block
 block discarded – undo
528 528
 	 * @throws InvalidArgumentException
529 529
 	 * @return CheckResult
530 530
 	 */
531
-	private function getCheckResultFor( Context $context, Constraint $constraint ) {
532
-		if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
531
+	private function getCheckResultFor(Context $context, Constraint $constraint) {
532
+		if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
533 533
 			$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
534
-			$result = $this->handleScope( $checker, $context, $constraint );
534
+			$result = $this->handleScope($checker, $context, $constraint);
535 535
 
536
-			if ( $result !== null ) {
537
-				$this->addMetadata( $result );
536
+			if ($result !== null) {
537
+				$this->addMetadata($result);
538 538
 				return $result;
539 539
 			}
540 540
 
541
-			$startTime = microtime( true );
541
+			$startTime = microtime(true);
542 542
 			try {
543
-				$result = $checker->checkConstraint( $context, $constraint );
544
-			} catch ( ConstraintParameterException $e ) {
545
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage() );
546
-			} catch ( SparqlHelperException $e ) {
547
-				$message = wfMessage( 'wbqc-violation-message-sparql-error' )->escaped();
548
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message );
543
+				$result = $checker->checkConstraint($context, $constraint);
544
+			} catch (ConstraintParameterException $e) {
545
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage());
546
+			} catch (SparqlHelperException $e) {
547
+				$message = wfMessage('wbqc-violation-message-sparql-error')->escaped();
548
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message);
549 549
 			}
550
-			$endTime = microtime( true );
550
+			$endTime = microtime(true);
551 551
 
552
-			$this->addMetadata( $result );
552
+			$this->addMetadata($result);
553 553
 
554 554
 			try {
555 555
 				$constraintStatus = $this->constraintParameterParser
556
-					->parseConstraintStatusParameter( $constraint->getConstraintParameters() );
557
-			} catch ( ConstraintParameterException $e ) {
558
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage() );
556
+					->parseConstraintStatusParameter($constraint->getConstraintParameters());
557
+			} catch (ConstraintParameterException $e) {
558
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage());
559 559
 				$constraintStatus = null;
560 560
 			}
561
-			if ( $constraintStatus === null ) {
561
+			if ($constraintStatus === null) {
562 562
 				// downgrade violation to warning
563
-				if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
564
-					$result->setStatus( CheckResult::STATUS_WARNING );
563
+				if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
564
+					$result->setStatus(CheckResult::STATUS_WARNING);
565 565
 				}
566 566
 			} else {
567
-				if ( $constraintStatus !== 'mandatory' ) {
567
+				if ($constraintStatus !== 'mandatory') {
568 568
 					// @codeCoverageIgnoreStart
569 569
 					throw new LogicException(
570
-						"Unknown constraint status '$constraintStatus', " .
570
+						"Unknown constraint status '$constraintStatus', ".
571 571
 						"only known status is 'mandatory'"
572 572
 					);
573 573
 					// @codeCoverageIgnoreEnd
574 574
 				}
575
-				$result->addParameter( 'constraint_status', $constraintStatus );
575
+				$result->addParameter('constraint_status', $constraintStatus);
576 576
 			}
577 577
 
578 578
 			$this->loggingHelper->logConstraintCheck(
579 579
 				$context,
580 580
 				$constraint,
581 581
 				$result,
582
-				get_class( $checker ),
582
+				get_class($checker),
583 583
 				$endTime - $startTime,
584 584
 				__METHOD__
585 585
 			);
586 586
 
587 587
 			return $result;
588 588
 		} else {
589
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
589
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
590 590
 		}
591 591
 	}
592 592
 
@@ -600,29 +600,29 @@  discard block
 block discarded – undo
600 600
 				$constraint->getConstraintParameters(),
601 601
 				$constraint->getConstraintTypeItemId()
602 602
 			);
603
-		} catch ( ConstraintParameterException $e ) {
604
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage() );
603
+		} catch (ConstraintParameterException $e) {
604
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getMessage());
605 605
 		}
606
-		if ( $checkedContextTypes === null ) {
606
+		if ($checkedContextTypes === null) {
607 607
 			$checkedContextTypes = $checker->getDefaultContextTypes();
608 608
 		}
609
-		if ( !in_array( $context->getType(), $checkedContextTypes ) ) {
610
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null );
609
+		if (!in_array($context->getType(), $checkedContextTypes)) {
610
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null);
611 611
 		}
612
-		if ( $checker->getSupportedContextTypes()[$context->getType()] === CheckResult::STATUS_TODO ) {
613
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
612
+		if ($checker->getSupportedContextTypes()[$context->getType()] === CheckResult::STATUS_TODO) {
613
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
614 614
 		}
615 615
 		return null;
616 616
 	}
617 617
 
618
-	private function addMetadata( CheckResult $result ) {
619
-		$result->withMetadata( Metadata::merge( [
618
+	private function addMetadata(CheckResult $result) {
619
+		$result->withMetadata(Metadata::merge([
620 620
 			$result->getMetadata(),
621
-			Metadata::ofDependencyMetadata( DependencyMetadata::merge( [
622
-				DependencyMetadata::ofEntityId( $result->getEntityId() ),
623
-				DependencyMetadata::ofEntityId( $result->getConstraint()->getPropertyId() ),
624
-			] ) ),
625
-		] ) );
621
+			Metadata::ofDependencyMetadata(DependencyMetadata::merge([
622
+				DependencyMetadata::ofEntityId($result->getEntityId()),
623
+				DependencyMetadata::ofEntityId($result->getConstraint()->getPropertyId()),
624
+			])),
625
+		]));
626 626
 	}
627 627
 
628 628
 	/**
@@ -630,12 +630,12 @@  discard block
 block discarded – undo
630 630
 	 *
631 631
 	 * @return CheckResult[]
632 632
 	 */
633
-	private function sortResult( array $result ) {
634
-		if ( count( $result ) < 2 ) {
633
+	private function sortResult(array $result) {
634
+		if (count($result) < 2) {
635 635
 			return $result;
636 636
 		}
637 637
 
638
-		$sortFunction = function ( CheckResult $a, CheckResult $b ) {
638
+		$sortFunction = function(CheckResult $a, CheckResult $b) {
639 639
 			$orderNum = 0;
640 640
 			$order = [
641 641
 				CheckResult::STATUS_BAD_PARAMETERS => $orderNum++,
@@ -651,45 +651,45 @@  discard block
 block discarded – undo
651 651
 			$statusA = $a->getStatus();
652 652
 			$statusB = $b->getStatus();
653 653
 
654
-			$orderA = array_key_exists( $statusA, $order ) ? $order[ $statusA ] : $order[ 'other' ];
655
-			$orderB = array_key_exists( $statusB, $order ) ? $order[ $statusB ] : $order[ 'other' ];
654
+			$orderA = array_key_exists($statusA, $order) ? $order[$statusA] : $order['other'];
655
+			$orderB = array_key_exists($statusB, $order) ? $order[$statusB] : $order['other'];
656 656
 
657
-			if ( $orderA === $orderB ) {
657
+			if ($orderA === $orderB) {
658 658
 				$pidA = $a->getContext()->getSnak()->getPropertyId()->getSerialization();
659 659
 				$pidB = $b->getContext()->getSnak()->getPropertyId()->getSerialization();
660 660
 
661
-				if ( $pidA === $pidB ) {
661
+				if ($pidA === $pidB) {
662 662
 					$hashA = $a->getContext()->getSnak()->getHash();
663 663
 					$hashB = $b->getContext()->getSnak()->getHash();
664 664
 
665
-					if ( $hashA === $hashB ) {
666
-						if ( $a instanceof NullResult ) {
665
+					if ($hashA === $hashB) {
666
+						if ($a instanceof NullResult) {
667 667
 							return $b instanceof NullResult ? 0 : -1;
668 668
 						}
669
-						if ( $b instanceof NullResult ) {
669
+						if ($b instanceof NullResult) {
670 670
 							return $a instanceof NullResult ? 0 : 1;
671 671
 						}
672 672
 
673 673
 						$typeA = $a->getConstraint()->getConstraintTypeItemId();
674 674
 						$typeB = $b->getConstraint()->getConstraintTypeItemId();
675 675
 
676
-						if ( $typeA == $typeB ) {
676
+						if ($typeA == $typeB) {
677 677
 							return 0;
678 678
 						} else {
679
-							return ( $typeA > $typeB ) ? 1 : -1;
679
+							return ($typeA > $typeB) ? 1 : -1;
680 680
 						}
681 681
 					} else {
682
-						return ( $hashA > $hashB ) ? 1 : -1;
682
+						return ($hashA > $hashB) ? 1 : -1;
683 683
 					}
684 684
 				} else {
685
-					return ( $pidA > $pidB ) ? 1 : -1;
685
+					return ($pidA > $pidB) ? 1 : -1;
686 686
 				}
687 687
 			} else {
688
-				return ( $orderA > $orderB ) ? 1 : -1;
688
+				return ($orderA > $orderB) ? 1 : -1;
689 689
 			}
690 690
 		};
691 691
 
692
-		uasort( $result, $sortFunction );
692
+		uasort($result, $sortFunction);
693 693
 
694 694
 		return $result;
695 695
 	}
Please login to merge, or discard this patch.
src/WikibaseQualityConstraintsHooks.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -30,36 +30,36 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return bool
32 32
 	 */
33
-	public static function onCreateSchema( DatabaseUpdater $updater ) {
34
-		$updater->addExtensionTable( 'wbqc_constraints', __DIR__ . '/../sql/create_wbqc_constraints.sql' );
33
+	public static function onCreateSchema(DatabaseUpdater $updater) {
34
+		$updater->addExtensionTable('wbqc_constraints', __DIR__.'/../sql/create_wbqc_constraints.sql');
35 35
 		return true;
36 36
 	}
37 37
 
38
-	public static function onWikibaseChange( Change $change ) {
38
+	public static function onWikibaseChange(Change $change) {
39 39
 		$config = MediaWikiServices::getInstance()->getMainConfig();
40
-		if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) &&
41
-			self::isConstraintStatementsChange( $config, $change )
40
+		if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') &&
41
+			self::isConstraintStatementsChange($config, $change)
42 42
 		) {
43 43
 			/** @var EntityChange $change */
44 44
 			$title = Title::newMainPage();
45
-			$params = [ 'propertyId' => $change->getEntityId()->getSerialization() ];
45
+			$params = ['propertyId' => $change->getEntityId()->getSerialization()];
46 46
 			JobQueueGroup::singleton()->push(
47
-				new JobSpecification( 'constraintsTableUpdate', $params, [], $title )
47
+				new JobSpecification('constraintsTableUpdate', $params, [], $title)
48 48
 			);
49 49
 		}
50 50
 	}
51 51
 
52
-	public static function isConstraintStatementsChange( Config $config, Change $change ) {
53
-		if ( !( $change instanceof EntityChange ) ||
52
+	public static function isConstraintStatementsChange(Config $config, Change $change) {
53
+		if (!($change instanceof EntityChange) ||
54 54
 			 $change->getAction() !== EntityChange::UPDATE ||
55
-			 !( $change->getEntityId() instanceof PropertyId )
55
+			 !($change->getEntityId() instanceof PropertyId)
56 56
 		) {
57 57
 			return false;
58 58
 		}
59 59
 
60 60
 		$info = $change->getInfo();
61 61
 
62
-		if ( !array_key_exists( 'compactDiff', $info ) ) {
62
+		if (!array_key_exists('compactDiff', $info)) {
63 63
 			// the non-compact diff ($info['diff']) does not contain statement diffs (T110996),
64 64
 			// so we only know that the change *might* affect the constraint statements
65 65
 			return true;
@@ -68,18 +68,18 @@  discard block
 block discarded – undo
68 68
 		/** @var EntityDiffChangedAspects $aspects */
69 69
 		$aspects = $info['compactDiff'];
70 70
 
71
-		$propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' );
72
-		return in_array( $propertyConstraintId, $aspects->getStatementChanges() );
71
+		$propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId');
72
+		return in_array($propertyConstraintId, $aspects->getStatementChanges());
73 73
 	}
74 74
 
75
-	public static function onArticlePurge( WikiPage $wikiPage ) {
75
+	public static function onArticlePurge(WikiPage $wikiPage) {
76 76
 		$repo = WikibaseRepo::getDefaultInstance();
77 77
 
78 78
 		$entityContentFactory = $repo->getEntityContentFactory();
79
-		if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) {
80
-			$entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() );
79
+		if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) {
80
+			$entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle());
81 81
 			$resultsCache = ResultsCache::getDefaultInstance();
82
-			$resultsCache->delete( $entityId );
82
+			$resultsCache->delete($entityId);
83 83
 		}
84 84
 	}
85 85
 
@@ -88,18 +88,18 @@  discard block
 block discarded – undo
88 88
 	 * @param int $timestamp UTC timestamp (seconds since the Epoch)
89 89
 	 * @return bool
90 90
 	 */
91
-	public static function isGadgetEnabledForUserName( $userName, $timestamp ) {
91
+	public static function isGadgetEnabledForUserName($userName, $timestamp) {
92 92
 		$initial = $userName[0];
93 93
 
94
-		if ( $initial === 'Z' ) {
94
+		if ($initial === 'Z') {
95 95
 			$firstWeek = 0;
96
-		} elseif ( $initial >= 'W' && $initial < 'Z' ) {
96
+		} elseif ($initial >= 'W' && $initial < 'Z') {
97 97
 			$firstWeek = 1;
98
-		} elseif ( $initial >= 'T' && $initial < 'W' ) {
98
+		} elseif ($initial >= 'T' && $initial < 'W') {
99 99
 			$firstWeek = 2;
100
-		} elseif ( $initial >= 'N' && $initial < 'T' ) {
100
+		} elseif ($initial >= 'N' && $initial < 'T') {
101 101
 			$firstWeek = 3;
102
-		} elseif ( $initial >= 'E' && $initial < 'N' ) {
102
+		} elseif ($initial >= 'E' && $initial < 'N') {
103 103
 			$firstWeek = 4;
104 104
 		} else {
105 105
 			$firstWeek = 5;
@@ -117,24 +117,24 @@  discard block
 block discarded – undo
117 117
 		return $timestamp >= $threshold;
118 118
 	}
119 119
 
120
-	public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
120
+	public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin) {
121 121
 		$repo = WikibaseRepo::getDefaultInstance();
122 122
 
123 123
 		$lookup = $repo->getEntityNamespaceLookup();
124 124
 		$title = $out->getTitle();
125
-		if ( $title === null ) {
125
+		if ($title === null) {
126 126
 			return;
127 127
 		}
128 128
 
129
-		if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) {
129
+		if (!$lookup->isEntityNamespace($title->getNamespace())) {
130 130
 			return;
131 131
 		}
132
-		if ( !$out->getUser()->isLoggedIn() ) {
132
+		if (!$out->getUser()->isLoggedIn()) {
133 133
 			return;
134 134
 		}
135 135
 
136
-		if ( self::isGadgetEnabledForUserName( $out->getUser()->getName(), time() ) ) {
137
-			$out->addModules( 'wikibase.quality.constraints.gadget' );
136
+		if (self::isGadgetEnabledForUserName($out->getUser()->getName(), time())) {
137
+			$out->addModules('wikibase.quality.constraints.gadget');
138 138
 		}
139 139
 	}
140 140
 
Please login to merge, or discard this patch.
src/ConstraintCheck/ItemIdSnakValue.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param ItemId $itemId
45 45
 	 * @return self
46 46
 	 */
47
-	public static function fromItemId( ItemId $itemId ) {
47
+	public static function fromItemId(ItemId $itemId) {
48 48
 		$ret = new self;
49 49
 		$ret->itemId = $itemId;
50 50
 		return $ret;
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	 * @throws InvalidArgumentException
81 81
 	 * @return self
82 82
 	 */
83
-	public static function fromSnak( Snak $snak ) {
84
-		switch ( true ) {
83
+	public static function fromSnak(Snak $snak) {
84
+		switch (true) {
85 85
 			case $snak instanceof PropertyValueSnak:
86 86
 				$dataValue = $snak->getDataValue();
87
-				if ( $dataValue instanceof EntityIdValue
87
+				if ($dataValue instanceof EntityIdValue
88 88
 					&& $dataValue->getEntityId() instanceof ItemId
89 89
 				) {
90
-					return self::fromItemId( $dataValue->getEntityId() );
90
+					return self::fromItemId($dataValue->getEntityId());
91 91
 				}
92 92
 				break;
93 93
 			case $snak instanceof PropertySomeValueSnak:
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 				return self::noValue();
97 97
 		}
98 98
 
99
-		throw new InvalidArgumentException( 'Snak must contain item ID value or be a somevalue / novalue snak' );
99
+		throw new InvalidArgumentException('Snak must contain item ID value or be a somevalue / novalue snak');
100 100
 	}
101 101
 
102 102
 	/**
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 	 * @return ItemId
134 134
 	 */
135 135
 	public function getItemId() {
136
-		if ( ! $this->isValue() ) {
137
-			throw new DomainException( 'This value does not contain an item ID.' );
136
+		if (!$this->isValue()) {
137
+			throw new DomainException('This value does not contain an item ID.');
138 138
 		}
139 139
 		return $this->itemId;
140 140
 	}
@@ -146,13 +146,13 @@  discard block
 block discarded – undo
146 146
 	 * @param Snak $snak
147 147
 	 * @return bool
148 148
 	 */
149
-	public function matchesSnak( Snak $snak ) {
150
-		switch ( true ) {
149
+	public function matchesSnak(Snak $snak) {
150
+		switch (true) {
151 151
 			case $snak instanceof PropertyValueSnak:
152 152
 				return $this->isValue() &&
153 153
 					$snak->getDataValue() instanceof EntityIdValue &&
154 154
 					$snak->getDataValue()->getEntityId() instanceof ItemId &&
155
-					$snak->getDataValue()->getEntityId()->equals( $this->getItemId() );
155
+					$snak->getDataValue()->getEntityId()->equals($this->getItemId());
156 156
 			case $snak instanceof PropertySomeValueSnak:
157 157
 				return $this->isSomeValue();
158 158
 			case $snak instanceof PropertyNoValueSnak:
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConnectionCheckerHelper.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 		StatementList $statementList,
31 31
 		PropertyId $propertyId
32 32
 	) {
33
-		$statementListByPropertyId = $statementList->getByPropertyId( $propertyId );
34
-		if ( $statementListByPropertyId->isEmpty() ) {
33
+		$statementListByPropertyId = $statementList->getByPropertyId($propertyId);
34
+		if ($statementListByPropertyId->isEmpty()) {
35 35
 			return null;
36 36
 		} else {
37 37
 			return $statementListByPropertyId->toArray()[0];
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 		PropertyId $propertyId,
53 53
 		EntityId $value
54 54
 	) {
55
-		$statementListByPropertyId = $statementList->getByPropertyId( $propertyId );
55
+		$statementListByPropertyId = $statementList->getByPropertyId($propertyId);
56 56
 		/** @var Statement $statement */
57
-		foreach ( $statementListByPropertyId as $statement ) {
57
+		foreach ($statementListByPropertyId as $statement) {
58 58
 			$snak = $statement->getMainSnak();
59
-			if ( $snak instanceof PropertyValueSnak ) {
59
+			if ($snak instanceof PropertyValueSnak) {
60 60
 				$dataValue = $snak->getDataValue();
61
-				if ( $dataValue instanceof EntityIdValue &&
62
-					$dataValue->getEntityId()->equals( $value )
61
+				if ($dataValue instanceof EntityIdValue &&
62
+					$dataValue->getEntityId()->equals($value)
63 63
 				) {
64 64
 					return $statement;
65 65
 				}
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 		PropertyId $propertyId,
83 83
 		array $values
84 84
 	) {
85
-		$statementListByPropertyId = $statementList->getByPropertyId( $propertyId );
85
+		$statementListByPropertyId = $statementList->getByPropertyId($propertyId);
86 86
 		/** @var Statement $statement */
87
-		foreach ( $statementListByPropertyId as $statement ) {
87
+		foreach ($statementListByPropertyId as $statement) {
88 88
 			$snak = $statement->getMainSnak();
89
-			foreach ( $values as $value ) {
90
-				if ( $value->matchesSnak( $snak ) ) {
89
+			foreach ($values as $value) {
90
+				if ($value->matchesSnak($snak)) {
91 91
 					return $statement;
92 92
 				}
93 93
 			}
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
 	 * @param array $parameters
78 78
 	 * @throws ConstraintParameterException
79 79
 	 */
80
-	public function checkError( array $parameters ) {
81
-		if ( array_key_exists( '@error', $parameters ) ) {
80
+	public function checkError(array $parameters) {
81
+		if (array_key_exists('@error', $parameters)) {
82 82
 			$error = $parameters['@error'];
83
-			if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) {
83
+			if (array_key_exists('toolong', $error) && $error['toolong']) {
84 84
 				$msg = 'wbqc-violation-message-parameters-error-toolong';
85 85
 			} else {
86 86
 				$msg = 'wbqc-violation-message-parameters-error-unknown';
87 87
 			}
88
-			throw new ConstraintParameterException( wfMessage( $msg )->escaped() );
88
+			throw new ConstraintParameterException(wfMessage($msg)->escaped());
89 89
 		}
90 90
 	}
91 91
 
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 	 * @param string $parameterId
96 96
 	 * @throws ConstraintParameterException
97 97
 	 */
98
-	private function requireSingleParameter( array $parameters, $parameterId ) {
99
-		if ( count( $parameters[$parameterId] ) !== 1 ) {
98
+	private function requireSingleParameter(array $parameters, $parameterId) {
99
+		if (count($parameters[$parameterId]) !== 1) {
100 100
 			throw new ConstraintParameterException(
101
-				wfMessage( 'wbqc-violation-message-parameter-single' )
102
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
101
+				wfMessage('wbqc-violation-message-parameter-single')
102
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY))
103 103
 					->escaped()
104 104
 			);
105 105
 		}
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 	 * @return void
113 113
 	 * @throws ConstraintParameterException
114 114
 	 */
115
-	private function requireValueParameter( Snak $snak, $parameterId ) {
116
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
115
+	private function requireValueParameter(Snak $snak, $parameterId) {
116
+		if (!($snak instanceof PropertyValueSnak)) {
117 117
 			throw new ConstraintParameterException(
118
-				wfMessage( 'wbqc-violation-message-parameter-value' )
119
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
118
+				wfMessage('wbqc-violation-message-parameter-value')
119
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY))
120 120
 					->escaped()
121 121
 			);
122 122
 		}
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
 	 * @throws ConstraintParameterException
130 130
 	 * @return EntityId
131 131
 	 */
132
-	private function parseEntityIdParameter( array $snakSerialization, $parameterId ) {
133
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
134
-		$this->requireValueParameter( $snak, $parameterId );
132
+	private function parseEntityIdParameter(array $snakSerialization, $parameterId) {
133
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
134
+		$this->requireValueParameter($snak, $parameterId);
135 135
 		$value = $snak->getDataValue();
136
-		if ( $value instanceof EntityIdValue ) {
136
+		if ($value instanceof EntityIdValue) {
137 137
 			return $value->getEntityId();
138 138
 		} else {
139 139
 			throw new ConstraintParameterException(
140
-				wfMessage( 'wbqc-violation-message-parameter-entity' )
140
+				wfMessage('wbqc-violation-message-parameter-entity')
141 141
 					->rawParams(
142
-						$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
143
-						$this->constraintParameterRenderer->formatDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
142
+						$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
143
+						$this->constraintParameterRenderer->formatDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
144 144
 					)
145 145
 					->escaped()
146 146
 			);
@@ -153,21 +153,21 @@  discard block
 block discarded – undo
153 153
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
154 154
 	 * @return string[] class entity ID serializations
155 155
 	 */
156
-	public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) {
157
-		$this->checkError( $constraintParameters );
158
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
159
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
156
+	public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) {
157
+		$this->checkError($constraintParameters);
158
+		$classId = $this->config->get('WBQualityConstraintsClassId');
159
+		if (!array_key_exists($classId, $constraintParameters)) {
160 160
 			throw new ConstraintParameterException(
161
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
162
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
163
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $classId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
161
+				wfMessage('wbqc-violation-message-parameter-needed')
162
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
163
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($classId, Role::CONSTRAINT_PARAMETER_PROPERTY))
164 164
 					->escaped()
165 165
 			);
166 166
 		}
167 167
 
168 168
 		$classes = [];
169
-		foreach ( $constraintParameters[$classId] as $class ) {
170
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
169
+		foreach ($constraintParameters[$classId] as $class) {
170
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
171 171
 		}
172 172
 		return $classes;
173 173
 	}
@@ -178,33 +178,33 @@  discard block
 block discarded – undo
178 178
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
179 179
 	 * @return string 'instance' or 'subclass'
180 180
 	 */
181
-	public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) {
182
-		$this->checkError( $constraintParameters );
183
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
184
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
181
+	public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) {
182
+		$this->checkError($constraintParameters);
183
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
184
+		if (!array_key_exists($relationId, $constraintParameters)) {
185 185
 			throw new ConstraintParameterException(
186
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
187
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
188
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $relationId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
186
+				wfMessage('wbqc-violation-message-parameter-needed')
187
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
188
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($relationId, Role::CONSTRAINT_PARAMETER_PROPERTY))
189 189
 					->escaped()
190 190
 			);
191 191
 		}
192 192
 
193
-		$this->requireSingleParameter( $constraintParameters, $relationId );
194
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
195
-		$instanceId = $this->config->get( 'WBQualityConstraintsInstanceOfRelationId' );
196
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfRelationId' );
197
-		switch ( $relationEntityId ) {
193
+		$this->requireSingleParameter($constraintParameters, $relationId);
194
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
195
+		$instanceId = $this->config->get('WBQualityConstraintsInstanceOfRelationId');
196
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfRelationId');
197
+		switch ($relationEntityId) {
198 198
 			case $instanceId:
199 199
 				return 'instance';
200 200
 			case $subclassId:
201 201
 				return 'subclass';
202 202
 			default:
203 203
 				throw new ConstraintParameterException(
204
-					wfMessage( 'wbqc-violation-message-parameter-oneof' )
205
-						->rawParams( $this->constraintParameterRenderer->formatPropertyId( $relationId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
206
-						->numParams( 2 )
207
-						->rawParams( $this->constraintParameterRenderer->formatItemIdList( [ $instanceId, $subclassId ], Role::CONSTRAINT_PARAMETER_VALUE ) )
204
+					wfMessage('wbqc-violation-message-parameter-oneof')
205
+						->rawParams($this->constraintParameterRenderer->formatPropertyId($relationId, Role::CONSTRAINT_PARAMETER_PROPERTY))
206
+						->numParams(2)
207
+						->rawParams($this->constraintParameterRenderer->formatItemIdList([$instanceId, $subclassId], Role::CONSTRAINT_PARAMETER_VALUE))
208 208
 						->escaped()
209 209
 				);
210 210
 		}
@@ -217,21 +217,21 @@  discard block
 block discarded – undo
217 217
 	 * @throws ConstraintParameterException
218 218
 	 * @return PropertyId
219 219
 	 */
220
-	private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) {
221
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
222
-		$this->requireValueParameter( $snak, $parameterId );
220
+	private function parsePropertyIdParameter(array $snakSerialization, $parameterId) {
221
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
222
+		$this->requireValueParameter($snak, $parameterId);
223 223
 		$value = $snak->getDataValue();
224
-		if ( $value instanceof EntityIdValue ) {
224
+		if ($value instanceof EntityIdValue) {
225 225
 			$id = $value->getEntityId();
226
-			if ( $id instanceof PropertyId ) {
226
+			if ($id instanceof PropertyId) {
227 227
 				return $id;
228 228
 			}
229 229
 		}
230 230
 		throw new ConstraintParameterException(
231
-			wfMessage( 'wbqc-violation-message-parameter-property' )
231
+			wfMessage('wbqc-violation-message-parameter-property')
232 232
 				->rawParams(
233
-					$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
234
-					$this->constraintParameterRenderer->formatDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
233
+					$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
234
+					$this->constraintParameterRenderer->formatDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
235 235
 				)
236 236
 				->escaped()
237 237
 		);
@@ -244,34 +244,34 @@  discard block
 block discarded – undo
244 244
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
245 245
 	 * @return PropertyId
246 246
 	 */
247
-	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
248
-		$this->checkError( $constraintParameters );
249
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
250
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
247
+	public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) {
248
+		$this->checkError($constraintParameters);
249
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
250
+		if (!array_key_exists($propertyId, $constraintParameters)) {
251 251
 			throw new ConstraintParameterException(
252
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
253
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
254
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
252
+				wfMessage('wbqc-violation-message-parameter-needed')
253
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
254
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY))
255 255
 					->escaped()
256 256
 			);
257 257
 		}
258 258
 
259
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
260
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
259
+		$this->requireSingleParameter($constraintParameters, $propertyId);
260
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
261 261
 	}
262 262
 
263
-	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
263
+	private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) {
264 264
 		$dataValue = $snak->getDataValue();
265
-		if ( $dataValue instanceof EntityIdValue &&
265
+		if ($dataValue instanceof EntityIdValue &&
266 266
 			$dataValue->getEntityId() instanceof ItemId
267 267
 		) {
268
-			return ItemIdSnakValue::fromItemId( $dataValue->getEntityId() );
268
+			return ItemIdSnakValue::fromItemId($dataValue->getEntityId());
269 269
 		} else {
270 270
 			throw new ConstraintParameterException(
271
-				wfMessage( 'wbqc-violation-message-parameter-item' )
271
+				wfMessage('wbqc-violation-message-parameter-item')
272 272
 					->rawParams(
273
-						$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
274
-						$this->constraintParameterRenderer->formatDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
273
+						$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
274
+						$this->constraintParameterRenderer->formatDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
275 275
 					)
276 276
 					->escaped()
277 277
 			);
@@ -285,15 +285,15 @@  discard block
 block discarded – undo
285 285
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
286 286
 	 * @return ItemIdSnakValue[] array of values
287 287
 	 */
288
-	public function parseItemsParameter( array $constraintParameters, $constraintTypeItemId, $required ) {
289
-		$this->checkError( $constraintParameters );
290
-		$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
291
-		if ( !array_key_exists( $qualifierId, $constraintParameters ) ) {
292
-			if ( $required ) {
288
+	public function parseItemsParameter(array $constraintParameters, $constraintTypeItemId, $required) {
289
+		$this->checkError($constraintParameters);
290
+		$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
291
+		if (!array_key_exists($qualifierId, $constraintParameters)) {
292
+			if ($required) {
293 293
 				throw new ConstraintParameterException(
294
-					wfMessage( 'wbqc-violation-message-parameter-needed' )
295
-						->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
296
-						->rawParams( $this->constraintParameterRenderer->formatPropertyId( $qualifierId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
294
+					wfMessage('wbqc-violation-message-parameter-needed')
295
+						->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
296
+						->rawParams($this->constraintParameterRenderer->formatPropertyId($qualifierId, Role::CONSTRAINT_PARAMETER_PROPERTY))
297 297
 						->escaped()
298 298
 				);
299 299
 			} else {
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
 		}
303 303
 
304 304
 		$values = [];
305
-		foreach ( $constraintParameters[$qualifierId] as $parameter ) {
306
-			$snak = $this->snakDeserializer->deserialize( $parameter );
307
-			switch ( true ) {
305
+		foreach ($constraintParameters[$qualifierId] as $parameter) {
306
+			$snak = $this->snakDeserializer->deserialize($parameter);
307
+			switch (true) {
308 308
 				case $snak instanceof PropertyValueSnak:
309
-					$values[] = $this->parseItemIdParameter( $snak, $qualifierId );
309
+					$values[] = $this->parseItemIdParameter($snak, $qualifierId);
310 310
 					break;
311 311
 				case $snak instanceof PropertySomeValueSnak:
312 312
 					$values[] = ItemIdSnakValue::someValue();
@@ -325,28 +325,28 @@  discard block
 block discarded – undo
325 325
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
326 326
 	 * @return PropertyId[]
327 327
 	 */
328
-	public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) {
329
-		$this->checkError( $constraintParameters );
330
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
331
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
328
+	public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) {
329
+		$this->checkError($constraintParameters);
330
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
331
+		if (!array_key_exists($propertyId, $constraintParameters)) {
332 332
 			throw new ConstraintParameterException(
333
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
334
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
335
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
333
+				wfMessage('wbqc-violation-message-parameter-needed')
334
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
335
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($propertyId, Role::CONSTRAINT_PARAMETER_PROPERTY))
336 336
 					->escaped()
337 337
 			);
338 338
 		}
339 339
 
340 340
 		$parameters = $constraintParameters[$propertyId];
341
-		if ( count( $parameters ) === 1 &&
342
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
341
+		if (count($parameters) === 1 &&
342
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
343 343
 		) {
344 344
 			return [];
345 345
 		}
346 346
 
347 347
 		$properties = [];
348
-		foreach ( $parameters as $parameter ) {
349
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
348
+		foreach ($parameters as $parameter) {
349
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
350 350
 		}
351 351
 		return $properties;
352 352
 	}
@@ -357,16 +357,16 @@  discard block
 block discarded – undo
357 357
 	 * @throws ConstraintParameterException
358 358
 	 * @return DataValue|null
359 359
 	 */
360
-	private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) {
361
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
362
-		if ( $snak instanceof PropertyValueSnak ) {
360
+	private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) {
361
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
362
+		if ($snak instanceof PropertyValueSnak) {
363 363
 			return $snak->getDataValue();
364
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
364
+		} elseif ($snak instanceof PropertyNoValueSnak) {
365 365
 			return null;
366 366
 		} else {
367 367
 			throw new ConstraintParameterException(
368
-				wfMessage( 'wbqc-violation-message-parameter-value-or-novalue' )
369
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
368
+				wfMessage('wbqc-violation-message-parameter-value-or-novalue')
369
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY))
370 370
 					->escaped()
371 371
 			);
372 372
 		}
@@ -377,13 +377,13 @@  discard block
 block discarded – undo
377 377
 	 * @param string $parameterId
378 378
 	 * @return DataValue|null
379 379
 	 */
380
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) {
380
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) {
381 381
 		try {
382
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
383
-		} catch ( ConstraintParameterException $e ) {
382
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
383
+		} catch (ConstraintParameterException $e) {
384 384
 			// unknown value means “now”
385
-			$timeParser = ( new TimeParserFactory() )->getTimeParser();
386
-			return $timeParser->parse( gmdate( '+Y-m-d\T00:00:00\Z' ) );
385
+			$timeParser = (new TimeParserFactory())->getTimeParser();
386
+			return $timeParser->parse(gmdate('+Y-m-d\T00:00:00\Z'));
387 387
 		}
388 388
 	}
389 389
 
@@ -394,14 +394,14 @@  discard block
 block discarded – undo
394 394
 	 * @param string $unit
395 395
 	 * @return bool
396 396
 	 */
397
-	private function exactlyOneQuantityWithUnit( DataValue $min = null, DataValue $max = null, $unit ) {
398
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
399
-			!( $max instanceof UnboundedQuantityValue )
397
+	private function exactlyOneQuantityWithUnit(DataValue $min = null, DataValue $max = null, $unit) {
398
+		if (!($min instanceof UnboundedQuantityValue) ||
399
+			!($max instanceof UnboundedQuantityValue)
400 400
 		) {
401 401
 			return false;
402 402
 		}
403 403
 
404
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
404
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
405 405
 	}
406 406
 
407 407
 	/**
@@ -412,9 +412,9 @@  discard block
 block discarded – undo
412 412
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
413 413
 	 * @return DataValue[] a pair of two quantity-type data values, either of which may be null to signify an open range
414 414
 	 */
415
-	public function parseRangeParameter( array $constraintParameters, $constraintTypeItemId, $type ) {
416
-		$this->checkError( $constraintParameters );
417
-		switch ( $type ) {
415
+	public function parseRangeParameter(array $constraintParameters, $constraintTypeItemId, $type) {
416
+		$this->checkError($constraintParameters);
417
+		switch ($type) {
418 418
 			case 'quantity':
419 419
 				$configKey = 'Quantity';
420 420
 				break;
@@ -423,46 +423,46 @@  discard block
 block discarded – undo
423 423
 				break;
424 424
 			default:
425 425
 				throw new ConstraintParameterException(
426
-					wfMessage( 'wbqc-violation-message-value-needed-of-types-2' )
426
+					wfMessage('wbqc-violation-message-value-needed-of-types-2')
427 427
 						->rawParams(
428
-							wfMessage( 'datatypes-type-quantity' )->escaped(),
429
-							wfMessage( 'datatypes-type-time' )->escaped()
428
+							wfMessage('datatypes-type-quantity')->escaped(),
429
+							wfMessage('datatypes-type-time')->escaped()
430 430
 						)
431 431
 						->escaped()
432 432
 				);
433 433
 		}
434
-		$minimumId = $this->config->get( 'WBQualityConstraintsMinimum' . $configKey . 'Id' );
435
-		$maximumId = $this->config->get( 'WBQualityConstraintsMaximum' . $configKey . 'Id' );
436
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
437
-			!array_key_exists( $maximumId, $constraintParameters )
434
+		$minimumId = $this->config->get('WBQualityConstraintsMinimum'.$configKey.'Id');
435
+		$maximumId = $this->config->get('WBQualityConstraintsMaximum'.$configKey.'Id');
436
+		if (!array_key_exists($minimumId, $constraintParameters) ||
437
+			!array_key_exists($maximumId, $constraintParameters)
438 438
 		) {
439 439
 			throw new ConstraintParameterException(
440
-				wfMessage( 'wbqc-violation-message-range-parameters-needed' )
440
+				wfMessage('wbqc-violation-message-range-parameters-needed')
441 441
 					->rawParams(
442
-						wfMessage( 'datatypes-type-' . $type )->escaped(),
443
-						$this->constraintParameterRenderer->formatPropertyId( $minimumId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
444
-						$this->constraintParameterRenderer->formatPropertyId( $maximumId, Role::CONSTRAINT_PARAMETER_PROPERTY )
442
+						wfMessage('datatypes-type-'.$type)->escaped(),
443
+						$this->constraintParameterRenderer->formatPropertyId($minimumId, Role::CONSTRAINT_PARAMETER_PROPERTY),
444
+						$this->constraintParameterRenderer->formatPropertyId($maximumId, Role::CONSTRAINT_PARAMETER_PROPERTY)
445 445
 					)
446
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
446
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
447 447
 					->escaped()
448 448
 			);
449 449
 		}
450 450
 
451
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
452
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
451
+		$this->requireSingleParameter($constraintParameters, $minimumId);
452
+		$this->requireSingleParameter($constraintParameters, $maximumId);
453 453
 		$parseFunction = $configKey === 'Date' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
454
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
455
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
454
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
455
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
456 456
 
457
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
458
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
457
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
458
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
459 459
 			throw new ConstraintParameterException(
460
-				wfMessage( 'wbqc-violation-message-range-parameters-one-year' )
460
+				wfMessage('wbqc-violation-message-range-parameters-one-year')
461 461
 					->escaped()
462 462
 			);
463 463
 		}
464 464
 
465
-		return [ $min, $max ];
465
+		return [$min, $max];
466 466
 	}
467 467
 
468 468
 	/**
@@ -472,18 +472,18 @@  discard block
 block discarded – undo
472 472
 	 * @throws ConstraintParameterException
473 473
 	 * @return string
474 474
 	 */
475
-	private function parseStringParameter( array $snakSerialization, $parameterId ) {
476
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
477
-		$this->requireValueParameter( $snak, $parameterId );
475
+	private function parseStringParameter(array $snakSerialization, $parameterId) {
476
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
477
+		$this->requireValueParameter($snak, $parameterId);
478 478
 		$value = $snak->getDataValue();
479
-		if ( $value instanceof StringValue ) {
479
+		if ($value instanceof StringValue) {
480 480
 			return $value->getValue();
481 481
 		} else {
482 482
 			throw new ConstraintParameterException(
483
-				wfMessage( 'wbqc-violation-message-parameter-string' )
483
+				wfMessage('wbqc-violation-message-parameter-string')
484 484
 					->rawParams(
485
-						$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
486
-						$this->constraintParameterRenderer->formatDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
485
+						$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
486
+						$this->constraintParameterRenderer->formatDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
487 487
 					)
488 488
 					->escaped()
489 489
 			);
@@ -496,15 +496,15 @@  discard block
 block discarded – undo
496 496
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
497 497
 	 * @return string
498 498
 	 */
499
-	public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) {
500
-		$this->checkError( $constraintParameters );
501
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
502
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
499
+	public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) {
500
+		$this->checkError($constraintParameters);
501
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
502
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
503 503
 			return '';
504 504
 		}
505 505
 
506
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
507
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
506
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
507
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
508 508
 	}
509 509
 
510 510
 	/**
@@ -513,20 +513,20 @@  discard block
 block discarded – undo
513 513
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
514 514
 	 * @return string
515 515
 	 */
516
-	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
517
-		$this->checkError( $constraintParameters );
518
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
519
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
516
+	public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) {
517
+		$this->checkError($constraintParameters);
518
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
519
+		if (!array_key_exists($formatId, $constraintParameters)) {
520 520
 			throw new ConstraintParameterException(
521
-				wfMessage( 'wbqc-violation-message-parameter-needed' )
522
-					->rawParams( $this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM ) )
523
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $formatId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
521
+				wfMessage('wbqc-violation-message-parameter-needed')
522
+					->rawParams($this->constraintParameterRenderer->formatItemId($constraintTypeItemId, Role::CONSTRAINT_TYPE_ITEM))
523
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($formatId, Role::CONSTRAINT_PARAMETER_PROPERTY))
524 524
 					->escaped()
525 525
 			);
526 526
 		}
527 527
 
528
-		$this->requireSingleParameter( $constraintParameters, $formatId );
529
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
528
+		$this->requireSingleParameter($constraintParameters, $formatId);
529
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
530 530
 	}
531 531
 
532 532
 	/**
@@ -534,16 +534,16 @@  discard block
 block discarded – undo
534 534
 	 * @throws ConstraintParameterException if the parameter is invalid
535 535
 	 * @return EntityId[]
536 536
 	 */
537
-	public function parseExceptionParameter( array $constraintParameters ) {
538
-		$this->checkError( $constraintParameters );
539
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
540
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
537
+	public function parseExceptionParameter(array $constraintParameters) {
538
+		$this->checkError($constraintParameters);
539
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
540
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
541 541
 			return [];
542 542
 		}
543 543
 
544 544
 		return array_map(
545
-			function( $snakSerialization ) use ( $exceptionId ) {
546
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
545
+			function($snakSerialization) use ($exceptionId) {
546
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
547 547
 			},
548 548
 			$constraintParameters[$exceptionId]
549 549
 		);
@@ -554,27 +554,27 @@  discard block
 block discarded – undo
554 554
 	 * @throws ConstraintParameterException if the parameter is invalid
555 555
 	 * @return string|null 'mandatory' or null
556 556
 	 */
557
-	public function parseConstraintStatusParameter( array $constraintParameters ) {
558
-		$this->checkError( $constraintParameters );
559
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
560
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
557
+	public function parseConstraintStatusParameter(array $constraintParameters) {
558
+		$this->checkError($constraintParameters);
559
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
560
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
561 561
 			return null;
562 562
 		}
563 563
 
564
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
565
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
566
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
567
-		$this->requireValueParameter( $snak, $constraintStatusId );
564
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
565
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
566
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
567
+		$this->requireValueParameter($snak, $constraintStatusId);
568 568
 		$statusId = $snak->getDataValue()->getEntityId()->getSerialization();
569 569
 
570
-		if ( $statusId === $mandatoryId ) {
570
+		if ($statusId === $mandatoryId) {
571 571
 			return 'mandatory';
572 572
 		} else {
573 573
 			throw new ConstraintParameterException(
574
-				wfMessage( 'wbqc-violation-message-parameter-oneof' )
575
-					->rawParams( $this->constraintParameterRenderer->formatPropertyId( $constraintStatusId, Role::CONSTRAINT_PARAMETER_PROPERTY ) )
576
-					->numParams( 1 )
577
-					->rawParams( $this->constraintParameterRenderer->formatItemIdList( [ $mandatoryId ], Role::CONSTRAINT_PARAMETER_VALUE ) )
574
+				wfMessage('wbqc-violation-message-parameter-oneof')
575
+					->rawParams($this->constraintParameterRenderer->formatPropertyId($constraintStatusId, Role::CONSTRAINT_PARAMETER_PROPERTY))
576
+					->numParams(1)
577
+					->rawParams($this->constraintParameterRenderer->formatItemIdList([$mandatoryId], Role::CONSTRAINT_PARAMETER_VALUE))
578 578
 					->escaped()
579 579
 			);
580 580
 		}
@@ -587,13 +587,13 @@  discard block
 block discarded – undo
587 587
 	 * @return void
588 588
 	 * @throws ConstraintParameterException
589 589
 	 */
590
-	private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) {
591
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
590
+	private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) {
591
+		if (!($dataValue instanceof MonolingualTextValue)) {
592 592
 			throw new ConstraintParameterException(
593
-				wfMessage( 'wbqc-violation-message-parameter-monolingualtext' )
593
+				wfMessage('wbqc-violation-message-parameter-monolingualtext')
594 594
 					->rawParams(
595
-						$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY ),
596
-						$this->constraintParameterRenderer->formatDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
595
+						$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY),
596
+						$this->constraintParameterRenderer->formatDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
597 597
 					)
598 598
 					->escaped()
599 599
 			);
@@ -608,26 +608,26 @@  discard block
 block discarded – undo
608 608
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
609 609
 	 * @return string[]
610 610
 	 */
611
-	private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) {
611
+	private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) {
612 612
 		$result = [];
613 613
 
614
-		foreach ( $snakSerializations as $snakSerialization ) {
615
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
616
-			$this->requireValueParameter( $snak, $parameterId );
614
+		foreach ($snakSerializations as $snakSerialization) {
615
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
616
+			$this->requireValueParameter($snak, $parameterId);
617 617
 
618 618
 			$value = $snak->getDataValue();
619
-			$this->requireMonolingualTextParameter( $value, $parameterId );
619
+			$this->requireMonolingualTextParameter($value, $parameterId);
620 620
 			/** @var MonolingualTextValue $value */
621 621
 
622 622
 			$code = $value->getLanguageCode();
623
-			if ( array_key_exists( $code, $result ) ) {
623
+			if (array_key_exists($code, $result)) {
624 624
 				throw new ConstraintParameterException(
625
-					wfMessage( 'wbqc-violation-message-parameter-single-per-language' )
625
+					wfMessage('wbqc-violation-message-parameter-single-per-language')
626 626
 						->rawParams(
627
-							$this->constraintParameterRenderer->formatPropertyId( $parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY )
627
+							$this->constraintParameterRenderer->formatPropertyId($parameterId, Role::CONSTRAINT_PARAMETER_PROPERTY)
628 628
 						)
629 629
 						->plaintextParams(
630
-							Language::fetchLanguageName( $code ),
630
+							Language::fetchLanguageName($code),
631 631
 							$code
632 632
 						)
633 633
 						->escaped()
@@ -646,23 +646,23 @@  discard block
 block discarded – undo
646 646
 	 * @throws ConstraintParameterException if the parameter is invalid
647 647
 	 * @return string|null
648 648
 	 */
649
-	public function parseSyntaxClarificationParameter( array $constraintParameters, Language $language ) {
650
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
649
+	public function parseSyntaxClarificationParameter(array $constraintParameters, Language $language) {
650
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
651 651
 
652
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
652
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
653 653
 			return null;
654 654
 		}
655 655
 
656 656
 		$languageCodes = $language->getFallbackLanguages();
657
-		array_unshift( $languageCodes, $language->getCode() );
657
+		array_unshift($languageCodes, $language->getCode());
658 658
 
659 659
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
660 660
 			$constraintParameters[$syntaxClarificationId],
661 661
 			$syntaxClarificationId
662 662
 		);
663 663
 
664
-		foreach ( $languageCodes as $languageCode ) {
665
-			if ( array_key_exists( $languageCode, $syntaxClarifications ) ) {
664
+		foreach ($languageCodes as $languageCode) {
665
+			if (array_key_exists($languageCode, $syntaxClarifications)) {
666 666
 				return $syntaxClarifications[$languageCode];
667 667
 			}
668 668
 		}
@@ -678,20 +678,20 @@  discard block
 block discarded – undo
678 678
 	 * @throws ConstraintParameterException if the parameter is invalid
679 679
 	 * @return string[]|null Context::TYPE_* constants
680 680
 	 */
681
-	public function parseConstraintScopeParameter( array $constraintParameters, $constraintTypeItemId, array $validScopes = null ) {
682
-		$constraintScopeId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
683
-		$mainSnakId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' );
684
-		$qualifiersId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' );
685
-		$referencesId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' );
681
+	public function parseConstraintScopeParameter(array $constraintParameters, $constraintTypeItemId, array $validScopes = null) {
682
+		$constraintScopeId = $this->config->get('WBQualityConstraintsConstraintScopeId');
683
+		$mainSnakId = $this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId');
684
+		$qualifiersId = $this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId');
685
+		$referencesId = $this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId');
686 686
 
687
-		if ( !array_key_exists( $constraintScopeId, $constraintParameters ) ) {
687
+		if (!array_key_exists($constraintScopeId, $constraintParameters)) {
688 688
 			return null;
689 689
 		}
690 690
 
691 691
 		$contextTypes = [];
692
-		foreach ( $constraintParameters[$constraintScopeId] as $snakSerialization ) {
693
-			$scopeEntityId = $this->parseEntityIdParameter( $snakSerialization, $constraintScopeId );
694
-			switch ( $scopeEntityId->getSerialization() ) {
692
+		foreach ($constraintParameters[$constraintScopeId] as $snakSerialization) {
693
+			$scopeEntityId = $this->parseEntityIdParameter($snakSerialization, $constraintScopeId);
694
+			switch ($scopeEntityId->getSerialization()) {
695 695
 				case $mainSnakId:
696 696
 					$contextTypes[] = Context::TYPE_STATEMENT;
697 697
 					break;
@@ -703,14 +703,14 @@  discard block
 block discarded – undo
703 703
 					break;
704 704
 				default:
705 705
 					throw new ConstraintParameterException(
706
-						wfMessage( 'wbqc-violation-message-parameter-oneof' )
706
+						wfMessage('wbqc-violation-message-parameter-oneof')
707 707
 							->rawParams(
708 708
 								$this->constraintParameterRenderer->formatPropertyId(
709 709
 									$constraintScopeId,
710 710
 									Role::CONSTRAINT_PARAMETER_PROPERTY
711 711
 								)
712 712
 							)
713
-							->numParams( 3 )
713
+							->numParams(3)
714 714
 							->rawParams(
715 715
 								$this->constraintParameterRenderer->formatItemIdList(
716 716
 									[
@@ -726,12 +726,12 @@  discard block
 block discarded – undo
726 726
 			}
727 727
 		}
728 728
 
729
-		if ( $validScopes !== null ) {
730
-			$invalidScopes = array_diff( $contextTypes, $validScopes );
731
-			if ( $invalidScopes !== [] ) {
732
-				$invalidScope = array_pop( $invalidScopes );
729
+		if ($validScopes !== null) {
730
+			$invalidScopes = array_diff($contextTypes, $validScopes);
731
+			if ($invalidScopes !== []) {
732
+				$invalidScope = array_pop($invalidScopes);
733 733
 				throw new ConstraintParameterException(
734
-					wfMessage( 'wbqc-violation-message-invalid-scope' )
734
+					wfMessage('wbqc-violation-message-invalid-scope')
735 735
 						->rawParams(
736 736
 							$this->constraintParameterRenderer->formatConstraintScope(
737 737
 								$invalidScope,
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 								Role::CONSTRAINT_TYPE_ITEM
743 743
 							)
744 744
 						)
745
-						->numParams( count( $validScopes ) )
745
+						->numParams(count($validScopes))
746 746
 						->rawParams(
747 747
 							$this->constraintParameterRenderer->formatConstraintScopeList(
748 748
 								$validScopes,
Please login to merge, or discard this patch.
src/UpdateConstraintsTableJob.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 
27 27
 	const BATCH_SIZE = 10;
28 28
 
29
-	public static function newFromGlobalState( Title $title, array $params ) {
30
-		Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' );
29
+	public static function newFromGlobalState(Title $title, array $params) {
30
+		Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]');
31 31
 		$repo = WikibaseRepo::getDefaultInstance();
32 32
 		return new UpdateConstraintsTableJob(
33 33
 			$title,
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		EntityLookup $entityLookup,
84 84
 		Serializer $snakSerializer
85 85
 	) {
86
-		parent::__construct( 'constraintsTableUpdate', $title, $params );
86
+		parent::__construct('constraintsTableUpdate', $title, $params);
87 87
 
88 88
 		$this->propertyId = $propertyId;
89 89
 		$this->config = $config;
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 		$this->snakSerializer = $snakSerializer;
93 93
 	}
94 94
 
95
-	public function extractParametersFromQualifiers( SnakList $qualifiers ) {
95
+	public function extractParametersFromQualifiers(SnakList $qualifiers) {
96 96
 		$parameters = [];
97
-		foreach ( $qualifiers as $qualifier ) {
97
+		foreach ($qualifiers as $qualifier) {
98 98
 			$qualifierId = $qualifier->getPropertyId()->getSerialization();
99
-			$paramSerialization = $this->snakSerializer->serialize( $qualifier );
99
+			$paramSerialization = $this->snakSerializer->serialize($qualifier);
100 100
 			$parameters[$qualifierId][] = $paramSerialization;
101 101
 		}
102 102
 		return $parameters;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	) {
109 109
 		$constraintId = $constraintStatement->getGuid();
110 110
 		$constraintTypeQid = $constraintStatement->getMainSnak()->getDataValue()->getEntityId()->getSerialization();
111
-		$parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() );
111
+		$parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers());
112 112
 		return new Constraint(
113 113
 			$constraintId,
114 114
 			$propertyId,
@@ -123,17 +123,17 @@  discard block
 block discarded – undo
123 123
 		PropertyId $propertyConstraintPropertyId
124 124
 	) {
125 125
 		$constraintsStatements = $property->getStatements()
126
-			->getByPropertyId( $propertyConstraintPropertyId )
127
-			->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] );
126
+			->getByPropertyId($propertyConstraintPropertyId)
127
+			->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]);
128 128
 		$constraints = [];
129
-		foreach ( $constraintsStatements->getIterator() as $constraintStatement ) {
130
-			$constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement );
131
-			if ( count( $constraints ) >= self::BATCH_SIZE ) {
132
-				$constraintRepo->insertBatch( $constraints );
129
+		foreach ($constraintsStatements->getIterator() as $constraintStatement) {
130
+			$constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement);
131
+			if (count($constraints) >= self::BATCH_SIZE) {
132
+				$constraintRepo->insertBatch($constraints);
133 133
 				$constraints = [];
134 134
 			}
135 135
 		}
136
-		$constraintRepo->insertBatch( $constraints );
136
+		$constraintRepo->insertBatch($constraints);
137 137
 	}
138 138
 
139 139
 	/**
@@ -144,15 +144,15 @@  discard block
 block discarded – undo
144 144
 	public function run() {
145 145
 		// TODO in the future: only touch constraints affected by the edit (requires T163465)
146 146
 
147
-		$propertyId = new PropertyId( $this->propertyId );
148
-		$this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId( $propertyId );
147
+		$propertyId = new PropertyId($this->propertyId);
148
+		$this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId($propertyId);
149 149
 
150 150
 		/** @var Property $property */
151
-		$property = $this->entityLookup->getEntity( $propertyId );
151
+		$property = $this->entityLookup->getEntity($propertyId);
152 152
 		$this->importConstraintsForProperty(
153 153
 			$property,
154 154
 			$this->constraintRepo,
155
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) )
155
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId'))
156 156
 		);
157 157
 
158 158
 		return true;
Please login to merge, or discard this patch.
src/Api/CheckingResultsBuilder.php 1 patch
Spacing   +29 added lines, -30 removed lines patch added patch discarded remove patch
@@ -75,54 +75,53 @@  discard block
 block discarded – undo
75 75
 	) {
76 76
 		$response = [];
77 77
 		$metadatas = [];
78
-		$statusesFlipped = array_flip( $statuses );
79
-		foreach ( $entityIds as $entityId ) {
78
+		$statusesFlipped = array_flip($statuses);
79
+		foreach ($entityIds as $entityId) {
80 80
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnEntityId(
81 81
 				$entityId,
82 82
 				$constraintIds,
83
-				[ $this, 'defaultResults' ]
83
+				[$this, 'defaultResults']
84 84
 			);
85
-			$results = array_filter( $results, $this->statusSelected( $statusesFlipped ) );
86
-			foreach ( $results as $result ) {
85
+			$results = array_filter($results, $this->statusSelected($statusesFlipped));
86
+			foreach ($results as $result) {
87 87
 				$metadatas[] = $result->getMetadata();
88
-				$resultArray = $this->checkResultToArray( $result );
89
-				$result->getContext()->storeCheckResultInArray( $resultArray, $response );
88
+				$resultArray = $this->checkResultToArray($result);
89
+				$result->getContext()->storeCheckResultInArray($resultArray, $response);
90 90
 			}
91 91
 		}
92
-		foreach ( $claimIds as $claimId ) {
92
+		foreach ($claimIds as $claimId) {
93 93
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnClaimId(
94 94
 				$claimId,
95 95
 				$constraintIds,
96
-				[ $this, 'defaultResults' ]
96
+				[$this, 'defaultResults']
97 97
 			);
98
-			$results = array_filter( $results, $this->statusSelected( $statusesFlipped ) );
99
-			foreach ( $results as $result ) {
98
+			$results = array_filter($results, $this->statusSelected($statusesFlipped));
99
+			foreach ($results as $result) {
100 100
 				$metadatas[] = $result->getMetadata();
101
-				$resultArray = $this->checkResultToArray( $result );
102
-				$result->getContext()->storeCheckResultInArray( $resultArray, $response );
101
+				$resultArray = $this->checkResultToArray($result);
102
+				$result->getContext()->storeCheckResultInArray($resultArray, $response);
103 103
 			}
104 104
 		}
105 105
 		return new CachedCheckConstraintsResponse(
106 106
 			$response,
107
-			Metadata::merge( $metadatas )
107
+			Metadata::merge($metadatas)
108 108
 		);
109 109
 	}
110 110
 
111
-	public function defaultResults( Context $context ) {
111
+	public function defaultResults(Context $context) {
112 112
 		return $context->getType() === Context::TYPE_STATEMENT ?
113
-			[ new NullResult( $context ) ] :
114
-			[];
113
+			[new NullResult($context)] : [];
115 114
 	}
116 115
 
117
-	public function statusSelected( array $statusesFlipped ) {
118
-		return function( CheckResult $result ) use ( $statusesFlipped ) {
119
-			return array_key_exists( $result->getStatus(), $statusesFlipped ) ||
116
+	public function statusSelected(array $statusesFlipped) {
117
+		return function(CheckResult $result) use ($statusesFlipped) {
118
+			return array_key_exists($result->getStatus(), $statusesFlipped) ||
120 119
 				$result instanceof NullResult;
121 120
 		};
122 121
 	}
123 122
 
124
-	public function checkResultToArray( CheckResult $checkResult ) {
125
-		if ( $checkResult instanceof NullResult ) {
123
+	public function checkResultToArray(CheckResult $checkResult) {
124
+		if ($checkResult instanceof NullResult) {
126 125
 			return null;
127 126
 		}
128 127
 
@@ -130,10 +129,10 @@  discard block
 block discarded – undo
130 129
 		$typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId();
131 130
 		$constraintPropertyId = $checkResult->getContext()->getSnak()->getPropertyId();
132 131
 
133
-		$title = $this->entityTitleLookup->getTitleForId( $constraintPropertyId );
134
-		$typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) );
132
+		$title = $this->entityTitleLookup->getTitleForId($constraintPropertyId);
133
+		$typeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($typeItemId));
135 134
 		// TODO link to the statement when possible (T169224)
136
-		$link = $title->getFullURL() . '#' . $this->config->get( 'WBQualityConstraintsPropertyConstraintId' );
135
+		$link = $title->getFullURL().'#'.$this->config->get('WBQualityConstraintsPropertyConstraintId');
137 136
 
138 137
 		$constraint = [
139 138
 			'id' => $constraintId,
@@ -142,11 +141,11 @@  discard block
 block discarded – undo
142 141
 			'link' => $link,
143 142
 			'discussLink' => $title->getTalkPage()->getFullURL(),
144 143
 		];
145
-		if ( $this->config->get( 'WBQualityConstraintsIncludeDetailInApi' ) ) {
144
+		if ($this->config->get('WBQualityConstraintsIncludeDetailInApi')) {
146 145
 			$parameters = $checkResult->getParameters();
147 146
 			$constraint += [
148 147
 				'detail' => $parameters,
149
-				'detailHTML' => $this->constraintParameterRenderer->formatParameters( $parameters ),
148
+				'detailHTML' => $this->constraintParameterRenderer->formatParameters($parameters),
150 149
 			];
151 150
 		}
152 151
 
@@ -156,14 +155,14 @@  discard block
 block discarded – undo
156 155
 			'constraint' => $constraint
157 156
 		];
158 157
 		$message = $checkResult->getMessage();
159
-		if ( $message ) {
158
+		if ($message) {
160 159
 			$result['message-html'] = $message;
161 160
 		}
162
-		if ( $checkResult->getContext()->getType() === Context::TYPE_STATEMENT ) {
161
+		if ($checkResult->getContext()->getType() === Context::TYPE_STATEMENT) {
163 162
 			$result['claim'] = $checkResult->getContext()->getSnakStatement()->getGuid();
164 163
 		}
165 164
 		$cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray();
166
-		if ( $cachingMetadataArray !== null ) {
165
+		if ($cachingMetadataArray !== null) {
167 166
 			$result['cached'] = $cachingMetadataArray;
168 167
 		}
169 168
 
Please login to merge, or discard this patch.