@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return self |
78 | 78 | */ |
79 | - public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) { |
|
79 | + public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') { |
|
80 | 80 | $repo = WikibaseRepo::getDefaultInstance(); |
81 | 81 | |
82 | 82 | $language = $repo->getUserLanguage(); |
83 | 83 | $formatterOptions = new FormatterOptions(); |
84 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
84 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
85 | 85 | $valueFormatterFactory = $repo->getValueFormatterFactory(); |
86 | - $valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
86 | + $valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
87 | 87 | |
88 | 88 | $languageFallbackLabelDescriptionLookupFactory = $repo->getLanguageFallbackLabelDescriptionLookupFactory(); |
89 | - $labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup( $language ); |
|
89 | + $labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup($language); |
|
90 | 90 | $entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory(); |
91 | - $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup ); |
|
91 | + $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelDescriptionLookup); |
|
92 | 92 | $entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory(); |
93 | - $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup ); |
|
93 | + $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelDescriptionLookup); |
|
94 | 94 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
95 | 95 | $titleParser = MediaWikiServices::getInstance()->getTitleParser(); |
96 | 96 | $unitConverter = $repo->getUnitConverter(); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $constraintParameterRenderer, |
126 | 126 | $config |
127 | 127 | ); |
128 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
128 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
129 | 129 | $wikiPageEntityMetaDataAccessor = new WikiPageEntityMetaDataLookup( |
130 | 130 | $repo->getEntityNamespaceLookup() |
131 | 131 | ); |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | ResultsCache::getDefaultInstance(), |
137 | 137 | $wikiPageEntityMetaDataAccessor, |
138 | 138 | $entityIdParser, |
139 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
139 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
140 | 140 | [ |
141 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
142 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
143 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
144 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
141 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
142 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
143 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
144 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
145 | 145 | ], |
146 | 146 | $dataFactory |
147 | 147 | ); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $prefix, |
154 | 154 | $repo->getEntityIdParser(), |
155 | 155 | $repo->getStatementGuidValidator(), |
156 | - $repo->getApiHelperFactory( RequestContext::getMain() ), |
|
156 | + $repo->getApiHelperFactory(RequestContext::getMain()), |
|
157 | 157 | $resultsBuilder, |
158 | 158 | $dataFactory |
159 | 159 | ); |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | ResultsBuilder $resultsBuilder, |
180 | 180 | IBufferingStatsdDataFactory $dataFactory |
181 | 181 | ) { |
182 | - parent::__construct( $main, $name, $prefix ); |
|
182 | + parent::__construct($main, $name, $prefix); |
|
183 | 183 | $this->entityIdParser = $entityIdParser; |
184 | 184 | $this->statementGuidValidator = $statementGuidValidator; |
185 | - $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); |
|
186 | - $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
185 | + $this->resultBuilder = $apiHelperFactory->getResultBuilder($this); |
|
186 | + $this->errorReporter = $apiHelperFactory->getErrorReporter($this); |
|
187 | 187 | $this->resultsBuilder = $resultsBuilder; |
188 | 188 | $this->dataFactory = $dataFactory; |
189 | 189 | } |
@@ -198,9 +198,9 @@ discard block |
||
198 | 198 | |
199 | 199 | $params = $this->extractRequestParams(); |
200 | 200 | |
201 | - $this->validateParameters( $params ); |
|
202 | - $entityIds = $this->parseEntityIds( $params ); |
|
203 | - $claimIds = $this->parseClaimIds( $params ); |
|
201 | + $this->validateParameters($params); |
|
202 | + $entityIds = $this->parseEntityIds($params); |
|
203 | + $claimIds = $this->parseClaimIds($params); |
|
204 | 204 | $constraintIDs = $params[self::PARAM_CONSTRAINT_ID]; |
205 | 205 | $statuses = $params[self::PARAM_STATUS]; |
206 | 206 | |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | )->getArray() |
216 | 216 | ); |
217 | 217 | // ensure that result contains the given entity IDs even if they have no statements |
218 | - foreach ( $entityIds as $entityId ) { |
|
218 | + foreach ($entityIds as $entityId) { |
|
219 | 219 | $this->getResult()->addArrayType( |
220 | - [ $this->getModuleName(), $entityId->getSerialization() ], |
|
220 | + [$this->getModuleName(), $entityId->getSerialization()], |
|
221 | 221 | 'assoc' |
222 | 222 | ); |
223 | 223 | } |
224 | - $this->resultBuilder->markSuccess( 1 ); |
|
224 | + $this->resultBuilder->markSuccess(1); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -229,24 +229,24 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return EntityId[] |
231 | 231 | */ |
232 | - private function parseEntityIds( array $params ) { |
|
232 | + private function parseEntityIds(array $params) { |
|
233 | 233 | $ids = $params[self::PARAM_ID]; |
234 | 234 | |
235 | - if ( $ids === null ) { |
|
235 | + if ($ids === null) { |
|
236 | 236 | return []; |
237 | - } elseif ( $ids === [] ) { |
|
237 | + } elseif ($ids === []) { |
|
238 | 238 | $this->errorReporter->dieError( |
239 | - 'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
239 | + 'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
240 | 240 | } |
241 | 241 | |
242 | - return array_map( function ( $id ) { |
|
242 | + return array_map(function($id) { |
|
243 | 243 | try { |
244 | - return $this->entityIdParser->parse( $id ); |
|
245 | - } catch ( EntityIdParsingException $e ) { |
|
244 | + return $this->entityIdParser->parse($id); |
|
245 | + } catch (EntityIdParsingException $e) { |
|
246 | 246 | $this->errorReporter->dieError( |
247 | - "Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] ); |
|
247 | + "Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] ); |
|
248 | 248 | } |
249 | - }, $ids ); |
|
249 | + }, $ids); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -254,35 +254,35 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return string[] |
256 | 256 | */ |
257 | - private function parseClaimIds( array $params ) { |
|
257 | + private function parseClaimIds(array $params) { |
|
258 | 258 | $ids = $params[self::PARAM_CLAIM_ID]; |
259 | 259 | |
260 | - if ( $ids === null ) { |
|
260 | + if ($ids === null) { |
|
261 | 261 | return []; |
262 | - } elseif ( $ids === [] ) { |
|
262 | + } elseif ($ids === []) { |
|
263 | 263 | $this->errorReporter->dieError( |
264 | - 'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
264 | + 'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
265 | 265 | } |
266 | 266 | |
267 | - foreach ( $ids as $id ) { |
|
268 | - if ( !$this->statementGuidValidator->validate( $id ) ) { |
|
267 | + foreach ($ids as $id) { |
|
268 | + if (!$this->statementGuidValidator->validate($id)) { |
|
269 | 269 | $this->errorReporter->dieError( |
270 | - "Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] ); |
|
270 | + "Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] ); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | 274 | return $ids; |
275 | 275 | } |
276 | 276 | |
277 | - private function validateParameters( array $params ) { |
|
278 | - if ( $params[self::PARAM_CONSTRAINT_ID] !== null |
|
279 | - && empty( $params[self::PARAM_CONSTRAINT_ID] ) |
|
277 | + private function validateParameters(array $params) { |
|
278 | + if ($params[self::PARAM_CONSTRAINT_ID] !== null |
|
279 | + && empty($params[self::PARAM_CONSTRAINT_ID]) |
|
280 | 280 | ) { |
281 | 281 | $paramConstraintId = self::PARAM_CONSTRAINT_ID; |
282 | 282 | $this->errorReporter->dieError( |
283 | 283 | "If $paramConstraintId is specified, it must be nonempty.", 'no-data' ); |
284 | 284 | } |
285 | - if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) { |
|
285 | + if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) { |
|
286 | 286 | $paramId = self::PARAM_ID; |
287 | 287 | $paramClaimId = self::PARAM_CLAIM_ID; |
288 | 288 | $this->errorReporter->dieError( |