Completed
Push — master ( fe64de...4c5602 )
by
unknown
08:58 queued 05:30
created
src/Api/CheckingResultsBuilder.php 1 patch
Spacing   +30 added lines, -31 removed lines patch added patch discarded remove patch
@@ -83,54 +83,53 @@  discard block
 block discarded – undo
83 83
 	) {
84 84
 		$response = [];
85 85
 		$metadatas = [];
86
-		$statusesFlipped = array_flip( $statuses );
87
-		foreach ( $entityIds as $entityId ) {
86
+		$statusesFlipped = array_flip($statuses);
87
+		foreach ($entityIds as $entityId) {
88 88
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnEntityId(
89 89
 				$entityId,
90 90
 				$constraintIds,
91
-				[ $this, 'defaultResults' ]
91
+				[$this, 'defaultResults']
92 92
 			);
93
-			$results = array_filter( $results, $this->statusSelected( $statusesFlipped ) );
94
-			foreach ( $results as $result ) {
93
+			$results = array_filter($results, $this->statusSelected($statusesFlipped));
94
+			foreach ($results as $result) {
95 95
 				$metadatas[] = $result->getMetadata();
96
-				$resultArray = $this->checkResultToArray( $result );
97
-				$result->getContext()->storeCheckResultInArray( $resultArray, $response );
96
+				$resultArray = $this->checkResultToArray($result);
97
+				$result->getContext()->storeCheckResultInArray($resultArray, $response);
98 98
 			}
99 99
 		}
100
-		foreach ( $claimIds as $claimId ) {
100
+		foreach ($claimIds as $claimId) {
101 101
 			$results = $this->delegatingConstraintChecker->checkAgainstConstraintsOnClaimId(
102 102
 				$claimId,
103 103
 				$constraintIds,
104
-				[ $this, 'defaultResults' ]
104
+				[$this, 'defaultResults']
105 105
 			);
106
-			$results = array_filter( $results, $this->statusSelected( $statusesFlipped ) );
107
-			foreach ( $results as $result ) {
106
+			$results = array_filter($results, $this->statusSelected($statusesFlipped));
107
+			foreach ($results as $result) {
108 108
 				$metadatas[] = $result->getMetadata();
109
-				$resultArray = $this->checkResultToArray( $result );
110
-				$result->getContext()->storeCheckResultInArray( $resultArray, $response );
109
+				$resultArray = $this->checkResultToArray($result);
110
+				$result->getContext()->storeCheckResultInArray($resultArray, $response);
111 111
 			}
112 112
 		}
113 113
 		return new CachedCheckConstraintsResponse(
114 114
 			$response,
115
-			Metadata::merge( $metadatas )
115
+			Metadata::merge($metadatas)
116 116
 		);
117 117
 	}
118 118
 
119
-	public function defaultResults( Context $context ) {
119
+	public function defaultResults(Context $context) {
120 120
 		return $context->getType() === Context::TYPE_STATEMENT ?
121
-			[ new NullResult( $context ) ] :
122
-			[];
121
+			[new NullResult($context)] : [];
123 122
 	}
124 123
 
125
-	public function statusSelected( array $statusesFlipped ) {
126
-		return function( CheckResult $result ) use ( $statusesFlipped ) {
127
-			return array_key_exists( $result->getStatus(), $statusesFlipped ) ||
124
+	public function statusSelected(array $statusesFlipped) {
125
+		return function(CheckResult $result) use ($statusesFlipped) {
126
+			return array_key_exists($result->getStatus(), $statusesFlipped) ||
128 127
 				$result instanceof NullResult;
129 128
 		};
130 129
 	}
131 130
 
132
-	public function checkResultToArray( CheckResult $checkResult ) {
133
-		if ( $checkResult instanceof NullResult ) {
131
+	public function checkResultToArray(CheckResult $checkResult) {
132
+		if ($checkResult instanceof NullResult) {
134 133
 			return null;
135 134
 		}
136 135
 
@@ -138,10 +137,10 @@  discard block
 block discarded – undo
138 137
 		$typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId();
139 138
 		$constraintPropertyId = $checkResult->getContext()->getSnak()->getPropertyId();
140 139
 
141
-		$title = $this->entityTitleLookup->getTitleForId( $constraintPropertyId );
142
-		$typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) );
140
+		$title = $this->entityTitleLookup->getTitleForId($constraintPropertyId);
141
+		$typeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($typeItemId));
143 142
 		// TODO link to the statement when possible (T169224)
144
-		$link = $title->getFullURL() . '#' . $this->config->get( 'WBQualityConstraintsPropertyConstraintId' );
143
+		$link = $title->getFullURL().'#'.$this->config->get('WBQualityConstraintsPropertyConstraintId');
145 144
 
146 145
 		$constraint = [
147 146
 			'id' => $constraintId,
@@ -150,11 +149,11 @@  discard block
 block discarded – undo
150 149
 			'link' => $link,
151 150
 			'discussLink' => $title->getTalkPage()->getFullURL(),
152 151
 		];
153
-		if ( $this->config->get( 'WBQualityConstraintsIncludeDetailInApi' ) ) {
152
+		if ($this->config->get('WBQualityConstraintsIncludeDetailInApi')) {
154 153
 			$parameters = $checkResult->getParameters();
155 154
 			$constraint += [
156 155
 				'detail' => $parameters,
157
-				'detailHTML' => $this->constraintParameterRenderer->formatParameters( $parameters ),
156
+				'detailHTML' => $this->constraintParameterRenderer->formatParameters($parameters),
158 157
 			];
159 158
 		}
160 159
 
@@ -164,14 +163,14 @@  discard block
 block discarded – undo
164 163
 			'constraint' => $constraint
165 164
 		];
166 165
 		$message = $checkResult->getMessage();
167
-		if ( $message ) {
168
-			$result['message-html'] = $this->violationMessageRenderer->render( $message );
166
+		if ($message) {
167
+			$result['message-html'] = $this->violationMessageRenderer->render($message);
169 168
 		}
170
-		if ( $checkResult->getContext()->getType() === Context::TYPE_STATEMENT ) {
169
+		if ($checkResult->getContext()->getType() === Context::TYPE_STATEMENT) {
171 170
 			$result['claim'] = $checkResult->getContext()->getSnakStatement()->getGuid();
172 171
 		}
173 172
 		$cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray();
174
-		if ( $cachingMetadataArray !== null ) {
173
+		if ($cachingMetadataArray !== null) {
175 174
 			$result['cached'] = $cachingMetadataArray;
176 175
 		}
177 176
 
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
@@ -77,21 +77,21 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return self
79 79
 	 */
80
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
80
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
81 81
 		$repo = WikibaseRepo::getDefaultInstance();
82 82
 
83 83
 		$language = $repo->getUserLanguage();
84 84
 		$formatterOptions = new FormatterOptions();
85
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
85
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
86 86
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
87
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
87
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
88 88
 
89 89
 		$languageFallbackLabelDescriptionLookupFactory = $repo->getLanguageFallbackLabelDescriptionLookupFactory();
90
-		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup( $language );
90
+		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup($language);
91 91
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
92
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
92
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
93 93
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
94
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
94
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
95 95
 		$config = MediaWikiServices::getInstance()->getMainConfig();
96 96
 		$titleParser = MediaWikiServices::getInstance()->getTitleParser();
97 97
 		$unitConverter = $repo->getUnitConverter();
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 			new ViolationMessageRenderer(),
128 128
 			$config
129 129
 		);
130
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
130
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
131 131
 			$wikiPageEntityMetaDataAccessor = new WikiPageEntityMetaDataLookup(
132 132
 				$repo->getEntityNamespaceLookup()
133 133
 			);
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
 				ResultsCache::getDefaultInstance(),
139 139
 				$wikiPageEntityMetaDataAccessor,
140 140
 				$entityIdParser,
141
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
141
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
142 142
 				[
143
-					$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
144
-					$config->get( 'WBQualityConstraintsTypeConstraintId' ),
145
-					$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
146
-					$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
143
+					$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
144
+					$config->get('WBQualityConstraintsTypeConstraintId'),
145
+					$config->get('WBQualityConstraintsValueTypeConstraintId'),
146
+					$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
147 147
 				],
148 148
 				$dataFactory
149 149
 			);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			$prefix,
156 156
 			$repo->getEntityIdParser(),
157 157
 			$repo->getStatementGuidValidator(),
158
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
158
+			$repo->getApiHelperFactory(RequestContext::getMain()),
159 159
 			$resultsBuilder,
160 160
 			$dataFactory
161 161
 		);
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 		ResultsBuilder $resultsBuilder,
182 182
 		IBufferingStatsdDataFactory $dataFactory
183 183
 	) {
184
-		parent::__construct( $main, $name, $prefix );
184
+		parent::__construct($main, $name, $prefix);
185 185
 		$this->entityIdParser = $entityIdParser;
186 186
 		$this->statementGuidValidator = $statementGuidValidator;
187
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
188
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
187
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
188
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
189 189
 		$this->resultsBuilder = $resultsBuilder;
190 190
 		$this->dataFactory = $dataFactory;
191 191
 	}
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 
201 201
 		$params = $this->extractRequestParams();
202 202
 
203
-		$this->validateParameters( $params );
204
-		$entityIds = $this->parseEntityIds( $params );
205
-		$claimIds = $this->parseClaimIds( $params );
203
+		$this->validateParameters($params);
204
+		$entityIds = $this->parseEntityIds($params);
205
+		$claimIds = $this->parseClaimIds($params);
206 206
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
207 207
 		$statuses = $params[self::PARAM_STATUS];
208 208
 
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 			)->getArray()
218 218
 		);
219 219
 		// ensure that result contains the given entity IDs even if they have no statements
220
-		foreach ( $entityIds as $entityId ) {
220
+		foreach ($entityIds as $entityId) {
221 221
 			$this->getResult()->addArrayType(
222
-				[ $this->getModuleName(), $entityId->getSerialization() ],
222
+				[$this->getModuleName(), $entityId->getSerialization()],
223 223
 				'assoc'
224 224
 			);
225 225
 		}
226
-		$this->resultBuilder->markSuccess( 1 );
226
+		$this->resultBuilder->markSuccess(1);
227 227
 	}
228 228
 
229 229
 	/**
@@ -231,24 +231,24 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @return EntityId[]
233 233
 	 */
234
-	private function parseEntityIds( array $params ) {
234
+	private function parseEntityIds(array $params) {
235 235
 		$ids = $params[self::PARAM_ID];
236 236
 
237
-		if ( $ids === null ) {
237
+		if ($ids === null) {
238 238
 			return [];
239
-		} elseif ( $ids === [] ) {
239
+		} elseif ($ids === []) {
240 240
 			$this->errorReporter->dieError(
241
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
241
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
242 242
 		}
243 243
 
244
-		return array_map( function ( $id ) {
244
+		return array_map(function($id) {
245 245
 			try {
246
-				return $this->entityIdParser->parse( $id );
247
-			} catch ( EntityIdParsingException $e ) {
246
+				return $this->entityIdParser->parse($id);
247
+			} catch (EntityIdParsingException $e) {
248 248
 				$this->errorReporter->dieError(
249
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
249
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
250 250
 			}
251
-		}, $ids );
251
+		}, $ids);
252 252
 	}
253 253
 
254 254
 	/**
@@ -256,35 +256,35 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @return string[]
258 258
 	 */
259
-	private function parseClaimIds( array $params ) {
259
+	private function parseClaimIds(array $params) {
260 260
 		$ids = $params[self::PARAM_CLAIM_ID];
261 261
 
262
-		if ( $ids === null ) {
262
+		if ($ids === null) {
263 263
 			return [];
264
-		} elseif ( $ids === [] ) {
264
+		} elseif ($ids === []) {
265 265
 			$this->errorReporter->dieError(
266
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
266
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
267 267
 		}
268 268
 
269
-		foreach ( $ids as $id ) {
270
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
269
+		foreach ($ids as $id) {
270
+			if (!$this->statementGuidValidator->validate($id)) {
271 271
 				$this->errorReporter->dieError(
272
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
272
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
273 273
 			}
274 274
 		}
275 275
 
276 276
 		return $ids;
277 277
 	}
278 278
 
279
-	private function validateParameters( array $params ) {
280
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
281
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
279
+	private function validateParameters(array $params) {
280
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
281
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
282 282
 		) {
283 283
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
284 284
 			$this->errorReporter->dieError(
285 285
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
286 286
 		}
287
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
287
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
288 288
 			$paramId = self::PARAM_ID;
289 289
 			$paramClaimId = self::PARAM_CLAIM_ID;
290 290
 			$this->errorReporter->dieError(
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/ViolationMessageRenderer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -24,12 +24,12 @@
 block discarded – undo
24 24
 		$language = null,
25 25
 		$format = Message::FORMAT_ESCAPED
26 26
 	) {
27
-		if ( is_string( $violationMessage ) ) {
27
+		if (is_string($violationMessage)) {
28 28
 			// TODO remove this once all checkers produce ViolationMessage objects
29 29
 			return $violationMessage;
30 30
 		}
31
-		$message = new Message( $violationMessage->getMessageKey(), [], $language );
32
-		return $message->toString( $format );
31
+		$message = new Message($violationMessage->getMessageKey(), [], $language);
32
+		return $message->toString($format);
33 33
 	}
34 34
 
35 35
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/LoggingHelper.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 		$this->dataFactory = $dataFactory;
47 47
 		$this->logger = $logger;
48 48
 		$this->constraintCheckDurationLimits = [
49
-			'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ),
50
-			'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ),
49
+			'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'),
50
+			'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'),
51 51
 		];
52 52
 	}
53 53
 
@@ -73,46 +73,46 @@  discard block
 block discarded – undo
73 73
 		$durationSeconds,
74 74
 		$method
75 75
 	) {
76
-		$constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 );
76
+		$constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1);
77 77
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
78 78
 
79 79
 		$this->dataFactory->timing(
80
-			'wikibase.quality.constraints.check.timing.' .
81
-				$constraintTypeItemId . '-' .
80
+			'wikibase.quality.constraints.check.timing.'.
81
+				$constraintTypeItemId.'-'.
82 82
 				$constraintCheckerClassShortName,
83 83
 			$durationSeconds * 1000
84 84
 		);
85 85
 
86 86
 		// find the longest limit (and associated log level) that the duration exceeds
87
-		foreach ( $this->constraintCheckDurationLimits as $level => $limit ) {
87
+		foreach ($this->constraintCheckDurationLimits as $level => $limit) {
88 88
 			if (
89 89
 				// duration exceeds this limit
90
-				isset( $limit ) && $durationSeconds > $limit &&
90
+				isset($limit) && $durationSeconds > $limit &&
91 91
 				// this limit is longer than previous longest limit
92
-				( !isset( $limitSeconds ) || $limit > $limitSeconds )
92
+				(!isset($limitSeconds) || $limit > $limitSeconds)
93 93
 			) {
94 94
 				$limitSeconds = $limit;
95 95
 				$logLevel = $level;
96 96
 			}
97 97
 		}
98 98
 
99
-		if ( !isset( $limitSeconds ) ) {
99
+		if (!isset($limitSeconds)) {
100 100
 			return;
101 101
 		}
102
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
102
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
103 103
 			// TODO log less details but still log something
104 104
 			return;
105 105
 		}
106 106
 
107 107
 		$resultMessage = $result->getMessage();
108
-		if ( $resultMessage instanceof ViolationMessage ) {
108
+		if ($resultMessage instanceof ViolationMessage) {
109 109
 			$resultMessage = $resultMessage->getMessageKey();
110 110
 		}
111 111
 
112 112
 		$this->logger->log(
113 113
 			$logLevel,
114
-			'Constraint check with {constraintCheckerClassShortName} ' .
115
-			'took longer than {limitSeconds} second(s) ' .
114
+			'Constraint check with {constraintCheckerClassShortName} '.
115
+			'took longer than {limitSeconds} second(s) '.
116 116
 			'(duration: {durationSeconds} seconds).',
117 117
 			[
118 118
 				'method' => $method,
Please login to merge, or discard this patch.
src/Specials/SpecialConstraintReport.php 1 patch
Spacing   +109 added lines, -110 removed lines patch added patch discarded remove patch
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 		Config $config,
134 134
 		IBufferingStatsdDataFactory $dataFactory
135 135
 	) {
136
-		parent::__construct( 'ConstraintReport' );
136
+		parent::__construct('ConstraintReport');
137 137
 
138 138
 		$this->entityLookup = $entityLookup;
139 139
 		$this->entityTitleLookup = $entityTitleLookup;
@@ -142,13 +142,13 @@  discard block
 block discarded – undo
142 142
 		$language = $this->getLanguage();
143 143
 
144 144
 		$formatterOptions = new FormatterOptions();
145
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
145
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
146 146
 		$this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(
147 147
 			SnakFormatter::FORMAT_HTML,
148 148
 			$formatterOptions
149 149
 		);
150 150
 
151
-		$labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup( $language );
151
+		$labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup($language);
152 152
 
153 153
 		$this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter(
154 154
 			$labelLookup
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	 * @return array
178 178
 	 */
179 179
 	private function getModules() {
180
-		return [ 'SpecialConstraintReportPage' ];
180
+		return ['SpecialConstraintReportPage'];
181 181
 	}
182 182
 
183 183
 	/**
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @return string
196 196
 	 */
197 197
 	public function getDescription() {
198
-		return $this->msg( 'wbqc-constraintreport' )->escaped();
198
+		return $this->msg('wbqc-constraintreport')->escaped();
199 199
 	}
200 200
 
201 201
 	/**
@@ -207,42 +207,42 @@  discard block
 block discarded – undo
207 207
 	 * @throws EntityIdParsingException
208 208
 	 * @throws UnexpectedValueException
209 209
 	 */
210
-	public function execute( $subPage ) {
210
+	public function execute($subPage) {
211 211
 		$out = $this->getOutput();
212 212
 
213
-		$postRequest = $this->getContext()->getRequest()->getVal( 'entityid' );
214
-		if ( $postRequest ) {
215
-			$out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() );
213
+		$postRequest = $this->getContext()->getRequest()->getVal('entityid');
214
+		if ($postRequest) {
215
+			$out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL());
216 216
 			return;
217 217
 		}
218 218
 
219
-		$out->addModules( $this->getModules() );
219
+		$out->addModules($this->getModules());
220 220
 
221 221
 		$this->setHeaders();
222 222
 
223
-		$out->addHTML( $this->getExplanationText() );
223
+		$out->addHTML($this->getExplanationText());
224 224
 		$this->buildEntityIdForm();
225 225
 
226
-		if ( !$subPage ) {
226
+		if (!$subPage) {
227 227
 			return;
228 228
 		}
229 229
 
230
-		if ( !is_string( $subPage ) ) {
231
-			throw new InvalidArgumentException( '$subPage must be string.' );
230
+		if (!is_string($subPage)) {
231
+			throw new InvalidArgumentException('$subPage must be string.');
232 232
 		}
233 233
 
234 234
 		try {
235
-			$entityId = $this->entityIdParser->parse( $subPage );
236
-		} catch ( EntityIdParsingException $e ) {
235
+			$entityId = $this->entityIdParser->parse($subPage);
236
+		} catch (EntityIdParsingException $e) {
237 237
 			$out->addHTML(
238
-				$this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true )
238
+				$this->buildNotice('wbqc-constraintreport-invalid-entity-id', true)
239 239
 			);
240 240
 			return;
241 241
 		}
242 242
 
243
-		if ( !$this->entityLookup->hasEntity( $entityId ) ) {
243
+		if (!$this->entityLookup->hasEntity($entityId)) {
244 244
 			$out->addHTML(
245
-				$this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true )
245
+				$this->buildNotice('wbqc-constraintreport-not-existent-entity', true)
246 246
 			);
247 247
 			return;
248 248
 		}
@@ -250,18 +250,18 @@  discard block
 block discarded – undo
250 250
 		$this->dataFactory->increment(
251 251
 			'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck'
252 252
 		);
253
-		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId );
253
+		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId);
254 254
 
255
-		if ( count( $results ) > 0 ) {
255
+		if (count($results) > 0) {
256 256
 			$out->addHTML(
257
-				$this->buildResultHeader( $entityId )
258
-				. $this->buildSummary( $results )
259
-				. $this->buildResultTable( $entityId, $results )
257
+				$this->buildResultHeader($entityId)
258
+				. $this->buildSummary($results)
259
+				. $this->buildResultTable($entityId, $results)
260 260
 			);
261 261
 		} else {
262 262
 			$out->addHTML(
263
-				$this->buildResultHeader( $entityId )
264
-				. $this->buildNotice( 'wbqc-constraintreport-empty-result' )
263
+				$this->buildResultHeader($entityId)
264
+				. $this->buildNotice('wbqc-constraintreport-empty-result')
265 265
 			);
266 266
 		}
267 267
 	}
@@ -277,15 +277,15 @@  discard block
 block discarded – undo
277 277
 				'name' => 'entityid',
278 278
 				'label-message' => 'wbqc-constraintreport-form-entityid-label',
279 279
 				'cssclass' => 'wbqc-constraintreport-form-entity-id',
280
-				'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped()
280
+				'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped()
281 281
 			]
282 282
 		];
283
-		$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' );
284
-		$htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() );
285
-		$htmlForm->setSubmitCallback( function() {
283
+		$htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form');
284
+		$htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped());
285
+		$htmlForm->setSubmitCallback(function() {
286 286
 			return false;
287 287
 		} );
288
-		$htmlForm->setMethod( 'post' );
288
+		$htmlForm->setMethod('post');
289 289
 		$htmlForm->show();
290 290
 	}
291 291
 
@@ -299,16 +299,16 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @return string HTML
301 301
 	 */
302
-	private function buildNotice( $messageKey, $error = false ) {
303
-		if ( !is_string( $messageKey ) ) {
304
-			throw new InvalidArgumentException( '$message must be string.' );
302
+	private function buildNotice($messageKey, $error = false) {
303
+		if (!is_string($messageKey)) {
304
+			throw new InvalidArgumentException('$message must be string.');
305 305
 		}
306
-		if ( !is_bool( $error ) ) {
307
-			throw new InvalidArgumentException( '$error must be bool.' );
306
+		if (!is_bool($error)) {
307
+			throw new InvalidArgumentException('$error must be bool.');
308 308
 		}
309 309
 
310 310
 		$cssClasses = 'wbqc-constraintreport-notice';
311
-		if ( $error ) {
311
+		if ($error) {
312 312
 			$cssClasses .= ' wbqc-constraintreport-notice-error';
313 313
 		}
314 314
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 				[
318 318
 					'class' => $cssClasses
319 319
 				],
320
-				$this->msg( $messageKey )->escaped()
320
+				$this->msg($messageKey)->escaped()
321 321
 			);
322 322
 	}
323 323
 
@@ -327,16 +327,16 @@  discard block
 block discarded – undo
327 327
 	private function getExplanationText() {
328 328
 		return Html::rawElement(
329 329
 			'div',
330
-			[ 'class' => 'wbqc-explanation' ],
330
+			['class' => 'wbqc-explanation'],
331 331
 			Html::rawElement(
332 332
 				'p',
333 333
 				[],
334
-				$this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped()
334
+				$this->msg('wbqc-constraintreport-explanation-part-one')->escaped()
335 335
 			)
336 336
 			. Html::rawElement(
337 337
 				'p',
338 338
 				[],
339
-				$this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped()
339
+				$this->msg('wbqc-constraintreport-explanation-part-two')->escaped()
340 340
 			)
341 341
 		);
342 342
 	}
@@ -347,71 +347,70 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @return string HTML
349 349
 	 */
350
-	private function buildResultTable( EntityId $entityId, array $results ) {
350
+	private function buildResultTable(EntityId $entityId, array $results) {
351 351
 		// Set table headers
352 352
 		$table = new HtmlTableBuilder(
353 353
 			[
354 354
 				new HtmlTableHeaderBuilder(
355
-					$this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(),
355
+					$this->msg('wbqc-constraintreport-result-table-header-status')->escaped(),
356 356
 					true
357 357
 				),
358 358
 				new HtmlTableHeaderBuilder(
359
-					$this->msg( 'wbqc-constraintreport-result-table-header-claim' )->escaped(),
359
+					$this->msg('wbqc-constraintreport-result-table-header-claim')->escaped(),
360 360
 					true
361 361
 				),
362 362
 				new HtmlTableHeaderBuilder(
363
-					$this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(),
363
+					$this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(),
364 364
 					true
365 365
 				)
366 366
 			]
367 367
 		);
368 368
 
369
-		foreach ( $results as $result ) {
370
-			$table = $this->appendToResultTable( $table, $entityId, $result );
369
+		foreach ($results as $result) {
370
+			$table = $this->appendToResultTable($table, $entityId, $result);
371 371
 		}
372 372
 
373 373
 		return $table->toHtml();
374 374
 	}
375 375
 
376
-	private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) {
376
+	private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) {
377 377
 		// Status column
378 378
 		$statusColumn = $this->buildTooltipElement(
379
-			$this->formatStatus( $result->getStatus() ),
379
+			$this->formatStatus($result->getStatus()),
380 380
 			$result->getMessage() !== null ?
381
-				$this->violationMessageRenderer->render( $result->getMessage() ) :
382
-				null,
381
+				$this->violationMessageRenderer->render($result->getMessage()) : null,
383 382
 			'[?]'
384 383
 		);
385 384
 
386 385
 		// Claim column
387
-		$property = $this->entityIdLabelFormatter->formatEntityId( $result->getContext()->getSnak()->getPropertyId() );
388
-		if ( $result->getSnakType() === 'value' ) {
389
-			$value = $this->constraintParameterRenderer->formatValue( $result->getDataValue() );
386
+		$property = $this->entityIdLabelFormatter->formatEntityId($result->getContext()->getSnak()->getPropertyId());
387
+		if ($result->getSnakType() === 'value') {
388
+			$value = $this->constraintParameterRenderer->formatValue($result->getDataValue());
390 389
 		} else {
391
-			$value = htmlspecialchars( $result->getSnakType() );
390
+			$value = htmlspecialchars($result->getSnakType());
392 391
 		}
393 392
 
394 393
 		$claimColumn = $this->getClaimLink(
395 394
 			$entityId,
396 395
 			$result->getContext()->getSnak()->getPropertyId(),
397
-			$property . ': ' . $value
396
+			$property.': '.$value
398 397
 		);
399 398
 
400 399
 		// Constraint column
401 400
 		$constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId();
402 401
 		try {
403
-			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) );
404
-		} catch ( InvalidArgumentException $e ) {
405
-			$constraintTypeLabel = htmlspecialchars( $constraintTypeItemId );
402
+			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId));
403
+		} catch (InvalidArgumentException $e) {
404
+			$constraintTypeLabel = htmlspecialchars($constraintTypeItemId);
406 405
 		}
407 406
 		$constraintLink = $this->getClaimLink(
408 407
 			$result->getContext()->getSnak()->getPropertyId(),
409
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ),
408
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')),
410 409
 			$constraintTypeLabel
411 410
 		);
412 411
 		$constraintColumn = $this->buildExpandableElement(
413 412
 			$constraintLink,
414
-			$this->constraintParameterRenderer->formatParameters( $result->getParameters() ),
413
+			$this->constraintParameterRenderer->formatParameters($result->getParameters()),
415 414
 			'[...]'
416 415
 		);
417 416
 
@@ -446,15 +445,15 @@  discard block
 block discarded – undo
446 445
 	 *
447 446
 	 * @return string HTML
448 447
 	 */
449
-	protected function buildResultHeader( EntityId $entityId ) {
450
-		$entityLink = sprintf( '%s (%s)',
451
-							   $this->entityIdLinkFormatter->formatEntityId( $entityId ),
452
-							   htmlspecialchars( $entityId->getSerialization() ) );
448
+	protected function buildResultHeader(EntityId $entityId) {
449
+		$entityLink = sprintf('%s (%s)',
450
+							   $this->entityIdLinkFormatter->formatEntityId($entityId),
451
+							   htmlspecialchars($entityId->getSerialization()));
453 452
 
454 453
 		return Html::rawElement(
455 454
 			'h3',
456 455
 			[],
457
-			sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
456
+			sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink)
458 457
 		);
459 458
 	}
460 459
 
@@ -465,24 +464,24 @@  discard block
 block discarded – undo
465 464
 	 *
466 465
 	 * @return string HTML
467 466
 	 */
468
-	protected function buildSummary( array $results ) {
467
+	protected function buildSummary(array $results) {
469 468
 		$statuses = [];
470
-		foreach ( $results as $result ) {
471
-			$status = strtolower( $result->getStatus() );
472
-			$statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1;
469
+		foreach ($results as $result) {
470
+			$status = strtolower($result->getStatus());
471
+			$statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1;
473 472
 		}
474 473
 
475 474
 		$statusElements = [];
476
-		foreach ( $statuses as $status => $count ) {
477
-			if ( $count > 0 ) {
475
+		foreach ($statuses as $status => $count) {
476
+			if ($count > 0) {
478 477
 				$statusElements[] =
479
-					$this->formatStatus( $status )
478
+					$this->formatStatus($status)
480 479
 					. ': '
481 480
 					. $count;
482 481
 			}
483 482
 		}
484 483
 
485
-		return Html::rawElement( 'p', [], implode( ', ', $statusElements ) );
484
+		return Html::rawElement('p', [], implode(', ', $statusElements));
486 485
 	}
487 486
 
488 487
 	/**
@@ -497,15 +496,15 @@  discard block
 block discarded – undo
497 496
 	 *
498 497
 	 * @return string HTML
499 498
 	 */
500
-	protected function buildTooltipElement( $content, $tooltipContent, $indicator ) {
501
-		if ( !is_string( $content ) ) {
502
-			throw new InvalidArgumentException( '$content has to be string.' );
499
+	protected function buildTooltipElement($content, $tooltipContent, $indicator) {
500
+		if (!is_string($content)) {
501
+			throw new InvalidArgumentException('$content has to be string.');
503 502
 		}
504
-		if ( $tooltipContent && ( !is_string( $tooltipContent ) ) ) {
505
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
503
+		if ($tooltipContent && (!is_string($tooltipContent))) {
504
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
506 505
 		}
507 506
 
508
-		if ( empty( $tooltipContent ) ) {
507
+		if (empty($tooltipContent)) {
509 508
 			return $content;
510 509
 		}
511 510
 
@@ -522,13 +521,13 @@  discard block
 block discarded – undo
522 521
 			[
523 522
 				'class' => 'wbqc-indicator'
524 523
 			],
525
-			htmlspecialchars( $indicator ) . $tooltip
524
+			htmlspecialchars($indicator).$tooltip
526 525
 		);
527 526
 
528 527
 		return Html::rawElement(
529 528
 			'span',
530 529
 			[],
531
-			sprintf( '%s %s', $content, $tooltipIndicator )
530
+			sprintf('%s %s', $content, $tooltipIndicator)
532 531
 		);
533 532
 	}
534 533
 
@@ -544,15 +543,15 @@  discard block
 block discarded – undo
544 543
 	 *
545 544
 	 * @return string HTML
546 545
 	 */
547
-	protected function buildExpandableElement( $content, $expandableContent, $indicator ) {
548
-		if ( !is_string( $content ) ) {
549
-			throw new InvalidArgumentException( '$content has to be string.' );
546
+	protected function buildExpandableElement($content, $expandableContent, $indicator) {
547
+		if (!is_string($content)) {
548
+			throw new InvalidArgumentException('$content has to be string.');
550 549
 		}
551
-		if ( $expandableContent && ( !is_string( $expandableContent ) ) ) {
552
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
550
+		if ($expandableContent && (!is_string($expandableContent))) {
551
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
553 552
 		}
554 553
 
555
-		if ( empty( $expandableContent ) ) {
554
+		if (empty($expandableContent)) {
556 555
 			return $content;
557 556
 		}
558 557
 
@@ -573,7 +572,7 @@  discard block
 block discarded – undo
573 572
 		);
574 573
 
575 574
 		return
576
-			sprintf( '%s %s %s', $content, $tooltipIndicator, $expandableContent );
575
+			sprintf('%s %s %s', $content, $tooltipIndicator, $expandableContent);
577 576
 	}
578 577
 
579 578
 	/**
@@ -585,16 +584,16 @@  discard block
 block discarded – undo
585 584
 	 *
586 585
 	 * @return string HTML
587 586
 	 */
588
-	private function formatStatus( $status ) {
589
-		$messageName = "wbqc-constraintreport-status-" . strtolower( $status );
587
+	private function formatStatus($status) {
588
+		$messageName = "wbqc-constraintreport-status-".strtolower($status);
590 589
 
591 590
 		$formattedStatus =
592 591
 			Html::element(
593 592
 				'span',
594 593
 				[
595
-					'class' => 'wbqc-status wbqc-status-' . $status
594
+					'class' => 'wbqc-status wbqc-status-'.$status
596 595
 				],
597
-				$this->msg( $messageName )->text()
596
+				$this->msg($messageName)->text()
598 597
 			);
599 598
 
600 599
 		return $formattedStatus;
@@ -610,26 +609,26 @@  discard block
 block discarded – undo
610 609
 	 *
611 610
 	 * @return string HTML
612 611
 	 */
613
-	protected function formatDataValues( $dataValues, $separator = ', ' ) {
614
-		if ( $dataValues instanceof DataValue ) {
615
-			$dataValues = [ $dataValues ];
616
-		} elseif ( !is_array( $dataValues ) ) {
617
-			throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
612
+	protected function formatDataValues($dataValues, $separator = ', ') {
613
+		if ($dataValues instanceof DataValue) {
614
+			$dataValues = [$dataValues];
615
+		} elseif (!is_array($dataValues)) {
616
+			throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
618 617
 		}
619 618
 
620 619
 		$formattedDataValues = [];
621
-		foreach ( $dataValues as $dataValue ) {
622
-			if ( !( $dataValue instanceof DataValue ) ) {
623
-				throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
620
+		foreach ($dataValues as $dataValue) {
621
+			if (!($dataValue instanceof DataValue)) {
622
+				throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
624 623
 			}
625
-			if ( $dataValue instanceof EntityIdValue ) {
626
-				$formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() );
624
+			if ($dataValue instanceof EntityIdValue) {
625
+				$formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId());
627 626
 			} else {
628
-				$formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue );
627
+				$formattedDataValues[] = $this->dataValueFormatter->format($dataValue);
629 628
 			}
630 629
 		}
631 630
 
632
-		return implode( $separator, $formattedDataValues );
631
+		return implode($separator, $formattedDataValues);
633 632
 	}
634 633
 
635 634
 	/**
@@ -641,12 +640,12 @@  discard block
 block discarded – undo
641 640
 	 *
642 641
 	 * @return string HTML
643 642
 	 */
644
-	private function getClaimLink( EntityId $entityId, PropertyId $propertyId, $text ) {
643
+	private function getClaimLink(EntityId $entityId, PropertyId $propertyId, $text) {
645 644
 		return
646 645
 			Html::rawElement(
647 646
 				'a',
648 647
 				[
649
-					'href' => $this->getClaimUrl( $entityId, $propertyId ),
648
+					'href' => $this->getClaimUrl($entityId, $propertyId),
650 649
 					'target' => '_blank'
651 650
 				],
652 651
 				$text
@@ -661,9 +660,9 @@  discard block
 block discarded – undo
661 660
 	 *
662 661
 	 * @return string
663 662
 	 */
664
-	private function getClaimUrl( EntityId $entityId, PropertyId $propertyId ) {
665
-		$title = $this->entityTitleLookup->getTitleForId( $entityId );
666
-		$entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() );
663
+	private function getClaimUrl(EntityId $entityId, PropertyId $propertyId) {
664
+		$title = $this->entityTitleLookup->getTitleForId($entityId);
665
+		$entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization());
667 666
 
668 667
 		return $entityUrl;
669 668
 	}
Please login to merge, or discard this patch.