Completed
Push — master ( ea1cb0...da43d1 )
by
unknown
04:41 queued 40s
created
WikibaseQualityConstraints.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( function_exists( 'wfLoadExtension' ) ) {
4
-	wfLoadExtension( 'WikibaseQualityConstraints', __DIR__ . '/extension.json' );
3
+if (function_exists('wfLoadExtension')) {
4
+	wfLoadExtension('WikibaseQualityConstraints', __DIR__.'/extension.json');
5 5
 	// Keep i18n globals so mergeMessageFileList.php doesn't break
6
-	$wgMessagesDirs['WikibaseQualityConstraints'] = __DIR__ . '/i18n';
7
-	$wgExtensionMessagesFiles['WikibaseQualityConstraintsAlias'] = __DIR__ . '/WikibaseQualityConstraints.alias.php';
6
+	$wgMessagesDirs['WikibaseQualityConstraints'] = __DIR__.'/i18n';
7
+	$wgExtensionMessagesFiles['WikibaseQualityConstraintsAlias'] = __DIR__.'/WikibaseQualityConstraints.alias.php';
8 8
 	/* wfWarn(
9 9
 		'Deprecated PHP entry point used for WikibaseQualityConstraints extension. ' .
10 10
 		'Please use wfLoadExtension instead, ' .
@@ -12,5 +12,5 @@  discard block
 block discarded – undo
12 12
 	); */
13 13
 	return;
14 14
 } else {
15
-	die( 'This version of the WikibaseQualityConstraints extension requires MediaWiki 1.25+' );
15
+	die('This version of the WikibaseQualityConstraints extension requires MediaWiki 1.25+');
16 16
 }
Please login to merge, or discard this patch.
WikibaseQualityConstraints.alias.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,5 +10,5 @@
 block discarded – undo
10 10
 
11 11
 /** English (English) */
12 12
 $specialPageAliases['en'] = [
13
-	'ConstraintReport' => [ 'ConstraintReport', 'Constraint Report' ],
13
+	'ConstraintReport' => ['ConstraintReport', 'Constraint Report'],
14 14
 ];
Please login to merge, or discard this patch.
maintenance/ImportConstraintStatements.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@  discard block
 block discarded – undo
8 8
 use WikibaseQuality\ConstraintReport\UpdateConstraintsTableJob;
9 9
 use Wikibase\Repo\WikibaseRepo;
10 10
 
11
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
12
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
11
+$basePath = getenv("MW_INSTALL_PATH") !== false
12
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
13 13
 
14
-require_once $basePath . "/maintenance/Maintenance.php";
14
+require_once $basePath."/maintenance/Maintenance.php";
15 15
 
16 16
 /**
17 17
  * Runs {@link UpdateConstraintsTableJob} once for every property.
@@ -23,23 +23,23 @@  discard block
 block discarded – undo
23 23
 	public function __construct() {
24 24
 		parent::__construct();
25 25
 
26
-		$this->addDescription( 'Imports property constraints from statements on properties' );
26
+		$this->addDescription('Imports property constraints from statements on properties');
27 27
 	}
28 28
 
29 29
 	public function execute() {
30
-		if ( !MediaWikiServices::getInstance()->getMainConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
31
-			$this->error( 'Constraint statements are not enabled. Aborting.', 1 );
30
+		if (!MediaWikiServices::getInstance()->getMainConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) {
31
+			$this->error('Constraint statements are not enabled. Aborting.', 1);
32 32
 		}
33 33
 
34 34
 		$propertyInfoLookup = WikibaseRepo::getDefaultInstance()->getStore()->getPropertyInfoLookup();
35
-		foreach ( $propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info ) {
36
-			$this->output( sprintf( 'Importing constraint statements for % 6s... ', $propertyIdSerialization ), $propertyIdSerialization );
37
-			$startTime = microtime( true );
38
-			$job = UpdateConstraintsTableJob::newFromGlobalState( Title::newMainPage(), [ 'propertyId' => $propertyIdSerialization ] );
35
+		foreach ($propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info) {
36
+			$this->output(sprintf('Importing constraint statements for % 6s... ', $propertyIdSerialization), $propertyIdSerialization);
37
+			$startTime = microtime(true);
38
+			$job = UpdateConstraintsTableJob::newFromGlobalState(Title::newMainPage(), ['propertyId' => $propertyIdSerialization]);
39 39
 			$job->run();
40
-			$endTime = microtime( true );
41
-			$millis = ( $endTime - $startTime ) * 1000;
42
-			$this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization );
40
+			$endTime = microtime(true);
41
+			$millis = ($endTime - $startTime) * 1000;
42
+			$this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization);
43 43
 		}
44 44
 	}
45 45
 
Please login to merge, or discard this patch.
src/Api/CheckConstraintParameters.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @return self
61 61
 	 */
62
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
62
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
63 63
 		$constraintReportFactory = ConstraintReportFactory::getDefaultInstance();
64 64
 		$repo = WikibaseRepo::getDefaultInstance();
65
-		$helperFactory = $repo->getApiHelperFactory( RequestContext::getMain() );
65
+		$helperFactory = $repo->getApiHelperFactory(RequestContext::getMain());
66 66
 		return new self(
67 67
 			$main,
68 68
 			$name,
@@ -89,53 +89,53 @@  discard block
 block discarded – undo
89 89
 		DelegatingConstraintChecker $delegatingConstraintChecker,
90 90
 		StatementGuidParser $statementGuidParser
91 91
 	) {
92
-		parent::__construct( $main, $name, $prefix );
92
+		parent::__construct($main, $name, $prefix);
93 93
 
94
-		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this );
94
+		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this);
95 95
 		$this->delegatingConstraintChecker = $delegatingConstraintChecker;
96 96
 		$this->statementGuidParser = $statementGuidParser;
97 97
 	}
98 98
 
99 99
 	public function execute() {
100 100
 		MediaWikiServices::getInstance()->getStatsdDataFactory()
101
-			->increment( 'wikibase.quality.constraints.api.checkConstraintParameters.execute' );
101
+			->increment('wikibase.quality.constraints.api.checkConstraintParameters.execute');
102 102
 
103 103
 		$params = $this->extractRequestParams();
104 104
 		$result = $this->getResult();
105 105
 
106
-		$propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] );
107
-		$constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] );
106
+		$propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]);
107
+		$constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]);
108 108
 
