Completed
Push — master ( abda46...09a985 )
by
unknown
07:52
created
src/ConstraintCheck/ItemIdSnakValue.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param ItemId $itemId
45 45
 	 * @return self
46 46
 	 */
47
-	public static function fromItemId( ItemId $itemId ) {
47
+	public static function fromItemId(ItemId $itemId) {
48 48
 		$ret = new self;
49 49
 		$ret->itemId = $itemId;
50 50
 		return $ret;
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	 * @throws InvalidArgumentException
81 81
 	 * @return self
82 82
 	 */
83
-	public static function fromSnak( Snak $snak ) {
84
-		switch ( true ) {
83
+	public static function fromSnak(Snak $snak) {
84
+		switch (true) {
85 85
 			case $snak instanceof PropertyValueSnak:
86 86
 				$dataValue = $snak->getDataValue();
87
-				if ( $dataValue instanceof EntityIdValue ) {
87
+				if ($dataValue instanceof EntityIdValue) {
88 88
 					$itemId = $dataValue->getEntityId();
89
-					if ( $itemId instanceof ItemId ) {
90
-						return self::fromItemId( $itemId );
89
+					if ($itemId instanceof ItemId) {
90
+						return self::fromItemId($itemId);
91 91
 					}
92 92
 				}
93 93
 				break;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 				return self::noValue();
98 98
 		}
99 99
 
100
-		throw new InvalidArgumentException( 'Snak must contain item ID value or be a somevalue / novalue snak' );
100
+		throw new InvalidArgumentException('Snak must contain item ID value or be a somevalue / novalue snak');
101 101
 	}
102 102
 
103 103
 	/**
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 * @return ItemId
136 136
 	 */
137 137
 	public function getItemId() {
138
-		if ( !$this->isValue() ) {
139
-			throw new DomainException( 'This value does not contain an item ID.' );
138
+		if (!$this->isValue()) {
139
+			throw new DomainException('This value does not contain an item ID.');
140 140
 		}
141 141
 		return $this->itemId;
142 142
 	}
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 	 * @param Snak $snak
149 149
 	 * @return bool
150 150
 	 */
151
-	public function matchesSnak( Snak $snak ) {
152
-		switch ( true ) {
151
+	public function matchesSnak(Snak $snak) {
152
+		switch (true) {
153 153
 			case $snak instanceof PropertyValueSnak:
154 154
 				$dataValue = $snak->getDataValue();
155 155
 				return $this->isValue() &&
156 156
 					$dataValue instanceof EntityIdValue &&
157 157
 					$dataValue->getEntityId() instanceof ItemId &&
158
-					$dataValue->getEntityId()->equals( $this->getItemId() );
158
+					$dataValue->getEntityId()->equals($this->getItemId());
159 159
 			case $snak instanceof PropertySomeValueSnak:
160 160
 				return $this->isSomeValue();
161 161
 			case $snak instanceof PropertyNoValueSnak:
Please login to merge, or discard this patch.
src/Job/CheckConstraintsJob.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -37,25 +37,25 @@  discard block
 block discarded – undo
37 37
 	 * @param Title $title
38 38
 	 * @param string[] $params should contain 'entityId' => 'Q1234'
39 39
 	 */
40
-	public function __construct( Title $title, array $params ) {
41
-		parent::__construct( self::COMMAND, $title, $params );
40
+	public function __construct(Title $title, array $params) {
41
+		parent::__construct(self::COMMAND, $title, $params);
42 42
 		$this->removeDuplicates = true;
43 43
 
44
-		Assert::parameterType( 'string', $params['entityId'], '$params[\'entityId\']' );
44
+		Assert::parameterType('string', $params['entityId'], '$params[\'entityId\']');
45 45
 
46
-		$resultSource = ConstraintsServices::getResultsSource( MediaWikiServices::getInstance() );
46
+		$resultSource = ConstraintsServices::getResultsSource(MediaWikiServices::getInstance());
47 47
 		'@phan-var CachingResultsSource $resultSource';
48 48
 		// This job should only ever be used when caching result sources are used.
49
-		$this->setResultsSource( $resultSource );
49
+		$this->setResultsSource($resultSource);
50 50
 
51
-		$this->setEntityIdParser( WikibaseRepo::getDefaultInstance()->getEntityIdParser() );
51
+		$this->setEntityIdParser(WikibaseRepo::getDefaultInstance()->getEntityIdParser());
52 52
 	}
53 53
 
54
-	public function setResultsSource( CachingResultsSource $resultsSource ) {
54
+	public function setResultsSource(CachingResultsSource $resultsSource) {
55 55
 		$this->resultsSource = $resultsSource;
56 56
 	}
57 57
 
58
-	public function setEntityIdParser( EntityIdParser $parser ) {
58
+	public function setEntityIdParser(EntityIdParser $parser) {
59 59
 		$this->entityIdParser = $parser;
60 60
 	}
61 61
 
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function run() {
68 68
 		try {
69
-			$entityId = $this->entityIdParser->parse( $this->params['entityId'] );
70
-		} catch ( EntityIdParsingException $e ) {
69
+			$entityId = $this->entityIdParser->parse($this->params['entityId']);
70
+		} catch (EntityIdParsingException $e) {
71 71
 			return false;
72 72
 		}
73 73
 
74
-		$this->checkConstraints( $entityId );
74
+		$this->checkConstraints($entityId);
75 75
 
76 76
 		return true;
77 77
 	}
78 78
 
79
-	private function checkConstraints( EntityId $entityId ) {
79
+	private function checkConstraints(EntityId $entityId) {
80 80
 		$this->resultsSource->getResults(
81
-			[ $entityId ],
81
+			[$entityId],
82 82
 			[],
83 83
 			null,
84 84
 			[]
Please login to merge, or discard this patch.
src/Api/CheckConstraintParameters.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -75,17 +75,17 @@  discard block
 block discarded – undo
75 75
 		DelegatingConstraintChecker $delegatingConstraintChecker
76 76
 	): self {
77 77
 		$repo = WikibaseRepo::getDefaultInstance();
78
-		$helperFactory = $repo->getApiHelperFactory( RequestContext::getMain() );
78
+		$helperFactory = $repo->getApiHelperFactory(RequestContext::getMain());
79 79
 		$language = $repo->getUserLanguage();
80 80
 
81 81
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
82 82
 		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory
83
-			->getEntityIdFormatter( $language );
83
+			->getEntityIdFormatter($language);
84 84
 		$formatterOptions = new FormatterOptions();
85
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
85
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
86 86
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
87 87
 		$dataValueFormatter = $valueFormatterFactory
88
-			->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
88
+			->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
89 89
 		$violationMessageRenderer = new MultilingualTextViolationMessageRenderer(
90 90
 			$entityIdHtmlLinkFormatter,
91 91
 			$dataValueFormatter,
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 		StatementGuidParser $statementGuidParser,
122 122
 		IBufferingStatsdDataFactory $dataFactory
123 123
 	) {
124
-		parent::__construct( $main, $name );
124
+		parent::__construct($main, $name);
125 125
 
126
-		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this );
126
+		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this);
127 127
 		$this->delegatingConstraintChecker = $delegatingConstraintChecker;
128 128
 		$this->violationMessageRenderer = $violationMessageRenderer;
129 129
 		$this->statementGuidParser = $statementGuidParser;
@@ -138,39 +138,39 @@  discard block
 block discarded – undo
138 138
 		$params = $this->extractRequestParams();
139 139
 		$result = $this->getResult();
140 140
 
141
-		$propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] );
142
-		$constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] );
141
+		$propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]);
142
+		$constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]);
143 143
 
144
-		$this->checkPropertyIds( $propertyIds, $result );
145
-		$this->checkConstraintIds( $constraintIds, $result );
144
+		$this->checkPropertyIds($propertyIds, $result);
145
+		$this->checkConstraintIds($constraintIds, $result);
146 146
 
147
-		$result->addValue( null, 'success', 1 );
147
+		$result->addValue(null, 'success', 1);
148 148
 	}
149 149
 
150 150
 	/**
151 151
 	 * @param array|null $propertyIdSerializations
152 152
 	 * @return PropertyId[]
153 153
 	 */
154
-	private function parsePropertyIds( $propertyIdSerializations ) {
155
-		if ( $propertyIdSerializations === null ) {
154
+	private function parsePropertyIds($propertyIdSerializations) {
155
+		if ($propertyIdSerializations === null) {
156 156
 			return [];
157
-		} elseif ( empty( $propertyIdSerializations ) ) {
157
+		} elseif (empty($propertyIdSerializations)) {
158 158
 			$this->apiErrorReporter->dieError(
159
-				'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.',
159
+				'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.',
160 160
 				'no-data'
161 161
 			);
162 162
 		}
163 163
 
164 164
 		return array_map(
165
-			function( $propertyIdSerialization ) {
165
+			function($propertyIdSerialization) {
166 166
 				try {
167
-					return new PropertyId( $propertyIdSerialization );
168
-				} catch ( InvalidArgumentException $e ) {
167
+					return new PropertyId($propertyIdSerialization);
168
+				} catch (InvalidArgumentException $e) {
169 169
 					$this->apiErrorReporter->dieError(
170 170
 						"Invalid id: $propertyIdSerialization",
171 171
 						'invalid-property-id',
172 172
 						0, // default argument
173
-						[ self::PARAM_PROPERTY_ID => $propertyIdSerialization ]
173
+						[self::PARAM_PROPERTY_ID => $propertyIdSerialization]
174 174
 					);
175 175
 				}
176 176
 			},
@@ -182,35 +182,35 @@  discard block
 block discarded – undo
182 182
 	 * @param array|null $constraintIds
183 183
 	 * @return string[]
184 184
 	 */
185
-	private function parseConstraintIds( $constraintIds ) {
186
-		if ( $constraintIds === null ) {
185
+	private function parseConstraintIds($constraintIds) {
186
+		if ($constraintIds === null) {
187 187
 			return [];
188
-		} elseif ( empty( $constraintIds ) ) {
188
+		} elseif (empty($constraintIds)) {
189 189
 			$this->apiErrorReporter->dieError(
190
-				'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.',
190
+				'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.',
191 191
 				'no-data'
192 192
 			);
193 193
 		}
194 194
 
195 195
 		return array_map(
196
-			function( $constraintId ) {
196
+			function($constraintId) {
197 197
 				try {
198
-					$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
199
-					if ( !$propertyId instanceof PropertyId ) {
198
+					$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
199
+					if (!$propertyId instanceof PropertyId) {
200 200
 						$this->apiErrorReporter->dieError(
201 201
 							"Invalid property ID: {$propertyId->getSerialization()}",
202 202
 							'invalid-property-id',
203 203
 							0, // default argument
204
-							[ self::PARAM_CONSTRAINT_ID => $constraintId ]
204
+							[self::PARAM_CONSTRAINT_ID => $constraintId]
205 205
 						);
206 206
 					}
207 207
 					return $constraintId;
208
-				} catch ( StatementGuidParsingException $e ) {
208
+				} catch (StatementGuidParsingException $e) {
209 209
 					$this->apiErrorReporter->dieError(
210 210
 						"Invalid statement GUID: $constraintId",
211 211
 						'invalid-guid',
212 212
 						0, // default argument
213
-						[ self::PARAM_CONSTRAINT_ID => $constraintId ]
213
+						[self::PARAM_CONSTRAINT_ID => $constraintId]
214 214
 					);
215 215
 				}
216 216
 			},
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 	 * @param PropertyId[] $propertyIds
223 223
 	 * @param ApiResult $result
224 224
 	 */
225
-	private function checkPropertyIds( array $propertyIds, ApiResult $result ) {
226
-		foreach ( $propertyIds as $propertyId ) {
227
-			$result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' );
225
+	private function checkPropertyIds(array $propertyIds, ApiResult $result) {
226
+		foreach ($propertyIds as $propertyId) {
227
+			$result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc');
228 228
 			$allConstraintExceptions = $this->delegatingConstraintChecker
229
-				->checkConstraintParametersOnPropertyId( $propertyId );
230
-			foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) {
229
+				->checkConstraintParametersOnPropertyId($propertyId);
230
+			foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) {
231 231
 				$this->addConstraintParameterExceptionsToResult(
232 232
 					$constraintId,
233 233
 					$constraintParameterExceptions,
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
 	 * @param string[] $constraintIds
242 242
 	 * @param ApiResult $result
243 243
 	 */
244
-	private function checkConstraintIds( array $constraintIds, ApiResult $result ) {
245
-		foreach ( $constraintIds as $constraintId ) {
246
-			if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) {
244
+	private function checkConstraintIds(array $constraintIds, ApiResult $result) {
245
+		foreach ($constraintIds as $constraintId) {
246
+			if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) {
247 247
 				// already checked as part of checkPropertyIds()
248 248
 				continue;
249 249
 			}
250 250
 			$constraintParameterExceptions = $this->delegatingConstraintChecker
251
-				->checkConstraintParametersOnConstraintId( $constraintId );
252
-			$this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result );
251
+				->checkConstraintParametersOnConstraintId($constraintId);
252
+			$this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result);
253 253
 		}
254 254
 	}
255 255
 
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 	 * @param PropertyId $propertyId
258 258
 	 * @return string[]
259 259
 	 */
260
-	private function getResultPathForPropertyId( PropertyId $propertyId ) {
261
-		return [ $this->getModuleName(), $propertyId->getSerialization() ];
260
+	private function getResultPathForPropertyId(PropertyId $propertyId) {
261
+		return [$this->getModuleName(), $propertyId->getSerialization()];
262 262
 	}
263 263
 
264 264
 	/**
265 265
 	 * @param string $constraintId
266 266
 	 * @return string[]
267 267
 	 */
268
-	private function getResultPathForConstraintId( $constraintId ) {
269
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
268
+	private function getResultPathForConstraintId($constraintId) {
269
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
270 270
 		'@phan-var PropertyId $propertyId';
271
-		return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] );
271
+		return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]);
272 272
 	}
273 273
 
274 274
 	/**
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 		$constraintParameterExceptions,
284 284
 		ApiResult $result
285 285
 	) {
286
-		$path = $this->getResultPathForConstraintId( $constraintId );
287
-		if ( $constraintParameterExceptions === null ) {
286
+		$path = $this->getResultPathForConstraintId($constraintId);
287
+		if ($constraintParameterExceptions === null) {
288 288
 			$result->addValue(
289 289
 				$path,
290 290
 				self::KEY_STATUS,
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 			$result->addValue(
295 295
 				$path,
296 296
 				self::KEY_STATUS,
297
-				empty( $constraintParameterExceptions ) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY
297
+				empty($constraintParameterExceptions) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY
298 298
 			);
299 299
 			$result->addValue(
300 300
 				$path,
301 301
 				self::KEY_PROBLEMS,
302
-				array_map( [ $this, 'formatConstraintParameterException' ], $constraintParameterExceptions )
302
+				array_map([$this, 'formatConstraintParameterException'], $constraintParameterExceptions)
303 303
 			);
304 304
 		}
305 305
 	}
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	 * @param ConstraintParameterException $e
311 311
 	 * @return string[]
312 312
 	 */
313
-	private function formatConstraintParameterException( ConstraintParameterException $e ) {
313
+	private function formatConstraintParameterException(ConstraintParameterException $e) {
314 314
 		return [
315 315
 			self::KEY_MESSAGE_HTML => $this->violationMessageRenderer->render(
316 316
 				$e->getViolationMessage()
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 		return [
344 344
 			'action=wbcheckconstraintparameters&propertyid=P247'
345 345
 				=> 'apihelp-wbcheckconstraintparameters-example-propertyid-1',
346
-			'action=wbcheckconstraintparameters&' .
347
-			'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|' .
346
+			'action=wbcheckconstraintparameters&'.
347
+			'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|'.
348 348
 			'P225$cdc71e4a-47a0-12c5-dfb3-3f6fc0b6613f'
349 349
 				=> 'apihelp-wbcheckconstraintparameters-example-constraintid-2',
350 350
 		];
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
 
84 84
 		$language = $repo->getUserLanguage();
85 85
 		$formatterOptions = new FormatterOptions();
86
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
86
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
87 87
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
88
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
88
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
89 89
 
90 90
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
91
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language );
91
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language);
92 92
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
93
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language );
93
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language);
94 94
 
95 95
 		$checkResultsRenderer = new CheckResultsRenderer(
96 96
 			$repo->getEntityTitleLookup(),
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 			$name,
109 109
 			$repo->getEntityIdParser(),
110 110
 			$repo->getStatementGuidValidator(),
111
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
111
+			$repo->getApiHelperFactory(RequestContext::getMain()),
112 112
 			$resultsSource,
113 113
 			$checkResultsRenderer,
114 114
 			$dataFactory
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 		CheckResultsRenderer $checkResultsRenderer,
136 136
 		IBufferingStatsdDataFactory $dataFactory
137 137
 	) {
138
-		parent::__construct( $main, $name );
138
+		parent::__construct($main, $name);
139 139
 		$this->entityIdParser = $entityIdParser;
140 140
 		$this->statementGuidValidator = $statementGuidValidator;
141
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
142
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
141
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
142
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
143 143
 		$this->resultsSource = $resultsSource;
144 144
 		$this->checkResultsRenderer = $checkResultsRenderer;
145 145
 		$this->dataFactory = $dataFactory;
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 
156 156
 		$params = $this->extractRequestParams();
157 157
 
158
-		$this->validateParameters( $params );
159
-		$entityIds = $this->parseEntityIds( $params );
160
-		$claimIds = $this->parseClaimIds( $params );
158
+		$this->validateParameters($params);
159
+		$entityIds = $this->parseEntityIds($params);
160
+		$claimIds = $this->parseClaimIds($params);
161 161
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
162 162
 		$statuses = $params[self::PARAM_STATUS];
163 163
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 				)
174 174
 			)->getArray()
175 175
 		);
176
-		$this->resultBuilder->markSuccess( 1 );
176
+		$this->resultBuilder->markSuccess(1);
177 177
 	}
178 178
 
179 179
 	/**
@@ -181,24 +181,24 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return EntityId[]
183 183
 	 */
184
-	private function parseEntityIds( array $params ) {
184
+	private function parseEntityIds(array $params) {
185 185
 		$ids = $params[self::PARAM_ID];
186 186
 
187
-		if ( $ids === null ) {
187
+		if ($ids === null) {
188 188
 			return [];
189
-		} elseif ( $ids === [] ) {
189
+		} elseif ($ids === []) {
190 190
 			$this->errorReporter->dieError(
191
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
191
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
192 192
 		}
193 193
 
194
-		return array_map( function ( $id ) {
194
+		return array_map(function($id) {
195 195
 			try {
196
-				return $this->entityIdParser->parse( $id );
197
-			} catch ( EntityIdParsingException $e ) {
196
+				return $this->entityIdParser->parse($id);
197
+			} catch (EntityIdParsingException $e) {
198 198
 				$this->errorReporter->dieError(
199
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
199
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
200 200
 			}
201
-		}, $ids );
201
+		}, $ids);
202 202
 	}
203 203
 
204 204
 	/**
@@ -206,36 +206,36 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @return string[]
208 208
 	 */
209
-	private function parseClaimIds( array $params ) {
209
+	private function parseClaimIds(array $params) {
210 210
 		$ids = $params[self::PARAM_CLAIM_ID];
211 211
 
212
-		if ( $ids === null ) {
212
+		if ($ids === null) {
213 213
 			return [];
214
-		} elseif ( $ids === [] ) {
214
+		} elseif ($ids === []) {
215 215
 			$this->errorReporter->dieError(
216
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
216
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
217 217
 		}
218 218
 
219
-		foreach ( $ids as $id ) {
220
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
219
+		foreach ($ids as $id) {
220
+			if (!$this->statementGuidValidator->validate($id)) {
221 221
 				$this->errorReporter->dieError(
222
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
222
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
223 223
 			}
224 224
 		}
225 225
 
226 226
 		return $ids;
227 227
 	}
228 228
 
229
-	private function validateParameters( array $params ) {
230
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
231
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
229
+	private function validateParameters(array $params) {
230
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
231
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
232 232
 		) {
233 233
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
234 234
 			$this->errorReporter->dieError(
235 235
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
236 236
 		}
237 237
 		// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset
238
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
238
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
239 239
 			$paramId = self::PARAM_ID;
240 240
 			$paramClaimId = self::PARAM_CLAIM_ID;
241 241
 			$this->errorReporter->dieError(
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 				],
277 277
 				ApiBase::PARAM_ISMULTI => true,
278 278
 				ApiBase::PARAM_ALL => true,
279
-				ApiBase::PARAM_DFLT => implode( '|', CachingResultsSource::CACHED_STATUSES ),
279
+				ApiBase::PARAM_DFLT => implode('|', CachingResultsSource::CACHED_STATUSES),
280 280
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
281 281
 			],
282 282
 		];
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterParser.php 1 patch
Spacing   +287 added lines, -287 removed lines patch added patch discarded remove patch
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
 	 * @param array $parameters
78 78
 	 * @throws ConstraintParameterException
79 79
 	 */
80
-	public function checkError( array $parameters ) {
81
-		if ( array_key_exists( '@error', $parameters ) ) {
80
+	public function checkError(array $parameters) {
81
+		if (array_key_exists('@error', $parameters)) {
82 82
 			$error = $parameters['@error'];
83
-			if ( array_key_exists( 'toolong', $error ) && $error['toolong'] ) {
83
+			if (array_key_exists('toolong', $error) && $error['toolong']) {
84 84
 				$msg = 'wbqc-violation-message-parameters-error-toolong';
85 85
 			} else {
86 86
 				$msg = 'wbqc-violation-message-parameters-error-unknown';
87 87
 			}
88
-			throw new ConstraintParameterException( new ViolationMessage( $msg ) );
88
+			throw new ConstraintParameterException(new ViolationMessage($msg));
89 89
 		}
90 90
 	}
91 91
 
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
 	 * @param string $parameterId
96 96
 	 * @throws ConstraintParameterException
97 97
 	 */
98
-	private function requireSingleParameter( array $parameters, $parameterId ) {
99
-		if ( count( $parameters[$parameterId] ) !== 1 ) {
98
+	private function requireSingleParameter(array $parameters, $parameterId) {
99
+		if (count($parameters[$parameterId]) !== 1) {
100 100
 			throw new ConstraintParameterException(
101
-				( new ViolationMessage( 'wbqc-violation-message-parameter-single' ) )
102
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
101
+				(new ViolationMessage('wbqc-violation-message-parameter-single'))
102
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
103 103
 			);
104 104
 		}
105 105
 	}
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
 	 * @return void
112 112
 	 * @throws ConstraintParameterException
113 113
 	 */
114
-	private function requireValueParameter( Snak $snak, $parameterId ) {
115
-		if ( !( $snak instanceof PropertyValueSnak ) ) {
114
+	private function requireValueParameter(Snak $snak, $parameterId) {
115
+		if (!($snak instanceof PropertyValueSnak)) {
116 116
 			throw new ConstraintParameterException(
117
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
118
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
117
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
118
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
119 119
 			);
120 120
 		}
121 121
 	}
@@ -127,17 +127,17 @@  discard block
 block discarded – undo
127 127
 	 * @throws ConstraintParameterException
128 128
 	 * @return EntityId
129 129
 	 */
130
-	private function parseEntityIdParameter( array $snakSerialization, $parameterId ) {
131
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
132
-		$this->requireValueParameter( $snak, $parameterId );
130
+	private function parseEntityIdParameter(array $snakSerialization, $parameterId) {
131
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
132
+		$this->requireValueParameter($snak, $parameterId);
133 133
 		$value = $snak->getDataValue();
134
-		if ( $value instanceof EntityIdValue ) {
134
+		if ($value instanceof EntityIdValue) {
135 135
 			return $value->getEntityId();
136 136
 		} else {
137 137
 			throw new ConstraintParameterException(
138
-				( new ViolationMessage( 'wbqc-violation-message-parameter-entity' ) )
139
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
140
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
138
+				(new ViolationMessage('wbqc-violation-message-parameter-entity'))
139
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
140
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
141 141
 			);
142 142
 		}
143 143
 	}
@@ -148,20 +148,20 @@  discard block
 block discarded – undo
148 148
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
149 149
 	 * @return string[] class entity ID serializations
150 150
 	 */
151
-	public function parseClassParameter( array $constraintParameters, $constraintTypeItemId ) {
152
-		$this->checkError( $constraintParameters );
153
-		$classId = $this->config->get( 'WBQualityConstraintsClassId' );
154
-		if ( !array_key_exists( $classId, $constraintParameters ) ) {
151
+	public function parseClassParameter(array $constraintParameters, $constraintTypeItemId) {
152
+		$this->checkError($constraintParameters);
153
+		$classId = $this->config->get('WBQualityConstraintsClassId');
154
+		if (!array_key_exists($classId, $constraintParameters)) {
155 155
 			throw new ConstraintParameterException(
156
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
157
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
158
-					->withEntityId( new PropertyId( $classId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
156
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
157
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
158
+					->withEntityId(new PropertyId($classId), Role::CONSTRAINT_PARAMETER_PROPERTY)
159 159
 			);
160 160
 		}
161 161
 
162 162
 		$classes = [];
163
-		foreach ( $constraintParameters[$classId] as $class ) {
164
-			$classes[] = $this->parseEntityIdParameter( $class, $classId )->getSerialization();
163
+		foreach ($constraintParameters[$classId] as $class) {
164
+			$classes[] = $this->parseEntityIdParameter($class, $classId)->getSerialization();
165 165
 		}
166 166
 		return $classes;
167 167
 	}
@@ -172,23 +172,23 @@  discard block
 block discarded – undo
172 172
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
173 173
 	 * @return string 'instance', 'subclass', or 'instanceOrSubclass'
174 174
 	 */
175
-	public function parseRelationParameter( array $constraintParameters, $constraintTypeItemId ) {
176
-		$this->checkError( $constraintParameters );
177
-		$relationId = $this->config->get( 'WBQualityConstraintsRelationId' );
178
-		if ( !array_key_exists( $relationId, $constraintParameters ) ) {
175
+	public function parseRelationParameter(array $constraintParameters, $constraintTypeItemId) {
176
+		$this->checkError($constraintParameters);
177
+		$relationId = $this->config->get('WBQualityConstraintsRelationId');
178
+		if (!array_key_exists($relationId, $constraintParameters)) {
179 179
 			throw new ConstraintParameterException(
180
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
181
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
182
-					->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
180
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
181
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
182
+					->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
183 183
 			);
184 184
 		}
185 185
 
186
-		$this->requireSingleParameter( $constraintParameters, $relationId );
187
-		$relationEntityId = $this->parseEntityIdParameter( $constraintParameters[$relationId][0], $relationId );
188
-		$instanceId = $this->config->get( 'WBQualityConstraintsInstanceOfRelationId' );
189
-		$subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfRelationId' );
190
-		$instanceOrSubclassId = $this->config->get( 'WBQualityConstraintsInstanceOrSubclassOfRelationId' );
191
-		switch ( $relationEntityId ) {
186
+		$this->requireSingleParameter($constraintParameters, $relationId);
187
+		$relationEntityId = $this->parseEntityIdParameter($constraintParameters[$relationId][0], $relationId);
188
+		$instanceId = $this->config->get('WBQualityConstraintsInstanceOfRelationId');
189
+		$subclassId = $this->config->get('WBQualityConstraintsSubclassOfRelationId');
190
+		$instanceOrSubclassId = $this->config->get('WBQualityConstraintsInstanceOrSubclassOfRelationId');
191
+		switch ($relationEntityId) {
192 192
 			case $instanceId:
193 193
 				return 'instance';
194 194
 			case $subclassId:
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
 				return 'instanceOrSubclass';
198 198
 			default:
199 199
 				throw new ConstraintParameterException(
200
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
201
-						->withEntityId( new PropertyId( $relationId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
200
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
201
+						->withEntityId(new PropertyId($relationId), Role::CONSTRAINT_PARAMETER_PROPERTY)
202 202
 						->withEntityIdList(
203 203
 							[
204
-								new ItemId( $instanceId ),
205
-								new ItemId( $subclassId ),
206
-								new ItemId( $instanceOrSubclassId ),
204
+								new ItemId($instanceId),
205
+								new ItemId($subclassId),
206
+								new ItemId($instanceOrSubclassId),
207 207
 							],
208 208
 							Role::CONSTRAINT_PARAMETER_VALUE
209 209
 						)
@@ -218,20 +218,20 @@  discard block
 block discarded – undo
218 218
 	 * @throws ConstraintParameterException
219 219
 	 * @return PropertyId
220 220
 	 */
221
-	private function parsePropertyIdParameter( array $snakSerialization, $parameterId ) {
222
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
223
-		$this->requireValueParameter( $snak, $parameterId );
221
+	private function parsePropertyIdParameter(array $snakSerialization, $parameterId) {
222
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
223
+		$this->requireValueParameter($snak, $parameterId);
224 224
 		$value = $snak->getDataValue();
225
-		if ( $value instanceof EntityIdValue ) {
225
+		if ($value instanceof EntityIdValue) {
226 226
 			$id = $value->getEntityId();
227
-			if ( $id instanceof PropertyId ) {
227
+			if ($id instanceof PropertyId) {
228 228
 				return $id;
229 229
 			}
230 230
 		}
231 231
 		throw new ConstraintParameterException(
232
-			( new ViolationMessage( 'wbqc-violation-message-parameter-property' ) )
233
-				->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
234
-				->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
232
+			(new ViolationMessage('wbqc-violation-message-parameter-property'))
233
+				->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
234
+				->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
235 235
 		);
236 236
 	}
237 237
 
@@ -242,33 +242,33 @@  discard block
 block discarded – undo
242 242
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
243 243
 	 * @return PropertyId
244 244
 	 */
245
-	public function parsePropertyParameter( array $constraintParameters, $constraintTypeItemId ) {
246
-		$this->checkError( $constraintParameters );
247
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
248
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
245
+	public function parsePropertyParameter(array $constraintParameters, $constraintTypeItemId) {
246
+		$this->checkError($constraintParameters);
247
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
248
+		if (!array_key_exists($propertyId, $constraintParameters)) {
249 249
 			throw new ConstraintParameterException(
250
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
251
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
252
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
250
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
251
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
252
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
253 253
 			);
254 254
 		}
255 255
 
256
-		$this->requireSingleParameter( $constraintParameters, $propertyId );
257
-		return $this->parsePropertyIdParameter( $constraintParameters[$propertyId][0], $propertyId );
256
+		$this->requireSingleParameter($constraintParameters, $propertyId);
257
+		return $this->parsePropertyIdParameter($constraintParameters[$propertyId][0], $propertyId);
258 258
 	}
259 259
 
260
-	private function parseItemIdParameter( PropertyValueSnak $snak, $parameterId ) {
260
+	private function parseItemIdParameter(PropertyValueSnak $snak, $parameterId) {
261 261
 		$dataValue = $snak->getDataValue();
262
-		if ( $dataValue instanceof EntityIdValue ) {
262
+		if ($dataValue instanceof EntityIdValue) {
263 263
 			$entityId = $dataValue->getEntityId();
264
-			if ( $entityId instanceof ItemId ) {
265
-				return ItemIdSnakValue::fromItemId( $entityId );
264
+			if ($entityId instanceof ItemId) {
265
+				return ItemIdSnakValue::fromItemId($entityId);
266 266
 			}
267 267
 		}
268 268
 		throw new ConstraintParameterException(
269
-			( new ViolationMessage( 'wbqc-violation-message-parameter-item' ) )
270
-				->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
271
-				->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
269
+			(new ViolationMessage('wbqc-violation-message-parameter-item'))
270
+				->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
271
+				->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
272 272
 		);
273 273
 	}
274 274
 
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
 		$required,
287 287
 		$parameterId = null
288 288
 	) {
289
-		$this->checkError( $constraintParameters );
290
-		if ( $parameterId === null ) {
291
-			$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
289
+		$this->checkError($constraintParameters);
290
+		if ($parameterId === null) {
291
+			$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
292 292
 		}
293
-		if ( !array_key_exists( $parameterId, $constraintParameters ) ) {
294
-			if ( $required ) {
293
+		if (!array_key_exists($parameterId, $constraintParameters)) {
294
+			if ($required) {
295 295
 				throw new ConstraintParameterException(
296
-					( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
297
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
298
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
296
+					(new ViolationMessage('wbqc-violation-message-parameter-needed'))
297
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
298
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
299 299
 				);
300 300
 			} else {
301 301
 				return [];
@@ -303,11 +303,11 @@  discard block
 block discarded – undo
303 303
 		}
304 304
 
305 305
 		$values = [];
306
-		foreach ( $constraintParameters[$parameterId] as $parameter ) {
307
-			$snak = $this->snakDeserializer->deserialize( $parameter );
308
-			switch ( true ) {
306
+		foreach ($constraintParameters[$parameterId] as $parameter) {
307
+			$snak = $this->snakDeserializer->deserialize($parameter);
308
+			switch (true) {
309 309
 				case $snak instanceof PropertyValueSnak:
310
-					$values[] = $this->parseItemIdParameter( $snak, $parameterId );
310
+					$values[] = $this->parseItemIdParameter($snak, $parameterId);
311 311
 					break;
312 312
 				case $snak instanceof PropertySomeValueSnak:
313 313
 					$values[] = ItemIdSnakValue::someValue();
@@ -326,27 +326,27 @@  discard block
 block discarded – undo
326 326
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
327 327
 	 * @return PropertyId[]
328 328
 	 */
329
-	public function parsePropertiesParameter( array $constraintParameters, $constraintTypeItemId ) {
330
-		$this->checkError( $constraintParameters );
331
-		$propertyId = $this->config->get( 'WBQualityConstraintsPropertyId' );
332
-		if ( !array_key_exists( $propertyId, $constraintParameters ) ) {
329
+	public function parsePropertiesParameter(array $constraintParameters, $constraintTypeItemId) {
330
+		$this->checkError($constraintParameters);
331
+		$propertyId = $this->config->get('WBQualityConstraintsPropertyId');
332
+		if (!array_key_exists($propertyId, $constraintParameters)) {
333 333
 			throw new ConstraintParameterException(
334
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
335
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
336
-					->withEntityId( new PropertyId( $propertyId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
334
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
335
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
336
+					->withEntityId(new PropertyId($propertyId), Role::CONSTRAINT_PARAMETER_PROPERTY)
337 337
 			);
338 338
 		}
339 339
 
340 340
 		$parameters = $constraintParameters[$propertyId];
341
-		if ( count( $parameters ) === 1 &&
342
-			$this->snakDeserializer->deserialize( $parameters[0] ) instanceof PropertyNoValueSnak
341
+		if (count($parameters) === 1 &&
342
+			$this->snakDeserializer->deserialize($parameters[0]) instanceof PropertyNoValueSnak
343 343
 		) {
344 344
 			return [];
345 345
 		}
346 346
 
347 347
 		$properties = [];
348
-		foreach ( $parameters as $parameter ) {
349
-			$properties[] = $this->parsePropertyIdParameter( $parameter, $propertyId );
348
+		foreach ($parameters as $parameter) {
349
+			$properties[] = $this->parsePropertyIdParameter($parameter, $propertyId);
350 350
 		}
351 351
 		return $properties;
352 352
 	}
@@ -357,16 +357,16 @@  discard block
 block discarded – undo
357 357
 	 * @throws ConstraintParameterException
358 358
 	 * @return DataValue|null
359 359
 	 */
360
-	private function parseValueOrNoValueParameter( array $snakSerialization, $parameterId ) {
361
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
362
-		if ( $snak instanceof PropertyValueSnak ) {
360
+	private function parseValueOrNoValueParameter(array $snakSerialization, $parameterId) {
361
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
362
+		if ($snak instanceof PropertyValueSnak) {
363 363
 			return $snak->getDataValue();
364
-		} elseif ( $snak instanceof PropertyNoValueSnak ) {
364
+		} elseif ($snak instanceof PropertyNoValueSnak) {
365 365
 			return null;
366 366
 		} else {
367 367
 			throw new ConstraintParameterException(
368
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
369
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
368
+				(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
369
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
370 370
 			);
371 371
 		}
372 372
 	}
@@ -376,10 +376,10 @@  discard block
 block discarded – undo
376 376
 	 * @param string $parameterId
377 377
 	 * @return DataValue|null
378 378
 	 */
379
-	private function parseValueOrNoValueOrNowParameter( array $snakSerialization, $parameterId ) {
379
+	private function parseValueOrNoValueOrNowParameter(array $snakSerialization, $parameterId) {
380 380
 		try {
381
-			return $this->parseValueOrNoValueParameter( $snakSerialization, $parameterId );
382
-		} catch ( ConstraintParameterException $e ) {
381
+			return $this->parseValueOrNoValueParameter($snakSerialization, $parameterId);
382
+		} catch (ConstraintParameterException $e) {
383 383
 			// unknown value means “now”
384 384
 			return new NowValue();
385 385
 		}
@@ -392,14 +392,14 @@  discard block
 block discarded – undo
392 392
 	 * @param string $unit
393 393
 	 * @return bool
394 394
 	 */
395
-	private function exactlyOneQuantityWithUnit( ?DataValue $min, ?DataValue $max, $unit ) {
396
-		if ( !( $min instanceof UnboundedQuantityValue ) ||
397
-			!( $max instanceof UnboundedQuantityValue )
395
+	private function exactlyOneQuantityWithUnit(?DataValue $min, ?DataValue $max, $unit) {
396
+		if (!($min instanceof UnboundedQuantityValue) ||
397
+			!($max instanceof UnboundedQuantityValue)
398 398
 		) {
399 399
 			return false;
400 400
 		}
401 401
 
402
-		return ( $min->getUnit() === $unit ) !== ( $max->getUnit() === $unit );
402
+		return ($min->getUnit() === $unit) !== ($max->getUnit() === $unit);
403 403
 	}
404 404
 
405 405
 	/**
@@ -412,42 +412,42 @@  discard block
 block discarded – undo
412 412
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
413 413
 	 * @return DataValue[] if the parameter is invalid or missing
414 414
 	 */
415
-	private function parseRangeParameter( array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type ) {
416
-		$this->checkError( $constraintParameters );
417
-		if ( !array_key_exists( $minimumId, $constraintParameters ) ||
418
-			!array_key_exists( $maximumId, $constraintParameters )
415
+	private function parseRangeParameter(array $constraintParameters, $minimumId, $maximumId, $constraintTypeItemId, $type) {
416
+		$this->checkError($constraintParameters);
417
+		if (!array_key_exists($minimumId, $constraintParameters) ||
418
+			!array_key_exists($maximumId, $constraintParameters)
419 419
 		) {
420 420
 			throw new ConstraintParameterException(
421
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-needed' ) )
422
-					->withDataValueType( $type )
423
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
424
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
425
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
421
+				(new ViolationMessage('wbqc-violation-message-range-parameters-needed'))
422
+					->withDataValueType($type)
423
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
424
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
425
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
426 426
 			);
427 427
 		}
428 428
 
429
-		$this->requireSingleParameter( $constraintParameters, $minimumId );
430
-		$this->requireSingleParameter( $constraintParameters, $maximumId );
429
+		$this->requireSingleParameter($constraintParameters, $minimumId);
430
+		$this->requireSingleParameter($constraintParameters, $maximumId);
431 431
 		$parseFunction = $type === 'time' ? 'parseValueOrNoValueOrNowParameter' : 'parseValueOrNoValueParameter';
432
-		$min = $this->$parseFunction( $constraintParameters[$minimumId][0], $minimumId );
433
-		$max = $this->$parseFunction( $constraintParameters[$maximumId][0], $maximumId );
432
+		$min = $this->$parseFunction($constraintParameters[$minimumId][0], $minimumId);
433
+		$max = $this->$parseFunction($constraintParameters[$maximumId][0], $maximumId);
434 434
 
435
-		$yearUnit = $this->config->get( 'WBQualityConstraintsYearUnit' );
436
-		if ( $this->exactlyOneQuantityWithUnit( $min, $max, $yearUnit ) ) {
435
+		$yearUnit = $this->config->get('WBQualityConstraintsYearUnit');
436
+		if ($this->exactlyOneQuantityWithUnit($min, $max, $yearUnit)) {
437 437
 			throw new ConstraintParameterException(
438
-				new ViolationMessage( 'wbqc-violation-message-range-parameters-one-year' )
438
+				new ViolationMessage('wbqc-violation-message-range-parameters-one-year')
439 439
 			);
440 440
 		}
441
-		if ( $min === null && $max === null ||
442
-			$min !== null && $max !== null && $min->equals( $max ) ) {
441
+		if ($min === null && $max === null ||
442
+			$min !== null && $max !== null && $min->equals($max)) {
443 443
 			throw new ConstraintParameterException(
444
-				( new ViolationMessage( 'wbqc-violation-message-range-parameters-same' ) )
445
-					->withEntityId( new PropertyId( $minimumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
446
-					->withEntityId( new PropertyId( $maximumId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
444
+				(new ViolationMessage('wbqc-violation-message-range-parameters-same'))
445
+					->withEntityId(new PropertyId($minimumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
446
+					->withEntityId(new PropertyId($maximumId), Role::CONSTRAINT_PARAMETER_PROPERTY)
447 447
 			);
448 448
 		}
449 449
 
450
-		return [ $min, $max ];
450
+		return [$min, $max];
451 451
 	}
452 452
 
453 453
 	/**
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
458 458
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
459 459
 	 */
460
-	public function parseQuantityRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
460
+	public function parseQuantityRangeParameter(array $constraintParameters, $constraintTypeItemId) {
461 461
 		return $this->parseRangeParameter(
462 462
 			$constraintParameters,
463
-			$this->config->get( 'WBQualityConstraintsMinimumQuantityId' ),
464
-			$this->config->get( 'WBQualityConstraintsMaximumQuantityId' ),
463
+			$this->config->get('WBQualityConstraintsMinimumQuantityId'),
464
+			$this->config->get('WBQualityConstraintsMaximumQuantityId'),
465 465
 			$constraintTypeItemId,
466 466
 			'quantity'
467 467
 		);
@@ -474,11 +474,11 @@  discard block
 block discarded – undo
474 474
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
475 475
 	 * @return DataValue[] a pair of two data values, either of which may be null to signify an open range
476 476
 	 */
477
-	public function parseTimeRangeParameter( array $constraintParameters, $constraintTypeItemId ) {
477
+	public function parseTimeRangeParameter(array $constraintParameters, $constraintTypeItemId) {
478 478
 		return $this->parseRangeParameter(
479 479
 			$constraintParameters,
480
-			$this->config->get( 'WBQualityConstraintsMinimumDateId' ),
481
-			$this->config->get( 'WBQualityConstraintsMaximumDateId' ),
480
+			$this->config->get('WBQualityConstraintsMinimumDateId'),
481
+			$this->config->get('WBQualityConstraintsMaximumDateId'),
482 482
 			$constraintTypeItemId,
483 483
 			'time'
484 484
 		);
@@ -491,17 +491,17 @@  discard block
 block discarded – undo
491 491
 	 * @throws ConstraintParameterException
492 492
 	 * @return string
493 493
 	 */
494
-	private function parseStringParameter( array $snakSerialization, $parameterId ) {
495
-		$snak = $this->snakDeserializer->deserialize( $snakSerialization );
496
-		$this->requireValueParameter( $snak, $parameterId );
494
+	private function parseStringParameter(array $snakSerialization, $parameterId) {
495
+		$snak = $this->snakDeserializer->deserialize($snakSerialization);
496
+		$this->requireValueParameter($snak, $parameterId);
497 497
 		$value = $snak->getDataValue();
498
-		if ( $value instanceof StringValue ) {
498
+		if ($value instanceof StringValue) {
499 499
 			return $value->getValue();
500 500
 		} else {
501 501
 			throw new ConstraintParameterException(
502
-				( new ViolationMessage( 'wbqc-violation-message-parameter-string' ) )
503
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
504
-					->withDataValue( $value, Role::CONSTRAINT_PARAMETER_VALUE )
502
+				(new ViolationMessage('wbqc-violation-message-parameter-string'))
503
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
504
+					->withDataValue($value, Role::CONSTRAINT_PARAMETER_VALUE)
505 505
 			);
506 506
 		}
507 507
 	}
@@ -512,15 +512,15 @@  discard block
 block discarded – undo
512 512
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
513 513
 	 * @return string
514 514
 	 */
515
-	public function parseNamespaceParameter( array $constraintParameters, $constraintTypeItemId ) {
516
-		$this->checkError( $constraintParameters );
517
-		$namespaceId = $this->config->get( 'WBQualityConstraintsNamespaceId' );
518
-		if ( !array_key_exists( $namespaceId, $constraintParameters ) ) {
515
+	public function parseNamespaceParameter(array $constraintParameters, $constraintTypeItemId) {
516
+		$this->checkError($constraintParameters);
517
+		$namespaceId = $this->config->get('WBQualityConstraintsNamespaceId');
518
+		if (!array_key_exists($namespaceId, $constraintParameters)) {
519 519
 			return '';
520 520
 		}
521 521
 
522
-		$this->requireSingleParameter( $constraintParameters, $namespaceId );
523
-		return $this->parseStringParameter( $constraintParameters[$namespaceId][0], $namespaceId );
522
+		$this->requireSingleParameter($constraintParameters, $namespaceId);
523
+		return $this->parseStringParameter($constraintParameters[$namespaceId][0], $namespaceId);
524 524
 	}
525 525
 
526 526
 	/**
@@ -529,19 +529,19 @@  discard block
 block discarded – undo
529 529
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
530 530
 	 * @return string
531 531
 	 */
532
-	public function parseFormatParameter( array $constraintParameters, $constraintTypeItemId ) {
533
-		$this->checkError( $constraintParameters );
534
-		$formatId = $this->config->get( 'WBQualityConstraintsFormatAsARegularExpressionId' );
535
-		if ( !array_key_exists( $formatId, $constraintParameters ) ) {
532
+	public function parseFormatParameter(array $constraintParameters, $constraintTypeItemId) {
533
+		$this->checkError($constraintParameters);
534
+		$formatId = $this->config->get('WBQualityConstraintsFormatAsARegularExpressionId');
535
+		if (!array_key_exists($formatId, $constraintParameters)) {
536 536
 			throw new ConstraintParameterException(
537
-				( new ViolationMessage( 'wbqc-violation-message-parameter-needed' ) )
538
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
539
-					->withEntityId( new PropertyId( $formatId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
537
+				(new ViolationMessage('wbqc-violation-message-parameter-needed'))
538
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
539
+					->withEntityId(new PropertyId($formatId), Role::CONSTRAINT_PARAMETER_PROPERTY)
540 540
 			);
541 541
 		}
542 542
 
543
-		$this->requireSingleParameter( $constraintParameters, $formatId );
544
-		return $this->parseStringParameter( $constraintParameters[$formatId][0], $formatId );
543
+		$this->requireSingleParameter($constraintParameters, $formatId);
544
+		return $this->parseStringParameter($constraintParameters[$formatId][0], $formatId);
545 545
 	}
546 546
 
547 547
 	/**
@@ -549,16 +549,16 @@  discard block
 block discarded – undo
549 549
 	 * @throws ConstraintParameterException if the parameter is invalid
550 550
 	 * @return EntityId[]
551 551
 	 */
552
-	public function parseExceptionParameter( array $constraintParameters ) {
553
-		$this->checkError( $constraintParameters );
554
-		$exceptionId = $this->config->get( 'WBQualityConstraintsExceptionToConstraintId' );
555
-		if ( !array_key_exists( $exceptionId, $constraintParameters ) ) {
552
+	public function parseExceptionParameter(array $constraintParameters) {
553
+		$this->checkError($constraintParameters);
554
+		$exceptionId = $this->config->get('WBQualityConstraintsExceptionToConstraintId');
555
+		if (!array_key_exists($exceptionId, $constraintParameters)) {
556 556
 			return [];
557 557
 		}
558 558
 
559 559
 		return array_map(
560
-			function( $snakSerialization ) use ( $exceptionId ) {
561
-				return $this->parseEntityIdParameter( $snakSerialization, $exceptionId );
560
+			function($snakSerialization) use ($exceptionId) {
561
+				return $this->parseEntityIdParameter($snakSerialization, $exceptionId);
562 562
 			},
563 563
 			$constraintParameters[$exceptionId]
564 564
 		);
@@ -569,39 +569,39 @@  discard block
 block discarded – undo
569 569
 	 * @throws ConstraintParameterException if the parameter is invalid
570 570
 	 * @return string|null 'mandatory', 'suggestion' or null
571 571
 	 */
572
-	public function parseConstraintStatusParameter( array $constraintParameters ) {
573
-		$this->checkError( $constraintParameters );
574
-		$constraintStatusId = $this->config->get( 'WBQualityConstraintsConstraintStatusId' );
575
-		if ( !array_key_exists( $constraintStatusId, $constraintParameters ) ) {
572
+	public function parseConstraintStatusParameter(array $constraintParameters) {
573
+		$this->checkError($constraintParameters);
574
+		$constraintStatusId = $this->config->get('WBQualityConstraintsConstraintStatusId');
575
+		if (!array_key_exists($constraintStatusId, $constraintParameters)) {
576 576
 			return null;
577 577
 		}
578 578
 
579
-		$mandatoryId = $this->config->get( 'WBQualityConstraintsMandatoryConstraintId' );
580
-		$supportedStatuses = [ new ItemId( $mandatoryId ) ];
581
-		if ( $this->config->get( 'WBQualityConstraintsEnableSuggestionConstraintStatus' ) ) {
582
-			$suggestionId = $this->config->get( 'WBQualityConstraintsSuggestionConstraintId' );
583
-			$supportedStatuses[] = new ItemId( $suggestionId );
579
+		$mandatoryId = $this->config->get('WBQualityConstraintsMandatoryConstraintId');
580
+		$supportedStatuses = [new ItemId($mandatoryId)];
581
+		if ($this->config->get('WBQualityConstraintsEnableSuggestionConstraintStatus')) {
582
+			$suggestionId = $this->config->get('WBQualityConstraintsSuggestionConstraintId');
583
+			$supportedStatuses[] = new ItemId($suggestionId);
584 584
 		} else {
585 585
 			$suggestionId = null;
586 586
 		}
587 587
 
588
-		$this->requireSingleParameter( $constraintParameters, $constraintStatusId );
589
-		$snak = $this->snakDeserializer->deserialize( $constraintParameters[$constraintStatusId][0] );
590
-		$this->requireValueParameter( $snak, $constraintStatusId );
588
+		$this->requireSingleParameter($constraintParameters, $constraintStatusId);
589
+		$snak = $this->snakDeserializer->deserialize($constraintParameters[$constraintStatusId][0]);
590
+		$this->requireValueParameter($snak, $constraintStatusId);
591 591
 		'@phan-var \Wikibase\DataModel\Snak\PropertyValueSnak $snak';
592 592
 		$dataValue = $snak->getDataValue();
593 593
 		'@phan-var EntityIdValue $dataValue';
594 594
 		$entityId = $dataValue->getEntityId();
595 595
 		$statusId = $entityId->getSerialization();
596 596
 
597
-		if ( $statusId === $mandatoryId ) {
597
+		if ($statusId === $mandatoryId) {
598 598
 			return 'mandatory';
599
-		} elseif ( $statusId === $suggestionId ) {
599
+		} elseif ($statusId === $suggestionId) {
600 600
 			return 'suggestion';
601 601
 		} else {
602 602
 			throw new ConstraintParameterException(
603
-				( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
604
-					->withEntityId( new PropertyId( $constraintStatusId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
603
+				(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
604
+					->withEntityId(new PropertyId($constraintStatusId), Role::CONSTRAINT_PARAMETER_PROPERTY)
605 605
 					->withEntityIdList(
606 606
 						$supportedStatuses,
607 607
 						Role::CONSTRAINT_PARAMETER_VALUE
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
 	 * @return void
618 618
 	 * @throws ConstraintParameterException
619 619
 	 */
620
-	private function requireMonolingualTextParameter( DataValue $dataValue, $parameterId ) {
621
-		if ( !( $dataValue instanceof MonolingualTextValue ) ) {
620
+	private function requireMonolingualTextParameter(DataValue $dataValue, $parameterId) {
621
+		if (!($dataValue instanceof MonolingualTextValue)) {
622 622
 			throw new ConstraintParameterException(
623
-				( new ViolationMessage( 'wbqc-violation-message-parameter-monolingualtext' ) )
624
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
625
-					->withDataValue( $dataValue, Role::CONSTRAINT_PARAMETER_VALUE )
623
+				(new ViolationMessage('wbqc-violation-message-parameter-monolingualtext'))
624
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
625
+					->withDataValue($dataValue, Role::CONSTRAINT_PARAMETER_VALUE)
626 626
 			);
627 627
 		}
628 628
 	}
@@ -635,31 +635,31 @@  discard block
 block discarded – undo
635 635
 	 * @throws ConstraintParameterException if invalid snaks are found or a language has multiple texts
636 636
 	 * @return MultilingualTextValue
637 637
 	 */
638
-	private function parseMultilingualTextParameter( array $snakSerializations, $parameterId ) {
638
+	private function parseMultilingualTextParameter(array $snakSerializations, $parameterId) {
639 639
 		$result = [];
640 640
 
641
-		foreach ( $snakSerializations as $snakSerialization ) {
642
-			$snak = $this->snakDeserializer->deserialize( $snakSerialization );
643
-			$this->requireValueParameter( $snak, $parameterId );
641
+		foreach ($snakSerializations as $snakSerialization) {
642
+			$snak = $this->snakDeserializer->deserialize($snakSerialization);
643
+			$this->requireValueParameter($snak, $parameterId);
644 644
 
645 645
 			$value = $snak->getDataValue();
646
-			$this->requireMonolingualTextParameter( $value, $parameterId );
646
+			$this->requireMonolingualTextParameter($value, $parameterId);
647 647
 			/** @var MonolingualTextValue $value */
648 648
 			'@phan-var MonolingualTextValue $value';
649 649
 
650 650
 			$code = $value->getLanguageCode();
651
-			if ( array_key_exists( $code, $result ) ) {
651
+			if (array_key_exists($code, $result)) {
652 652
 				throw new ConstraintParameterException(
653
-					( new ViolationMessage( 'wbqc-violation-message-parameter-single-per-language' ) )
654
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
655
-						->withLanguage( $code )
653
+					(new ViolationMessage('wbqc-violation-message-parameter-single-per-language'))
654
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
655
+						->withLanguage($code)
656 656
 				);
657 657
 			}
658 658
 
659 659
 			$result[$code] = $value;
660 660
 		}
661 661
 
662
-		return new MultilingualTextValue( $result );
662
+		return new MultilingualTextValue($result);
663 663
 	}
664 664
 
665 665
 	/**
@@ -667,11 +667,11 @@  discard block
 block discarded – undo
667 667
 	 * @throws ConstraintParameterException if the parameter is invalid
668 668
 	 * @return MultilingualTextValue
669 669
 	 */
670
-	public function parseSyntaxClarificationParameter( array $constraintParameters ) {
671
-		$syntaxClarificationId = $this->config->get( 'WBQualityConstraintsSyntaxClarificationId' );
670
+	public function parseSyntaxClarificationParameter(array $constraintParameters) {
671
+		$syntaxClarificationId = $this->config->get('WBQualityConstraintsSyntaxClarificationId');
672 672
 
673
-		if ( !array_key_exists( $syntaxClarificationId, $constraintParameters ) ) {
674
-			return new MultilingualTextValue( [] );
673
+		if (!array_key_exists($syntaxClarificationId, $constraintParameters)) {
674
+			return new MultilingualTextValue([]);
675 675
 		}
676 676
 
677 677
 		$syntaxClarifications = $this->parseMultilingualTextParameter(
@@ -690,9 +690,9 @@  discard block
 block discarded – undo
690 690
 	 * @throws ConstraintParameterException if the parameter is invalid
691 691
 	 * @return string[]|null Context::TYPE_* constants
692 692
 	 */
693
-	public function parseConstraintScopeParameter( array $constraintParameters, $constraintTypeItemId, array $validScopes = null ) {
693
+	public function parseConstraintScopeParameter(array $constraintParameters, $constraintTypeItemId, array $validScopes = null) {
694 694
 		$contextTypes = [];
695
-		$parameterId = $this->config->get( 'WBQualityConstraintsConstraintScopeId' );
695
+		$parameterId = $this->config->get('WBQualityConstraintsConstraintScopeId');
696 696
 		$items = $this->parseItemsParameter(
697 697
 			$constraintParameters,
698 698
 			$constraintTypeItemId,
@@ -700,23 +700,23 @@  discard block
 block discarded – undo
700 700
 			$parameterId
701 701
 		);
702 702
 
703
-		if ( $items === [] ) {
703
+		if ($items === []) {
704 704
 			return null;
705 705
 		}
706 706
 
707
-		foreach ( $items as $item ) {
708
-			$contextTypes[] = $this->parseContextTypeItem( $item, 'constraint scope', $parameterId );
707
+		foreach ($items as $item) {
708
+			$contextTypes[] = $this->parseContextTypeItem($item, 'constraint scope', $parameterId);
709 709
 		}
710 710
 
711
-		if ( $validScopes !== null ) {
712
-			$invalidScopes = array_diff( $contextTypes, $validScopes );
713
-			if ( $invalidScopes !== [] ) {
714
-				$invalidScope = array_pop( $invalidScopes );
711
+		if ($validScopes !== null) {
712
+			$invalidScopes = array_diff($contextTypes, $validScopes);
713
+			if ($invalidScopes !== []) {
714
+				$invalidScope = array_pop($invalidScopes);
715 715
 				throw new ConstraintParameterException(
716
-					( new ViolationMessage( 'wbqc-violation-message-invalid-scope' ) )
717
-						->withConstraintScope( $invalidScope, Role::CONSTRAINT_PARAMETER_VALUE )
718
-						->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
719
-						->withConstraintScopeList( $validScopes, Role::CONSTRAINT_PARAMETER_VALUE )
716
+					(new ViolationMessage('wbqc-violation-message-invalid-scope'))
717
+						->withConstraintScope($invalidScope, Role::CONSTRAINT_PARAMETER_VALUE)
718
+						->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
719
+						->withConstraintScopeList($validScopes, Role::CONSTRAINT_PARAMETER_VALUE)
720 720
 				);
721 721
 			}
722 722
 		}
@@ -730,8 +730,8 @@  discard block
 block discarded – undo
730 730
 	 * @param ItemId $unitId
731 731
 	 * @return string unit
732 732
 	 */
733
-	private function parseUnitParameter( ItemId $unitId ) {
734
-		return $this->unitItemConceptBaseUri . $unitId->getSerialization();
733
+	private function parseUnitParameter(ItemId $unitId) {
734
+		return $this->unitItemConceptBaseUri.$unitId->getSerialization();
735 735
 	}
736 736
 
737 737
 	/**
@@ -741,23 +741,23 @@  discard block
 block discarded – undo
741 741
 	 * @return UnitsParameter
742 742
 	 * @throws ConstraintParameterException
743 743
 	 */
744
-	private function parseUnitItem( ItemIdSnakValue $item ) {
745
-		switch ( true ) {
744
+	private function parseUnitItem(ItemIdSnakValue $item) {
745
+		switch (true) {
746 746
 			case $item->isValue():
747
-				$unit = $this->parseUnitParameter( $item->getItemId() );
747
+				$unit = $this->parseUnitParameter($item->getItemId());
748 748
 				return new UnitsParameter(
749
-					[ $item->getItemId() ],
750
-					[ UnboundedQuantityValue::newFromNumber( 1, $unit ) ],
749
+					[$item->getItemId()],
750
+					[UnboundedQuantityValue::newFromNumber(1, $unit)],
751 751
 					false
752 752
 				);
753 753
 			case $item->isSomeValue():
754
-				$qualifierId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
754
+				$qualifierId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
755 755
 				throw new ConstraintParameterException(
756
-					( new ViolationMessage( 'wbqc-violation-message-parameter-value-or-novalue' ) )
757
-						->withEntityId( new PropertyId( $qualifierId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
756
+					(new ViolationMessage('wbqc-violation-message-parameter-value-or-novalue'))
757
+						->withEntityId(new PropertyId($qualifierId), Role::CONSTRAINT_PARAMETER_PROPERTY)
758 758
 				);
759 759
 			case $item->isNoValue():
760
-				return new UnitsParameter( [], [], true );
760
+				return new UnitsParameter([], [], true);
761 761
 		}
762 762
 	}
763 763
 
@@ -767,26 +767,26 @@  discard block
 block discarded – undo
767 767
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
768 768
 	 * @return UnitsParameter
769 769
 	 */
770
-	public function parseUnitsParameter( array $constraintParameters, $constraintTypeItemId ) {
771
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
770
+	public function parseUnitsParameter(array $constraintParameters, $constraintTypeItemId) {
771
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
772 772
 		$unitItems = [];
773 773
 		$unitQuantities = [];
774 774
 		$unitlessAllowed = false;
775 775
 
776
-		foreach ( $items as $item ) {
777
-			$unit = $this->parseUnitItem( $item );
778
-			$unitItems = array_merge( $unitItems, $unit->getUnitItemIds() );
779
-			$unitQuantities = array_merge( $unitQuantities, $unit->getUnitQuantities() );
776
+		foreach ($items as $item) {
777
+			$unit = $this->parseUnitItem($item);
778
+			$unitItems = array_merge($unitItems, $unit->getUnitItemIds());
779
+			$unitQuantities = array_merge($unitQuantities, $unit->getUnitQuantities());
780 780
 			$unitlessAllowed = $unitlessAllowed || $unit->getUnitlessAllowed();
781 781
 		}
782 782
 
783
-		if ( $unitQuantities === [] && !$unitlessAllowed ) {
783
+		if ($unitQuantities === [] && !$unitlessAllowed) {
784 784
 			throw new LogicException(
785 785
 				'The "units" parameter is required, and yet we seem to be missing any allowed unit'
786 786
 			);
787 787
 		}
788 788
 
789
-		return new UnitsParameter( $unitItems, $unitQuantities, $unitlessAllowed );
789
+		return new UnitsParameter($unitItems, $unitQuantities, $unitlessAllowed);
790 790
 	}
791 791
 
792 792
 	/**
@@ -796,53 +796,53 @@  discard block
 block discarded – undo
796 796
 	 * @return EntityTypesParameter
797 797
 	 * @throws ConstraintParameterException
798 798
 	 */
799
-	private function parseEntityTypeItem( ItemIdSnakValue $item ) {
800
-		$parameterId = $this->config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' );
799
+	private function parseEntityTypeItem(ItemIdSnakValue $item) {
800
+		$parameterId = $this->config->get('WBQualityConstraintsQualifierOfPropertyConstraintId');
801 801
 
802
-		if ( !$item->isValue() ) {
802
+		if (!$item->isValue()) {
803 803
 			throw new ConstraintParameterException(
804
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
805
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
804
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
805
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
806 806
 			);
807 807
 		}
808 808
 
809 809
 		$itemId = $item->getItemId();
810
-		switch ( $itemId->getSerialization() ) {
811
-			case $this->config->get( 'WBQualityConstraintsWikibaseItemId' ):
810
+		switch ($itemId->getSerialization()) {
811
+			case $this->config->get('WBQualityConstraintsWikibaseItemId'):
812 812
 				$entityType = 'item';
813 813
 				break;
814
-			case $this->config->get( 'WBQualityConstraintsWikibasePropertyId' ):
814
+			case $this->config->get('WBQualityConstraintsWikibasePropertyId'):
815 815
 				$entityType = 'property';
816 816
 				break;
817
-			case $this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ):
817
+			case $this->config->get('WBQualityConstraintsWikibaseLexemeId'):
818 818
 				$entityType = 'lexeme';
819 819
 				break;
820
-			case $this->config->get( 'WBQualityConstraintsWikibaseFormId' ):
820
+			case $this->config->get('WBQualityConstraintsWikibaseFormId'):
821 821
 				$entityType = 'form';
822 822
 				break;
823
-			case $this->config->get( 'WBQualityConstraintsWikibaseSenseId' ):
823
+			case $this->config->get('WBQualityConstraintsWikibaseSenseId'):
824 824
 				$entityType = 'sense';
825 825
 				break;
826
-			case $this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ):
826
+			case $this->config->get('WBQualityConstraintsWikibaseMediaInfoId'):
827 827
 				$entityType = 'mediainfo';
828 828
 				break;
829 829
 			default:
830 830
 				$allowed = [
831
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseItemId' ) ),
832
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibasePropertyId' ) ),
833
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseLexemeId' ) ),
834
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseFormId' ) ),
835
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseSenseId' ) ),
836
-					new ItemId( $this->config->get( 'WBQualityConstraintsWikibaseMediaInfoId' ) ),
831
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseItemId')),
832
+					new ItemId($this->config->get('WBQualityConstraintsWikibasePropertyId')),
833
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseLexemeId')),
834
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseFormId')),
835
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseSenseId')),
836
+					new ItemId($this->config->get('WBQualityConstraintsWikibaseMediaInfoId')),
837 837
 				];
838 838
 				throw new ConstraintParameterException(
839
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
840
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
841
-						->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
839
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
840
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
841
+						->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
842 842
 				);
843 843
 		}
844 844
 
845
-		return new EntityTypesParameter( [ $entityType ], [ $itemId ] );
845
+		return new EntityTypesParameter([$entityType], [$itemId]);
846 846
 	}
847 847
 
848 848
 	/**
@@ -851,27 +851,27 @@  discard block
 block discarded – undo
851 851
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
852 852
 	 * @return EntityTypesParameter
853 853
 	 */
854
-	public function parseEntityTypesParameter( array $constraintParameters, $constraintTypeItemId ) {
854
+	public function parseEntityTypesParameter(array $constraintParameters, $constraintTypeItemId) {
855 855
 		$entityTypes = [];
856 856
 		$entityTypeItemIds = [];
857
-		$items = $this->parseItemsParameter( $constraintParameters, $constraintTypeItemId, true );
857
+		$items = $this->parseItemsParameter($constraintParameters, $constraintTypeItemId, true);
858 858
 
859
-		foreach ( $items as $item ) {
860
-			$entityType = $this->parseEntityTypeItem( $item );
861
-			$entityTypes = array_merge( $entityTypes, $entityType->getEntityTypes() );
862
-			$entityTypeItemIds = array_merge( $entityTypeItemIds, $entityType->getEntityTypeItemIds() );
859
+		foreach ($items as $item) {
860
+			$entityType = $this->parseEntityTypeItem($item);
861
+			$entityTypes = array_merge($entityTypes, $entityType->getEntityTypes());
862
+			$entityTypeItemIds = array_merge($entityTypeItemIds, $entityType->getEntityTypeItemIds());
863 863
 		}
864 864
 
865
-		if ( empty( $entityTypes ) ) {
865
+		if (empty($entityTypes)) {
866 866
 			// @codeCoverageIgnoreStart
867 867
 			throw new LogicException(
868
-				'The "entity types" parameter is required, ' .
868
+				'The "entity types" parameter is required, '.
869 869
 				'and yet we seem to be missing any allowed entity type'
870 870
 			);
871 871
 			// @codeCoverageIgnoreEnd
872 872
 		}
873 873
 
874
-		return new EntityTypesParameter( $entityTypes, $entityTypeItemIds );
874
+		return new EntityTypesParameter($entityTypes, $entityTypeItemIds);
875 875
 	}
876 876
 
877 877
 	/**
@@ -879,18 +879,18 @@  discard block
 block discarded – undo
879 879
 	 * @throws ConstraintParameterException if the parameter is invalid
880 880
 	 * @return PropertyId[]
881 881
 	 */
882
-	public function parseSeparatorsParameter( array $constraintParameters ) {
883
-		$separatorId = $this->config->get( 'WBQualityConstraintsSeparatorId' );
882
+	public function parseSeparatorsParameter(array $constraintParameters) {
883
+		$separatorId = $this->config->get('WBQualityConstraintsSeparatorId');
884 884
 
885
-		if ( !array_key_exists( $separatorId, $constraintParameters ) ) {
885
+		if (!array_key_exists($separatorId, $constraintParameters)) {
886 886
 			return [];
887 887
 		}
888 888
 
889 889
 		$parameters = $constraintParameters[$separatorId];
890 890
 		$separators = [];
891 891
 
892
-		foreach ( $parameters as $parameter ) {
893
-			$separators[] = $this->parsePropertyIdParameter( $parameter, $separatorId );
892
+		foreach ($parameters as $parameter) {
893
+			$separators[] = $this->parsePropertyIdParameter($parameter, $separatorId);
894 894
 		}
895 895
 
896 896
 		return $separators;
@@ -905,26 +905,26 @@  discard block
 block discarded – undo
905 905
 	 * @return string one of the Context::TYPE_* constants
906 906
 	 * @throws ConstraintParameterException
907 907
 	 */
908
-	private function parseContextTypeItem( ItemIdSnakValue $item, $use, $parameterId ) {
909
-		if ( !$item->isValue() ) {
908
+	private function parseContextTypeItem(ItemIdSnakValue $item, $use, $parameterId) {
909
+		if (!$item->isValue()) {
910 910
 			throw new ConstraintParameterException(
911
-				( new ViolationMessage( 'wbqc-violation-message-parameter-value' ) )
912
-					->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
911
+				(new ViolationMessage('wbqc-violation-message-parameter-value'))
912
+					->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
913 913
 			);
914 914
 		}
915 915
 
916
-		if ( $use === 'constraint scope' ) {
917
-			$mainSnakId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnMainValueId' );
918
-			$qualifiersId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnQualifiersId' );
919
-			$referencesId = $this->config->get( 'WBQualityConstraintsConstraintCheckedOnReferencesId' );
916
+		if ($use === 'constraint scope') {
917
+			$mainSnakId = $this->config->get('WBQualityConstraintsConstraintCheckedOnMainValueId');
918
+			$qualifiersId = $this->config->get('WBQualityConstraintsConstraintCheckedOnQualifiersId');
919
+			$referencesId = $this->config->get('WBQualityConstraintsConstraintCheckedOnReferencesId');
920 920
 		} else {
921
-			$mainSnakId = $this->config->get( 'WBQualityConstraintsAsMainValueId' );
922
-			$qualifiersId = $this->config->get( 'WBQualityConstraintsAsQualifiersId' );
923
-			$referencesId = $this->config->get( 'WBQualityConstraintsAsReferencesId' );
921
+			$mainSnakId = $this->config->get('WBQualityConstraintsAsMainValueId');
922
+			$qualifiersId = $this->config->get('WBQualityConstraintsAsQualifiersId');
923
+			$referencesId = $this->config->get('WBQualityConstraintsAsReferencesId');
924 924
 		}
925 925
 
926 926
 		$itemId = $item->getItemId();
927
-		switch ( $itemId->getSerialization() ) {
927
+		switch ($itemId->getSerialization()) {
928 928
 			case $mainSnakId:
929 929
 				return Context::TYPE_STATEMENT;
930 930
 			case $qualifiersId:
@@ -932,11 +932,11 @@  discard block
 block discarded – undo
932 932
 			case $referencesId:
933 933
 				return Context::TYPE_REFERENCE;
934 934
 			default:
935
-				$allowed = [ $mainSnakId, $qualifiersId, $referencesId ];
935
+				$allowed = [$mainSnakId, $qualifiersId, $referencesId];
936 936
 				throw new ConstraintParameterException(
937
-					( new ViolationMessage( 'wbqc-violation-message-parameter-oneof' ) )
938
-						->withEntityId( new PropertyId( $parameterId ), Role::CONSTRAINT_PARAMETER_PROPERTY )
939
-						->withEntityIdList( $allowed, Role::CONSTRAINT_PARAMETER_VALUE )
937
+					(new ViolationMessage('wbqc-violation-message-parameter-oneof'))
938
+						->withEntityId(new PropertyId($parameterId), Role::CONSTRAINT_PARAMETER_PROPERTY)
939
+						->withEntityIdList($allowed, Role::CONSTRAINT_PARAMETER_VALUE)
940 940
 				);
941 941
 		}
942 942
 	}
@@ -947,9 +947,9 @@  discard block
 block discarded – undo
947 947
 	 * @throws ConstraintParameterException if the parameter is invalid or missing
948 948
 	 * @return string[] list of Context::TYPE_* constants
949 949
 	 */
950
-	public function parsePropertyScopeParameter( array $constraintParameters, $constraintTypeItemId ) {
950
+	public function parsePropertyScopeParameter(array $constraintParameters, $constraintTypeItemId) {
951 951
 		$contextTypes = [];
952
-		$parameterId = $this->config->get( 'WBQualityConstraintsPropertyScopeId' );
952
+		$parameterId = $this->config->get('WBQualityConstraintsPropertyScopeId');
953 953
 		$items = $this->parseItemsParameter(
954 954
 			$constraintParameters,
955 955
 			$constraintTypeItemId,
@@ -957,14 +957,14 @@  discard block
 block discarded – undo
957 957
 			$parameterId
958 958
 		);
959 959
 
960
-		foreach ( $items as $item ) {
961
-			$contextTypes[] = $this->parseContextTypeItem( $item, 'property scope', $parameterId );
960
+		foreach ($items as $item) {
961
+			$contextTypes[] = $this->parseContextTypeItem($item, 'property scope', $parameterId);
962 962
 		}
963 963
 
964
-		if ( empty( $contextTypes ) ) {
964
+		if (empty($contextTypes)) {
965 965
 			// @codeCoverageIgnoreStart
966 966
 			throw new LogicException(
967
-				'The "property scope" parameter is required, ' .
967
+				'The "property scope" parameter is required, '.
968 968
 				'and yet we seem to be missing any allowed scope'
969 969
 			);
970 970
 			// @codeCoverageIgnoreEnd
Please login to merge, or discard this patch.
src/WikibaseQualityConstraintsHooks.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -28,25 +28,25 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @param DatabaseUpdater $updater
30 30
 	 */
31
-	public static function onCreateSchema( DatabaseUpdater $updater ) {
31
+	public static function onCreateSchema(DatabaseUpdater $updater) {
32 32
 		$updater->addExtensionTable(
33 33
 			'wbqc_constraints',
34
-			__DIR__ . '/../sql/create_wbqc_constraints.sql'
34
+			__DIR__.'/../sql/create_wbqc_constraints.sql'
35 35
 		);
36 36
 		$updater->addExtensionField(
37 37
 			'wbqc_constraints',
38 38
 			'constraint_id',
39
-			__DIR__ . '/../sql/patch-wbqc_constraints-constraint_id.sql'
39
+			__DIR__.'/../sql/patch-wbqc_constraints-constraint_id.sql'
40 40
 		);
41 41
 		$updater->addExtensionIndex(
42 42
 			'wbqc_constraints',
43 43
 			'wbqc_constraints_guid_uniq',
44
-			__DIR__ . '/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql'
44
+			__DIR__.'/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql'
45 45
 		);
46 46
 	}
47 47
 
48
-	public static function onWikibaseChange( Change $change ) {
49
-		if ( !( $change instanceof EntityChange ) ) {
48
+	public static function onWikibaseChange(Change $change) {
49
+		if (!($change instanceof EntityChange)) {
50 50
 			return;
51 51
 		}
52 52
 
@@ -55,48 +55,48 @@  discard block
 block discarded – undo
55 55
 
56 56
 		// If jobs are enabled and the results would be stored in some way run a job.
57 57
 		if (
58
-			$config->get( 'WBQualityConstraintsEnableConstraintsCheckJobs' ) &&
59
-			$config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) &&
58
+			$config->get('WBQualityConstraintsEnableConstraintsCheckJobs') &&
59
+			$config->get('WBQualityConstraintsCacheCheckConstraintsResults') &&
60 60
 			self::isSelectedForJobRunBasedOnPercentage()
61 61
 		) {
62
-			$params = [ 'entityId' => $change->getEntityId()->getSerialization() ];
62
+			$params = ['entityId' => $change->getEntityId()->getSerialization()];
63 63
 			JobQueueGroup::singleton()->push(
64
-				new JobSpecification( CheckConstraintsJob::COMMAND, $params )
64
+				new JobSpecification(CheckConstraintsJob::COMMAND, $params)
65 65
 			);
66 66
 		}
67 67
 
68
-		if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) &&
69
-			self::isConstraintStatementsChange( $config, $change )
68
+		if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') &&
69
+			self::isConstraintStatementsChange($config, $change)
70 70
 		) {
71
-			$params = [ 'propertyId' => $change->getEntityId()->getSerialization() ];
71
+			$params = ['propertyId' => $change->getEntityId()->getSerialization()];
72 72
 			$metadata = $change->getMetadata();
73
-			if ( array_key_exists( 'rev_id', $metadata ) ) {
73
+			if (array_key_exists('rev_id', $metadata)) {
74 74
 				$params['revisionId'] = $metadata['rev_id'];
75 75
 			}
76 76
 			JobQueueGroup::singleton()->push(
77
-				new JobSpecification( 'constraintsTableUpdate', $params )
77
+				new JobSpecification('constraintsTableUpdate', $params)
78 78
 			);
79 79
 		}
80 80
 	}
81 81
 
82 82
 	private static function isSelectedForJobRunBasedOnPercentage() {
83 83
 		$config = MediaWikiServices::getInstance()->getMainConfig();
84
-		$percentage = $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobsRatio' );
84
+		$percentage = $config->get('WBQualityConstraintsEnableConstraintsCheckJobsRatio');
85 85
 
86
-		return mt_rand( 1, 100 ) <= $percentage;
86
+		return mt_rand(1, 100) <= $percentage;
87 87
 	}
88 88
 
89
-	public static function isConstraintStatementsChange( Config $config, Change $change ) {
90
-		if ( !( $change instanceof EntityChange ) ||
89
+	public static function isConstraintStatementsChange(Config $config, Change $change) {
90
+		if (!($change instanceof EntityChange) ||
91 91
 			 $change->getAction() !== EntityChange::UPDATE ||
92
-			 !( $change->getEntityId() instanceof PropertyId )
92
+			 !($change->getEntityId() instanceof PropertyId)
93 93
 		) {
94 94
 			return false;
95 95
 		}
96 96
 
97 97
 		$info = $change->getInfo();
98 98
 
99
-		if ( !array_key_exists( 'compactDiff', $info ) ) {
99
+		if (!array_key_exists('compactDiff', $info)) {
100 100
 			// the non-compact diff ($info['diff']) does not contain statement diffs (T110996),
101 101
 			// so we only know that the change *might* affect the constraint statements
102 102
 			return true;
@@ -105,46 +105,46 @@  discard block
 block discarded – undo
105 105
 		/** @var EntityDiffChangedAspects $aspects */
106 106
 		$aspects = $info['compactDiff'];
107 107
 
108
-		$propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' );
109
-		return in_array( $propertyConstraintId, $aspects->getStatementChanges() );
108
+		$propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId');
109
+		return in_array($propertyConstraintId, $aspects->getStatementChanges());
110 110
 	}
111 111
 
112
-	public static function onArticlePurge( WikiPage $wikiPage ) {
112
+	public static function onArticlePurge(WikiPage $wikiPage) {
113 113
 		$repo = WikibaseRepo::getDefaultInstance();
114 114
 
115 115
 		$entityContentFactory = $repo->getEntityContentFactory();
116
-		if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) {
117
-			$entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() );
118
-			if ( $entityId !== null ) {
116
+		if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) {
117
+			$entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle());
118
+			if ($entityId !== null) {
119 119
 				$resultsCache = ResultsCache::getDefaultInstance();
120
-				$resultsCache->delete( $entityId );
120
+				$resultsCache->delete($entityId);
121 121
 			}
122 122
 		}
123 123
 	}
124 124
 
125
-	public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
125
+	public static function onBeforePageDisplay(OutputPage $out, Skin $skin) {
126 126
 		$repo = WikibaseRepo::getDefaultInstance();
127 127
 
128 128
 		$lookup = $repo->getEntityNamespaceLookup();
129 129
 		$title = $out->getTitle();
130
-		if ( $title === null ) {
130
+		if ($title === null) {
131 131
 			return;
132 132
 		}
133 133
 
134
-		if ( !$lookup->isNamespaceWithEntities( $title->getNamespace() ) ) {
134
+		if (!$lookup->isNamespaceWithEntities($title->getNamespace())) {
135 135
 			return;
136 136
 		}
137
-		if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) {
137
+		if (empty($out->getJsConfigVars()['wbIsEditView'])) {
138 138
 			return;
139 139
 		}
140 140
 
141
-		$out->addModules( 'wikibase.quality.constraints.suggestions' );
141
+		$out->addModules('wikibase.quality.constraints.suggestions');
142 142
 
143
-		if ( !$out->getUser()->isLoggedIn() ) {
143
+		if (!$out->getUser()->isLoggedIn()) {
144 144
 			return;
145 145
 		}
146 146
 
147
-		$out->addModules( 'wikibase.quality.constraints.gadget' );
147
+		$out->addModules('wikibase.quality.constraints.gadget');
148 148
 	}
149 149
 
150 150
 }
Please login to merge, or discard this patch.
src/Api/CheckConstraintsRdf.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		EntityIdLookup $entityIdLookup,
48 48
 		RdfVocabulary $rdfVocabulary
49 49
 	) {
50
-		parent::__construct( $page, $context );
50
+		parent::__construct($page, $context);
51 51
 		$this->resultsSource = $resultsSource;
52 52
 		$this->entityIdLookup = $entityIdLookup;
53 53
 		$this->rdfVocabulary = $rdfVocabulary;
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	 * @param string $guid
109 109
 	 * @return string
110 110
 	 */
111
-	private function cleanupGuid( $guid ) {
112
-		return preg_replace( '/[^\w-]/', '-', $guid );
111
+	private function cleanupGuid($guid) {
112
+		return preg_replace('/[^\w-]/', '-', $guid);
113 113
 	}
114 114
 
115 115
 	/**
@@ -121,60 +121,60 @@  discard block
 block discarded – undo
121 121
 		$response = $this->getRequest()->response();
122 122
 		$this->getOutput()->disable();
123 123
 
124
-		if ( !$this->resultsSource instanceof CachingResultsSource ) {
124
+		if (!$this->resultsSource instanceof CachingResultsSource) {
125 125
 			// TODO: make configurable whether only cached results are returned
126
-			$response->statusHeader( 501 ); // Not Implemented
126
+			$response->statusHeader(501); // Not Implemented
127 127
 			return null;
128 128
 		}
129 129
 
130
-		$entityId = $this->entityIdLookup->getEntityIdForTitle( $this->getTitle() );
131
-		if ( $entityId === null ) {
132
-			$response->statusHeader( 404 ); // Not Found
130
+		$entityId = $this->entityIdLookup->getEntityIdForTitle($this->getTitle());
131
+		if ($entityId === null) {
132
+			$response->statusHeader(404); // Not Found
133 133
 			return null;
134 134
 		}
135
-		$revId = $this->getRequest()->getInt( 'revision' );
135
+		$revId = $this->getRequest()->getInt('revision');
136 136
 
137
-		$results = $this->resultsSource->getStoredResults( $entityId, $revId );
138
-		if ( $results === null ) {
139
-			$response->statusHeader( 204 ); // No Content
137
+		$results = $this->resultsSource->getStoredResults($entityId, $revId);
138
+		if ($results === null) {
139
+			$response->statusHeader(204); // No Content
140 140
 			return null;
141 141
 		}
142 142
 
143 143
 		$format = 'ttl'; // TODO: make format an option
144 144
 
145 145
 		$writerFactory = new RdfWriterFactory();
146
-		$formatName = $writerFactory->getFormatName( $format );
147
-		$contentType = $writerFactory->getMimeTypes( $formatName )[0];
146
+		$formatName = $writerFactory->getFormatName($format);
147
+		$contentType = $writerFactory->getMimeTypes($formatName)[0];
148 148
 
149
-		$writer = $writerFactory->getWriter( $formatName );
150
-		foreach ( [ RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY ] as $ns ) {
151
-			$writer->prefix( $ns, $this->rdfVocabulary->getNamespaceURI( $ns ) );
149
+		$writer = $writerFactory->getWriter($formatName);
150
+		foreach ([RdfVocabulary::NS_STATEMENT, RdfVocabulary::NS_ONTOLOGY] as $ns) {
151
+			$writer->prefix($ns, $this->rdfVocabulary->getNamespaceURI($ns));
152 152
 		}
153 153
 		$writer->start();
154 154
 		$writtenAny = false;
155 155
 
156
-		foreach ( $results->getArray() as $checkResult ) {
157
-			if ( $checkResult instanceof NullResult ) {
156
+		foreach ($results->getArray() as $checkResult) {
157
+			if ($checkResult instanceof NullResult) {
158 158
 				continue;
159 159
 			}
160
-			if ( $checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS ) {
160
+			if ($checkResult->getStatus() === CheckResult::STATUS_BAD_PARAMETERS) {
161 161
 				continue;
162 162
 			}
163 163
 			$writtenAny = true;
164
-			$writer->about( RdfVocabulary::NS_STATEMENT,
165
-				$this->cleanupGuid( $checkResult->getContextCursor()->getStatementGuid() ) )
166
-				->say( RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint' )
167
-				->is( RdfVocabulary::NS_STATEMENT,
168
-					$this->cleanupGuid( $checkResult->getConstraint()->getConstraintId() ) );
164
+			$writer->about(RdfVocabulary::NS_STATEMENT,
165
+				$this->cleanupGuid($checkResult->getContextCursor()->getStatementGuid()))
166
+				->say(RdfVocabulary::NS_ONTOLOGY, 'hasViolationForConstraint')
167
+				->is(RdfVocabulary::NS_STATEMENT,
168
+					$this->cleanupGuid($checkResult->getConstraint()->getConstraintId()));
169 169
 		}
170 170
 		$writer->finish();
171
-		if ( $writtenAny ) {
172
-			$response->header( "Content-Type: $contentType; charset=UTF-8" );
171
+		if ($writtenAny) {
172
+			$response->header("Content-Type: $contentType; charset=UTF-8");
173 173
 			echo $writer->drain();
174 174
 		} else {
175 175
 			// Do not output RDF if we haven't written any actual statements. Output 204 instead
176 176
 			$writer->drain();
177
-			$response->statusHeader( 204 ); // No Content
177
+			$response->statusHeader(204); // No Content
178 178
 		}
179 179
 		return null;
180 180
 	}
Please login to merge, or discard this patch.
maintenance/ImportConstraintEntities.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
 use Wikibase\Repo\WikibaseRepo;
17 17
 
18 18
 // @codeCoverageIgnoreStart
19
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
20
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
19
+$basePath = getenv("MW_INSTALL_PATH") !== false
20
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
21 21
 
22
-require_once $basePath . "/maintenance/Maintenance.php";
22
+require_once $basePath."/maintenance/Maintenance.php";
23 23
 // @codeCoverageIgnoreEnd
24 24
 
25 25
 /**
@@ -53,20 +53,20 @@  discard block
 block discarded – undo
53 53
 		parent::__construct();
54 54
 
55 55
 		$this->addDescription(
56
-			'Import entities needed for constraint checks ' .
56
+			'Import entities needed for constraint checks '.
57 57
 			'from Wikidata into the local repository.'
58 58
 		);
59 59
 		$this->addOption(
60 60
 			'config-format',
61
-			'The format in which the resulting configuration will be omitted: ' .
62
-			'"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), ' .
61
+			'The format in which the resulting configuration will be omitted: '.
62
+			'"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), '.
63 63
 			'or "wgConf" for printing parts of arrays suitable for inclusion in $wgConf->settings.'
64 64
 		);
65 65
 		$this->addOption(
66 66
 			'dry-run',
67 67
 			'Don’t actually import entities, just print which ones would be imported.'
68 68
 		);
69
-		$this->requireExtension( 'WikibaseQualityConstraints' );
69
+		$this->requireExtension('WikibaseQualityConstraints');
70 70
 	}
71 71
 
72 72
 	/**
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 		$this->entitySerializer = $repo->getAllTypesEntitySerializer();
78 78
 		$this->entityDeserializer = $repo->getInternalFormatEntityDeserializer();
79 79
 		$this->entityStore = $repo->getEntityStore();
80
-		if ( !$this->getOption( 'dry-run', false ) ) {
81
-			$this->user = User::newSystemUser( 'WikibaseQualityConstraints importer' );
80
+		if (!$this->getOption('dry-run', false)) {
81
+			$this->user = User::newSystemUser('WikibaseQualityConstraints importer');
82 82
 		}
83 83
 	}
84 84
 
@@ -87,21 +87,21 @@  discard block
 block discarded – undo
87 87
 
88 88
 		$configUpdates = [];
89 89
 
90
-		$extensionJsonFile = __DIR__ . '/../extension.json';
91
-		$extensionJsonText = file_get_contents( $extensionJsonFile );
92
-		$extensionJson = json_decode( $extensionJsonText, /* assoc = */ true );
90
+		$extensionJsonFile = __DIR__.'/../extension.json';
91
+		$extensionJsonText = file_get_contents($extensionJsonFile);
92
+		$extensionJson = json_decode($extensionJsonText, /* assoc = */ true);
93 93
 		// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
94
-		$wikidataEntityIds = $this->getEntitiesToImport( $extensionJson['config'], $this->getConfig() );
94
+		$wikidataEntityIds = $this->getEntitiesToImport($extensionJson['config'], $this->getConfig());
95 95
 
96
-		foreach ( $wikidataEntityIds as $key => $wikidataEntityId ) {
97
-			$localEntityId = $this->importEntityFromWikidata( $wikidataEntityId );
96
+		foreach ($wikidataEntityIds as $key => $wikidataEntityId) {
97
+			$localEntityId = $this->importEntityFromWikidata($wikidataEntityId);
98 98
 			$configUpdates[$key] = [
99 99
 				'wikidata' => $wikidataEntityId,
100 100
 				'local' => $localEntityId,
101 101
 			];
102 102
 		}
103 103
 
104
-		$this->outputConfigUpdates( $configUpdates );
104
+		$this->outputConfigUpdates($configUpdates);
105 105
 	}
106 106
 
107 107
 	/**
@@ -109,18 +109,18 @@  discard block
 block discarded – undo
109 109
 	 * @param Config $wikiConfig
110 110
 	 * @return string[]
111 111
 	 */
112
-	private function getEntitiesToImport( array $extensionJsonConfig, Config $wikiConfig ) {
112
+	private function getEntitiesToImport(array $extensionJsonConfig, Config $wikiConfig) {
113 113
 		$wikidataEntityIds = [];
114 114
 
115
-		foreach ( $extensionJsonConfig as $key => $value ) {
116
-			if ( !preg_match( '/Id$/', $key ) ) {
115
+		foreach ($extensionJsonConfig as $key => $value) {
116
+			if (!preg_match('/Id$/', $key)) {
117 117
 				continue;
118 118
 			}
119 119
 
120 120
 			$wikidataEntityId = $value['value'];
121
-			$localEntityId = $wikiConfig->get( $key );
121
+			$localEntityId = $wikiConfig->get($key);
122 122
 
123
-			if ( $localEntityId === $wikidataEntityId ) {
123
+			if ($localEntityId === $wikidataEntityId) {
124 124
 				$wikidataEntityIds[$key] = $wikidataEntityId;
125 125
 			}
126 126
 		}
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 	 * @param string $wikidataEntityId
133 133
 	 * @return string local entity ID
134 134
 	 */
135
-	private function importEntityFromWikidata( $wikidataEntityId ) {
135
+	private function importEntityFromWikidata($wikidataEntityId) {
136 136
 		$wikidataEntityUrl = "https://www.wikidata.org/wiki/Special:EntityData/$wikidataEntityId.json";
137
-		$wikidataEntitiesJson = MediaWikiServices::getInstance()->getHttpRequestFactory()->get( $wikidataEntityUrl );
138
-		return $this->importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson );
137
+		$wikidataEntitiesJson = MediaWikiServices::getInstance()->getHttpRequestFactory()->get($wikidataEntityUrl);
138
+		return $this->importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson);
139 139
 	}
140 140
 
141 141
 	/**
@@ -143,24 +143,24 @@  discard block
 block discarded – undo
143 143
 	 * @param string $wikidataEntitiesJson
144 144
 	 * @return string local entity ID
145 145
 	 */
146
-	private function importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ) {
146
+	private function importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson) {
147 147
 		// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
148
-		$wikidataEntityArray = json_decode( $wikidataEntitiesJson, true )['entities'][$wikidataEntityId];
149
-		$wikidataEntity = $this->entityDeserializer->deserialize( $wikidataEntityArray );
148
+		$wikidataEntityArray = json_decode($wikidataEntitiesJson, true)['entities'][$wikidataEntityId];
149
+		$wikidataEntity = $this->entityDeserializer->deserialize($wikidataEntityArray);
150 150
 
151
-		$wikidataEntity->setId( null );
151
+		$wikidataEntity->setId(null);
152 152
 
153
-		if ( $wikidataEntity instanceof StatementListProvider ) {
153
+		if ($wikidataEntity instanceof StatementListProvider) {
154 154
 			$wikidataEntity->getStatements()->clear();
155 155
 		}
156 156
 
157
-		if ( $wikidataEntity instanceof Item ) {
158
-			$wikidataEntity->setSiteLinkList( new SiteLinkList() );
157
+		if ($wikidataEntity instanceof Item) {
158
+			$wikidataEntity->setSiteLinkList(new SiteLinkList());
159 159
 		}
160 160
 
161
-		if ( $this->getOption( 'dry-run', false ) ) {
162
-			$wikidataEntityJson = json_encode( $this->entitySerializer->serialize( $wikidataEntity ) );
163
-			$this->output( $wikidataEntityJson . "\n" );
161
+		if ($this->getOption('dry-run', false)) {
162
+			$wikidataEntityJson = json_encode($this->entitySerializer->serialize($wikidataEntity));
163
+			$this->output($wikidataEntityJson."\n");
164 164
 			return "-$wikidataEntityId";
165 165
 		}
166 166
 
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 			)->getEntity();
174 174
 
175 175
 			return $localEntity->getId()->getSerialization();
176
-		} catch ( StorageException $storageException ) {
177
-			return $this->storageExceptionToEntityId( $storageException );
176
+		} catch (StorageException $storageException) {
177
+			return $this->storageExceptionToEntityId($storageException);
178 178
 		}
179 179
 	}
180 180
 
181
-	private function storageExceptionToEntityId( StorageException $storageException ) {
181
+	private function storageExceptionToEntityId(StorageException $storageException) {
182 182
 		$message = $storageException->getMessage();
183 183
 		// example messages:
184 184
 		// * Item [[Item:Q475|Q475]] already has label "as references"
@@ -188,25 +188,25 @@  discard block
 block discarded – undo
188 188
 		// * Property [[Property:P694|P694]] already has label "instance of"
189 189
 		//   associated with language code en.
190 190
 		$pattern = '/[[|]([^][|]*)]] already has label .* associated with language code/';
191
-		if ( preg_match( $pattern, $message, $matches ) ) {
191
+		if (preg_match($pattern, $message, $matches)) {
192 192
 			return $matches[1];
193 193
 		} else {
194 194
 			throw $storageException;
195 195
 		}
196 196
 	}
197 197
 
198
-	private function outputConfigUpdates( array $configUpdates ) {
199
-		$configFormat = $this->getOption( 'config-format', 'globals' );
200
-		switch ( $configFormat ) {
198
+	private function outputConfigUpdates(array $configUpdates) {
199
+		$configFormat = $this->getOption('config-format', 'globals');
200
+		switch ($configFormat) {
201 201
 			case 'globals':
202
-				$this->outputConfigUpdatesGlobals( $configUpdates );
202
+				$this->outputConfigUpdatesGlobals($configUpdates);
203 203
 				break;
204 204
 			case 'wgConf':
205
-				$this->outputConfigUpdatesWgConf( $configUpdates );
205
+				$this->outputConfigUpdatesWgConf($configUpdates);
206 206
 				break;
207 207
 			default:
208
-				$this->error( "Invalid config format \"$configFormat\", using \"globals\"" );
209
-				$this->outputConfigUpdatesGlobals( $configUpdates );
208
+				$this->error("Invalid config format \"$configFormat\", using \"globals\"");
209
+				$this->outputConfigUpdatesGlobals($configUpdates);
210 210
 				break;
211 211
 		}
212 212
 	}
@@ -214,22 +214,22 @@  discard block
 block discarded – undo
214 214
 	/**
215 215
 	 * @param array[] $configUpdates
216 216
 	 */
217
-	private function outputConfigUpdatesGlobals( array $configUpdates ) {
218
-		foreach ( $configUpdates as $key => $value ) {
219
-			$localValueCode = var_export( $value['local'], true );
220
-			$this->output( "\$wg$key = $localValueCode;\n" );
217
+	private function outputConfigUpdatesGlobals(array $configUpdates) {
218
+		foreach ($configUpdates as $key => $value) {
219
+			$localValueCode = var_export($value['local'], true);
220
+			$this->output("\$wg$key = $localValueCode;\n");
221 221
 		}
222 222
 	}
223 223
 
224 224
 	/**
225 225
 	 * @param array[] $configUpdates
226 226
 	 */
227
-	private function outputConfigUpdatesWgConf( array $configUpdates ) {
228
-		foreach ( $configUpdates as $key => $value ) {
229
-			$keyCode = var_export( "wg$key", true );
230
-			$wikidataValueCode = var_export( $value['wikidata'], true );
231
-			$localValueCode = var_export( $value['local'], true );
232
-			$wikiIdCode = var_export( wfWikiID(), true );
227
+	private function outputConfigUpdatesWgConf(array $configUpdates) {
228
+		foreach ($configUpdates as $key => $value) {
229
+			$keyCode = var_export("wg$key", true);
230
+			$wikidataValueCode = var_export($value['wikidata'], true);
231
+			$localValueCode = var_export($value['local'], true);
232
+			$wikiIdCode = var_export(wfWikiID(), true);
233 233
 			$block = <<< EOF
234 234
 $keyCode => [
235 235
 	'default' => $wikidataValueCode,
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
 
240 240
 EOF;
241
-			$this->output( $block );
241
+			$this->output($block);
242 242
 		}
243 243
 	}
244 244
 
Please login to merge, or discard this patch.
src/Api/CheckResultsRenderer.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 	 * @param CachedCheckResults $checkResults
52 52
 	 * @return CachedCheckConstraintsResponse
53 53
 	 */
54
-	public function render( CachedCheckResults $checkResults ) {
54
+	public function render(CachedCheckResults $checkResults) {
55 55
 		$response = [];
56
-		foreach ( $checkResults->getArray() as $checkResult ) {
57
-			$resultArray = $this->checkResultToArray( $checkResult );
58
-			$checkResult->getContextCursor()->storeCheckResultInArray( $resultArray, $response );
56
+		foreach ($checkResults->getArray() as $checkResult) {
57
+			$resultArray = $this->checkResultToArray($checkResult);
58
+			$checkResult->getContextCursor()->storeCheckResultInArray($resultArray, $response);
59 59
 		}
60 60
 		return new CachedCheckConstraintsResponse(
61 61
 			$response,
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 		);
64 64
 	}
65 65
 
66
-	public function checkResultToArray( CheckResult $checkResult ) {
67
-		if ( $checkResult instanceof NullResult ) {
66
+	public function checkResultToArray(CheckResult $checkResult) {
67
+		if ($checkResult instanceof NullResult) {
68 68
 			return null;
69 69
 		}
70 70
 
71 71
 		$constraintId = $checkResult->getConstraint()->getConstraintId();
72 72
 		$typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId();
73
-		$constraintPropertyId = new PropertyId( $checkResult->getContextCursor()->getSnakPropertyId() );
73
+		$constraintPropertyId = new PropertyId($checkResult->getContextCursor()->getSnakPropertyId());
74 74
 
75
-		$title = $this->entityTitleLookup->getTitleForId( $constraintPropertyId );
75
+		$title = $this->entityTitleLookup->getTitleForId($constraintPropertyId);
76 76
 		$talkTitle = $title->getTalkPageIfDefined();
77
-		$typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) );
78
-		$link = $title->getFullURL() . '#' . $constraintId;
77
+		$typeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($typeItemId));
78
+		$link = $title->getFullURL().'#'.$constraintId;
79 79
 
80 80
 		$constraint = [
81 81
 			'id' => $constraintId,
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 			'constraint' => $constraint
92 92
 		];
93 93
 		$message = $checkResult->getMessage();
94
-		if ( $message ) {
95
-			$result['message-html'] = $this->violationMessageRenderer->render( $message );
94
+		if ($message) {
95
+			$result['message-html'] = $this->violationMessageRenderer->render($message);
96 96
 		}
97
-		if ( $checkResult->getContextCursor()->getType() === Context::TYPE_STATEMENT ) {
97
+		if ($checkResult->getContextCursor()->getType() === Context::TYPE_STATEMENT) {
98 98
 			$result['claim'] = $checkResult->getContextCursor()->getStatementGuid();
99 99
 		}
100 100
 		$cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray();
101
-		if ( $cachingMetadataArray !== null ) {
101
+		if ($cachingMetadataArray !== null) {
102 102
 			$result['cached'] = $cachingMetadataArray;
103 103
 		}
104 104
 
Please login to merge, or discard this patch.