Completed
Push — master ( af1662...d5f822 )
by
unknown
04:16
created
src/Api/CheckConstraints.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -92,28 +92,28 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return self
94 94
 	 */
95
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
95
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
96 96
 		$repo = WikibaseRepo::getDefaultInstance();
97 97
 
98 98
 		$language = $repo->getUserLanguage();
99 99
 		$formatterOptions = new FormatterOptions();
100
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
100
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
101 101
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
102
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
102
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
103 103
 
104 104
 		$languageFallbackLabelDescriptionLookupFactory = $repo->getLanguageFallbackLabelDescriptionLookupFactory();
105
-		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup( $language );
105
+		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup($language);
106 106
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
107
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
107
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
108 108
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
109
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
109
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
110 110
 		$config = MediaWikiServices::getInstance()->getMainConfig();
111 111
 		$titleParser = MediaWikiServices::getInstance()->getTitleParser();
112 112
 		$unitConverter = $repo->getUnitConverter();
113 113
 		$dataFactory = MediaWikiServices::getInstance()->getStatsdDataFactory();
114 114
 		$loggingHelper = new LoggingHelper(
115 115
 			$dataFactory,
116
-			LoggerFactory::getInstance( 'WikibaseQualityConstraints' ),
116
+			LoggerFactory::getInstance('WikibaseQualityConstraints'),
117 117
 			$config
118 118
 		);
119 119
 		$constraintParameterRenderer = new ConstraintParameterRenderer(
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
 		$checkResultsRenderer = new CheckResultsRenderer(
148 148
 			$repo->getEntityTitleLookup(),
149 149
 			$entityIdLabelFormatter,
150
-			new MultilingualTextViolationMessageRenderer( $entityIdHtmlLinkFormatter, $valueFormatter, $config ),
150
+			new MultilingualTextViolationMessageRenderer($entityIdHtmlLinkFormatter, $valueFormatter, $config),
151 151
 			$config
152 152
 		);
153 153
 		$resultsSource = new CheckingResultsSource(
154 154
 			$constraintReportFactory->getConstraintChecker()
155 155
 		);
156
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
156
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
157 157
 			$wikiPageEntityMetaDataAccessor = new WikiPageEntityMetaDataLookup(
158 158
 				$repo->getEntityNamespaceLookup()
159 159
 			);
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
 				$checkResultDeserializer,
183 183
 				$wikiPageEntityMetaDataAccessor,
184 184
 				$entityIdParser,
185
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
185
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
186 186
 				[
187
-					$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
188
-					$config->get( 'WBQualityConstraintsTypeConstraintId' ),
189
-					$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
190
-					$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
187
+					$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
188
+					$config->get('WBQualityConstraintsTypeConstraintId'),
189
+					$config->get('WBQualityConstraintsValueTypeConstraintId'),
190
+					$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
191 191
 				],
192
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ),
192
+				$config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'),
193 193
 				$loggingHelper
194 194
 			);
195 195
 		}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$prefix,
201 201
 			$repo->getEntityIdParser(),
202 202
 			$repo->getStatementGuidValidator(),
203
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
203
+			$repo->getApiHelperFactory(RequestContext::getMain()),
204 204
 			$resultsSource,
205 205
 			$checkResultsRenderer,
206 206
 			$dataFactory
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
 		CheckResultsRenderer $checkResultsRenderer,
230 230
 		IBufferingStatsdDataFactory $dataFactory
231 231
 	) {
232
-		parent::__construct( $main, $name, $prefix );
232
+		parent::__construct($main, $name, $prefix);
233 233
 		$this->entityIdParser = $entityIdParser;
234 234
 		$this->statementGuidValidator = $statementGuidValidator;
235
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
236
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
235
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
236
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
237 237
 		$this->resultsSource = $resultsSource;
238 238
 		$this->checkResultsRenderer = $checkResultsRenderer;
239 239
 		$this->dataFactory = $dataFactory;
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 
250 250
 		$params = $this->extractRequestParams();
251 251
 
252
-		$this->validateParameters( $params );
253
-		$entityIds = $this->parseEntityIds( $params );
254
-		$claimIds = $this->parseClaimIds( $params );
252
+		$this->validateParameters($params);
253
+		$entityIds = $this->parseEntityIds($params);
254
+		$claimIds = $this->parseClaimIds($params);
255 255
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
256 256
 		$statuses = $params[self::PARAM_STATUS];
257 257
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 				)
268 268
 			)->getArray()
269 269
 		);
270
-		$this->resultBuilder->markSuccess( 1 );
270
+		$this->resultBuilder->markSuccess(1);
271 271
 	}
272 272
 
273 273
 	/**
@@ -275,24 +275,24 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @return EntityId[]
277 277
 	 */
