Completed
Push — master ( 9e4e08...942668 )
by
unknown
05:54
created
src/Api/CheckingResultsBuilder.php 1 patch
Spacing   +29 added lines, -30 removed lines patch added patch discarded remove patch
@@ -75,54 +75,53 @@  discard block
 block discarded – undo
75 75
 	) {
76 76
 		$response = [];
77 77
 		$metadatas = [];
78
-		$statusesFlipped = array_flip( $statuses );
79
-		foreach ( $entityIds as $entityId ) {
78
+		$statusesFlipped = array_flip($statuses);
79
+		foreach ($entityIds as $entityId) {
80 80
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnEntityId(
81 81
 				$entityId,
82 82
 				$constraintIds,
83
-				[ $this, 'defaultResults' ]
83
+				[$this, 'defaultResults']
84 84
 			);
85
-			$results = array_filter( $results, $this->statusSelected( $statusesFlipped ) );
86
-			foreach ( $results as $result ) {
85
+			$results = array_filter($results, $this->statusSelected($statusesFlipped));
86
+			foreach ($results as $result) {
87 87
 				$metadatas[] = $result->getMetadata();
88
-				$resultArray = $this->checkResultToArray( $result );
89
-				$result->getContext()->storeCheckResultInArray( $resultArray, $response );
88
+				$resultArray = $this->checkResultToArray($result);
89
+				$result->getContext()->storeCheckResultInArray($resultArray, $response);
90 90
 			}
91 91
 		}
92
-		foreach ( $claimIds as $claimId ) {
92
+		foreach ($claimIds as $claimId) {
93 93
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnClaimId(
94 94
 				$claimId,
95 95
 				$constraintIds,
96
-				[ $this, 'defaultResults' ]
96
+				[$this, 'defaultResults']
97 97
 			);
98
-			$results = array_filter( $results, $this->statusSelected( $statusesFlipped ) );
99
-			foreach ( $results as $result ) {
98
+			$results = array_filter($results, $this->statusSelected($statusesFlipped));
99
+			foreach ($results as $result) {
100 100
 				$metadatas[] = $result->getMetadata();
101
-				$resultArray = $this->checkResultToArray( $result );
102
-				$result->getContext()->storeCheckResultInArray( $resultArray, $response );
101
+				$resultArray = $this->checkResultToArray($result);
102
+				$result->getContext()->storeCheckResultInArray($resultArray, $response);
103 103
 			}
104 104
 		}
105 105
 		return new CachedCheckConstraintsResponse(
106 106
 			$response,
107
-			Metadata::merge( $metadatas )
107
+			Metadata::merge($metadatas)
108 108
 		);
109 109
 	}
110 110
 
111
-	public function defaultResults( Context $context ) {
111
+	public function defaultResults(Context $context) {
112 112
 		return $context->getType() === Context::TYPE_STATEMENT ?
113
-			[ new NullResult( $context ) ] :
114
-			[];
113
+			[new NullResult($context)] : [];
115 114
 	}
116 115
 
117
-	public function statusSelected( array $statusesFlipped ) {
118
-		return function( CheckResult $result ) use ( $statusesFlipped ) {
119
-			return array_key_exists( $result->getStatus(), $statusesFlipped ) ||
116
+	public function statusSelected(array $statusesFlipped) {
117
+		return function(CheckResult $result) use ($statusesFlipped) {
118
+			return array_key_exists($result->getStatus(), $statusesFlipped) ||
120 119
 				$result instanceof NullResult;
121 120
 		};
122 121
 	}
123 122
 
124
-	public function checkResultToArray( CheckResult $checkResult ) {
125
-		if ( $checkResult instanceof NullResult ) {
123
+	public function checkResultToArray(CheckResult $checkResult) {
124
+		if ($checkResult instanceof NullResult) {
126 125
 			return null;
127 126
 		}
128 127
 
@@ -130,10 +129,10 @@  discard block
 block discarded – undo
130 129
 		$typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId();
131 130
 		$constraintPropertyId = $checkResult->getContext()->getSnak()->getPropertyId();
132 131
 
133
-		$title = $this->entityTitleLookup->getTitleForId( $constraintPropertyId );
134
-		$typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) );
132
+		$title = $this->entityTitleLookup->getTitleForId($constraintPropertyId);
133
+		$typeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($typeItemId));
135 134
 		// TODO link to the statement when possible (T169224)
136
-		$link = $title->getFullURL() . '#' . $this->config->get( 'WBQualityConstraintsPropertyConstraintId' );
135
+		$link = $title->getFullURL().'#'.$this->config->get('WBQualityConstraintsPropertyConstraintId');
137 136
 
138 137
 		$constraint = [
139 138
 			'id' => $constraintId,
@@ -142,11 +141,11 @@  discard block
 block discarded – undo
142 141
 			'link' => $link,
143 142
 			'discussLink' => $title->getTalkPage()->getFullURL(),
144 143
 		];
145
-		if ( $this->config->get( 'WBQualityConstraintsIncludeDetailInApi' ) ) {
144
+		if ($this->config->get('WBQualityConstraintsIncludeDetailInApi')) {
146 145
 			$parameters = $checkResult->getParameters();
147 146
 			$constraint += [
148 147
 				'detail' => $parameters,
149
-				'detailHTML' => $this->constraintParameterRenderer->formatParameters( $parameters ),
148
+				'detailHTML' => $this->constraintParameterRenderer->formatParameters($parameters),
150 149
 			];
151 150
 		}
152 151
 
@@ -156,14 +155,14 @@  discard block
 block discarded – undo
156 155
 			'constraint' => $constraint
157 156
 		];
158 157
 		$message = $checkResult->getMessage();
159
-		if ( $message ) {
158
+		if ($message) {
160 159
 			$result['message-html'] = $message;
161 160
 		}
162
-		if ( $checkResult->getContext()->getType() === Context::TYPE_STATEMENT ) {
161
+		if ($checkResult->getContext()->getType() === Context::TYPE_STATEMENT) {
163 162
 			$result['claim'] = $checkResult->getContext()->getSnakStatement()->getGuid();
164 163
 		}
165 164
 		$cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray();
166
-		if ( $cachingMetadataArray !== null ) {
165
+		if ($cachingMetadataArray !== null) {
167 166
 			$result['cached'] = $cachingMetadataArray;
168 167
 		}
169 168
 
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -75,21 +75,21 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return self
77 77
 	 */
78
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
78
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
79 79
 		$repo = WikibaseRepo::getDefaultInstance();
80 80
 
81 81
 		$language = $repo->getUserLanguage();
82 82
 		$formatterOptions = new FormatterOptions();
83
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
83
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
84 84
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
85
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
85
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
86 86
 
87 87
 		$languageFallbackLabelDescriptionLookupFactory = $repo->getLanguageFallbackLabelDescriptionLookupFactory();
88
-		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup( $language );
88
+		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup($language);
89 89
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
90
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
90
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
91 91
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
92
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
92
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
93 93
 		$config = MediaWikiServices::getInstance()->getMainConfig();
94 94
 		$titleParser = MediaWikiServices::getInstance()->getTitleParser();
95 95
 		$unitConverter = $repo->getUnitConverter();
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 			$constraintParameterRenderer,
125 125
 			$config
126 126
 		);
127
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
127
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
128 128
 			$wikiPageEntityMetaDataAccessor = new WikiPageEntityMetaDataLookup(
129 129
 				$repo->getEntityNamespaceLookup()
130 130
 			);
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
 				ResultsCache::getDefaultInstance(),
136 136
 				$wikiPageEntityMetaDataAccessor,
137 137
 				$entityIdParser,
138
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
138
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
139 139
 				[
140
-					$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
141
-					$config->get( 'WBQualityConstraintsTypeConstraintId' ),
142
-					$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
143
-					$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
140
+					$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
141
+					$config->get('WBQualityConstraintsTypeConstraintId'),
142
+					$config->get('WBQualityConstraintsValueTypeConstraintId'),
143
+					$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
144 144
 				],
145 145
 				$dataFactory
146 146
 			);
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 			$prefix,
153 153
 			$repo->getEntityIdParser(),
154 154
 			$repo->getStatementGuidValidator(),
155
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
155
+			$repo->getApiHelperFactory(RequestContext::getMain()),
156 156
 			$resultsBuilder,
157 157
 			$dataFactory
158 158
 		);
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 		ResultsBuilder $resultsBuilder,
179 179
 		IBufferingStatsdDataFactory $dataFactory
180 180
 	) {
181
-		parent::__construct( $main, $name, $prefix );
181
+		parent::__construct($main, $name, $prefix);
182 182
 		$this->entityIdParser = $entityIdParser;
183 183
 		$this->statementGuidValidator = $statementGuidValidator;
184
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
185
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
184
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
185
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
186 186
 		$this->resultsBuilder = $resultsBuilder;
187 187
 		$this->dataFactory = $dataFactory;
188 188
 	}
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 
198 198
 		$params = $this->extractRequestParams();
199 199
 
200
-		$this->validateParameters( $params );
201
-		$entityIds = $this->parseEntityIds( $params );
202
-		$claimIds = $this->parseClaimIds( $params );
200
+		$this->validateParameters($params);
201
+		$entityIds = $this->parseEntityIds($params);
202
+		$claimIds = $this->parseClaimIds($params);
203 203
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
204 204
 
205 205
 		$this->getResult()->addValue(
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
 			)->getArray()
223 223
 		);
224 224
 		// ensure that result contains the given entity IDs even if they have no statements
225
-		foreach ( $entityIds as $entityId ) {
225
+		foreach ($entityIds as $entityId) {
226 226
 			$this->getResult()->addArrayType(
227
-				[ $this->getModuleName(), $entityId->getSerialization() ],
227
+				[$this->getModuleName(), $entityId->getSerialization()],
228 228
 				'assoc'
229 229
 			);
230 230
 		}
231
-		$this->resultBuilder->markSuccess( 1 );
231
+		$this->resultBuilder->markSuccess(1);
232 232
 	}
233 233
 
234 234
 	/**
@@ -236,24 +236,24 @@  discard block
 block discarded – undo
236 236
 	 *
237 237
 	 * @return EntityId[]
238 238
 	 */
239
-	private function parseEntityIds( array $params ) {
239
+	private function parseEntityIds(array $params) {
240 240
 		$ids = $params[self::PARAM_ID];
241 241
 
242
-		if ( $ids === null ) {
242
+		if ($ids === null) {
243 243
 			return [];
244
-		} elseif ( $ids === [] ) {
244
+		} elseif ($ids === []) {
245 245
 			$this->errorReporter->dieError(
246
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
246
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
247 247
 		}
248 248
 
249
-		return array_map( function ( $id ) {
249
+		return array_map(function($id) {
250 250
 			try {
251
-				return $this->entityIdParser->parse( $id );
252
-			} catch ( EntityIdParsingException $e ) {
251
+				return $this->entityIdParser->parse($id);
252
+			} catch (EntityIdParsingException $e) {
253 253
 				$this->errorReporter->dieError(
254
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
254
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
255 255
 			}
256
-		}, $ids );
256
+		}, $ids);
257 257
 	}
258 258
 
259 259
 	/**
@@ -261,35 +261,35 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @return string[]
263 263
 	 */
264
-	private function parseClaimIds( array $params ) {
264
+	private function parseClaimIds(array $params) {
265 265
 		$ids = $params[self::PARAM_CLAIM_ID];
266 266
 
267
-		if ( $ids === null ) {
267
+		if ($ids === null) {
268 268
 			return [];
269
-		} elseif ( $ids === [] ) {
269
+		} elseif ($ids === []) {
270 270
 			$this->errorReporter->dieError(
271
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
271
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
272 272
 		}
273 273
 
274
-		foreach ( $ids as $id ) {
275
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
274
+		foreach ($ids as $id) {
275
+			if (!$this->statementGuidValidator->validate($id)) {
276 276
 				$this->errorReporter->dieError(
277
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
277
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
278 278
 			}
279 279
 		}
280 280
 
281 281
 		return $ids;
282 282
 	}
283 283
 
284
-	private function validateParameters( array $params ) {
285
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
286
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
284
+	private function validateParameters(array $params) {
285
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
286
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
287 287
 		) {
288 288
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
289 289
 			$this->errorReporter->dieError(
290 290
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
291 291
 		}
292
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
292
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
293 293
 			$paramId = self::PARAM_ID;
294 294
 			$paramClaimId = self::PARAM_CLAIM_ID;
295 295
 			$this->errorReporter->dieError(
Please login to merge, or discard this patch.
src/Api/CachingResultsBuilder.php 1 patch
Spacing   +50 added lines, -51 removed lines patch added patch discarded remove patch
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 	) {
135 135
 		$results = [];
136 136
 		$metadatas = [];
137
-		if ( $this->canUseStoredResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
137
+		if ($this->canUseStoredResults($entityIds, $claimIds, $constraintIds, $statuses)) {
138 138
 			$storedEntityIds = [];
139
-			foreach ( $entityIds as $entityId ) {
140
-				$storedResults = $this->getStoredResults( $entityId );
141
-				if ( $storedResults !== null ) {
139
+			foreach ($entityIds as $entityId) {
140
+				$storedResults = $this->getStoredResults($entityId);
141
+				if ($storedResults !== null) {
142 142
 					$this->dataFactory->increment(
143 143
 						'wikibase.quality.constraints.cache.entity.hit'
144 144
 					);
@@ -147,20 +147,20 @@  discard block
 block discarded – undo
147 147
 					$storedEntityIds[] = $entityId;
148 148
 				}
149 149
 			}
150
-			$entityIds = array_values( array_diff( $entityIds, $storedEntityIds ) );
150
+			$entityIds = array_values(array_diff($entityIds, $storedEntityIds));
151 151
 		}
152
-		if ( $entityIds !== [] || $claimIds !== [] ) {
152
+		if ($entityIds !== [] || $claimIds !== []) {
153 153
 			$this->dataFactory->updateCount(
154 154
 				'wikibase.quality.constraints.cache.entity.miss',
155
-				count( $entityIds )
155
+				count($entityIds)
156 156
 			);
157
-			$response = $this->getAndStoreResults( $entityIds, $claimIds, $constraintIds, $statuses );
157
+			$response = $this->getAndStoreResults($entityIds, $claimIds, $constraintIds, $statuses);
158 158
 			$results += $response->getArray();
159 159
 			$metadatas[] = $response->getMetadata();
160 160
 		}
161 161
 		return new CachedCheckConstraintsResponse(
162 162
 			$results,
163
-			Metadata::merge( $metadatas )
163
+			Metadata::merge($metadatas)
164 164
 		);
165 165
 	}
166 166
 
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
 		array $constraintIds = null,
190 190
 		array $statuses
191 191
 	) {
192
-		if ( $claimIds !== [] ) {
192
+		if ($claimIds !== []) {
193 193
 			return false;
194 194
 		}
195
-		if ( $constraintIds !== null ) {
195
+		if ($constraintIds !== null) {
196 196
 			return false;
197 197
 		}
198
-		if ( $statuses != $this->cachedStatuses ) {
198
+		if ($statuses != $this->cachedStatuses) {
199 199
 			return false;
200 200
 		}
201 201
 		return true;
@@ -214,17 +214,17 @@  discard block
 block discarded – undo
214 214
 		array $constraintIds = null,
215 215
 		array $statuses
216 216
 	) {
217
-		$results = $this->resultsBuilder->getResults( $entityIds, $claimIds, $constraintIds, $statuses );
217
+		$results = $this->resultsBuilder->getResults($entityIds, $claimIds, $constraintIds, $statuses);
218 218
 
219
-		if ( $this->canStoreResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
220
-			foreach ( $entityIds as $entityId ) {
219
+		if ($this->canStoreResults($entityIds, $claimIds, $constraintIds, $statuses)) {
220
+			foreach ($entityIds as $entityId) {
221 221
 				$value = [
222 222
 					'results' => $results->getArray()[$entityId->getSerialization()],
223 223
 					'latestRevisionIds' => $this->getLatestRevisionIds(
224 224
 						$results->getMetadata()->getDependencyMetadata()->getEntityIds()
225 225
 					),
226 226
 				];
227
-				$this->cache->set( $entityId, $value, $this->ttlInSeconds );
227
+				$this->cache->set($entityId, $value, $this->ttlInSeconds);
228 228
 			}
229 229
 		}
230 230
 
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
 		array $constraintIds = null,
257 257
 		array $statuses
258 258
 	) {
259
-		if ( $constraintIds !== null ) {
259
+		if ($constraintIds !== null) {
260 260
 			return false;
261 261
 		}
262
-		if ( $statuses != $this->cachedStatuses ) {
262
+		if ($statuses != $this->cachedStatuses) {
263 263
 			return false;
264 264
 		}
265 265
 		return true;
@@ -272,45 +272,44 @@  discard block
 block discarded – undo
272 272
 	public function getStoredResults(
273 273
 		EntityId $entityId
274 274
 	) {
275
-		$value = $this->cache->get( $entityId, $curTTL, [], $asOf );
276
-		$now = call_user_func( $this->microtime, true );
275
+		$value = $this->cache->get($entityId, $curTTL, [], $asOf);
276
+		$now = call_user_func($this->microtime, true);
277 277
 
278
-		if ( $value === false ) {
278
+		if ($value === false) {
279 279
 			return null;
280 280
 		}
281 281
 
282
-		$ageInSeconds = (int)ceil( $now - $asOf );
282
+		$ageInSeconds = (int) ceil($now - $asOf);
283 283
 
284 284
 		$dependedEntityIds = array_map(
285
-			[ $this->entityIdParser, "parse" ],
286
-			array_keys( $value['latestRevisionIds'] )
285
+			[$this->entityIdParser, "parse"],
286
+			array_keys($value['latestRevisionIds'])
287 287
 		);
288 288
 
289
-		if ( $value['latestRevisionIds'] !== $this->getLatestRevisionIds( $dependedEntityIds ) ) {
289
+		if ($value['latestRevisionIds'] !== $this->getLatestRevisionIds($dependedEntityIds)) {
290 290
 			return null;
291 291
 		}
292 292
 
293 293
 		$cachingMetadata = $ageInSeconds > 0 ?
294
-			CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) :
295
-			CachingMetadata::fresh();
294
+			CachingMetadata::ofMaximumAgeInSeconds($ageInSeconds) : CachingMetadata::fresh();
296 295
 
297
-		if ( is_array( $value['results'] ) ) {
298
-			array_walk( $value['results'], [ $this, 'updateCachingMetadata' ], $cachingMetadata );
296
+		if (is_array($value['results'])) {
297
+			array_walk($value['results'], [$this, 'updateCachingMetadata'], $cachingMetadata);
299 298
 		}
300 299
 
301 300
 		return new CachedCheckConstraintsResponse(
302
-			[ $entityId->getSerialization() => $value['results'] ],
301
+			[$entityId->getSerialization() => $value['results']],
303 302
 			array_reduce(
304 303
 				$dependedEntityIds,
305
-				function( Metadata $metadata, EntityId $entityId ) {
306
-					return Metadata::merge( [
304
+				function(Metadata $metadata, EntityId $entityId) {
305
+					return Metadata::merge([
307 306
 						$metadata,
308 307
 						Metadata::ofDependencyMetadata(
309
-							DependencyMetadata::ofEntityId( $entityId )
308
+							DependencyMetadata::ofEntityId($entityId)
310 309
 						)
311
-					] );
310
+					]);
312 311
 				},
313
-				Metadata::ofCachingMetadata( $cachingMetadata )
312
+				Metadata::ofCachingMetadata($cachingMetadata)
314 313
 			)
315 314
 		);
316 315
 	}
@@ -319,39 +318,39 @@  discard block
 block discarded – undo
319 318
 	 * @param EntityId[] $entityIds
320 319
 	 * @return int[]
321 320
 	 */
322
-	private function getLatestRevisionIds( array $entityIds ) {
321
+	private function getLatestRevisionIds(array $entityIds) {
323 322
 		$revisionInformations = $this->wikiPageEntityMetaDataAccessor->loadRevisionInformation(
324 323
 			$entityIds,
325 324
 			EntityRevisionLookup::LATEST_FROM_REPLICA
326 325
 		);
327 326
 		$latestRevisionIds = [];
328
-		foreach ( $revisionInformations as $serialization => $revisionInformation ) {
327
+		foreach ($revisionInformations as $serialization => $revisionInformation) {
329 328
 			$latestRevisionIds[$serialization] = $revisionInformation->page_latest;
330 329
 		}
331 330
 		return $latestRevisionIds;
332 331
 	}
333 332
 
334
-	public function updateCachingMetadata( &$element, $key, CachingMetadata $cachingMetadata ) {
335
-		if ( $key === 'cached' ) {
336
-			$element = CachingMetadata::merge( [
333
+	public function updateCachingMetadata(&$element, $key, CachingMetadata $cachingMetadata) {
334
+		if ($key === 'cached') {
335
+			$element = CachingMetadata::merge([
337 336
 				$cachingMetadata,
338
-				CachingMetadata::ofArray( $element ),
339
-			] )->toArray();
337
+				CachingMetadata::ofArray($element),
338
+			])->toArray();
340 339
 		}
341 340
 		if (
342
-			is_array( $element ) &&
343
-			array_key_exists( 'constraint', $element ) &&
344
-			in_array( $element['constraint']['type'], $this->possiblyStaleConstraintTypes, true )
341
+			is_array($element) &&
342
+			array_key_exists('constraint', $element) &&
343
+			in_array($element['constraint']['type'], $this->possiblyStaleConstraintTypes, true)
345 344
 		) {
346
-			$element['cached'] = CachingMetadata::merge( [
345
+			$element['cached'] = CachingMetadata::merge([
347 346
 				$cachingMetadata,
348 347
 				CachingMetadata::ofArray(
349
-					array_key_exists( 'cached', $element ) ? $element['cached'] : null
348
+					array_key_exists('cached', $element) ? $element['cached'] : null
350 349
 				),
351
-			] )->toArray();
350
+			])->toArray();
352 351
 		}
353
-		if ( is_array( $element ) ) {
354
-			array_walk( $element, [ $this, __FUNCTION__ ], $cachingMetadata );
352
+		if (is_array($element)) {
353
+			array_walk($element, [$this, __FUNCTION__], $cachingMetadata);
355 354
 		}
356 355
 	}
357 356
 
@@ -360,7 +359,7 @@  discard block
 block discarded – undo
360 359
 	 *
361 360
 	 * @param callable $microtime
362 361
 	 */
363
-	public function setMicrotimeFunction( callable $microtime ) {
362
+	public function setMicrotimeFunction(callable $microtime) {
364 363
 		$this->microtime = $microtime;
365 364
 	}
366 365
 
Please login to merge, or discard this patch.