Completed
Push — master ( 8c8efa...462963 )
by
unknown
02:09
created
src/ConstraintCheck/Cache/DependencyMetadata.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param EntityId $entityId An entity ID from which the value was derived.
38 38
 	 * @return self Indication that a value was derived from the entity with the given ID.
39 39
 	 */
40
-	public static function ofEntityId( EntityId $entityId ) {
40
+	public static function ofEntityId(EntityId $entityId) {
41 41
 		$ret = new self;
42 42
 		$ret->entityIds[] = $entityId;
43 43
 		return $ret;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @return self Indication that a value will only remain valid
50 50
 	 * as long as the given time value is in the future, not in the past.
51 51
 	 */
52
-	public static function ofFutureTime( TimeValue $timeValue ) {
52
+	public static function ofFutureTime(TimeValue $timeValue) {
53 53
 		$ret = new self;
54 54
 		$ret->timeValue = $timeValue;
55 55
 		return $ret;
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 	 * @param self[] $metadatas
60 60
 	 * @return self
61 61
 	 */
62
-	public static function merge( array $metadatas ) {
63
-		Assert::parameterElementType( self::class, $metadatas, '$metadatas' );
62
+	public static function merge(array $metadatas) {
63
+		Assert::parameterElementType(self::class, $metadatas, '$metadatas');
64 64
 		$ret = new self;
65 65
 		$entityIds = [];
66
-		foreach ( $metadatas as $metadata ) {
67
-			foreach ( $metadata->entityIds as $entityId ) {
66
+		foreach ($metadatas as $metadata) {
67
+			foreach ($metadata->entityIds as $entityId) {
68 68
 				$entityIds[$entityId->getSerialization()] = $entityId;
69 69
 			}
70
-			$ret->timeValue = self::minTimeValue( $ret->timeValue, $metadata->timeValue );
70
+			$ret->timeValue = self::minTimeValue($ret->timeValue, $metadata->timeValue);
71 71
 		}
72
-		$ret->entityIds = array_values( $entityIds );
72
+		$ret->entityIds = array_values($entityIds);
73 73
 		return $ret;
74 74
 	}
75 75
 
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 	 * @param TimeValue|null $t2
79 79
 	 * @return TimeValue|null
80 80
 	 */
81
-	private static function minTimeValue( TimeValue $t1 = null, TimeValue $t2 = null ) {
82
-		if ( $t1 === null ) {
81
+	private static function minTimeValue(TimeValue $t1 = null, TimeValue $t2 = null) {
82
+		if ($t1 === null) {
83 83
 			return $t2;
84 84
 		}
85
-		if ( $t2 === null ) {
85
+		if ($t2 === null) {
86 86
 			return $t1;
87 87
 		}
88
-		return ( new TimeValueComparer() )->getMinimum( $t1, $t2 );
88
+		return (new TimeValueComparer())->getMinimum($t1, $t2);
89 89
 	}
90 90
 
91 91
 	/**
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +47 added lines, -47 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,14 +152,14 @@  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
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ),
162
+				$config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'),
163 163
 				$loggingHelper
164 164
 			);
165 165
 		}
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 			$prefix,
171 171
 			$repo->getEntityIdParser(),
172 172
 			$repo->getStatementGuidValidator(),
173
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
173
+			$repo->getApiHelperFactory(RequestContext::getMain()),
174 174
 			$resultsBuilder,
175 175
 			$dataFactory
176 176
 		);
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 		ResultsBuilder $resultsBuilder,
197 197
 		IBufferingStatsdDataFactory $dataFactory
198 198
 	) {
199
-		parent::__construct( $main, $name, $prefix );
199
+		parent::__construct($main, $name, $prefix);
200 200
 		$this->entityIdParser = $entityIdParser;
201 201
 		$this->statementGuidValidator = $statementGuidValidator;
202
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
203
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
202
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
203
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
204 204
 		$this->resultsBuilder = $resultsBuilder;
205 205
 		$this->dataFactory = $dataFactory;
206 206
 	}
@@ -215,9 +215,9 @@  discard block
 block discarded – undo
215 215
 
216 216
 		$params = $this->extractRequestParams();
217 217
 
218
-		$this->validateParameters( $params );
219
-		$entityIds = $this->parseEntityIds( $params );
220
-		$claimIds = $this->parseClaimIds( $params );
218
+		$this->validateParameters($params);
219
+		$entityIds = $this->parseEntityIds($params);
220
+		$claimIds = $this->parseClaimIds($params);
221 221
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
222 222
 		$statuses = $params[self::PARAM_STATUS];
223 223
 
@@ -232,13 +232,13 @@  discard block
 block discarded – undo
232 232
 			)->getArray()
233 233
 		);
234 234
 		// ensure that result contains the given entity IDs even if they have no statements
235
-		foreach ( $entityIds as $entityId ) {
235
+		foreach ($entityIds as $entityId) {
236 236
 			$this->getResult()->addArrayType(
237
-				[ $this->getModuleName(), $entityId->getSerialization() ],
237
+				[$this->getModuleName(), $entityId->getSerialization()],
238 238
 				'assoc'
239 239
 			);
240 240
 		}
241
-		$this->resultBuilder->markSuccess( 1 );
241
+		$this->resultBuilder->markSuccess(1);
242 242
 	}
243 243
 
244 244
 	/**
@@ -246,24 +246,24 @@  discard block
 block discarded – undo
246 246
 	 *
247 247
 	 * @return EntityId[]
248 248
 	 */
249
-	private function parseEntityIds( array $params ) {
249
+	private function parseEntityIds(array $params) {
250 250
 		$ids = $params[self::PARAM_ID];
251 251
 
252
-		if ( $ids === null ) {
252
+		if ($ids === null) {
253 253
 			return [];
254
-		} elseif ( $ids === [] ) {
254
+		} elseif ($ids === []) {
255 255
 			$this->errorReporter->dieError(
256
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
256
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
257 257
 		}
258 258
 
259
-		return array_map( function ( $id ) {
259
+		return array_map(function($id) {
260 260
 			try {
261
-				return $this->entityIdParser->parse( $id );
262
-			} catch ( EntityIdParsingException $e ) {
261
+				return $this->entityIdParser->parse($id);
262
+			} catch (EntityIdParsingException $e) {
263 263
 				$this->errorReporter->dieError(
264
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
264
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
265 265
 			}
266
-		}, $ids );
266
+		}, $ids);
267 267
 	}
268 268
 
269 269
 	/**
@@ -271,35 +271,35 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @return string[]
273 273
 	 */
274
-	private function parseClaimIds( array $params ) {
274
+	private function parseClaimIds(array $params) {
275 275
 		$ids = $params[self::PARAM_CLAIM_ID];
276 276
 
277
-		if ( $ids === null ) {
277
+		if ($ids === null) {
278 278
 			return [];
279
-		} elseif ( $ids === [] ) {
279
+		} elseif ($ids === []) {
280 280
 			$this->errorReporter->dieError(
281
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
281
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
282 282
 		}
283 283
 
284
-		foreach ( $ids as $id ) {
285
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
284
+		foreach ($ids as $id) {
285
+			if (!$this->statementGuidValidator->validate($id)) {
286 286
 				$this->errorReporter->dieError(
287
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
287
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
288 288
 			}
289 289
 		}
290 290
 
291 291
 		return $ids;
292 292
 	}
293 293
 
294
-	private function validateParameters( array $params ) {
295
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
296
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
294
+	private function validateParameters(array $params) {
295
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
296
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
297 297
 		) {
298 298
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
299 299
 			$this->errorReporter->dieError(
300 300
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
301 301
 		}
302
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
302
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
303 303
 			$paramId = self::PARAM_ID;
304 304
 			$paramClaimId = self::PARAM_CLAIM_ID;
305 305
 			$this->errorReporter->dieError(
@@ -340,11 +340,11 @@  discard block
 block discarded – undo
340 340
 				],
341 341
 				ApiBase::PARAM_ISMULTI => true,
342 342
 				ApiBase::PARAM_ALL => true,
343
-				ApiBase::PARAM_DFLT => implode( '|', [
343
+				ApiBase::PARAM_DFLT => implode('|', [
344 344
 					CheckResult::STATUS_VIOLATION,
345 345
 					CheckResult::STATUS_WARNING,
346 346
 					CheckResult::STATUS_BAD_PARAMETERS,
347
-				] ),
347
+				]),
348 348
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
349 349
 			],
350 350
 		];
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/LoggingHelper.php 1 patch
Spacing   +20 added lines, -20 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
 
@@ -181,16 +181,16 @@  discard block
 block discarded – undo
181 181
 	 * @param EntityId[] $entityIds
182 182
 	 * @param int $maxRevisionIds
183 183
 	 */
184
-	public function logHugeDependencyMetadata( array $entityIds, $maxRevisionIds ) {
184
+	public function logHugeDependencyMetadata(array $entityIds, $maxRevisionIds) {
185 185
 		$this->logger->log(
186 186
 			'warning',
187
-			'Dependency metadata for constraint check result has huge set of entity IDs ' .
188
-			'(count ' . count( $entityIds ) . ', limit ' . $maxRevisionIds . '); ' .
187
+			'Dependency metadata for constraint check result has huge set of entity IDs '.
188
+			'(count '.count($entityIds).', limit '.$maxRevisionIds.'); '.
189 189
 			'caching disabled for this check result.',
190 190
 			[
191 191
 				'loggingMethod' => __METHOD__,
192 192
 				'entityIds' => array_map(
193
-					function ( EntityId $entityId ) {
193
+					function(EntityId $entityId) {
194 194
 						return $entityId->getSerialization();
195 195
 					},
196 196
 					$entityIds
Please login to merge, or discard this patch.
src/Api/CachingResultsBuilder.php 1 patch
Spacing   +69 added lines, -70 removed lines patch added patch discarded remove patch
@@ -151,30 +151,30 @@  discard block
 block discarded – undo
151 151
 	) {
152 152
 		$results = [];
153 153
 		$metadatas = [];
154
-		if ( $this->canUseStoredResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
154
+		if ($this->canUseStoredResults($entityIds, $claimIds, $constraintIds, $statuses)) {
155 155
 			$storedEntityIds = [];
156
-			foreach ( $entityIds as $entityId ) {
157
-				$storedResults = $this->getStoredResults( $entityId );
158
-				if ( $storedResults !== null ) {
159
-					$this->loggingHelper->logCheckConstraintsCacheHit( $entityId );
156
+			foreach ($entityIds as $entityId) {
157
+				$storedResults = $this->getStoredResults($entityId);
158
+				if ($storedResults !== null) {
159
+					$this->loggingHelper->logCheckConstraintsCacheHit($entityId);
160 160
 					$results += $storedResults->getArray();
161 161
 					$metadatas[] = $storedResults->getMetadata();
162 162
 					$storedEntityIds[] = $entityId;
163 163
 				}
164 164
 			}
165
-			$entityIds = array_values( array_diff( $entityIds, $storedEntityIds ) );
165
+			$entityIds = array_values(array_diff($entityIds, $storedEntityIds));
166 166
 		}
167
-		if ( $entityIds !== [] || $claimIds !== [] ) {
168
-			if ( $entityIds !== [] ) {
169
-				$this->loggingHelper->logCheckConstraintsCacheMisses( $entityIds );
167
+		if ($entityIds !== [] || $claimIds !== []) {
168
+			if ($entityIds !== []) {
169
+				$this->loggingHelper->logCheckConstraintsCacheMisses($entityIds);
170 170
 			}
171
-			$response = $this->getAndStoreResults( $entityIds, $claimIds, $constraintIds, $statuses );
171
+			$response = $this->getAndStoreResults($entityIds, $claimIds, $constraintIds, $statuses);
172 172
 			$results += $response->getArray();
173 173
 			$metadatas[] = $response->getMetadata();
174 174
 		}
175 175
 		return new CachedCheckConstraintsResponse(
176 176
 			$results,
177
-			Metadata::merge( $metadatas )
177
+			Metadata::merge($metadatas)
178 178
 		);
179 179
 	}
180 180
 
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
 		array $constraintIds = null,
204 204
 		array $statuses
205 205
 	) {
206
-		if ( $claimIds !== [] ) {
206
+		if ($claimIds !== []) {
207 207
 			return false;
208 208
 		}
209
-		if ( $constraintIds !== null ) {
209
+		if ($constraintIds !== null) {
210 210
 			return false;
211 211
 		}
212
-		if ( $statuses != $this->cachedStatuses ) {
212
+		if ($statuses != $this->cachedStatuses) {
213 213
 			return false;
214 214
 		}
215 215
 		return true;
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
 		array $constraintIds = null,
229 229
 		array $statuses
230 230
 	) {
231
-		$results = $this->resultsBuilder->getResults( $entityIds, $claimIds, $constraintIds, $statuses );
231
+		$results = $this->resultsBuilder->getResults($entityIds, $claimIds, $constraintIds, $statuses);
232 232
 
233
-		if ( $this->canStoreResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
234
-			foreach ( $entityIds as $entityId ) {
233
+		if ($this->canStoreResults($entityIds, $claimIds, $constraintIds, $statuses)) {
234
+			foreach ($entityIds as $entityId) {
235 235
 				$latestRevisionIds = $this->getLatestRevisionIds(
236 236
 					$results->getMetadata()->getDependencyMetadata()->getEntityIds()
237 237
 				);
238
-				if ( $latestRevisionIds === null ) {
238
+				if ($latestRevisionIds === null) {
239 239
 					continue;
240 240
 				}
241 241
 				$value = [
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 					'latestRevisionIds' => $latestRevisionIds,
244 244
 				];
245 245
 				$futureTime = $results->getMetadata()->getDependencyMetadata()->getFutureTime();
246
-				if ( $futureTime !== null ) {
246
+				if ($futureTime !== null) {
247 247
 					$value['futureTime'] = $futureTime->getArrayValue();
248 248
 				}
249
-				$this->cache->set( $entityId, $value, $this->ttlInSeconds );
249
+				$this->cache->set($entityId, $value, $this->ttlInSeconds);
250 250
 			}
251 251
 		}
252 252
 
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
 		array $constraintIds = null,
279 279
 		array $statuses
280 280
 	) {
281
-		if ( $constraintIds !== null ) {
281
+		if ($constraintIds !== null) {
282 282
 			return false;
283 283
 		}
284
-		if ( $statuses != $this->cachedStatuses ) {
284
+		if ($statuses != $this->cachedStatuses) {
285 285
 			return false;
286 286
 		}
287 287
 		return true;
@@ -294,45 +294,44 @@  discard block
 block discarded – undo
294 294
 	public function getStoredResults(
295 295
 		EntityId $entityId
296 296
 	) {
297
-		$value = $this->cache->get( $entityId, $curTTL, [], $asOf );
298
-		$now = call_user_func( $this->microtime, true );
297
+		$value = $this->cache->get($entityId, $curTTL, [], $asOf);
298
+		$now = call_user_func($this->microtime, true);
299 299
 
300
-		if ( $value === false ) {
300
+		if ($value === false) {
301 301
 			return null;
302 302
 		}
303 303
 
304
-		$ageInSeconds = (int)ceil( $now - $asOf );
304
+		$ageInSeconds = (int) ceil($now - $asOf);
305 305
 
306 306
 		$dependedEntityIds = array_map(
307
-			[ $this->entityIdParser, "parse" ],
308
-			array_keys( $value['latestRevisionIds'] )
307
+			[$this->entityIdParser, "parse"],
308
+			array_keys($value['latestRevisionIds'])
309 309
 		);
310 310
 
311
-		if ( $value['latestRevisionIds'] !== $this->getLatestRevisionIds( $dependedEntityIds ) ) {
311
+		if ($value['latestRevisionIds'] !== $this->getLatestRevisionIds($dependedEntityIds)) {
312 312
 			return null;
313 313
 		}
314 314
 
315
-		if ( array_key_exists( 'futureTime', $value ) ) {
316
-			$futureTime = TimeValue::newFromArray( $value['futureTime'] );
317
-			if ( !$this->timeValueComparer->isFutureTime( $futureTime ) ) {
315
+		if (array_key_exists('futureTime', $value)) {
316
+			$futureTime = TimeValue::newFromArray($value['futureTime']);
317
+			if (!$this->timeValueComparer->isFutureTime($futureTime)) {
318 318
 				return null;
319 319
 			}
320
-			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime( $futureTime );
320
+			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime($futureTime);
321 321
 		} else {
322 322
 			$futureTimeDependencyMetadata = DependencyMetadata::blank();
323 323
 		}
324 324
 
325 325
 		$cachingMetadata = $ageInSeconds > 0 ?
326
-			CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) :
327
-			CachingMetadata::fresh();
326
+			CachingMetadata::ofMaximumAgeInSeconds($ageInSeconds) : CachingMetadata::fresh();
328 327
 
329
-		if ( is_array( $value['results'] ) ) {
330
-			array_walk( $value['results'], [ $this, 'updateCachingMetadata' ], $cachingMetadata );
328
+		if (is_array($value['results'])) {
329
+			array_walk($value['results'], [$this, 'updateCachingMetadata'], $cachingMetadata);
331 330
 		}
332 331
 
333 332
 		return new CachedCheckConstraintsResponse(
334
-			[ $entityId->getSerialization() => $value['results'] ],
335
-			$this->mergeStoredMetadata( $cachingMetadata, $dependedEntityIds, $futureTimeDependencyMetadata )
333
+			[$entityId->getSerialization() => $value['results']],
334
+			$this->mergeStoredMetadata($cachingMetadata, $dependedEntityIds, $futureTimeDependencyMetadata)
336 335
 		);
337 336
 	}
338 337
 
@@ -347,19 +346,19 @@  discard block
 block discarded – undo
347 346
 		array $dependedEntityIds,
348 347
 		DependencyMetadata $futureTimeDependencyMetadata = null
349 348
 	) {
350
-		return Metadata::merge( [
351
-			Metadata::ofCachingMetadata( $cachingMetadata ),
352
-			Metadata::ofDependencyMetadata( array_reduce(
349
+		return Metadata::merge([
350
+			Metadata::ofCachingMetadata($cachingMetadata),
351
+			Metadata::ofDependencyMetadata(array_reduce(
353 352
 				$dependedEntityIds,
354
-				function( DependencyMetadata $metadata, EntityId $entityId ) {
355
-					return DependencyMetadata::merge( [
353
+				function(DependencyMetadata $metadata, EntityId $entityId) {
354
+					return DependencyMetadata::merge([
356 355
 						$metadata,
357
-						DependencyMetadata::ofEntityId( $entityId )
358
-					] );
356
+						DependencyMetadata::ofEntityId($entityId)
357
+					]);
359 358
 				},
360 359
 				$futureTimeDependencyMetadata
361
-			) )
362
-		] );
360
+			))
361
+		]);
363 362
 	}
364 363
 
365 364
 	/**
@@ -367,14 +366,14 @@  discard block
 block discarded – undo
367 366
 	 * @return int[]|null array from entity ID serializations to revision ID,
368 367
 	 * or null to indicate that not all revision IDs could be loaded
369 368
 	 */
370
-	private function getLatestRevisionIds( array $entityIds ) {
371
-		if ( $entityIds === [] ) {
369
+	private function getLatestRevisionIds(array $entityIds) {
370
+		if ($entityIds === []) {
372 371
 			$this->loggingHelper->logEmptyDependencyMetadata();
373 372
 			return [];
374 373
 		}
375
-		if ( count( $entityIds ) > $this->maxRevisionIds ) {
374
+		if (count($entityIds) > $this->maxRevisionIds) {
376 375
 			// one of those entities will probably be edited soon, so might as well skip caching
377
-			$this->loggingHelper->logHugeDependencyMetadata( $entityIds, $this->maxRevisionIds );
376
+			$this->loggingHelper->logHugeDependencyMetadata($entityIds, $this->maxRevisionIds);
378 377
 			return null;
379 378
 		}
380 379
 
@@ -382,11 +381,11 @@  discard block
 block discarded – undo
382 381
 			$entityIds,
383 382
 			EntityRevisionLookup::LATEST_FROM_REPLICA
384 383
 		);
385
-		if ( $this->hasFalseElements( $revisionInformations ) ) {
384
+		if ($this->hasFalseElements($revisionInformations)) {
386 385
 			return null;
387 386
 		}
388 387
 		$latestRevisionIds = [];
389
-		foreach ( $revisionInformations as $serialization => $revisionInformation ) {
388
+		foreach ($revisionInformations as $serialization => $revisionInformation) {
390 389
 			$latestRevisionIds[$serialization] = $revisionInformation->page_latest;
391 390
 		}
392 391
 		return $latestRevisionIds;
@@ -396,31 +395,31 @@  discard block
 block discarded – undo
396 395
 	 * @param array $array
397 396
 	 * @return bool
398 397
 	 */
399
-	private function hasFalseElements( array $array ) {
400
-		return in_array( false, $array, true );
398
+	private function hasFalseElements(array $array) {
399
+		return in_array(false, $array, true);
401 400
 	}
402 401
 
403
-	public function updateCachingMetadata( &$element, $key, CachingMetadata $cachingMetadata ) {
404
-		if ( $key === 'cached' ) {
405
-			$element = CachingMetadata::merge( [
402
+	public function updateCachingMetadata(&$element, $key, CachingMetadata $cachingMetadata) {
403
+		if ($key === 'cached') {
404
+			$element = CachingMetadata::merge([
406 405
 				$cachingMetadata,
407
-				CachingMetadata::ofArray( $element ),
408
-			] )->toArray();
406
+				CachingMetadata::ofArray($element),
407
+			])->toArray();
409 408
 		}
410 409
 		if (
411
-			is_array( $element ) &&
412
-			array_key_exists( 'constraint', $element ) &&
413
-			in_array( $element['constraint']['type'], $this->possiblyStaleConstraintTypes, true )
410
+			is_array($element) &&
411
+			array_key_exists('constraint', $element) &&
412
+			in_array($element['constraint']['type'], $this->possiblyStaleConstraintTypes, true)
414 413
 		) {
415
-			$element['cached'] = CachingMetadata::merge( [
414
+			$element['cached'] = CachingMetadata::merge([
416 415
 				$cachingMetadata,
417 416
 				CachingMetadata::ofArray(
418
-					array_key_exists( 'cached', $element ) ? $element['cached'] : null
417
+					array_key_exists('cached', $element) ? $element['cached'] : null
419 418
 				),
420
-			] )->toArray();
419
+			])->toArray();
421 420
 		}
422
-		if ( is_array( $element ) ) {
423
-			array_walk( $element, [ $this, __FUNCTION__ ], $cachingMetadata );
421
+		if (is_array($element)) {
422
+			array_walk($element, [$this, __FUNCTION__], $cachingMetadata);
424 423
 		}
425 424
 	}
426 425
 
@@ -429,7 +428,7 @@  discard block
 block discarded – undo
429 428
 	 *
430 429
 	 * @param callable $microtime
431 430
 	 */
432
-	public function setMicrotimeFunction( callable $microtime ) {
431
+	public function setMicrotimeFunction(callable $microtime) {
433 432
 		$this->microtime = $microtime;
434 433
 	}
435 434
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ApiV2ContextCursor.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,29 +36,29 @@  discard block
 block discarded – undo
36 36
 		$statementPropertyId,
37 37
 		$statementGuid
38 38
 	) {
39
-		if ( !array_key_exists( $entityId, $container ) ) {
39
+		if (!array_key_exists($entityId, $container)) {
40 40
 			$container[$entityId] = [];
41 41
 		}
42 42
 		$entityContainer = &$container[$entityId];
43 43
 
44
-		if ( !array_key_exists( 'claims', $entityContainer ) ) {
44
+		if (!array_key_exists('claims', $entityContainer)) {
45 45
 			$entityContainer['claims'] = [];
46 46
 		}
47 47
 		$claimsContainer = &$entityContainer['claims'];
48 48
 
49
-		if ( !array_key_exists( $statementPropertyId, $claimsContainer ) ) {
49
+		if (!array_key_exists($statementPropertyId, $claimsContainer)) {
50 50
 			$claimsContainer[$statementPropertyId] = [];
51 51
 		}
52 52
 		$propertyContainer = &$claimsContainer[$statementPropertyId];
53 53
 
54
-		foreach ( $propertyContainer as &$statement ) {
55
-			if ( $statement['id'] === $statementGuid ) {
54
+		foreach ($propertyContainer as &$statement) {
55
+			if ($statement['id'] === $statementGuid) {
56 56
 				$statementArray = &$statement;
57 57
 				break;
58 58
 			}
59 59
 		}
60
-		if ( !isset( $statementArray ) ) {
61
-			$statementArray = [ 'id' => $statementGuid ];
60
+		if (!isset($statementArray)) {
61
+			$statementArray = ['id' => $statementGuid];
62 62
 			$propertyContainer[] = &$statementArray;
63 63
 		}
64 64
 
@@ -73,19 +73,19 @@  discard block
 block discarded – undo
73 73
 	 * @param array[] &$container
74 74
 	 * @return array
75 75
 	 */
76
-	abstract protected function &getMainArray( array &$container );
76
+	abstract protected function &getMainArray(array &$container);
77 77
 
78 78
 	/**
79 79
 	 * @param array|null $result
80 80
 	 * @param array[] &$container
81 81
 	 */
82
-	public function storeCheckResultInArray( array $result = null, array &$container ) {
83
-		$mainArray = &$this->getMainArray( $container );
84
-		if ( !array_key_exists( 'results', $mainArray ) ) {
82
+	public function storeCheckResultInArray(array $result = null, array &$container) {
83
+		$mainArray = &$this->getMainArray($container);
84
+		if (!array_key_exists('results', $mainArray)) {
85 85
 			$mainArray['results'] = [];
86 86
 		}
87 87
 
88
-		if ( $result !== null ) {
88
+		if ($result !== null) {
89 89
 			$mainArray['results'][] = $result;
90 90
 		}
91 91
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ContextCursor.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,6 +86,6 @@
 block discarded – undo
86 86
 	 * @param array|null $result
87 87
 	 * @param array[] &$container
88 88
 	 */
89
-	public function storeCheckResultInArray( array $result = null, array &$container );
89
+	public function storeCheckResultInArray(array $result = null, array &$container);
90 90
 
91 91
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/ReferenceContext.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 		Reference $reference,
31 31
 		Snak $snak
32 32
 	) {
33
-		parent::__construct( $entity, $snak );
33
+		parent::__construct($entity, $snak);
34 34
 		$this->statement = $statement;
35 35
 		$this->reference = $reference;
36 36
 	}
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 
42 42
 	public function getSnakGroup() {
43 43
 		$snaks = $this->reference->getSnaks();
44
-		return array_values( $snaks->getArrayCopy() );
44
+		return array_values($snaks->getArrayCopy());
45 45
 	}
46 46
 
47 47
 	public function getCursor() {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		);
56 56
 	}
57 57
 
58
-	protected function &getMainArray( array &$container ) {
58
+	protected function &getMainArray(array &$container) {
59 59
 		$statementArray = &$this->getStatementArray(
60 60
 			$container,
61 61
 			$this->entity->getId()->getSerialization(),
@@ -63,38 +63,38 @@  discard block
 block discarded – undo
63 63
 			$this->statement->getGuid()
64 64
 		);
65 65
 
66
-		if ( !array_key_exists( 'references', $statementArray ) ) {
66
+		if (!array_key_exists('references', $statementArray)) {
67 67
 			$statementArray['references'] = [];
68 68
 		}
69 69
 		$referencesArray = &$statementArray['references'];
70 70
 
71
-		foreach ( $referencesArray as &$potentialReferenceArray ) {
72
-			if ( $potentialReferenceArray['hash'] === $this->reference->getHash() ) {
71
+		foreach ($referencesArray as &$potentialReferenceArray) {
72
+			if ($potentialReferenceArray['hash'] === $this->reference->getHash()) {
73 73
 				$referenceArray = &$potentialReferenceArray;
74 74
 				break;
75 75
 			}
76 76
 		}
77
-		if ( !isset( $referenceArray ) ) {
78
-			$referenceArray = [ 'hash' => $this->reference->getHash(), 'snaks' => [] ];
77
+		if (!isset($referenceArray)) {
78
+			$referenceArray = ['hash' => $this->reference->getHash(), 'snaks' => []];
79 79
 			$referencesArray[] = &$referenceArray;
80 80
 		}
81 81
 
82 82
 		$snaksArray = &$referenceArray['snaks'];
83 83
 
84 84
 		$propertyId = $this->getSnak()->getPropertyId()->getSerialization();
85
-		if ( !array_key_exists( $propertyId, $snaksArray ) ) {
85
+		if (!array_key_exists($propertyId, $snaksArray)) {
86 86
 			$snaksArray[$propertyId] = [];
87 87
 		}
88 88
 		$propertyArray = &$snaksArray[$propertyId];
89 89
 
90
-		foreach ( $propertyArray as &$potentialSnakArray ) {
91
-			if ( $potentialSnakArray['hash'] === $this->getSnak()->getHash() ) {
90
+		foreach ($propertyArray as &$potentialSnakArray) {
91
+			if ($potentialSnakArray['hash'] === $this->getSnak()->getHash()) {
92 92
 				$snakArray = &$potentialSnakArray;
93 93
 				break;
94 94
 			}
95 95
 		}
96
-		if ( !isset( $snakArray ) ) {
97
-			$snakArray = [ 'hash' => $this->getSnak()->getHash() ];
96
+		if (!isset($snakArray)) {
97
+			$snakArray = ['hash' => $this->getSnak()->getHash()];
98 98
 			$propertyArray[] = &$snakArray;
99 99
 		}
100 100
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/MainSnakContext.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
 	 */
21 21
 	private $statement;
22 22
 
23
-	public function __construct( EntityDocument $entity, Statement $statement ) {
24
-		Assert::parameterType( StatementListProvider::class, $entity, '$entity' );
25
-		parent::__construct( $entity, $statement->getMainSnak() );
23
+	public function __construct(EntityDocument $entity, Statement $statement) {
24
+		Assert::parameterType(StatementListProvider::class, $entity, '$entity');
25
+		parent::__construct($entity, $statement->getMainSnak());
26 26
 
27 27
 		$this->statement = $statement;
28 28
 	}
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		/** @var StatementList $statements */
44 44
 		$statements = $this->entity->getStatements();
45 45
 		return $statements
46
-			->getByRank( [ Statement::RANK_NORMAL, Statement::RANK_PREFERRED ] )
46
+			->getByRank([Statement::RANK_NORMAL, Statement::RANK_PREFERRED])
47 47
 			->getMainSnaks();
48 48
 	}
49 49
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		);
57 57
 	}
58 58
 
59
-	protected function &getMainArray( array &$container ) {
59
+	protected function &getMainArray(array &$container) {
60 60
 		$statementArray = &$this->getStatementArray(
61 61
 			$container,
62 62
 			$this->entity->getId()->getSerialization(),
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 			$this->statement->getGuid()
65 65
 		);
66 66
 
67
-		if ( !array_key_exists( 'mainsnak', $statementArray ) ) {
68
-			$statementArray['mainsnak'] = [ 'hash' => $this->statement->getMainSnak()->getHash() ];
67
+		if (!array_key_exists('mainsnak', $statementArray)) {
68
+			$statementArray['mainsnak'] = ['hash' => $this->statement->getMainSnak()->getHash()];
69 69
 		}
70 70
 		$mainsnakArray = &$statementArray['mainsnak'];
71 71
 
Please login to merge, or discard this patch.
src/ConstraintCheck/Context/QualifierContext.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 		Statement $statement,
24 24
 		Snak $snak
25 25
 	) {
26
-		parent::__construct( $entity, $snak );
26
+		parent::__construct($entity, $snak);
27 27
 		$this->statement = $statement;
28 28
 	}
29 29
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 
34 34
 	public function getSnakGroup() {
35 35
 		$snaks = $this->statement->getQualifiers();
36
-		return array_values( $snaks->getArrayCopy() );
36
+		return array_values($snaks->getArrayCopy());
37 37
 	}
38 38
 
39 39
 	public function getCursor() {
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		);
47 47
 	}
48 48
 
49
-	protected function &getMainArray( array &$container ) {
49
+	protected function &getMainArray(array &$container) {
50 50
 		$statementArray = &$this->getStatementArray(
51 51
 			$container,
52 52
 			$this->entity->getId()->getSerialization(),
@@ -54,25 +54,25 @@  discard block
 block discarded – undo
54 54
 			$this->statement->getGuid()
55 55
 		);
56 56
 
57
-		if ( !array_key_exists( 'qualifiers', $statementArray ) ) {
57
+		if (!array_key_exists('qualifiers', $statementArray)) {
58 58
 			$statementArray['qualifiers'] = [];
59 59
 		}
60 60
 		$qualifiersArray = &$statementArray['qualifiers'];
61 61
 
62 62
 		$propertyId = $this->getSnak()->getPropertyId()->getSerialization();
63
-		if ( !array_key_exists( $propertyId, $qualifiersArray ) ) {
63
+		if (!array_key_exists($propertyId, $qualifiersArray)) {
64 64
 			$qualifiersArray[$propertyId] = [];
65 65
 		}
66 66
 		$propertyArray = &$qualifiersArray[$propertyId];
67 67
 
68
-		foreach ( $propertyArray as &$potentialQualifierArray ) {
69
-			if ( $potentialQualifierArray['hash'] === $this->getSnak()->getHash() ) {
68
+		foreach ($propertyArray as &$potentialQualifierArray) {
69
+			if ($potentialQualifierArray['hash'] === $this->getSnak()->getHash()) {
70 70
 				$qualifierArray = &$potentialQualifierArray;
71 71
 				break;
72 72
 			}
73 73
 		}
74
-		if ( !isset( $qualifierArray ) ) {
75
-			$qualifierArray = [ 'hash' => $this->getSnak()->getHash() ];
74
+		if (!isset($qualifierArray)) {
75
+			$qualifierArray = ['hash' => $this->getSnak()->getHash()];
76 76
 			$propertyArray[] = &$qualifierArray;
77 77
 		}
78 78
 
Please login to merge, or discard this patch.