Completed
Push — master ( df1271...516dab )
by
unknown
05:58 queued 03:33
created
src/Api/CheckConstraints.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @return self
81 81
 	 */
82
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
82
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
83 83
 		$repo = WikibaseRepo::getDefaultInstance();
84 84
 
85 85
 		$language = $repo->getUserLanguage();
86 86
 		$formatterOptions = new FormatterOptions();
87
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
87
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
88 88
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
89
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
89
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
90 90
 
91 91
 		$languageFallbackLabelDescriptionLookupFactory = $repo->getLanguageFallbackLabelDescriptionLookupFactory();
92
-		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup( $language );
92
+		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup($language);
93 93
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
94
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
94
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
95 95
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
96
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
96
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
97 97
 		$config = MediaWikiServices::getInstance()->getMainConfig();
98 98
 		$titleParser = MediaWikiServices::getInstance()->getTitleParser();
99 99
 		$unitConverter = $repo->getUnitConverter();
@@ -131,10 +131,10 @@  discard block
 block discarded – undo
131 131
 			$repo->getEntityTitleLookup(),
132 132
 			$entityIdLabelFormatter,
133 133
 			$constraintParameterRenderer,
134
-			new MultilingualTextViolationMessageRenderer( $entityIdHtmlLinkFormatter, $valueFormatter, $config ),
134
+			new MultilingualTextViolationMessageRenderer($entityIdHtmlLinkFormatter, $valueFormatter, $config),
135 135
 			$config
136 136
 		);
137
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
137
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
138 138
 			$wikiPageEntityMetaDataAccessor = new WikiPageEntityMetaDataLookup(
139 139
 				$repo->getEntityNamespaceLookup()
140 140
 			);
@@ -145,12 +145,12 @@  discard block
 block discarded – undo
145 145
 				ResultsCache::getDefaultInstance(),
146 146
 				$wikiPageEntityMetaDataAccessor,
147 147
 				$entityIdParser,
148
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
148
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
149 149
 				[
150
-					$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
151
-					$config->get( 'WBQualityConstraintsTypeConstraintId' ),
152
-					$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
153
-					$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
150
+					$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
151
+					$config->get('WBQualityConstraintsTypeConstraintId'),
152
+					$config->get('WBQualityConstraintsValueTypeConstraintId'),
153
+					$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
154 154
 				],
155 155
 				$dataFactory
156 156
 			);
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 			$prefix,
163 163
 			$repo->getEntityIdParser(),
164 164
 			$repo->getStatementGuidValidator(),
165
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
165
+			$repo->getApiHelperFactory(RequestContext::getMain()),
166 166
 			$resultsBuilder,
167 167
 			$dataFactory
168 168
 		);
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 		ResultsBuilder $resultsBuilder,
189 189
 		IBufferingStatsdDataFactory $dataFactory
190 190
 	) {
191
-		parent::__construct( $main, $name, $prefix );
191
+		parent::__construct($main, $name, $prefix);
192 192
 		$this->entityIdParser = $entityIdParser;
193 193
 		$this->statementGuidValidator = $statementGuidValidator;
194
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
195
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
194
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
195
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
196 196
 		$this->resultsBuilder = $resultsBuilder;
197 197
 		$this->dataFactory = $dataFactory;
198 198
 	}
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
 
208 208
 		$params = $this->extractRequestParams();
209 209
 
210
-		$this->validateParameters( $params );
211
-		$entityIds = $this->parseEntityIds( $params );
212
-		$claimIds = $this->parseClaimIds( $params );
210
+		$this->validateParameters($params);
211
+		$entityIds = $this->parseEntityIds($params);
212
+		$claimIds = $this->parseClaimIds($params);
213 213
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
214 214
 		$statuses = $params[self::PARAM_STATUS];
215 215
 
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
 			)->getArray()
225 225
 		);
226 226
 		// ensure that result contains the given entity IDs even if they have no statements
