Completed
Push — master ( d474ac...b9f07c )
by
unknown
41s queued 11s
created
maintenance/ImportConstraintEntities.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -18,10 +18,10 @@  discard block
 block discarded – undo
18 18
 use WikiMap;
19 19
 
20 20
 // @codeCoverageIgnoreStart
21
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
22
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
21
+$basePath = getenv("MW_INSTALL_PATH") !== false
22
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
23 23
 
24
-require_once $basePath . "/maintenance/Maintenance.php";
24
+require_once $basePath."/maintenance/Maintenance.php";
25 25
 // @codeCoverageIgnoreEnd
26 26
 
27 27
 /**
@@ -60,20 +60,20 @@  discard block
 block discarded – undo
60 60
 		parent::__construct();
61 61
 
62 62
 		$this->addDescription(
63
-			'Import entities needed for constraint checks ' .
63
+			'Import entities needed for constraint checks '.
64 64
 			'from Wikidata into the local repository.'
65 65
 		);
66 66
 		$this->addOption(
67 67
 			'config-format',
68
-			'The format in which the resulting configuration will be omitted: ' .
69
-			'"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), ' .
68
+			'The format in which the resulting configuration will be omitted: '.
69
+			'"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), '.
70 70
 			'or "wgConf" for printing parts of arrays suitable for inclusion in $wgConf->settings.'
71 71
 		);
72 72
 		$this->addOption(
73 73
 			'dry-run',
74 74
 			'Don’t actually import entities, just print which ones would be imported.'
75 75
 		);
76
-		$this->requireExtension( 'WikibaseQualityConstraints' );
76
+		$this->requireExtension('WikibaseQualityConstraints');
77 77
 	}
78 78
 
79 79
 	/**
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	private function setupServices() {
83 83
 		$services = MediaWikiServices::getInstance();
84
-		$this->entitySerializer = WikibaseRepo::getAllTypesEntitySerializer( $services );
85
-		$this->entityDeserializer = WikibaseRepo::getInternalFormatEntityDeserializer( $services );
86
-		$this->entityStore = WikibaseRepo::getEntityStore( $services );
84
+		$this->entitySerializer = WikibaseRepo::getAllTypesEntitySerializer($services);
85
+		$this->entityDeserializer = WikibaseRepo::getInternalFormatEntityDeserializer($services);
86
+		$this->entityStore = WikibaseRepo::getEntityStore($services);
87 87
 		$this->httpRequestFactory = $services->getHttpRequestFactory();
88
-		if ( !$this->getOption( 'dry-run', false ) ) {
89
-			$this->user = User::newSystemUser( 'WikibaseQualityConstraints importer' );
88
+		if (!$this->getOption('dry-run', false)) {
89
+			$this->user = User::newSystemUser('WikibaseQualityConstraints importer');
90 90
 		}
91 91
 	}
92 92
 
@@ -95,21 +95,21 @@  discard block
 block discarded – undo
95 95
 
96 96
 		$configUpdates = [];
97 97
 
98
-		$extensionJsonFile = __DIR__ . '/../extension.json';
99
-		$extensionJsonText = file_get_contents( $extensionJsonFile );
100
-		$extensionJson = json_decode( $extensionJsonText, /* assoc = */ true );
98
+		$extensionJsonFile = __DIR__.'/../extension.json';
99
+		$extensionJsonText = file_get_contents($extensionJsonFile);
100
+		$extensionJson = json_decode($extensionJsonText, /* assoc = */ true);
101 101
 		// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
102
-		$wikidataEntityIds = $this->getEntitiesToImport( $extensionJson['config'], $this->getConfig() );
102
+		$wikidataEntityIds = $this->getEntitiesToImport($extensionJson['config'], $this->getConfig());
103 103
 
104
-		foreach ( $wikidataEntityIds as $key => $wikidataEntityId ) {
105
-			$localEntityId = $this->importEntityFromWikidata( $wikidataEntityId );
104
+		foreach ($wikidataEntityIds as $key => $wikidataEntityId) {
105
+			$localEntityId = $this->importEntityFromWikidata($wikidataEntityId);
106 106
 			$configUpdates[$key] = [
107 107
 				'wikidata' => $wikidataEntityId,
108 108
 				'local' => $localEntityId,
109 109
 			];
110 110
 		}
111 111
 
112
-		$this->outputConfigUpdates( $configUpdates );
112
+		$this->outputConfigUpdates($configUpdates);
113 113
 	}
