Completed
Push — master ( 511ffa...2ddbee )
by
unknown
01:51
created
maintenance/ImportConstraintEntities.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
 use Wikibase\Repo\WikibaseRepo;
17 17
 
18 18
 // @codeCoverageIgnoreStart
19
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
20
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
19
+$basePath = getenv("MW_INSTALL_PATH") !== false
20
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
21 21
 
22
-require_once $basePath . "/maintenance/Maintenance.php";
22
+require_once $basePath."/maintenance/Maintenance.php";
23 23
 // @codeCoverageIgnoreEnd
24 24
 
25 25
 /**
@@ -53,20 +53,20 @@  discard block
 block discarded – undo
53 53
 		parent::__construct();
54 54
 
55 55
 		$this->addDescription(
56
-			'Import entities needed for constraint checks ' .
56
+			'Import entities needed for constraint checks '.
57 57
 			'from Wikidata into the local repository.'
58 58
 		);
59 59
 		$this->addOption(
60 60
 			'config-format',
61
-			'The format in which the resulting configuration will be omitted: ' .
62
-			'"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), ' .
61
+			'The format in which the resulting configuration will be omitted: '.
62
+			'"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), '.
63 63
 			'or "wgConf" for printing parts of arrays suitable for inclusion in $wgConf->settings.'
64 64
 		);
65 65
 		$this->addOption(
66 66
 			'dry-run',
67 67
 			'Don’t actually import entities, just print which ones would be imported.'
68 68
 		);
69
-		$this->requireExtension( 'WikibaseQualityConstraints' );
69
+		$this->requireExtension('WikibaseQualityConstraints');
70 70
 	}
71 71
 
72 72
 	/**
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 		$this->entitySerializer = $repo->getAllTypesEntitySerializer();
78 78
 		$this->entityDeserializer = $repo->getInternalFormatEntityDeserializer();
79 79
 		$this->entityStore = $repo->getEntityStore();
80
-		if ( !$this->getOption( 'dry-run', false ) ) {
81
-			$this->user = User::newSystemUser( 'WikibaseQualityConstraints importer' );
80
+		if (!$this->getOption('dry-run', false)) {
81
+			$this->user = User::newSystemUser('WikibaseQualityConstraints importer');
82 82
 		}
83 83
 	}
84 84
 
@@ -87,21 +87,21 @@  discard block
 block discarded – undo
87 87
 
88 88
 		$configUpdates = [];
89 89
 
90
-		$extensionJsonFile = __DIR__ . '/../extension.json';
91
-		$extensionJsonText = file_get_contents( $extensionJsonFile );
92
-		$extensionJson = json_decode( $extensionJsonText, /* assoc = */ true );
90
+		$extensionJsonFile = __DIR__.'/../extension.json';
91
+		$extensionJsonText = file_get_contents($extensionJsonFile);
92
+		$extensionJson = json_decode($extensionJsonText, /* assoc = */ true);
93 93
 		// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
94
-		$wikidataEntityIds = $this->getEntitiesToImport( $extensionJson['config'], $this->getConfig() );
94
+		$wikidataEntityIds = $this->getEntitiesToImport($extensionJson['config'], $this->getConfig());
95 95
 
96
-		foreach ( $wikidataEntityIds as $key => $wikidataEntityId ) {
97
-			$localEntityId = $this->importEntityFromWikidata( $wikidataEntityId );
96
+		foreach ($wikidataEntityIds as $key => $wikidataEntityId) {
97
+			$localEntityId = $this->importEntityFromWikidata($wikidataEntityId);
98 98
 			$configUpdates[$key] = [
99 99
 				'wikidata' => $wikidataEntityId,
100 100
 				'local' => $localEntityId,
101 101
 			];
102 102
 		}
103 103
 
104
-		$this->outputConfigUpdates( $configUpdates );
104
+		$this->outputConfigUpdates($configUpdates);
105 105
 	}
106 106
 
107 107
 	/**
@@ -109,18 +109,18 @@  discard block
 block discarded – undo
109 109
 	 * @param Config $wikiConfig
110 110
 	 * @return string[]
111 111
 	 */
