Completed
Push — master ( 49fffe...aa47cc )
by
unknown
02:48
created
src/ConstraintCheck/Checker/DiffWithinRangeChecker.php 1 patch
Spacing   +42 added lines, -43 removed lines patch added patch discarded remove patch
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 	 * @throws ConstraintParameterException
85 85
 	 * @return array [ DataValue|null $min, DataValue|null $max, PropertyId $property, array $parameters ]
86 86
 	 */
87
-	private function parseConstraintParameters( Constraint $constraint ) {
88
-		list( $min, $max ) = $this->constraintParameterParser->parseQuantityRangeParameter(
87
+	private function parseConstraintParameters(Constraint $constraint) {
88
+		list($min, $max) = $this->constraintParameterParser->parseQuantityRangeParameter(
89 89
 			$constraint->getConstraintParameters(),
90 90
 			$constraint->getConstraintTypeItemId()
91 91
 		);
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 			$constraint->getConstraintTypeItemId()
95 95
 		);
96 96
 
97
-		if ( $min !== null ) {
98
-			$parameters['minimum_quantity'] = [ $min ];
97
+		if ($min !== null) {
98
+			$parameters['minimum_quantity'] = [$min];
99 99
 		}
100
-		if ( $max !== null ) {
101
-			$parameters['maximum_quantity'] = [ $max ];
100
+		if ($max !== null) {
101
+			$parameters['maximum_quantity'] = [$max];
102 102
 		}
103
-		$parameters['property'] = [ $property ];
103
+		$parameters['property'] = [$property];
104 104
 
105
-		return [ $min, $max, $property, $parameters ];
105
+		return [$min, $max, $property, $parameters];
106 106
 	}
107 107
 
108 108
 	/**
@@ -112,13 +112,13 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @return bool
114 114
 	 */
115
-	private function rangeInYears( $min, $max ) {
116
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
115
+	private function rangeInYears($min, $max) {
116
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
117 117
 
118
-		if ( $min !== null && $min->getUnit() === $yearUnit ) {
118
+		if ($min !== null && $min->getUnit() === $yearUnit) {
119 119
 			return true;
120 120
 		}
121
-		if ( $max !== null && $max->getUnit() === $yearUnit ) {
121
+		if ($max !== null && $max->getUnit() === $yearUnit) {
122 122
 			return true;
123 123
 		}
124 124
 
@@ -134,59 +134,58 @@  discard block
 block discarded – undo
134 134
 	 * @throws ConstraintParameterException
135 135
 	 * @return CheckResult
136 136
 	 */
137
-	public function checkConstraint( Context $context, Constraint $constraint ) {
138
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
139
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
137
+	public function checkConstraint(Context $context, Constraint $constraint) {
138
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
139
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
140 140
 		}
141 141
 
142 142
 		$parameters = [];
143 143
 
144 144
 		$snak = $context->getSnak();
145 145
 
146
-		if ( !$snak instanceof PropertyValueSnak ) {
146
+		if (!$snak instanceof PropertyValueSnak) {
147 147
 			// nothing to check
148
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
148
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
149 149
 		}
150 150
 
151 151
 		$minuend = $snak->getDataValue();
152 152
 
153 153
 		/** @var PropertyId $property */
154
-		list( $min, $max, $property, $parameters ) = $this->parseConstraintParameters( $constraint );
154
+		list($min, $max, $property, $parameters) = $this->parseConstraintParameters($constraint);
155 155
 
156 156
 		// checks only the first occurrence of the referenced property (this constraint implies a single value constraint on that property)
157
-		foreach ( $context->getSnakGroup( Context::GROUP_NON_DEPRECATED ) as $otherSnak ) {
157
+		foreach ($context->getSnakGroup(Context::GROUP_NON_DEPRECATED) as $otherSnak) {
158 158
 			if (
159
-				!$property->equals( $otherSnak->getPropertyId() ) ||
159
+				!$property->equals($otherSnak->getPropertyId()) ||
160 160
 				!$otherSnak instanceof PropertyValueSnak
161 161
 			) {
162 162
 				continue;
163 163
 			}
164 164
 
165 165
 			$subtrahend = $otherSnak->getDataValue();
166
-			if ( $subtrahend->getType() === $minuend->getType() ) {
167
-				$diff = $this->rangeInYears( $min, $max ) && $minuend->getType() === 'time' ?
168
-					$this->rangeCheckerHelper->getDifferenceInYears( $minuend, $subtrahend ) :
169
-					$this->rangeCheckerHelper->getDifference( $minuend, $subtrahend );
166
+			if ($subtrahend->getType() === $minuend->getType()) {
167
+				$diff = $this->rangeInYears($min, $max) && $minuend->getType() === 'time' ?
168
+					$this->rangeCheckerHelper->getDifferenceInYears($minuend, $subtrahend) : $this->rangeCheckerHelper->getDifference($minuend, $subtrahend);
170 169
 
171
-				if ( $this->rangeCheckerHelper->getComparison( $min, $diff ) > 0 ||
172
-					$this->rangeCheckerHelper->getComparison( $diff, $max ) > 0
170
+				if ($this->rangeCheckerHelper->getComparison($min, $diff) > 0 ||
171
+					$this->rangeCheckerHelper->getComparison($diff, $max) > 0
173 172
 				) {
174 173
 					// at least one of $min, $max is set at this point, otherwise there could be no violation
175
-					$openness = $min !== null ? ( $max !== null ? '' : '-rightopen' ) : '-leftopen';
174
+					$openness = $min !== null ? ($max !== null ? '' : '-rightopen') : '-leftopen';
176 175
 					// possible message keys:
177 176
 					// wbqc-violation-message-diff-within-range
178 177
 					// wbqc-violation-message-diff-within-range-leftopen
179 178
 					// wbqc-violation-message-diff-within-range-rightopen
180
-					$message = ( new ViolationMessage( "wbqc-violation-message-diff-within-range$openness" ) )
181
-						->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE )
182
-						->withDataValue( $minuend, Role::OBJECT )
183
-						->withEntityId( $otherSnak->getPropertyId(), Role::PREDICATE )
184
-						->withDataValue( $subtrahend, Role::OBJECT );
185
-					if ( $min !== null ) {
186
-						$message = $message->withDataValue( $min, Role::OBJECT );
179
+					$message = (new ViolationMessage("wbqc-violation-message-diff-within-range$openness"))
180
+						->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)
181
+						->withDataValue($minuend, Role::OBJECT)
182
+						->withEntityId($otherSnak->getPropertyId(), Role::PREDICATE)
183
+						->withDataValue($subtrahend, Role::OBJECT);
184
+					if ($min !== null) {
185
+						$message = $message->withDataValue($min, Role::OBJECT);
187 186
 					}
188
-					if ( $max !== null ) {
189
-						$message = $message->withDataValue( $max, Role::OBJECT );
187
+					if ($max !== null) {
188
+						$message = $message->withDataValue($max, Role::OBJECT);
190 189
 					}
191 190
 					$status = CheckResult::STATUS_VIOLATION;
192 191
 				} else {
@@ -194,17 +193,17 @@  discard block
 block discarded – undo
194 193
 					$status = CheckResult::STATUS_COMPLIANCE;
195 194
 				}
196 195
 			} else {
197
-				$message = new ViolationMessage( 'wbqc-violation-message-diff-within-range-must-have-equal-types' );
196
+				$message = new ViolationMessage('wbqc-violation-message-diff-within-range-must-have-equal-types');
198 197
 				$status = CheckResult::STATUS_VIOLATION;
199 198
 			}
200 199
 
201
-			return new CheckResult( $context, $constraint, $parameters, $status, $message );
200
+			return new CheckResult($context, $constraint, $parameters, $status, $message);
202 201
 		}
203 202
 
204
-		return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
203
+		return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
205 204
 	}
206 205
 
207
-	public function checkConstraintParameters( Constraint $constraint ) {
206
+	public function checkConstraintParameters(Constraint $constraint) {
208 207
 		$constraintParameters = $constraint->getConstraintParameters();
209 208
 		$exceptions = [];
210 209
 		try {
@@ -212,12 +211,12 @@  discard block
 block discarded – undo
212 211
 				$constraintParameters,
213 212
 				$constraint->getConstraintTypeItemId()
214 213
 			);
215
-		} catch ( ConstraintParameterException $e ) {
214
+		} catch (ConstraintParameterException $e) {
216 215
 			$exceptions[] = $e;
217 216
 		}
218 217
 		try {
219
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
220
-		} catch ( ConstraintParameterException $e ) {
218
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
219
+		} catch (ConstraintParameterException $e) {
221 220
 			$exceptions[] = $e;
222 221
 		}
223 222
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/EntityTypeChecker.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 		];
60 60
 	}
61 61
 
62
-	public function checkConstraint( Context $context, Constraint $constraint ) {
63
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
64
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
62
+	public function checkConstraint(Context $context, Constraint $constraint) {
63
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
64
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
65 65
 		}
66 66
 
67 67
 		$constraintParameters = $constraint->getConstraintParameters();
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 		);
72 72
 		$parameters['item'] = $entityTypes->getEntityTypes();
73 73
 
74
-		if ( !in_array( $context->getEntity()->getType(), $entityTypes->getEntityTypes() ) ) {
75
-			$message = ( new ViolationMessage( 'wbqc-violation-message-entityType' ) )
76
-				->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY )
77
-				->withEntityIdList( $entityTypes->getEntityTypeItemIds(), Role::CONSTRAINT_PARAMETER_VALUE );
74
+		if (!in_array($context->getEntity()->getType(), $entityTypes->getEntityTypes())) {
75
+			$message = (new ViolationMessage('wbqc-violation-message-entityType'))
76
+				->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY)
77
+				->withEntityIdList($entityTypes->getEntityTypeItemIds(), Role::CONSTRAINT_PARAMETER_VALUE);
78 78
 
79 79
 			return new CheckResult(
80 80
 				$context,
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 			);
86 86
 		}
87 87
 
88
-		return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
88
+		return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
89 89
 	}
90 90
 
91
-	public function checkConstraintParameters( Constraint $constraint ) {
91
+	public function checkConstraintParameters(Constraint $constraint) {
92 92
 		$constraintParameters = $constraint->getConstraintParameters();
93 93
 		$exceptions = [];
94 94
 		try {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 				$constraintParameters,
97 97
 				$constraint->getConstraintTypeItemId()
98 98
 			);
99
-		} catch ( ConstraintParameterException $e ) {
99
+		} catch (ConstraintParameterException $e) {
100 100
 			$exceptions[] = $e;
101 101
 		}
102 102
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/NoneOfChecker.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
 	 * @throws ConstraintParameterException
69 69
 	 * @return CheckResult
70 70
 	 */
71
-	public function checkConstraint( Context $context, Constraint $constraint ) {
72
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
73
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
71
+	public function checkConstraint(Context $context, Constraint $constraint) {
72
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
73
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
74 74
 		}
75 75
 
76 76
 		$parameters = [];
77 77
 		$constraintParameters = $constraint->getConstraintParameters();
78 78
 
79
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true );
79
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true);
80 80
 		$parameters['item'] = $items;
81 81
 
82 82
 		$snak = $context->getSnak();
@@ -84,25 +84,25 @@  discard block
 block discarded – undo
84 84
 		$message = null;
85 85
 		$status = CheckResult::STATUS_COMPLIANCE;
86 86
 
87
-		foreach ( $items as $item ) {
88
-			if ( $item->matchesSnak( $snak ) ) {
89
-				$message = ( new ViolationMessage( 'wbqc-violation-message-none-of' ) )
90
-					->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE )
91
-					->withItemIdSnakValueList( $items, Role::OBJECT );
87
+		foreach ($items as $item) {
88
+			if ($item->matchesSnak($snak)) {
89
+				$message = (new ViolationMessage('wbqc-violation-message-none-of'))
90
+					->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)
91
+					->withItemIdSnakValueList($items, Role::OBJECT);
92 92
 				$status = CheckResult::STATUS_VIOLATION;
93 93
 				break;
94 94
 			}
95 95
 		}
96 96
 
97
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
97
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
98 98
 	}
99 99
 
100
-	public function checkConstraintParameters( Constraint $constraint ) {
100
+	public function checkConstraintParameters(Constraint $constraint) {
101 101
 		$constraintParameters = $constraint->getConstraintParameters();
102 102
 		$exceptions = [];
103 103
 		try {
104
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true );
105
-		} catch ( ConstraintParameterException $e ) {
104
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true);
105
+		} catch (ConstraintParameterException $e) {
106 106
 			$exceptions[] = $e;
107 107
 		}
108 108
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/LoggingHelper.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 		$this->dataFactory = $dataFactory;
47 47
 		$this->logger = $logger;
48 48
 		$this->constraintCheckDurationLimits = [
49
-			'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ),
50
-			'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ),
49
+			'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'),
50
+			'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'),
51 51
 		];
52 52
 	}
53 53
 
@@ -73,39 +73,39 @@  discard block
 block discarded – undo
73 73
 		$durationSeconds,
74 74
 		$method
75 75
 	) {
76
-		$constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 );
76
+		$constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1);
77 77
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
78 78
 
79 79
 		$this->dataFactory->timing(
80
-			'wikibase.quality.constraints.check.timing.' .
81
-				$constraintTypeItemId . '-' .
80
+			'wikibase.quality.constraints.check.timing.'.
81
+				$constraintTypeItemId.'-'.
82 82
 				$constraintCheckerClassShortName,
83 83
 			$durationSeconds * 1000
84 84
 		);
85 85
 
86 86
 		// find the longest limit (and associated log level) that the duration exceeds
87
-		foreach ( $this->constraintCheckDurationLimits as $level => $limit ) {
87
+		foreach ($this->constraintCheckDurationLimits as $level => $limit) {
88 88
 			if (
89 89
 				// duration exceeds this limit
90
-				isset( $limit ) && $durationSeconds > $limit &&
90
+				isset($limit) && $durationSeconds > $limit &&
91 91
 				// this limit is longer than previous longest limit
92
-				( !isset( $limitSeconds ) || $limit > $limitSeconds )
92
+				(!isset($limitSeconds) || $limit > $limitSeconds)
93 93
 			) {
94 94
 				$limitSeconds = $limit;
95 95
 				$logLevel = $level;
96 96
 			}
97 97
 		}
98 98
 
99
-		if ( !isset( $limitSeconds ) ) {
99
+		if (!isset($limitSeconds)) {
100 100
 			return;
101 101
 		}
102
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
102
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
103 103
 			// TODO log less details but still log something
104 104
 			return;
105 105
 		}
106 106
 
107 107
 		$resultMessage = $result->getMessage();
108
-		if ( $resultMessage !== null ) {
108
+		if ($resultMessage !== null) {
109 109
 			$resultMessageKey = $resultMessage->getMessageKey();
110 110
 		} else {
111 111
 			$resultMessageKey = null;
@@ -113,8 +113,8 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$this->logger->log(
115 115
 			$logLevel,
116
-			'Constraint check with {constraintCheckerClassShortName} ' .
117
-			'took longer than {limitSeconds} second(s) ' .
116
+			'Constraint check with {constraintCheckerClassShortName} '.
117
+			'took longer than {limitSeconds} second(s) '.
118 118
 			'(duration: {durationSeconds} seconds).',
119 119
 			[
120 120
 				'method' => $method,
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @param EntityId $entityId
143 143
 	 */
144
-	public function logCheckConstraintsCacheHit( EntityId $entityId ) {
144
+	public function logCheckConstraintsCacheHit(EntityId $entityId) {
145 145
 		$this->dataFactory->increment(
146 146
 			'wikibase.quality.constraints.cache.entity.hit'
147 147
 		);
@@ -152,10 +152,10 @@  discard block
 block discarded – undo
152 152
 	 *
153 153
 	 * @param EntityId[] $entityIds
154 154
 	 */
155
-	public function logCheckConstraintsCacheMisses( array $entityIds ) {
155
+	public function logCheckConstraintsCacheMisses(array $entityIds) {
156 156
 		$this->dataFactory->updateCount(
157 157
 			'wikibase.quality.constraints.cache.entity.miss',
158
-			count( $entityIds )
158
+			count($entityIds)
159 159
 		);
160 160
 	}
161 161
 
@@ -182,16 +182,16 @@  discard block
 block discarded – undo
182 182
 	 * @param EntityId[] $entityIds
183 183
 	 * @param int $maxRevisionIds
184 184
 	 */
185
-	public function logHugeDependencyMetadata( array $entityIds, $maxRevisionIds ) {
185
+	public function logHugeDependencyMetadata(array $entityIds, $maxRevisionIds) {
186 186
 		$this->logger->log(
187 187
 			'warning',
188
-			'Dependency metadata for constraint check result has huge set of entity IDs ' .
189
-			'(count ' . count( $entityIds ) . ', limit ' . $maxRevisionIds . '); ' .
188
+			'Dependency metadata for constraint check result has huge set of entity IDs '.
189
+			'(count '.count($entityIds).', limit '.$maxRevisionIds.'); '.
190 190
 			'caching disabled for this check result.',
191 191
 			[
192 192
 				'loggingMethod' => __METHOD__,
193 193
 				'entityIds' => array_map(
194
-					function ( EntityId $entityId ) {
194
+					function(EntityId $entityId) {
195 195
 						return $entityId->getSerialization();
196 196
 					},
197 197
 					$entityIds
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +265 added lines, -265 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
 	/**
@@ -809,41 +809,41 @@  discard block
 block discarded – undo
809 809
 	 * @return EntityTypesParameter
810 810
 	 * @throws ConstraintParameterException
811 811
 	 */
812
-	private function parseEntityTypeItem( ItemIdSnakValue $item ) {
813
-		$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
812
+	private function parseEntityTypeItem(ItemIdSnakValue $item) {
813
+		$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
814 814
 
815
-		if ( !$item->isValue() ) {
815
+		if (!$item->isValue()) {
816 816
 			throw new ConstraintParameterException(
817
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
818
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
817
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
818
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
819 819
 			);
820 820
 		}
821 821
 
822 822
 		$itemId = $item->getItemId();
823
-		switch ( $itemId->getSerialization() ) {
824
-			case $this->config->get( 'WBQualityConstraintsWikibaseItemId' ):
823
+		switch ($itemId->getSerialization()) {
824
+			case $this->config->get('WBQualityConstraintsWikibaseItemId'):
825 825
 				$entityType = 'item';
826 826
 				break;
827
-			case $this->config->get( 'WBQualityConstraintsWikibasePropertyId' ):
827
+			case $this->config->get('WBQualityConstraintsWikibasePropertyId'):
828 828
 				$entityType = 'property';
829 829
 				break;
830
-			case $this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ):
830
+			case $this->config->get('WBQualityConstraintsWikibaseLexemeId'):
831 831
 				$entityType = 'lexeme';
832 832
 				break;
833 833
 			default:
834 834
 				$allowed = [
835
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseItemId' ) ),
836
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibasePropertyId' ) ),
837
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ) ),
835
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseItemId')),
836
+					new ItemId($this->config->get('WBQualityConstraintsWikibasePropertyId')),
837
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseLexemeId')),
838 838
 				];
839 839
 				throw new ConstraintParameterException(
840
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
841
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
842
-						->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
840
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
841
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
842
+						->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
843 843
 				);
844 844
 		}
845 845
 
846
-		return new EntityTypesParameter( [ $entityType ], [ $itemId ] );
846
+		return new EntityTypesParameter([$entityType], [$itemId]);
847 847
 	}
848 848
 
849 849
 	/**
@@ -852,27 +852,27 @@  discard block
 block discarded – undo
852 852
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
853 853
 	 * @return EntityTypesParameter
854 854
 	 */
855
-	public function parseEntityTypesParameter( array $constraintParameters, $constraintTypeItemId ) {
855
+	public function parseEntityTypesParameter(array $constraintParameters, $constraintTypeItemId) {
856 856
 		$entityTypes = [];
857 857
 		$entityTypeItemIds = [];
858
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
858
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
859 859
 
860
-		foreach ( $items as $item ) {
861
-			$entityType = $this->parseEntityTypeItem( $item );
862
-			$entityTypes = array_merge( $entityTypes, $entityType->getEntityTypes() );
863
-			$entityTypeItemIds = array_merge( $entityTypeItemIds, $entityType->getEntityTypeItemIds() );
860
+		foreach ($items as $item) {
861
+			$entityType = $this->parseEntityTypeItem($item);
862
+			$entityTypes = array_merge($entityTypes, $entityType->getEntityTypes());
863
+			$entityTypeItemIds = array_merge($entityTypeItemIds, $entityType->getEntityTypeItemIds());
864 864
 		}
865 865
 
866
-		if ( empty( $entityTypes ) ) {
866
+		if (empty($entityTypes)) {
867 867
 			// @codeCoverageIgnoreStart
868 868
 			throw new LogicException(
869
-				'The "entity types" parameter is required, ' .
869
+				'The "entity types" parameter is required, '.
870 870
 				'and yet we seem to be missing any allowed entity type'
871 871
 			);
872 872
 			// @codeCoverageIgnoreEnd
873 873
 		}
874 874
 
875
-		return new EntityTypesParameter( $entityTypes, $entityTypeItemIds );
875
+		return new EntityTypesParameter($entityTypes, $entityTypeItemIds);
876 876
 	}
877 877
 
878 878
 	/**
@@ -880,18 +880,18 @@  discard block
 block discarded – undo
880 880
 	 * @throws ConstraintParameterException if the parameter is invalid
881 881
 	 * @return PropertyId[]
882 882
 	 */
883
-	public function parseSeparatorsParameter( array $constraintParameters ) {
884
-		$separatorId = $this->config->get( 'WBQualityConstraintsSeparatorId' );
883
+	public function parseSeparatorsParameter(array $constraintParameters) {
884
+		$separatorId = $this->config->get('WBQualityConstraintsSeparatorId');
885 885
 
886
-		if ( !array_key_exists( $separatorId, $constraintParameters ) ) {
886
+		if (!array_key_exists($separatorId, $constraintParameters)) {
887 887
 			return [];
888 888
 		}
889 889
 
890 890
 		$parameters = $constraintParameters[$separatorId];
891 891
 		$separators = [];
892 892
 
893
-		foreach ( $parameters as $parameter ) {
894
-			$separators[] = $this->parsePropertyIdParameter( $parameter, $separatorId );
893
+		foreach ($parameters as $parameter) {
894
+			$separators[] = $this->parsePropertyIdParameter($parameter, $separatorId);
895 895
 		}
896 896
 
897 897
 		return $separators;
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/MainSnakContext.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	private $statement;
26 26
 
27
-	public function __construct( EntityDocument $entity, Statement $statement ) {
28
-		Assert::parameterType( StatementListProvider::class, $entity, '$entity' );
29
-		parent::__construct( $entity, $statement->getMainSnak() );
27
+	public function __construct(EntityDocument $entity, Statement $statement) {
28
+		Assert::parameterType(StatementListProvider::class, $entity, '$entity');
29
+		parent::__construct($entity, $statement->getMainSnak());
30 30
 
31 31
 		$this->statement = $statement;
32 32
 	}
@@ -43,21 +43,21 @@  discard block
 block discarded – undo
43 43
 		return $this->statement;
44 44
 	}
45 45
 
46
-	public function getSnakGroup( $groupingMode, array $separators = [] ) {
46
+	public function getSnakGroup($groupingMode, array $separators = []) {
47 47
 		/** @var StatementList $statements */
48 48
 		$statements = $this->entity->getStatements();
49
-		switch ( $groupingMode ) {
49
+		switch ($groupingMode) {
50 50
 			case Context::GROUP_NON_DEPRECATED:
51
-				$statements = $statements->getByRank( [
51
+				$statements = $statements->getByRank([
52 52
 					Statement::RANK_NORMAL,
53 53
 					Statement::RANK_PREFERRED,
54
-				] );
54
+				]);
55 55
 				break;
56 56
 			case Context::GROUP_BEST_RANK:
57
-				$statements = $this->getBestStatementsPerPropertyId( $statements );
57
+				$statements = $this->getBestStatementsPerPropertyId($statements);
58 58
 				break;
59 59
 			default:
60
-				throw new LogicException( 'Unknown $groupingMode ' . $groupingMode );
60
+				throw new LogicException('Unknown $groupingMode '.$groupingMode);
61 61
 		}
62 62
 		return $this->getStatementsWithSameQualifiersForProperties(
63 63
 			$this->statement,
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 		)->getMainSnaks();
67 67
 	}
68 68
 
69
-	private function getBestStatementsPerPropertyId( StatementList $statements ) {
69
+	private function getBestStatementsPerPropertyId(StatementList $statements) {
70 70
 		$allBestStatements = new StatementList();
71
-		foreach ( $statements->getPropertyIds() as $propertyId ) {
72
-			$bestStatements = $statements->getByPropertyId( $propertyId )
71
+		foreach ($statements->getPropertyIds() as $propertyId) {
72
+			$bestStatements = $statements->getByPropertyId($propertyId)
73 73
 				->getBestStatements();
74
-			foreach ( $bestStatements as $bestStatement ) {
75
-				$allBestStatements->addStatement( $bestStatement );
74
+			foreach ($bestStatements as $bestStatement) {
75
+				$allBestStatements->addStatement($bestStatement);
76 76
 			}
77 77
 		}
78 78
 		return $allBestStatements;
@@ -94,20 +94,20 @@  discard block
 block discarded – undo
94 94
 		array $qualifierPropertyIds
95 95
 	) {
96 96
 		$similarStatements = new StatementList();
97
-		foreach ( $allStatements as $statement ) {
98
-			if ( $statement === $currentStatement ) {
97
+		foreach ($allStatements as $statement) {
98
+			if ($statement === $currentStatement) {
99 99
 				// if the statement has an “unknown value” qualifier,
100 100
 				// it might be considered different from itself,
101 101
 				// so add it explicitly to ensure it’s always included
102
-				$similarStatements->addStatement( $statement );
102
+				$similarStatements->addStatement($statement);
103 103
 				continue;
104 104
 			}
105
-			foreach ( $qualifierPropertyIds as $qualifierPropertyId ) {
106
-				if ( !$this->haveSameQualifiers( $currentStatement, $statement, $qualifierPropertyId ) ) {
105
+			foreach ($qualifierPropertyIds as $qualifierPropertyId) {
106
+				if (!$this->haveSameQualifiers($currentStatement, $statement, $qualifierPropertyId)) {
107 107
 					continue 2;
108 108
 				}
109 109
 			}
110
-			$similarStatements->addStatement( $statement );
110
+			$similarStatements->addStatement($statement);
111 111
 		}
112 112
 		return $similarStatements;
113 113
 	}
@@ -121,19 +121,19 @@  discard block
 block discarded – undo
121 121
 	 * @param PropertyId $propertyId
122 122
 	 * @return bool
123 123
 	 */
124
-	private function haveSameQualifiers( Statement $s1, Statement $s2, PropertyId $propertyId ) {
125
-		$q1 = $this->getSnaksWithPropertyId( $s1->getQualifiers(), $propertyId );
126
-		$q2 = $this->getSnaksWithPropertyId( $s2->getQualifiers(), $propertyId );
124
+	private function haveSameQualifiers(Statement $s1, Statement $s2, PropertyId $propertyId) {
125
+		$q1 = $this->getSnaksWithPropertyId($s1->getQualifiers(), $propertyId);
126
+		$q2 = $this->getSnaksWithPropertyId($s2->getQualifiers(), $propertyId);
127 127
 
128
-		if ( $q1->count() !== $q2->count() ) {
128
+		if ($q1->count() !== $q2->count()) {
129 129
 			return false;
130 130
 		}
131 131
 
132
-		foreach ( $q1 as $qualifier ) {
133
-			switch ( $qualifier->getType() ) {
132
+		foreach ($q1 as $qualifier) {
133
+			switch ($qualifier->getType()) {
134 134
 				case 'value':
135 135
 				case 'novalue':
136
-					if ( !$q2->hasSnak( $qualifier ) ) {
136
+					if (!$q2->hasSnak($qualifier)) {
137 137
 						return false;
138 138
 					}
139 139
 					break;
@@ -155,12 +155,12 @@  discard block
 block discarded – undo
155 155
 	 * @param PropertyId $propertyId
156 156
 	 * @return SnakList
157 157
 	 */
158
-	private function getSnaksWithPropertyId( SnakList $allSnaks, PropertyId $propertyId ) {
158
+	private function getSnaksWithPropertyId(SnakList $allSnaks, PropertyId $propertyId) {
159 159
 		$snaks = new SnakList();
160 160
 		/** @var Snak $snak */
161
-		foreach ( $allSnaks as $snak ) {
162
-			if ( $snak->getPropertyId()->equals( $propertyId ) ) {
163
-				$snaks->addSnak( $snak );
161
+		foreach ($allSnaks as $snak) {
162
+			if ($snak->getPropertyId()->equals($propertyId)) {
163
+				$snaks->addSnak($snak);
164 164
 			}
165 165
 		}
166 166
 		return $snaks;
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, array $separators = [] ) {
34
+	public function getSnakGroup($groupingMode, array $separators = []) {
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, array $separators = [] ) {
42
+	public function getSnakGroup($groupingMode, array $separators = []) {
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
@@ -109,7 +109,7 @@
 block discarded – undo
109 109
 	 * @return Snak[] not a SnakList because for a statement context,
110 110
 	 * the returned value might contain the same snak several times.
111 111
 	 */
112
-	public function getSnakGroup( $groupingMode, array $separators = [] );
112
+	public function getSnakGroup($groupingMode, array $separators = []);
113 113
 
114 114
 	/**
115 115
 	 * Get the cursor that can be used to address check results for this context.
Please login to merge, or discard this patch.