109
-		$this->checkPropertyIds( $propertyIds, $result );
110
-		$this->checkConstraintIds( $constraintIds, $result );
109
+		$this->checkPropertyIds($propertyIds, $result);
110
+		$this->checkConstraintIds($constraintIds, $result);
111 111
 
112
-		$result->addValue( null, 'success', 1 );
112
+		$result->addValue(null, 'success', 1);
113 113
 	}
114 114
 
115 115
 	/**
116 116
 	 * @param array|null $propertyIdSerializations
117 117
 	 * @return PropertyId[]
118 118
 	 */
119
-	private function parsePropertyIds( $propertyIdSerializations ) {
120
-		if ( $propertyIdSerializations === null ) {
119
+	private function parsePropertyIds($propertyIdSerializations) {
120
+		if ($propertyIdSerializations === null) {
121 121
 			return [];
122
-		} elseif ( empty( $propertyIdSerializations ) ) {
122
+		} elseif (empty($propertyIdSerializations)) {
123 123
 			$this->apiErrorReporter->dieError(
124
-				'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.',
124
+				'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.',
125 125
 				'no-data'
126 126
 			);
127 127
 		}
128 128
 
129 129
 		return array_map(
130
-			function( $propertyIdSerialization ) {
130
+			function($propertyIdSerialization) {
131 131
 				try {
132
-					return new PropertyId( $propertyIdSerialization );
133
-				} catch ( InvalidArgumentException $e ) {
132
+					return new PropertyId($propertyIdSerialization);
133
+				} catch (InvalidArgumentException $e) {
134 134
 					$this->apiErrorReporter->dieError(
135 135
 						"Invalid id: $propertyIdSerialization",
136 136
 						'invalid-property-id',
137 137
 						0, // default argument
138
-						[ self::PARAM_PROPERTY_ID => $propertyIdSerialization ]
138
+						[self::PARAM_PROPERTY_ID => $propertyIdSerialization]
139 139
 					);
140 140
 				}
141 141
 			},
@@ -147,35 +147,35 @@  discard block
 block discarded – undo
147 147
 	 * @param array|null $constraintIds
148 148
 	 * @return string[]
149 149
 	 */
150
-	private function parseConstraintIds( $constraintIds ) {
151
-		if ( $constraintIds === null ) {
150
+	private function parseConstraintIds($constraintIds) {
151
+		if ($constraintIds === null) {
152 152
 			return [];
153
-		} elseif ( empty( $constraintIds ) ) {
153
+		} elseif (empty($constraintIds)) {
154 154
 			$this->apiErrorReporter->dieError(
155
-				'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.',
155
+				'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.',
156 156
 				'no-data'
157 157
 			);
158 158
 		}
159 159
 
160 160
 		return array_map(
161
-			function( $constraintId ) {
161
+			function($constraintId) {
162 162
 				try {
163
-					$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
164
-					if ( !$propertyId instanceof PropertyId ) {
163
+					$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
164
+					if (!$propertyId instanceof PropertyId) {
165 165
 						$this->apiErrorReporter->dieError(
166 166
 							"Invalid property ID: {$propertyId->getSerialization()}",
167 167
 							'invalid-property-id',
168 168
 							0, // default argument
169
-							[ self::PARAM_CONSTRAINT_ID => $constraintId ]
169
+							[self::PARAM_CONSTRAINT_ID => $constraintId]
170 170
 						);
171 171
 					}
172 172
 					return $constraintId;
173
-				} catch ( StatementGuidParsingException $e ) {
173
+				} catch (StatementGuidParsingException $e) {
174 174
 					$this->apiErrorReporter->dieError(
175 175
 						"Invalid statement GUID: $constraintId",
176 176
 						'invalid-guid',
177 177
 						0, // default argument
178
-						[ self::PARAM_CONSTRAINT_ID => $constraintId ]
178
+						[self::PARAM_CONSTRAINT_ID => $constraintId]
179 179
 					);
180 180
 				}
181 181
 			},
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 	 * @param PropertyId[] $propertyIds
188 188
 	 * @param ApiResult $result
189 189
 	 */
190
-	private function checkPropertyIds( array $propertyIds, ApiResult $result ) {
191
-		foreach ( $propertyIds as $propertyId ) {
192
-			$result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' );
193
-			$allConstraintExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnPropertyId( $propertyId );
194
-			foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) {
195
-				$this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result );
190
+	private function checkPropertyIds(array $propertyIds, ApiResult $result) {
191
+		foreach ($propertyIds as $propertyId) {
192
+			$result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc');
193
+			$allConstraintExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnPropertyId($propertyId);
194
+			foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) {
195
+				$this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result);
196 196
 			}
197 197
 		}
198 198
 	}
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 	 * @param string[] $constraintIds
202 202
 	 * @param ApiResult $result
203 203
 	 */
204
-	private function checkConstraintIds( array $constraintIds, ApiResult $result ) {
205
-		foreach ( $constraintIds as $constraintId ) {
206
-			if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) {
204
+	private function checkConstraintIds(array $constraintIds, ApiResult $result) {
205
+		foreach ($constraintIds as $constraintId) {
206
+			if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) {
207 207
 				// already checked as part of checkPropertyIds()
208 208
 				continue;
209 209
 			}
210
-			$constraintParameterExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnConstraintId( $constraintId );
211
-			$this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result );
210
+			$constraintParameterExceptions = $this->delegatingConstraintChecker->checkConstraintParametersOnConstraintId($constraintId);
211
+			$this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result);
212 212
 		}
213 213
 	}
214 214
 
@@ -216,17 +216,17 @@  discard block
 block discarded – undo
216 216
 	 * @param PropertyId $propertyId
217 217
 	 * @return string[]
218 218
 	 */
219
-	private function getResultPathForPropertyId( PropertyId $propertyId ) {
220
-		return [ $this->getModuleName(), $propertyId->getSerialization() ];
219
+	private function getResultPathForPropertyId(PropertyId $propertyId) {
220
+		return [$this->getModuleName(), $propertyId->getSerialization()];
221 221
 	}
222 222
 
223 223
 	/**
224 224
 	 * @param string $constraintId
225 225
 	 * @return string[]
226 226
 	 */
227
-	private function getResultPathForConstraintId( $constraintId ) {
228
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
229
-		return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] );
227
+	private function getResultPathForConstraintId($constraintId) {
228
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
229
+		return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]);
230 230
 	}
231 231
 
232 232
 	/**
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 	 * @param ConstraintParameterException[]|null $constraintParameterExceptions
237 237
 	 * @param ApiResult $result
238 238
 	 */
239
-	private function addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, ApiResult $result ) {
240
-		$path = $this->getResultPathForConstraintId( $constraintId );
241
-		if ( $constraintParameterExceptions === null ) {
239
+	private function addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, ApiResult $result) {
240
+		$path = $this->getResultPathForConstraintId($constraintId);
241
+		if ($constraintParameterExceptions === null) {
242 242
 			$result->addValue(
243 243
 				$path,
244 244
 				self::KEY_STATUS,
@@ -248,12 +248,12 @@  discard block
 block discarded – undo
248 248
 			$result->addValue(
249 249
 				$path,
250 250
 				self::KEY_STATUS,
251
-				empty( $constraintParameterExceptions ) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY
251
+				empty($constraintParameterExceptions) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY
252 252
 			);
253 253
 			$result->addValue(
254 254
 				$path,
255 255
 				self::KEY_PROBLEMS,
256
-				array_map( [ $this, 'formatConstraintParameterException' ], $constraintParameterExceptions )
256
+				array_map([$this, 'formatConstraintParameterException'], $constraintParameterExceptions)
257 257
 			);
258 258
 		}
259 259
 	}
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 	 * @param ConstraintParameterException $e
265 265
 	 * @return array
266 266
 	 */
267
-	private function formatConstraintParameterException( ConstraintParameterException $e ) {
267
+	private function formatConstraintParameterException(ConstraintParameterException $e) {
268 268
 		return [
269 269
 			self::KEY_MESSAGE_HTML => $e->getMessage(),
270 270
 		];
Please login to merge, or discard this patch.
src/ConstraintLookup.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,6 +14,6 @@
 block discarded – undo
14 14
 	 *
15 15
 	 * @return Constraint[]
16 16
 	 */
17
-	public function queryConstraintsForProperty( PropertyId $propertyId );
17
+	public function queryConstraintsForProperty(PropertyId $propertyId);
18 18
 
19 19
 }
Please login to merge, or discard this patch.
src/UpdateConstraintsTableJob.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 
27 27
 	const BATCH_SIZE = 10;
28 28
 
29
-	public static function newFromGlobalState( Title $title, array $params ) {
30
-		Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' );
29
+	public static function newFromGlobalState(Title $title, array $params) {
30
+		Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]');
31 31
 		$repo = WikibaseRepo::getDefaultInstance();
32 32
 		return new UpdateConstraintsTableJob(
33 33
 			$title,
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		EntityLookup $entityLookup,
84 84
 		Serializer $snakSerializer
85 85
 	) {
86
-		parent::__construct( 'constraintsTableUpdate', $title, $params );
86
+		parent::__construct('constraintsTableUpdate', $title, $params);
87 87
 
88 88
 		$this->propertyId = $propertyId;
89 89
 		$this->config = $config;
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 		$this->snakSerializer = $snakSerializer;
93 93
 	}
94 94
 
95
-	public function extractParametersFromQualifiers( SnakList $qualifiers ) {
95
+	public function extractParametersFromQualifiers(SnakList $qualifiers) {
96 96
 		$parameters = [];
97
-		foreach ( $qualifiers as $qualifier ) {
97
+		foreach ($qualifiers as $qualifier) {
98 98
 			$qualifierId = $qualifier->getPropertyId()->getSerialization();
99
-			$paramSerialization = $this->snakSerializer->serialize( $qualifier );
99
+			$paramSerialization = $this->snakSerializer->serialize($qualifier);
100 100
 			$parameters[$qualifierId][] = $paramSerialization;
101 101
 		}
102 102
 		return $parameters;
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	) {
109 109
 		$constraintId = $constraintStatement->getGuid();
110 110
 		$constraintTypeQid = $constraintStatement->getMainSnak()->getDataValue()->getEntityId()->getSerialization();
111
-		$parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() );
111
+		$parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers());
112 112
 		return new Constraint(
113 113
 			$constraintId,
114 114
 			$propertyId,
@@ -122,16 +122,16 @@  discard block
 block discarded – undo
122 122
 		ConstraintRepository $constraintRepo,
123 123
 		PropertyId $propertyConstraintPropertyId
124 124
 	) {
125
-		$constraintsStatements = $property->getStatements()->getByPropertyId( $propertyConstraintPropertyId );
125
+		$constraintsStatements = $property->getStatements()->getByPropertyId($propertyConstraintPropertyId);
126 126
 		$constraints = [];
127
-		foreach ( $constraintsStatements->getIterator() as $constraintStatement ) {
128
-			$constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement );
129
-			if ( count( $constraints ) >= self::BATCH_SIZE ) {
130
-				$constraintRepo->insertBatch( $constraints );
127
+		foreach ($constraintsStatements->getIterator() as $constraintStatement) {
128
+			$constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement);
129
+			if (count($constraints) >= self::BATCH_SIZE) {
130
+				$constraintRepo->insertBatch($constraints);
131 131
 				$constraints = [];
132 132
 			}
133 133
 		}
134
-		$constraintRepo->insertBatch( $constraints );
134
+		$constraintRepo->insertBatch($constraints);
135 135
 	}
136 136
 
137 137
 	/**
@@ -142,14 +142,14 @@  discard block
 block discarded – undo
142 142
 	public function run() {
143 143
 		// TODO in the future: only touch constraints affected by the edit (requires T163465)
144 144
 
145
-		$propertyId = new PropertyId( $this->propertyId );
146
-		$this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId( $propertyId );
145
+		$propertyId = new PropertyId($this->propertyId);
146
+		$this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId($propertyId);
147 147
 
148
-		$property = $this->entityLookup->getEntity( $propertyId );
148
+		$property = $this->entityLookup->getEntity($propertyId);
149 149
 		$this->importConstraintsForProperty(
150 150
 			$property,
151 151
 			$this->constraintRepo,
152
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) )
152
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId'))
153 153
 		);
154 154
 
155 155
 		return true;
Please login to merge, or discard this patch.
src/ConstraintRepository.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -20,23 +20,23 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return Constraint[]
22 22
 	 */
23
-	public function queryConstraintsForProperty( PropertyId $propertyId ) {
24
-		$db = wfGetDB( DB_REPLICA );
23
+	public function queryConstraintsForProperty(PropertyId $propertyId) {
24
+		$db = wfGetDB(DB_REPLICA);
25 25
 
26 26
 		$results = $db->select(
27 27
 			'wbqc_constraints',
28 28
 			'*',
29
-			[ 'pid' => $propertyId->getNumericId() ]
29
+			['pid' => $propertyId->getNumericId()]
30 30
 		);
31 31
 
32
-		return $this->convertToConstraints( $results );
32
+		return $this->convertToConstraints($results);
33 33
 	}
34 34
 
35
-	private function encodeConstraintParameters( array $constraintParameters ) {
36
-		$json = json_encode( $constraintParameters, JSON_FORCE_OBJECT );
35
+	private function encodeConstraintParameters(array $constraintParameters) {
36
+		$json = json_encode($constraintParameters, JSON_FORCE_OBJECT);
37 37
 
38
-		if ( strlen( $json ) > 50000 ) {
39
-			$json = json_encode( [ '@error' => [ 'toolong' => true ] ] );
38
+		if (strlen($json) > 50000) {
39
+			$json = json_encode(['@error' => ['toolong' => true]]);
40 40
 		}
41 41
 
42 42
 		return $json;
@@ -48,21 +48,21 @@  discard block
 block discarded – undo
48 48
 	 * @throws DBUnexpectedError
49 49
 	 * @return bool
50 50
 	 */
51
-	public function insertBatch( array $constraints ) {
51
+	public function insertBatch(array $constraints) {
52 52
 		$accumulator = array_map(
53
-			function ( Constraint $constraint ) {
53
+			function(Constraint $constraint) {
54 54
 				return [
55 55
 					'constraint_guid' => $constraint->getConstraintId(),
56 56
 					'pid' => $constraint->getPropertyId()->getNumericId(),
57 57
 					'constraint_type_qid' => $constraint->getConstraintTypeItemId(),
58
-					'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() )
58
+					'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters())
59 59
 				];
60 60
 			},
61 61
 			$constraints
62 62
 		);
63 63
 
64
-		$db = wfGetDB( DB_MASTER );
65
-		return $db->insert( 'wbqc_constraints', $accumulator );
64
+		$db = wfGetDB(DB_MASTER);
65
+		return $db->insert('wbqc_constraints', $accumulator);
66 66
 	}
67 67
 
68 68
 	/**
@@ -70,13 +70,13 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return array
72 72
 	 */
73
-	private function uuidPattern( LikeMatch $any ) {
73
+	private function uuidPattern(LikeMatch $any) {
74 74
 		return array_merge(
75
-			array_fill( 0, 8, $any ), [ '-' ],
76
-			array_fill( 0, 4, $any ), [ '-' ],
77
-			array_fill( 0, 4, $any ), [ '-' ],
78
-			array_fill( 0, 4, $any ), [ '-' ],
79
-			array_fill( 0, 12, $any )
75
+			array_fill(0, 8, $any), ['-'],
76
+			array_fill(0, 4, $any), ['-'],
77
+			array_fill(0, 4, $any), ['-'],
78
+			array_fill(0, 4, $any), ['-'],
79
+			array_fill(0, 12, $any)
80 80
 		);
81 81
 	}
82 82
 
@@ -87,11 +87,11 @@  discard block
 block discarded – undo
87 87
 	 * @throws DBUnexpectedError
88 88
 	 */
89 89
 	public function deleteWhereConstraintIdIsUuid() {
90
-		$db = wfGetDB( DB_MASTER );
90
+		$db = wfGetDB(DB_MASTER);
91 91
 		$db->delete(
92 92
 			'wbqc_constraints',
93 93
 			// WHERE constraint_guid LIKE ________-____-____-____-____________
94
-			'constraint_guid ' . $db->buildLike( $this->uuidPattern( $db->anyChar() ) )
94
+			'constraint_guid '.$db->buildLike($this->uuidPattern($db->anyChar()))
95 95
 		);
96 96
 	}
97 97
 
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @throws DBUnexpectedError
103 103
 	 */
104
-	public function deleteForPropertyWhereConstraintIdIsStatementId( PropertyId $propertyId ) {
105
-		$db = wfGetDB( DB_MASTER );
104
+	public function deleteForPropertyWhereConstraintIdIsStatementId(PropertyId $propertyId) {
105
+		$db = wfGetDB(DB_MASTER);
106 106
 		$db->delete(
107 107
 			'wbqc_constraints',
108 108
 			[
109 109
 				'pid' => $propertyId->getNumericId(),
110 110
 				// AND constraint_guid LIKE %$________-____-____-____-____________
111
-				'constraint_guid ' . $db->buildLike( array_merge( [ $db->anyString(), '$' ], $this->uuidPattern( $db->anyChar() ) ) )
111
+				'constraint_guid '.$db->buildLike(array_merge([$db->anyString(), '$'], $this->uuidPattern($db->anyChar())))
112 112
 			]
113 113
 		);
114 114
 	}
@@ -119,20 +119,20 @@  discard block
 block discarded – undo
119 119
 	 * @throws InvalidArgumentException
120 120
 	 * @throws DBUnexpectedError
121 121
 	 */
122
-	public function deleteAll( $batchSize = 1000 ) {
123
-		if ( !is_int( $batchSize ) ) {
122
+	public function deleteAll($batchSize = 1000) {
123
+		if (!is_int($batchSize)) {
124 124
 			throw new InvalidArgumentException();
125 125
 		}
126
-		$db = wfGetDB( DB_MASTER );
127
-		if ( $db->getType() === 'sqlite' ) {
128
-			$db->delete( 'wbqc_constraints', '*' );
126
+		$db = wfGetDB(DB_MASTER);
127
+		if ($db->getType() === 'sqlite') {
128
+			$db->delete('wbqc_constraints', '*');
129 129
 		} else {
130 130
 			do {
131
-				$db->commit( __METHOD__, 'flush' );
131
+				$db->commit(__METHOD__, 'flush');
132 132
 				wfGetLBFactory()->waitForReplication();
133
-				$table = $db->tableName( 'wbqc_constraints' );
134
-				$db->query( sprintf( 'DELETE FROM %s LIMIT %d', $table, $batchSize ) );
135
-			} while ( $db->affectedRows() > 0 );
133
+				$table = $db->tableName('wbqc_constraints');
134
+				$db->query(sprintf('DELETE FROM %s LIMIT %d', $table, $batchSize));
135
+			} while ($db->affectedRows() > 0);
136 136
 		}
137 137
 	}
138 138
 
@@ -141,26 +141,26 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @return Constraint[]
143 143
 	 */
144
-	private function convertToConstraints( ResultWrapper $results ) {
144
+	private function convertToConstraints(ResultWrapper $results) {
145 145
 		$constraints = [];
146
-		foreach ( $results as $result ) {
146
+		foreach ($results as $result) {
147 147
 			$constraintTypeItemId = $result->constraint_type_qid;
148
-			$constraintParameters = json_decode( $result->constraint_parameters, true );
148
+			$constraintParameters = json_decode($result->constraint_parameters, true);
149 149
 
150
-			if ( $constraintParameters === null ) {
150
+			if ($constraintParameters === null) {
151 151
 				// T171295
152
-				LoggerFactory::getInstance( 'WikibaseQualityConstraints' )
153
-					->warning( 'Constraint {constraintId} has invalid constraint parameters.', [
152
+				LoggerFactory::getInstance('WikibaseQualityConstraints')
153
+					->warning('Constraint {constraintId} has invalid constraint parameters.', [
154 154
 						'method' => __METHOD__,
155 155
 						'constraintId' => $result->constraint_guid,
156 156
 						'constraintParameters' => $result->constraint_parameters,
157
-					] );
158
-				$constraintParameters = [ '@error' => [ /* unknown */ ] ];
157
+					]);
158
+				$constraintParameters = ['@error' => [/* unknown */]];
159 159
 			}
160 160
 
161 161
 			$constraints[] = new Constraint(
162 162
 				$result->constraint_guid,
163
-				PropertyId::newFromNumber( $result->pid ),
163
+				PropertyId::newFromNumber($result->pid),
164 164
 				$constraintTypeItemId,
165 165
 				$constraintParameters
166 166
 			);
Please login to merge, or discard this patch.
src/WikibaseQualityConstraintsHooks.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,36 +25,36 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @return bool
27 27
 	 */
28
-	public static function onCreateSchema( DatabaseUpdater $updater ) {
29
-		$updater->addExtensionTable( 'wbqc_constraints', __DIR__ . '/../sql/create_wbqc_constraints.sql' );
28
+	public static function onCreateSchema(DatabaseUpdater $updater) {
29
+		$updater->addExtensionTable('wbqc_constraints', __DIR__.'/../sql/create_wbqc_constraints.sql');
30 30
 		return true;
31 31
 	}
32 32
 
33
-	public static function onWikibaseChange( Change $change ) {
33
+	public static function onWikibaseChange(Change $change) {
34 34
 		$config = MediaWikiServices::getInstance()->getMainConfig();
35
-		if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) &&
36
-			self::isConstraintStatementsChange( $config, $change )
35
+		if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') &&
36
+			self::isConstraintStatementsChange($config, $change)
37 37
 		) {
38 38
 			/** @var EntityChange $change */
39 39
 			$title = Title::newMainPage();
40
-			$params = [ 'propertyId' => $change->getEntityId()->getSerialization() ];
40
+			$params = ['propertyId' => $change->getEntityId()->getSerialization()];
41 41
 			JobQueueGroup::singleton()->push(
42
-				new JobSpecification( 'constraintsTableUpdate', $params, [], $title )
42
+				new JobSpecification('constraintsTableUpdate', $params, [], $title)
43 43
 			);
44 44
 		}
45 45
 	}
46 46
 
47
-	public static function isConstraintStatementsChange( Config $config, Change $change ) {
48
-		if ( !( $change instanceof EntityChange ) ||
47
+	public static function isConstraintStatementsChange(Config $config, Change $change) {
48
+		if (!($change instanceof EntityChange) ||
49 49
 			 $change->getAction() !== EntityChange::UPDATE ||
50
-			 !( $change->getEntityId() instanceof PropertyId )
50
+			 !($change->getEntityId() instanceof PropertyId)
51 51
 		) {
52 52
 			return false;
53 53
 		}
54 54
 
55 55
 		$info = $change->getInfo();
56 56
 
57
-		if ( !array_key_exists( 'compactDiff', $info ) ) {
57
+		if (!array_key_exists('compactDiff', $info)) {
58 58
 			// the non-compact diff ($info['diff']) does not contain statement diffs (T110996),
59 59
 			// so we only know that the change *might* affect the constraint statements
60 60
 			return true;
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 		/** @var EntityDiffChangedAspects $aspects */
64 64
 		$aspects = $info['compactDiff'];
65 65
 
66
-		$propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' );
67
-		return in_array( $propertyConstraintId, $aspects->getStatementChanges() );
66
+		$propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId');
67
+		return in_array($propertyConstraintId, $aspects->getStatementChanges());
68 68
 	}
69 69
 
70 70
 }
Please login to merge, or discard this patch.
src/Specials/SpecialConstraintReport.php 1 patch
Spacing   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		DelegatingConstraintChecker $constraintChecker,
132 132
 		Config $config
133 133
 	) {
134
-		parent::__construct( 'ConstraintReport' );
134
+		parent::__construct('ConstraintReport');
135 135
 
136 136
 		$this->entityLookup = $entityLookup;
137 137
 		$this->entityTitleLookup = $entityTitleLookup;
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
 		$language = $this->getLanguage();
141 141
 
142 142
 		$formatterOptions = new FormatterOptions();
143
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
143
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
144 144
 		$this->dataValueFormatter = $valueFormatterFactory->getValueFormatter(
145 145
 			SnakFormatter::FORMAT_HTML,
146 146
 			$formatterOptions
147 147
 		);
148 148
 
149
-		$labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup( $language );
149
+		$labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup($language);
150 150
 
151 151
 		$this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter(
152 152
 			$labelLookup
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 		$this->constraintChecker = $constraintChecker;
160 160
 
161
-		$this->constraintParameterRenderer = new ConstraintParameterRenderer( $this->entityIdLabelFormatter, $this->dataValueFormatter );
161
+		$this->constraintParameterRenderer = new ConstraintParameterRenderer($this->entityIdLabelFormatter, $this->dataValueFormatter);
162 162
 
163 163
 		$this->config = $config;
164 164
 	}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 * @return array
170 170
 	 */
171 171
 	private function getModules() {
172
-		return [ 'SpecialConstraintReportPage' ];
172
+		return ['SpecialConstraintReportPage'];
173 173
 	}
174 174
 
175 175
 	/**
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @return string
188 188
 	 */
189 189
 	public function getDescription() {
190
-		return $this->msg( 'wbqc-constraintreport' )->escaped();
190
+		return $this->msg('wbqc-constraintreport')->escaped();
191 191
 	}
192 192
 
193 193
 	/**
@@ -199,60 +199,60 @@  discard block
 block discarded – undo
199 199
 	 * @throws EntityIdParsingException
200 200
 	 * @throws UnexpectedValueException
201 201
 	 */
202
-	public function execute( $subPage ) {
202
+	public function execute($subPage) {
203 203
 		$out = $this->getOutput();
204 204
 
205
-		$postRequest = $this->getContext()->getRequest()->getVal( 'entityid' );
206
-		if ( $postRequest ) {
207
-			$out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() );
205
+		$postRequest = $this->getContext()->getRequest()->getVal('entityid');
206
+		if ($postRequest) {
207
+			$out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL());
208 208
 			return;
209 209
 		}
210 210
 
211
-		$out->addModules( $this->getModules() );
211
+		$out->addModules($this->getModules());
212 212
 
213 213
 		$this->setHeaders();
214 214
 
215
-		$out->addHTML( $this->getExplanationText() );
215
+		$out->addHTML($this->getExplanationText());
216 216
 		$this->buildEntityIdForm();
217 217
 
218
-		if ( !$subPage ) {
218
+		if (!$subPage) {
219 219
 			return;
220 220
 		}
221 221
 
222
-		if ( !is_string( $subPage ) ) {
223
-			throw new InvalidArgumentException( '$subPage must be string.' );
222
+		if (!is_string($subPage)) {
223
+			throw new InvalidArgumentException('$subPage must be string.');
224 224
 		}
225 225
 
226 226
 		try {
227
-			$entityId = $this->entityIdParser->parse( $subPage );
228
-		} catch ( EntityIdParsingException $e ) {
227
+			$entityId = $this->entityIdParser->parse($subPage);
228
+		} catch (EntityIdParsingException $e) {
229 229
 			$out->addHTML(
230
-				$this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true )
230
+				$this->buildNotice('wbqc-constraintreport-invalid-entity-id', true)
231 231
 			);
232 232
 			return;
233 233
 		}
234 234
 
235
-		if ( !$this->entityLookup->hasEntity( $entityId ) ) {
235
+		if (!$this->entityLookup->hasEntity($entityId)) {
236 236
 			$out->addHTML(
237
-				$this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true )
237
+				$this->buildNotice('wbqc-constraintreport-not-existent-entity', true)
238 238
 			);
239 239
 			return;
240 240
 		}
241 241
 
242 242
 		MediaWikiServices::getInstance()->getStatsdDataFactory()
243
-			->increment( 'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck' );
244
-		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId );
243
+			->increment('wikibase.quality.constraints.specials.specialConstraintReport.executeCheck');
244
+		$results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId);
245 245
 
246
-		if ( count( $results ) > 0 ) {
246
+		if (count($results) > 0) {
247 247
 			$out->addHTML(
248
-				$this->buildResultHeader( $entityId )
249
-				. $this->buildSummary( $results )
250
-				. $this->buildResultTable( $entityId, $results )
248
+				$this->buildResultHeader($entityId)
249
+				. $this->buildSummary($results)
250
+				. $this->buildResultTable($entityId, $results)
251 251
 			);
252 252
 		} else {
253 253
 			$out->addHTML(
254
-				$this->buildResultHeader( $entityId )
255
-				. $this->buildNotice( 'wbqc-constraintreport-empty-result' )
254
+				$this->buildResultHeader($entityId)
255
+				. $this->buildNotice('wbqc-constraintreport-empty-result')
256 256
 			);
257 257
 		}
258 258
 	}
@@ -268,15 +268,15 @@  discard block
 block discarded – undo
268 268
 				'name' => 'entityid',
269 269
 				'label-message' => 'wbqc-constraintreport-form-entityid-label',
270 270
 				'cssclass' => 'wbqc-constraintreport-form-entity-id',
271
-				'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped()
271
+				'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped()
272 272
 			]
273 273
 		];
274
-		$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' );
275
-		$htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() );
276
-		$htmlForm->setSubmitCallback( function() {
274
+		$htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form');
275
+		$htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped());
276
+		$htmlForm->setSubmitCallback(function() {
277 277
 			return false;
278 278
 		} );
279
-		$htmlForm->setMethod( 'post' );
279
+		$htmlForm->setMethod('post');
280 280
 		$htmlForm->show();
281 281
 	}
282 282
 
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
 	 *
291 291
 	 * @return string HTML
292 292
 	 */
293
-	private function buildNotice( $messageKey, $error = false ) {
294
-		if ( !is_string( $messageKey ) ) {
295
-			throw new InvalidArgumentException( '$message must be string.' );
293
+	private function buildNotice($messageKey, $error = false) {
294
+		if (!is_string($messageKey)) {
295
+			throw new InvalidArgumentException('$message must be string.');
296 296
 		}
297
-		if ( !is_bool( $error ) ) {
298
-			throw new InvalidArgumentException( '$error must be bool.' );
297
+		if (!is_bool($error)) {
298
+			throw new InvalidArgumentException('$error must be bool.');
299 299
 		}
300 300
 
301 301
 		$cssClasses = 'wbqc-constraintreport-notice';
302
-		if ( $error ) {
302
+		if ($error) {
303 303
 			$cssClasses .= ' wbqc-constraintreport-notice-error';
304 304
 		}
305 305
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 				[
309 309
 					'class' => $cssClasses
310 310
 				],
311
-				$this->msg( $messageKey )->escaped()
311
+				$this->msg($messageKey)->escaped()
312 312
 			);
313 313
 	}
314 314
 
@@ -318,16 +318,16 @@  discard block
 block discarded – undo
318 318
 	private function getExplanationText() {
319 319
 		return Html::rawElement(
320 320
 			'div',
321
-			[ 'class' => 'wbqc-explanation' ],
321
+			['class' => 'wbqc-explanation'],
322 322
 			Html::rawElement(
323 323
 				'p',
324 324
 				[],
325
-				$this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped()
325
+				$this->msg('wbqc-constraintreport-explanation-part-one')->escaped()
326 326
 			)
327 327
 			. Html::rawElement(
328 328
 				'p',
329 329
 				[],
330
-				$this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped()
330
+				$this->msg('wbqc-constraintreport-explanation-part-two')->escaped()
331 331
 			)
332 332
 		);
333 333
 	}
@@ -338,69 +338,69 @@  discard block
 block discarded – undo
338 338
 	 *
339 339
 	 * @return string HTML
340 340
 	 */
341
-	private function buildResultTable( EntityId $entityId, array $results ) {
341
+	private function buildResultTable(EntityId $entityId, array $results) {
342 342
 		// Set table headers
343 343
 		$table = new HtmlTableBuilder(
344 344
 			[
345 345
 				new HtmlTableHeaderBuilder(
346
-					$this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(),
346
+					$this->msg('wbqc-constraintreport-result-table-header-status')->escaped(),
347 347
 					true
348 348
 				),
349 349
 				new HtmlTableHeaderBuilder(
350
-					$this->msg( 'wbqc-constraintreport-result-table-header-claim' )->escaped(),
350
+					$this->msg('wbqc-constraintreport-result-table-header-claim')->escaped(),
351 351
 					true
352 352
 				),
353 353
 				new HtmlTableHeaderBuilder(
354
-					$this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(),
354
+					$this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(),
355 355
 					true
356 356
 				)
357 357
 			]
358 358
 		);
359 359
 
360
-		foreach ( $results as $result ) {
361
-			$table = $this->appendToResultTable( $table, $entityId, $result );
360
+		foreach ($results as $result) {
361
+			$table = $this->appendToResultTable($table, $entityId, $result);
362 362
 		}
363 363
 
364 364
 		return $table->toHtml();
365 365
 	}
366 366
 
367
-	private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) {
367
+	private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) {
368 368
 		// Status column
369 369
 		$statusColumn = $this->buildTooltipElement(
370
-			$this->formatStatus( $result->getStatus() ),
370
+			$this->formatStatus($result->getStatus()),
371 371
 			$result->getMessage(),
372 372
 			'[?]'
373 373
 		);
374 374
 
375 375
 		// Claim column
376
-		$property = $this->entityIdLabelFormatter->formatEntityId( $result->getContext()->getSnak()->getPropertyId() );
377
-		if ( $result->getSnakType() === 'value' ) {
378
-			$value = $this->constraintParameterRenderer->formatValue( $result->getDataValue() );
376
+		$property = $this->entityIdLabelFormatter->formatEntityId($result->getContext()->getSnak()->getPropertyId());
377
+		if ($result->getSnakType() === 'value') {
378
+			$value = $this->constraintParameterRenderer->formatValue($result->getDataValue());
379 379
 		} else {
380
-			$value = htmlspecialchars( $result->getSnakType() );
380
+			$value = htmlspecialchars($result->getSnakType());
381 381
 		}
382 382
 
383 383
 		$claimColumn = $this->getClaimLink(
384 384
 			$entityId,
385 385
 			$result->getContext()->getSnak()->getPropertyId(),
386
-			$property . ': ' . $value
386
+			$property.': '.$value
387 387
 		);
388 388
 
389 389
 		// Constraint column
390 390
 		$constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId();
391 391
 		try {
392
-			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) );
393
-		} catch ( InvalidArgumentException $e ) {
394
-			$constraintTypeLabel = htmlspecialchars( $constraintTypeItemId );
392
+			$constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId));
393
+		} catch (InvalidArgumentException $e) {
394
+			$constraintTypeLabel = htmlspecialchars($constraintTypeItemId);
395 395
 		}
396 396
 		$constraintLink = $this->getClaimLink(
397 397
 			$result->getContext()->getSnak()->getPropertyId(),
398
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ),
398
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')),
399 399
 			$constraintTypeLabel
400 400
 		);
401 401
 		$constraintColumn = $this->buildExpandableElement(
402 402
 			$constraintLink,
403
-			$this->constraintParameterRenderer->formatParameters( $result->getParameters() ),
403
+			$this->constraintParameterRenderer->formatParameters($result->getParameters()),
404 404
 			'[...]'
405 405
 		);
406 406
 
@@ -435,15 +435,15 @@  discard block
 block discarded – undo
435 435
 	 *
436 436
 	 * @return string HTML
437 437
 	 */
438
-	protected function buildResultHeader( EntityId $entityId ) {
439
-		$entityLink = sprintf( '%s (%s)',
440
-							   $this->entityIdLinkFormatter->formatEntityId( $entityId ),
441
-							   htmlspecialchars( $entityId->getSerialization() ) );
438
+	protected function buildResultHeader(EntityId $entityId) {
439
+		$entityLink = sprintf('%s (%s)',
440
+							   $this->entityIdLinkFormatter->formatEntityId($entityId),
441
+							   htmlspecialchars($entityId->getSerialization()));
442 442
 
443 443
 		return Html::rawElement(
444 444
 			'h3',
445 445
 			[],
446
-			sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink )
446
+			sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink)
447 447
 		);
448 448
 	}
449 449
 
@@ -454,24 +454,24 @@  discard block
 block discarded – undo
454 454
 	 *
455 455
 	 * @return string HTML
456 456
 	 */
457
-	protected function buildSummary( array $results ) {
457
+	protected function buildSummary(array $results) {
458 458
 		$statuses = [];
459
-		foreach ( $results as $result ) {
460
-			$status = strtolower( $result->getStatus() );
461
-			$statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1;
459
+		foreach ($results as $result) {
460
+			$status = strtolower($result->getStatus());
461
+			$statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1;
462 462
 		}
463 463
 
464 464
 		$statusElements = [];
465
-		foreach ( $statuses as $status => $count ) {
466
-			if ( $count > 0 ) {
465
+		foreach ($statuses as $status => $count) {
466
+			if ($count > 0) {
467 467
 				$statusElements[] =
468
-					$this->formatStatus( $status )
468
+					$this->formatStatus($status)
469 469
 					. ': '
470 470
 					. $count;
471 471
 			}
472 472
 		}
473 473
 
474
-		return Html::rawElement( 'p', [], implode( ', ', $statusElements ) );
474
+		return Html::rawElement('p', [], implode(', ', $statusElements));
475 475
 	}
476 476
 
477 477
 	/**
@@ -486,15 +486,15 @@  discard block
 block discarded – undo
486 486
 	 *
487 487
 	 * @return string HTML
488 488
 	 */
489
-	protected function buildTooltipElement( $content, $tooltipContent, $indicator ) {
490
-		if ( !is_string( $content ) ) {
491
-			throw new InvalidArgumentException( '$content has to be string.' );
489
+	protected function buildTooltipElement($content, $tooltipContent, $indicator) {
490
+		if (!is_string($content)) {
491
+			throw new InvalidArgumentException('$content has to be string.');
492 492
 		}
493
-		if ( $tooltipContent && ( !is_string( $tooltipContent ) ) ) {
494
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
493
+		if ($tooltipContent && (!is_string($tooltipContent))) {
494
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
495 495
 		}
496 496
 
497
-		if ( empty( $tooltipContent ) ) {
497
+		if (empty($tooltipContent)) {
498 498
 			return $content;
499 499
 		}
500 500
 
@@ -511,13 +511,13 @@  discard block
 block discarded – undo
511 511
 			[
512 512
 				'class' => 'wbqc-indicator'
513 513
 			],
514
-			htmlspecialchars( $indicator ) . $tooltip
514
+			htmlspecialchars($indicator).$tooltip
515 515
 		);
516 516
 
517 517
 		return Html::rawElement(
518 518
 			'span',
519 519
 			[],
520
-			sprintf( '%s %s', $content, $tooltipIndicator )
520
+			sprintf('%s %s', $content, $tooltipIndicator)
521 521
 		);
522 522
 	}
523 523
 
@@ -533,15 +533,15 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @return string HTML
535 535
 	 */
536
-	protected function buildExpandableElement( $content, $expandableContent, $indicator ) {
537
-		if ( !is_string( $content ) ) {
538
-			throw new InvalidArgumentException( '$content has to be string.' );
536
+	protected function buildExpandableElement($content, $expandableContent, $indicator) {
537
+		if (!is_string($content)) {
538
+			throw new InvalidArgumentException('$content has to be string.');
539 539
 		}
540
-		if ( $expandableContent && ( !is_string( $expandableContent ) ) ) {
541
-			throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' );
540
+		if ($expandableContent && (!is_string($expandableContent))) {
541
+			throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.');
542 542
 		}
543 543
 
544
-		if ( empty( $expandableContent ) ) {
544
+		if (empty($expandableContent)) {
545 545
 			return $content;
546 546
 		}
547 547
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 		);
563 563
 
564 564
 		return
565
-			sprintf( '%s %s %s', $content, $tooltipIndicator, $expandableContent );
565
+			sprintf('%s %s %s', $content, $tooltipIndicator, $expandableContent);
566 566
 	}
567 567
 
568 568
 	/**
@@ -574,16 +574,16 @@  discard block
 block discarded – undo
574 574
 	 *
575 575
 	 * @return string HTML
576 576
 	 */
577
-	private function formatStatus( $status ) {
578
-		$messageName = "wbqc-constraintreport-status-" . strtolower( $status );
577
+	private function formatStatus($status) {
578
+		$messageName = "wbqc-constraintreport-status-".strtolower($status);
579 579
 
580 580
 		$formattedStatus =
581 581
 			Html::element(
582 582
 				'span',
583 583
 				[
584
-					'class' => 'wbqc-status wbqc-status-' . $status
584
+					'class' => 'wbqc-status wbqc-status-'.$status
585 585
 				],
586
-				$this->msg( $messageName )->text()
586
+				$this->msg($messageName)->text()
587 587
 			);
588 588
 
589 589
 		return $formattedStatus;
@@ -599,26 +599,26 @@  discard block
 block discarded – undo
599 599
 	 *
600 600
 	 * @return string HTML
601 601
 	 */
602
-	protected function formatDataValues( $dataValues, $separator = ', ' ) {
603
-		if ( $dataValues instanceof DataValue ) {
604
-			$dataValues = [ $dataValues ];
605
-		} elseif ( !is_array( $dataValues ) ) {
606
-			throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
602
+	protected function formatDataValues($dataValues, $separator = ', ') {
603
+		if ($dataValues instanceof DataValue) {
604
+			$dataValues = [$dataValues];
605
+		} elseif (!is_array($dataValues)) {
606
+			throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
607 607
 		}
608 608
 
609 609
 		$formattedDataValues = [];
610
-		foreach ( $dataValues as $dataValue ) {
611
-			if ( !( $dataValue instanceof DataValue ) ) {
612
-				throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' );
610
+		foreach ($dataValues as $dataValue) {
611
+			if (!($dataValue instanceof DataValue)) {
612
+				throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.');
613 613
 			}
614
-			if ( $dataValue instanceof EntityIdValue ) {
615
-				$formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() );
614
+			if ($dataValue instanceof EntityIdValue) {
615
+				$formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId());
616 616
 			} else {
617
-				$formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue );
617
+				$formattedDataValues[] = $this->dataValueFormatter->format($dataValue);
618 618
 			}
619 619
 		}
620 620
 
621
-		return implode( $separator, $formattedDataValues );
621
+		return implode($separator, $formattedDataValues);
622 622
 	}
623 623
 
624 624
 	/**
@@ -630,12 +630,12 @@  discard block
 block discarded – undo
630 630
 	 *
631 631
 	 * @return string HTML
632 632
 	 */
633
-	private function getClaimLink( EntityId $entityId, PropertyId $propertyId, $text ) {
633
+	private function getClaimLink(EntityId $entityId, PropertyId $propertyId, $text) {
634 634
 		return
635 635
 			Html::rawElement(
636 636
 				'a',
637 637
 				[
638
-					'href' => $this->getClaimUrl( $entityId, $propertyId ),
638
+					'href' => $this->getClaimUrl($entityId, $propertyId),
639 639
 					'target' => '_blank'
640 640
 				],
641 641
 				$text
@@ -650,9 +650,9 @@  discard block
 block discarded – undo
650 650
 	 *
651 651
 	 * @return string
652 652
 	 */
653
-	private function getClaimUrl( EntityId $entityId, PropertyId $propertyId ) {
654
-		$title = $this->entityTitleLookup->getTitleForId( $entityId );
655
-		$entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() );
653
+	private function getClaimUrl(EntityId $entityId, PropertyId $propertyId) {
654
+		$title = $this->entityTitleLookup->getTitleForId($entityId);
655
+		$entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization());
656 656
 
657 657
 		return $entityUrl;
658 658
 	}
Please login to merge, or discard this patch.