114 114
 
115 115
 	/**
@@ -117,18 +117,18 @@  discard block
 block discarded – undo
117 117
 	 * @param Config $wikiConfig
118 118
 	 * @return string[]
119 119
 	 */
120
-	private function getEntitiesToImport( array $extensionJsonConfig, Config $wikiConfig ) {
120
+	private function getEntitiesToImport(array $extensionJsonConfig, Config $wikiConfig) {
121 121
 		$wikidataEntityIds = [];
122 122
 
123
-		foreach ( $extensionJsonConfig as $key => $value ) {
124
-			if ( !preg_match( '/Id$/', $key ) ) {
123
+		foreach ($extensionJsonConfig as $key => $value) {
124
+			if (!preg_match('/Id$/', $key)) {
125 125
 				continue;
126 126
 			}
127 127
 
128 128
 			$wikidataEntityId = $value['value'];
129
-			$localEntityId = $wikiConfig->get( $key );
129
+			$localEntityId = $wikiConfig->get($key);
130 130
 
131
-			if ( $localEntityId === $wikidataEntityId ) {
131
+			if ($localEntityId === $wikidataEntityId) {
132 132
 				$wikidataEntityIds[$key] = $wikidataEntityId;
133 133
 			}
134 134
 		}
@@ -140,10 +140,10 @@  discard block
 block discarded – undo
140 140
 	 * @param string $wikidataEntityId
141 141
 	 * @return string local entity ID
142 142
 	 */
143
-	private function importEntityFromWikidata( $wikidataEntityId ) {
143
+	private function importEntityFromWikidata($wikidataEntityId) {
144 144
 		$wikidataEntityUrl = "https://www.wikidata.org/wiki/Special:EntityData/$wikidataEntityId.json";
145
-		$wikidataEntitiesJson = $this->httpRequestFactory->get( $wikidataEntityUrl, [], __METHOD__ );
146
-		return $this->importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson );
145
+		$wikidataEntitiesJson = $this->httpRequestFactory->get($wikidataEntityUrl, [], __METHOD__);
146
+		return $this->importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson);
147 147
 	}
148 148
 
149 149
 	/**
@@ -151,24 +151,24 @@  discard block
 block discarded – undo
151 151
 	 * @param string $wikidataEntitiesJson
152 152
 	 * @return string local entity ID
153 153
 	 */
154
-	private function importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ) {
154
+	private function importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson) {
155 155
 		// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
156
-		$wikidataEntityArray = json_decode( $wikidataEntitiesJson, true )['entities'][$wikidataEntityId];
157
-		$wikidataEntity = $this->entityDeserializer->deserialize( $wikidataEntityArray );
156
+		$wikidataEntityArray = json_decode($wikidataEntitiesJson, true)['entities'][$wikidataEntityId];
157
+		$wikidataEntity = $this->entityDeserializer->deserialize($wikidataEntityArray);
158 158
 
159
-		$wikidataEntity->setId( null );
159
+		$wikidataEntity->setId(null);
160 160
 
161
-		if ( $wikidataEntity instanceof StatementListProvider ) {
161
+		if ($wikidataEntity instanceof StatementListProvider) {
162 162
 			$wikidataEntity->getStatements()->clear();
163 163
 		}
164 164
 
165
-		if ( $wikidataEntity instanceof Item ) {
166
-			$wikidataEntity->setSiteLinkList( new SiteLinkList() );
165
+		if ($wikidataEntity instanceof Item) {
166
+			$wikidataEntity->setSiteLinkList(new SiteLinkList());
167 167
 		}
168 168
 
169
-		if ( $this->getOption( 'dry-run', false ) ) {
170
-			$wikidataEntityJson = json_encode( $this->entitySerializer->serialize( $wikidataEntity ) );
171
-			$this->output( $wikidataEntityJson . "\n" );
169
+		if ($this->getOption('dry-run', false)) {
170
+			$wikidataEntityJson = json_encode($this->entitySerializer->serialize($wikidataEntity));
171
+			$this->output($wikidataEntityJson."\n");
172 172
 			return "-$wikidataEntityId";
173 173
 		}
174 174
 
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
 			)->getEntity();
182 182
 
183 183
 			return $localEntity->getId()->getSerialization();
184
-		} catch ( StorageException $storageException ) {
185
-			return $this->storageExceptionToEntityId( $storageException );
184
+		} catch (StorageException $storageException) {
185
+			return $this->storageExceptionToEntityId($storageException);
186 186
 		}
187 187
 	}
188 188
 
189
-	private function storageExceptionToEntityId( StorageException $storageException ) {
189
+	private function storageExceptionToEntityId(StorageException $storageException) {
190 190
 		$message = $storageException->getMessage();
191 191
 		// example messages:
192 192
 		// * Item [[Item:Q475|Q475]] already has label "as references"
@@ -196,25 +196,25 @@  discard block
 block discarded – undo
196 196
 		// * Property [[Property:P694|P694]] already has label "instance of"
197 197
 		//   associated with language code en.
198 198
 		$pattern = '/[[|]([^][|]*)]] already has label .* associated with language code/';
199
-		if ( preg_match( $pattern, $message, $matches ) ) {
199
+		if (preg_match($pattern, $message, $matches)) {
200 200
 			return $matches[1];
201 201
 		} else {
202 202
 			throw $storageException;
203 203
 		}
204 204
 	}
205 205
 
206
-	private function outputConfigUpdates( array $configUpdates ) {
207
-		$configFormat = $this->getOption( 'config-format', 'globals' );
208
-		switch ( $configFormat ) {
206
+	private function outputConfigUpdates(array $configUpdates) {
207
+		$configFormat = $this->getOption('config-format', 'globals');
208
+		switch ($configFormat) {
209 209
 			case 'globals':
210
-				$this->outputConfigUpdatesGlobals( $configUpdates );
210
+				$this->outputConfigUpdatesGlobals($configUpdates);
211 211
 				break;
212 212
 			case 'wgConf':
213
-				$this->outputConfigUpdatesWgConf( $configUpdates );
213
+				$this->outputConfigUpdatesWgConf($configUpdates);
214 214
 				break;
215 215
 			default:
216
-				$this->error( "Invalid config format \"$configFormat\", using \"globals\"" );
217
-				$this->outputConfigUpdatesGlobals( $configUpdates );
216
+				$this->error("Invalid config format \"$configFormat\", using \"globals\"");
217
+				$this->outputConfigUpdatesGlobals($configUpdates);
218 218
 				break;
219 219
 		}
220 220
 	}
@@ -222,22 +222,22 @@  discard block
 block discarded – undo
222 222
 	/**
223 223
 	 * @param array[] $configUpdates
224 224
 	 */
225
-	private function outputConfigUpdatesGlobals( array $configUpdates ) {
226
-		foreach ( $configUpdates as $key => $value ) {
227
-			$localValueCode = var_export( $value['local'], true );
228
-			$this->output( "\$wg$key = $localValueCode;\n" );
225
+	private function outputConfigUpdatesGlobals(array $configUpdates) {
226
+		foreach ($configUpdates as $key => $value) {
227
+			$localValueCode = var_export($value['local'], true);
228
+			$this->output("\$wg$key = $localValueCode;\n");
229 229
 		}
230 230
 	}
231 231
 
232 232
 	/**
233 233
 	 * @param array[] $configUpdates
234 234
 	 */
235
-	private function outputConfigUpdatesWgConf( array $configUpdates ) {
236
-		foreach ( $configUpdates as $key => $value ) {
237
-			$keyCode = var_export( "wg$key", true );
238
-			$wikidataValueCode = var_export( $value['wikidata'], true );
239
-			$localValueCode = var_export( $value['local'], true );
240
-			$wikiIdCode = var_export( WikiMap::getCurrentWikiId(), true );
235
+	private function outputConfigUpdatesWgConf(array $configUpdates) {
236
+		foreach ($configUpdates as $key => $value) {
237
+			$keyCode = var_export("wg$key", true);
238
+			$wikidataValueCode = var_export($value['wikidata'], true);
239
+			$localValueCode = var_export($value['local'], true);
240
+			$wikiIdCode = var_export(WikiMap::getCurrentWikiId(), true);
241 241
 			$block = <<< EOF
242 242
 $keyCode => [
243 243
 	'default' => $wikidataValueCode,
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 
247 247
 
248 248
 EOF;
249
-			$this->output( $block );
249
+			$this->output($block);
250 250
 		}
251 251
 	}
252 252
 
Please login to merge, or discard this patch.
src/ServiceWiring.php 1 patch
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -29,46 +29,46 @@  discard block
 block discarded – undo
29 29
 use WikiMap;
30 30
 
31 31
 return [
32
-	ConstraintsServices::EXPIRY_LOCK => static function ( MediaWikiServices $services ) {
33
-		return new ExpiryLock( ObjectCache::getInstance( CACHE_ANYTHING ) );
32
+	ConstraintsServices::EXPIRY_LOCK => static function(MediaWikiServices $services) {
33
+		return new ExpiryLock(ObjectCache::getInstance(CACHE_ANYTHING));
34 34
 	},
35 35
 
36
-	ConstraintsServices::LOGGING_HELPER => static function ( MediaWikiServices $services ) {
36
+	ConstraintsServices::LOGGING_HELPER => static function(MediaWikiServices $services) {
37 37
 		return new LoggingHelper(
38 38
 			$services->getStatsdDataFactory(),
39
-			LoggerFactory::getInstance( 'WikibaseQualityConstraints' ),
39
+			LoggerFactory::getInstance('WikibaseQualityConstraints'),
40 40
 			$services->getMainConfig()
41 41
 		);
42 42
 	},
43 43
 
44
-	ConstraintsServices::CONSTRAINT_STORE => static function ( MediaWikiServices $services ) {
45
-		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services );
46
-		$propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE );
44
+	ConstraintsServices::CONSTRAINT_STORE => static function(MediaWikiServices $services) {
45
+		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services);
46
+		$propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE);
47 47
 		$dbName = $propertySource->getDatabaseName();
48
-		$localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName();
48
+		$localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName();
49 49
 
50
-		if ( $propertySource->getSourceName() !== $localEntitySourceName ) {
51
-			throw new \RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' );
50
+		if ($propertySource->getSourceName() !== $localEntitySourceName) {
51
+			throw new \RuntimeException('Can\'t get a ConstraintStore for a non local entity source.');
52 52
 		}
53 53
 
54 54
 		return new ConstraintRepositoryStore(
55
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
55
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
56 56
 			$dbName
57 57
 		);
58 58
 	},
59 59
 
60
-	ConstraintsServices::CONSTRAINT_LOOKUP => static function ( MediaWikiServices $services ) {
61
-		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services );
62
-		$propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE );
60
+	ConstraintsServices::CONSTRAINT_LOOKUP => static function(MediaWikiServices $services) {
61
+		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services);
62
+		$propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE);
63 63
 		$dbName = $propertySource->getDatabaseName();
64 64
 		$rawLookup = new ConstraintRepositoryLookup(
65
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
65
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
66 66
 			$dbName
67 67
 		);
68
-		return new CachingConstraintLookup( $rawLookup );
68
+		return new CachingConstraintLookup($rawLookup);
69 69
 	},
70 70
 
71
-	ConstraintsServices::CHECK_RESULT_SERIALIZER => static function ( MediaWikiServices $services ) {
71
+	ConstraintsServices::CHECK_RESULT_SERIALIZER => static function(MediaWikiServices $services) {
72 72
 		return new CheckResultSerializer(
73 73
 			new ConstraintSerializer(
74 74
 				false // constraint parameters are not exposed
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 		);
80 80
 	},
81 81
 
82
-	ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function ( MediaWikiServices $services ) {
83
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
84
-		$dataValueFactory = WikibaseRepo::getDataValueFactory( $services );
82
+	ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function(MediaWikiServices $services) {
83
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
84
+		$dataValueFactory = WikibaseRepo::getDataValueFactory($services);
85 85
 
86 86
 		return new CheckResultDeserializer(
87 87
 			new ConstraintDeserializer(),
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 		);
95 95
 	},
96 96
 
97
-	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function ( MediaWikiServices $services ) {
97
+	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function(MediaWikiServices $services) {
98 98
 		return new ViolationMessageSerializer();
99 99
 	},
100 100
 
101
-	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function ( MediaWikiServices $services ) {
102
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
103
-		$dataValueFactory = WikibaseRepo::getDataValueFactory( $services );
101
+	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function(MediaWikiServices $services) {
102
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
103
+		$dataValueFactory = WikibaseRepo::getDataValueFactory($services);
104 104
 
105 105
 		return new ViolationMessageDeserializer(
106 106
 			$entityIdParser,
@@ -108,37 +108,37 @@  discard block
 block discarded – undo
108 108
 		);
109 109
 	},
110 110
 
111
-	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function ( MediaWikiServices $services ) {
112
-		$deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory( $services );
113
-		$entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services );
111
+	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function(MediaWikiServices $services) {
112
+		$deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory($services);
113
+		$entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services);
114 114
 
115 115
 		return new ConstraintParameterParser(
116 116
 			$services->getMainConfig(),
117 117
 			$deserializerFactory,
118
-			$entitySourceDefinitions->getDatabaseSourceForEntityType( 'item' )->getConceptBaseUri()
118
+			$entitySourceDefinitions->getDatabaseSourceForEntityType('item')->getConceptBaseUri()
119 119
 		);
120 120
 	},
121 121
 
122
-	ConstraintsServices::CONNECTION_CHECKER_HELPER => static function ( MediaWikiServices $services ) {
122
+	ConstraintsServices::CONNECTION_CHECKER_HELPER => static function(MediaWikiServices $services) {
123 123
 		return new ConnectionCheckerHelper();
124 124
 	},
125 125
 
126
-	ConstraintsServices::RANGE_CHECKER_HELPER => static function ( MediaWikiServices $services ) {
126
+	ConstraintsServices::RANGE_CHECKER_HELPER => static function(MediaWikiServices $services) {
127 127
 		return new RangeCheckerHelper(
128 128
 			$services->getMainConfig(),
129
-			WikibaseRepo::getUnitConverter( $services )
129
+			WikibaseRepo::getUnitConverter($services)
130 130
 		);
131 131
 	},
132 132
 
133
-	ConstraintsServices::SPARQL_HELPER => static function ( MediaWikiServices $services ) {
134
-		$endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' );
135
-		if ( $endpoint === '' ) {
133
+	ConstraintsServices::SPARQL_HELPER => static function(MediaWikiServices $services) {
134
+		$endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint');
135
+		if ($endpoint === '') {
136 136
 			return new DummySparqlHelper();
137 137
 		}
138 138
 
139
-		$rdfVocabulary = WikibaseRepo::getRdfVocabulary( $services );
140
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
141
-		$propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup( $services );
139
+		$rdfVocabulary = WikibaseRepo::getRdfVocabulary($services);
140
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
141
+		$propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup($services);
142 142
 
143 143
 		return new SparqlHelper(
144 144
 			$services->getMainConfig(),
@@ -146,126 +146,126 @@  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 ),
153
-			ConstraintsServices::getLoggingHelper( $services ),
154
-			WikiMap::getCurrentWikiId() . ' WikibaseQualityConstraints ' . Http::userAgent(),
152
+			ConstraintsServices::getExpiryLock($services),
153
+			ConstraintsServices::getLoggingHelper($services),
154
+			WikiMap::getCurrentWikiId().' WikibaseQualityConstraints '.Http::userAgent(),
155 155
 			$services->getHttpRequestFactory()
156 156
 		);
157 157
 	},
158 158
 
159
-	ConstraintsServices::TYPE_CHECKER_HELPER => static function ( MediaWikiServices $services ) {
159
+	ConstraintsServices::TYPE_CHECKER_HELPER => static 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 => static function ( MediaWikiServices $services ) {
169
-		$statementGuidParser = WikibaseRepo::getStatementGuidParser( $services );
168
+	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function(MediaWikiServices $services) {
169
+		$statementGuidParser = WikibaseRepo::getStatementGuidParser($services);
170 170
 
171 171
 		$config = $services->getMainConfig();
172 172
 		$checkerMap = [
173
-			$config->get( 'WBQualityConstraintsConflictsWithConstraintId' )
174
-				=> ConstraintCheckerServices::getConflictsWithChecker( $services ),
175
-			$config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' )
176
-				=> ConstraintCheckerServices::getItemChecker( $services ),
177
-			$config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' )
178
-				=> ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ),
179
-			$config->get( 'WBQualityConstraintsSymmetricConstraintId' )
180
-				=> ConstraintCheckerServices::getSymmetricChecker( $services ),
181
-			$config->get( 'WBQualityConstraintsInverseConstraintId' )
182
-				=> ConstraintCheckerServices::getInverseChecker( $services ),
183
-			$config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' )
184
-				=> ConstraintCheckerServices::getQualifierChecker( $services ),
185
-			$config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' )
186
-				=> ConstraintCheckerServices::getQualifiersChecker( $services ),
187
-			$config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' )
188
-				=> ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ),
189
-			$config->get( 'WBQualityConstraintsRangeConstraintId' )
190
-				=> ConstraintCheckerServices::getRangeChecker( $services ),
191
-			$config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' )
192
-				=> ConstraintCheckerServices::getDiffWithinRangeChecker( $services ),
193
-			$config->get( 'WBQualityConstraintsTypeConstraintId' )
194
-				=> ConstraintCheckerServices::getTypeChecker( $services ),
195
-			$config->get( 'WBQualityConstraintsValueTypeConstraintId' )
196
-				=> ConstraintCheckerServices::getValueTypeChecker( $services ),
197
-			$config->get( 'WBQualityConstraintsSingleValueConstraintId' )
198
-				=> ConstraintCheckerServices::getSingleValueChecker( $services ),
199
-			$config->get( 'WBQualityConstraintsMultiValueConstraintId' )
200
-				=> ConstraintCheckerServices::getMultiValueChecker( $services ),
201
-			$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' )
202
-				=> ConstraintCheckerServices::getUniqueValueChecker( $services ),
203
-			$config->get( 'WBQualityConstraintsFormatConstraintId' )
204
-				=> ConstraintCheckerServices::getFormatChecker( $services ),
205
-			$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' )
206
-				=> ConstraintCheckerServices::getCommonsLinkChecker( $services ),
207
-			$config->get( 'WBQualityConstraintsOneOfConstraintId' )
208
-				=> ConstraintCheckerServices::getOneOfChecker( $services ),
209
-			$config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' )
210
-				=> ConstraintCheckerServices::getValueOnlyChecker( $services ),
211
-			$config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' )
212
-				=> ConstraintCheckerServices::getReferenceChecker( $services ),
213
-			$config->get( 'WBQualityConstraintsNoBoundsConstraintId' )
214
-				=> ConstraintCheckerServices::getNoBoundsChecker( $services ),
215
-			$config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' )
216
-				=> ConstraintCheckerServices::getAllowedUnitsChecker( $services ),
217
-			$config->get( 'WBQualityConstraintsSingleBestValueConstraintId' )
218
-				=> ConstraintCheckerServices::getSingleBestValueChecker( $services ),
219
-			$config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' )
220
-				=> ConstraintCheckerServices::getEntityTypeChecker( $services ),
221
-			$config->get( 'WBQualityConstraintsNoneOfConstraintId' )
222
-				=> ConstraintCheckerServices::getNoneOfChecker( $services ),
223
-			$config->get( 'WBQualityConstraintsIntegerConstraintId' )
224
-				=> ConstraintCheckerServices::getIntegerChecker( $services ),
225
-			$config->get( 'WBQualityConstraintsCitationNeededConstraintId' )
226
-				=> ConstraintCheckerServices::getCitationNeededChecker( $services ),
227
-			$config->get( 'WBQualityConstraintsPropertyScopeConstraintId' )
228
-				=> ConstraintCheckerServices::getPropertyScopeChecker( $services ),
229
-			$config->get( 'WBQualityConstraintsContemporaryConstraintId' )
230
-				=> ConstraintCheckerServices::getContemporaryChecker( $services ),
231
-			$config->get( 'WBQualityConstraintsLexemeLanguageConstraintId' )
232
-				=> ConstraintCheckerServices::getLexemeLanguageChecker( $services ),
233
-			$config->get( 'WBQualityConstraintsLabelInLanguageConstraintId' )
234
-				=> ConstraintCheckerServices::getLabelInLanguageChecker( $services ),
173
+			$config->get('WBQualityConstraintsConflictsWithConstraintId')
174
+				=> ConstraintCheckerServices::getConflictsWithChecker($services),
175
+			$config->get('WBQualityConstraintsItemRequiresClaimConstraintId')
176
+				=> ConstraintCheckerServices::getItemChecker($services),
177
+			$config->get('WBQualityConstraintsValueRequiresClaimConstraintId')
178
+				=> ConstraintCheckerServices::getTargetRequiredClaimChecker($services),
179
+			$config->get('WBQualityConstraintsSymmetricConstraintId')
180
+				=> ConstraintCheckerServices::getSymmetricChecker($services),
181
+			$config->get('WBQualityConstraintsInverseConstraintId')
182
+				=> ConstraintCheckerServices::getInverseChecker($services),
183
+			$config->get('WBQualityConstraintsUsedAsQualifierConstraintId')
184
+				=> ConstraintCheckerServices::getQualifierChecker($services),
185
+			$config->get('WBQualityConstraintsAllowedQualifiersConstraintId')
186
+				=> ConstraintCheckerServices::getQualifiersChecker($services),
187
+			$config->get('WBQualityConstraintsMandatoryQualifierConstraintId')
188
+				=> ConstraintCheckerServices::getMandatoryQualifiersChecker($services),
189
+			$config->get('WBQualityConstraintsRangeConstraintId')
190
+				=> ConstraintCheckerServices::getRangeChecker($services),
191
+			$config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId')
192
+				=> ConstraintCheckerServices::getDiffWithinRangeChecker($services),
193
+			$config->get('WBQualityConstraintsTypeConstraintId')
194
+				=> ConstraintCheckerServices::getTypeChecker($services),
195
+			$config->get('WBQualityConstraintsValueTypeConstraintId')
196
+				=> ConstraintCheckerServices::getValueTypeChecker($services),
197
+			$config->get('WBQualityConstraintsSingleValueConstraintId')
198
+				=> ConstraintCheckerServices::getSingleValueChecker($services),
199
+			$config->get('WBQualityConstraintsMultiValueConstraintId')
200
+				=> ConstraintCheckerServices::getMultiValueChecker($services),
201
+			$config->get('WBQualityConstraintsDistinctValuesConstraintId')
202
+				=> ConstraintCheckerServices::getUniqueValueChecker($services),
203
+			$config->get('WBQualityConstraintsFormatConstraintId')
204
+				=> ConstraintCheckerServices::getFormatChecker($services),
205
+			$config->get('WBQualityConstraintsCommonsLinkConstraintId')
206
+				=> ConstraintCheckerServices::getCommonsLinkChecker($services),
207
+			$config->get('WBQualityConstraintsOneOfConstraintId')
208
+				=> ConstraintCheckerServices::getOneOfChecker($services),
209
+			$config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId')
210
+				=> ConstraintCheckerServices::getValueOnlyChecker($services),
211
+			$config->get('WBQualityConstraintsUsedAsReferenceConstraintId')
212
+				=> ConstraintCheckerServices::getReferenceChecker($services),
213
+			$config->get('WBQualityConstraintsNoBoundsConstraintId')
214
+				=> ConstraintCheckerServices::getNoBoundsChecker($services),
215
+			$config->get('WBQualityConstraintsAllowedUnitsConstraintId')
216
+				=> ConstraintCheckerServices::getAllowedUnitsChecker($services),
217
+			$config->get('WBQualityConstraintsSingleBestValueConstraintId')
218
+				=> ConstraintCheckerServices::getSingleBestValueChecker($services),
219
+			$config->get('WBQualityConstraintsAllowedEntityTypesConstraintId')
220
+				=> ConstraintCheckerServices::getEntityTypeChecker($services),
221
+			$config->get('WBQualityConstraintsNoneOfConstraintId')
222
+				=> ConstraintCheckerServices::getNoneOfChecker($services),
223
+			$config->get('WBQualityConstraintsIntegerConstraintId')
224
+				=> ConstraintCheckerServices::getIntegerChecker($services),
225
+			$config->get('WBQualityConstraintsCitationNeededConstraintId')
226
+				=> ConstraintCheckerServices::getCitationNeededChecker($services),
227
+			$config->get('WBQualityConstraintsPropertyScopeConstraintId')
228
+				=> ConstraintCheckerServices::getPropertyScopeChecker($services),
229
+			$config->get('WBQualityConstraintsContemporaryConstraintId')
230
+				=> ConstraintCheckerServices::getContemporaryChecker($services),
231
+			$config->get('WBQualityConstraintsLexemeLanguageConstraintId')
232
+				=> ConstraintCheckerServices::getLexemeLanguageChecker($services),
233
+			$config->get('WBQualityConstraintsLabelInLanguageConstraintId')
234
+				=> ConstraintCheckerServices::getLabelInLanguageChecker($services),
235 235
 		];
236 236
 
237 237
 		return new DelegatingConstraintChecker(
238
-			WikibaseServices::getEntityLookup( $services ),
238
+			WikibaseServices::getEntityLookup($services),
239 239
 			$checkerMap,
240
-			ConstraintsServices::getConstraintLookup( $services ),
241
-			ConstraintsServices::getConstraintParameterParser( $services ),
240
+			ConstraintsServices::getConstraintLookup($services),
241
+			ConstraintsServices::getConstraintParameterParser($services),
242 242
 			$statementGuidParser,
243
-			ConstraintsServices::getLoggingHelper( $services ),
244
-			$config->get( 'WBQualityConstraintsCheckQualifiers' ),
245
-			$config->get( 'WBQualityConstraintsCheckReferences' ),
246
-			$config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' )
243
+			ConstraintsServices::getLoggingHelper($services),
244
+			$config->get('WBQualityConstraintsCheckQualifiers'),
245
+			$config->get('WBQualityConstraintsCheckReferences'),
246
+			$config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers')
247 247
 		);
248 248
 	},
249 249
 
250
-	ConstraintsServices::RESULTS_SOURCE => static function ( MediaWikiServices $services ) {
250
+	ConstraintsServices::RESULTS_SOURCE => static function(MediaWikiServices $services) {
251 251
 		$config = $services->getMainConfig();
252 252
 		$resultsSource = new CheckingResultsSource(
253
-			ConstraintsServices::getDelegatingConstraintChecker( $services )
253
+			ConstraintsServices::getDelegatingConstraintChecker($services)
254 254
 		);
255 255
 
256 256
 		$cacheCheckConstraintsResults = false;
257 257
 
258
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
258
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
259 259
 			$cacheCheckConstraintsResults = true;
260 260
 			// check that we can use getLocalRepoWikiPageMetaDataAccessor()
261 261
 			// TODO we should always be able to cache constraint check results (T244726)
262
-			$entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources();
263
-			$localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName();
262
+			$entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources();
263
+			$localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName();
264 264
 
265
-			foreach ( $entitySources as $entitySource ) {
266
-				if ( $entitySource->getSourceName() !== $localEntitySourceName ) {
267
-					LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning(
268
-						'Cannot cache constraint check results for non-local source: ' .
265
+			foreach ($entitySources as $entitySource) {
266
+				if ($entitySource->getSourceName() !== $localEntitySourceName) {
267
+					LoggerFactory::getInstance('WikibaseQualityConstraints')->warning(
268
+						'Cannot cache constraint check results for non-local source: '.
269 269
 						$entitySource->getSourceName()
270 270
 					);
271 271
 					$cacheCheckConstraintsResults = false;
@@ -274,28 +274,28 @@  discard block
 block discarded – undo
274 274
 			}
275 275
 		}
276 276
 
277
-		if ( $cacheCheckConstraintsResults ) {
277
+		if ($cacheCheckConstraintsResults) {
278 278
 			$possiblyStaleConstraintTypes = [
279
-				$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
280
-				$config->get( 'WBQualityConstraintsTypeConstraintId' ),
281
-				$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
282
-				$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
279
+				$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
280
+				$config->get('WBQualityConstraintsTypeConstraintId'),
281
+				$config->get('WBQualityConstraintsValueTypeConstraintId'),
282
+				$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
283 283
 			];
284
-			$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
284
+			$entityIdParser = WikibaseRepo::getEntityIdParser($services);
285 285
 			$wikiPageEntityMetaDataAccessor = WikibaseRepo::getLocalRepoWikiPageMetaDataAccessor(
286 286
 				$services );
287 287
 
288 288
 			$resultsSource = new CachingResultsSource(
289 289
 				$resultsSource,
290 290
 				ResultsCache::getDefaultInstance(),
291
-				ConstraintsServices::getCheckResultSerializer( $services ),
292
-				ConstraintsServices::getCheckResultDeserializer( $services ),
291
+				ConstraintsServices::getCheckResultSerializer($services),
292
+				ConstraintsServices::getCheckResultDeserializer($services),
293 293
 				$wikiPageEntityMetaDataAccessor,
294 294
 				$entityIdParser,
295
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
295
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
296 296
 				$possiblyStaleConstraintTypes,
297
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ),
298
-				ConstraintsServices::getLoggingHelper( $services )
297
+				$config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'),
298
+				ConstraintsServices::getLoggingHelper($services)
299 299
 			);
300 300
 		}
301 301
 
Please login to merge, or discard this patch.