Completed
Push — master ( fc4b7c...c46c38 )
by
unknown
02:21 queued 11s
created
src/WikibaseQualityConstraintsHooks.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -28,27 +28,27 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @param DatabaseUpdater $updater
30 30
 	 */
31
-	public static function onCreateSchema( DatabaseUpdater $updater ) {
32
-		$dir = dirname( __DIR__ ) . '/sql/';
31
+	public static function onCreateSchema(DatabaseUpdater $updater) {
32
+		$dir = dirname(__DIR__).'/sql/';
33 33
 
34 34
 		$updater->addExtensionTable(
35 35
 			'wbqc_constraints',
36
-			$dir . "/{$updater->getDB()->getType()}/tables-generated.sql"
36
+			$dir."/{$updater->getDB()->getType()}/tables-generated.sql"
37 37
 		);
38 38
 		$updater->addExtensionField(
39 39
 			'wbqc_constraints',
40 40
 			'constraint_id',
41
-			$dir . '/patch-wbqc_constraints-constraint_id.sql'
41
+			$dir.'/patch-wbqc_constraints-constraint_id.sql'
42 42
 		);
43 43
 		$updater->addExtensionIndex(
44 44
 			'wbqc_constraints',
45 45
 			'wbqc_constraints_guid_uniq',
46
-			$dir . '/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql'
46
+			$dir.'/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql'
47 47
 		);
48 48
 	}
49 49
 
50
-	public static function onWikibaseChange( Change $change ) {
51
-		if ( !( $change instanceof EntityChange ) ) {
50
+	public static function onWikibaseChange(Change $change) {
51
+		if (!($change instanceof EntityChange)) {
52 52
 			return;
53 53
 		}
54 54
 
@@ -57,48 +57,48 @@  discard block
 block discarded – undo
57 57
 
58 58
 		// If jobs are enabled and the results would be stored in some way run a job.
59 59
 		if (
60
-			$config->get( 'WBQualityConstraintsEnableConstraintsCheckJobs' ) &&
61
-			$config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) &&
60
+			$config->get('WBQualityConstraintsEnableConstraintsCheckJobs') &&
61
+			$config->get('WBQualityConstraintsCacheCheckConstraintsResults') &&
62 62
 			self::isSelectedForJobRunBasedOnPercentage()
63 63
 		) {
64
-			$params = [ 'entityId' => $change->getEntityId()->getSerialization() ];
64
+			$params = ['entityId' => $change->getEntityId()->getSerialization()];
65 65
 			JobQueueGroup::singleton()->lazyPush(
66
-				new JobSpecification( CheckConstraintsJob::COMMAND, $params )
66
+				new JobSpecification(CheckConstraintsJob::COMMAND, $params)
67 67
 			);
68 68
 		}
69 69
 
70
-		if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) &&
71
-			self::isConstraintStatementsChange( $config, $change )
70
+		if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') &&
71
+			self::isConstraintStatementsChange($config, $change)
72 72
 		) {
73
-			$params = [ 'propertyId' => $change->getEntityId()->getSerialization() ];
73
+			$params = ['propertyId' => $change->getEntityId()->getSerialization()];
74 74
 			$metadata = $change->getMetadata();
75
-			if ( array_key_exists( 'rev_id', $metadata ) ) {
75
+			if (array_key_exists('rev_id', $metadata)) {
76 76
 				$params['revisionId'] = $metadata['rev_id'];
77 77
 			}
78 78
 			JobQueueGroup::singleton()->push(
79
-				new JobSpecification( 'constraintsTableUpdate', $params )
79
+				new JobSpecification('constraintsTableUpdate', $params)
80 80
 			);
81 81
 		}
82 82
 	}
83 83
 
84 84
 	private static function isSelectedForJobRunBasedOnPercentage() {
85 85
 		$config = MediaWikiServices::getInstance()->getMainConfig();
86
-		$percentage = $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobsRatio' );
86
+		$percentage = $config->get('WBQualityConstraintsEnableConstraintsCheckJobsRatio');
87 87
 
88
-		return mt_rand( 1, 100 ) <= $percentage;
88
+		return mt_rand(1, 100) <= $percentage;
89 89
 	}
90 90
 
91
-	public static function isConstraintStatementsChange( Config $config, Change $change ) {
92
-		if ( !( $change instanceof EntityChange ) ||
91
+	public static function isConstraintStatementsChange(Config $config, Change $change) {
92
+		if (!($change instanceof EntityChange) ||
93 93
 			 $change->getAction() !== EntityChange::UPDATE ||
94
-			 !( $change->getEntityId() instanceof PropertyId )
94
+			 !($change->getEntityId() instanceof PropertyId)
95 95
 		) {
96 96
 			return false;
97 97
 		}
98 98
 
99 99
 		$info = $change->getInfo();
100 100
 
101
-		if ( !array_key_exists( 'compactDiff', $info ) ) {
101
+		if (!array_key_exists('compactDiff', $info)) {
102 102
 			// the non-compact diff ($info['diff']) does not contain statement diffs (T110996),
103 103
 			// so we only know that the change *might* affect the constraint statements
104 104
 			return true;
@@ -107,45 +107,45 @@  discard block
 block discarded – undo
107 107
 		/** @var EntityDiffChangedAspects $aspects */
108 108
 		$aspects = $info['compactDiff'];
109 109
 
110
-		$propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' );
111
-		return in_array( $propertyConstraintId, $aspects->getStatementChanges() );
110
+		$propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId');
111
+		return in_array($propertyConstraintId, $aspects->getStatementChanges());
112 112
 	}
113 113
 
114
-	public static function onArticlePurge( WikiPage $wikiPage ) {
114
+	public static function onArticlePurge(WikiPage $wikiPage) {
115 115
 		$entityContentFactory = WikibaseRepo::getEntityContentFactory();
116
-		if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) {
116
+		if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) {
117 117
 			$entityIdLookup = WikibaseRepo::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()->isRegistered() ) {
144
+		if (!$out->getUser()->isRegistered()) {
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/Api/CheckConstraints.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -86,13 +86,13 @@  discard block
 block discarded – undo
86 86
 
87 87
 		$language = $repo->getUserLanguage();
88 88
 		$formatterOptions = new FormatterOptions();
89
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
90
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
89
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
90
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
91 91
 
92 92
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
93
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language );
93
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language);
94 94
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
95
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language );
95
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language);
96 96
 
97 97
 		$checkResultsRenderer = new CheckResultsRenderer(
98 98
 			$entityTitleLookup,
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 			$name,
111 111
 			$entityIdParser,
112 112
 			$statementGuidValidator,
113
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
113
+			$repo->getApiHelperFactory(RequestContext::getMain()),
114 114
 			$resultsSource,
115 115
 			$checkResultsRenderer,
116 116
 			$dataFactory
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 		CheckResultsRenderer $checkResultsRenderer,
138 138
 		IBufferingStatsdDataFactory $dataFactory
139 139
 	) {
140
-		parent::__construct( $main, $name );
140
+		parent::__construct($main, $name);
141 141
 		$this->entityIdParser = $entityIdParser;
142 142
 		$this->statementGuidValidator = $statementGuidValidator;
143
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
144
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
143
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
144
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
145 145
 		$this->resultsSource = $resultsSource;
146 146
 		$this->checkResultsRenderer = $checkResultsRenderer;
147 147
 		$this->dataFactory = $dataFactory;
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
 
158 158
 		$params = $this->extractRequestParams();
159 159
 
160
-		$this->validateParameters( $params );
161
-		$entityIds = $this->parseEntityIds( $params );
162
-		$claimIds = $this->parseClaimIds( $params );
160
+		$this->validateParameters($params);
161
+		$entityIds = $this->parseEntityIds($params);
162
+		$claimIds = $this->parseClaimIds($params);
163 163
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
164 164
 		$statuses = $params[self::PARAM_STATUS];
165 165
 
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 				)
176 176
 			)->getArray()
177 177
 		);
178
-		$this->resultBuilder->markSuccess( 1 );
178
+		$this->resultBuilder->markSuccess(1);
179 179
 	}
180 180
 
181 181
 	/**
@@ -183,24 +183,24 @@  discard block
 block discarded – undo
183 183
 	 *
184 184
 	 * @return EntityId[]
185 185
 	 */
186
-	private function parseEntityIds( array $params ) {
186
+	private function parseEntityIds(array $params) {
187 187
 		$ids = $params[self::PARAM_ID];
188 188
 
189
-		if ( $ids === null ) {
189
+		if ($ids === null) {
190 190
 			return [];
191
-		} elseif ( $ids === [] ) {
191
+		} elseif ($ids === []) {
192 192
 			$this->errorReporter->dieError(
193
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
193
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
194 194
 		}
195 195
 
196
-		return array_map( function ( $id ) {
196
+		return array_map(function($id) {
197 197
 			try {
198
-				return $this->entityIdParser->parse( $id );
199
-			} catch ( EntityIdParsingException $e ) {
198
+				return $this->entityIdParser->parse($id);
199
+			} catch (EntityIdParsingException $e) {
200 200
 				$this->errorReporter->dieError(
201
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
201
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
202 202
 			}
203
-		}, $ids );
203
+		}, $ids);
204 204
 	}
205 205
 
206 206
 	/**
@@ -208,35 +208,35 @@  discard block
 block discarded – undo
208 208
 	 *
209 209
 	 * @return string[]
210 210
 	 */
211
-	private function parseClaimIds( array $params ) {
211
+	private function parseClaimIds(array $params) {
212 212
 		$ids = $params[self::PARAM_CLAIM_ID];
213 213
 
214
-		if ( $ids === null ) {
214
+		if ($ids === null) {
215 215
 			return [];
216
-		} elseif ( $ids === [] ) {
216
+		} elseif ($ids === []) {
217 217
 			$this->errorReporter->dieError(
218
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
218
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
219 219
 		}
220 220
 
221
-		foreach ( $ids as $id ) {
222
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
221
+		foreach ($ids as $id) {
222
+			if (!$this->statementGuidValidator->validate($id)) {
223 223
 				$this->errorReporter->dieError(
224
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
224
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
225 225
 			}
226 226
 		}
227 227
 
228 228
 		return $ids;
229 229
 	}
230 230
 
231
-	private function validateParameters( array $params ) {
232
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
233
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
231
+	private function validateParameters(array $params) {
232
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
233
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
234 234
 		) {
235 235
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
236 236
 			$this->errorReporter->dieError(
237 237
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
238 238
 		}
239
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
239
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
240 240
 			$paramId = self::PARAM_ID;
241 241
 			$paramClaimId = self::PARAM_CLAIM_ID;
242 242
 			$this->errorReporter->dieError(
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 				],
278 278
 				ApiBase::PARAM_ISMULTI => true,
279 279
 				ApiBase::PARAM_ALL => true,
280
-				ApiBase::PARAM_DFLT => implode( '|', CachingResultsSource::CACHED_STATUSES ),
280
+				ApiBase::PARAM_DFLT => implode('|', CachingResultsSource::CACHED_STATUSES),
281 281
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
282 282
 			],
283 283
 		];
Please login to merge, or discard this patch.
src/Job/UpdateConstraintsTableJob.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	private const BATCH_SIZE = 50;
40 40
 
41
-	public static function newFromGlobalState( Title $title, array $params ) {
42
-		Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' );
41
+	public static function newFromGlobalState(Title $title, array $params) {
42
+		Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]');
43 43
 		$services = MediaWikiServices::getInstance();
44 44
 		$repo = WikibaseRepo::getDefaultInstance();
45 45
 		return new UpdateConstraintsTableJob(
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 			$services->getMainConfig(),
51 51
 			ConstraintsServices::getConstraintStore(),
52 52
 			$services->getDBLoadBalancerFactory(),
53
-			$repo->getEntityRevisionLookup( Store::LOOKUP_CACHING_DISABLED ),
54
-			WikibaseRepo::getBaseDataModelSerializerFactory( $services )
53
+			$repo->getEntityRevisionLookup(Store::LOOKUP_CACHING_DISABLED),
54
+			WikibaseRepo::getBaseDataModelSerializerFactory($services)
55 55
 				->newSnakSerializer()
56 56
 		);
57 57
 	}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		EntityRevisionLookup $entityRevisionLookup,
112 112
 		Serializer $snakSerializer
113 113
 	) {
114
-		parent::__construct( 'constraintsTableUpdate', $title, $params );
114
+		parent::__construct('constraintsTableUpdate', $title, $params);
115 115
 
116 116
 		$this->propertyId = $propertyId;
117 117
 		$this->revisionId = $revisionId;
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 		$this->snakSerializer = $snakSerializer;
123 123
 	}
124 124
 
125
-	public function extractParametersFromQualifiers( SnakList $qualifiers ) {
125
+	public function extractParametersFromQualifiers(SnakList $qualifiers) {
126 126
 		$parameters = [];
127
-		foreach ( $qualifiers as $qualifier ) {
127
+		foreach ($qualifiers as $qualifier) {
128 128
 			$qualifierId = $qualifier->getPropertyId()->getSerialization();
129
-			$paramSerialization = $this->snakSerializer->serialize( $qualifier );
129
+			$paramSerialization = $this->snakSerializer->serialize($qualifier);
130 130
 			$parameters[$qualifierId][] = $paramSerialization;
131 131
 		}
132 132
 		return $parameters;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		'@phan-var \Wikibase\DataModel\Entity\EntityIdValue $dataValue';
144 144
 		$entityId = $dataValue->getEntityId();
145 145
 		$constraintTypeQid = $entityId->getSerialization();
146
-		$parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() );
146
+		$parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers());
147 147
 		return new Constraint(
148 148
 			$constraintId,
149 149
 			$propertyId,
@@ -158,24 +158,24 @@  discard block
 block discarded – undo
158 158
 		PropertyId $propertyConstraintPropertyId
159 159
 	) {
160 160
 		$constraintsStatements = $property->getStatements()
161
-			->getByPropertyId( $propertyConstraintPropertyId )
162
-			->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] );
161
+			->getByPropertyId($propertyConstraintPropertyId)
162
+			->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]);
163 163
 		$constraints = [];
164
-		foreach ( $constraintsStatements->getIterator() as $constraintStatement ) {
165
-			$constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement );
166
-			if ( count( $constraints ) >= self::BATCH_SIZE ) {
167
-				$constraintStore->insertBatch( $constraints );
164
+		foreach ($constraintsStatements->getIterator() as $constraintStatement) {
165
+			$constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement);
166
+			if (count($constraints) >= self::BATCH_SIZE) {
167
+				$constraintStore->insertBatch($constraints);
168 168
 				// interrupt transaction and wait for replication
169
-				$connection = $this->lbFactory->getMainLB()->getConnection( DB_MASTER );
170
-				$connection->endAtomic( __CLASS__ );
171
-				if ( !$connection->explicitTrxActive() ) {
169
+				$connection = $this->lbFactory->getMainLB()->getConnection(DB_MASTER);
170
+				$connection->endAtomic(__CLASS__);
171
+				if (!$connection->explicitTrxActive()) {
172 172
 					$this->lbFactory->waitForReplication();
173 173
 				}
174
-				$connection->startAtomic( __CLASS__ );
174
+				$connection->startAtomic(__CLASS__);
175 175
 				$constraints = [];
176 176
 			}
177 177
 		}
178
-		$constraintStore->insertBatch( $constraints );
178
+		$constraintStore->insertBatch($constraints);
179 179
 	}
180 180
 
181 181
 	/**
@@ -186,24 +186,24 @@  discard block
 block discarded – undo
186 186
 	public function run() {
187 187
 		// TODO in the future: only touch constraints affected by the edit (requires T163465)
188 188
 
189
-		$propertyId = new PropertyId( $this->propertyId );
189
+		$propertyId = new PropertyId($this->propertyId);
190 190
 		$propertyRevision = $this->entityRevisionLookup->getEntityRevision(
191 191
 			$propertyId,
192 192
 			0, // latest
193 193
 			LookupConstants::LATEST_FROM_REPLICA
194 194
 		);
195 195
 
196
-		if ( $this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId ) {
197
-			JobQueueGroup::singleton()->push( $this );
196
+		if ($this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId) {
197
+			JobQueueGroup::singleton()->push($this);
198 198
 			return true;
199 199
 		}
200 200
 
201
-		$connection = $this->lbFactory->getMainLB()->getConnection( DB_MASTER );
201
+		$connection = $this->lbFactory->getMainLB()->getConnection(DB_MASTER);
202 202
 		// start transaction (if not started yet) – using __CLASS__, not __METHOD__,
203 203
 		// because importConstraintsForProperty() can interrupt the transaction
204
-		$connection->startAtomic( __CLASS__ );
204
+		$connection->startAtomic(__CLASS__);
205 205
 
206
-		$this->constraintStore->deleteForProperty( $propertyId );
206
+		$this->constraintStore->deleteForProperty($propertyId);
207 207
 
208 208
 		/** @var Property $property */
209 209
 		$property = $propertyRevision->getEntity();
@@ -211,10 +211,10 @@  discard block
 block discarded – undo
211 211
 		$this->importConstraintsForProperty(
212 212
 			$property,
213 213
 			$this->constraintStore,
214
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) )
214
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId'))
215 215
 		);
216 216
 
217
-		$connection->endAtomic( __CLASS__ );
217
+		$connection->endAtomic(__CLASS__);
218 218
 
219 219
 		return true;
220 220
 	}
Please login to merge, or discard this patch.
maintenance/ImportConstraintEntities.php 1 patch
Spacing   +57 added lines, -57 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
 	/**
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 	private function setupServices() {
82 82
 		$services = MediaWikiServices::getInstance();
83 83
 		$repo = WikibaseRepo::getDefaultInstance();
84
-		$this->entitySerializer = WikibaseRepo::getAllTypesEntitySerializer( $services );
84
+		$this->entitySerializer = WikibaseRepo::getAllTypesEntitySerializer($services);
85 85
 		$this->entityDeserializer = $repo->getInternalFormatEntityDeserializer();
86 86
 		$this->entityStore = $repo->getEntityStore();
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( wfWikiID(), 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(wfWikiID(), 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   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -28,46 +28,46 @@  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_STORE => function ( MediaWikiServices $services ) {
44
-		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services );
45
-		$propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE );
43
+	ConstraintsServices::CONSTRAINT_STORE => function(MediaWikiServices $services) {
44
+		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services);
45
+		$propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE);
46 46
 		$dbName = $propertySource->getDatabaseName();
47
-		$localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName();
47
+		$localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName();
48 48
 
49
-		if ( $propertySource->getSourceName() !== $localEntitySourceName ) {
50
-			throw new \RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' );
49
+		if ($propertySource->getSourceName() !== $localEntitySourceName) {
50
+			throw new \RuntimeException('Can\'t get a ConstraintStore for a non local entity source.');
51 51
 		}
52 52
 
53 53
 		return new ConstraintRepositoryStore(
54
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
54
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
55 55
 			$dbName
56 56
 		);
57 57
 	},
58 58
 
59
-	ConstraintsServices::CONSTRAINT_LOOKUP => function ( MediaWikiServices $services ) {
60
-		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services );
61
-		$propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE );
59
+	ConstraintsServices::CONSTRAINT_LOOKUP => function(MediaWikiServices $services) {
60
+		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services);
61
+		$propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE);
62 62
 		$dbName = $propertySource->getDatabaseName();
63 63
 		$rawLookup = new ConstraintRepositoryLookup(
64
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
64
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
65 65
 			$dbName
66 66
 		);
67
-		return new CachingConstraintLookup( $rawLookup );
67
+		return new CachingConstraintLookup($rawLookup);
68 68
 	},
69 69
 
70
-	ConstraintsServices::CHECK_RESULT_SERIALIZER => function ( MediaWikiServices $services ) {
70
+	ConstraintsServices::CHECK_RESULT_SERIALIZER => function(MediaWikiServices $services) {
71 71
 		return new CheckResultSerializer(
72 72
 			new ConstraintSerializer(
73 73
 				false // constraint parameters are not exposed
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 		);
79 79
 	},
80 80
 
81
-	ConstraintsServices::CHECK_RESULT_DESERIALIZER => function ( MediaWikiServices $services ) {
82
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
83
-		$dataValueFactory = WikibaseRepo::getDataValueFactory( $services );
81
+	ConstraintsServices::CHECK_RESULT_DESERIALIZER => function(MediaWikiServices $services) {
82
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
83
+		$dataValueFactory = WikibaseRepo::getDataValueFactory($services);
84 84
 
85 85
 		return new CheckResultDeserializer(
86 86
 			new ConstraintDeserializer(),
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 		);
94 94
 	},
95 95
 
96
-	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function ( MediaWikiServices $services ) {
96
+	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function(MediaWikiServices $services) {
97 97
 		return new ViolationMessageSerializer();
98 98
 	},
99 99
 
100
-	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function ( MediaWikiServices $services ) {
101
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
102
-		$dataValueFactory = WikibaseRepo::getDataValueFactory( $services );
100
+	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function(MediaWikiServices $services) {
101
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
102
+		$dataValueFactory = WikibaseRepo::getDataValueFactory($services);
103 103
 
104 104
 		return new ViolationMessageDeserializer(
105 105
 			$entityIdParser,
@@ -107,22 +107,22 @@  discard block
 block discarded – undo
107 107
 		);
108 108
 	},
109 109
 
110
-	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function ( MediaWikiServices $services ) {
111
-		$deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory( $services );
112
-		$entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services );
110
+	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) {
111
+		$deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory($services);
112
+		$entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services);
113 113
 
114 114
 		return new ConstraintParameterParser(
115 115
 			$services->getMainConfig(),
116 116
 			$deserializerFactory,
117
-			$entitySourceDefinitions->getSourceForEntityType( 'item' )->getConceptBaseUri()
117
+			$entitySourceDefinitions->getSourceForEntityType('item')->getConceptBaseUri()
118 118
 		);
119 119
 	},
120 120
 
121
-	ConstraintsServices::CONNECTION_CHECKER_HELPER => function ( MediaWikiServices $services ) {
121
+	ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) {
122 122
 		return new ConnectionCheckerHelper();
123 123
 	},
124 124
 
125
-	ConstraintsServices::RANGE_CHECKER_HELPER => function ( MediaWikiServices $services ) {
125
+	ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) {
126 126
 		// TODO in the future, get UnitConverter from $services?
127 127
 		$repo = WikibaseRepo::getDefaultInstance();
128 128
 		$unitConverter = $repo->getUnitConverter();
@@ -133,16 +133,16 @@  discard block
 block discarded – undo
133 133
 		);
134 134
 	},
135 135
 
136
-	ConstraintsServices::SPARQL_HELPER => function ( MediaWikiServices $services ) {
137
-		$endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' );
138
-		if ( $endpoint === '' ) {
136
+	ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) {
137
+		$endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint');
138
+		if ($endpoint === '') {
139 139
 			return new DummySparqlHelper();
140 140
 		}
141 141
 
142 142
 		// TODO get PropertyDataTypeLookup from $services
143 143
 		$repo = WikibaseRepo::getDefaultInstance();
144
-		$rdfVocabulary = WikibaseRepo::getRdfVocabulary( $services );
145
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
144
+		$rdfVocabulary = WikibaseRepo::getRdfVocabulary($services);
145
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
146 146
 		$propertyDataTypeLookup = $repo->getPropertyDataTypeLookup();
147 147
 
148 148
 		return new SparqlHelper(
@@ -151,122 +151,122 @@  discard block
 block discarded – undo
151 151
 			$entityIdParser,
152 152
 			$propertyDataTypeLookup,
153 153
 			$services->getMainWANObjectCache(),
154
-			ConstraintsServices::getViolationMessageSerializer( $services ),
155
-			ConstraintsServices::getViolationMessageDeserializer( $services ),
154
+			ConstraintsServices::getViolationMessageSerializer($services),
155
+			ConstraintsServices::getViolationMessageDeserializer($services),
156 156
 			$services->getStatsdDataFactory(),
157
-			ConstraintsServices::getExpiryLock( $services ),
157
+			ConstraintsServices::getExpiryLock($services),
158 158
 			ConstraintsServices::getLoggingHelper(),
159
-			wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(),
159
+			wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(),
160 160
 			$services->getHttpRequestFactory()
161 161
 		);
162 162
 	},
163 163
 
164
-	ConstraintsServices::TYPE_CHECKER_HELPER => function ( MediaWikiServices $services ) {
164
+	ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) {
165 165
 		return new TypeCheckerHelper(
166
-			WikibaseServices::getEntityLookup( $services ),
166
+			WikibaseServices::getEntityLookup($services),
167 167
 			$services->getMainConfig(),
168
-			ConstraintsServices::getSparqlHelper( $services ),
168
+			ConstraintsServices::getSparqlHelper($services),
169 169
 			$services->getStatsdDataFactory()
170 170
 		);
171 171
 	},
172 172
 
173
-	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function ( MediaWikiServices $services ) {
174
-		$statementGuidParser = WikibaseRepo::getStatementGuidParser( $services );
173
+	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) {
174
+		$statementGuidParser = WikibaseRepo::getStatementGuidParser($services);
175 175
 
176 176
 		$config = $services->getMainConfig();
177 177
 		$checkerMap = [
178
-			$config->get( 'WBQualityConstraintsConflictsWithConstraintId' )
179
-				=> ConstraintCheckerServices::getConflictsWithChecker( $services ),
180
-			$config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' )
181
-				=> ConstraintCheckerServices::getItemChecker( $services ),
182
-			$config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' )
183
-				=> ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ),
184
-			$config->get( 'WBQualityConstraintsSymmetricConstraintId' )
185
-				=> ConstraintCheckerServices::getSymmetricChecker( $services ),
186
-			$config->get( 'WBQualityConstraintsInverseConstraintId' )
187
-				=> ConstraintCheckerServices::getInverseChecker( $services ),
188
-			$config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' )
189
-				=> ConstraintCheckerServices::getQualifierChecker( $services ),
190
-			$config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' )
191
-				=> ConstraintCheckerServices::getQualifiersChecker( $services ),
192
-			$config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' )
193
-				=> ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ),
194
-			$config->get( 'WBQualityConstraintsRangeConstraintId' )
195
-				=> ConstraintCheckerServices::getRangeChecker( $services ),
196
-			$config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' )
197
-				=> ConstraintCheckerServices::getDiffWithinRangeChecker( $services ),
198
-			$config->get( 'WBQualityConstraintsTypeConstraintId' )
199
-				=> ConstraintCheckerServices::getTypeChecker( $services ),
200
-			$config->get( 'WBQualityConstraintsValueTypeConstraintId' )
201
-				=> ConstraintCheckerServices::getValueTypeChecker( $services ),
202
-			$config->get( 'WBQualityConstraintsSingleValueConstraintId' )
203
-				=> ConstraintCheckerServices::getSingleValueChecker( $services ),
204
-			$config->get( 'WBQualityConstraintsMultiValueConstraintId' )
205
-				=> ConstraintCheckerServices::getMultiValueChecker( $services ),
206
-			$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' )
207
-				=> ConstraintCheckerServices::getUniqueValueChecker( $services ),
208
-			$config->get( 'WBQualityConstraintsFormatConstraintId' )
209
-				=> ConstraintCheckerServices::getFormatChecker( $services ),
210
-			$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' )
211
-				=> ConstraintCheckerServices::getCommonsLinkChecker( $services ),
212
-			$config->get( 'WBQualityConstraintsOneOfConstraintId' )
213
-				=> ConstraintCheckerServices::getOneOfChecker( $services ),
214
-			$config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' )
215
-				=> ConstraintCheckerServices::getValueOnlyChecker( $services ),
216
-			$config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' )
217
-				=> ConstraintCheckerServices::getReferenceChecker( $services ),
218
-			$config->get( 'WBQualityConstraintsNoBoundsConstraintId' )
219
-				=> ConstraintCheckerServices::getNoBoundsChecker( $services ),
220
-			$config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' )
221
-				=> ConstraintCheckerServices::getAllowedUnitsChecker( $services ),
222
-			$config->get( 'WBQualityConstraintsSingleBestValueConstraintId' )
223
-				=> ConstraintCheckerServices::getSingleBestValueChecker( $services ),
224
-			$config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' )
225
-				=> ConstraintCheckerServices::getEntityTypeChecker( $services ),
226
-			$config->get( 'WBQualityConstraintsNoneOfConstraintId' )
227
-				=> ConstraintCheckerServices::getNoneOfChecker( $services ),
228
-			$config->get( 'WBQualityConstraintsIntegerConstraintId' )
229
-				=> ConstraintCheckerServices::getIntegerChecker( $services ),
230
-			$config->get( 'WBQualityConstraintsCitationNeededConstraintId' )
231
-				=> ConstraintCheckerServices::getCitationNeededChecker( $services ),
232
-			$config->get( 'WBQualityConstraintsPropertyScopeConstraintId' )
233
-				=> ConstraintCheckerServices::getPropertyScopeChecker( $services ),
234
-			$config->get( 'WBQualityConstraintsContemporaryConstraintId' )
235
-				=> ConstraintCheckerServices::getContemporaryChecker( $services ),
178
+			$config->get('WBQualityConstraintsConflictsWithConstraintId')
179
+				=> ConstraintCheckerServices::getConflictsWithChecker($services),
180
+			$config->get('WBQualityConstraintsItemRequiresClaimConstraintId')
181
+				=> ConstraintCheckerServices::getItemChecker($services),
182
+			$config->get('WBQualityConstraintsValueRequiresClaimConstraintId')
183
+				=> ConstraintCheckerServices::getTargetRequiredClaimChecker($services),
184
+			$config->get('WBQualityConstraintsSymmetricConstraintId')
185
+				=> ConstraintCheckerServices::getSymmetricChecker($services),
186
+			$config->get('WBQualityConstraintsInverseConstraintId')
187
+				=> ConstraintCheckerServices::getInverseChecker($services),
188
+			$config->get('WBQualityConstraintsUsedAsQualifierConstraintId')
189
+				=> ConstraintCheckerServices::getQualifierChecker($services),
190
+			$config->get('WBQualityConstraintsAllowedQualifiersConstraintId')
191
+				=> ConstraintCheckerServices::getQualifiersChecker($services),
192
+			$config->get('WBQualityConstraintsMandatoryQualifierConstraintId')
193
+				=> ConstraintCheckerServices::getMandatoryQualifiersChecker($services),
194
+			$config->get('WBQualityConstraintsRangeConstraintId')
195
+				=> ConstraintCheckerServices::getRangeChecker($services),
196
+			$config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId')
197
+				=> ConstraintCheckerServices::getDiffWithinRangeChecker($services),
198
+			$config->get('WBQualityConstraintsTypeConstraintId')
199
+				=> ConstraintCheckerServices::getTypeChecker($services),
200
+			$config->get('WBQualityConstraintsValueTypeConstraintId')
201
+				=> ConstraintCheckerServices::getValueTypeChecker($services),
202
+			$config->get('WBQualityConstraintsSingleValueConstraintId')
203
+				=> ConstraintCheckerServices::getSingleValueChecker($services),
204
+			$config->get('WBQualityConstraintsMultiValueConstraintId')
205
+				=> ConstraintCheckerServices::getMultiValueChecker($services),
206
+			$config->get('WBQualityConstraintsDistinctValuesConstraintId')
207
+				=> ConstraintCheckerServices::getUniqueValueChecker($services),
208
+			$config->get('WBQualityConstraintsFormatConstraintId')
209
+				=> ConstraintCheckerServices::getFormatChecker($services),
210
+			$config->get('WBQualityConstraintsCommonsLinkConstraintId')
211
+				=> ConstraintCheckerServices::getCommonsLinkChecker($services),
212
+			$config->get('WBQualityConstraintsOneOfConstraintId')
213
+				=> ConstraintCheckerServices::getOneOfChecker($services),
214
+			$config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId')
215
+				=> ConstraintCheckerServices::getValueOnlyChecker($services),
216
+			$config->get('WBQualityConstraintsUsedAsReferenceConstraintId')
217
+				=> ConstraintCheckerServices::getReferenceChecker($services),
218
+			$config->get('WBQualityConstraintsNoBoundsConstraintId')
219
+				=> ConstraintCheckerServices::getNoBoundsChecker($services),
220
+			$config->get('WBQualityConstraintsAllowedUnitsConstraintId')
221
+				=> ConstraintCheckerServices::getAllowedUnitsChecker($services),
222
+			$config->get('WBQualityConstraintsSingleBestValueConstraintId')
223
+				=> ConstraintCheckerServices::getSingleBestValueChecker($services),
224
+			$config->get('WBQualityConstraintsAllowedEntityTypesConstraintId')
225
+				=> ConstraintCheckerServices::getEntityTypeChecker($services),
226
+			$config->get('WBQualityConstraintsNoneOfConstraintId')
227
+				=> ConstraintCheckerServices::getNoneOfChecker($services),
228
+			$config->get('WBQualityConstraintsIntegerConstraintId')
229
+				=> ConstraintCheckerServices::getIntegerChecker($services),
230
+			$config->get('WBQualityConstraintsCitationNeededConstraintId')
231
+				=> ConstraintCheckerServices::getCitationNeededChecker($services),
232
+			$config->get('WBQualityConstraintsPropertyScopeConstraintId')
233
+				=> ConstraintCheckerServices::getPropertyScopeChecker($services),
234
+			$config->get('WBQualityConstraintsContemporaryConstraintId')
235
+				=> ConstraintCheckerServices::getContemporaryChecker($services),
236 236
 		];
237 237
 
238 238
 		return new DelegatingConstraintChecker(
239
-			WikibaseServices::getEntityLookup( $services ),
239
+			WikibaseServices::getEntityLookup($services),
240 240
 			$checkerMap,
241
-			ConstraintsServices::getConstraintLookup( $services ),
242
-			ConstraintsServices::getConstraintParameterParser( $services ),
241
+			ConstraintsServices::getConstraintLookup($services),
242
+			ConstraintsServices::getConstraintParameterParser($services),
243 243
 			$statementGuidParser,
244
-			ConstraintsServices::getLoggingHelper( $services ),
245
-			$config->get( 'WBQualityConstraintsCheckQualifiers' ),
246
-			$config->get( 'WBQualityConstraintsCheckReferences' ),
247
-			$config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' )
244
+			ConstraintsServices::getLoggingHelper($services),
245
+			$config->get('WBQualityConstraintsCheckQualifiers'),
246
+			$config->get('WBQualityConstraintsCheckReferences'),
247
+			$config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers')
248 248
 		);
249 249
 	},
250 250
 
251
-	ConstraintsServices::RESULTS_SOURCE => function ( MediaWikiServices $services ) {
251
+	ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) {
252 252
 		$config = $services->getMainConfig();
253 253
 		$resultsSource = new CheckingResultsSource(
254
-			ConstraintsServices::getDelegatingConstraintChecker( $services )
254
+			ConstraintsServices::getDelegatingConstraintChecker($services)
255 255
 		);
256 256
 
257 257
 		$cacheCheckConstraintsResults = false;
258 258
 
259
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
259
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
260 260
 			$cacheCheckConstraintsResults = true;
261 261
 			// check that we can use getLocalRepoWikiPageMetaDataAccessor()
262 262
 			// TODO we should always be able to cache constraint check results (T244726)
263
-			$entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources();
264
-			$localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName();
263
+			$entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources();
264
+			$localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName();
265 265
 
266
-			foreach ( $entitySources as $entitySource ) {
267
-				if ( $entitySource->getSourceName() !== $localEntitySourceName ) {
268
-					LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning(
269
-						'Cannot cache constraint check results for non-local source: ' .
266
+			foreach ($entitySources as $entitySource) {
267
+				if ($entitySource->getSourceName() !== $localEntitySourceName) {
268
+					LoggerFactory::getInstance('WikibaseQualityConstraints')->warning(
269
+						'Cannot cache constraint check results for non-local source: '.
270 270
 						$entitySource->getSourceName()
271 271
 					);
272 272
 					$cacheCheckConstraintsResults = false;
@@ -275,29 +275,29 @@  discard block
 block discarded – undo
275 275
 			}
276 276
 		}
277 277
 
278
-		if ( $cacheCheckConstraintsResults ) {
278
+		if ($cacheCheckConstraintsResults) {
279 279
 			$possiblyStaleConstraintTypes = [
280
-				$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
281
-				$config->get( 'WBQualityConstraintsTypeConstraintId' ),
282
-				$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
283
-				$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
280
+				$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
281
+				$config->get('WBQualityConstraintsTypeConstraintId'),
282
+				$config->get('WBQualityConstraintsValueTypeConstraintId'),
283
+				$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
284 284
 			];
285 285
 			// TODO in the future, get WikiPageEntityMetaDataAccessor from $services?
286 286
 			$repo = WikibaseRepo::getDefaultInstance();
287
-			$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
287
+			$entityIdParser = WikibaseRepo::getEntityIdParser($services);
288 288
 			$wikiPageEntityMetaDataAccessor = $repo->getLocalRepoWikiPageMetaDataAccessor();
289 289
 
290 290
 			$resultsSource = new CachingResultsSource(
291 291
 				$resultsSource,
292 292
 				ResultsCache::getDefaultInstance(),
293
-				ConstraintsServices::getCheckResultSerializer( $services ),
294
-				ConstraintsServices::getCheckResultDeserializer( $services ),
293
+				ConstraintsServices::getCheckResultSerializer($services),
294
+				ConstraintsServices::getCheckResultDeserializer($services),
295 295
 				$wikiPageEntityMetaDataAccessor,
296 296
 				$entityIdParser,
297
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
297
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
298 298
 				$possiblyStaleConstraintTypes,
299
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ),
300
-				ConstraintsServices::getLoggingHelper( $services )
299
+				$config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'),
300
+				ConstraintsServices::getLoggingHelper($services)
301 301
 			);
302 302
 		}
303 303
 
Please login to merge, or discard this patch.