Completed
Push — master ( cd9049...efe5a3 )
by
unknown
23s
created
src/ConstraintCheck/Helper/TypeCheckerHelper.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -81,26 +81,26 @@  discard block
 block discarded – undo
81 81
 	 * @return bool
82 82
 	 * @throws OverflowException if $entitiesChecked exceeds the configured limit
83 83
 	 */
84
-	private function isSubclassOf( EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0 ) {
85
-		$maxEntities = $this->config->get( 'WBQualityConstraintsTypeCheckMaxEntities' );
84
+	private function isSubclassOf(EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0) {
85
+		$maxEntities = $this->config->get('WBQualityConstraintsTypeCheckMaxEntities');
86 86
 		if ( ++$entitiesChecked > $maxEntities ) {
87
-			throw new OverflowException( 'Too many entities to check' );
87
+			throw new OverflowException('Too many entities to check');
88 88
 		}
89 89
 
90
-		$item = $this->entityLookup->getEntity( $comparativeClass );
91
-		if ( !( $item instanceof StatementListProvider ) ) {
90
+		$item = $this->entityLookup->getEntity($comparativeClass);
91
+		if (!($item instanceof StatementListProvider)) {
92 92
 			return false; // lookup failed, probably because item doesn't exist
93 93
 		}
94 94
 
95
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
95
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfId');
96 96
 		$statements = $item->getStatements()
97
-			->getByPropertyId( new NumericPropertyId( $subclassId ) )
97
+			->getByPropertyId(new NumericPropertyId($subclassId))
98 98
 			->getBestStatements();
99 99
 		/** @var Statement $statement */
100
-		foreach ( $statements as $statement ) {
100
+		foreach ($statements as $statement) {
101 101
 			$mainSnak = $statement->getMainSnak();
102 102
 
103
-			if ( !$this->hasCorrectType( $mainSnak ) ) {
103
+			if (!$this->hasCorrectType($mainSnak)) {
104 104
 				continue;
105 105
 			}
106 106
 			/** @var PropertyValueSnak $mainSnak */
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
 			'@phan-var EntityIdValue $dataValue';
111 111
 			$comparativeClass = $dataValue->getEntityId();
112 112
 
113
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
113
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
114 114
 				return true;
115 115
 			}
116 116
 
117
-			if ( $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ) ) {
117
+			if ($this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked)) {
118 118
 				return true;
119 119
 			}
120 120
 		}
@@ -135,40 +135,40 @@  discard block
 block discarded – undo
135 135
 	 * @return CachedBool
136 136
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
137 137
 	 */
138
-	public function isSubclassOfWithSparqlFallback( EntityId $comparativeClass, array $classesToCheck ) {
139
-		$timing = $this->statsFactory->getTiming( 'isSubclassOf_duration_seconds' )
140
-			->setLabel( 'result', 'success' )
141
-			->setLabel( 'TypeCheckerImplementation', 'php' )
142
-			->copyToStatsdAt( 'wikibase.quality.constraints.type.php.success.timing' );
138
+	public function isSubclassOfWithSparqlFallback(EntityId $comparativeClass, array $classesToCheck) {
139
+		$timing = $this->statsFactory->getTiming('isSubclassOf_duration_seconds')
140
+			->setLabel('result', 'success')
141
+			->setLabel('TypeCheckerImplementation', 'php')
142
+			->copyToStatsdAt('wikibase.quality.constraints.type.php.success.timing');
143 143
 		$timing->start();
144 144
 
145 145
 		try {
146 146
 			$entitiesChecked = 0;
147
-			$isSubclass = $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked );
147
+			$isSubclass = $this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked);
148 148
 			$timing->stop();
149 149
 
150 150
 			// not really a timing, but works like one (we want percentiles etc.)
151 151
 			// TODO: probably a good candidate for T348796
152
-			$this->statsFactory->getTiming( 'isSubclassOf_entities_total' )
153
-				->setLabel( 'TypeCheckerImplementation', 'php' )
154
-				->setLabel( 'result', 'success' )
155
-				->copyToStatsdAt( 'wikibase.quality.constraints.type.php.success.entities' )
156
-				->observe( $entitiesChecked );
157
-
158
-			return new CachedBool( $isSubclass, Metadata::blank() );
159
-		} catch ( OverflowException ) {
160
-			$timing->setLabel( 'result', 'overflow' )
161
-				->copyToStatsdAt( 'wikibase.quality.constraints.type.php.overflow.timing' )
152
+			$this->statsFactory->getTiming('isSubclassOf_entities_total')
153
+				->setLabel('TypeCheckerImplementation', 'php')
154
+				->setLabel('result', 'success')
155
+				->copyToStatsdAt('wikibase.quality.constraints.type.php.success.entities')
156
+				->observe($entitiesChecked);
157
+
158
+			return new CachedBool($isSubclass, Metadata::blank());
159
+		} catch (OverflowException) {
160
+			$timing->setLabel('result', 'overflow')
161
+				->copyToStatsdAt('wikibase.quality.constraints.type.php.overflow.timing')
162 162
 				->stop();
163 163
 
164
-			if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) {
165
-				$this->statsFactory->getCounter( 'sparql_typeFallback_total' )
166
-					->copyToStatsdAt( 'wikibase.quality.constraints.sparql.typeFallback' )
164
+			if (!($this->sparqlHelper instanceof DummySparqlHelper)) {
165
+				$this->statsFactory->getCounter('sparql_typeFallback_total')
166
+					->copyToStatsdAt('wikibase.quality.constraints.sparql.typeFallback')
167 167
 					->increment();
168 168
 
169
-				$timing->setLabel( 'TypeCheckerImplementation', 'sparql' )
170
-					->setLabel( 'result', 'success' )
171
-					->copyToStatsdAt( 'wikibase.quality.constraints.type.sparql.success.timing' )
169
+				$timing->setLabel('TypeCheckerImplementation', 'sparql')
170
+					->setLabel('result', 'success')
171
+					->copyToStatsdAt('wikibase.quality.constraints.type.sparql.success.timing')
172 172
 					->start();
173 173
 
174 174
 				$hasType = $this->sparqlHelper->hasType(
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
 				return $hasType;
182 182
 			} else {
183
-				return new CachedBool( false, Metadata::blank() );
183
+				return new CachedBool(false, Metadata::blank());
184 184
 			}
185 185
 		}
186 186
 	}
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
 	 * @return CachedBool
199 199
 	 * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs
200 200
 	 */
201
-	public function hasClassInRelation( StatementList $statements, array $relationIds, array $classesToCheck ) {
201
+	public function hasClassInRelation(StatementList $statements, array $relationIds, array $classesToCheck) {
202 202
 		$metadatas = [];
203 203
 
204
-		foreach ( $this->getBestStatementsByPropertyIds( $statements, $relationIds ) as $statement ) {
204
+		foreach ($this->getBestStatementsByPropertyIds($statements, $relationIds) as $statement) {
205 205
 			$mainSnak = $statement->getMainSnak();
206 206
 
207
-			if ( !$this->hasCorrectType( $mainSnak ) ) {
207
+			if (!$this->hasCorrectType($mainSnak)) {
208 208
 				continue;
209 209
 			}
210 210
 			/** @var PropertyValueSnak $mainSnak */
@@ -214,24 +214,24 @@  discard block
 block discarded – undo
214 214
 			'@phan-var EntityIdValue $dataValue';
215 215
 			$comparativeClass = $dataValue->getEntityId();
216 216
 
217
-			if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) {
217
+			if (in_array($comparativeClass->getSerialization(), $classesToCheck)) {
218 218
 				// discard $metadatas, we know this is fresh
219
-				return new CachedBool( true, Metadata::blank() );
219
+				return new CachedBool(true, Metadata::blank());
220 220
 			}
221 221
 
222
-			$result = $this->isSubclassOfWithSparqlFallback( $comparativeClass, $classesToCheck );
222
+			$result = $this->isSubclassOfWithSparqlFallback($comparativeClass, $classesToCheck);
223 223
 			$metadatas[] = $result->getMetadata();
224
-			if ( $result->getBool() ) {
224
+			if ($result->getBool()) {
225 225
 				return new CachedBool(
226 226
 					true,
227
-					Metadata::merge( $metadatas )
227
+					Metadata::merge($metadatas)
228 228
 				);
229 229
 			}
230 230
 		}
231 231
 
232 232
 		return new CachedBool(
233 233
 			false,
234
-			Metadata::merge( $metadatas )
234
+			Metadata::merge($metadatas)
235 235
 		);
236 236
 	}
237 237
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	 * @return bool
241 241
 	 * @phan-assert PropertyValueSnak $mainSnak
242 242
 	 */
243
-	private function hasCorrectType( Snak $mainSnak ) {
243
+	private function hasCorrectType(Snak $mainSnak) {
244 244
 		return $mainSnak instanceof PropertyValueSnak
245 245
 			&& $mainSnak->getDataValue()->getType() === 'wikibase-entityid';
246 246
 	}
@@ -257,15 +257,15 @@  discard block
 block discarded – undo
257 257
 	) {
258 258
 		$statementArrays = [];
259 259
 
260
-		foreach ( $propertyIdSerializations as $propertyIdSerialization ) {
261
-			$propertyId = new NumericPropertyId( $propertyIdSerialization );
260
+		foreach ($propertyIdSerializations as $propertyIdSerialization) {
261
+			$propertyId = new NumericPropertyId($propertyIdSerialization);
262 262
 			$statementArrays[] = $statements
263
-				->getByPropertyId( $propertyId )
263
+				->getByPropertyId($propertyId)
264 264
 				->getBestStatements()
265 265
 				->toArray();
266 266
 		}
267 267
 
268
-		return array_merge( ...$statementArrays );
268
+		return array_merge(...$statementArrays);
269 269
 	}
270 270
 
271 271
 	/**
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 		$relation
286 286
 	) {
287 287
 		$classes = array_map(
288
-			static function ( $itemIdSerialization ) {
289
-				return new ItemId( $itemIdSerialization );
288
+			static function($itemIdSerialization) {
289
+				return new ItemId($itemIdSerialization);
290 290
 			},
291 291
 			$classes
292 292
 		);
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 		// wbqc-violation-message-valueType-instance
299 299
 		// wbqc-violation-message-valueType-subclass
300 300
 		// wbqc-violation-message-valueType-instanceOrSubclass
301
-		return ( new ViolationMessage( 'wbqc-violation-message-' . $checker . '-' . $relation ) )
302
-			->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY )
303
-			->withEntityId( $entityId, Role::SUBJECT )
304
-			->withEntityIdList( $classes, Role::OBJECT );
301
+		return (new ViolationMessage('wbqc-violation-message-'.$checker.'-'.$relation))
302
+			->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY)
303
+			->withEntityId($entityId, Role::SUBJECT)
304
+			->withEntityIdList($classes, Role::OBJECT);
305 305
 	}
306 306
 
307 307
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Helper;
6 6
 
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
 	 * Check if any errors are recorded in the constraint parameters.
69 69
 	 * @throws ConstraintParameterException
70 70
 	 */
71
-	public function checkError( array $parameters ): void {
72
-		if ( array_key_exists( '@error', $parameters ) ) {
71
+	public function checkError(array $parameters): void {
72
+		if (array_key_exists('@error', $parameters)) {
73 73
 			$error = $parameters['@error'];
74
-			if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) {
74
+			if (array_key_exists('toolong', $error) && $error['toolong']) {
75 75
 				$msg = 'wbqc-violation-message-parameters-error-toolong';
76 76
 			} else {
77 77
 				$msg = 'wbqc-violation-message-parameters-error-unknown';
78 78
 			}
79
-			throw new ConstraintParameterException( new ViolationMessage( $msg ) );
79
+			throw new ConstraintParameterException(new ViolationMessage($msg));
80 80
 		}
81 81
 	}
82 82
 
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 	 * Require that $parameters contains exactly one $parameterId parameter.
85 85
 	 * @throws ConstraintParameterException
86 86
 	 */
87
-	private function requireSingleParameter( array $parameters, string $parameterId ): void {
88
-		if ( count( $parameters[$parameterId] ) !== 1 ) {
87
+	private function requireSingleParameter(array $parameters, string $parameterId): void {
88
+		if (count($parameters[$parameterId]) !== 1) {
89 89
 			throw new ConstraintParameterException(
90
-				( new ViolationMessage( 'wbqc-violation-message-parameter-single' ) )
91
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
90
+				(new ViolationMessage('wbqc-violation-message-parameter-single'))
91
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
92 92
 			);
93 93
 		}
94 94
 	}
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
 	 * Require that $snak is a {@link PropertyValueSnak}.
98 98
 	 * @throws ConstraintParameterException
99 99
 	 */
100
-	private function requireValueParameter( Snak $snak, string $parameterId ): void {
101
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
100
+	private function requireValueParameter(Snak $snak, string $parameterId): void {
101
+		if (!($snak instanceof PropertyValueSnak)) {
102 102
 			throw new ConstraintParameterException(
103
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
104
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
103
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
104
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
105 105
 			);
106 106
 		}
107 107
 	}
@@ -110,17 +110,17 @@  discard block
 block discarded – undo
110 110
 	 * Parse a single entity ID parameter.
111 111
 	 * @throws ConstraintParameterException
112 112
 	 */
113
-	private function parseEntityIdParameter( array $snakSerialization, string $parameterId ): EntityId {
114
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
115
-		$this->requireValueParameter( $snak, $parameterId );
113
+	private function parseEntityIdParameter(array $snakSerialization, string $parameterId): EntityId {
114
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
115
+		$this->requireValueParameter($snak, $parameterId);
116 116
 		$value = $snak->getDataValue();
117
-		if ( $value instanceof EntityIdValue ) {
117
+		if ($value instanceof EntityIdValue) {
118 118
 			return $value->getEntityId();
119 119
 		} else {
120 120
 			throw new ConstraintParameterException(
121
-				( new ViolationMessage( 'wbqc-violation-message-parameter-entity' ) )
122
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
123
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
121
+				(new ViolationMessage('wbqc-violation-message-parameter-entity'))
122
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
123
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
124 124
 			);
125 125
 		}
126 126
 	}
@@ -131,20 +131,20 @@  discard block
 block discarded – undo
131 131
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
132 132
 	 * @return string[] class entity ID serializations
133 133
 	 */
134
-	public function parseClassParameter( array $constraintParameters, string $constraintTypeItemId ): array {
135
-		$this->checkError( $constraintParameters );
136
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
137
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
134
+	public function parseClassParameter(array $constraintParameters, string $constraintTypeItemId): array {
135
+		$this->checkError($constraintParameters);
136
+		$classId = $this->config->get('WBQualityConstraintsClassId');
137
+		if (!array_key_exists($classId, $constraintParameters)) {
138 138
 			throw new ConstraintParameterException(
139
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
140
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
141
-					->withEntityId( new NumericPropertyId( $classId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
139
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
140
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
141
+					->withEntityId(new NumericPropertyId($classId), Role::CONSTRAINT_PARAMETER_PROPERTY)
142 142
 			);
143 143
 		}
144 144
 
145 145
 		$classes = [];
146
-		foreach ( $constraintParameters[$classId] as $class ) {
147
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
146
+		foreach ($constraintParameters[$classId] as $class) {
147
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
148 148
 		}
149 149
 		return $classes;
150 150
 	}
@@ -155,31 +155,31 @@  discard block
 block discarded – undo
155 155
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
156 156
 	 * @return string 'instance', 'subclass', or 'instanceOrSubclass'
157 157
 	 */
158
-	public function parseRelationParameter( array $constraintParameters, string $constraintTypeItemId ): string {
159
-		$this->checkError( $constraintParameters );
160
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
161
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
158
+	public function parseRelationParameter(array $constraintParameters, string $constraintTypeItemId): string {
159
+		$this->checkError($constraintParameters);
160
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
161
+		if (!array_key_exists($relationId, $constraintParameters)) {
162 162
 			throw new ConstraintParameterException(
163
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
164
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
165
-					->withEntityId( new NumericPropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
163
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
164
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
165
+					->withEntityId(new NumericPropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
166 166
 			);
167 167
 		}
168 168
 
169
-		$this->requireSingleParameter( $constraintParameters, $relationId );
170
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
171
-		if ( !( $relationEntityId instanceof ItemId ) ) {
169
+		$this->requireSingleParameter($constraintParameters, $relationId);
170
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
171
+		if (!($relationEntityId instanceof ItemId)) {
172 172
 			throw new ConstraintParameterException(
173
-				( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
174
-					->withEntityId( new NumericPropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
175
-					->withDataValue( new EntityIdValue( $relationEntityId ), Role::CONSTRAINT_PARAMETER_VALUE )
173
+				(new ViolationMessage('wbqc-violation-message-parameter-item'))
174
+					->withEntityId(new NumericPropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
175
+					->withDataValue(new EntityIdValue($relationEntityId), Role::CONSTRAINT_PARAMETER_VALUE)
176 176
 			);
177 177
 		}
178
-		return $this->mapItemId( $relationEntityId, [
179
-			$this->config->get( 'WBQualityConstraintsInstanceOfRelationId' ) => 'instance',
180
-			$this->config->get( 'WBQualityConstraintsSubclassOfRelationId' ) => 'subclass',
181
-			$this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' ) => 'instanceOrSubclass',
182
-		], $relationId );
178
+		return $this->mapItemId($relationEntityId, [
179
+			$this->config->get('WBQualityConstraintsInstanceOfRelationId') => 'instance',
180
+			$this->config->get('WBQualityConstraintsSubclassOfRelationId') => 'subclass',
181
+			$this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId') => 'instanceOrSubclass',
182
+		], $relationId);
183 183
 	}
184 184
 
185 185
 	/**
@@ -189,20 +189,20 @@  discard block
 block discarded – undo
189 189
 	 * @throws ConstraintParameterException
190 190
 	 * @return PropertyId
191 191
 	 */
192
-	private function parsePropertyIdParameter( array $snakSerialization, string $parameterId ): PropertyId {
193
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
194
-		$this->requireValueParameter( $snak, $parameterId );
192
+	private function parsePropertyIdParameter(array $snakSerialization, string $parameterId): PropertyId {
193
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
194
+		$this->requireValueParameter($snak, $parameterId);
195 195
 		$value = $snak->getDataValue();
196
-		if ( $value instanceof EntityIdValue ) {
196
+		if ($value instanceof EntityIdValue) {
197 197
 			$id = $value->getEntityId();
198
-			if ( $id instanceof PropertyId ) {
198
+			if ($id instanceof PropertyId) {
199 199
 				return $id;
200 200
 			}
201 201
 		}
202 202
 		throw new ConstraintParameterException(
203
-			( new ViolationMessage( 'wbqc-violation-message-parameter-property' ) )
204
-				->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
205
-				->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
203
+			(new ViolationMessage('wbqc-violation-message-parameter-property'))
204
+				->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
205
+				->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
206 206
 		);
207 207
 	}
208 208
 
@@ -213,34 +213,34 @@  discard block
 block discarded – undo
213 213
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
214 214
 	 * @return PropertyId
215 215
 	 */
216
-	public function parsePropertyParameter( array $constraintParameters, string $constraintTypeItemId ): PropertyId {
217
-		$this->checkError( $constraintParameters );
218
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
219
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
216
+	public function parsePropertyParameter(array $constraintParameters, string $constraintTypeItemId): PropertyId {
217
+		$this->checkError($constraintParameters);
218
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
219
+		if (!array_key_exists($propertyId, $constraintParameters)) {
220 220
 			throw new ConstraintParameterException(
221
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
222
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
223
-					->withEntityId( new NumericPropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
221
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
222
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
223
+					->withEntityId(new NumericPropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
224 224
 			);
225 225
 		}
226 226
 
227
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
228
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
227
+		$this->requireSingleParameter($constraintParameters, $propertyId);
228
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
229 229
 	}
230 230
 
231 231
 	/** @throws ConstraintParameterException */
232
-	private function parseItemIdParameter( PropertyValueSnak $snak, string $parameterId ): ItemIdSnakValue {
232
+	private function parseItemIdParameter(PropertyValueSnak $snak, string $parameterId): ItemIdSnakValue {
233 233
 		$dataValue = $snak->getDataValue();
234
-		if ( $dataValue instanceof EntityIdValue ) {
234
+		if ($dataValue instanceof EntityIdValue) {
235 235
 			$entityId = $dataValue->getEntityId();
236
-			if ( $entityId instanceof ItemId ) {
237
-				return ItemIdSnakValue::fromItemId( $entityId );
236
+			if ($entityId instanceof ItemId) {
237
+				return ItemIdSnakValue::fromItemId($entityId);
238 238
 			}
239 239
 		}
240 240
 		throw new ConstraintParameterException(
241
-			( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
242
-				->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
243
-				->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
241
+			(new ViolationMessage('wbqc-violation-message-parameter-item'))
242
+				->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
243
+				->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
244 244
 		);
245 245
 	}
246 246
 
@@ -258,14 +258,14 @@  discard block
 block discarded – undo
258 258
 		bool $required,
259 259
 		?string $parameterId = null
260 260
 	): array {
261
-		$this->checkError( $constraintParameters );
262
-		$parameterId ??= $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
263
-		if ( !array_key_exists( $parameterId, $constraintParameters ) ) {
264
-			if ( $required ) {
261
+		$this->checkError($constraintParameters);
262
+		$parameterId ??= $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
263
+		if (!array_key_exists($parameterId, $constraintParameters)) {
264
+			if ($required) {
265 265
 				throw new ConstraintParameterException(
266
-					( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
267
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
268
-						->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
266
+					(new ViolationMessage('wbqc-violation-message-parameter-needed'))
267
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
268
+						->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
269 269
 				);
270 270
 			} else {
271 271
 				return [];
@@ -273,11 +273,11 @@  discard block
 block discarded – undo
273 273
 		}
274 274
 
275 275
 		$values = [];
276
-		foreach ( $constraintParameters[$parameterId] as $parameter ) {
277
-			$snak = $this->snakDeserializer->deserialize( $parameter );
278
-			switch ( true ) {
276
+		foreach ($constraintParameters[$parameterId] as $parameter) {
277
+			$snak = $this->snakDeserializer->deserialize($parameter);
278
+			switch (true) {
279 279
 				case $snak instanceof PropertyValueSnak:
280
-					$values[] = $this->parseItemIdParameter( $snak, $parameterId );
280
+					$values[] = $this->parseItemIdParameter($snak, $parameterId);
281 281
 					break;
282 282
 				case $snak instanceof PropertySomeValueSnak:
283 283
 					$values[] = ItemIdSnakValue::someValue();
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
 		string $parameterId
307 307
 	): array {
308 308
 		/** @throws ConstraintParameterException */
309
-		return array_map( static function ( ItemIdSnakValue $value ) use ( $parameterId ): ItemId {
310
-			if ( $value->isValue() ) {
309
+		return array_map(static function(ItemIdSnakValue $value) use ($parameterId): ItemId {
310
+			if ($value->isValue()) {
311 311
 				return $value->getItemId();
312 312
 			} else {
313 313
 				throw new ConstraintParameterException(
314
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
315
-						->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
314
+					(new ViolationMessage('wbqc-violation-message-parameter-value'))
315
+						->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
316 316
 				);
317 317
 			}
318 318
 		}, $this->parseItemsParameter(
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 			$constraintTypeItemId,
321 321
 			$required,
322 322
 			$parameterId
323
-		) );
323
+		));
324 324
 	}
325 325
 
326 326
 	/**
@@ -328,18 +328,18 @@  discard block
 block discarded – undo
328 328
 	 * @throws ConstraintParameterException
329 329
 	 * @return mixed elements of $mapping
330 330
 	 */
331
-	private function mapItemId( ItemId $itemId, array $mapping, string $parameterId ) {
331
+	private function mapItemId(ItemId $itemId, array $mapping, string $parameterId) {
332 332
 		$serialization = $itemId->getSerialization();
333
-		if ( array_key_exists( $serialization, $mapping ) ) {
333
+		if (array_key_exists($serialization, $mapping)) {
334 334
 			return $mapping[$serialization];
335 335
 		} else {
336
-			$allowed = array_map( static function ( $id ) {
337
-				return new ItemId( $id );
338
-			}, array_keys( $mapping ) );
336
+			$allowed = array_map(static function($id) {
337
+				return new ItemId($id);
338
+			}, array_keys($mapping));
339 339
 			throw new ConstraintParameterException(
340
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
341
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
342
-					->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
340
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
341
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
342
+					->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
343 343
 			);
344 344
 		}
345 345
 	}
@@ -350,27 +350,27 @@  discard block
 block discarded – undo
350 350
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
351 351
 	 * @return PropertyId[]
352 352
 	 */
353
-	public function parsePropertiesParameter( array $constraintParameters, string $constraintTypeItemId ): array {
354
-		$this->checkError( $constraintParameters );
355
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
356
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
353
+	public function parsePropertiesParameter(array $constraintParameters, string $constraintTypeItemId): array {
354
+		$this->checkError($constraintParameters);
355
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
356
+		if (!array_key_exists($propertyId, $constraintParameters)) {
357 357
 			throw new ConstraintParameterException(
358
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
359
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
360
-					->withEntityId( new NumericPropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
358
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
359
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
360
+					->withEntityId(new NumericPropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
361 361
 			);
362 362
 		}
363 363
 
364 364
 		$parameters = $constraintParameters[$propertyId];
365
-		if ( count( $parameters ) === 1 &&
366
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
365
+		if (count($parameters) === 1 &&
366
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
367 367
 		) {
368 368
 			return [];
369 369
 		}
370 370
 
371 371
 		$properties = [];
372
-		foreach ( $parameters as $parameter ) {
373
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
372
+		foreach ($parameters as $parameter) {
373
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
374 374
 		}
375 375
 		return $properties;
376 376
 	}
@@ -378,24 +378,24 @@  discard block
 block discarded – undo
378 378
 	/**
379 379
 	 * @throws ConstraintParameterException
380 380
 	 */
381
-	private function parseValueOrNoValueParameter( array $snakSerialization, string $parameterId ): ?DataValue {
382
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
383
-		if ( $snak instanceof PropertyValueSnak ) {
381
+	private function parseValueOrNoValueParameter(array $snakSerialization, string $parameterId): ?DataValue {
382
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
383
+		if ($snak instanceof PropertyValueSnak) {
384 384
 			return $snak->getDataValue();
385
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
385
+		} elseif ($snak instanceof PropertyNoValueSnak) {
386 386
 			return null;
387 387
 		} else {
388 388
 			throw new ConstraintParameterException(
389
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
390
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
389
+				(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
390
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
391 391
 			);
392 392
 		}
393 393
 	}
394 394
 
395
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, string $parameterId ): ?DataValue {
395
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, string $parameterId): ?DataValue {
396 396
 		try {
397
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
398
-		} catch ( ConstraintParameterException ) {
397
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
398
+		} catch (ConstraintParameterException) {
399 399
 			// unknown value means “now”
400 400
 			return new NowValue();
401 401
 		}
@@ -404,14 +404,14 @@  discard block
 block discarded – undo
404 404
 	/**
405 405
 	 * Checks whether there is exactly one non-null quantity with the given unit.
406 406
 	 */
407
-	private function exactlyOneQuantityWithUnit( ?DataValue $min, ?DataValue $max, string $unit ): bool {
408
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
409
-			!( $max instanceof UnboundedQuantityValue )
407
+	private function exactlyOneQuantityWithUnit(?DataValue $min, ?DataValue $max, string $unit): bool {
408
+		if (!($min instanceof UnboundedQuantityValue) ||
409
+			!($max instanceof UnboundedQuantityValue)
410 410
 		) {
411 411
 			return false;
412 412
 		}
413 413
 
414
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
414
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
415 415
 	}
416 416
 
417 417
 	/**
@@ -431,42 +431,42 @@  discard block
 block discarded – undo
431 431
 		string $constraintTypeItemId,
432 432
 		string $type
433 433
 	): array {
434
-		$this->checkError( $constraintParameters );
435
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
436
-			!array_key_exists( $maximumId, $constraintParameters )
434
+		$this->checkError($constraintParameters);
435
+		if (!array_key_exists($minimumId, $constraintParameters) ||
436
+			!array_key_exists($maximumId, $constraintParameters)
437 437
 		) {
438 438
 			throw new ConstraintParameterException(
439
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-needed' ) )
440
-					->withDataValueType( $type )
441
-					->withEntityId( new NumericPropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
442
-					->withEntityId( new NumericPropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
443
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
439
+				(new ViolationMessage('wbqc-violation-message-range-parameters-needed'))
440
+					->withDataValueType($type)
441
+					->withEntityId(new NumericPropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
442
+					->withEntityId(new NumericPropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
443
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
444 444
 			);
445 445
 		}
446 446
 
447
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
448
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
447
+		$this->requireSingleParameter($constraintParameters, $minimumId);
448
+		$this->requireSingleParameter($constraintParameters, $maximumId);
449 449
 		$parseFunction = $type === 'time' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
450
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
451
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
450
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
451
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
452 452
 
453
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
454
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
453
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
454
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
455 455
 			throw new ConstraintParameterException(
456
-				new ViolationMessage( 'wbqc-violation-message-range-parameters-one-year' )
456
+				new ViolationMessage('wbqc-violation-message-range-parameters-one-year')
457 457
 			);
458 458
 		}
459
-		if ( ( $min === null && $max === null ) ||
460
-			( $min !== null && $max !== null && $min->equals( $max ) )
459
+		if (($min === null && $max === null) ||
460
+			($min !== null && $max !== null && $min->equals($max))
461 461
 		) {
462 462
 			throw new ConstraintParameterException(
463
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-same' ) )
464
-					->withEntityId( new NumericPropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
465
-					->withEntityId( new NumericPropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
463
+				(new ViolationMessage('wbqc-violation-message-range-parameters-same'))
464
+					->withEntityId(new NumericPropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
465
+					->withEntityId(new NumericPropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
466 466
 			);
467 467
 		}
468 468
 
469
-		return [ $min, $max ];
469
+		return [$min, $max];
470 470
 	}
471 471
 
472 472
 	/**
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
477 477
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
478 478
 	 */
479
-	public function parseQuantityRangeParameter( array $constraintParameters, string $constraintTypeItemId ): array {
479
+	public function parseQuantityRangeParameter(array $constraintParameters, string $constraintTypeItemId): array {
480 480
 		return $this->parseRangeParameter(
481 481
 			$constraintParameters,
482
-			$this->config->get( 'WBQualityConstraintsMinimumQuantityId' ),
483
-			$this->config->get( 'WBQualityConstraintsMaximumQuantityId' ),
482
+			$this->config->get('WBQualityConstraintsMinimumQuantityId'),
483
+			$this->config->get('WBQualityConstraintsMaximumQuantityId'),
484 484
 			$constraintTypeItemId,
485 485
 			'quantity'
486 486
 		);
@@ -493,11 +493,11 @@  discard block
 block discarded – undo
493 493
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
494 494
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
495 495
 	 */
496
-	public function parseTimeRangeParameter( array $constraintParameters, string $constraintTypeItemId ): array {
496
+	public function parseTimeRangeParameter(array $constraintParameters, string $constraintTypeItemId): array {
497 497
 		return $this->parseRangeParameter(
498 498
 			$constraintParameters,
499
-			$this->config->get( 'WBQualityConstraintsMinimumDateId' ),
500
-			$this->config->get( 'WBQualityConstraintsMaximumDateId' ),
499
+			$this->config->get('WBQualityConstraintsMinimumDateId'),
500
+			$this->config->get('WBQualityConstraintsMaximumDateId'),
501 501
 			$constraintTypeItemId,
502 502
 			'time'
503 503
 		);
@@ -510,20 +510,20 @@  discard block
 block discarded – undo
510 510
 	 * @throws ConstraintParameterException
511 511
 	 * @return string[]
512 512
 	 */
513
-	public function parseLanguageParameter( array $constraintParameters, string $constraintTypeItemId ): array {
514
-		$this->checkError( $constraintParameters );
515
-		$languagePropertyId = $this->config->get( 'WBQualityConstraintsLanguagePropertyId' );
516
-		if ( !array_key_exists( $languagePropertyId, $constraintParameters ) ) {
513
+	public function parseLanguageParameter(array $constraintParameters, string $constraintTypeItemId): array {
514
+		$this->checkError($constraintParameters);
515
+		$languagePropertyId = $this->config->get('WBQualityConstraintsLanguagePropertyId');
516
+		if (!array_key_exists($languagePropertyId, $constraintParameters)) {
517 517
 			throw new ConstraintParameterException(
518
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
519
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
520
-					->withEntityId( new NumericPropertyId( $languagePropertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
518
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
519
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
520
+					->withEntityId(new NumericPropertyId($languagePropertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
521 521
 			);
522 522
 		}
523 523
 
524 524
 		$languages = [];
525
-		foreach ( $constraintParameters[$languagePropertyId] as $snak ) {
526
-			$languages[] = $this->parseStringParameter( $snak, $languagePropertyId );
525
+		foreach ($constraintParameters[$languagePropertyId] as $snak) {
526
+			$languages[] = $this->parseStringParameter($snak, $languagePropertyId);
527 527
 		}
528 528
 		return $languages;
529 529
 	}
@@ -532,17 +532,17 @@  discard block
 block discarded – undo
532 532
 	 * Parse a single string parameter.
533 533
 	 * @throws ConstraintParameterException
534 534
 	 */
535
-	private function parseStringParameter( array $snakSerialization, string $parameterId ): string {
536
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
537
-		$this->requireValueParameter( $snak, $parameterId );
535
+	private function parseStringParameter(array $snakSerialization, string $parameterId): string {
536
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
537
+		$this->requireValueParameter($snak, $parameterId);
538 538
 		$value = $snak->getDataValue();
539
-		if ( $value instanceof StringValue ) {
539
+		if ($value instanceof StringValue) {
540 540
 			return $value->getValue();
541 541
 		} else {
542 542
 			throw new ConstraintParameterException(
543
-				( new ViolationMessage( 'wbqc-violation-message-parameter-string' ) )
544
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
545
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
543
+				(new ViolationMessage('wbqc-violation-message-parameter-string'))
544
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
545
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
546 546
 			);
547 547
 		}
548 548
 	}
@@ -553,15 +553,15 @@  discard block
 block discarded – undo
553 553
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
554 554
 	 * @return string
555 555
 	 */
556
-	public function parseNamespaceParameter( array $constraintParameters, string $constraintTypeItemId ): string {
557
-		$this->checkError( $constraintParameters );
558
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
559
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
556
+	public function parseNamespaceParameter(array $constraintParameters, string $constraintTypeItemId): string {
557
+		$this->checkError($constraintParameters);
558
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
559
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
560 560
 			return '';
561 561
 		}
562 562
 
563
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
564
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
563
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
564
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
565 565
 	}
566 566
 
567 567
 	/**
@@ -570,19 +570,19 @@  discard block
 block discarded – undo
570 570
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
571 571
 	 * @return string
572 572
 	 */
573
-	public function parseFormatParameter( array $constraintParameters, string $constraintTypeItemId ): string {
574
-		$this->checkError( $constraintParameters );
575
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
576
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
573
+	public function parseFormatParameter(array $constraintParameters, string $constraintTypeItemId): string {
574
+		$this->checkError($constraintParameters);
575
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
576
+		if (!array_key_exists($formatId, $constraintParameters)) {
577 577
 			throw new ConstraintParameterException(
578
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
579
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
580
-					->withEntityId( new NumericPropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
578
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
579
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
580
+					->withEntityId(new NumericPropertyId($formatId), Role::CONSTRAINT_PARAMETER_PROPERTY)
581 581
 			);
582 582
 		}
583 583
 
584
-		$this->requireSingleParameter( $constraintParameters, $formatId );
585
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
584
+		$this->requireSingleParameter($constraintParameters, $formatId);
585
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
586 586
 	}
587 587
 
588 588
 	/**
@@ -590,16 +590,16 @@  discard block
 block discarded – undo
590 590
 	 * @throws ConstraintParameterException if the parameter is invalid
591 591
 	 * @return EntityId[]
592 592
 	 */
593
-	public function parseExceptionParameter( array $constraintParameters ): array {
594
-		$this->checkError( $constraintParameters );
595
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
596
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
593
+	public function parseExceptionParameter(array $constraintParameters): array {
594
+		$this->checkError($constraintParameters);
595
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
596
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
597 597
 			return [];
598 598
 		}
599 599
 
600 600
 		return array_map(
601
-			function ( $snakSerialization ) use ( $exceptionId ) {
602
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
601
+			function($snakSerialization) use ($exceptionId) {
602
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
603 603
 			},
604 604
 			$constraintParameters[$exceptionId]
605 605
 		);
@@ -610,39 +610,39 @@  discard block
 block discarded – undo
610 610
 	 * @throws ConstraintParameterException if the parameter is invalid
611 611
 	 * @return string|null 'mandatory', 'suggestion' or null
612 612
 	 */
613
-	public function parseConstraintStatusParameter( array $constraintParameters ): ?string {
614
-		$this->checkError( $constraintParameters );
615
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
616
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
613
+	public function parseConstraintStatusParameter(array $constraintParameters): ?string {
614
+		$this->checkError($constraintParameters);
615
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
616
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
617 617
 			return null;
618 618
 		}
619 619
 
620
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
621
-		$supportedStatuses = [ new ItemId( $mandatoryId ) ];
622
-		if ( $this->config->get( 'WBQualityConstraintsEnableSuggestionConstraintStatus' ) ) {
623
-			$suggestionId = $this->config->get( 'WBQualityConstraintsSuggestionConstraintId' );
624
-			$supportedStatuses[] = new ItemId( $suggestionId );
620
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
621
+		$supportedStatuses = [new ItemId($mandatoryId)];
622
+		if ($this->config->get('WBQualityConstraintsEnableSuggestionConstraintStatus')) {
623
+			$suggestionId = $this->config->get('WBQualityConstraintsSuggestionConstraintId');
624
+			$supportedStatuses[] = new ItemId($suggestionId);
625 625
 		} else {
626 626
 			$suggestionId = null;
627 627
 		}
628 628
 
629
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
630
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
631
-		$this->requireValueParameter( $snak, $constraintStatusId );
629
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
630
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
631
+		$this->requireValueParameter($snak, $constraintStatusId);
632 632
 		'@phan-var \Wikibase\DataModel\Snak\PropertyValueSnak $snak';
633 633
 		$dataValue = $snak->getDataValue();
634 634
 		'@phan-var EntityIdValue $dataValue';
635 635
 		$entityId = $dataValue->getEntityId();
636 636
 		$statusId = $entityId->getSerialization();
637 637
 
638
-		if ( $statusId === $mandatoryId ) {
638
+		if ($statusId === $mandatoryId) {
639 639
 			return 'mandatory';
640
-		} elseif ( $statusId === $suggestionId ) {
640
+		} elseif ($statusId === $suggestionId) {
641 641
 			return 'suggestion';
642 642
 		} else {
643 643
 			throw new ConstraintParameterException(
644
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
645
-					->withEntityId( new NumericPropertyId( $constraintStatusId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
644
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
645
+					->withEntityId(new NumericPropertyId($constraintStatusId), Role::CONSTRAINT_PARAMETER_PROPERTY)
646 646
 					->withEntityIdList(
647 647
 						$supportedStatuses,
648 648
 						Role::CONSTRAINT_PARAMETER_VALUE
@@ -655,12 +655,12 @@  discard block
 block discarded – undo
655 655
 	 * Require that $dataValue is a {@link MonolingualTextValue}.
656 656
 	 * @throws ConstraintParameterException
657 657
 	 */
658
-	private function requireMonolingualTextParameter( DataValue $dataValue, string $parameterId ): void {
659
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
658
+	private function requireMonolingualTextParameter(DataValue $dataValue, string $parameterId): void {
659
+		if (!($dataValue instanceof MonolingualTextValue)) {
660 660
 			throw new ConstraintParameterException(
661
-				( new ViolationMessage( 'wbqc-violation-message-parameter-monolingualtext' ) )
662
-					->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
663
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
661
+				(new ViolationMessage('wbqc-violation-message-parameter-monolingualtext'))
662
+					->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
663
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
664 664
 			);
665 665
 		}
666 666
 	}
@@ -670,31 +670,31 @@  discard block
 block discarded – undo
670 670
 	 *
671 671
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
672 672
 	 */
673
-	private function parseMultilingualTextParameter( array $snakSerializations, string $parameterId ): MultilingualTextValue {
673
+	private function parseMultilingualTextParameter(array $snakSerializations, string $parameterId): MultilingualTextValue {
674 674
 		$result = [];
675 675
 
676
-		foreach ( $snakSerializations as $snakSerialization ) {
677
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
678
-			$this->requireValueParameter( $snak, $parameterId );
676
+		foreach ($snakSerializations as $snakSerialization) {
677
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
678
+			$this->requireValueParameter($snak, $parameterId);
679 679
 
680 680
 			$value = $snak->getDataValue();
681
-			$this->requireMonolingualTextParameter( $value, $parameterId );
681
+			$this->requireMonolingualTextParameter($value, $parameterId);
682 682
 			/** @var MonolingualTextValue $value */
683 683
 			'@phan-var MonolingualTextValue $value';
684 684
 
685 685
 			$code = $value->getLanguageCode();
686
-			if ( array_key_exists( $code, $result ) ) {
686
+			if (array_key_exists($code, $result)) {
687 687
 				throw new ConstraintParameterException(
688
-					( new ViolationMessage( 'wbqc-violation-message-parameter-single-per-language' ) )
689
-						->withEntityId( new NumericPropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
690
-						->withLanguage( $code )
688
+					(new ViolationMessage('wbqc-violation-message-parameter-single-per-language'))
689
+						->withEntityId(new NumericPropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
690
+						->withLanguage($code)
691 691
 				);
692 692
 			}
693 693
 
694 694
 			$result[$code] = $value;
695 695
 		}
696 696
 
697
-		return new MultilingualTextValue( $result );
697
+		return new MultilingualTextValue($result);
698 698
 	}
699 699
 
700 700
 	/**
@@ -702,11 +702,11 @@  discard block
 block discarded – undo
702 702
 	 * @throws ConstraintParameterException if the parameter is invalid
703 703
 	 * @return MultilingualTextValue
704 704
 	 */
705
-	public function parseSyntaxClarificationParameter( array $constraintParameters ): MultilingualTextValue {
706
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
705
+	public function parseSyntaxClarificationParameter(array $constraintParameters): MultilingualTextValue {
706
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
707 707
 
708
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
709
-			return new MultilingualTextValue( [] );
708
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
709
+			return new MultilingualTextValue([]);
710 710
 		}
711 711
 
712 712
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
@@ -722,11 +722,11 @@  discard block
 block discarded – undo
722 722
 	 * @throws ConstraintParameterException if the parameter is invalid
723 723
 	 * @return MultilingualTextValue
724 724
 	 */
725
-	public function parseConstraintClarificationParameter( array $constraintParameters ): MultilingualTextValue {
726
-		$constraintClarificationId = $this->config->get( 'WBQualityConstraintsConstraintClarificationId' );
725
+	public function parseConstraintClarificationParameter(array $constraintParameters): MultilingualTextValue {
726
+		$constraintClarificationId = $this->config->get('WBQualityConstraintsConstraintClarificationId');
727 727
 
728
-		if ( !array_key_exists( $constraintClarificationId, $constraintParameters ) ) {
729
-			return new MultilingualTextValue( [] );
728
+		if (!array_key_exists($constraintClarificationId, $constraintParameters)) {
729
+			return new MultilingualTextValue([]);
730 730
 		}
731 731
 
732 732
 		$constraintClarifications = $this->parseMultilingualTextParameter(
@@ -759,14 +759,14 @@  discard block
 block discarded – undo
759 759
 		array $validContextTypes,
760 760
 		array $validEntityTypes
761 761
 	): array {
762
-		$contextTypeParameterId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
762
+		$contextTypeParameterId = $this->config->get('WBQualityConstraintsConstraintScopeId');
763 763
 		$contextTypeItemIds = $this->parseItemIdsParameter(
764 764
 			$constraintParameters,
765 765
 			$constraintTypeItemId,
766 766
 			false,
767 767
 			$contextTypeParameterId
768 768
 		);
769
-		$entityTypeParameterId = $this->config->get( 'WBQualityConstraintsConstraintEntityTypesId' );
769
+		$entityTypeParameterId = $this->config->get('WBQualityConstraintsConstraintEntityTypesId');
770 770
 		$entityTypeItemIds = $this->parseItemIdsParameter(
771 771
 			$constraintParameters,
772 772
 			$constraintTypeItemId,
@@ -782,26 +782,26 @@  discard block
 block discarded – undo
782 782
 		$contextTypes = null;
783 783
 		$entityTypes = null;
784 784
 
785
-		if ( $contextTypeParameterId === $entityTypeParameterId ) {
785
+		if ($contextTypeParameterId === $entityTypeParameterId) {
786 786
 			$itemIds = $contextTypeItemIds;
787 787
 			$mapping = $contextTypeMapping + $entityTypeMapping;
788
-			foreach ( $itemIds as $itemId ) {
789
-				$mapped = $this->mapItemId( $itemId, $mapping, $contextTypeParameterId );
790
-				if ( in_array( $mapped, $contextTypeMapping, true ) ) {
788
+			foreach ($itemIds as $itemId) {
789
+				$mapped = $this->mapItemId($itemId, $mapping, $contextTypeParameterId);
790
+				if (in_array($mapped, $contextTypeMapping, true)) {
791 791
 					$contextTypes[] = $mapped;
792 792
 				} else {
793 793
 					$entityTypes[] = $mapped;
794 794
 				}
795 795
 			}
796 796
 		} else {
797
-			foreach ( $contextTypeItemIds as $contextTypeItemId ) {
797
+			foreach ($contextTypeItemIds as $contextTypeItemId) {
798 798
 				$contextTypes[] = $this->mapItemId(
799 799
 					$contextTypeItemId,
800 800
 					$contextTypeMapping,
801 801
 					$contextTypeParameterId
802 802
 				);
803 803
 			}
804
-			foreach ( $entityTypeItemIds as $entityTypeItemId ) {
804
+			foreach ($entityTypeItemIds as $entityTypeItemId) {
805 805
 				$entityTypes[] = $this->mapItemId(
806 806
 					$entityTypeItemId,
807 807
 					$entityTypeMapping,
@@ -810,22 +810,22 @@  discard block
 block discarded – undo
810 810
 			}
811 811
 		}
812 812
 
813
-		$this->checkValidScope( $constraintTypeItemId, $contextTypes, $validContextTypes );
814
-		$this->checkValidScope( $constraintTypeItemId, $entityTypes, $validEntityTypes );
813
+		$this->checkValidScope($constraintTypeItemId, $contextTypes, $validContextTypes);
814
+		$this->checkValidScope($constraintTypeItemId, $entityTypes, $validEntityTypes);
815 815
 
816
-		return [ $contextTypes, $entityTypes ];
816
+		return [$contextTypes, $entityTypes];
817 817
 	}
818 818
 
819 819
 	/** @throws ConstraintParameterException */
820
-	private function checkValidScope( string $constraintTypeItemId, ?array $types, array $validTypes ): void {
821
-		$invalidTypes = array_diff( $types ?: [], $validTypes );
822
-		if ( $invalidTypes !== [] ) {
823
-			$invalidType = array_pop( $invalidTypes );
820
+	private function checkValidScope(string $constraintTypeItemId, ?array $types, array $validTypes): void {
821
+		$invalidTypes = array_diff($types ?: [], $validTypes);
822
+		if ($invalidTypes !== []) {
823
+			$invalidType = array_pop($invalidTypes);
824 824
 			throw new ConstraintParameterException(
825
-				( new ViolationMessage( 'wbqc-violation-message-invalid-scope' ) )
826
-					->withConstraintScope( $invalidType, Role::CONSTRAINT_PARAMETER_VALUE )
827
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
828
-					->withConstraintScopeList( $validTypes, Role::CONSTRAINT_PARAMETER_VALUE )
825
+				(new ViolationMessage('wbqc-violation-message-invalid-scope'))
826
+					->withConstraintScope($invalidType, Role::CONSTRAINT_PARAMETER_VALUE)
827
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
828
+					->withConstraintScopeList($validTypes, Role::CONSTRAINT_PARAMETER_VALUE)
829 829
 			);
830 830
 		}
831 831
 	}
@@ -833,8 +833,8 @@  discard block
 block discarded – undo
833 833
 	/**
834 834
 	 * Turn an item ID into a full unit string (using the concept URI).
835 835
 	 */
836
-	private function parseUnitParameter( ItemId $unitId ): string {
837
-		return $this->unitItemConceptBaseUri . $unitId->getSerialization();
836
+	private function parseUnitParameter(ItemId $unitId): string {
837
+		return $this->unitItemConceptBaseUri.$unitId->getSerialization();
838 838
 	}
839 839
 
840 840
 	/**
@@ -842,23 +842,23 @@  discard block
 block discarded – undo
842 842
 	 *
843 843
 	 * @throws ConstraintParameterException
844 844
 	 */
845
-	private function parseUnitItem( ItemIdSnakValue $item ): UnitsParameter {
846
-		switch ( true ) {
845
+	private function parseUnitItem(ItemIdSnakValue $item): UnitsParameter {
846
+		switch (true) {
847 847
 			case $item->isValue():
848
-				$unit = $this->parseUnitParameter( $item->getItemId() );
848
+				$unit = $this->parseUnitParameter($item->getItemId());
849 849
 				return new UnitsParameter(
850
-					[ $item->getItemId() ],
851
-					[ UnboundedQuantityValue::newFromNumber( 1, $unit ) ],
850
+					[$item->getItemId()],
851
+					[UnboundedQuantityValue::newFromNumber(1, $unit)],
852 852
 					false
853 853
 				);
854 854
 			case $item->isSomeValue():
855
-				$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
855
+				$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
856 856
 				throw new ConstraintParameterException(
857
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
858
-						->withEntityId( new NumericPropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
857
+					(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
858
+						->withEntityId(new NumericPropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
859 859
 				);
860 860
 			case $item->isNoValue():
861
-				return new UnitsParameter( [], [], true );
861
+				return new UnitsParameter([], [], true);
862 862
 		}
863 863
 	}
864 864
 
@@ -868,36 +868,36 @@  discard block
 block discarded – undo
868 868
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
869 869
 	 * @return UnitsParameter
870 870
 	 */
871
-	public function parseUnitsParameter( array $constraintParameters, string $constraintTypeItemId ): UnitsParameter {
872
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
871
+	public function parseUnitsParameter(array $constraintParameters, string $constraintTypeItemId): UnitsParameter {
872
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
873 873
 		$unitItems = [];
874 874
 		$unitQuantities = [];
875 875
 		$unitlessAllowed = false;
876 876
 
877
-		foreach ( $items as $item ) {
878
-			$unit = $this->parseUnitItem( $item );
879
-			$unitItems = array_merge( $unitItems, $unit->getUnitItemIds() );
880
-			$unitQuantities = array_merge( $unitQuantities, $unit->getUnitQuantities() );
877
+		foreach ($items as $item) {
878
+			$unit = $this->parseUnitItem($item);
879
+			$unitItems = array_merge($unitItems, $unit->getUnitItemIds());
880
+			$unitQuantities = array_merge($unitQuantities, $unit->getUnitQuantities());
881 881
 			$unitlessAllowed = $unitlessAllowed || $unit->getUnitlessAllowed();
882 882
 		}
883 883
 
884
-		if ( $unitQuantities === [] && !$unitlessAllowed ) {
884
+		if ($unitQuantities === [] && !$unitlessAllowed) {
885 885
 			throw new LogicException(
886 886
 				'The "units" parameter is required, and yet we seem to be missing any allowed unit'
887 887
 			);
888 888
 		}
889 889
 
890
-		return new UnitsParameter( $unitItems, $unitQuantities, $unitlessAllowed );
890
+		return new UnitsParameter($unitItems, $unitQuantities, $unitlessAllowed);
891 891
 	}
892 892
 
893 893
 	private function getEntityTypeMapping(): array {
894 894
 		return [
895
-			$this->config->get( 'WBQualityConstraintsWikibaseItemId' ) => 'item',
896
-			$this->config->get( 'WBQualityConstraintsWikibasePropertyId' ) => 'property',
897
-			$this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ) => 'lexeme',
898
-			$this->config->get( 'WBQualityConstraintsWikibaseFormId' ) => 'form',
899
-			$this->config->get( 'WBQualityConstraintsWikibaseSenseId' ) => 'sense',
900
-			$this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ) => 'mediainfo',
895
+			$this->config->get('WBQualityConstraintsWikibaseItemId') => 'item',
896
+			$this->config->get('WBQualityConstraintsWikibasePropertyId') => 'property',
897
+			$this->config->get('WBQualityConstraintsWikibaseLexemeId') => 'lexeme',
898
+			$this->config->get('WBQualityConstraintsWikibaseFormId') => 'form',
899
+			$this->config->get('WBQualityConstraintsWikibaseSenseId') => 'sense',
900
+			$this->config->get('WBQualityConstraintsWikibaseMediaInfoId') => 'mediainfo',
901 901
 		];
902 902
 	}
903 903
 
@@ -907,10 +907,10 @@  discard block
 block discarded – undo
907 907
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
908 908
 	 * @return EntityTypesParameter
909 909
 	 */
910
-	public function parseEntityTypesParameter( array $constraintParameters, string $constraintTypeItemId ): EntityTypesParameter {
910
+	public function parseEntityTypesParameter(array $constraintParameters, string $constraintTypeItemId): EntityTypesParameter {
911 911
 		$entityTypes = [];
912 912
 		$entityTypeItemIds = [];
913
-		$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
913
+		$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
914 914
 		$itemIds = $this->parseItemIdsParameter(
915 915
 			$constraintParameters,
916 916
 			$constraintTypeItemId,
@@ -919,22 +919,22 @@  discard block
 block discarded – undo
919 919
 		);
920 920
 
921 921
 		$mapping = $this->getEntityTypeMapping();
922
-		foreach ( $itemIds as $itemId ) {
923
-			$entityType = $this->mapItemId( $itemId, $mapping, $parameterId );
922
+		foreach ($itemIds as $itemId) {
923
+			$entityType = $this->mapItemId($itemId, $mapping, $parameterId);
924 924
 			$entityTypes[] = $entityType;
925 925
 			$entityTypeItemIds[] = $itemId;
926 926
 		}
927 927
 
928
-		if ( $entityTypes === [] ) {
928
+		if ($entityTypes === []) {
929 929
 			// @codeCoverageIgnoreStart
930 930
 			throw new LogicException(
931
-				'The "entity types" parameter is required, ' .
931
+				'The "entity types" parameter is required, '.
932 932
 				'and yet we seem to be missing any allowed entity type'
933 933
 			);
934 934
 			// @codeCoverageIgnoreEnd
935 935
 		}
936 936
 
937
-		return new EntityTypesParameter( $entityTypes, $entityTypeItemIds );
937
+		return new EntityTypesParameter($entityTypes, $entityTypeItemIds);
938 938
 	}
939 939
 
940 940
 	/**
@@ -942,18 +942,18 @@  discard block
 block discarded – undo
942 942
 	 * @throws ConstraintParameterException if the parameter is invalid
943 943
 	 * @return PropertyId[]
944 944
 	 */
945
-	public function parseSeparatorsParameter( array $constraintParameters ): array {
946
-		$separatorId = $this->config->get( 'WBQualityConstraintsSeparatorId' );
945
+	public function parseSeparatorsParameter(array $constraintParameters): array {
946
+		$separatorId = $this->config->get('WBQualityConstraintsSeparatorId');
947 947
 
948
-		if ( !array_key_exists( $separatorId, $constraintParameters ) ) {
948
+		if (!array_key_exists($separatorId, $constraintParameters)) {
949 949
 			return [];
950 950
 		}
951 951
 
952 952
 		$parameters = $constraintParameters[$separatorId];
953 953
 		$separators = [];
954 954
 
955
-		foreach ( $parameters as $parameter ) {
956
-			$separators[] = $this->parsePropertyIdParameter( $parameter, $separatorId );
955
+		foreach ($parameters as $parameter) {
956
+			$separators[] = $this->parsePropertyIdParameter($parameter, $separatorId);
957 957
 		}
958 958
 
959 959
 		return $separators;
@@ -961,17 +961,17 @@  discard block
 block discarded – undo
961 961
 
962 962
 	private function getConstraintScopeContextTypeMapping(): array {
963 963
 		return [
964
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' ) => Context::TYPE_STATEMENT,
965
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' ) => Context::TYPE_QUALIFIER,
966
-			$this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' ) => Context::TYPE_REFERENCE,
964
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId') => Context::TYPE_STATEMENT,
965
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId') => Context::TYPE_QUALIFIER,
966
+			$this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId') => Context::TYPE_REFERENCE,
967 967
 		];
968 968
 	}
969 969
 
970 970
 	private function getPropertyScopeContextTypeMapping(): array {
971 971
 		return [
972
-			$this->config->get( 'WBQualityConstraintsAsMainValueId' ) => Context::TYPE_STATEMENT,
973
-			$this->config->get( 'WBQualityConstraintsAsQualifiersId' ) => Context::TYPE_QUALIFIER,
974
-			$this->config->get( 'WBQualityConstraintsAsReferencesId' ) => Context::TYPE_REFERENCE,
972
+			$this->config->get('WBQualityConstraintsAsMainValueId') => Context::TYPE_STATEMENT,
973
+			$this->config->get('WBQualityConstraintsAsQualifiersId') => Context::TYPE_QUALIFIER,
974
+			$this->config->get('WBQualityConstraintsAsReferencesId') => Context::TYPE_REFERENCE,
975 975
 		];
976 976
 	}
977 977
 
@@ -981,9 +981,9 @@  discard block
 block discarded – undo
981 981
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
982 982
 	 * @return string[] list of Context::TYPE_* constants
983 983
 	 */
984
-	public function parsePropertyScopeParameter( array $constraintParameters, string $constraintTypeItemId ): array {
984
+	public function parsePropertyScopeParameter(array $constraintParameters, string $constraintTypeItemId): array {
985 985
 		$contextTypes = [];
986
-		$parameterId = $this->config->get( 'WBQualityConstraintsPropertyScopeId' );
986
+		$parameterId = $this->config->get('WBQualityConstraintsPropertyScopeId');
987 987
 		$itemIds = $this->parseItemIdsParameter(
988 988
 			$constraintParameters,
989 989
 			$constraintTypeItemId,
@@ -992,14 +992,14 @@  discard block
 block discarded – undo
992 992
 		);
993 993
 
994 994
 		$mapping = $this->getPropertyScopeContextTypeMapping();
995
-		foreach ( $itemIds as $itemId ) {
996
-			$contextTypes[] = $this->mapItemId( $itemId, $mapping, $parameterId );
995
+		foreach ($itemIds as $itemId) {
996
+			$contextTypes[] = $this->mapItemId($itemId, $mapping, $parameterId);
997 997
 		}
998 998
 
999
-		if ( $contextTypes === [] ) {
999
+		if ($contextTypes === []) {
1000 1000
 			// @codeCoverageIgnoreStart
1001 1001
 			throw new LogicException(
1002
-				'The "property scope" parameter is required, ' .
1002
+				'The "property scope" parameter is required, '.
1003 1003
 				'and yet we seem to be missing any allowed scope'
1004 1004
 			);
1005 1005
 			// @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.
src/Api/CachingResultsSource.php 1 patch
Spacing   +77 added lines, -78 removed lines patch added patch discarded remove patch
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 	) {
145 145
 		$results = [];
146 146
 		$metadatas = [];
147
-		if ( $this->canUseStoredResults( $claimIds, $constraintIds, $statuses ) ) {
147
+		if ($this->canUseStoredResults($claimIds, $constraintIds, $statuses)) {
148 148
 			$storedEntityIds = [];
149
-			foreach ( $entityIds as $entityId ) {
150
-				$storedResults = $this->getStoredResults( $entityId );
151
-				if ( $storedResults !== null ) {
152
-					$this->loggingHelper->logCheckConstraintsCacheHit( $entityId );
153
-					foreach ( $storedResults->getArray() as $checkResult ) {
154
-						if ( $this->statusSelected( $statuses, $checkResult ) ) {
149
+			foreach ($entityIds as $entityId) {
150
+				$storedResults = $this->getStoredResults($entityId);
151
+				if ($storedResults !== null) {
152
+					$this->loggingHelper->logCheckConstraintsCacheHit($entityId);
153
+					foreach ($storedResults->getArray() as $checkResult) {
154
+						if ($this->statusSelected($statuses, $checkResult)) {
155 155
 							$results[] = $checkResult;
156 156
 						}
157 157
 					}
@@ -159,19 +159,19 @@  discard block
 block discarded – undo
159 159
 					$storedEntityIds[] = $entityId;
160 160
 				}
161 161
 			}
162
-			$entityIds = array_values( array_diff( $entityIds, $storedEntityIds ) );
162
+			$entityIds = array_values(array_diff($entityIds, $storedEntityIds));
163 163
 		}
164
-		if ( $entityIds !== [] || $claimIds !== [] ) {
165
-			if ( $entityIds !== [] ) {
166
-				$this->loggingHelper->logCheckConstraintsCacheMisses( $entityIds );
164
+		if ($entityIds !== [] || $claimIds !== []) {
165
+			if ($entityIds !== []) {
166
+				$this->loggingHelper->logCheckConstraintsCacheMisses($entityIds);
167 167
 			}
168
-			$response = $this->getAndStoreResults( $entityIds, $claimIds, $constraintIds, $statuses );
169
-			$results = array_merge( $results, $response->getArray() );
168
+			$response = $this->getAndStoreResults($entityIds, $claimIds, $constraintIds, $statuses);
169
+			$results = array_merge($results, $response->getArray());
170 170
 			$metadatas[] = $response->getMetadata();
171 171
 		}
172 172
 		return new CachedCheckResults(
173 173
 			$results,
174
-			Metadata::merge( $metadatas )
174
+			Metadata::merge($metadatas)
175 175
 		);
176 176
 	}
177 177
 
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
 		?array $constraintIds,
193 193
 		array $statuses
194 194
 	) {
195
-		if ( $claimIds !== [] ) {
195
+		if ($claimIds !== []) {
196 196
 			return false;
197 197
 		}
198
-		if ( $constraintIds !== null ) {
198
+		if ($constraintIds !== null) {
199 199
 			return false;
200 200
 		}
201
-		if ( array_diff( $statuses, self::CACHED_STATUSES ) !== [] ) {
201
+		if (array_diff($statuses, self::CACHED_STATUSES) !== []) {
202 202
 			return false;
203 203
 		}
204 204
 		return true;
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
 	 * @param CheckResult $result
214 214
 	 * @return bool
215 215
 	 */
216
-	private function statusSelected( array $statuses, CheckResult $result ) {
217
-		return in_array( $result->getStatus(), $statuses, true ) ||
216
+	private function statusSelected(array $statuses, CheckResult $result) {
217
+		return in_array($result->getStatus(), $statuses, true) ||
218 218
 			$result instanceof NullResult;
219 219
 	}
220 220
 
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
 		?array $constraintIds,
232 232
 		array $statuses
233 233
 	) {
234
-		$results = $this->resultsSource->getResults( $entityIds, $claimIds, $constraintIds, $statuses );
234
+		$results = $this->resultsSource->getResults($entityIds, $claimIds, $constraintIds, $statuses);
235 235
 
236
-		if ( $this->canStoreResults( $constraintIds, $statuses ) ) {
237
-			foreach ( $entityIds as $entityId ) {
238
-				$this->storeResults( $entityId, $results );
236
+		if ($this->canStoreResults($constraintIds, $statuses)) {
237
+			foreach ($entityIds as $entityId) {
238
+				$this->storeResults($entityId, $results);
239 239
 			}
240 240
 		}
241 241
 
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
 		?array $constraintIds,
263 263
 		array $statuses
264 264
 	) {
265
-		if ( $constraintIds !== null ) {
265
+		if ($constraintIds !== null) {
266 266
 			return false;
267 267
 		}
268
-		if ( array_diff( self::CACHED_STATUSES, $statuses ) !== [] ) {
268
+		if (array_diff(self::CACHED_STATUSES, $statuses) !== []) {
269 269
 			return false;
270 270
 		}
271 271
 		return true;
@@ -279,21 +279,21 @@  discard block
 block discarded – undo
279 279
 	 * May include check results for other entity IDs as well,
280 280
 	 * or check results with statuses that we’re not interested in caching.
281 281
 	 */
282
-	private function storeResults( EntityId $entityId, CachedCheckResults $results ) {
282
+	private function storeResults(EntityId $entityId, CachedCheckResults $results) {
283 283
 		$latestRevisionIds = $this->getLatestRevisionIds(
284 284
 			$results->getMetadata()->getDependencyMetadata()->getEntityIds()
285 285
 		);
286
-		if ( $latestRevisionIds === null ) {
286
+		if ($latestRevisionIds === null) {
287 287
 			return;
288 288
 		}
289 289
 
290 290
 		$resultSerializations = [];
291
-		foreach ( $results->getArray() as $checkResult ) {
292
-			if ( $checkResult->getContextCursor()->getEntityId() !== $entityId->getSerialization() ) {
291
+		foreach ($results->getArray() as $checkResult) {
292
+			if ($checkResult->getContextCursor()->getEntityId() !== $entityId->getSerialization()) {
293 293
 				continue;
294 294
 			}
295
-			if ( $this->statusSelected( self::CACHED_STATUSES, $checkResult ) ) {
296
-				$resultSerializations[] = $this->checkResultSerializer->serialize( $checkResult );
295
+			if ($this->statusSelected(self::CACHED_STATUSES, $checkResult)) {
296
+				$resultSerializations[] = $this->checkResultSerializer->serialize($checkResult);
297 297
 			}
298 298
 		}
299 299
 
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
 			'latestRevisionIds' => $latestRevisionIds,
303 303
 		];
304 304
 		$futureTime = $results->getMetadata()->getDependencyMetadata()->getFutureTime();
305
-		if ( $futureTime !== null ) {
305
+		if ($futureTime !== null) {
306 306
 			$value['futureTime'] = $futureTime->getArrayValue();
307 307
 		}
308 308
 
309
-		$this->cache->set( $entityId, $value, $this->ttlInSeconds );
309
+		$this->cache->set($entityId, $value, $this->ttlInSeconds);
310 310
 	}
311 311
 
312 312
 	/**
@@ -321,33 +321,32 @@  discard block
 block discarded – undo
321 321
 		$forRevision = 0
322 322
 	) {
323 323
 		$cacheInfo = WANObjectCache::PASS_BY_REF;
324
-		$value = $this->cache->get( $entityId, $curTTL, [], $cacheInfo );
325
-		$now = ( $this->microtime )( true );
324
+		$value = $this->cache->get($entityId, $curTTL, [], $cacheInfo);
325
+		$now = ($this->microtime)(true);
326 326
 
327
-		$dependencyMetadata = $this->checkDependencyMetadata( $value,
328
-			[ $entityId->getSerialization() => $forRevision ] );
329
-		if ( $dependencyMetadata === null ) {
327
+		$dependencyMetadata = $this->checkDependencyMetadata($value,
328
+			[$entityId->getSerialization() => $forRevision]);
329
+		if ($dependencyMetadata === null) {
330 330
 			return null;
331 331
 		}
332 332
 
333 333
 		// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset False positive
334 334
 		$asOf = $cacheInfo[WANObjectCache::KEY_AS_OF];
335
-		$ageInSeconds = (int)ceil( $now - $asOf );
335
+		$ageInSeconds = (int) ceil($now - $asOf);
336 336
 		$cachingMetadata = $ageInSeconds > 0 ?
337
-			CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) :
338
-			CachingMetadata::fresh();
337
+			CachingMetadata::ofMaximumAgeInSeconds($ageInSeconds) : CachingMetadata::fresh();
339 338
 
340 339
 		$results = [];
341
-		foreach ( $value['results'] as $resultSerialization ) {
342
-			$results[] = $this->deserializeCheckResult( $resultSerialization, $cachingMetadata );
340
+		foreach ($value['results'] as $resultSerialization) {
341
+			$results[] = $this->deserializeCheckResult($resultSerialization, $cachingMetadata);
343 342
 		}
344 343
 
345 344
 		return new CachedCheckResults(
346 345
 			$results,
347
-			Metadata::merge( [
348
-				Metadata::ofCachingMetadata( $cachingMetadata ),
349
-				Metadata::ofDependencyMetadata( $dependencyMetadata ),
350
-			] )
346
+			Metadata::merge([
347
+				Metadata::ofCachingMetadata($cachingMetadata),
348
+				Metadata::ofDependencyMetadata($dependencyMetadata),
349
+			])
351 350
 		);
352 351
 	}
353 352
 
@@ -363,43 +362,43 @@  discard block
 block discarded – undo
363 362
 	 * @return DependencyMetadata|null the dependency metadata,
364 363
 	 * or null if $value should no longer be used
365 364
 	 */
366
-	private function checkDependencyMetadata( $value, $paramRevs ) {
367
-		if ( $value === false ) {
365
+	private function checkDependencyMetadata($value, $paramRevs) {
366
+		if ($value === false) {
368 367
 			return null;
369 368
 		}
370 369
 
371
-		if ( array_key_exists( 'futureTime', $value ) ) {
372
-			$futureTime = TimeValue::newFromArray( $value['futureTime'] );
373
-			if ( !$this->timeValueComparer->isFutureTime( $futureTime ) ) {
370
+		if (array_key_exists('futureTime', $value)) {
371
+			$futureTime = TimeValue::newFromArray($value['futureTime']);
372
+			if (!$this->timeValueComparer->isFutureTime($futureTime)) {
374 373
 				return null;
375 374
 			}
376
-			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime( $futureTime );
375
+			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime($futureTime);
377 376
 		} else {
378 377
 			$futureTimeDependencyMetadata = DependencyMetadata::blank();
379 378
 		}
380 379
 
381
-		foreach ( $paramRevs as $id => $revision ) {
382
-			if ( $revision > 0 ) {
383
-				$value['latestRevisionIds'][$id] = min( $revision, $value['latestRevisionIds'][$id] ?? PHP_INT_MAX );
380
+		foreach ($paramRevs as $id => $revision) {
381
+			if ($revision > 0) {
382
+				$value['latestRevisionIds'][$id] = min($revision, $value['latestRevisionIds'][$id] ?? PHP_INT_MAX);
384 383
 			}
385 384
 		}
386 385
 
387 386
 		$dependedEntityIds = array_map(
388
-			[ $this->entityIdParser, "parse" ],
389
-			array_keys( $value['latestRevisionIds'] )
387
+			[$this->entityIdParser, "parse"],
388
+			array_keys($value['latestRevisionIds'])
390 389
 		);
391 390
 
392
-		if ( $value['latestRevisionIds'] !== $this->getLatestRevisionIds( $dependedEntityIds ) ) {
391
+		if ($value['latestRevisionIds'] !== $this->getLatestRevisionIds($dependedEntityIds)) {
393 392
 			return null;
394 393
 		}
395 394
 
396 395
 		return array_reduce(
397 396
 			$dependedEntityIds,
398
-			static function ( DependencyMetadata $metadata, EntityId $entityId ) {
399
-				return DependencyMetadata::merge( [
397
+			static function(DependencyMetadata $metadata, EntityId $entityId) {
398
+				return DependencyMetadata::merge([
400 399
 					$metadata,
401
-					DependencyMetadata::ofEntityId( $entityId ),
402
-				] );
400
+					DependencyMetadata::ofEntityId($entityId),
401
+				]);
403 402
 			},
404 403
 			$futureTimeDependencyMetadata
405 404
 		);
@@ -419,13 +418,13 @@  discard block
 block discarded – undo
419 418
 		array $resultSerialization,
420 419
 		CachingMetadata $cachingMetadata
421 420
 	) {
422
-		$result = $this->checkResultDeserializer->deserialize( $resultSerialization );
423
-		if ( $this->isPossiblyStaleResult( $result ) ) {
421
+		$result = $this->checkResultDeserializer->deserialize($resultSerialization);
422
+		if ($this->isPossiblyStaleResult($result)) {
424 423
 			$result->withMetadata(
425
-				Metadata::merge( [
424
+				Metadata::merge([
426 425
 					$result->getMetadata(),
427
-					Metadata::ofCachingMetadata( $cachingMetadata ),
428
-				] )
426
+					Metadata::ofCachingMetadata($cachingMetadata),
427
+				])
429 428
 			);
430 429
 		}
431 430
 		return $result;
@@ -435,8 +434,8 @@  discard block
 block discarded – undo
435 434
 	 * @param CheckResult $result
436 435
 	 * @return bool
437 436
 	 */
438
-	private function isPossiblyStaleResult( CheckResult $result ) {
439
-		if ( $result instanceof NullResult ) {
437
+	private function isPossiblyStaleResult(CheckResult $result) {
438
+		if ($result instanceof NullResult) {
440 439
 			return false;
441 440
 		}
442 441
 
@@ -451,14 +450,14 @@  discard block
 block discarded – undo
451 450
 	 * @return int[]|null array from entity ID serializations to revision ID,
452 451
 	 * or null to indicate that not all revision IDs could be loaded
453 452
 	 */
454
-	private function getLatestRevisionIds( array $entityIds ) {
455
-		if ( $entityIds === [] ) {
453
+	private function getLatestRevisionIds(array $entityIds) {
454
+		if ($entityIds === []) {
456 455
 			$this->loggingHelper->logEmptyDependencyMetadata();
457 456
 			return [];
458 457
 		}
459
-		if ( count( $entityIds ) > $this->maxRevisionIds ) {
458
+		if (count($entityIds) > $this->maxRevisionIds) {
460 459
 			// one of those entities will probably be edited soon, so might as well skip caching
461
-			$this->loggingHelper->logHugeDependencyMetadata( $entityIds, $this->maxRevisionIds );
460
+			$this->loggingHelper->logHugeDependencyMetadata($entityIds, $this->maxRevisionIds);
462 461
 			return null;
463 462
 		}
464 463
 
@@ -466,7 +465,7 @@  discard block
 block discarded – undo
466 465
 			$entityIds,
467 466
 			LookupConstants::LATEST_FROM_REPLICA
468 467
 		);
469
-		if ( $this->hasFalseElements( $latestRevisionIds ) ) {
468
+		if ($this->hasFalseElements($latestRevisionIds)) {
470 469
 			return null;
471 470
 		}
472 471
 		return $latestRevisionIds;
@@ -476,14 +475,14 @@  discard block
 block discarded – undo
476 475
 	 * @param array $array
477 476
 	 * @return bool
478 477
 	 */
479
-	private function hasFalseElements( array $array ) {
480
-		return in_array( false, $array, true );
478
+	private function hasFalseElements(array $array) {
479
+		return in_array(false, $array, true);
481 480
 	}
482 481
 
483 482
 	/**
484 483
 	 * Set a custom function to get the current time, instead of microtime().
485 484
 	 */
486
-	public function setMicrotimeFunction( callable $microtime ) {
485
+	public function setMicrotimeFunction(callable $microtime) {
487 486
 		$this->microtime = $microtime;
488 487
 	}
489 488
 
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\Api;
6 6
 
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 		CheckResultsRendererFactory $checkResultsRendererFactory,
85 85
 		StatsFactory $statsFactory
86 86
 	) {
87
-		parent::__construct( $main, $name );
87
+		parent::__construct($main, $name);
88 88
 		$this->entityIdParser = $entityIdParser;
89 89
 		$this->statementGuidValidator = $statementGuidValidator;
90
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
91
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
90
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
91
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
92 92
 		$this->resultsSource = $resultsSource;
93 93
 		$this->checkResultsRendererFactory = $checkResultsRendererFactory;
94 94
 		$this->statsFactory = $statsFactory;
@@ -99,19 +99,19 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function execute() {
101 101
 		$baseKey = 'wikibase.quality.constraints.api.checkConstraints.execute';
102
-		$metric = $this->statsFactory->getCounter( 'check_constraints_execute_total' );
103
-		$metric->copyToStatsdAt( $baseKey )->increment();
102
+		$metric = $this->statsFactory->getCounter('check_constraints_execute_total');
103
+		$metric->copyToStatsdAt($baseKey)->increment();
104 104
 
105 105
 		$params = $this->extractRequestParams();
106 106
 
107
-		$this->validateParameters( $params );
108
-		$entityIds = $this->parseEntityIds( $params );
109
-		$claimIds = $this->parseClaimIds( $params );
107
+		$this->validateParameters($params);
108
+		$entityIds = $this->parseEntityIds($params);
109
+		$claimIds = $this->parseClaimIds($params);
110 110
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
111 111
 		$statuses = $params[self::PARAM_STATUS];
112 112
 
113 113
 		$checkResultsRenderer = $this->checkResultsRendererFactory
114
-			->getCheckResultsRenderer( $this->getLanguage(), $this );
114
+			->getCheckResultsRenderer($this->getLanguage(), $this);
115 115
 
116 116
 		$this->getResult()->addValue(
117 117
 			null,
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 				)
126 126
 			)->getArray()
127 127
 		);
128
-		$this->resultBuilder->markSuccess( 1 );
128
+		$this->resultBuilder->markSuccess(1);
129 129
 	}
130 130
 
131 131
 	/**
@@ -133,24 +133,24 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @return EntityId[]
135 135
 	 */
136
-	private function parseEntityIds( array $params ): array {
136
+	private function parseEntityIds(array $params): array {
137 137
 		$ids = $params[self::PARAM_ID];
138 138
 
139
-		if ( $ids === null ) {
139
+		if ($ids === null) {
140 140
 			return [];
141
-		} elseif ( $ids === [] ) {
141
+		} elseif ($ids === []) {
142 142
 			$this->errorReporter->dieError(
143
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
143
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
144 144
 		}
145 145
 
146
-		return array_map( function ( $id ) {
146
+		return array_map(function($id) {
147 147
 			try {
148
-				return $this->entityIdParser->parse( $id );
149
-			} catch ( EntityIdParsingException ) {
148
+				return $this->entityIdParser->parse($id);
149
+			} catch (EntityIdParsingException) {
150 150
 				$this->errorReporter->dieError(
151
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
151
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
152 152
 			}
153
-		}, $ids );
153
+		}, $ids);
154 154
 	}
155 155
 
156 156
 	/**
@@ -158,35 +158,35 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @return string[]
160 160
 	 */
161
-	private function parseClaimIds( array $params ): array {
161
+	private function parseClaimIds(array $params): array {
162 162
 		$ids = $params[self::PARAM_CLAIM_ID];
163 163
 
164
-		if ( $ids === null ) {
164
+		if ($ids === null) {
165 165
 			return [];
166
-		} elseif ( $ids === [] ) {
166
+		} elseif ($ids === []) {
167 167
 			$this->errorReporter->dieError(
168
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
168
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
169 169
 		}
170 170
 
171
-		foreach ( $ids as $id ) {
172
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
171
+		foreach ($ids as $id) {
172
+			if (!$this->statementGuidValidator->validate($id)) {
173 173
 				$this->errorReporter->dieError(
174
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
174
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
175 175
 			}
176 176
 		}
177 177
 
178 178
 		return $ids;
179 179
 	}
180 180
 
181
-	private function validateParameters( array $params ): void {
182
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
183
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
181
+	private function validateParameters(array $params): void {
182
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
183
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
184 184
 		) {
185 185
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
186 186
 			$this->errorReporter->dieError(
187 187
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
188 188
 		}
189
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
189
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
190 190
 			$paramId = self::PARAM_ID;
191 191
 			$paramClaimId = self::PARAM_CLAIM_ID;
192 192
 			$this->errorReporter->dieError(
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 				],
228 228
 				ParamValidator::PARAM_ISMULTI => true,
229 229
 				ParamValidator::PARAM_ALL => true,
230
-				ParamValidator::PARAM_DEFAULT => implode( '|', CachingResultsSource::CACHED_STATUSES ),
230
+				ParamValidator::PARAM_DEFAULT => implode('|', CachingResultsSource::CACHED_STATUSES),
231 231
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
232 232
 			],
233 233
 		];
Please login to merge, or discard this patch.
src/Api/CheckConstraintParameters.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\Api;
6 6
 
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 		StatementGuidParser $statementGuidParser,
80 80
 		IBufferingStatsdDataFactory $dataFactory
81 81
 	) {
82
-		parent::__construct( $main, $name );
82
+		parent::__construct($main, $name);
83 83
 
84
-		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this );
84
+		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this);
85 85
 		$this->languageFallbackChainFactory = $languageFallbackChainFactory;
86 86
 		$this->delegatingConstraintChecker = $delegatingConstraintChecker;
87 87
 		$this->violationMessageRendererFactory = $violationMessageRendererFactory;
@@ -97,39 +97,39 @@  discard block
 block discarded – undo
97 97
 		$params = $this->extractRequestParams();
98 98
 		$result = $this->getResult();
99 99
 
100
-		$propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] );
101
-		$constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] );
100
+		$propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]);
101
+		$constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]);
102 102
 
103
-		$this->checkPropertyIds( $propertyIds, $result );
104
-		$this->checkConstraintIds( $constraintIds, $result );
103
+		$this->checkPropertyIds($propertyIds, $result);
104
+		$this->checkConstraintIds($constraintIds, $result);
105 105
 
106
-		$result->addValue( null, 'success', 1 );
106
+		$result->addValue(null, 'success', 1);
107 107
 	}
108 108
 
109 109
 	/**
110 110
 	 * @param array|null $propertyIdSerializations
111 111
 	 * @return NumericPropertyId[]
112 112
 	 */
113
-	private function parsePropertyIds( ?array $propertyIdSerializations ): array {
114
-		if ( $propertyIdSerializations === null ) {
113
+	private function parsePropertyIds(?array $propertyIdSerializations): array {
114
+		if ($propertyIdSerializations === null) {
115 115
 			return [];
116
-		} elseif ( $propertyIdSerializations === [] ) {
116
+		} elseif ($propertyIdSerializations === []) {
117 117
 			$this->apiErrorReporter->dieError(
118
-				'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.',
118
+				'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.',
119 119
 				'no-data'
120 120
 			);
121 121
 		}
122 122
 
123 123
 		return array_map(
124
-			function ( $propertyIdSerialization ) {
124
+			function($propertyIdSerialization) {
125 125
 				try {
126
-					return new NumericPropertyId( $propertyIdSerialization );
127
-				} catch ( InvalidArgumentException ) {
126
+					return new NumericPropertyId($propertyIdSerialization);
127
+				} catch (InvalidArgumentException) {
128 128
 					$this->apiErrorReporter->dieError(
129 129
 						"Invalid id: $propertyIdSerialization",
130 130
 						'invalid-property-id',
131 131
 						0, // default argument
132
-						[ self::PARAM_PROPERTY_ID => $propertyIdSerialization ]
132
+						[self::PARAM_PROPERTY_ID => $propertyIdSerialization]
133 133
 					);
134 134
 				}
135 135
 			},
@@ -141,35 +141,35 @@  discard block
 block discarded – undo
141 141
 	 * @param array|null $constraintIds
142 142
 	 * @return string[]
143 143
 	 */
144
-	private function parseConstraintIds( ?array $constraintIds ): array {
145
-		if ( $constraintIds === null ) {
144
+	private function parseConstraintIds(?array $constraintIds): array {
145
+		if ($constraintIds === null) {
146 146
 			return [];
147
-		} elseif ( $constraintIds === [] ) {
147
+		} elseif ($constraintIds === []) {
148 148
 			$this->apiErrorReporter->dieError(
149
-				'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.',
149
+				'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.',
150 150
 				'no-data'
151 151
 			);
152 152
 		}
153 153
 
154 154
 		return array_map(
155
-			function ( $constraintId ) {
155
+			function($constraintId) {
156 156
 				try {
157
-					$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
158
-					if ( !$propertyId instanceof NumericPropertyId ) {
157
+					$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
158
+					if (!$propertyId instanceof NumericPropertyId) {
159 159
 						$this->apiErrorReporter->dieError(
160 160
 							"Invalid property ID: {$propertyId->getSerialization()}",
161 161
 							'invalid-property-id',
162 162
 							0, // default argument
163
-							[ self::PARAM_CONSTRAINT_ID => $constraintId ]
163
+							[self::PARAM_CONSTRAINT_ID => $constraintId]
164 164
 						);
165 165
 					}
166 166
 					return $constraintId;
167
-				} catch ( StatementGuidParsingException ) {
167
+				} catch (StatementGuidParsingException) {
168 168
 					$this->apiErrorReporter->dieError(
169 169
 						"Invalid statement GUID: $constraintId",
170 170
 						'invalid-guid',
171 171
 						0, // default argument
172
-						[ self::PARAM_CONSTRAINT_ID => $constraintId ]
172
+						[self::PARAM_CONSTRAINT_ID => $constraintId]
173 173
 					);
174 174
 				}
175 175
 			},
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
 	 * @param NumericPropertyId[] $propertyIds
182 182
 	 * @param ApiResult $result
183 183
 	 */
184
-	private function checkPropertyIds( array $propertyIds, ApiResult $result ): void {
185
-		foreach ( $propertyIds as $propertyId ) {
186
-			$result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' );
184
+	private function checkPropertyIds(array $propertyIds, ApiResult $result): void {
185
+		foreach ($propertyIds as $propertyId) {
186
+			$result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc');
187 187
 			$allConstraintExceptions = $this->delegatingConstraintChecker
188
-				->checkConstraintParametersOnPropertyId( $propertyId );
189
-			foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) {
188
+				->checkConstraintParametersOnPropertyId($propertyId);
189
+			foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) {
190 190
 				$this->addConstraintParameterExceptionsToResult(
191 191
 					$constraintId,
192 192
 					$constraintParameterExceptions,
@@ -200,15 +200,15 @@  discard block
 block discarded – undo
200 200
 	 * @param string[] $constraintIds
201 201
 	 * @param ApiResult $result
202 202
 	 */
203
-	private function checkConstraintIds( array $constraintIds, ApiResult $result ): void {
204
-		foreach ( $constraintIds as $constraintId ) {
205
-			if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) {
203
+	private function checkConstraintIds(array $constraintIds, ApiResult $result): void {
204
+		foreach ($constraintIds as $constraintId) {
205
+			if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) {
206 206
 				// already checked as part of checkPropertyIds()
207 207
 				continue;
208 208
 			}
209 209
 			$constraintParameterExceptions = $this->delegatingConstraintChecker
210
-				->checkConstraintParametersOnConstraintId( $constraintId );
211
-			$this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result );
210
+				->checkConstraintParametersOnConstraintId($constraintId);
211
+			$this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result);
212 212
 		}
213 213
 	}
214 214
 
@@ -216,18 +216,18 @@  discard block
 block discarded – undo
216 216
 	 * @param NumericPropertyId $propertyId
217 217
 	 * @return string[]
218 218
 	 */
219
-	private function getResultPathForPropertyId( NumericPropertyId $propertyId ): array {
220
-		return [ $this->getModuleName(), $propertyId->getSerialization() ];
219
+	private function getResultPathForPropertyId(NumericPropertyId $propertyId): array {
220
+		return [$this->getModuleName(), $propertyId->getSerialization()];
221 221
 	}
222 222
 
223 223
 	/**
224 224
 	 * @param string $constraintId
225 225
 	 * @return string[]
226 226
 	 */
227
-	private function getResultPathForConstraintId( string $constraintId ): array {
228
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
227
+	private function getResultPathForConstraintId(string $constraintId): array {
228
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
229 229
 		'@phan-var NumericPropertyId $propertyId';
230
-		return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] );
230
+		return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]);
231 231
 	}
232 232
 
233 233
 	/**
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
 		?array $constraintParameterExceptions,
243 243
 		ApiResult $result
244 244
 	): void {
245
-		$path = $this->getResultPathForConstraintId( $constraintId );
246
-		if ( $constraintParameterExceptions === null ) {
245
+		$path = $this->getResultPathForConstraintId($constraintId);
246
+		if ($constraintParameterExceptions === null) {
247 247
 			$result->addValue(
248 248
 				$path,
249 249
 				self::KEY_STATUS,
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 			$violationMessageRenderer = $this->violationMessageRendererFactory
261 261
 				->getViolationMessageRenderer(
262 262
 					$language,
263
-					$this->languageFallbackChainFactory->newFromLanguage( $language ),
263
+					$this->languageFallbackChainFactory->newFromLanguage($language),
264 264
 					$this
265 265
 				);
266 266
 			$problems = [];
267
-			foreach ( $constraintParameterExceptions as $constraintParameterException ) {
267
+			foreach ($constraintParameterExceptions as $constraintParameterException) {
268 268
 				$problems[] = [
269 269
 					self::KEY_MESSAGE_HTML => $violationMessageRenderer->render(
270 270
 						$constraintParameterException->getViolationMessage() ),
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 		return [
304 304
 			'action=wbcheckconstraintparameters&propertyid=P247'
305 305
 				=> 'apihelp-wbcheckconstraintparameters-example-propertyid-1',
306
-			'action=wbcheckconstraintparameters&' .
307
-			'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|' .
306
+			'action=wbcheckconstraintparameters&'.
307
+			'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|'.
308 308
 			'P225$cdc71e4a-47a0-12c5-dfb3-3f6fc0b6613f'
309 309
 				=> 'apihelp-wbcheckconstraintparameters-example-constraintid-2',
310 310
 		];
Please login to merge, or discard this patch.
src/Api/ExpiryLock.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\Api;
6 6
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 
22 22
 	private BagOStuff $cache;
23 23
 
24
-	public function __construct( BagOStuff $cache ) {
24
+	public function __construct(BagOStuff $cache) {
25 25
 		$this->cache = $cache;
26 26
 	}
27 27
 
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @throws \Wikimedia\Assert\ParameterTypeException
34 34
 	 */
35
-	private function makeKey( string $id ): string {
36
-		if ( trim( $id ) === '' ) {
37
-			throw new ParameterTypeException( '$id', 'non-empty string' );
35
+	private function makeKey(string $id): string {
36
+		if (trim($id) === '') {
37
+			throw new ParameterTypeException('$id', 'non-empty string');
38 38
 		}
39 39
 
40 40
 		return $this->cache->makeKey(
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @throws \Wikimedia\Assert\ParameterTypeException
54 54
 	 */
55
-	public function lock( string $id, ConvertibleTimestamp $expiryTimestamp ): bool {
55
+	public function lock(string $id, ConvertibleTimestamp $expiryTimestamp): bool {
56 56
 
57
-		$cacheId = $this->makeKey( $id );
57
+		$cacheId = $this->makeKey($id);
58 58
 
59
-		if ( !$this->isLockedInternal( $cacheId ) ) {
59
+		if (!$this->isLockedInternal($cacheId)) {
60 60
 			return $this->cache->set(
61 61
 				$cacheId,
62
-				$expiryTimestamp->getTimestamp( TS_UNIX ),
63
-				(int)$expiryTimestamp->getTimestamp( TS_UNIX )
62
+				$expiryTimestamp->getTimestamp(TS_UNIX),
63
+				(int) $expiryTimestamp->getTimestamp(TS_UNIX)
64 64
 			);
65 65
 		} else {
66 66
 			return false;
@@ -74,20 +74,20 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @throws \Wikimedia\Assert\ParameterTypeException
76 76
 	 */
77
-	private function isLockedInternal( string $cacheId ): bool {
78
-		$expiryTime = $this->cache->get( $cacheId );
79
-		if ( !$expiryTime ) {
77
+	private function isLockedInternal(string $cacheId): bool {
78
+		$expiryTime = $this->cache->get($cacheId);
79
+		if (!$expiryTime) {
80 80
 			return false;
81 81
 		}
82 82
 
83 83
 		try {
84
-			$lockExpiryTimeStamp = new ConvertibleTimestamp( $expiryTime );
85
-		} catch ( TimestampException ) {
84
+			$lockExpiryTimeStamp = new ConvertibleTimestamp($expiryTime);
85
+		} catch (TimestampException) {
86 86
 			return false;
87 87
 		}
88 88
 
89 89
 		$now = new ConvertibleTimestamp();
90
-		if ( $now->timestamp < $lockExpiryTimeStamp->timestamp ) {
90
+		if ($now->timestamp < $lockExpiryTimeStamp->timestamp) {
91 91
 			return true;
92 92
 		} else {
93 93
 			return false;
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @throws \Wikimedia\Assert\ParameterTypeException
103 103
 	 */
104
-	public function isLocked( string $id ): bool {
105
-		return $this->isLockedInternal( $this->makeKey( $id ) );
104
+	public function isLocked(string $id): bool {
105
+		return $this->isLockedInternal($this->makeKey($id));
106 106
 	}
107 107
 
108 108
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Result/NullResult.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 // @phan-file-suppress PhanPluginNeverReturnMethod
6 6
 
@@ -28,22 +28,22 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	private const NULL_PROPERTY_ID = 'P2147483647';
30 30
 
31
-	public function __construct( ContextCursor $contextCursor ) {
31
+	public function __construct(ContextCursor $contextCursor) {
32 32
 		$constraint = new Constraint(
33 33
 			'null',
34
-			new NumericPropertyId( self::NULL_PROPERTY_ID ),
34
+			new NumericPropertyId(self::NULL_PROPERTY_ID),
35 35
 			'none',
36 36
 			[]
37 37
 		);
38
-		parent::__construct( $contextCursor, $constraint );
38
+		parent::__construct($contextCursor, $constraint);
39 39
 	}
40 40
 
41 41
 	public function getConstraint(): Constraint {
42
-		throw new DomainException( 'NullResult holds no constraint' );
42
+		throw new DomainException('NullResult holds no constraint');
43 43
 	}
44 44
 
45 45
 	public function getConstraintId(): string {
46
-		throw new DomainException( 'NullResult holds no constraint' );
46
+		throw new DomainException('NullResult holds no constraint');
47 47
 	}
48 48
 
49 49
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/DummySparqlHelper.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 // @phan-file-suppress PhanPluginNeverReturnMethod
6 6
 
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 		// no parent::__construct() call
30 30
 	}
31 31
 
32
-	public function hasType( EntityId $id, array $classes ): CachedBool {
33
-		throw new LogicException( 'methods of this class should never be called' );
32
+	public function hasType(EntityId $id, array $classes): CachedBool {
33
+		throw new LogicException('methods of this class should never be called');
34 34
 	}
35 35
 
36 36
 	public function findEntitiesWithSameStatement(
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		Statement $statement,
39 39
 		array $separators
40 40
 	): CachedEntityIds {
41
-		throw new LogicException( 'methods of this class should never be called' );
41
+		throw new LogicException('methods of this class should never be called');
42 42
 	}
43 43
 
44 44
 	public function findEntitiesWithSameQualifierOrReference(
@@ -47,15 +47,15 @@  discard block
 block discarded – undo
47 47
 		string $type,
48 48
 		bool $ignoreDeprecatedStatements
49 49
 	): CachedEntityIds {
50
-		throw new LogicException( 'methods of this class should never be called' );
50
+		throw new LogicException('methods of this class should never be called');
51 51
 	}
52 52
 
53
-	public function matchesRegularExpression( string $text, string $regex ): bool {
54
-		throw new LogicException( 'methods of this class should never be called' );
53
+	public function matchesRegularExpression(string $text, string $regex): bool {
54
+		throw new LogicException('methods of this class should never be called');
55 55
 	}
56 56
 
57
-	public function runQuery( string $query, string $endpoint, bool $needsPrefixes = true ): CachedQueryResults {
58
-		throw new LogicException( 'methods of this class should never be called' );
57
+	public function runQuery(string $query, string $endpoint, bool $needsPrefixes = true): CachedQueryResults {
58
+		throw new LogicException('methods of this class should never be called');
59 59
 	}
60 60
 
61 61
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/EntityContextCursor.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 // @phan-file-suppress PhanPluginNeverReturnMethod
6 6
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @codeCoverageIgnore This method is not supported.
34 34
 	 */
35 35
 	public function getType(): string {
36
-		throw new LogicException( 'EntityContextCursor has no full associated context' );
36
+		throw new LogicException('EntityContextCursor has no full associated context');
37 37
 	}
38 38
 
39 39
 	public function getEntityId(): string {
@@ -44,35 +44,35 @@  discard block
 block discarded – undo
44 44
 	 * @codeCoverageIgnore This method is not supported.
45 45
 	 */
46 46
 	public function getStatementPropertyId(): string {
47
-		throw new LogicException( 'EntityContextCursor has no full associated context' );
47
+		throw new LogicException('EntityContextCursor has no full associated context');
48 48
 	}
49 49
 
50 50
 	/**
51 51
 	 * @codeCoverageIgnore This method is not supported.
52 52
 	 */
53 53
 	public function getStatementGuid(): string {
54
-		throw new LogicException( 'EntityContextCursor has no full associated context' );
54
+		throw new LogicException('EntityContextCursor has no full associated context');
55 55
 	}
56 56
 
57 57
 	/**
58 58
 	 * @codeCoverageIgnore This method is not supported.
59 59
 	 */
60 60
 	public function getSnakPropertyId(): string {
61
-		throw new LogicException( 'EntityContextCursor has no full associated context' );
61
+		throw new LogicException('EntityContextCursor has no full associated context');
62 62
 	}
63 63
 
64 64
 	/**
65 65
 	 * @codeCoverageIgnore This method is not supported.
66 66
 	 */
67 67
 	public function getSnakHash(): string {
68
-		throw new LogicException( 'EntityContextCursor has no full associated context' );
68
+		throw new LogicException('EntityContextCursor has no full associated context');
69 69
 	}
70 70
 
71 71
 	/**
72 72
 	 * @codeCoverageIgnore This method is not supported.
73 73
 	 */
74
-	public function &getMainArray( array &$container ): array {
75
-		throw new LogicException( 'EntityContextCursor cannot store check results' );
74
+	public function &getMainArray(array &$container): array {
75
+		throw new LogicException('EntityContextCursor cannot store check results');
76 76
 	}
77 77
 
78 78
 	/**
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 	 * @param ?array $result must be null
82 82
 	 * @param array[] &$container
83 83
 	 */
84
-	public function storeCheckResultInArray( ?array $result, array &$container ): void {
85
-		if ( $result !== null ) {
86
-			throw new LogicException( 'EntityContextCursor cannot store check results' );
84
+	public function storeCheckResultInArray(?array $result, array &$container): void {
85
+		if ($result !== null) {
86
+			throw new LogicException('EntityContextCursor cannot store check results');
87 87
 		}
88 88
 
89 89
 		// this ensures that the claims array is present in the $container,
90 90
 		// populating it if necessary, even though we ignore the return value
91
-		$this->getClaimsArray( $container );
91
+		$this->getClaimsArray($container);
92 92
 	}
93 93
 
94 94
 }
Please login to merge, or discard this patch.