Completed
Push — master ( aab1b7...b64451 )
by
unknown
04:30
created
src/ConstraintCheck/Helper/ConstraintParameterException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@
 block discarded – undo
21 21
 	/**
22 22
 	 * @param ViolationMessage $violationMessage
23 23
 	 */
24
-	public function __construct( ViolationMessage $violationMessage ) {
25
-		$message = '⧼' . $violationMessage->getMessageKey() . '⧽';
26
-		parent::__construct( $message );
24
+	public function __construct(ViolationMessage $violationMessage) {
25
+		$message = '⧼'.$violationMessage->getMessageKey().'⧽';
26
+		parent::__construct($message);
27 27
 
28 28
 		$this->violationMessage = $violationMessage;
29 29
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/MultilingualTextViolationMessageRenderer.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -55,34 +55,34 @@  discard block
 block discarded – undo
55 55
 	 * (temporarily, pre-rendered strings are allowed and returned without changes)
56 56
 	 * @return string
57 57
 	 */
58
-	public function render( ViolationMessage $violationMessage ) {
59
-		if ( !array_key_exists( $violationMessage->getMessageKey(), $this->alternativeMessageKeys ) ) {
60
-			return parent::render( $violationMessage );
58
+	public function render(ViolationMessage $violationMessage) {
59
+		if (!array_key_exists($violationMessage->getMessageKey(), $this->alternativeMessageKeys)) {
60
+			return parent::render($violationMessage);
61 61
 		}
62 62
 
63 63
 		$arguments = $violationMessage->getArguments();
64
-		$multilingualTextArgument = array_pop( $arguments );
64
+		$multilingualTextArgument = array_pop($arguments);
65 65
 		$multilingualTextParams = $this->renderMultilingualText(
66 66
 			$multilingualTextArgument['value'],
67 67
 			$multilingualTextArgument['role']
68 68
 		);
69 69
 
70
-		$paramsLists = [ [] ];
71
-		foreach ( $arguments as $argument ) {
72
-			$paramsLists[] = $this->renderArgument( $argument );
70
+		$paramsLists = [[]];
71
+		foreach ($arguments as $argument) {
72
+			$paramsLists[] = $this->renderArgument($argument);
73 73
 		}
74
-		$regularParams = call_user_func_array( 'array_merge', $paramsLists );
74
+		$regularParams = call_user_func_array('array_merge', $paramsLists);
75 75
 
76
-		if ( $multilingualTextParams === null ) {
76
+		if ($multilingualTextParams === null) {
77 77
 			return $this->messageLocalizer
78
-				->msg( $this->alternativeMessageKeys[$violationMessage->getMessageKey()] )
79
-				->params( $regularParams )
78
+				->msg($this->alternativeMessageKeys[$violationMessage->getMessageKey()])
79
+				->params($regularParams)
80 80
 				->escaped();
81 81
 		} else {
82 82
 			return $this->messageLocalizer
83
-				->msg( $violationMessage->getMessageKey() )
84
-				->params( $regularParams )
85
-				->params( $multilingualTextParams )
83
+				->msg($violationMessage->getMessageKey())
84
+				->params($regularParams)
85
+				->params($multilingualTextParams)
86 86
 				->escaped();
87 87
 		}
88 88
 	}
@@ -93,18 +93,18 @@  discard block
 block discarded – undo
93 93
 	 * @return array[]|null list of parameters as accepted by Message::params(),
94 94
 	 * or null if the text is not available in the user’s language
95 95
 	 */
96
-	protected function renderMultilingualText( MultilingualTextValue $text, $role ) {
96
+	protected function renderMultilingualText(MultilingualTextValue $text, $role) {
97 97
 		global $wgLang;
98 98
 		$languageCodes = $wgLang->getFallbackLanguages();
99
-		array_unshift( $languageCodes, $wgLang->getCode() );
99
+		array_unshift($languageCodes, $wgLang->getCode());
100 100
 
101 101
 		$texts = $text->getTexts();
102
-		foreach ( $languageCodes as $languageCode ) {
103
-			if ( array_key_exists( $languageCode, $texts ) ) {
104
-				return [ Message::rawParam( $this->addRole(
105
-					htmlspecialchars( $texts[$languageCode]->getText() ),
102
+		foreach ($languageCodes as $languageCode) {
103
+			if (array_key_exists($languageCode, $texts)) {
104
+				return [Message::rawParam($this->addRole(
105
+					htmlspecialchars($texts[$languageCode]->getText()),
106 106
 					$role
107
-				) ) ];
107
+				))];
108 108
 			}
109 109
 		}
110 110
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Result/CheckResult.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
 		$status = self::STATUS_TODO,
123 123
 		ViolationMessage $message = null
124 124
 	) {
125
-		if ( $contextCursor instanceof Context ) {
125
+		if ($contextCursor instanceof Context) {
126 126
 			$context = $contextCursor;
127 127
 			$this->contextCursor = $context->getCursor();
128 128
 			$this->snakType = $context->getSnak()->getType();
129 129
 			$mainSnak = $context->getSnak();
130
-			if ( $mainSnak instanceof PropertyValueSnak ) {
130
+			if ($mainSnak instanceof PropertyValueSnak) {
131 131
 				$this->dataValue = $mainSnak->getDataValue();
132 132
 			} else {
133 133
 				$this->dataValue = null;
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @param string $key
191 191
 	 * @param string $value
192 192
 	 */
193
-	public function addParameter( $key, $value ) {
193
+	public function addParameter($key, $value) {
194 194
 		$this->parameters[$key][] = $value;
195 195
 	}
196 196
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	/**
205 205
 	 * @param string $status
206 206
 	 */
207
-	public function setStatus( $status ) {
207
+	public function setStatus($status) {
208 208
 		$this->status = $status;
209 209
 	}
210 210
 
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	 * @param Metadata $metadata
220 220
 	 * @return self
221 221
 	 */
222
-	public function withMetadata( Metadata $metadata ) {
222
+	public function withMetadata(Metadata $metadata) {
223 223
 		$this->metadata = $metadata;
224 224
 		return $this;
225 225
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
 	 * @param array $parameters
89 89
 	 * @throws ConstraintParameterException
90 90
 	 */
91
-	public function checkError( array $parameters ) {
92
-		if ( array_key_exists( '@error', $parameters ) ) {
91
+	public function checkError(array $parameters) {
92
+		if (array_key_exists('@error', $parameters)) {
93 93
 			$error = $parameters['@error'];
94
-			if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) {
94
+			if (array_key_exists('toolong', $error) && $error['toolong']) {
95 95
 				$msg = 'wbqc-violation-message-parameters-error-toolong';
96 96
 			} else {
97 97
 				$msg = 'wbqc-violation-message-parameters-error-unknown';
98 98
 			}
99
-			throw new ConstraintParameterException( new ViolationMessage( $msg ) );
99
+			throw new ConstraintParameterException(new ViolationMessage($msg));
100 100
 		}
101 101
 	}
102 102
 
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 	 * @param string $parameterId
107 107
 	 * @throws ConstraintParameterException
108 108
 	 */
109
-	private function requireSingleParameter( array $parameters, $parameterId ) {
110
-		if ( count( $parameters[$parameterId] ) !== 1 ) {
109
+	private function requireSingleParameter(array $parameters, $parameterId) {
110
+		if (count($parameters[$parameterId]) !== 1) {
111 111
 			throw new ConstraintParameterException(
112
-				( new ViolationMessage( 'wbqc-violation-message-parameter-single' ) )
113
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
112
+				(new ViolationMessage('wbqc-violation-message-parameter-single'))
113
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
114 114
 			);
115 115
 		}
116 116
 	}
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 	 * @return void
123 123
 	 * @throws ConstraintParameterException
124 124
 	 */
125
-	private function requireValueParameter( Snak $snak, $parameterId ) {
126
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
125
+	private function requireValueParameter(Snak $snak, $parameterId) {
126
+		if (!($snak instanceof PropertyValueSnak)) {
127 127
 			throw new ConstraintParameterException(
128
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
129
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
128
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
129
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
130 130
 			);
131 131
 		}
132 132
 	}
@@ -138,17 +138,17 @@  discard block
 block discarded – undo
138 138
 	 * @throws ConstraintParameterException
139 139
 	 * @return EntityId
140 140
 	 */
141
-	private function parseEntityIdParameter( array $snakSerialization, $parameterId ) {
142
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
143
-		$this->requireValueParameter( $snak, $parameterId );
141
+	private function parseEntityIdParameter(array $snakSerialization, $parameterId) {
142
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
143
+		$this->requireValueParameter($snak, $parameterId);
144 144
 		$value = $snak->getDataValue();
145
-		if ( $value instanceof EntityIdValue ) {
145
+		if ($value instanceof EntityIdValue) {
146 146
 			return $value->getEntityId();
147 147
 		} else {
148 148
 			throw new ConstraintParameterException(
149
-				( new ViolationMessage( 'wbqc-violation-message-parameter-entity' ) )
150
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
151
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
149
+				(new ViolationMessage('wbqc-violation-message-parameter-entity'))
150
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
151
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
152 152
 			);
153 153
 		}
154 154
 	}
@@ -159,20 +159,20 @@  discard block
 block discarded – undo
159 159
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
160 160
 	 * @return string[] class entity ID serializations
161 161
 	 */
162
-	public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) {
163
-		$this->checkError( $constraintParameters );
164
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
165
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
162
+	public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) {
163
+		$this->checkError($constraintParameters);
164
+		$classId = $this->config->get('WBQualityConstraintsClassId');
165
+		if (!array_key_exists($classId, $constraintParameters)) {
166 166
 			throw new ConstraintParameterException(
167
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
168
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
169
-					->withEntityId( new PropertyId( $classId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
167
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
168
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
169
+					->withEntityId(new PropertyId($classId), Role::CONSTRAINT_PARAMETER_PROPERTY)
170 170
 			);
171 171
 		}
172 172
 
173 173
 		$classes = [];
174
-		foreach ( $constraintParameters[$classId] as $class ) {
175
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
174
+		foreach ($constraintParameters[$classId] as $class) {
175
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
176 176
 		}
177 177
 		return $classes;
178 178
 	}
@@ -183,23 +183,23 @@  discard block
 block discarded – undo
183 183
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
184 184
 	 * @return string 'instance', 'subclass', or 'instanceOrSubclass'
185 185
 	 */
186
-	public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) {
187
-		$this->checkError( $constraintParameters );
188
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
189
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
186
+	public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) {
187
+		$this->checkError($constraintParameters);
188
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
189
+		if (!array_key_exists($relationId, $constraintParameters)) {
190 190
 			throw new ConstraintParameterException(
191
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
192
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
193
-					->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
191
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
192
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
193
+					->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
194 194
 			);
195 195
 		}
196 196
 
197
-		$this->requireSingleParameter( $constraintParameters, $relationId );
198
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
199
-		$instanceId = $this->config->get( 'WBQualityConstraintsInstanceOfRelationId' );
200
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfRelationId' );
201
-		$instanceOrSubclassId = $this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' );
202
-		switch ( $relationEntityId ) {
197
+		$this->requireSingleParameter($constraintParameters, $relationId);
198
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
199
+		$instanceId = $this->config->get('WBQualityConstraintsInstanceOfRelationId');
200
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfRelationId');
201
+		$instanceOrSubclassId = $this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId');
202
+		switch ($relationEntityId) {
203 203
 			case $instanceId:
204 204
 				return 'instance';
205 205
 			case $subclassId:
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
 				return 'instanceOrSubclass';
209 209
 			default:
210 210
 				throw new ConstraintParameterException(
211
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
212
-						->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
211
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
212
+						->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
213 213
 						->withEntityIdList(
214 214
 							[
215
-								new ItemId( $instanceId ),
216
-								new ItemId( $subclassId ),
217
-								new ItemId( $instanceOrSubclassId ),
215
+								new ItemId($instanceId),
216
+								new ItemId($subclassId),
217
+								new ItemId($instanceOrSubclassId),
218 218
 							],
219 219
 							Role::CONSTRAINT_PARAMETER_VALUE
220 220
 						)
@@ -229,20 +229,20 @@  discard block
 block discarded – undo
229 229
 	 * @throws ConstraintParameterException
230 230
 	 * @return PropertyId
231 231
 	 */
232
-	private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) {
233
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
234
-		$this->requireValueParameter( $snak, $parameterId );
232
+	private function parsePropertyIdParameter(array $snakSerialization, $parameterId) {
233
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
234
+		$this->requireValueParameter($snak, $parameterId);
235 235
 		$value = $snak->getDataValue();
236
-		if ( $value instanceof EntityIdValue ) {
236
+		if ($value instanceof EntityIdValue) {
237 237
 			$id = $value->getEntityId();
238
-			if ( $id instanceof PropertyId ) {
238
+			if ($id instanceof PropertyId) {
239 239
 				return $id;
240 240
 			}
241 241
 		}
242 242
 		throw new ConstraintParameterException(
243
-			( new ViolationMessage( 'wbqc-violation-message-parameter-property' ) )
244
-				->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
245
-				->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
243
+			(new ViolationMessage('wbqc-violation-message-parameter-property'))
244
+				->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
245
+				->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
246 246
 		);
247 247
 	}
248 248
 
@@ -253,32 +253,32 @@  discard block
 block discarded – undo
253 253
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
254 254
 	 * @return PropertyId
255 255
 	 */
256
-	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
257
-		$this->checkError( $constraintParameters );
258
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
259
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
256
+	public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) {
257
+		$this->checkError($constraintParameters);
258
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
259
+		if (!array_key_exists($propertyId, $constraintParameters)) {
260 260
 			throw new ConstraintParameterException(
261
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
262
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
263
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
261
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
262
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
263
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
264 264
 			);
265 265
 		}
266 266
 
267
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
268
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
267
+		$this->requireSingleParameter($constraintParameters, $propertyId);
268
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
269 269
 	}
270 270
 
271
-	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
271
+	private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) {
272 272
 		$dataValue = $snak->getDataValue();
273
-		if ( $dataValue instanceof EntityIdValue &&
273
+		if ($dataValue instanceof EntityIdValue &&
274 274
 			$dataValue->getEntityId() instanceof ItemId
275 275
 		) {
276
-			return ItemIdSnakValue::fromItemId( $dataValue->getEntityId() );
276
+			return ItemIdSnakValue::fromItemId($dataValue->getEntityId());
277 277
 		} else {
278 278
 			throw new ConstraintParameterException(
279
-				( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
280
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
281
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
279
+				(new ViolationMessage('wbqc-violation-message-parameter-item'))
280
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
281
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
282 282
 			);
283 283
 		}
284 284
 	}
@@ -290,15 +290,15 @@  discard block
 block discarded – undo
290 290
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
291 291
 	 * @return ItemIdSnakValue[] array of values
292 292
 	 */
293
-	public function parseItemsParameter( array $constraintParameters, $constraintTypeItemId, $required ) {
294
-		$this->checkError( $constraintParameters );
295
-		$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
296
-		if ( !array_key_exists( $qualifierId, $constraintParameters ) ) {
297
-			if ( $required ) {
293
+	public function parseItemsParameter(array $constraintParameters, $constraintTypeItemId, $required) {
294
+		$this->checkError($constraintParameters);
295
+		$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
296
+		if (!array_key_exists($qualifierId, $constraintParameters)) {
297
+			if ($required) {
298 298
 				throw new ConstraintParameterException(
299
-					( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
300
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
301
-						->withEntityId( new PropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
299
+					(new ViolationMessage('wbqc-violation-message-parameter-needed'))
300
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
301
+						->withEntityId(new PropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
302 302
 				);
303 303
 			} else {
304 304
 				return [];
@@ -306,11 +306,11 @@  discard block
 block discarded – undo
306 306
 		}
307 307
 
308 308
 		$values = [];
309
-		foreach ( $constraintParameters[$qualifierId] as $parameter ) {
310
-			$snak = $this->snakDeserializer->deserialize( $parameter );
311
-			switch ( true ) {
309
+		foreach ($constraintParameters[$qualifierId] as $parameter) {
310
+			$snak = $this->snakDeserializer->deserialize($parameter);
311
+			switch (true) {
312 312
 				case $snak instanceof PropertyValueSnak:
313
-					$values[] = $this->parseItemIdParameter( $snak, $qualifierId );
313
+					$values[] = $this->parseItemIdParameter($snak, $qualifierId);
314 314
 					break;
315 315
 				case $snak instanceof PropertySomeValueSnak:
316 316
 					$values[] = ItemIdSnakValue::someValue();
@@ -329,27 +329,27 @@  discard block
 block discarded – undo
329 329
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
330 330
 	 * @return PropertyId[]
331 331
 	 */
332
-	public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) {
333
-		$this->checkError( $constraintParameters );
334
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
335
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
332
+	public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) {
333
+		$this->checkError($constraintParameters);
334
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
335
+		if (!array_key_exists($propertyId, $constraintParameters)) {
336 336
 			throw new ConstraintParameterException(
337
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
338
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
339
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
337
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
338
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
339
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
340 340
 			);
341 341
 		}
342 342
 
343 343
 		$parameters = $constraintParameters[$propertyId];
344
-		if ( count( $parameters ) === 1 &&
345
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
344
+		if (count($parameters) === 1 &&
345
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
346 346
 		) {
347 347
 			return [];
348 348
 		}
349 349
 
350 350
 		$properties = [];
351
-		foreach ( $parameters as $parameter ) {
352
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
351
+		foreach ($parameters as $parameter) {
352
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
353 353
 		}
354 354
 		return $properties;
355 355
 	}
@@ -360,16 +360,16 @@  discard block
 block discarded – undo
360 360
 	 * @throws ConstraintParameterException
361 361
 	 * @return DataValue|null
362 362
 	 */
363
-	private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) {
364
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
365
-		if ( $snak instanceof PropertyValueSnak ) {
363
+	private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) {
364
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
365
+		if ($snak instanceof PropertyValueSnak) {
366 366
 			return $snak->getDataValue();
367
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
367
+		} elseif ($snak instanceof PropertyNoValueSnak) {
368 368
 			return null;
369 369
 		} else {
370 370
 			throw new ConstraintParameterException(
371
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
372
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
371
+				(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
372
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
373 373
 			);
374 374
 		}
375 375
 	}
@@ -379,10 +379,10 @@  discard block
 block discarded – undo
379 379
 	 * @param string $parameterId
380 380
 	 * @return DataValue|null
381 381
 	 */
382
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) {
382
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) {
383 383
 		try {
384
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
385
-		} catch ( ConstraintParameterException $e ) {
384
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
385
+		} catch (ConstraintParameterException $e) {
386 386
 			// unknown value means “now”
387 387
 			return new NowValue();
388 388
 		}
@@ -395,14 +395,14 @@  discard block
 block discarded – undo
395 395
 	 * @param string $unit
396 396
 	 * @return bool
397 397
 	 */
398
-	private function exactlyOneQuantityWithUnit( DataValue $min = null, DataValue $max = null, $unit ) {
399
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
400
-			!( $max instanceof UnboundedQuantityValue )
398
+	private function exactlyOneQuantityWithUnit(DataValue $min = null, DataValue $max = null, $unit) {
399
+		if (!($min instanceof UnboundedQuantityValue) ||
400
+			!($max instanceof UnboundedQuantityValue)
401 401
 		) {
402 402
 			return false;
403 403
 		}
404 404
 
405
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
405
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
406 406
 	}
407 407
 
408 408
 	/**
@@ -415,42 +415,42 @@  discard block
 block discarded – undo
415 415
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
416 416
 	 * @return DataValue[] if the parameter is invalid or missing
417 417
 	 */
418
-	private function parseRangeParameter( array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type ) {
419
-		$this->checkError( $constraintParameters );
420
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
421
-			!array_key_exists( $maximumId, $constraintParameters )
418
+	private function parseRangeParameter(array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type) {
419
+		$this->checkError($constraintParameters);
420
+		if (!array_key_exists($minimumId, $constraintParameters) ||
421
+			!array_key_exists($maximumId, $constraintParameters)
422 422
 		) {
423 423
 			throw new ConstraintParameterException(
424
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-needed' ) )
425
-					->withDataValueType( $type )
426
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
427
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
428
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
424
+				(new ViolationMessage('wbqc-violation-message-range-parameters-needed'))
425
+					->withDataValueType($type)
426
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
427
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
428
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
429 429
 			);
430 430
 		}
431 431
 
432
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
433
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
432
+		$this->requireSingleParameter($constraintParameters, $minimumId);
433
+		$this->requireSingleParameter($constraintParameters, $maximumId);
434 434
 		$parseFunction = $type === 'time' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
435
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
436
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
435
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
436
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
437 437
 
438
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
439
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
438
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
439
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
440 440
 			throw new ConstraintParameterException(
441
-				new ViolationMessage( 'wbqc-violation-message-range-parameters-one-year' )
441
+				new ViolationMessage('wbqc-violation-message-range-parameters-one-year')
442 442
 			);
443 443
 		}
444
-		if ( $min === null && $max === null ||
445
-			$min !== null && $max !== null && $min->equals( $max ) ) {
444
+		if ($min === null && $max === null ||
445
+			$min !== null && $max !== null && $min->equals($max)) {
446 446
 			throw new ConstraintParameterException(
447
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-same' ) )
448
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
449
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
447
+				(new ViolationMessage('wbqc-violation-message-range-parameters-same'))
448
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
449
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
450 450
 			);
451 451
 		}
452 452
 
453
-		return [ $min, $max ];
453
+		return [$min, $max];
454 454
 	}
455 455
 
456 456
 	/**
@@ -460,11 +460,11 @@  discard block
 block discarded – undo
460 460
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
461 461
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
462 462
 	 */
463
-	public function parseQuantityRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
463
+	public function parseQuantityRangeParameter(array $constraintParameters, $constraintTypeItemId) {
464 464
 		return $this->parseRangeParameter(
465 465
 			$constraintParameters,
466
-			$this->config->get( 'WBQualityConstraintsMinimumQuantityId' ),
467
-			$this->config->get( 'WBQualityConstraintsMaximumQuantityId' ),
466
+			$this->config->get('WBQualityConstraintsMinimumQuantityId'),
467
+			$this->config->get('WBQualityConstraintsMaximumQuantityId'),
468 468
 			$constraintTypeItemId,
469 469
 			'quantity'
470 470
 		);
@@ -477,11 +477,11 @@  discard block
 block discarded – undo
477 477
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
478 478
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
479 479
 	 */
480
-	public function parseTimeRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
480
+	public function parseTimeRangeParameter(array $constraintParameters, $constraintTypeItemId) {
481 481
 		return $this->parseRangeParameter(
482 482
 			$constraintParameters,
483
-			$this->config->get( 'WBQualityConstraintsMinimumDateId' ),
484
-			$this->config->get( 'WBQualityConstraintsMaximumDateId' ),
483
+			$this->config->get('WBQualityConstraintsMinimumDateId'),
484
+			$this->config->get('WBQualityConstraintsMaximumDateId'),
485 485
 			$constraintTypeItemId,
486 486
 			'time'
487 487
 		);
@@ -494,17 +494,17 @@  discard block
 block discarded – undo
494 494
 	 * @throws ConstraintParameterException
495 495
 	 * @return string
496 496
 	 */
497
-	private function parseStringParameter( array $snakSerialization, $parameterId ) {
498
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
499
-		$this->requireValueParameter( $snak, $parameterId );
497
+	private function parseStringParameter(array $snakSerialization, $parameterId) {
498
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
499
+		$this->requireValueParameter($snak, $parameterId);
500 500
 		$value = $snak->getDataValue();
501
-		if ( $value instanceof StringValue ) {
501
+		if ($value instanceof StringValue) {
502 502
 			return $value->getValue();
503 503
 		} else {
504 504
 			throw new ConstraintParameterException(
505
-				( new ViolationMessage( 'wbqc-violation-message-parameter-string' ) )
506
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
507
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
505
+				(new ViolationMessage('wbqc-violation-message-parameter-string'))
506
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
507
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
508 508
 			);
509 509
 		}
510 510
 	}
@@ -515,15 +515,15 @@  discard block
 block discarded – undo
515 515
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
516 516
 	 * @return string
517 517
 	 */
518
-	public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) {
519
-		$this->checkError( $constraintParameters );
520
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
521
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
518
+	public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) {
519
+		$this->checkError($constraintParameters);
520
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
521
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
522 522
 			return '';
523 523
 		}
524 524
 
525
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
526
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
525
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
526
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
527 527
 	}
528 528
 
529 529
 	/**
@@ -532,19 +532,19 @@  discard block
 block discarded – undo
532 532
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
533 533
 	 * @return string
534 534
 	 */
535
-	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
536
-		$this->checkError( $constraintParameters );
537
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
538
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
535
+	public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) {
536
+		$this->checkError($constraintParameters);
537
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
538
+		if (!array_key_exists($formatId, $constraintParameters)) {
539 539
 			throw new ConstraintParameterException(
540
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
541
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
542
-					->withEntityId( new PropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
540
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
541
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
542
+					->withEntityId(new PropertyId($formatId), Role::CONSTRAINT_PARAMETER_PROPERTY)
543 543
 			);
544 544
 		}
545 545
 
546
-		$this->requireSingleParameter( $constraintParameters, $formatId );
547
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
546
+		$this->requireSingleParameter($constraintParameters, $formatId);
547
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
548 548
 	}
549 549
 
550 550
 	/**
@@ -552,16 +552,16 @@  discard block
 block discarded – undo
552 552
 	 * @throws ConstraintParameterException if the parameter is invalid
553 553
 	 * @return EntityId[]
554 554
 	 */
555
-	public function parseExceptionParameter( array $constraintParameters ) {
556
-		$this->checkError( $constraintParameters );
557
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
558
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
555
+	public function parseExceptionParameter(array $constraintParameters) {
556
+		$this->checkError($constraintParameters);
557
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
558
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
559 559
 			return [];
560 560
 		}
561 561
 
562 562
 		return array_map(
563
-			function( $snakSerialization ) use ( $exceptionId ) {
564
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
563
+			function($snakSerialization) use ($exceptionId) {
564
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
565 565
 			},
566 566
 			$constraintParameters[$exceptionId]
567 567
 		);
@@ -572,26 +572,26 @@  discard block
 block discarded – undo
572 572
 	 * @throws ConstraintParameterException if the parameter is invalid
573 573
 	 * @return string|null 'mandatory' or null
574 574
 	 */
575
-	public function parseConstraintStatusParameter( array $constraintParameters ) {
576
-		$this->checkError( $constraintParameters );
577
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
578
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
575
+	public function parseConstraintStatusParameter(array $constraintParameters) {
576
+		$this->checkError($constraintParameters);
577
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
578
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
579 579
 			return null;
580 580
 		}
581 581
 
582
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
583
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
584
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
585
-		$this->requireValueParameter( $snak, $constraintStatusId );
582
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
583
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
584
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
585
+		$this->requireValueParameter($snak, $constraintStatusId);
586 586
 		$statusId = $snak->getDataValue()->getEntityId()->getSerialization();
587 587
 
588
-		if ( $statusId === $mandatoryId ) {
588
+		if ($statusId === $mandatoryId) {
589 589
 			return 'mandatory';
590 590
 		} else {
591 591
 			throw new ConstraintParameterException(
592
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
593
-					->withEntityId( new PropertyId( $constraintStatusId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
594
-					->withEntityIdList( [ new ItemId( $mandatoryId ) ], Role::CONSTRAINT_PARAMETER_VALUE )
592
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
593
+					->withEntityId(new PropertyId($constraintStatusId), Role::CONSTRAINT_PARAMETER_PROPERTY)
594
+					->withEntityIdList([new ItemId($mandatoryId)], Role::CONSTRAINT_PARAMETER_VALUE)
595 595
 			);
596 596
 		}
597 597
 	}
@@ -603,12 +603,12 @@  discard block
 block discarded – undo
603 603
 	 * @return void
604 604
 	 * @throws ConstraintParameterException
605 605
 	 */
606
-	private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) {
607
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
606
+	private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) {
607
+		if (!($dataValue instanceof MonolingualTextValue)) {
608 608
 			throw new ConstraintParameterException(
609
-				( new ViolationMessage( 'wbqc-violation-message-parameter-monolingualtext' ) )
610
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
611
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
609
+				(new ViolationMessage('wbqc-violation-message-parameter-monolingualtext'))
610
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
611
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
612 612
 			);
613 613
 		}
614 614
 	}
@@ -621,30 +621,30 @@  discard block
 block discarded – undo
621 621
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
622 622
 	 * @return MultilingualTextValue
623 623
 	 */
624
-	private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) {
624
+	private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) {
625 625
 		$result = [];
626 626
 
627
-		foreach ( $snakSerializations as $snakSerialization ) {
628
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
629
-			$this->requireValueParameter( $snak, $parameterId );
627
+		foreach ($snakSerializations as $snakSerialization) {
628
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
629
+			$this->requireValueParameter($snak, $parameterId);
630 630
 
631 631
 			$value = $snak->getDataValue();
632
-			$this->requireMonolingualTextParameter( $value, $parameterId );
632
+			$this->requireMonolingualTextParameter($value, $parameterId);
633 633
 			/** @var MonolingualTextValue $value */
634 634
 
635 635
 			$code = $value->getLanguageCode();
636
-			if ( array_key_exists( $code, $result ) ) {
636
+			if (array_key_exists($code, $result)) {
637 637
 				throw new ConstraintParameterException(
638
-					( new ViolationMessage( 'wbqc-violation-message-parameter-single-per-language' ) )
639
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
640
-						->withLanguage( $code )
638
+					(new ViolationMessage('wbqc-violation-message-parameter-single-per-language'))
639
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
640
+						->withLanguage($code)
641 641
 				);
642 642
 			}
643 643
 
644 644
 			$result[$code] = $value;
645 645
 		}
646 646
 
647
-		return new MultilingualTextValue( $result );
647
+		return new MultilingualTextValue($result);
648 648
 	}
649 649
 
650 650
 	/**
@@ -652,11 +652,11 @@  discard block
 block discarded – undo
652 652
 	 * @throws ConstraintParameterException if the parameter is invalid
653 653
 	 * @return MultilingualTextValue
654 654
 	 */
655
-	public function parseSyntaxClarificationParameter( array $constraintParameters ) {
656
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
655
+	public function parseSyntaxClarificationParameter(array $constraintParameters) {
656
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
657 657
 
658
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
659
-			return new MultilingualTextValue( [] );
658
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
659
+			return new MultilingualTextValue([]);
660 660
 		}
661 661
 
662 662
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
@@ -675,20 +675,20 @@  discard block
 block discarded – undo
675 675
 	 * @throws ConstraintParameterException if the parameter is invalid
676 676
 	 * @return string[]|null Context::TYPE_* constants
677 677
 	 */
678
-	public function parseConstraintScopeParameter( array $constraintParameters, $constraintTypeItemId, array $validScopes = null ) {
679
-		$constraintScopeId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
680
-		$mainSnakId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' );
681
-		$qualifiersId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' );
682
-		$referencesId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' );
678
+	public function parseConstraintScopeParameter(array $constraintParameters, $constraintTypeItemId, array $validScopes = null) {
679
+		$constraintScopeId = $this->config->get('WBQualityConstraintsConstraintScopeId');
680
+		$mainSnakId = $this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId');
681
+		$qualifiersId = $this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId');
682
+		$referencesId = $this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId');
683 683
 
684
-		if ( !array_key_exists( $constraintScopeId, $constraintParameters ) ) {
684
+		if (!array_key_exists($constraintScopeId, $constraintParameters)) {
685 685
 			return null;
686 686
 		}
687 687
 
688 688
 		$contextTypes = [];
689
-		foreach ( $constraintParameters[$constraintScopeId] as $snakSerialization ) {
690
-			$scopeEntityId = $this->parseEntityIdParameter( $snakSerialization, $constraintScopeId );
691
-			switch ( $scopeEntityId->getSerialization() ) {
689
+		foreach ($constraintParameters[$constraintScopeId] as $snakSerialization) {
690
+			$scopeEntityId = $this->parseEntityIdParameter($snakSerialization, $constraintScopeId);
691
+			switch ($scopeEntityId->getSerialization()) {
692 692
 				case $mainSnakId:
693 693
 					$contextTypes[] = Context::TYPE_STATEMENT;
694 694
 					break;
@@ -700,13 +700,13 @@  discard block
 block discarded – undo
700 700
 					break;
701 701
 				default:
702 702
 					throw new ConstraintParameterException(
703
-						( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
704
-							->withEntityId( new PropertyId( $constraintScopeId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
703
+						(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
704
+							->withEntityId(new PropertyId($constraintScopeId), Role::CONSTRAINT_PARAMETER_PROPERTY)
705 705
 							->withEntityIdList(
706 706
 								[
707
-									new ItemId( $mainSnakId ),
708
-									new ItemId( $qualifiersId ),
709
-									new ItemId( $referencesId ),
707
+									new ItemId($mainSnakId),
708
+									new ItemId($qualifiersId),
709
+									new ItemId($referencesId),
710 710
 								],
711 711
 								Role::CONSTRAINT_PARAMETER_VALUE
712 712
 							)
@@ -714,15 +714,15 @@  discard block
 block discarded – undo
714 714
 			}
715 715
 		}
716 716
 
717
-		if ( $validScopes !== null ) {
718
-			$invalidScopes = array_diff( $contextTypes, $validScopes );
719
-			if ( $invalidScopes !== [] ) {
720
-				$invalidScope = array_pop( $invalidScopes );
717
+		if ($validScopes !== null) {
718
+			$invalidScopes = array_diff($contextTypes, $validScopes);
719
+			if ($invalidScopes !== []) {
720
+				$invalidScope = array_pop($invalidScopes);
721 721
 				throw new ConstraintParameterException(
722
-					( new ViolationMessage( 'wbqc-violation-message-invalid-scope' ) )
723
-						->withConstraintScope( $invalidScope, Role::CONSTRAINT_PARAMETER_VALUE )
724
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
725
-						->withConstraintScopeList( $validScopes, Role::CONSTRAINT_PARAMETER_VALUE )
722
+					(new ViolationMessage('wbqc-violation-message-invalid-scope'))
723
+						->withConstraintScope($invalidScope, Role::CONSTRAINT_PARAMETER_VALUE)
724
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
725
+						->withConstraintScopeList($validScopes, Role::CONSTRAINT_PARAMETER_VALUE)
726 726
 				);
727 727
 			}
728 728
 		}
@@ -736,15 +736,15 @@  discard block
 block discarded – undo
736 736
 	 * @param ItemId $unitId
737 737
 	 * @return string unit
738 738
 	 */
739
-	private function parseUnitParameter( ItemId $unitId ) {
739
+	private function parseUnitParameter(ItemId $unitId) {
740 740
 		$unitRepositoryName = $unitId->getRepositoryName();
741
-		if ( !array_key_exists( $unitRepositoryName, $this->conceptBaseUris ) ) {
741
+		if (!array_key_exists($unitRepositoryName, $this->conceptBaseUris)) {
742 742
 			throw new LogicException(
743
-				'No base URI for concept URI for repository: ' . $unitRepositoryName
743
+				'No base URI for concept URI for repository: '.$unitRepositoryName
744 744
 			);
745 745
 		}
746 746
 		$baseUri = $this->conceptBaseUris[$unitRepositoryName];
747
-		return $baseUri . $unitId->getSerialization();
747
+		return $baseUri.$unitId->getSerialization();
748 748
 	}
749 749
 
750 750
 	/**
@@ -754,23 +754,23 @@  discard block
 block discarded – undo
754 754
 	 * @return UnitsParameter
755 755
 	 * @throws ConstraintParameterException
756 756
 	 */
757
-	private function parseUnitItem( ItemIdSnakValue $item ) {
758
-		switch ( true ) {
757
+	private function parseUnitItem(ItemIdSnakValue $item) {
758
+		switch (true) {
759 759
 			case $item->isValue():
760
-				$unit = $this->parseUnitParameter( $item->getItemId() );
760
+				$unit = $this->parseUnitParameter($item->getItemId());
761 761
 				return new UnitsParameter(
762
-					[ $item->getItemId() ],
763
-					[ UnboundedQuantityValue::newFromNumber( 1, $unit ) ],
762
+					[$item->getItemId()],
763
+					[UnboundedQuantityValue::newFromNumber(1, $unit)],
764 764
 					false
765 765
 				);
766 766
 			case $item->isSomeValue():
767
-				$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
767
+				$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
768 768
 				throw new ConstraintParameterException(
769
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
770
-						->withEntityId( new PropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
769
+					(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
770
+						->withEntityId(new PropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
771 771
 				);
772 772
 			case $item->isNoValue():
773
-				return new UnitsParameter( [], [], true );
773
+				return new UnitsParameter([], [], true);
774 774
 		}
775 775
 	}
776 776
 
@@ -780,26 +780,26 @@  discard block
 block discarded – undo
780 780
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
781 781
 	 * @return UnitsParameter
782 782
 	 */
783
-	public function parseUnitsParameter( array $constraintParameters, $constraintTypeItemId ) {
784
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
783
+	public function parseUnitsParameter(array $constraintParameters, $constraintTypeItemId) {
784
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
785 785
 		$unitItems = [];
786 786
 		$unitQuantities = [];
787 787
 		$unitlessAllowed = false;
788 788
 
789
-		foreach ( $items as $item ) {
790
-			$unit = $this->parseUnitItem( $item );
791
-			$unitItems = array_merge( $unitItems, $unit->getUnitItemIds() );
792
-			$unitQuantities = array_merge( $unitQuantities, $unit->getUnitQuantities() );
789
+		foreach ($items as $item) {
790
+			$unit = $this->parseUnitItem($item);
791
+			$unitItems = array_merge($unitItems, $unit->getUnitItemIds());
792
+			$unitQuantities = array_merge($unitQuantities, $unit->getUnitQuantities());
793 793
 			$unitlessAllowed = $unitlessAllowed || $unit->getUnitlessAllowed();
794 794
 		}
795 795
 
796
-		if ( $unitQuantities === [] && !$unitlessAllowed ) {
796
+		if ($unitQuantities === [] && !$unitlessAllowed) {
797 797
 			throw new LogicException(
798 798
 				'The "units" parameter is required, and yet we seem to be missing any allowed unit'
799 799
 			);
800 800
 		}
801 801
 
802
-		return new UnitsParameter( $unitItems, $unitQuantities, $unitlessAllowed );
802
+		return new UnitsParameter($unitItems, $unitQuantities, $unitlessAllowed);
803 803
 	}
804 804
 
805 805
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/AllowedUnitsChecker.php 1 patch
Spacing   +34 added lines, -35 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * @throws ConstraintParameterException
76 76
 	 * @return CheckResult
77 77
 	 */
78
-	public function checkConstraint( Context $context, Constraint $constraint ) {
78
+	public function checkConstraint(Context $context, Constraint $constraint) {
79 79
 		$parameters = [];
80 80
 		$constraintParameters = $constraint->getConstraintParameters();
81 81
 		$unitsParameter = $this->constraintParameterParser
@@ -85,50 +85,49 @@  discard block
 block discarded – undo
85 85
 			);
86 86
 
87 87
 		$snak = $context->getSnak();
88
-		if ( !$snak instanceof PropertyValueSnak ) {
88
+		if (!$snak instanceof PropertyValueSnak) {
89 89
 			// nothing to check
90
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
90
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
91 91
 		}
92 92
 
93 93
 		$dataValue = $snak->getDataValue();
94
-		if ( !$dataValue instanceof UnboundedQuantityValue ) {
95
-			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
96
-				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
97
-				->withDataValueType( 'quantity' );
98
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
94
+		if (!$dataValue instanceof UnboundedQuantityValue) {
95
+			$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type'))
96
+				->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM)
97
+				->withDataValueType('quantity');
98
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
99 99
 		}
100 100
 
101
-		if ( $dataValue->getUnit() === '1' ) {
102
-			return $this->checkUnitless( $context, $constraint, $unitsParameter, $snak );
101
+		if ($dataValue->getUnit() === '1') {
102
+			return $this->checkUnitless($context, $constraint, $unitsParameter, $snak);
103 103
 		}
104 104
 
105 105
 		$status = CheckResult::STATUS_VIOLATION;
106
-		$actualUnit = $this->standardize( $dataValue )->getUnit();
107
-		foreach ( $unitsParameter->getUnitQuantities() as $unitQuantity ) {
108
-			$allowedUnit = $this->standardize( $unitQuantity )->getUnit();
109
-			if ( $actualUnit === $allowedUnit ) {
106
+		$actualUnit = $this->standardize($dataValue)->getUnit();
107
+		foreach ($unitsParameter->getUnitQuantities() as $unitQuantity) {
108
+			$allowedUnit = $this->standardize($unitQuantity)->getUnit();
109
+			if ($actualUnit === $allowedUnit) {
110 110
 				$status = CheckResult::STATUS_COMPLIANCE;
111 111
 				break;
112 112
 			}
113 113
 		}
114 114
 
115
-		if ( $status === CheckResult::STATUS_VIOLATION ) {
116
-			if ( $unitsParameter->getUnitItemIds() === [] ) {
117
-				$message = ( new ViolationMessage( 'wbqc-violation-message-units-none' ) )
118
-					->withEntityId( $snak->getPropertyId(), Role::CONSTRAINT_PROPERTY );
115
+		if ($status === CheckResult::STATUS_VIOLATION) {
116
+			if ($unitsParameter->getUnitItemIds() === []) {
117
+				$message = (new ViolationMessage('wbqc-violation-message-units-none'))
118
+					->withEntityId($snak->getPropertyId(), Role::CONSTRAINT_PROPERTY);
119 119
 			} else {
120 120
 				$messageKey = $unitsParameter->getUnitlessAllowed() ?
121
-					'wbqc-violation-message-units-or-none' :
122
-					'wbqc-violation-message-units';
123
-				$message = ( new ViolationMessage( $messageKey ) )
124
-					->withEntityId( $snak->getPropertyId(), Role::CONSTRAINT_PROPERTY )
125
-					->withEntityIdList( $unitsParameter->getUnitItemIds(), Role::CONSTRAINT_PARAMETER_VALUE );
121
+					'wbqc-violation-message-units-or-none' : 'wbqc-violation-message-units';
122
+				$message = (new ViolationMessage($messageKey))
123
+					->withEntityId($snak->getPropertyId(), Role::CONSTRAINT_PROPERTY)
124
+					->withEntityIdList($unitsParameter->getUnitItemIds(), Role::CONSTRAINT_PARAMETER_VALUE);
126 125
 			}
127 126
 		} else {
128 127
 			$message = null;
129 128
 		}
130 129
 
131
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
130
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
132 131
 	}
133 132
 
134 133
 	/**
@@ -144,17 +143,17 @@  discard block
 block discarded – undo
144 143
 		UnitsParameter $unitsParameter,
145 144
 		PropertyValueSnak $snak
146 145
 	) {
147
-		if ( $unitsParameter->getUnitlessAllowed() ) {
146
+		if ($unitsParameter->getUnitlessAllowed()) {
148 147
 			$message = null;
149 148
 			$status = CheckResult::STATUS_COMPLIANCE;
150 149
 		} else {
151
-			$message = ( new ViolationMessage( 'wbqc-violation-message-units' ) )
152
-				->withEntityId( $snak->getPropertyId(), Role::CONSTRAINT_PROPERTY )
153
-				->withEntityIdList( $unitsParameter->getUnitItemIds(), Role::CONSTRAINT_PARAMETER_VALUE );
150
+			$message = (new ViolationMessage('wbqc-violation-message-units'))
151
+				->withEntityId($snak->getPropertyId(), Role::CONSTRAINT_PROPERTY)
152
+				->withEntityIdList($unitsParameter->getUnitItemIds(), Role::CONSTRAINT_PARAMETER_VALUE);
154 153
 			$status = CheckResult::STATUS_VIOLATION;
155 154
 		}
156 155
 
157
-		return new CheckResult( $context, $constraint, [], $status, $message );
156
+		return new CheckResult($context, $constraint, [], $status, $message);
158 157
 	}
159 158
 
160 159
 	/**
@@ -163,20 +162,20 @@  discard block
 block discarded – undo
163 162
 	 * @param UnboundedQuantityValue $value
164 163
 	 * @return UnboundedQuantityValue
165 164
 	 */
166
-	private function standardize( UnboundedQuantityValue $value ) {
167
-		if ( $this->unitConverter === null ) {
165
+	private function standardize(UnboundedQuantityValue $value) {
166
+		if ($this->unitConverter === null) {
168 167
 			return $value;
169 168
 		}
170 169
 
171
-		$standard = $this->unitConverter->toStandardUnits( $value );
172
-		if ( $standard !== null ) {
170
+		$standard = $this->unitConverter->toStandardUnits($value);
171
+		if ($standard !== null) {
173 172
 			return $standard;
174 173
 		} else {
175 174
 			return $value;
176 175
 		}
177 176
 	}
178 177
 
179
-	public function checkConstraintParameters( Constraint $constraint ) {
178
+	public function checkConstraintParameters(Constraint $constraint) {
180 179
 		$constraintParameters = $constraint->getConstraintParameters();
181 180
 		$exceptions = [];
182 181
 		try {
@@ -185,7 +184,7 @@  discard block
 block discarded – undo
185 184
 				$constraint->getConstraintTypeItemId(),
186 185
 				true
187 186
 			);
188
-		} catch ( ConstraintParameterException $e ) {
187
+		} catch (ConstraintParameterException $e) {
189 188
 			$exceptions[] = $e;
190 189
 		}
191 190
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/QualifierContext.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		Statement $statement,
24 24
 		Snak $snak
25 25
 	) {
26
-		parent::__construct( $entity, $snak );
26
+		parent::__construct($entity, $snak);
27 27
 		$this->statement = $statement;
28 28
 	}
29 29
 
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 		return self::TYPE_QUALIFIER;
32 32
 	}
33 33
 
34
-	public function getSnakGroup( $groupingMode ) {
34
+	public function getSnakGroup($groupingMode) {
35 35
 		$snaks = $this->statement->getQualifiers();
36
-		return array_values( $snaks->getArrayCopy() );
36
+		return array_values($snaks->getArrayCopy());
37 37
 	}
38 38
 
39 39
 	public function getCursor() {
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ReferenceContext.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 		Reference $reference,
31 31
 		Snak $snak
32 32
 	) {
33
-		parent::__construct( $entity, $snak );
33
+		parent::__construct($entity, $snak);
34 34
 		$this->statement = $statement;
35 35
 		$this->reference = $reference;
36 36
 	}
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 		return self::TYPE_REFERENCE;
40 40
 	}
41 41
 
42
-	public function getSnakGroup( $groupingMode ) {
42
+	public function getSnakGroup($groupingMode) {
43 43
 		$snaks = $this->reference->getSnaks();
44
-		return array_values( $snaks->getArrayCopy() );
44
+		return array_values($snaks->getArrayCopy());
45 45
 	}
46 46
 
47 47
 	public function getCursor() {
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/Context.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
 	 * @return Snak[] not a SnakList because for a statement context,
106 106
 	 * the returned value might contain the same snak several times.
107 107
 	 */
108
-	public function getSnakGroup( $groupingMode );
108
+	public function getSnakGroup($groupingMode);
109 109
 
110 110
 	/**
111 111
 	 * Get the cursor that can be used to address check results for this context.
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/MainSnakContext.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	private $statement;
23 23
 
24
-	public function __construct( EntityDocument $entity, Statement $statement ) {
25
-		Assert::parameterType( StatementListProvider::class, $entity, '$entity' );
26
-		parent::__construct( $entity, $statement->getMainSnak() );
24
+	public function __construct(EntityDocument $entity, Statement $statement) {
25
+		Assert::parameterType(StatementListProvider::class, $entity, '$entity');
26
+		parent::__construct($entity, $statement->getMainSnak());
27 27
 
28 28
 		$this->statement = $statement;
29 29
 	}
@@ -40,32 +40,32 @@  discard block
 block discarded – undo
40 40
 		return $this->statement;
41 41
 	}
42 42
 
43
-	public function getSnakGroup( $groupingMode ) {
43
+	public function getSnakGroup($groupingMode) {
44 44
 		/** @var StatementList $statements */
45 45
 		$statements = $this->entity->getStatements();
46
-		switch ( $groupingMode ) {
46
+		switch ($groupingMode) {
47 47
 			case Context::GROUP_NON_DEPRECATED:
48
-				$statements = $statements->getByRank( [
48
+				$statements = $statements->getByRank([
49 49
 					Statement::RANK_NORMAL,
50 50
 					Statement::RANK_PREFERRED,
51
-				] );
51
+				]);
52 52
 				break;
53 53
 			case Context::GROUP_BEST_RANK:
54
-				$statements = $this->getBestStatementsPerPropertyId( $statements );
54
+				$statements = $this->getBestStatementsPerPropertyId($statements);
55 55
 				break;
56 56
 			default:
57
-				throw new LogicException( 'Unknown $groupingMode ' . $groupingMode );
57
+				throw new LogicException('Unknown $groupingMode '.$groupingMode);
58 58
 		}
59 59
 		return $statements->getMainSnaks();
60 60
 	}
61 61
 
62
-	private function getBestStatementsPerPropertyId( StatementList $statements ) {
62
+	private function getBestStatementsPerPropertyId(StatementList $statements) {
63 63
 		$allBestStatements = new StatementList();
64
-		foreach ( $statements->getPropertyIds() as $propertyId ) {
65
-			$bestStatements = $statements->getByPropertyId( $propertyId )
64
+		foreach ($statements->getPropertyIds() as $propertyId) {
65
+			$bestStatements = $statements->getByPropertyId($propertyId)
66 66
 				->getBestStatements();
67
-			foreach ( $bestStatements as $bestStatement ) {
68
-				$allBestStatements->addStatement( $bestStatement );
67
+			foreach ($bestStatements as $bestStatement) {
68
+				$allBestStatements->addStatement($bestStatement);
69 69
 			}
70 70
 		}
71 71
 		return $allBestStatements;
Please login to merge, or discard this patch.