278
-	private function parseEntityIds( array $params ) {
278
+	private function parseEntityIds(array $params) {
279 279
 		$ids = $params[self::PARAM_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_ID . ' is specified, it must be nonempty.', 'no-data' );
285
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
286 286
 		}
287 287
 
288
-		return array_map( function ( $id ) {
288
+		return array_map(function($id) {
289 289
 			try {
290
-				return $this->entityIdParser->parse( $id );
291
-			} catch ( EntityIdParsingException $e ) {
290
+				return $this->entityIdParser->parse($id);
291
+			} catch (EntityIdParsingException $e) {
292 292
 				$this->errorReporter->dieError(
293
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
293
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
294 294
 			}
295
-		}, $ids );
295
+		}, $ids);
296 296
 	}
297 297
 
298 298
 	/**
@@ -300,35 +300,35 @@  discard block
 block discarded – undo
300 300
 	 *
301 301
 	 * @return string[]
302 302
 	 */
303
-	private function parseClaimIds( array $params ) {
303
+	private function parseClaimIds(array $params) {
304 304
 		$ids = $params[self::PARAM_CLAIM_ID];
305 305
 
306
-		if ( $ids === null ) {
306
+		if ($ids === null) {
307 307
 			return [];
308
-		} elseif ( $ids === [] ) {
308
+		} elseif ($ids === []) {
309 309
 			$this->errorReporter->dieError(
310
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
310
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
311 311
 		}
312 312
 
313
-		foreach ( $ids as $id ) {
314
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
313
+		foreach ($ids as $id) {
314
+			if (!$this->statementGuidValidator->validate($id)) {
315 315
 				$this->errorReporter->dieError(
316
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
316
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
317 317
 			}
318 318
 		}
319 319
 
320 320
 		return $ids;
321 321
 	}
322 322
 
323
-	private function validateParameters( array $params ) {
324
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
325
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
323
+	private function validateParameters(array $params) {
324
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
325
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
326 326
 		) {
327 327
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
328 328
 			$this->errorReporter->dieError(
329 329
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
330 330
 		}
331
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
331
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
332 332
 			$paramId = self::PARAM_ID;
333 333
 			$paramClaimId = self::PARAM_CLAIM_ID;
334 334
 			$this->errorReporter->dieError(
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
 				],
369 369
 				ApiBase::PARAM_ISMULTI => true,
370 370
 				ApiBase::PARAM_ALL => true,
371
-				ApiBase::PARAM_DFLT => implode( '|', [
371
+				ApiBase::PARAM_DFLT => implode('|', [
372 372
 					CheckResult::STATUS_VIOLATION,
373 373
 					CheckResult::STATUS_WARNING,
374 374
 					CheckResult::STATUS_BAD_PARAMETERS,
375
-				] ),
375
+				]),
376 376
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
377 377
 			],
378 378
 		];
Please login to merge, or discard this patch.
src/Api/ResultsCache.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param WANObjectCache $cache
37 37
 	 * @param string $formatVersion The version of the API response format.
38 38
 	 */
39
-	public function __construct( WANObjectCache $cache, $formatVersion ) {
39
+	public function __construct(WANObjectCache $cache, $formatVersion) {
40 40
 		$this->cache = $cache;
41 41
 		$this->formatVersion = $formatVersion;
42 42
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param EntityId $entityId
46 46
 	 * @return string cache key
47 47
 	 */
48
-	public function makeKey( EntityId $entityId ) {
48
+	public function makeKey(EntityId $entityId) {
49 49
 		return $this->cache->makeKey(
50 50
 			'WikibaseQualityConstraints', // extension
51 51
 			'checkConstraints', // action
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 * @param float &$asOf
62 62
 	 * @return mixed
63 63
 	 */
64
-	public function get( EntityId $key, &$curTTL = null, array $checkKeys = [], &$asOf = null ) {
65
-		return $this->cache->get( $this->makeKey( $key ), $curTTL, $checkKeys, $asOf );
64
+	public function get(EntityId $key, &$curTTL = null, array $checkKeys = [], &$asOf = null) {
65
+		return $this->cache->get($this->makeKey($key), $curTTL, $checkKeys, $asOf);
66 66
 	}
67 67
 
68 68
 	/**
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
 	 * @param array $opts
73 73
 	 * @return bool
74 74
 	 */
75
-	public function set( EntityId $key, $value, $ttl = 0, array $opts = [] ) {
76
-		return $this->cache->set( $this->makeKey( $key ), $value, $ttl, $opts );
75
+	public function set(EntityId $key, $value, $ttl = 0, array $opts = []) {
76
+		return $this->cache->set($this->makeKey($key), $value, $ttl, $opts);
77 77
 	}
78 78
 
79 79
 	/**
80 80
 	 * @param EntityId $key
81 81
 	 * @return bool
82 82
 	 */
83
-	public function delete( EntityId $key ) {
84
-		return $this->cache->delete( $this->makeKey( $key ) );
83
+	public function delete(EntityId $key) {
84
+		return $this->cache->delete($this->makeKey($key));
85 85
 	}
86 86
 
87 87
 }
Please login to merge, or discard this patch.