@@ -90,26 +90,26 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return self |
92 | 92 | */ |
93 | - public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) { |
|
93 | + public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') { |
|
94 | 94 | $repo = WikibaseRepo::getDefaultInstance(); |
95 | 95 | |
96 | 96 | $language = $repo->getUserLanguage(); |
97 | 97 | $formatterOptions = new FormatterOptions(); |
98 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
98 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
99 | 99 | $valueFormatterFactory = $repo->getValueFormatterFactory(); |
100 | - $valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
100 | + $valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
101 | 101 | |
102 | 102 | $languageFallbackLabelDescriptionLookupFactory = $repo->getLanguageFallbackLabelDescriptionLookupFactory(); |
103 | - $labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup( $language ); |
|
103 | + $labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup($language); |
|
104 | 104 | $entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory(); |
105 | - $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup ); |
|
105 | + $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelDescriptionLookup); |
|
106 | 106 | $entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory(); |
107 | - $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup ); |
|
107 | + $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelDescriptionLookup); |
|
108 | 108 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
109 | 109 | $dataFactory = MediaWikiServices::getInstance()->getStatsdDataFactory(); |
110 | 110 | $loggingHelper = new LoggingHelper( |
111 | 111 | $dataFactory, |
112 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
112 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
113 | 113 | $config |
114 | 114 | ); |
115 | 115 | $constraintReportFactory = ConstraintReportFactory::getDefaultInstance(); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $resultsSource = new CheckingResultsSource( |
129 | 129 | $constraintReportFactory->getConstraintChecker() |
130 | 130 | ); |
131 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
131 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
132 | 132 | $wikiPageEntityMetaDataAccessor = new WikiPageEntityMetaDataLookup( |
133 | 133 | $repo->getEntityNamespaceLookup() |
134 | 134 | ); |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | $checkResultDeserializer, |
158 | 158 | $wikiPageEntityMetaDataAccessor, |
159 | 159 | $entityIdParser, |
160 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
160 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
161 | 161 | [ |
162 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
163 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
164 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
165 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
162 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
163 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
164 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
165 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
166 | 166 | ], |
167 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
167 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
168 | 168 | $loggingHelper |
169 | 169 | ); |
170 | 170 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $prefix, |
176 | 176 | $repo->getEntityIdParser(), |
177 | 177 | $repo->getStatementGuidValidator(), |
178 | - $repo->getApiHelperFactory( RequestContext::getMain() ), |
|
178 | + $repo->getApiHelperFactory(RequestContext::getMain()), |
|
179 | 179 | $resultsSource, |
180 | 180 | $checkResultsRenderer, |
181 | 181 | $dataFactory |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | CheckResultsRenderer $checkResultsRenderer, |
205 | 205 | IBufferingStatsdDataFactory $dataFactory |
206 | 206 | ) { |
207 | - parent::__construct( $main, $name, $prefix ); |
|
207 | + parent::__construct($main, $name, $prefix); |
|
208 | 208 | $this->entityIdParser = $entityIdParser; |
209 | 209 | $this->statementGuidValidator = $statementGuidValidator; |
210 | - $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); |
|
211 | - $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
210 | + $this->resultBuilder = $apiHelperFactory->getResultBuilder($this); |
|
211 | + $this->errorReporter = $apiHelperFactory->getErrorReporter($this); |
|
212 | 212 | $this->resultsSource = $resultsSource; |
213 | 213 | $this->checkResultsRenderer = $checkResultsRenderer; |
214 | 214 | $this->dataFactory = $dataFactory; |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | |
225 | 225 | $params = $this->extractRequestParams(); |
226 | 226 | |
227 | - $this->validateParameters( $params ); |
|
228 | - $entityIds = $this->parseEntityIds( $params ); |
|
229 | - $claimIds = $this->parseClaimIds( $params ); |
|
227 | + $this->validateParameters($params); |
|
228 | + $entityIds = $this->parseEntityIds($params); |
|
229 | + $claimIds = $this->parseClaimIds($params); |
|
230 | 230 | $constraintIDs = $params[self::PARAM_CONSTRAINT_ID]; |
231 | 231 | $statuses = $params[self::PARAM_STATUS]; |
232 | 232 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | ) |
243 | 243 | )->getArray() |
244 | 244 | ); |
245 | - $this->resultBuilder->markSuccess( 1 ); |
|
245 | + $this->resultBuilder->markSuccess(1); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -250,24 +250,24 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return EntityId[] |
252 | 252 | */ |
253 | - private function parseEntityIds( array $params ) { |
|
253 | + private function parseEntityIds(array $params) { |
|
254 | 254 | $ids = $params[self::PARAM_ID]; |
255 | 255 | |
256 | - if ( $ids === null ) { |
|
256 | + if ($ids === null) { |
|
257 | 257 | return []; |
258 | - } elseif ( $ids === [] ) { |
|
258 | + } elseif ($ids === []) { |
|
259 | 259 | $this->errorReporter->dieError( |
260 | - 'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
260 | + 'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
261 | 261 | } |
262 | 262 | |
263 | - return array_map( function ( $id ) { |
|
263 | + return array_map(function($id) { |
|
264 | 264 | try { |
265 | - return $this->entityIdParser->parse( $id ); |
|
266 | - } catch ( EntityIdParsingException $e ) { |
|
265 | + return $this->entityIdParser->parse($id); |
|
266 | + } catch (EntityIdParsingException $e) { |
|
267 | 267 | $this->errorReporter->dieError( |
268 | - "Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] ); |
|
268 | + "Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] ); |
|
269 | 269 | } |
270 | - }, $ids ); |
|
270 | + }, $ids); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -275,35 +275,35 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return string[] |
277 | 277 | */ |
278 | - private function parseClaimIds( array $params ) { |
|
278 | + private function parseClaimIds(array $params) { |
|
279 | 279 | $ids = $params[self::PARAM_CLAIM_ID]; |
280 | 280 | |
281 | - if ( $ids === null ) { |
|
281 | + if ($ids === null) { |
|
282 | 282 | return []; |
283 | - } elseif ( $ids === [] ) { |
|
283 | + } elseif ($ids === []) { |
|
284 | 284 | $this->errorReporter->dieError( |
285 | - 'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
285 | + 'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
286 | 286 | } |
287 | 287 | |
288 | - foreach ( $ids as $id ) { |
|
289 | - if ( !$this->statementGuidValidator->validate( $id ) ) { |
|
288 | + foreach ($ids as $id) { |
|
289 | + if (!$this->statementGuidValidator->validate($id)) { |
|
290 | 290 | $this->errorReporter->dieError( |
291 | - "Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] ); |
|
291 | + "Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] ); |
|
292 | 292 | } |
293 | 293 | } |
294 | 294 | |
295 | 295 | return $ids; |
296 | 296 | } |
297 | 297 | |
298 | - private function validateParameters( array $params ) { |
|
299 | - if ( $params[self::PARAM_CONSTRAINT_ID] !== null |
|
300 | - && empty( $params[self::PARAM_CONSTRAINT_ID] ) |
|
298 | + private function validateParameters(array $params) { |
|
299 | + if ($params[self::PARAM_CONSTRAINT_ID] !== null |
|
300 | + && empty($params[self::PARAM_CONSTRAINT_ID]) |
|
301 | 301 | ) { |
302 | 302 | $paramConstraintId = self::PARAM_CONSTRAINT_ID; |
303 | 303 | $this->errorReporter->dieError( |
304 | 304 | "If $paramConstraintId is specified, it must be nonempty.", 'no-data' ); |
305 | 305 | } |
306 | - if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) { |
|
306 | + if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) { |
|
307 | 307 | $paramId = self::PARAM_ID; |
308 | 308 | $paramClaimId = self::PARAM_CLAIM_ID; |
309 | 309 | $this->errorReporter->dieError( |
@@ -343,11 +343,11 @@ discard block |
||
343 | 343 | ], |
344 | 344 | ApiBase::PARAM_ISMULTI => true, |
345 | 345 | ApiBase::PARAM_ALL => true, |
346 | - ApiBase::PARAM_DFLT => implode( '|', [ |
|
346 | + ApiBase::PARAM_DFLT => implode('|', [ |
|
347 | 347 | CheckResult::STATUS_VIOLATION, |
348 | 348 | CheckResult::STATUS_WARNING, |
349 | 349 | CheckResult::STATUS_BAD_PARAMETERS, |
350 | - ] ), |
|
350 | + ]), |
|
351 | 351 | ApiBase::PARAM_HELP_MSG_PER_VALUE => [], |
352 | 352 | ], |
353 | 353 | ]; |