Completed
Push — master ( cea476...15f106 )
by
unknown
04:53
created
src/Api/CachingResultsBuilder.php 1 patch
Spacing   +66 added lines, -67 removed lines patch added patch discarded remove patch
@@ -142,28 +142,28 @@  discard block
 block discarded – undo
142 142
 	) {
143 143
 		$results = [];
144 144
 		$metadatas = [];
145
-		if ( $this->canUseStoredResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
145
+		if ($this->canUseStoredResults($entityIds, $claimIds, $constraintIds, $statuses)) {
146 146
 			$storedEntityIds = [];
147
-			foreach ( $entityIds as $entityId ) {
148
-				$storedResults = $this->getStoredResults( $entityId );
149
-				if ( $storedResults !== null ) {
150
-					$this->loggingHelper->logCheckConstraintsCacheHit( $entityId );
147
+			foreach ($entityIds as $entityId) {
148
+				$storedResults = $this->getStoredResults($entityId);
149
+				if ($storedResults !== null) {
150
+					$this->loggingHelper->logCheckConstraintsCacheHit($entityId);
151 151
 					$results += $storedResults->getArray();
152 152
 					$metadatas[] = $storedResults->getMetadata();
153 153
 					$storedEntityIds[] = $entityId;
154 154
 				}
155 155
 			}
156
-			$entityIds = array_values( array_diff( $entityIds, $storedEntityIds ) );
156
+			$entityIds = array_values(array_diff($entityIds, $storedEntityIds));
157 157
 		}
158
-		if ( $entityIds !== [] || $claimIds !== [] ) {
159
-			$this->loggingHelper->logCheckConstraintsCacheMisses( $entityIds );
160
-			$response = $this->getAndStoreResults( $entityIds, $claimIds, $constraintIds, $statuses );
158
+		if ($entityIds !== [] || $claimIds !== []) {
159
+			$this->loggingHelper->logCheckConstraintsCacheMisses($entityIds);
160
+			$response = $this->getAndStoreResults($entityIds, $claimIds, $constraintIds, $statuses);
161 161
 			$results += $response->getArray();
162 162
 			$metadatas[] = $response->getMetadata();
163 163
 		}
164 164
 		return new CachedCheckConstraintsResponse(
165 165
 			$results,
166
-			Metadata::merge( $metadatas )
166
+			Metadata::merge($metadatas)
167 167
 		);
168 168
 	}
169 169
 
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
 		array $constraintIds = null,
193 193
 		array $statuses
194 194
 	) {
195
-		if ( $claimIds !== [] ) {
195
+		if ($claimIds !== []) {
196 196
 			return false;
197 197
 		}
198
-		if ( $constraintIds !== null ) {
198
+		if ($constraintIds !== null) {
199 199
 			return false;
200 200
 		}
201
-		if ( $statuses != $this->cachedStatuses ) {
201
+		if ($statuses != $this->cachedStatuses) {
202 202
 			return false;
203 203
 		}
204 204
 		return true;
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 		array $constraintIds = null,
218 218
 		array $statuses
219 219
 	) {
220
-		$results = $this->resultsBuilder->getResults( $entityIds, $claimIds, $constraintIds, $statuses );
220
+		$results = $this->resultsBuilder->getResults($entityIds, $claimIds, $constraintIds, $statuses);
221 221
 
222
-		if ( $this->canStoreResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
223
-			foreach ( $entityIds as $entityId ) {
222
+		if ($this->canStoreResults($entityIds, $claimIds, $constraintIds, $statuses)) {
223
+			foreach ($entityIds as $entityId) {
224 224
 				$latestRevisionIds = $this->getLatestRevisionIds(
225 225
 					$results->getMetadata()->getDependencyMetadata()->getEntityIds()
226 226
 				);
227
-				if ( $latestRevisionIds === null ) {
227
+				if ($latestRevisionIds === null) {
228 228
 					continue;
229 229
 				}
230 230
 				$value = [
@@ -232,10 +232,10 @@  discard block
 block discarded – undo
232 232
 					'latestRevisionIds' => $latestRevisionIds,
233 233
 				];
234 234
 				$futureTime = $results->getMetadata()->getDependencyMetadata()->getFutureTime();
235
-				if ( $futureTime !== null ) {
235
+				if ($futureTime !== null) {
236 236
 					$value['futureTime'] = $futureTime->getArrayValue();
237 237
 				}
238
-				$this->cache->set( $entityId, $value, $this->ttlInSeconds );
238
+				$this->cache->set($entityId, $value, $this->ttlInSeconds);
239 239
 			}
240 240
 		}
241 241
 
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 		array $constraintIds = null,
268 268
 		array $statuses
269 269
 	) {
270
-		if ( $constraintIds !== null ) {
270
+		if ($constraintIds !== null) {
271 271
 			return false;
272 272
 		}
273
-		if ( $statuses != $this->cachedStatuses ) {
273
+		if ($statuses != $this->cachedStatuses) {
274 274
 			return false;
275 275
 		}
276 276
 		return true;
@@ -283,45 +283,44 @@  discard block
 block discarded – undo
283 283
 	public function getStoredResults(
284 284
 		EntityId $entityId
285 285
 	) {
286
-		$value = $this->cache->get( $entityId, $curTTL, [], $asOf );
287
-		$now = call_user_func( $this->microtime, true );
286
+		$value = $this->cache->get($entityId, $curTTL, [], $asOf);
287
+		$now = call_user_func($this->microtime, true);
288 288
 
289
-		if ( $value === false ) {
289
+		if ($value === false) {
290 290
 			return null;
291 291
 		}
292 292
 
293
-		$ageInSeconds = (int)ceil( $now - $asOf );
293
+		$ageInSeconds = (int) ceil($now - $asOf);
294 294
 
295 295
 		$dependedEntityIds = array_map(
296
-			[ $this->entityIdParser, "parse" ],
297
-			array_keys( $value['latestRevisionIds'] )
296
+			[$this->entityIdParser, "parse"],
297
+			array_keys($value['latestRevisionIds'])
298 298
 		);
299 299
 
300
-		if ( $value['latestRevisionIds'] !== $this->getLatestRevisionIds( $dependedEntityIds ) ) {
300
+		if ($value['latestRevisionIds'] !== $this->getLatestRevisionIds($dependedEntityIds)) {
301 301
 			return null;
302 302
 		}
303 303
 
304
-		if ( array_key_exists( 'futureTime', $value ) ) {
305
-			$futureTime = TimeValue::newFromArray( $value['futureTime'] );
306
-			if ( !$this->timeValueComparer->isFutureTime( $futureTime ) ) {
304
+		if (array_key_exists('futureTime', $value)) {
305
+			$futureTime = TimeValue::newFromArray($value['futureTime']);
306
+			if (!$this->timeValueComparer->isFutureTime($futureTime)) {
307 307
 				return null;
308 308
 			}
309
-			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime( $futureTime );
309
+			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime($futureTime);
310 310
 		} else {
311 311
 			$futureTimeDependencyMetadata = DependencyMetadata::blank();
312 312
 		}
313 313
 
314 314
 		$cachingMetadata = $ageInSeconds > 0 ?
315
-			CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) :
316
-			CachingMetadata::fresh();
315
+			CachingMetadata::ofMaximumAgeInSeconds($ageInSeconds) : CachingMetadata::fresh();
317 316
 
318
-		if ( is_array( $value['results'] ) ) {
319
-			array_walk( $value['results'], [ $this, 'updateCachingMetadata' ], $cachingMetadata );
317
+		if (is_array($value['results'])) {
318
+			array_walk($value['results'], [$this, 'updateCachingMetadata'], $cachingMetadata);
320 319
 		}
321 320
 
322 321
 		return new CachedCheckConstraintsResponse(
323
-			[ $entityId->getSerialization() => $value['results'] ],
324
-			$this->mergeStoredMetadata( $cachingMetadata, $dependedEntityIds, $futureTimeDependencyMetadata )
322
+			[$entityId->getSerialization() => $value['results']],
323
+			$this->mergeStoredMetadata($cachingMetadata, $dependedEntityIds, $futureTimeDependencyMetadata)
325 324
 		);
326 325
 	}
327 326
 
@@ -336,19 +335,19 @@  discard block
 block discarded – undo
336 335
 		array $dependedEntityIds,
337 336
 		DependencyMetadata $futureTimeDependencyMetadata = null
338 337
 	) {
339
-		return Metadata::merge( [
340
-			Metadata::ofCachingMetadata( $cachingMetadata ),
341
-			Metadata::ofDependencyMetadata( array_reduce(
338
+		return Metadata::merge([
339
+			Metadata::ofCachingMetadata($cachingMetadata),
340
+			Metadata::ofDependencyMetadata(array_reduce(
342 341
 				$dependedEntityIds,
343
-				function( DependencyMetadata $metadata, EntityId $entityId ) {
344
-					return DependencyMetadata::merge( [
342
+				function(DependencyMetadata $metadata, EntityId $entityId) {
343
+					return DependencyMetadata::merge([
345 344
 						$metadata,
346
-						DependencyMetadata::ofEntityId( $entityId )
347
-					] );
345
+						DependencyMetadata::ofEntityId($entityId)
346
+					]);
348 347
 				},
349 348
 				$futureTimeDependencyMetadata
350
-			) )
351
-		] );
349
+			))
350
+		]);
352 351
 	}
353 352
 
354 353
 	/**
@@ -356,8 +355,8 @@  discard block
 block discarded – undo
356 355
 	 * @return int[]|null array from entity ID serializations to revision ID,
357 356
 	 * or null to indicate that not all revision IDs could be loaded
358 357
 	 */
359
-	private function getLatestRevisionIds( array $entityIds ) {
360
-		if ( $entityIds === [] ) {
358
+	private function getLatestRevisionIds(array $entityIds) {
359
+		if ($entityIds === []) {
361 360
 			$this->loggingHelper->logEmptyDependencyMetadata();
362 361
 			return [];
363 362
 		}
@@ -366,11 +365,11 @@  discard block
 block discarded – undo
366 365
 			$entityIds,
367 366
 			EntityRevisionLookup::LATEST_FROM_REPLICA
368 367
 		);
369
-		if ( $this->hasFalseElements( $revisionInformations ) ) {
368
+		if ($this->hasFalseElements($revisionInformations)) {
370 369
 			return null;
371 370
 		}
372 371
 		$latestRevisionIds = [];
373
-		foreach ( $revisionInformations as $serialization => $revisionInformation ) {
372
+		foreach ($revisionInformations as $serialization => $revisionInformation) {
374 373
 			$latestRevisionIds[$serialization] = $revisionInformation->page_latest;
375 374
 		}
376 375
 		return $latestRevisionIds;
@@ -380,31 +379,31 @@  discard block
 block discarded – undo
380 379
 	 * @param array $array
381 380
 	 * @return bool
382 381
 	 */
383
-	private function hasFalseElements( array $array ) {
384
-		return in_array( false, $array, true );
382
+	private function hasFalseElements(array $array) {
383
+		return in_array(false, $array, true);
385 384
 	}
386 385
 
387
-	public function updateCachingMetadata( &$element, $key, CachingMetadata $cachingMetadata ) {
388
-		if ( $key === 'cached' ) {
389
-			$element = CachingMetadata::merge( [
386
+	public function updateCachingMetadata(&$element, $key, CachingMetadata $cachingMetadata) {
387
+		if ($key === 'cached') {
388
+			$element = CachingMetadata::merge([
390 389
 				$cachingMetadata,
391
-				CachingMetadata::ofArray( $element ),
392
-			] )->toArray();
390
+				CachingMetadata::ofArray($element),
391
+			])->toArray();
393 392
 		}
394 393
 		if (
395
-			is_array( $element ) &&
396
-			array_key_exists( 'constraint', $element ) &&
397
-			in_array( $element['constraint']['type'], $this->possiblyStaleConstraintTypes, true )
394
+			is_array($element) &&
395
+			array_key_exists('constraint', $element) &&
396
+			in_array($element['constraint']['type'], $this->possiblyStaleConstraintTypes, true)
398 397
 		) {
399
-			$element['cached'] = CachingMetadata::merge( [
398
+			$element['cached'] = CachingMetadata::merge([
400 399
 				$cachingMetadata,
401 400
 				CachingMetadata::ofArray(
402
-					array_key_exists( 'cached', $element ) ? $element['cached'] : null
401
+					array_key_exists('cached', $element) ? $element['cached'] : null
403 402
 				),
404
-			] )->toArray();
403
+			])->toArray();
405 404
 		}
406
-		if ( is_array( $element ) ) {
407
-			array_walk( $element, [ $this, __FUNCTION__ ], $cachingMetadata );
405
+		if (is_array($element)) {
406
+			array_walk($element, [$this, __FUNCTION__], $cachingMetadata);
408 407
 		}
409 408
 	}
410 409
 
@@ -413,7 +412,7 @@  discard block
 block discarded – undo
413 412
 	 *
414 413
 	 * @param callable $microtime
415 414
 	 */
416
-	public function setMicrotimeFunction( callable $microtime ) {
415
+	public function setMicrotimeFunction(callable $microtime) {
417 416
 		$this->microtime = $microtime;
418 417
 	}
419 418
 
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -81,28 +81,28 @@  discard block
 block discarded – undo
81 81
 	 *
82 82
 	 * @return self
83 83
 	 */
84
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
84
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
85 85
 		$repo = WikibaseRepo::getDefaultInstance();
86 86
 
87 87
 		$language = $repo->getUserLanguage();
88 88
 		$formatterOptions = new FormatterOptions();
89
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
89
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
90 90
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
91
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
91
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
92 92
 
93 93
 		$languageFallbackLabelDescriptionLookupFactory = $repo->getLanguageFallbackLabelDescriptionLookupFactory();
94
-		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup( $language );
94
+		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup($language);
95 95
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
96
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
96
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
97 97
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
98
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
98
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
99 99
 		$config = MediaWikiServices::getInstance()->getMainConfig();
100 100
 		$titleParser = MediaWikiServices::getInstance()->getTitleParser();
101 101
 		$unitConverter = $repo->getUnitConverter();
102 102
 		$dataFactory = MediaWikiServices::getInstance()->getStatsdDataFactory();
103 103
 		$loggingHelper = new LoggingHelper(
104 104
 			$dataFactory,
105
-			LoggerFactory::getInstance( 'WikibaseQualityConstraints' ),
105
+			LoggerFactory::getInstance('WikibaseQualityConstraints'),
106 106
 			$config
107 107
 		);
108 108
 		$constraintParameterRenderer = new ConstraintParameterRenderer(
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
 			$repo->getEntityTitleLookup(),
139 139
 			$entityIdLabelFormatter,
140 140
 			$constraintParameterRenderer,
141
-			new MultilingualTextViolationMessageRenderer( $entityIdHtmlLinkFormatter, $valueFormatter, $config ),
141
+			new MultilingualTextViolationMessageRenderer($entityIdHtmlLinkFormatter, $valueFormatter, $config),
142 142
 			$config
143 143
 		);
144
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
144
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
145 145
 			$wikiPageEntityMetaDataAccessor = new WikiPageEntityMetaDataLookup(
146 146
 				$repo->getEntityNamespaceLookup()
147 147
 			);
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 				ResultsCache::getDefaultInstance(),
153 153
 				$wikiPageEntityMetaDataAccessor,
154 154
 				$entityIdParser,
155
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
155
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
156 156
 				[
157
-					$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
158
-					$config->get( 'WBQualityConstraintsTypeConstraintId' ),
159
-					$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
160
-					$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
157
+					$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
158
+					$config->get('WBQualityConstraintsTypeConstraintId'),
159
+					$config->get('WBQualityConstraintsValueTypeConstraintId'),
160
+					$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
161 161
 				],
162 162
 				$loggingHelper
163 163
 			);
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 			$prefix,
170 170
 			$repo->getEntityIdParser(),
171 171
 			$repo->getStatementGuidValidator(),
172
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
172
+			$repo->getApiHelperFactory(RequestContext::getMain()),
173 173
 			$resultsBuilder,
174 174
 			$dataFactory
175 175
 		);
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 		ResultsBuilder $resultsBuilder,
196 196
 		IBufferingStatsdDataFactory $dataFactory
197 197
 	) {
198
-		parent::__construct( $main, $name, $prefix );
198
+		parent::__construct($main, $name, $prefix);
199 199
 		$this->entityIdParser = $entityIdParser;
200 200
 		$this->statementGuidValidator = $statementGuidValidator;
201
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
202
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
201
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
202
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
203 203
 		$this->resultsBuilder = $resultsBuilder;
204 204
 		$this->dataFactory = $dataFactory;
205 205
 	}
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
 
215 215
 		$params = $this->extractRequestParams();
216 216
 
217
-		$this->validateParameters( $params );
218
-		$entityIds = $this->parseEntityIds( $params );
219
-		$claimIds = $this->parseClaimIds( $params );
217
+		$this->validateParameters($params);
218
+		$entityIds = $this->parseEntityIds($params);
219
+		$claimIds = $this->parseClaimIds($params);
220 220
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
221 221
 		$statuses = $params[self::PARAM_STATUS];
222 222
 
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
 			)->getArray()
232 232
 		);
233 233
 		// ensure that result contains the given entity IDs even if they have no statements
234
-		foreach ( $entityIds as $entityId ) {
234
+		foreach ($entityIds as $entityId) {
235 235
 			$this->getResult()->addArrayType(
236
-				[ $this->getModuleName(), $entityId->getSerialization() ],
236
+				[$this->getModuleName(), $entityId->getSerialization()],
237 237
 				'assoc'
238 238
 			);
239 239
 		}
240
-		$this->resultBuilder->markSuccess( 1 );
240
+		$this->resultBuilder->markSuccess(1);
241 241
 	}
242 242
 
243 243
 	/**
@@ -245,24 +245,24 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @return EntityId[]
247 247
 	 */
248
-	private function parseEntityIds( array $params ) {
248
+	private function parseEntityIds(array $params) {
249 249
 		$ids = $params[self::PARAM_ID];
250 250
 
251
-		if ( $ids === null ) {
251
+		if ($ids === null) {
252 252
 			return [];
253
-		} elseif ( $ids === [] ) {
253
+		} elseif ($ids === []) {
254 254
 			$this->errorReporter->dieError(
255
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
255
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
256 256
 		}
257 257
 
258
-		return array_map( function ( $id ) {
258
+		return array_map(function($id) {
259 259
 			try {
260
-				return $this->entityIdParser->parse( $id );
261
-			} catch ( EntityIdParsingException $e ) {
260
+				return $this->entityIdParser->parse($id);
261
+			} catch (EntityIdParsingException $e) {
262 262
 				$this->errorReporter->dieError(
263
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
263
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
264 264
 			}
265
-		}, $ids );
265
+		}, $ids);
266 266
 	}
267 267
 
268 268
 	/**
@@ -270,35 +270,35 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @return string[]
272 272
 	 */
273
-	private function parseClaimIds( array $params ) {
273
+	private function parseClaimIds(array $params) {
274 274
 		$ids = $params[self::PARAM_CLAIM_ID];
275 275
 
276
-		if ( $ids === null ) {
276
+		if ($ids === null) {
277 277
 			return [];
278
-		} elseif ( $ids === [] ) {
278
+		} elseif ($ids === []) {
279 279
 			$this->errorReporter->dieError(
280
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
280
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
281 281
 		}
282 282
 
283
-		foreach ( $ids as $id ) {
284
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
283
+		foreach ($ids as $id) {
284
+			if (!$this->statementGuidValidator->validate($id)) {
285 285
 				$this->errorReporter->dieError(
286
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
286
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
287 287
 			}
288 288
 		}
289 289
 
290 290
 		return $ids;
291 291
 	}
292 292
 
293
-	private function validateParameters( array $params ) {
294
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
295
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
293
+	private function validateParameters(array $params) {
294
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
295
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
296 296
 		) {
297 297
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
298 298
 			$this->errorReporter->dieError(
299 299
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
300 300
 		}
301
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
301
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
302 302
 			$paramId = self::PARAM_ID;
303 303
 			$paramClaimId = self::PARAM_CLAIM_ID;
304 304
 			$this->errorReporter->dieError(
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 				],
340 340
 				ApiBase::PARAM_ISMULTI => true,
341 341
 				ApiBase::PARAM_ALL => true,
342
-				ApiBase::PARAM_DFLT => implode( '|', [
342
+				ApiBase::PARAM_DFLT => implode('|', [
343 343
 					CheckResult::STATUS_VIOLATION,
344 344
 					CheckResult::STATUS_WARNING,
345 345
 					CheckResult::STATUS_BAD_PARAMETERS,
346
-				] ),
346
+				]),
347 347
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
348 348
 			],
349 349
 		];
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/LoggingHelper.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -47,8 +47,8 @@  discard block
 block discarded – undo
47 47
 		$this->dataFactory = $dataFactory;
48 48
 		$this->logger = $logger;
49 49
 		$this->constraintCheckDurationLimits = [
50
-			'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ),
51
-			'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ),
50
+			'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'),
51
+			'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'),
52 52
 		];
53 53
 	}
54 54
 
@@ -74,46 +74,46 @@  discard block
 block discarded – undo
74 74
 		$durationSeconds,
75 75
 		$method
76 76
 	) {
77
-		$constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 );
77
+		$constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1);
78 78
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
79 79
 
80 80
 		$this->dataFactory->timing(
81
-			'wikibase.quality.constraints.check.timing.' .
82
-				$constraintTypeItemId . '-' .
81
+			'wikibase.quality.constraints.check.timing.'.
82
+				$constraintTypeItemId.'-'.
83 83
 				$constraintCheckerClassShortName,
84 84
 			$durationSeconds * 1000
85 85
 		);
86 86
 
87 87
 		// find the longest limit (and associated log level) that the duration exceeds
88
-		foreach ( $this->constraintCheckDurationLimits as $level => $limit ) {
88
+		foreach ($this->constraintCheckDurationLimits as $level => $limit) {
89 89
 			if (
90 90
 				// duration exceeds this limit
91
-				isset( $limit ) && $durationSeconds > $limit &&
91
+				isset($limit) && $durationSeconds > $limit &&
92 92
 				// this limit is longer than previous longest limit
93
-				( !isset( $limitSeconds ) || $limit > $limitSeconds )
93
+				(!isset($limitSeconds) || $limit > $limitSeconds)
94 94
 			) {
95 95
 				$limitSeconds = $limit;
96 96
 				$logLevel = $level;
97 97
 			}
98 98
 		}
99 99
 
100
-		if ( !isset( $limitSeconds ) ) {
100
+		if (!isset($limitSeconds)) {
101 101
 			return;
102 102
 		}
103
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
103
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
104 104
 			// TODO log less details but still log something
105 105
 			return;
106 106
 		}
107 107
 
108 108
 		$resultMessage = $result->getMessage();
109
-		if ( $resultMessage instanceof ViolationMessage ) {
109
+		if ($resultMessage instanceof ViolationMessage) {
110 110
 			$resultMessage = $resultMessage->getMessageKey();
111 111
 		}
112 112
 
113 113
 		$this->logger->log(
114 114
 			$logLevel,
115
-			'Constraint check with {constraintCheckerClassShortName} ' .
116
-			'took longer than {limitSeconds} second(s) ' .
115
+			'Constraint check with {constraintCheckerClassShortName} '.
116
+			'took longer than {limitSeconds} second(s) '.
117 117
 			'(duration: {durationSeconds} seconds).',
118 118
 			[
119 119
 				'method' => $method,
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 *
141 141
 	 * @param EntityId $entityId
142 142
 	 */
143
-	public function logCheckConstraintsCacheHit( EntityId $entityId ) {
143
+	public function logCheckConstraintsCacheHit(EntityId $entityId) {
144 144
 		$this->dataFactory->increment(
145 145
 			'wikibase.quality.constraints.cache.entity.hit'
146 146
 		);
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @param EntityId[] $entityIds
153 153
 	 */
154
-	public function logCheckConstraintsCacheMisses( array $entityIds ) {
154
+	public function logCheckConstraintsCacheMisses(array $entityIds) {
155 155
 		$this->dataFactory->updateCount(
156 156
 			'wikibase.quality.constraints.cache.entity.miss',
157
-			count( $entityIds )
157
+			count($entityIds)
158 158
 		);
159 159
 	}
160 160
 
Please login to merge, or discard this patch.