112
-	private function getEntitiesToImport( array $extensionJsonConfig, Config $wikiConfig ) {
112
+	private function getEntitiesToImport(array $extensionJsonConfig, Config $wikiConfig) {
113 113
 		$wikidataEntityIds = [];
114 114
 
115
-		foreach ( $extensionJsonConfig as $key => $value ) {
116
-			if ( !preg_match( '/Id$/', $key ) ) {
115
+		foreach ($extensionJsonConfig as $key => $value) {
116
+			if (!preg_match('/Id$/', $key)) {
117 117
 				continue;
118 118
 			}
119 119
 
120 120
 			$wikidataEntityId = $value['value'];
121
-			$localEntityId = $wikiConfig->get( $key );
121
+			$localEntityId = $wikiConfig->get($key);
122 122
 
123
-			if ( $localEntityId === $wikidataEntityId ) {
123
+			if ($localEntityId === $wikidataEntityId) {
124 124
 				$wikidataEntityIds[$key] = $wikidataEntityId;
125 125
 			}
126 126
 		}
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 	 * @param string $wikidataEntityId
133 133
 	 * @return string local entity ID
134 134
 	 */
135
-	private function importEntityFromWikidata( $wikidataEntityId ) {
135
+	private function importEntityFromWikidata($wikidataEntityId) {
136 136
 		$wikidataEntityUrl = "https://www.wikidata.org/wiki/Special:EntityData/$wikidataEntityId.json";
137
-		$wikidataEntitiesJson = MediaWikiServices::getInstance()->getHttpRequestFactory()->get( $wikidataEntityUrl );
138
-		return $this->importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson );
137
+		$wikidataEntitiesJson = MediaWikiServices::getInstance()->getHttpRequestFactory()->get($wikidataEntityUrl);
138
+		return $this->importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson);
139 139
 	}
140 140
 
141 141
 	/**
@@ -143,24 +143,24 @@  discard block
 block discarded – undo
143 143
 	 * @param string $wikidataEntitiesJson
144 144
 	 * @return string local entity ID
145 145
 	 */
146
-	private function importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ) {
146
+	private function importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson) {
147 147
 		// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
148
-		$wikidataEntityArray = json_decode( $wikidataEntitiesJson, true )['entities'][$wikidataEntityId];
149
-		$wikidataEntity = $this->entityDeserializer->deserialize( $wikidataEntityArray );
148
+		$wikidataEntityArray = json_decode($wikidataEntitiesJson, true)['entities'][$wikidataEntityId];
149
+		$wikidataEntity = $this->entityDeserializer->deserialize($wikidataEntityArray);
150 150
 
151
-		$wikidataEntity->setId( null );
151
+		$wikidataEntity->setId(null);
152 152
 
153
-		if ( $wikidataEntity instanceof StatementListProvider ) {
153
+		if ($wikidataEntity instanceof StatementListProvider) {
154 154
 			$wikidataEntity->getStatements()->clear();
155 155
 		}
156 156
 
157
-		if ( $wikidataEntity instanceof Item ) {
158
-			$wikidataEntity->setSiteLinkList( new SiteLinkList() );
157
+		if ($wikidataEntity instanceof Item) {
158
+			$wikidataEntity->setSiteLinkList(new SiteLinkList());
159 159
 		}
160 160
 
161
-		if ( $this->getOption( 'dry-run', false ) ) {
162
-			$wikidataEntityJson = json_encode( $this->entitySerializer->serialize( $wikidataEntity ) );
163
-			$this->output( $wikidataEntityJson . "\n" );
161
+		if ($this->getOption('dry-run', false)) {
162
+			$wikidataEntityJson = json_encode($this->entitySerializer->serialize($wikidataEntity));
163
+			$this->output($wikidataEntityJson."\n");
164 164
 			return "-$wikidataEntityId";
165 165
 		}
166 166
 
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 			)->getEntity();
174 174
 
175 175
 			return $localEntity->getId()->getSerialization();
176
-		} catch ( StorageException $storageException ) {
177
-			return $this->storageExceptionToEntityId( $storageException );
176
+		} catch (StorageException $storageException) {
177
+			return $this->storageExceptionToEntityId($storageException);
178 178
 		}
179 179
 	}
180 180
 
181
-	private function storageExceptionToEntityId( StorageException $storageException ) {
181
+	private function storageExceptionToEntityId(StorageException $storageException) {
182 182
 		$message = $storageException->getMessage();
183 183
 		// example messages:
184 184
 		// * Item [[Item:Q475|Q475]] already has label "as references"
@@ -188,25 +188,25 @@  discard block
 block discarded – undo
188 188
 		// * Property [[Property:P694|P694]] already has label "instance of"
189 189
 		//   associated with language code en.
190 190
 		$pattern = '/[[|]([^][|]*)]] already has label .* associated with language code/';
191
-		if ( preg_match( $pattern, $message, $matches ) ) {
191
+		if (preg_match($pattern, $message, $matches)) {
192 192
 			return $matches[1];
193 193
 		} else {
194 194
 			throw $storageException;
195 195
 		}
196 196
 	}
197 197
 
198
-	private function outputConfigUpdates( array $configUpdates ) {
199
-		$configFormat = $this->getOption( 'config-format', 'globals' );
200
-		switch ( $configFormat ) {
198
+	private function outputConfigUpdates(array $configUpdates) {
199
+		$configFormat = $this->getOption('config-format', 'globals');
200
+		switch ($configFormat) {
201 201
 			case 'globals':
202
-				$this->outputConfigUpdatesGlobals( $configUpdates );
202
+				$this->outputConfigUpdatesGlobals($configUpdates);
203 203
 				break;
204 204
 			case 'wgConf':
205
-				$this->outputConfigUpdatesWgConf( $configUpdates );
205
+				$this->outputConfigUpdatesWgConf($configUpdates);
206 206
 				break;
207 207
 			default:
208
-				$this->error( "Invalid config format \"$configFormat\", using \"globals\"" );
209
-				$this->outputConfigUpdatesGlobals( $configUpdates );
208
+				$this->error("Invalid config format \"$configFormat\", using \"globals\"");
209
+				$this->outputConfigUpdatesGlobals($configUpdates);
210 210
 				break;
211 211
 		}
212 212
 	}
@@ -214,22 +214,22 @@  discard block
 block discarded – undo
214 214
 	/**
215 215
 	 * @param array[] $configUpdates
216 216
 	 */
217
-	private function outputConfigUpdatesGlobals( array $configUpdates ) {
218
-		foreach ( $configUpdates as $key => $value ) {
219
-			$localValueCode = var_export( $value['local'], true );
220
-			$this->output( "\$wg$key = $localValueCode;\n" );
217
+	private function outputConfigUpdatesGlobals(array $configUpdates) {
218
+		foreach ($configUpdates as $key => $value) {
219
+			$localValueCode = var_export($value['local'], true);
220
+			$this->output("\$wg$key = $localValueCode;\n");
221 221
 		}
222 222
 	}
223 223
 
224 224
 	/**
225 225
 	 * @param array[] $configUpdates
226 226
 	 */
227
-	private function outputConfigUpdatesWgConf( array $configUpdates ) {
228
-		foreach ( $configUpdates as $key => $value ) {
229
-			$keyCode = var_export( "wg$key", true );
230
-			$wikidataValueCode = var_export( $value['wikidata'], true );
231
-			$localValueCode = var_export( $value['local'], true );
232
-			$wikiIdCode = var_export( wfWikiID(), true );
227
+	private function outputConfigUpdatesWgConf(array $configUpdates) {
228
+		foreach ($configUpdates as $key => $value) {
229
+			$keyCode = var_export("wg$key", true);
230
+			$wikidataValueCode = var_export($value['wikidata'], true);
231
+			$localValueCode = var_export($value['local'], true);
232
+			$wikiIdCode = var_export(wfWikiID(), true);
233 233
 			$block = <<< EOF
234 234
 $keyCode => [
235 235
 	'default' => $wikidataValueCode,
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
 
240 240
 EOF;
241
-			$this->output( $block );
241
+			$this->output($block);
242 242
 		}
243 243
 	}
244 244
 
Please login to merge, or discard this patch.
src/Api/CheckResultsRenderer.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 	 * @param CachedCheckResults $checkResults
52 52
 	 * @return CachedCheckConstraintsResponse
53 53
 	 */
54
-	public function render( CachedCheckResults $checkResults ) {
54
+	public function render(CachedCheckResults $checkResults) {
55 55
 		$response = [];
56
-		foreach ( $checkResults->getArray() as $checkResult ) {
57
-			$resultArray = $this->checkResultToArray( $checkResult );
58
-			$checkResult->getContextCursor()->storeCheckResultInArray( $resultArray, $response );
56
+		foreach ($checkResults->getArray() as $checkResult) {
57
+			$resultArray = $this->checkResultToArray($checkResult);
58
+			$checkResult->getContextCursor()->storeCheckResultInArray($resultArray, $response);
59 59
 		}
60 60
 		return new CachedCheckConstraintsResponse(
61 61
 			$response,
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 		);
64 64
 	}
65 65
 
66
-	public function checkResultToArray( CheckResult $checkResult ) {
67
-		if ( $checkResult instanceof NullResult ) {
66
+	public function checkResultToArray(CheckResult $checkResult) {
67
+		if ($checkResult instanceof NullResult) {
68 68
 			return null;
69 69
 		}
70 70
 
71 71
 		$constraintId = $checkResult->getConstraint()->getConstraintId();
72 72
 		$typeItemId = $checkResult->getConstraint()->getConstraintTypeItemId();
73
-		$constraintPropertyId = new PropertyId( $checkResult->getContextCursor()->getSnakPropertyId() );
73
+		$constraintPropertyId = new PropertyId($checkResult->getContextCursor()->getSnakPropertyId());
74 74
 
75
-		$title = $this->entityTitleLookup->getTitleForId( $constraintPropertyId );
75
+		$title = $this->entityTitleLookup->getTitleForId($constraintPropertyId);
76 76
 		$talkTitle = $title->getTalkPageIfDefined();
77
-		$typeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $typeItemId ) );
78
-		$link = $title->getFullURL() . '#' . $constraintId;
77
+		$typeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($typeItemId));
78
+		$link = $title->getFullURL().'#'.$constraintId;
79 79
 
80 80
 		$constraint = [
81 81
 			'id' => $constraintId,
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 			'constraint' => $constraint
92 92
 		];
93 93
 		$message = $checkResult->getMessage();
94
-		if ( $message ) {
95
-			$result['message-html'] = $this->violationMessageRenderer->render( $message );
94
+		if ($message) {
95
+			$result['message-html'] = $this->violationMessageRenderer->render($message);
96 96
 		}
97
-		if ( $checkResult->getContextCursor()->getType() === Context::TYPE_STATEMENT ) {
97
+		if ($checkResult->getContextCursor()->getType() === Context::TYPE_STATEMENT) {
98 98
 			$result['claim'] = $checkResult->getContextCursor()->getStatementGuid();
99 99
 		}
100 100
 		$cachingMetadataArray = $checkResult->getMetadata()->getCachingMetadata()->toArray();
101
-		if ( $cachingMetadataArray !== null ) {
101
+		if ($cachingMetadataArray !== null) {
102 102
 			$result['cached'] = $cachingMetadataArray;
103 103
 		}
104 104
 
Please login to merge, or discard this patch.
src/ConstraintRepository.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * then using the main DBLoadBalancer service may be incorrect.
28 28
 	 * @param string|false $dbName Database name ($domain for ILoadBalancer methods).
29 29
 	 */
30
-	public function __construct( ILoadBalancer $lb, $dbName ) {
30
+	public function __construct(ILoadBalancer $lb, $dbName) {
31 31
 		$this->lb = $lb;
32 32
 		$this->dbName = $dbName;
33 33
 	}
@@ -37,27 +37,27 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @return Constraint[]
39 39
 	 */
40
-	public function queryConstraintsForProperty( PropertyId $propertyId ) {
41
-		$dbr = $this->lb->getConnection( ILoadBalancer::DB_REPLICA, [], $this->dbName );
40
+	public function queryConstraintsForProperty(PropertyId $propertyId) {
41
+		$dbr = $this->lb->getConnection(ILoadBalancer::DB_REPLICA, [], $this->dbName);
42 42
 
43 43
 		$results = $dbr->select(
44 44
 			'wbqc_constraints',
45 45
 			'*',
46
-			[ 'pid' => $propertyId->getNumericId() ]
46
+			['pid' => $propertyId->getNumericId()]
47 47
 		);
48 48
 
49
-		if ( $this->dbName !== false ) {
50
-			$this->lb->reuseConnection( $dbr );
49
+		if ($this->dbName !== false) {
50
+			$this->lb->reuseConnection($dbr);
51 51
 		}
52 52
 
53
-		return $this->convertToConstraints( $results );
53
+		return $this->convertToConstraints($results);
54 54
 	}
55 55
 
56
-	private function encodeConstraintParameters( array $constraintParameters ) {
57
-		$json = json_encode( $constraintParameters, JSON_FORCE_OBJECT );
56
+	private function encodeConstraintParameters(array $constraintParameters) {
57
+		$json = json_encode($constraintParameters, JSON_FORCE_OBJECT);
58 58
 
59
-		if ( strlen( $json ) > 50000 ) {
60
-			$json = json_encode( [ '@error' => [ 'toolong' => true ] ] );
59
+		if (strlen($json) > 50000) {
60
+			$json = json_encode(['@error' => ['toolong' => true]]);
61 61
 		}
62 62
 
63 63
 		return $json;
@@ -69,25 +69,25 @@  discard block
 block discarded – undo
69 69
 	 * @throws DBUnexpectedError
70 70
 	 * @return bool
71 71
 	 */
72
-	public function insertBatch( array $constraints ) {
73
-		if ( $this->dbName !== false ) {
74
-			throw new LogicException( __METHOD__ . ' should not be called when constraints defined in non-local database.' );
72
+	public function insertBatch(array $constraints) {
73
+		if ($this->dbName !== false) {
74
+			throw new LogicException(__METHOD__.' should not be called when constraints defined in non-local database.');
75 75
 		}
76 76
 
77 77
 		$accumulator = array_map(
78
-			function ( Constraint $constraint ) {
78
+			function(Constraint $constraint) {
79 79
 				return [
80 80
 					'constraint_guid' => $constraint->getConstraintId(),
81 81
 					'pid' => $constraint->getPropertyId()->getNumericId(),
82 82
 					'constraint_type_qid' => $constraint->getConstraintTypeItemId(),
83
-					'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() )
83
+					'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters())
84 84
 				];
85 85
 			},
86 86
 			$constraints
87 87
 		);
88 88
 
89
-		$dbw = $this->lb->getConnection( ILoadBalancer::DB_MASTER );
90
-		return $dbw->insert( 'wbqc_constraints', $accumulator );
89
+		$dbw = $this->lb->getConnection(ILoadBalancer::DB_MASTER);
90
+		return $dbw->insert('wbqc_constraints', $accumulator);
91 91
 	}
92 92
 
93 93
 	/**
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @throws DBUnexpectedError
99 99
 	 */
100
-	public function deleteForProperty( PropertyId $propertyId ) {
101
-		if ( $this->dbName !== false ) {
102
-			throw new LogicException( __METHOD__ . ' should not be called when constraints defined in non-local database.' );
100
+	public function deleteForProperty(PropertyId $propertyId) {
101
+		if ($this->dbName !== false) {
102
+			throw new LogicException(__METHOD__.' should not be called when constraints defined in non-local database.');
103 103
 		}
104 104
 
105
-		$dbw = $this->lb->getConnection( ILoadBalancer::DB_MASTER );
105
+		$dbw = $this->lb->getConnection(ILoadBalancer::DB_MASTER);
106 106
 		$dbw->delete(
107 107
 			'wbqc_constraints',
108 108
 			[
@@ -116,26 +116,26 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @return Constraint[]
118 118
 	 */
119
-	private function convertToConstraints( IResultWrapper $results ) {
119
+	private function convertToConstraints(IResultWrapper $results) {
120 120
 		$constraints = [];
121
-		foreach ( $results as $result ) {
121
+		foreach ($results as $result) {
122 122
 			$constraintTypeItemId = $result->constraint_type_qid;
123
-			$constraintParameters = json_decode( $result->constraint_parameters, true );
123
+			$constraintParameters = json_decode($result->constraint_parameters, true);
124 124
 
125
-			if ( $constraintParameters === null ) {
125
+			if ($constraintParameters === null) {
126 126
 				// T171295
127
-				LoggerFactory::getInstance( 'WikibaseQualityConstraints' )
128
-					->warning( 'Constraint {constraintId} has invalid constraint parameters.', [
127
+				LoggerFactory::getInstance('WikibaseQualityConstraints')
128
+					->warning('Constraint {constraintId} has invalid constraint parameters.', [
129 129
 						'method' => __METHOD__,
130 130
 						'constraintId' => $result->constraint_guid,
131 131
 						'constraintParameters' => $result->constraint_parameters,
132
-					] );
133
-				$constraintParameters = [ '@error' => [ /* unknown */ ] ];
132
+					]);
133
+				$constraintParameters = ['@error' => [/* unknown */]];
134 134
 			}
135 135
 
136 136
 			$constraints[] = new Constraint(
137 137
 				$result->constraint_guid,
138
-				PropertyId::newFromNumber( $result->pid ),
138
+				PropertyId::newFromNumber($result->pid),
139 139
 				$constraintTypeItemId,
140 140
 				$constraintParameters
141 141
 			);
Please login to merge, or discard this patch.
src/ServiceWiring.php 1 patch
Spacing   +111 added lines, -111 removed lines patch added patch discarded remove patch
@@ -28,35 +28,35 @@  discard block
 block discarded – undo
28 28
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer;
29 29
 
30 30
 return [
31
-	ConstraintsServices::EXPIRY_LOCK => function( MediaWikiServices $services ) {
32
-		return new ExpiryLock( ObjectCache::getInstance( CACHE_ANYTHING ) );
31
+	ConstraintsServices::EXPIRY_LOCK => function(MediaWikiServices $services) {
32
+		return new ExpiryLock(ObjectCache::getInstance(CACHE_ANYTHING));
33 33
 	},
34 34
 
35
-	ConstraintsServices::LOGGING_HELPER => function( MediaWikiServices $services ) {
35
+	ConstraintsServices::LOGGING_HELPER => function(MediaWikiServices $services) {
36 36
 		return new LoggingHelper(
37 37
 			$services->getStatsdDataFactory(),
38
-			LoggerFactory::getInstance( 'WikibaseQualityConstraints' ),
38
+			LoggerFactory::getInstance('WikibaseQualityConstraints'),
39 39
 			$services->getMainConfig()
40 40
 		);
41 41
 	},
42 42
 
43
-	ConstraintsServices::CONSTRAINT_REPOSITORY => function( MediaWikiServices $services ) {
43
+	ConstraintsServices::CONSTRAINT_REPOSITORY => function(MediaWikiServices $services) {
44 44
 		$sourceDefinitions = WikibaseRepo::getDefaultInstance()->getEntitySourceDefinitions();
45
-		$propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE );
45
+		$propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE);
46 46
 		$dbName = $propertySource->getDatabaseName();
47 47
 
48 48
 		return new ConstraintRepository(
49
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
49
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
50 50
 			$dbName
51 51
 		);
52 52
 	},
53 53
 
54
-	ConstraintsServices::CONSTRAINT_LOOKUP => function( MediaWikiServices $services ) {
55
-		$constraintRepository = ConstraintsServices::getConstraintRepository( $services );
56
-		return new CachingConstraintLookup( $constraintRepository );
54
+	ConstraintsServices::CONSTRAINT_LOOKUP => function(MediaWikiServices $services) {
55
+		$constraintRepository = ConstraintsServices::getConstraintRepository($services);
56
+		return new CachingConstraintLookup($constraintRepository);
57 57
 	},
58 58
 
59
-	ConstraintsServices::CHECK_RESULT_SERIALIZER => function( MediaWikiServices $services ) {
59
+	ConstraintsServices::CHECK_RESULT_SERIALIZER => function(MediaWikiServices $services) {
60 60
 		return new CheckResultSerializer(
61 61
 			new ConstraintSerializer(
62 62
 				false // constraint parameters are not exposed
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		);
68 68
 	},
69 69
 
70
-	ConstraintsServices::CHECK_RESULT_DESERIALIZER => function( MediaWikiServices $services ) {
70
+	ConstraintsServices::CHECK_RESULT_DESERIALIZER => function(MediaWikiServices $services) {
71 71
 		// TODO in the future, get EntityIdParser and DataValueFactory from $services?
72 72
 		$repo = WikibaseRepo::getDefaultInstance();
73 73
 		$entityIdParser = $repo->getEntityIdParser();
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 	},
86 86
 
87
-	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function( MediaWikiServices $services ) {
87
+	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function(MediaWikiServices $services) {
88 88
 		return new ViolationMessageSerializer();
89 89
 	},
90 90
 
91
-	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function( MediaWikiServices $services ) {
91
+	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function(MediaWikiServices $services) {
92 92
 		// TODO in the future, get EntityIdParser and DataValueFactory from $services?
93 93
 		$repo = WikibaseRepo::getDefaultInstance();
94 94
 		$entityIdParser = $repo->getEntityIdParser();
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		);
101 101
 	},
102 102
 
103
-	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function( MediaWikiServices $services ) {
103
+	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) {
104 104
 		// TODO in the future, get DeserializerFactory and entity source definitions from $services?
105 105
 		$repo = WikibaseRepo::getDefaultInstance();
106 106
 		$deserializerFactory = $repo->getBaseDataModelDeserializerFactory();
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
 		return new ConstraintParameterParser(
110 110
 			$services->getMainConfig(),
111 111
 			$deserializerFactory,
112
-			$entitySourceDefinitions->getSourceForEntityType( 'item' )->getConceptBaseUri()
112
+			$entitySourceDefinitions->getSourceForEntityType('item')->getConceptBaseUri()
113 113
 		);
114 114
 	},
115 115
 
116
-	ConstraintsServices::CONNECTION_CHECKER_HELPER => function( MediaWikiServices $services ) {
116
+	ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) {
117 117
 		return new ConnectionCheckerHelper();
118 118
 	},
119 119
 
120
-	ConstraintsServices::RANGE_CHECKER_HELPER => function( MediaWikiServices $services ) {
120
+	ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) {
121 121
 		// TODO in the future, get UnitConverter from $services?
122 122
 		$repo = WikibaseRepo::getDefaultInstance();
123 123
 		$unitConverter = $repo->getUnitConverter();
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 		);
129 129
 	},
130 130
 
131
-	ConstraintsServices::SPARQL_HELPER => function( MediaWikiServices $services ) {
132
-		$endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' );
133
-		if ( $endpoint === '' ) {
131
+	ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) {
132
+		$endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint');
133
+		if ($endpoint === '') {
134 134
 			return new DummySparqlHelper();
135 135
 		}
136 136
 
@@ -146,122 +146,122 @@  discard block
 block discarded – undo
146 146
 			$entityIdParser,
147 147
 			$propertyDataTypeLookup,
148 148
 			$services->getMainWANObjectCache(),
149
-			ConstraintsServices::getViolationMessageSerializer( $services ),
150
-			ConstraintsServices::getViolationMessageDeserializer( $services ),
149
+			ConstraintsServices::getViolationMessageSerializer($services),
150
+			ConstraintsServices::getViolationMessageDeserializer($services),
151 151
 			$services->getStatsdDataFactory(),
152
-			ConstraintsServices::getExpiryLock( $services ),
152
+			ConstraintsServices::getExpiryLock($services),
153 153
 			ConstraintsServices::getLoggingHelper(),
154
-			wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(),
154
+			wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(),
155 155
 			$services->getHttpRequestFactory()
156 156
 		);
157 157
 	},
158 158
 
159
-	ConstraintsServices::TYPE_CHECKER_HELPER => function( MediaWikiServices $services ) {
159
+	ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) {
160 160
 		return new TypeCheckerHelper(
161
-			WikibaseServices::getEntityLookup( $services ),
161
+			WikibaseServices::getEntityLookup($services),
162 162
 			$services->getMainConfig(),
163
-			ConstraintsServices::getSparqlHelper( $services ),
163
+			ConstraintsServices::getSparqlHelper($services),
164 164
 			$services->getStatsdDataFactory()
165 165
 		);
166 166
 	},
167 167
 
168
-	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function( MediaWikiServices $services ) {
168
+	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) {
169 169
 		// TODO in the future, get StatementGuidParser from $services?
170 170
 		$repo = WikibaseRepo::getDefaultInstance();
171 171
 		$statementGuidParser = $repo->getStatementGuidParser();
172 172
 
173 173
 		$config = $services->getMainConfig();
174 174
 		$checkerMap = [
175
-			$config->get( 'WBQualityConstraintsConflictsWithConstraintId' )
176
-				=> ConstraintCheckerServices::getConflictsWithChecker( $services ),
177
-			$config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' )
178
-				=> ConstraintCheckerServices::getItemChecker( $services ),
179
-			$config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' )
180
-				=> ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ),
181
-			$config->get( 'WBQualityConstraintsSymmetricConstraintId' )
182
-				=> ConstraintCheckerServices::getSymmetricChecker( $services ),
183
-			$config->get( 'WBQualityConstraintsInverseConstraintId' )
184
-				=> ConstraintCheckerServices::getInverseChecker( $services ),
185
-			$config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' )
186
-				=> ConstraintCheckerServices::getQualifierChecker( $services ),
187
-			$config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' )
188
-				=> ConstraintCheckerServices::getQualifiersChecker( $services ),
189
-			$config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' )
190
-				=> ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ),
191
-			$config->get( 'WBQualityConstraintsRangeConstraintId' )
192
-				=> ConstraintCheckerServices::getRangeChecker( $services ),
193
-			$config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' )
194
-				=> ConstraintCheckerServices::getDiffWithinRangeChecker( $services ),
195
-			$config->get( 'WBQualityConstraintsTypeConstraintId' )
196
-				=> ConstraintCheckerServices::getTypeChecker( $services ),
197
-			$config->get( 'WBQualityConstraintsValueTypeConstraintId' )
198
-				=> ConstraintCheckerServices::getValueTypeChecker( $services ),
199
-			$config->get( 'WBQualityConstraintsSingleValueConstraintId' )
200
-				=> ConstraintCheckerServices::getSingleValueChecker( $services ),
201
-			$config->get( 'WBQualityConstraintsMultiValueConstraintId' )
202
-				=> ConstraintCheckerServices::getMultiValueChecker( $services ),
203
-			$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' )
204
-				=> ConstraintCheckerServices::getUniqueValueChecker( $services ),
205
-			$config->get( 'WBQualityConstraintsFormatConstraintId' )
206
-				=> ConstraintCheckerServices::getFormatChecker( $services ),
207
-			$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' )
208
-				=> ConstraintCheckerServices::getCommonsLinkChecker( $services ),
209
-			$config->get( 'WBQualityConstraintsOneOfConstraintId' )
210
-				=> ConstraintCheckerServices::getOneOfChecker( $services ),
211
-			$config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' )
212
-				=> ConstraintCheckerServices::getValueOnlyChecker( $services ),
213
-			$config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' )
214
-				=> ConstraintCheckerServices::getReferenceChecker( $services ),
215
-			$config->get( 'WBQualityConstraintsNoBoundsConstraintId' )
216
-				=> ConstraintCheckerServices::getNoBoundsChecker( $services ),
217
-			$config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' )
218
-				=> ConstraintCheckerServices::getAllowedUnitsChecker( $services ),
219
-			$config->get( 'WBQualityConstraintsSingleBestValueConstraintId' )
220
-				=> ConstraintCheckerServices::getSingleBestValueChecker( $services ),
221
-			$config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' )
222
-				=> ConstraintCheckerServices::getEntityTypeChecker( $services ),
223
-			$config->get( 'WBQualityConstraintsNoneOfConstraintId' )
224
-				=> ConstraintCheckerServices::getNoneOfChecker( $services ),
225
-			$config->get( 'WBQualityConstraintsIntegerConstraintId' )
226
-				=> ConstraintCheckerServices::getIntegerChecker( $services ),
227
-			$config->get( 'WBQualityConstraintsCitationNeededConstraintId' )
228
-				=> ConstraintCheckerServices::getCitationNeededChecker( $services ),
229
-			$config->get( 'WBQualityConstraintsPropertyScopeConstraintId' )
230
-				=> ConstraintCheckerServices::getPropertyScopeChecker( $services ),
231
-			$config->get( 'WBQualityConstraintsContemporaryConstraintId' )
232
-				=> ConstraintCheckerServices::getContemporaryChecker( $services ),
175
+			$config->get('WBQualityConstraintsConflictsWithConstraintId')
176
+				=> ConstraintCheckerServices::getConflictsWithChecker($services),
177
+			$config->get('WBQualityConstraintsItemRequiresClaimConstraintId')
178
+				=> ConstraintCheckerServices::getItemChecker($services),
179
+			$config->get('WBQualityConstraintsValueRequiresClaimConstraintId')
180
+				=> ConstraintCheckerServices::getTargetRequiredClaimChecker($services),
181
+			$config->get('WBQualityConstraintsSymmetricConstraintId')
182
+				=> ConstraintCheckerServices::getSymmetricChecker($services),
183
+			$config->get('WBQualityConstraintsInverseConstraintId')
184
+				=> ConstraintCheckerServices::getInverseChecker($services),
185
+			$config->get('WBQualityConstraintsUsedAsQualifierConstraintId')
186
+				=> ConstraintCheckerServices::getQualifierChecker($services),
187
+			$config->get('WBQualityConstraintsAllowedQualifiersConstraintId')
188
+				=> ConstraintCheckerServices::getQualifiersChecker($services),
189
+			$config->get('WBQualityConstraintsMandatoryQualifierConstraintId')
190
+				=> ConstraintCheckerServices::getMandatoryQualifiersChecker($services),
191
+			$config->get('WBQualityConstraintsRangeConstraintId')
192
+				=> ConstraintCheckerServices::getRangeChecker($services),
193
+			$config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId')
194
+				=> ConstraintCheckerServices::getDiffWithinRangeChecker($services),
195
+			$config->get('WBQualityConstraintsTypeConstraintId')
196
+				=> ConstraintCheckerServices::getTypeChecker($services),
197
+			$config->get('WBQualityConstraintsValueTypeConstraintId')
198
+				=> ConstraintCheckerServices::getValueTypeChecker($services),
199
+			$config->get('WBQualityConstraintsSingleValueConstraintId')
200
+				=> ConstraintCheckerServices::getSingleValueChecker($services),
201
+			$config->get('WBQualityConstraintsMultiValueConstraintId')
202
+				=> ConstraintCheckerServices::getMultiValueChecker($services),
203
+			$config->get('WBQualityConstraintsDistinctValuesConstraintId')
204
+				=> ConstraintCheckerServices::getUniqueValueChecker($services),
205
+			$config->get('WBQualityConstraintsFormatConstraintId')
206
+				=> ConstraintCheckerServices::getFormatChecker($services),
207
+			$config->get('WBQualityConstraintsCommonsLinkConstraintId')
208
+				=> ConstraintCheckerServices::getCommonsLinkChecker($services),
209
+			$config->get('WBQualityConstraintsOneOfConstraintId')
210
+				=> ConstraintCheckerServices::getOneOfChecker($services),
211
+			$config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId')
212
+				=> ConstraintCheckerServices::getValueOnlyChecker($services),
213
+			$config->get('WBQualityConstraintsUsedAsReferenceConstraintId')
214
+				=> ConstraintCheckerServices::getReferenceChecker($services),
215
+			$config->get('WBQualityConstraintsNoBoundsConstraintId')
216
+				=> ConstraintCheckerServices::getNoBoundsChecker($services),
217
+			$config->get('WBQualityConstraintsAllowedUnitsConstraintId')
218
+				=> ConstraintCheckerServices::getAllowedUnitsChecker($services),
219
+			$config->get('WBQualityConstraintsSingleBestValueConstraintId')
220
+				=> ConstraintCheckerServices::getSingleBestValueChecker($services),
221
+			$config->get('WBQualityConstraintsAllowedEntityTypesConstraintId')
222
+				=> ConstraintCheckerServices::getEntityTypeChecker($services),
223
+			$config->get('WBQualityConstraintsNoneOfConstraintId')
224
+				=> ConstraintCheckerServices::getNoneOfChecker($services),
225
+			$config->get('WBQualityConstraintsIntegerConstraintId')
226
+				=> ConstraintCheckerServices::getIntegerChecker($services),
227
+			$config->get('WBQualityConstraintsCitationNeededConstraintId')
228
+				=> ConstraintCheckerServices::getCitationNeededChecker($services),
229
+			$config->get('WBQualityConstraintsPropertyScopeConstraintId')
230
+				=> ConstraintCheckerServices::getPropertyScopeChecker($services),
231
+			$config->get('WBQualityConstraintsContemporaryConstraintId')
232
+				=> ConstraintCheckerServices::getContemporaryChecker($services),
233 233
 		];
234 234
 
235 235
 		return new DelegatingConstraintChecker(
236
-			WikibaseServices::getEntityLookup( $services ),
236
+			WikibaseServices::getEntityLookup($services),
237 237
 			$checkerMap,
238
-			ConstraintsServices::getConstraintLookup( $services ),
239
-			ConstraintsServices::getConstraintParameterParser( $services ),
238
+			ConstraintsServices::getConstraintLookup($services),
239
+			ConstraintsServices::getConstraintParameterParser($services),
240 240
 			$statementGuidParser,
241
-			ConstraintsServices::getLoggingHelper( $services ),
242
-			$config->get( 'WBQualityConstraintsCheckQualifiers' ),
243
-			$config->get( 'WBQualityConstraintsCheckReferences' ),
244
-			$config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' )
241
+			ConstraintsServices::getLoggingHelper($services),
242
+			$config->get('WBQualityConstraintsCheckQualifiers'),
243
+			$config->get('WBQualityConstraintsCheckReferences'),
244
+			$config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers')
245 245
 		);
246 246
 	},
247 247
 
248
-	ConstraintsServices::RESULTS_SOURCE => function( MediaWikiServices $services ) {
248
+	ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) {
249 249
 		$config = $services->getMainConfig();
250 250
 		$resultsSource = new CheckingResultsSource(
251
-			ConstraintsServices::getDelegatingConstraintChecker( $services )
251
+			ConstraintsServices::getDelegatingConstraintChecker($services)
252 252
 		);
253 253
 
254 254
 		$cacheCheckConstraintsResults = false;
255 255
 
256
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
256
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
257 257
 			$cacheCheckConstraintsResults = true;
258 258
 			// check that we can use getLocalRepoWikiPageMetaDataAccessor()
259 259
 			// TODO we should always be able to cache constraint check results (T244726)
260 260
 			$repo = WikibaseRepo::getDefaultInstance();
261
-			foreach ( $repo->getEntitySourceDefinitions()->getSources() as $entitySource ) {
262
-				if ( $entitySource->getDatabaseName() !== false ) {
263
-					LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning(
264
-						'Cannot cache constraint check results for non-local source: ' .
261
+			foreach ($repo->getEntitySourceDefinitions()->getSources() as $entitySource) {
262
+				if ($entitySource->getDatabaseName() !== false) {
263
+					LoggerFactory::getInstance('WikibaseQualityConstraints')->warning(
264
+						'Cannot cache constraint check results for non-local source: '.
265 265
 						$entitySource->getSourceName()
266 266
 					);
267 267
 					$cacheCheckConstraintsResults = false;
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
 			}
271 271
 		}
272 272
 
273
-		if ( $cacheCheckConstraintsResults ) {
273
+		if ($cacheCheckConstraintsResults) {
274 274
 			$possiblyStaleConstraintTypes = [
275
-				$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
276
-				$config->get( 'WBQualityConstraintsTypeConstraintId' ),
277
-				$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
278
-				$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
275
+				$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
276
+				$config->get('WBQualityConstraintsTypeConstraintId'),
277
+				$config->get('WBQualityConstraintsValueTypeConstraintId'),
278
+				$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
279 279
 			];
280 280
 			// TODO in the future, get EntityIdParser and WikiPageEntityMetaDataAccessor from $services?
281 281
 			$repo = WikibaseRepo::getDefaultInstance();
@@ -285,14 +285,14 @@  discard block
 block discarded – undo
285 285
 			$resultsSource = new CachingResultsSource(
286 286
 				$resultsSource,
287 287
 				ResultsCache::getDefaultInstance(),
288
-				ConstraintsServices::getCheckResultSerializer( $services ),
289
-				ConstraintsServices::getCheckResultDeserializer( $services ),
288
+				ConstraintsServices::getCheckResultSerializer($services),
289
+				ConstraintsServices::getCheckResultDeserializer($services),
290 290
 				$wikiPageEntityMetaDataAccessor,
291 291
 				$entityIdParser,
292
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
292
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
293 293
 				$possiblyStaleConstraintTypes,
294
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ),
295
-				ConstraintsServices::getLoggingHelper( $services )
294
+				$config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'),
295
+				ConstraintsServices::getLoggingHelper($services)
296 296
 			);
297 297
 		}
298 298
 
Please login to merge, or discard this patch.