227
-		foreach ( $entityIds as $entityId ) {
227
+		foreach ($entityIds as $entityId) {
228 228
 			$this->getResult()->addArrayType(
229
-				[ $this->getModuleName(), $entityId->getSerialization() ],
229
+				[$this->getModuleName(), $entityId->getSerialization()],
230 230
 				'assoc'
231 231
 			);
232 232
 		}
233
-		$this->resultBuilder->markSuccess( 1 );
233
+		$this->resultBuilder->markSuccess(1);
234 234
 	}
235 235
 
236 236
 	/**
@@ -238,24 +238,24 @@  discard block
 block discarded – undo
238 238
 	 *
239 239
 	 * @return EntityId[]
240 240
 	 */
241
-	private function parseEntityIds( array $params ) {
241
+	private function parseEntityIds(array $params) {
242 242
 		$ids = $params[self::PARAM_ID];
243 243
 
244
-		if ( $ids === null ) {
244
+		if ($ids === null) {
245 245
 			return [];
246
-		} elseif ( $ids === [] ) {
246
+		} elseif ($ids === []) {
247 247
 			$this->errorReporter->dieError(
248
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
248
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
249 249
 		}
250 250
 
251
-		return array_map( function ( $id ) {
251
+		return array_map(function($id) {
252 252
 			try {
253
-				return $this->entityIdParser->parse( $id );
254
-			} catch ( EntityIdParsingException $e ) {
253
+				return $this->entityIdParser->parse($id);
254
+			} catch (EntityIdParsingException $e) {
255 255
 				$this->errorReporter->dieError(
256
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
256
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
257 257
 			}
258
-		}, $ids );
258
+		}, $ids);
259 259
 	}
260 260
 
261 261
 	/**
@@ -263,35 +263,35 @@  discard block
 block discarded – undo
263 263
 	 *
264 264
 	 * @return string[]
265 265
 	 */
266
-	private function parseClaimIds( array $params ) {
266
+	private function parseClaimIds(array $params) {
267 267
 		$ids = $params[self::PARAM_CLAIM_ID];
268 268
 
269
-		if ( $ids === null ) {
269
+		if ($ids === null) {
270 270
 			return [];
271
-		} elseif ( $ids === [] ) {
271
+		} elseif ($ids === []) {
272 272
 			$this->errorReporter->dieError(
273
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
273
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
274 274
 		}
275 275
 
276
-		foreach ( $ids as $id ) {
277
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
276
+		foreach ($ids as $id) {
277
+			if (!$this->statementGuidValidator->validate($id)) {
278 278
 				$this->errorReporter->dieError(
279
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
279
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
280 280
 			}
281 281
 		}
282 282
 
283 283
 		return $ids;
284 284
 	}
285 285
 
286
-	private function validateParameters( array $params ) {
287
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
288
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
286
+	private function validateParameters(array $params) {
287
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
288
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
289 289
 		) {
290 290
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
291 291
 			$this->errorReporter->dieError(
292 292
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
293 293
 		}
294
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
294
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
295 295
 			$paramId = self::PARAM_ID;
296 296
 			$paramClaimId = self::PARAM_CLAIM_ID;
297 297
 			$this->errorReporter->dieError(
@@ -332,11 +332,11 @@  discard block
 block discarded – undo
332 332
 				],
333 333
 				ApiBase::PARAM_ISMULTI => true,
334 334
 				ApiBase::PARAM_ALL => true,
335
-				ApiBase::PARAM_DFLT => implode( '|', [
335
+				ApiBase::PARAM_DFLT => implode('|', [
336 336
 					CheckResult::STATUS_VIOLATION,
337 337
 					CheckResult::STATUS_WARNING,
338 338
 					CheckResult::STATUS_BAD_PARAMETERS,
339
-				] ),
339
+				]),
340 340
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
341 341
 			],
342 342
 		];
Please login to merge, or discard this patch.