Completed
Push — master ( 1bc60b...96730f )
by
unknown
06:11 queued 11s
created
src/ConstraintStore.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	 * @return bool
17 17
 	 * @throws DBUnexpectedError
18 18
 	 */
19
-	public function insertBatch( array $constraints );
19
+	public function insertBatch(array $constraints);
20 20
 
21 21
 	/**
22 22
 	 * Delete all constraints for the property ID.
@@ -25,6 +25,6 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @throws DBUnexpectedError
27 27
 	 */
28
-	public function deleteForProperty( PropertyId $propertyId );
28
+	public function deleteForProperty(PropertyId $propertyId);
29 29
 
30 30
 }
Please login to merge, or discard this patch.
src/ConstraintRepositoryStore.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
 	 * then using the main DBLoadBalancer service may be incorrect.
25 25
 	 * @param string|false $dbName Database name ($domain for ILoadBalancer methods).
26 26
 	 */
27
-	public function __construct( ILoadBalancer $lb, $dbName ) {
27
+	public function __construct(ILoadBalancer $lb, $dbName) {
28 28
 		$this->lb = $lb;
29 29
 		$this->dbName = $dbName;
30 30
 	}
31 31
 
32
-	private function encodeConstraintParameters( array $constraintParameters ) {
33
-		$json = json_encode( $constraintParameters, JSON_FORCE_OBJECT );
32
+	private function encodeConstraintParameters(array $constraintParameters) {
33
+		$json = json_encode($constraintParameters, JSON_FORCE_OBJECT);
34 34
 
35
-		if ( strlen( $json ) > 50000 ) {
36
-			$json = json_encode( [ '@error' => [ 'toolong' => true ] ] );
35
+		if (strlen($json) > 50000) {
36
+			$json = json_encode(['@error' => ['toolong' => true]]);
37 37
 		}
38 38
 
39 39
 		return $json;
@@ -45,21 +45,21 @@  discard block
 block discarded – undo
45 45
 	 * @throws DBUnexpectedError
46 46
 	 * @return bool
47 47
 	 */
48
-	public function insertBatch( array $constraints ) {
48
+	public function insertBatch(array $constraints) {
49 49
 		$accumulator = array_map(
50
-			function ( Constraint $constraint ) {
50
+			function(Constraint $constraint) {
51 51
 				return [
52 52
 					'constraint_guid' => $constraint->getConstraintId(),
53 53
 					'pid' => $constraint->getPropertyId()->getNumericId(),
54 54
 					'constraint_type_qid' => $constraint->getConstraintTypeItemId(),
55
-					'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() )
55
+					'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters())
56 56
 				];
57 57
 			},
58 58
 			$constraints
59 59
 		);
60 60
 
61
-		$dbw = $this->lb->getConnection( ILoadBalancer::DB_MASTER, [], $this->dbName );
62
-		return $dbw->insert( 'wbqc_constraints', $accumulator, __METHOD__ );
61
+		$dbw = $this->lb->getConnection(ILoadBalancer::DB_MASTER, [], $this->dbName);
62
+		return $dbw->insert('wbqc_constraints', $accumulator, __METHOD__);
63 63
 	}
64 64
 
65 65
 	/**
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @throws DBUnexpectedError
71 71
 	 */
72
-	public function deleteForProperty( PropertyId $propertyId ) {
73
-		$dbw = $this->lb->getConnection( ILoadBalancer::DB_MASTER, [], $this->dbName );
72
+	public function deleteForProperty(PropertyId $propertyId) {
73
+		$dbw = $this->lb->getConnection(ILoadBalancer::DB_MASTER, [], $this->dbName);
74 74
 		$dbw->delete(
75 75
 			'wbqc_constraints',
76 76
 			[
Please login to merge, or discard this patch.
src/ConstraintRepositoryLookup.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * then using the main DBLoadBalancer service may be incorrect.
26 26
 	 * @param string|false $dbName Database name ($domain for ILoadBalancer methods).
27 27
 	 */
28
-	public function __construct( ILoadBalancer $lb, $dbName ) {
28
+	public function __construct(ILoadBalancer $lb, $dbName) {
29 29
 		$this->lb = $lb;
30 30
 		$this->dbName = $dbName;
31 31
 	}
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return Constraint[]
37 37
 	 */
38
-	public function queryConstraintsForProperty( PropertyId $propertyId ) {
39
-		$dbr = $this->lb->getConnectionRef( ILoadBalancer::DB_REPLICA, [], $this->dbName );
38
+	public function queryConstraintsForProperty(PropertyId $propertyId) {
39
+		$dbr = $this->lb->getConnectionRef(ILoadBalancer::DB_REPLICA, [], $this->dbName);
40 40
 
41 41
 		$results = $dbr->select(
42 42
 			'wbqc_constraints',
43 43
 			'*',
44
-			[ 'pid' => $propertyId->getNumericId() ],
44
+			['pid' => $propertyId->getNumericId()],
45 45
 			__METHOD__
46 46
 		);
47 47
 
48
-		return $this->convertToConstraints( $results );
48
+		return $this->convertToConstraints($results);
49 49
 	}
50 50
 
51 51
 	/**
@@ -53,26 +53,26 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return Constraint[]
55 55
 	 */
56
-	private function convertToConstraints( IResultWrapper $results ) {
56
+	private function convertToConstraints(IResultWrapper $results) {
57 57
 		$constraints = [];
58
-		$logger = LoggerFactory::getInstance( 'WikibaseQualityConstraints' );
59
-		foreach ( $results as $result ) {
58
+		$logger = LoggerFactory::getInstance('WikibaseQualityConstraints');
59
+		foreach ($results as $result) {
60 60
 			$constraintTypeItemId = $result->constraint_type_qid;
61
-			$constraintParameters = json_decode( $result->constraint_parameters, true );
61
+			$constraintParameters = json_decode($result->constraint_parameters, true);
62 62
 
63
-			if ( $constraintParameters === null ) {
63
+			if ($constraintParameters === null) {
64 64
 				// T171295
65
-				$logger->warning( 'Constraint {constraintId} has invalid constraint parameters.', [
65
+				$logger->warning('Constraint {constraintId} has invalid constraint parameters.', [
66 66
 					'method' => __METHOD__,
67 67
 					'constraintId' => $result->constraint_guid,
68 68
 					'constraintParameters' => $result->constraint_parameters,
69
-				] );
70
-				$constraintParameters = [ '@error' => [ /* unknown */ ] ];
69
+				]);
70
+				$constraintParameters = ['@error' => [/* unknown */]];
71 71
 			}
72 72
 
73 73
 			$constraints[] = new Constraint(
74 74
 				$result->constraint_guid,
75
-				PropertyId::newFromNumber( $result->pid ),
75
+				PropertyId::newFromNumber($result->pid),
76 76
 				$constraintTypeItemId,
77 77
 				$constraintParameters
78 78
 			);
Please login to merge, or discard this patch.
maintenance/ImportConstraintEntities.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 use Wikibase\Repo\WikibaseRepo;
18 18
 
19 19
 // @codeCoverageIgnoreStart
20
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
21
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
20
+$basePath = getenv("MW_INSTALL_PATH") !== false
21
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
22 22
 
23
-require_once $basePath . "/maintenance/Maintenance.php";
23
+require_once $basePath."/maintenance/Maintenance.php";
24 24
 // @codeCoverageIgnoreEnd
25 25
 
26 26
 /**
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 		parent::__construct();
60 60
 
61 61
 		$this->addDescription(
62
-			'Import entities needed for constraint checks ' .
62
+			'Import entities needed for constraint checks '.
63 63
 			'from Wikidata into the local repository.'
64 64
 		);
65 65
 		$this->addOption(
66 66
 			'config-format',
67
-			'The format in which the resulting configuration will be omitted: ' .
68
-			'"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), ' .
67
+			'The format in which the resulting configuration will be omitted: '.
68
+			'"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), '.
69 69
 			'or "wgConf" for printing parts of arrays suitable for inclusion in $wgConf->settings.'
70 70
 		);
71 71
 		$this->addOption(
72 72
 			'dry-run',
73 73
 			'Don’t actually import entities, just print which ones would be imported.'
74 74
 		);
75
-		$this->requireExtension( 'WikibaseQualityConstraints' );
75
+		$this->requireExtension('WikibaseQualityConstraints');
76 76
 	}
77 77
 
78 78
 	/**
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 		$this->entityDeserializer = $repo->getInternalFormatEntityDeserializer();
85 85
 		$this->entityStore = $repo->getEntityStore();
86 86
 		$this->httpRequestFactory = MediaWikiServices::getInstance()->getHttpRequestFactory();
87
-		if ( !$this->getOption( 'dry-run', false ) ) {
88
-			$this->user = User::newSystemUser( 'WikibaseQualityConstraints importer' );
87
+		if (!$this->getOption('dry-run', false)) {
88
+			$this->user = User::newSystemUser('WikibaseQualityConstraints importer');
89 89
 		}
90 90
 	}
91 91
 
@@ -94,21 +94,21 @@  discard block
 block discarded – undo
94 94
 
95 95
 		$configUpdates = [];
96 96
 
97
-		$extensionJsonFile = __DIR__ . '/../extension.json';
98
-		$extensionJsonText = file_get_contents( $extensionJsonFile );
99
-		$extensionJson = json_decode( $extensionJsonText, /* assoc = */ true );
97
+		$extensionJsonFile = __DIR__.'/../extension.json';
98
+		$extensionJsonText = file_get_contents($extensionJsonFile);
99
+		$extensionJson = json_decode($extensionJsonText, /* assoc = */ true);
100 100
 		// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
101
-		$wikidataEntityIds = $this->getEntitiesToImport( $extensionJson['config'], $this->getConfig() );
101
+		$wikidataEntityIds = $this->getEntitiesToImport($extensionJson['config'], $this->getConfig());
102 102
 
103
-		foreach ( $wikidataEntityIds as $key => $wikidataEntityId ) {
104
-			$localEntityId = $this->importEntityFromWikidata( $wikidataEntityId );
103
+		foreach ($wikidataEntityIds as $key => $wikidataEntityId) {
104
+			$localEntityId = $this->importEntityFromWikidata($wikidataEntityId);
105 105
 			$configUpdates[$key] = [
106 106
 				'wikidata' => $wikidataEntityId,
107 107
 				'local' => $localEntityId,
108 108
 			];
109 109
 		}
110 110
 
111
-		$this->outputConfigUpdates( $configUpdates );
111
+		$this->outputConfigUpdates($configUpdates);
112 112
 	}
113 113
 
114 114
 	/**
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 	 * @param Config $wikiConfig
117 117
 	 * @return string[]
118 118
 	 */
119
-	private function getEntitiesToImport( array $extensionJsonConfig, Config $wikiConfig ) {
119
+	private function getEntitiesToImport(array $extensionJsonConfig, Config $wikiConfig) {
120 120
 		$wikidataEntityIds = [];
121 121
 
122
-		foreach ( $extensionJsonConfig as $key => $value ) {
123
-			if ( !preg_match( '/Id$/', $key ) ) {
122
+		foreach ($extensionJsonConfig as $key => $value) {
123
+			if (!preg_match('/Id$/', $key)) {
124 124
 				continue;
125 125
 			}
126 126
 
127 127
 			$wikidataEntityId = $value['value'];
128
-			$localEntityId = $wikiConfig->get( $key );
128
+			$localEntityId = $wikiConfig->get($key);
129 129
 
130
-			if ( $localEntityId === $wikidataEntityId ) {
130
+			if ($localEntityId === $wikidataEntityId) {
131 131
 				$wikidataEntityIds[$key] = $wikidataEntityId;
132 132
 			}
133 133
 		}
@@ -139,10 +139,10 @@  discard block
 block discarded – undo
139 139
 	 * @param string $wikidataEntityId
140 140
 	 * @return string local entity ID
141 141
 	 */
142
-	private function importEntityFromWikidata( $wikidataEntityId ) {
142
+	private function importEntityFromWikidata($wikidataEntityId) {
143 143
 		$wikidataEntityUrl = "https://www.wikidata.org/wiki/Special:EntityData/$wikidataEntityId.json";
144
-		$wikidataEntitiesJson = $this->httpRequestFactory->get( $wikidataEntityUrl, [], __METHOD__ );
145
-		return $this->importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson );
144
+		$wikidataEntitiesJson = $this->httpRequestFactory->get($wikidataEntityUrl, [], __METHOD__);
145
+		return $this->importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson);
146 146
 	}
147 147
 
148 148
 	/**
@@ -150,24 +150,24 @@  discard block
 block discarded – undo
150 150
 	 * @param string $wikidataEntitiesJson
151 151
 	 * @return string local entity ID
152 152
 	 */
153
-	private function importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ) {
153
+	private function importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson) {
154 154
 		// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
155
-		$wikidataEntityArray = json_decode( $wikidataEntitiesJson, true )['entities'][$wikidataEntityId];
156
-		$wikidataEntity = $this->entityDeserializer->deserialize( $wikidataEntityArray );
155
+		$wikidataEntityArray = json_decode($wikidataEntitiesJson, true)['entities'][$wikidataEntityId];
156
+		$wikidataEntity = $this->entityDeserializer->deserialize($wikidataEntityArray);
157 157
 
158
-		$wikidataEntity->setId( null );
158
+		$wikidataEntity->setId(null);
159 159
 
160
-		if ( $wikidataEntity instanceof StatementListProvider ) {
160
+		if ($wikidataEntity instanceof StatementListProvider) {
161 161
 			$wikidataEntity->getStatements()->clear();
162 162
 		}
163 163
 
164
-		if ( $wikidataEntity instanceof Item ) {
165
-			$wikidataEntity->setSiteLinkList( new SiteLinkList() );
164
+		if ($wikidataEntity instanceof Item) {
165
+			$wikidataEntity->setSiteLinkList(new SiteLinkList());
166 166
 		}
167 167
 
168
-		if ( $this->getOption( 'dry-run', false ) ) {
169
-			$wikidataEntityJson = json_encode( $this->entitySerializer->serialize( $wikidataEntity ) );
170
-			$this->output( $wikidataEntityJson . "\n" );
168
+		if ($this->getOption('dry-run', false)) {
169
+			$wikidataEntityJson = json_encode($this->entitySerializer->serialize($wikidataEntity));
170
+			$this->output($wikidataEntityJson."\n");
171 171
 			return "-$wikidataEntityId";
172 172
 		}
173 173
 
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 			)->getEntity();
181 181
 
182 182
 			return $localEntity->getId()->getSerialization();
183
-		} catch ( StorageException $storageException ) {
184
-			return $this->storageExceptionToEntityId( $storageException );
183
+		} catch (StorageException $storageException) {
184
+			return $this->storageExceptionToEntityId($storageException);
185 185
 		}
186 186
 	}
187 187
 
188
-	private function storageExceptionToEntityId( StorageException $storageException ) {
188
+	private function storageExceptionToEntityId(StorageException $storageException) {
189 189
 		$message = $storageException->getMessage();
190 190
 		// example messages:
191 191
 		// * Item [[Item:Q475|Q475]] already has label "as references"
@@ -195,25 +195,25 @@  discard block
 block discarded – undo
195 195
 		// * Property [[Property:P694|P694]] already has label "instance of"
196 196
 		//   associated with language code en.
197 197
 		$pattern = '/[[|]([^][|]*)]] already has label .* associated with language code/';
198
-		if ( preg_match( $pattern, $message, $matches ) ) {
198
+		if (preg_match($pattern, $message, $matches)) {
199 199
 			return $matches[1];
200 200
 		} else {
201 201
 			throw $storageException;
202 202
 		}
203 203
 	}
204 204
 
205
-	private function outputConfigUpdates( array $configUpdates ) {
206
-		$configFormat = $this->getOption( 'config-format', 'globals' );
207
-		switch ( $configFormat ) {
205
+	private function outputConfigUpdates(array $configUpdates) {
206
+		$configFormat = $this->getOption('config-format', 'globals');
207
+		switch ($configFormat) {
208 208
 			case 'globals':
209
-				$this->outputConfigUpdatesGlobals( $configUpdates );
209
+				$this->outputConfigUpdatesGlobals($configUpdates);
210 210
 				break;
211 211
 			case 'wgConf':
212
-				$this->outputConfigUpdatesWgConf( $configUpdates );
212
+				$this->outputConfigUpdatesWgConf($configUpdates);
213 213
 				break;
214 214
 			default:
215
-				$this->error( "Invalid config format \"$configFormat\", using \"globals\"" );
216
-				$this->outputConfigUpdatesGlobals( $configUpdates );
215
+				$this->error("Invalid config format \"$configFormat\", using \"globals\"");
216
+				$this->outputConfigUpdatesGlobals($configUpdates);
217 217
 				break;
218 218
 		}
219 219
 	}
@@ -221,22 +221,22 @@  discard block
 block discarded – undo
221 221
 	/**
222 222
 	 * @param array[] $configUpdates
223 223
 	 */
224
-	private function outputConfigUpdatesGlobals( array $configUpdates ) {
225
-		foreach ( $configUpdates as $key => $value ) {
226
-			$localValueCode = var_export( $value['local'], true );
227
-			$this->output( "\$wg$key = $localValueCode;\n" );
224
+	private function outputConfigUpdatesGlobals(array $configUpdates) {
225
+		foreach ($configUpdates as $key => $value) {
226
+			$localValueCode = var_export($value['local'], true);
227
+			$this->output("\$wg$key = $localValueCode;\n");
228 228
 		}
229 229
 	}
230 230
 
231 231
 	/**
232 232
 	 * @param array[] $configUpdates
233 233
 	 */
234
-	private function outputConfigUpdatesWgConf( array $configUpdates ) {
235
-		foreach ( $configUpdates as $key => $value ) {
236
-			$keyCode = var_export( "wg$key", true );
237
-			$wikidataValueCode = var_export( $value['wikidata'], true );
238
-			$localValueCode = var_export( $value['local'], true );
239
-			$wikiIdCode = var_export( wfWikiID(), true );
234
+	private function outputConfigUpdatesWgConf(array $configUpdates) {
235
+		foreach ($configUpdates as $key => $value) {
236
+			$keyCode = var_export("wg$key", true);
237
+			$wikidataValueCode = var_export($value['wikidata'], true);
238
+			$localValueCode = var_export($value['local'], true);
239
+			$wikiIdCode = var_export(wfWikiID(), true);
240 240
 			$block = <<< EOF
241 241
 $keyCode => [
242 242
 	'default' => $wikidataValueCode,
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 
246 246
 
247 247
 EOF;
248
-			$this->output( $block );
248
+			$this->output($block);
249 249
 		}
250 250
 	}
251 251
 
Please login to merge, or discard this patch.
src/WikibaseQualityConstraintsHooks.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -28,25 +28,25 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @param DatabaseUpdater $updater
30 30
 	 */
31
-	public static function onCreateSchema( DatabaseUpdater $updater ) {
31
+	public static function onCreateSchema(DatabaseUpdater $updater) {
32 32
 		$updater->addExtensionTable(
33 33
 			'wbqc_constraints',
34
-			__DIR__ . '/../sql/create_wbqc_constraints.sql'
34
+			__DIR__.'/../sql/create_wbqc_constraints.sql'
35 35
 		);
36 36
 		$updater->addExtensionField(
37 37
 			'wbqc_constraints',
38 38
 			'constraint_id',
39
-			__DIR__ . '/../sql/patch-wbqc_constraints-constraint_id.sql'
39
+			__DIR__.'/../sql/patch-wbqc_constraints-constraint_id.sql'
40 40
 		);
41 41
 		$updater->addExtensionIndex(
42 42
 			'wbqc_constraints',
43 43
 			'wbqc_constraints_guid_uniq',
44
-			__DIR__ . '/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql'
44
+			__DIR__.'/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql'
45 45
 		);
46 46
 	}
47 47
 
48
-	public static function onWikibaseChange( Change $change ) {
49
-		if ( !( $change instanceof EntityChange ) ) {
48
+	public static function onWikibaseChange(Change $change) {
49
+		if (!($change instanceof EntityChange)) {
50 50
 			return;
51 51
 		}
52 52
 
@@ -55,48 +55,48 @@  discard block
 block discarded – undo
55 55
 
56 56
 		// If jobs are enabled and the results would be stored in some way run a job.
57 57
 		if (
58
-			$config->get( 'WBQualityConstraintsEnableConstraintsCheckJobs' ) &&
59
-			$config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) &&
58
+			$config->get('WBQualityConstraintsEnableConstraintsCheckJobs') &&
59
+			$config->get('WBQualityConstraintsCacheCheckConstraintsResults') &&
60 60
 			self::isSelectedForJobRunBasedOnPercentage()
61 61
 		) {
62
-			$params = [ 'entityId' => $change->getEntityId()->getSerialization() ];
62
+			$params = ['entityId' => $change->getEntityId()->getSerialization()];
63 63
 			JobQueueGroup::singleton()->push(
64
-				new JobSpecification( CheckConstraintsJob::COMMAND, $params )
64
+				new JobSpecification(CheckConstraintsJob::COMMAND, $params)
65 65
 			);
66 66
 		}
67 67
 
68
-		if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) &&
69
-			self::isConstraintStatementsChange( $config, $change )
68
+		if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') &&
69
+			self::isConstraintStatementsChange($config, $change)
70 70
 		) {
71
-			$params = [ 'propertyId' => $change->getEntityId()->getSerialization() ];
71
+			$params = ['propertyId' => $change->getEntityId()->getSerialization()];
72 72
 			$metadata = $change->getMetadata();
73
-			if ( array_key_exists( 'rev_id', $metadata ) ) {
73
+			if (array_key_exists('rev_id', $metadata)) {
74 74
 				$params['revisionId'] = $metadata['rev_id'];
75 75
 			}
76 76
 			JobQueueGroup::singleton()->push(
77
-				new JobSpecification( 'constraintsTableUpdate', $params )
77
+				new JobSpecification('constraintsTableUpdate', $params)
78 78
 			);
79 79
 		}
80 80
 	}
81 81
 
82 82
 	private static function isSelectedForJobRunBasedOnPercentage() {
83 83
 		$config = MediaWikiServices::getInstance()->getMainConfig();
84
-		$percentage = $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobsRatio' );
84
+		$percentage = $config->get('WBQualityConstraintsEnableConstraintsCheckJobsRatio');
85 85
 
86
-		return mt_rand( 1, 100 ) <= $percentage;
86
+		return mt_rand(1, 100) <= $percentage;
87 87
 	}
88 88
 
89
-	public static function isConstraintStatementsChange( Config $config, Change $change ) {
90
-		if ( !( $change instanceof EntityChange ) ||
89
+	public static function isConstraintStatementsChange(Config $config, Change $change) {
90
+		if (!($change instanceof EntityChange) ||
91 91
 			 $change->getAction() !== EntityChange::UPDATE ||
92
-			 !( $change->getEntityId() instanceof PropertyId )
92
+			 !($change->getEntityId() instanceof PropertyId)
93 93
 		) {
94 94
 			return false;
95 95
 		}
96 96
 
97 97
 		$info = $change->getInfo();
98 98
 
99
-		if ( !array_key_exists( 'compactDiff', $info ) ) {
99
+		if (!array_key_exists('compactDiff', $info)) {
100 100
 			// the non-compact diff ($info['diff']) does not contain statement diffs (T110996),
101 101
 			// so we only know that the change *might* affect the constraint statements
102 102
 			return true;
@@ -105,47 +105,47 @@  discard block
 block discarded – undo
105 105
 		/** @var EntityDiffChangedAspects $aspects */
106 106
 		$aspects = $info['compactDiff'];
107 107
 
108
-		$propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' );
109
-		return in_array( $propertyConstraintId, $aspects->getStatementChanges() );
108
+		$propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId');
109
+		return in_array($propertyConstraintId, $aspects->getStatementChanges());
110 110
 	}
111 111
 
112
-	public static function onArticlePurge( WikiPage $wikiPage ) {
112
+	public static function onArticlePurge(WikiPage $wikiPage) {
113 113
 		$repo = WikibaseRepo::getDefaultInstance();
114 114
 
115 115
 		$entityContentFactory = $repo->getEntityContentFactory();
116
-		if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) {
116
+		if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) {
117 117
 			$entityIdLookup = $repo->getEntityIdLookup();
118
-			$entityId = $entityIdLookup->getEntityIdForTitle( $wikiPage->getTitle() );
119
-			if ( $entityId !== null ) {
118
+			$entityId = $entityIdLookup->getEntityIdForTitle($wikiPage->getTitle());
119
+			if ($entityId !== null) {
120 120
 				$resultsCache = ResultsCache::getDefaultInstance();
121
-				$resultsCache->delete( $entityId );
121
+				$resultsCache->delete($entityId);
122 122
 			}
123 123
 		}
124 124
 	}
125 125
 
126
-	public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
126
+	public static function onBeforePageDisplay(OutputPage $out, Skin $skin) {
127 127
 		$repo = WikibaseRepo::getDefaultInstance();
128 128
 
129 129
 		$lookup = $repo->getEntityNamespaceLookup();
130 130
 		$title = $out->getTitle();
131
-		if ( $title === null ) {
131
+		if ($title === null) {
132 132
 			return;
133 133
 		}
134 134
 
135
-		if ( !$lookup->isNamespaceWithEntities( $title->getNamespace() ) ) {
135
+		if (!$lookup->isNamespaceWithEntities($title->getNamespace())) {
136 136
 			return;
137 137
 		}
138
-		if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) {
138
+		if (empty($out->getJsConfigVars()['wbIsEditView'])) {
139 139
 			return;
140 140
 		}
141 141
 
142
-		$out->addModules( 'wikibase.quality.constraints.suggestions' );
142
+		$out->addModules('wikibase.quality.constraints.suggestions');
143 143
 
144
-		if ( !$out->getUser()->isLoggedIn() ) {
144
+		if (!$out->getUser()->isLoggedIn()) {
145 145
 			return;
146 146
 		}
147 147
 
148
-		$out->addModules( 'wikibase.quality.constraints.gadget' );
148
+		$out->addModules('wikibase.quality.constraints.gadget');
149 149
 	}
150 150
 
151 151
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/DelegatingConstraintChecker.php 1 patch
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 		callable $defaultResultsPerEntity = null
144 144
 	) {
145 145
 		$checkResults = [];
146
-		$entity = $this->entityLookup->getEntity( $entityId );
146
+		$entity = $this->entityLookup->getEntity($entityId);
147 147
 
148
-		if ( $entity instanceof StatementListProvidingEntity ) {
149
-			$startTime = microtime( true );
148
+		if ($entity instanceof StatementListProvidingEntity) {
149
+			$startTime = microtime(true);
150 150
 
151 151
 			$checkResults = $this->checkEveryStatement(
152 152
 				$entity,
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
 				$defaultResultsPerContext
155 155
 			);
156 156
 
157
-			$endTime = microtime( true );
157
+			$endTime = microtime(true);
158 158
 
159
-			if ( $constraintIds === null ) { // only log full constraint checks
159
+			if ($constraintIds === null) { // only log full constraint checks
160 160
 				$this->loggingHelper->logConstraintCheckOnEntity(
161 161
 					$entityId,
162 162
 					$checkResults,
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
 			}
167 167
 		}
168 168
 
169
-		if ( $defaultResultsPerEntity !== null ) {
170
-			$checkResults = array_merge( $defaultResultsPerEntity( $entityId ), $checkResults );
169
+		if ($defaultResultsPerEntity !== null) {
170
+			$checkResults = array_merge($defaultResultsPerEntity($entityId), $checkResults);
171 171
 		}
172 172
 
173
-		return $this->sortResult( $checkResults );
173
+		return $this->sortResult($checkResults);
174 174
 	}
175 175
 
176 176
 	/**
@@ -192,19 +192,19 @@  discard block
 block discarded – undo
192 192
 		callable $defaultResults = null
193 193
 	) {
194 194
 
195
-		$parsedGuid = $this->statementGuidParser->parse( $guid );
195
+		$parsedGuid = $this->statementGuidParser->parse($guid);
196 196
 		$entityId = $parsedGuid->getEntityId();
197
-		$entity = $this->entityLookup->getEntity( $entityId );
198
-		if ( $entity instanceof StatementListProvidingEntity ) {
199
-			$statement = $entity->getStatements()->getFirstStatementWithGuid( $guid );
200
-			if ( $statement ) {
197
+		$entity = $this->entityLookup->getEntity($entityId);
198
+		if ($entity instanceof StatementListProvidingEntity) {
199
+			$statement = $entity->getStatements()->getFirstStatementWithGuid($guid);
200
+			if ($statement) {
201 201
 				$result = $this->checkStatement(
202 202
 					$entity,
203 203
 					$statement,
204 204
 					$constraintIds,
205 205
 					$defaultResults
206 206
 				);
207
-				$output = $this->sortResult( $result );
207
+				$output = $this->sortResult($result);
208 208
 				return $output;
209 209
 			}
210 210
 		}
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 		return [];
213 213
 	}
214 214
 
215
-	private function getAllowedContextTypes( Constraint $constraint ) {
216
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
215
+	private function getAllowedContextTypes(Constraint $constraint) {
216
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
217 217
 			return [
218 218
 				Context::TYPE_STATEMENT,
219 219
 				Context::TYPE_QUALIFIER,
@@ -221,12 +221,12 @@  discard block
 block discarded – undo
221 221
 			];
222 222
 		}
223 223
 
224
-		return array_keys( array_filter(
224
+		return array_keys(array_filter(
225 225
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedContextTypes(),
226
-			function ( $resultStatus ) {
226
+			function($resultStatus) {
227 227
 				return $resultStatus !== CheckResult::STATUS_NOT_IN_SCOPE;
228 228
 			}
229
-		) );
229
+		));
230 230
 	}
231 231
 
232 232
 	/**
@@ -237,32 +237,32 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return ConstraintParameterException[]
239 239
 	 */
240
-	private function checkCommonConstraintParameters( Constraint $constraint ) {
240
+	private function checkCommonConstraintParameters(Constraint $constraint) {
241 241
 		$constraintParameters = $constraint->getConstraintParameters();
242 242
 		try {
243
-			$this->constraintParameterParser->checkError( $constraintParameters );
244
-		} catch ( ConstraintParameterException $e ) {
245
-			return [ $e ];
243
+			$this->constraintParameterParser->checkError($constraintParameters);
244
+		} catch (ConstraintParameterException $e) {
245
+			return [$e];
246 246
 		}
247 247
 
248 248
 		$problems = [];
249 249
 		try {
250
-			$this->constraintParameterParser->parseExceptionParameter( $constraintParameters );
251
-		} catch ( ConstraintParameterException $e ) {
250
+			$this->constraintParameterParser->parseExceptionParameter($constraintParameters);
251
+		} catch (ConstraintParameterException $e) {
252 252
 			$problems[] = $e;
253 253
 		}
254 254
 		try {
255
-			$this->constraintParameterParser->parseConstraintStatusParameter( $constraintParameters );
256
-		} catch ( ConstraintParameterException $e ) {
255
+			$this->constraintParameterParser->parseConstraintStatusParameter($constraintParameters);
256
+		} catch (ConstraintParameterException $e) {
257 257
 			$problems[] = $e;
258 258
 		}
259 259
 		try {
260 260
 			$this->constraintParameterParser->parseConstraintScopeParameter(
261 261
 				$constraintParameters,
262 262
 				$constraint->getConstraintTypeItemId(),
263
-				$this->getAllowedContextTypes( $constraint )
263
+				$this->getAllowedContextTypes($constraint)
264 264
 			);
265
-		} catch ( ConstraintParameterException $e ) {
265
+		} catch (ConstraintParameterException $e) {
266 266
 			$problems[] = $e;
267 267
 		}
268 268
 		return $problems;
@@ -275,16 +275,16 @@  discard block
 block discarded – undo
275 275
 	 * @return ConstraintParameterException[][] first level indexed by constraint ID,
276 276
 	 * second level like checkConstraintParametersOnConstraintId (but without possibility of null)
277 277
 	 */
278
-	public function checkConstraintParametersOnPropertyId( PropertyId $propertyId ) {
279
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
278
+	public function checkConstraintParametersOnPropertyId(PropertyId $propertyId) {
279
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
280 280
 		$result = [];
281 281
 
282
-		foreach ( $constraints as $constraint ) {
283
-			$problems = $this->checkCommonConstraintParameters( $constraint );
282
+		foreach ($constraints as $constraint) {
283
+			$problems = $this->checkCommonConstraintParameters($constraint);
284 284
 
285
-			if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
285
+			if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
286 286
 				$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
287
-				$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
287
+				$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
288 288
 			}
289 289
 
290 290
 			$result[$constraint->getConstraintId()] = $problems;
@@ -301,18 +301,18 @@  discard block
 block discarded – undo
301 301
 	 * @return ConstraintParameterException[]|null list of constraint parameter exceptions
302 302
 	 * (empty means all parameters okay), or null if constraint is not found
303 303
 	 */
304
-	public function checkConstraintParametersOnConstraintId( $constraintId ) {
305
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
304
+	public function checkConstraintParametersOnConstraintId($constraintId) {
305
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
306 306
 		'@phan-var PropertyId $propertyId';
307
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
307
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
308 308
 
309
-		foreach ( $constraints as $constraint ) {
310
-			if ( $constraint->getConstraintId() === $constraintId ) {
311
-				$problems = $this->checkCommonConstraintParameters( $constraint );
309
+		foreach ($constraints as $constraint) {
310
+			if ($constraint->getConstraintId() === $constraintId) {
311
+				$problems = $this->checkCommonConstraintParameters($constraint);
312 312
 
313
-				if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
313
+				if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
314 314
 					$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
315
-					$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
315
+					$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
316 316
 				}
317 317
 
318 318
 				return $problems;
@@ -337,14 +337,14 @@  discard block
 block discarded – undo
337 337
 		$result = [];
338 338
 
339 339
 		/** @var Statement $statement */
340
-		foreach ( $entity->getStatements() as $statement ) {
341
-			$result = array_merge( $result,
340
+		foreach ($entity->getStatements() as $statement) {
341
+			$result = array_merge($result,
342 342
 				$this->checkStatement(
343 343
 					$entity,
344 344
 					$statement,
345 345
 					$constraintIds,
346 346
 					$defaultResultsPerContext
347
-				) );
347
+				));
348 348
 		}
349 349
 
350 350
 		return $result;
@@ -366,32 +366,32 @@  discard block
 block discarded – undo
366 366
 	) {
367 367
 		$result = [];
368 368
 
369
-		$result = array_merge( $result,
369
+		$result = array_merge($result,
370 370
 			$this->checkConstraintsForMainSnak(
371 371
 				$entity,
372 372
 				$statement,
373 373
 				$constraintIds,
374 374
 				$defaultResultsPerContext
375
-			) );
375
+			));
376 376
 
377
-		if ( $this->checkQualifiers ) {
378
-			$result = array_merge( $result,
377
+		if ($this->checkQualifiers) {
378
+			$result = array_merge($result,
379 379
 				$this->checkConstraintsForQualifiers(
380 380
 					$entity,
381 381
 					$statement,
382 382
 					$constraintIds,
383 383
 					$defaultResultsPerContext
384
-				) );
384
+				));
385 385
 		}
386 386
 
387
-		if ( $this->checkReferences ) {
388
-			$result = array_merge( $result,
387
+		if ($this->checkReferences) {
388
+			$result = array_merge($result,
389 389
 				$this->checkConstraintsForReferences(
390 390
 					$entity,
391 391
 					$statement,
392 392
 					$constraintIds,
393 393
 					$defaultResultsPerContext
394
-				) );
394
+				));
395 395
 		}
396 396
 
397 397
 		return $result;
@@ -406,12 +406,12 @@  discard block
 block discarded – undo
406 406
 	 * @param string[]|null $constraintIds
407 407
 	 * @return Constraint[]
408 408
 	 */
409
-	private function getConstraintsToUse( PropertyId $propertyId, array $constraintIds = null ) {
410
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
411
-		if ( $constraintIds !== null ) {
409
+	private function getConstraintsToUse(PropertyId $propertyId, array $constraintIds = null) {
410
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
411
+		if ($constraintIds !== null) {
412 412
 			$constraintsToUse = [];
413
-			foreach ( $constraints as $constraint ) {
414
-				if ( in_array( $constraint->getConstraintId(), $constraintIds ) ) {
413
+			foreach ($constraints as $constraint) {
414
+				if (in_array($constraint->getConstraintId(), $constraintIds)) {
415 415
 					$constraintsToUse[] = $constraint;
416 416
 				}
417 417
 			}
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
 		array $constraintIds = null,
436 436
 		callable $defaultResults = null
437 437
 	) {
438
-		$context = new MainSnakContext( $entity, $statement );
438
+		$context = new MainSnakContext($entity, $statement);
439 439
 		$constraints = $this->getConstraintsToUse(
440 440
 			$statement->getPropertyId(),
441 441
 			$constraintIds
442 442
 		);
443
-		$result = $defaultResults !== null ? $defaultResults( $context ) : [];
443
+		$result = $defaultResults !== null ? $defaultResults($context) : [];
444 444
 
445
-		foreach ( $constraints as $constraint ) {
445
+		foreach ($constraints as $constraint) {
446 446
 			$parameters = $constraint->getConstraintParameters();
447 447
 			try {
448
-				$exceptions = $this->constraintParameterParser->parseExceptionParameter( $parameters );
449
-			} catch ( ConstraintParameterException $e ) {
448
+				$exceptions = $this->constraintParameterParser->parseExceptionParameter($parameters);
449
+			} catch (ConstraintParameterException $e) {
450 450
 				$result[] = new CheckResult(
451 451
 					$context,
452 452
 					$constraint,
@@ -456,13 +456,13 @@  discard block
 block discarded – undo
456 456
 				continue;
457 457
 			}
458 458
 
459
-			if ( in_array( $entity->getId(), $exceptions ) ) {
460
-				$message = new ViolationMessage( 'wbqc-violation-message-exception' );
461
-				$result[] = new CheckResult( $context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message );
459
+			if (in_array($entity->getId(), $exceptions)) {
460
+				$message = new ViolationMessage('wbqc-violation-message-exception');
461
+				$result[] = new CheckResult($context, $constraint, [], CheckResult::STATUS_EXCEPTION, $message);
462 462
 				continue;
463 463
 			}
464 464
 
465
-			$result[] = $this->getCheckResultFor( $context, $constraint );
465
+			$result[] = $this->getCheckResultFor($context, $constraint);
466 466
 		}
467 467
 
468 468
 		return $result;
@@ -484,24 +484,24 @@  discard block
 block discarded – undo
484 484
 	) {
485 485
 		$result = [];
486 486
 
487
-		if ( in_array(
487
+		if (in_array(
488 488
 			$statement->getPropertyId()->getSerialization(),
489 489
 			$this->propertiesWithViolatingQualifiers
490
-		) ) {
490
+		)) {
491 491
 			return $result;
492 492
 		}
493 493
 
494
-		foreach ( $statement->getQualifiers() as $qualifier ) {
495
-			$qualifierContext = new QualifierContext( $entity, $statement, $qualifier );
496
-			if ( $defaultResultsPerContext !== null ) {
497
-				$result = array_merge( $result, $defaultResultsPerContext( $qualifierContext ) );
494
+		foreach ($statement->getQualifiers() as $qualifier) {
495
+			$qualifierContext = new QualifierContext($entity, $statement, $qualifier);
496
+			if ($defaultResultsPerContext !== null) {
497
+				$result = array_merge($result, $defaultResultsPerContext($qualifierContext));
498 498
 			}
499 499
 			$qualifierConstraints = $this->getConstraintsToUse(
500 500
 				$qualifierContext->getSnak()->getPropertyId(),
501 501
 				$constraintIds
502 502
 			);
503
-			foreach ( $qualifierConstraints as $qualifierConstraint ) {
504
-				$result[] = $this->getCheckResultFor( $qualifierContext, $qualifierConstraint );
503
+			foreach ($qualifierConstraints as $qualifierConstraint) {
504
+				$result[] = $this->getCheckResultFor($qualifierContext, $qualifierConstraint);
505 505
 			}
506 506
 		}
507 507
 
@@ -525,19 +525,19 @@  discard block
 block discarded – undo
525 525
 		$result = [];
526 526
 
527 527
 		/** @var Reference $reference */
528
-		foreach ( $statement->getReferences() as $reference ) {
529
-			foreach ( $reference->getSnaks() as $snak ) {
528
+		foreach ($statement->getReferences() as $reference) {
529
+			foreach ($reference->getSnaks() as $snak) {
530 530
 				$referenceContext = new ReferenceContext(
531 531
 					$entity, $statement, $reference, $snak
532 532
 				);
533
-				if ( $defaultResultsPerContext !== null ) {
534
-					$result = array_merge( $result, $defaultResultsPerContext( $referenceContext ) );
533
+				if ($defaultResultsPerContext !== null) {
534
+					$result = array_merge($result, $defaultResultsPerContext($referenceContext));
535 535
 				}
536 536
 				$referenceConstraints = $this->getConstraintsToUse(
537 537
 					$referenceContext->getSnak()->getPropertyId(),
538 538
 					$constraintIds
539 539
 				);
540
-				foreach ( $referenceConstraints as $referenceConstraint ) {
540
+				foreach ($referenceConstraints as $referenceConstraint) {
541 541
 					$result[] = $this->getCheckResultFor(
542 542
 						$referenceContext,
543 543
 						$referenceConstraint
@@ -556,20 +556,20 @@  discard block
 block discarded – undo
556 556
 	 * @throws InvalidArgumentException
557 557
 	 * @return CheckResult
558 558
 	 */
559
-	private function getCheckResultFor( Context $context, Constraint $constraint ) {
560
-		if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
559
+	private function getCheckResultFor(Context $context, Constraint $constraint) {
560
+		if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
561 561
 			$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
562
-			$result = $this->handleScope( $checker, $context, $constraint );
562
+			$result = $this->handleScope($checker, $context, $constraint);
563 563
 
564
-			if ( $result !== null ) {
565
-				$this->addMetadata( $context, $result );
564
+			if ($result !== null) {
565
+				$this->addMetadata($context, $result);
566 566
 				return $result;
567 567
 			}
568 568
 
569
-			$startTime = microtime( true );
569
+			$startTime = microtime(true);
570 570
 			try {
571
-				$result = $checker->checkConstraint( $context, $constraint );
572
-			} catch ( ConstraintParameterException $e ) {
571
+				$result = $checker->checkConstraint($context, $constraint);
572
+			} catch (ConstraintParameterException $e) {
573 573
 				$result = new CheckResult(
574 574
 					$context,
575 575
 					$constraint,
@@ -577,28 +577,28 @@  discard block
 block discarded – undo
577 577
 					CheckResult::STATUS_BAD_PARAMETERS,
578 578
 					$e->getViolationMessage()
579 579
 				);
580
-			} catch ( SparqlHelperException $e ) {
581
-				$message = new ViolationMessage( 'wbqc-violation-message-sparql-error' );
582
-				$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, $message );
580
+			} catch (SparqlHelperException $e) {
581
+				$message = new ViolationMessage('wbqc-violation-message-sparql-error');
582
+				$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, $message);
583 583
 			}
584
-			$endTime = microtime( true );
584
+			$endTime = microtime(true);
585 585
 
586
-			$this->addMetadata( $context, $result );
586
+			$this->addMetadata($context, $result);
587 587
 
588
-			$this->downgradeResultStatus( $context, $result );
588
+			$this->downgradeResultStatus($context, $result);
589 589
 
590 590
 			$this->loggingHelper->logConstraintCheck(
591 591
 				$context,
592 592
 				$constraint,
593 593
 				$result,
594
-				get_class( $checker ),
594
+				get_class($checker),
595 595
 				$endTime - $startTime,
596 596
 				__METHOD__
597 597
 			);
598 598
 
599 599
 			return $result;
600 600
 		} else {
601
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
601
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
602 602
 		}
603 603
 	}
604 604
 
@@ -612,61 +612,61 @@  discard block
 block discarded – undo
612 612
 				$constraint->getConstraintParameters(),
613 613
 				$constraint->getConstraintTypeItemId()
614 614
 			);
615
-		} catch ( ConstraintParameterException $e ) {
616
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
615
+		} catch (ConstraintParameterException $e) {
616
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
617 617
 		}
618
-		if ( $checkedContextTypes === null ) {
618
+		if ($checkedContextTypes === null) {
619 619
 			$checkedContextTypes = $checker->getDefaultContextTypes();
620 620
 		}
621
-		if ( !in_array( $context->getType(), $checkedContextTypes ) ) {
622
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null );
621
+		if (!in_array($context->getType(), $checkedContextTypes)) {
622
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE, null);
623 623
 		}
624
-		if ( $checker->getSupportedContextTypes()[$context->getType()] === CheckResult::STATUS_TODO ) {
625
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_TODO, null );
624
+		if ($checker->getSupportedContextTypes()[$context->getType()] === CheckResult::STATUS_TODO) {
625
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_TODO, null);
626 626
 		}
627 627
 		return null;
628 628
 	}
629 629
 
630
-	private function addMetadata( Context $context, CheckResult $result ) {
631
-		$result->withMetadata( Metadata::merge( [
630
+	private function addMetadata(Context $context, CheckResult $result) {
631
+		$result->withMetadata(Metadata::merge([
632 632
 			$result->getMetadata(),
633
-			Metadata::ofDependencyMetadata( DependencyMetadata::merge( [
634
-				DependencyMetadata::ofEntityId( $context->getEntity()->getId() ),
635
-				DependencyMetadata::ofEntityId( $result->getConstraint()->getPropertyId() ),
636
-			] ) ),
637
-		] ) );
633
+			Metadata::ofDependencyMetadata(DependencyMetadata::merge([
634
+				DependencyMetadata::ofEntityId($context->getEntity()->getId()),
635
+				DependencyMetadata::ofEntityId($result->getConstraint()->getPropertyId()),
636
+			])),
637
+		]));
638 638
 	}
639 639
 
640
-	private function downgradeResultStatus( Context $context, CheckResult &$result ) {
640
+	private function downgradeResultStatus(Context $context, CheckResult &$result) {
641 641
 		$constraint = $result->getConstraint();
642 642
 		try {
643 643
 			$constraintStatus = $this->constraintParameterParser
644
-				->parseConstraintStatusParameter( $constraint->getConstraintParameters() );
645
-		} catch ( ConstraintParameterException $e ) {
646
-			$result = new CheckResult( $context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
644
+				->parseConstraintStatusParameter($constraint->getConstraintParameters());
645
+		} catch (ConstraintParameterException $e) {
646
+			$result = new CheckResult($context, $constraint, [], CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
647 647
 			$constraintStatus = null;
648 648
 		}
649
-		if ( $constraintStatus === null ) {
649
+		if ($constraintStatus === null) {
650 650
 			// downgrade violation to warning
651
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
652
-				$result->setStatus( CheckResult::STATUS_WARNING );
651
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
652
+				$result->setStatus(CheckResult::STATUS_WARNING);
653 653
 			}
654
-		} elseif ( $constraintStatus === 'suggestion' ) {
654
+		} elseif ($constraintStatus === 'suggestion') {
655 655
 			// downgrade violation to suggestion
656
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
657
-				$result->setStatus( CheckResult::STATUS_SUGGESTION );
656
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
657
+				$result->setStatus(CheckResult::STATUS_SUGGESTION);
658 658
 			}
659
-			$result->addParameter( 'constraint_status', $constraintStatus );
659
+			$result->addParameter('constraint_status', $constraintStatus);
660 660
 		} else {
661
-			if ( $constraintStatus !== 'mandatory' ) {
661
+			if ($constraintStatus !== 'mandatory') {
662 662
 				// @codeCoverageIgnoreStart
663 663
 				throw new LogicException(
664
-					"Unknown constraint status '$constraintStatus', " .
664
+					"Unknown constraint status '$constraintStatus', ".
665 665
 					"only known statuses are 'mandatory' and 'suggestion'"
666 666
 				);
667 667
 				// @codeCoverageIgnoreEnd
668 668
 			}
669
-			$result->addParameter( 'constraint_status', $constraintStatus );
669
+			$result->addParameter('constraint_status', $constraintStatus);
670 670
 		}
671 671
 	}
672 672
 
@@ -675,12 +675,12 @@  discard block
 block discarded – undo
675 675
 	 *
676 676
 	 * @return CheckResult[]
677 677
 	 */
678
-	private function sortResult( array $result ) {
679
-		if ( count( $result ) < 2 ) {
678
+	private function sortResult(array $result) {
679
+		if (count($result) < 2) {
680 680
 			return $result;
681 681
 		}
682 682
 
683
-		$sortFunction = function ( CheckResult $a, CheckResult $b ) {
683
+		$sortFunction = function(CheckResult $a, CheckResult $b) {
684 684
 			$orderNum = 0;
685 685
 			$order = [
686 686
 				CheckResult::STATUS_BAD_PARAMETERS => $orderNum++,
@@ -697,55 +697,55 @@  discard block
 block discarded – undo
697 697
 			$statusA = $a->getStatus();
698 698
 			$statusB = $b->getStatus();
699 699
 
700
-			$orderA = array_key_exists( $statusA, $order ) ? $order[ $statusA ] : $order[ 'other' ];
701
-			$orderB = array_key_exists( $statusB, $order ) ? $order[ $statusB ] : $order[ 'other' ];
700
+			$orderA = array_key_exists($statusA, $order) ? $order[$statusA] : $order['other'];
701
+			$orderB = array_key_exists($statusB, $order) ? $order[$statusB] : $order['other'];
702 702
 
703
-			if ( $orderA === $orderB ) {
703
+			if ($orderA === $orderB) {
704 704
 				$cursorA = $a->getContextCursor();
705 705
 				$cursorB = $b->getContextCursor();
706 706
 
707
-				if ( $cursorA instanceof EntityContextCursor ) {
707
+				if ($cursorA instanceof EntityContextCursor) {
708 708
 					return $cursorB instanceof EntityContextCursor ? 0 : -1;
709 709
 				}
710
-				if ( $cursorB instanceof EntityContextCursor ) {
710
+				if ($cursorB instanceof EntityContextCursor) {
711 711
 					return $cursorA instanceof EntityContextCursor ? 0 : 1;
712 712
 				}
713 713
 
714 714
 				$pidA = $cursorA->getSnakPropertyId();
715 715
 				$pidB = $cursorB->getSnakPropertyId();
716 716
 
717
-				if ( $pidA === $pidB ) {
717
+				if ($pidA === $pidB) {
718 718
 					$hashA = $cursorA->getSnakHash();
719 719
 					$hashB = $cursorB->getSnakHash();
720 720
 
721
-					if ( $hashA === $hashB ) {
722
-						if ( $a instanceof NullResult ) {
721
+					if ($hashA === $hashB) {
722
+						if ($a instanceof NullResult) {
723 723
 							return $b instanceof NullResult ? 0 : -1;
724 724
 						}
725
-						if ( $b instanceof NullResult ) {
725
+						if ($b instanceof NullResult) {
726 726
 							return $a instanceof NullResult ? 0 : 1;
727 727
 						}
728 728
 
729 729
 						$typeA = $a->getConstraint()->getConstraintTypeItemId();
730 730
 						$typeB = $b->getConstraint()->getConstraintTypeItemId();
731 731
 
732
-						if ( $typeA == $typeB ) {
732
+						if ($typeA == $typeB) {
733 733
 							return 0;
734 734
 						} else {
735
-							return ( $typeA > $typeB ) ? 1 : -1;
735
+							return ($typeA > $typeB) ? 1 : -1;
736 736
 						}
737 737
 					} else {
738
-						return ( $hashA > $hashB ) ? 1 : -1;
738
+						return ($hashA > $hashB) ? 1 : -1;
739 739
 					}
740 740
 				} else {
741
-					return ( $pidA > $pidB ) ? 1 : -1;
741
+					return ($pidA > $pidB) ? 1 : -1;
742 742
 				}
743 743
 			} else {
744
-				return ( $orderA > $orderB ) ? 1 : -1;
744
+				return ($orderA > $orderB) ? 1 : -1;
745 745
 			}
746 746
 		};
747 747
 
748
-		uasort( $result, $sortFunction );
748
+		uasort($result, $sortFunction);
749 749
 
750 750
 		return $result;
751 751
 	}
Please login to merge, or discard this patch.
maintenance/ImportConstraintStatements.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 use WikibaseQuality\ConstraintReport\Job\UpdateConstraintsTableJob;
10 10
 
11 11
 // @codeCoverageIgnoreStart
12
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
13
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
12
+$basePath = getenv("MW_INSTALL_PATH") !== false
13
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
14 14
 
15
-require_once $basePath . "/maintenance/Maintenance.php";
15
+require_once $basePath."/maintenance/Maintenance.php";
16 16
 // @codeCoverageIgnoreEnd
17 17
 
18 18
 /**
@@ -37,43 +37,43 @@  discard block
 block discarded – undo
37 37
 
38 38
 	public function __construct() {
39 39
 		parent::__construct();
40
-		$this->newUpdateConstraintsTableJob = function ( $propertyIdSerialization ) {
40
+		$this->newUpdateConstraintsTableJob = function($propertyIdSerialization) {
41 41
 			return UpdateConstraintsTableJob::newFromGlobalState(
42 42
 				Title::newMainPage(),
43
-				[ 'propertyId' => $propertyIdSerialization ]
43
+				['propertyId' => $propertyIdSerialization]
44 44
 			);
45 45
 		};
46 46
 
47
-		$this->addDescription( 'Imports property constraints from statements on properties' );
48
-		$this->requireExtension( 'WikibaseQualityConstraints' );
47
+		$this->addDescription('Imports property constraints from statements on properties');
48
+		$this->requireExtension('WikibaseQualityConstraints');
49 49
 
50 50
 		// Wikibase classes are not yet loaded, so setup services in a callback run in execute
51 51
 		// that can be overridden in tests.
52
-		$this->setupServices = function () {
52
+		$this->setupServices = function() {
53 53
 			$repo = WikibaseRepo::getDefaultInstance();
54 54
 			$this->propertyInfoLookup = $repo->getStore()->getPropertyInfoLookup();
55 55
 		};
56 56
 	}
57 57
 
58 58
 	public function execute() {
59
-		( $this->setupServices )();
60
-		if ( !$this->getConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
61
-			$this->error( 'Constraint statements are not enabled. Aborting.' );
59
+		($this->setupServices)();
60
+		if (!$this->getConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) {
61
+			$this->error('Constraint statements are not enabled. Aborting.');
62 62
 			return;
63 63
 		}
64 64
 
65
-		foreach ( $this->propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info ) {
66
-			$this->output( sprintf(
65
+		foreach ($this->propertyInfoLookup->getAllPropertyInfo() as $propertyIdSerialization => $info) {
66
+			$this->output(sprintf(
67 67
 				'Importing constraint statements for % 6s... ',
68 68
 				$propertyIdSerialization ),
69 69
 				$propertyIdSerialization
70 70
 			);
71
-			$startTime = microtime( true );
72
-			$job = call_user_func( $this->newUpdateConstraintsTableJob, $propertyIdSerialization );
71
+			$startTime = microtime(true);
72
+			$job = call_user_func($this->newUpdateConstraintsTableJob, $propertyIdSerialization);
73 73
 			$job->run();
74
-			$endTime = microtime( true );
75
-			$millis = ( $endTime - $startTime ) * 1000;
76
-			$this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization );
74
+			$endTime = microtime(true);
75
+			$millis = ($endTime - $startTime) * 1000;
76
+			$this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization);
77 77
 		}
78 78
 	}
79 79
 
Please login to merge, or discard this patch.
src/Job/CheckConstraintsJob.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -37,25 +37,25 @@  discard block
 block discarded – undo
37 37
 	 * @param Title $title
38 38
 	 * @param string[] $params should contain 'entityId' => 'Q1234'
39 39
 	 */
40
-	public function __construct( Title $title, array $params ) {
41
-		parent::__construct( self::COMMAND, $title, $params );
40
+	public function __construct(Title $title, array $params) {
41
+		parent::__construct(self::COMMAND, $title, $params);
42 42
 		$this->removeDuplicates = true;
43 43
 
44
-		Assert::parameterType( 'string', $params['entityId'], '$params[\'entityId\']' );
44
+		Assert::parameterType('string', $params['entityId'], '$params[\'entityId\']');
45 45
 
46
-		$resultSource = ConstraintsServices::getResultsSource( MediaWikiServices::getInstance() );
46
+		$resultSource = ConstraintsServices::getResultsSource(MediaWikiServices::getInstance());
47 47
 		'@phan-var CachingResultsSource $resultSource';
48 48
 		// This job should only ever be used when caching result sources are used.
49
-		$this->setResultsSource( $resultSource );
49
+		$this->setResultsSource($resultSource);
50 50
 
51
-		$this->setEntityIdParser( WikibaseRepo::getEntityIdParser() );
51
+		$this->setEntityIdParser(WikibaseRepo::getEntityIdParser());
52 52
 	}
53 53
 
54
-	public function setResultsSource( CachingResultsSource $resultsSource ) {
54
+	public function setResultsSource(CachingResultsSource $resultsSource) {
55 55
 		$this->resultsSource = $resultsSource;
56 56
 	}
57 57
 
58
-	public function setEntityIdParser( EntityIdParser $parser ) {
58
+	public function setEntityIdParser(EntityIdParser $parser) {
59 59
 		$this->entityIdParser = $parser;
60 60
 	}
61 61
 
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function run() {
68 68
 		try {
69
-			$entityId = $this->entityIdParser->parse( $this->params['entityId'] );
70
-		} catch ( EntityIdParsingException $e ) {
69
+			$entityId = $this->entityIdParser->parse($this->params['entityId']);
70
+		} catch (EntityIdParsingException $e) {
71 71
 			return false;
72 72
 		}
73 73
 
74
-		$this->checkConstraints( $entityId );
74
+		$this->checkConstraints($entityId);
75 75
 
76 76
 		return true;
77 77
 	}
78 78
 
79
-	private function checkConstraints( EntityId $entityId ) {
79
+	private function checkConstraints(EntityId $entityId) {
80 80
 		$this->resultsSource->getResults(
81
-			[ $entityId ],
81
+			[$entityId],
82 82
 			[],
83 83
 			null,
84 84
 			[]
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -81,14 +81,14 @@  discard block
 block discarded – undo
81 81
 
82 82
 		$language = $repo->getUserLanguage();
83 83
 		$formatterOptions = new FormatterOptions();
84
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
84
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
85 85
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
86
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
86
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
87 87
 
88 88
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
89
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language );
89
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language);
90 90
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
91
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language );
91
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language);
92 92
 
93 93
 		$checkResultsRenderer = new CheckResultsRenderer(
94 94
 			$repo->getEntityTitleLookup(),
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 			$name,
107 107
 			$entityIdParser,
108 108
 			$repo->getStatementGuidValidator(),
109
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
109
+			$repo->getApiHelperFactory(RequestContext::getMain()),
110 110
 			$resultsSource,
111 111
 			$checkResultsRenderer,
112 112
 			$dataFactory
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 		CheckResultsRenderer $checkResultsRenderer,
134 134
 		IBufferingStatsdDataFactory $dataFactory
135 135
 	) {
136
-		parent::__construct( $main, $name );
136
+		parent::__construct($main, $name);
137 137
 		$this->entityIdParser = $entityIdParser;
138 138
 		$this->statementGuidValidator = $statementGuidValidator;
139
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
140
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
139
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
140
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
141 141
 		$this->resultsSource = $resultsSource;
142 142
 		$this->checkResultsRenderer = $checkResultsRenderer;
143 143
 		$this->dataFactory = $dataFactory;
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
 
154 154
 		$params = $this->extractRequestParams();
155 155
 
156
-		$this->validateParameters( $params );
157
-		$entityIds = $this->parseEntityIds( $params );
158
-		$claimIds = $this->parseClaimIds( $params );
156
+		$this->validateParameters($params);
157
+		$entityIds = $this->parseEntityIds($params);
158
+		$claimIds = $this->parseClaimIds($params);
159 159
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
160 160
 		$statuses = $params[self::PARAM_STATUS];
161 161
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 				)
172 172
 			)->getArray()
173 173
 		);
174
-		$this->resultBuilder->markSuccess( 1 );
174
+		$this->resultBuilder->markSuccess(1);
175 175
 	}
176 176
 
177 177
 	/**
@@ -179,24 +179,24 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @return EntityId[]
181 181
 	 */
182
-	private function parseEntityIds( array $params ) {
182
+	private function parseEntityIds(array $params) {
183 183
 		$ids = $params[self::PARAM_ID];
184 184
 
185
-		if ( $ids === null ) {
185
+		if ($ids === null) {
186 186
 			return [];
187
-		} elseif ( $ids === [] ) {
187
+		} elseif ($ids === []) {
188 188
 			$this->errorReporter->dieError(
189
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
189
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
190 190
 		}
191 191
 
192
-		return array_map( function ( $id ) {
192
+		return array_map(function($id) {
193 193
 			try {
194
-				return $this->entityIdParser->parse( $id );
195
-			} catch ( EntityIdParsingException $e ) {
194
+				return $this->entityIdParser->parse($id);
195
+			} catch (EntityIdParsingException $e) {
196 196
 				$this->errorReporter->dieError(
197
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
197
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
198 198
 			}
199
-		}, $ids );
199
+		}, $ids);
200 200
 	}
201 201
 
202 202
 	/**
@@ -204,35 +204,35 @@  discard block
 block discarded – undo
204 204
 	 *
205 205
 	 * @return string[]
206 206
 	 */
207
-	private function parseClaimIds( array $params ) {
207
+	private function parseClaimIds(array $params) {
208 208
 		$ids = $params[self::PARAM_CLAIM_ID];
209 209
 
210
-		if ( $ids === null ) {
210
+		if ($ids === null) {
211 211
 			return [];
212
-		} elseif ( $ids === [] ) {
212
+		} elseif ($ids === []) {
213 213
 			$this->errorReporter->dieError(
214
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
214
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
215 215
 		}
216 216
 
217
-		foreach ( $ids as $id ) {
218
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
217
+		foreach ($ids as $id) {
218
+			if (!$this->statementGuidValidator->validate($id)) {
219 219
 				$this->errorReporter->dieError(
220
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
220
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
221 221
 			}
222 222
 		}
223 223
 
224 224
 		return $ids;
225 225
 	}
226 226
 
227
-	private function validateParameters( array $params ) {
228
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
229
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
227
+	private function validateParameters(array $params) {
228
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
229
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
230 230
 		) {
231 231
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
232 232
 			$this->errorReporter->dieError(
233 233
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
234 234
 		}
235
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
235
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
236 236
 			$paramId = self::PARAM_ID;
237 237
 			$paramClaimId = self::PARAM_CLAIM_ID;
238 238
 			$this->errorReporter->dieError(
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 				],
274 274
 				ApiBase::PARAM_ISMULTI => true,
275 275
 				ApiBase::PARAM_ALL => true,
276
-				ApiBase::PARAM_DFLT => implode( '|', CachingResultsSource::CACHED_STATUSES ),
276
+				ApiBase::PARAM_DFLT => implode('|', CachingResultsSource::CACHED_STATUSES),
277 277
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
278 278
 			],
279 279
 		];
Please login to merge, or discard this patch.