Completed
Push — master ( 1dc4ce...b37983 )
by
unknown
21s
created
src/ConstraintCheck/Helper/LoggingHelper.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 		$this->dataFactory = $dataFactory;
54 54
 		$this->logger = $logger;
55 55
 		$this->constraintCheckDurationLimits = [
56
-			'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ),
57
-			'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ),
56
+			'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'),
57
+			'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'),
58 58
 		];
59 59
 		$this->constraintCheckOnEntityDurationLimits = [
60
-			'info' => $config->get( 'WBQualityConstraintsCheckOnEntityDurationInfoSeconds' ),
61
-			'warning' => $config->get( 'WBQualityConstraintsCheckOnEntityDurationWarningSeconds' ),
60
+			'info' => $config->get('WBQualityConstraintsCheckOnEntityDurationInfoSeconds'),
61
+			'warning' => $config->get('WBQualityConstraintsCheckOnEntityDurationWarningSeconds'),
62 62
 		];
63 63
 	}
64 64
 
@@ -69,23 +69,23 @@  discard block
 block discarded – undo
69 69
 	 * @param float $durationSeconds
70 70
 	 * @return array [ $limitSeconds, $logLevel ]
71 71
 	 */
72
-	private function findLimit( $limits, $durationSeconds ) {
72
+	private function findLimit($limits, $durationSeconds) {
73 73
 		$limitSeconds = null;
74 74
 		$logLevel = null;
75 75
 
76
-		foreach ( $limits as $level => $limit ) {
76
+		foreach ($limits as $level => $limit) {
77 77
 			if (
78 78
 				// duration exceeds this limit
79 79
 				$limit !== null && $durationSeconds > $limit &&
80 80
 				// this limit is longer than previous longest limit
81
-				( $limitSeconds === null || $limit > $limitSeconds )
81
+				($limitSeconds === null || $limit > $limitSeconds)
82 82
 			) {
83 83
 				$limitSeconds = $limit;
84 84
 				$logLevel = $level;
85 85
 			}
86 86
 		}
87 87
 
88
-		return [ $limitSeconds, $logLevel ];
88
+		return [$limitSeconds, $logLevel];
89 89
 	}
90 90
 
91 91
 	/**
@@ -110,31 +110,31 @@  discard block
 block discarded – undo
110 110
 		$durationSeconds,
111 111
 		$method
112 112
 	) {
113
-		$constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 );
113
+		$constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1);
114 114
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
115 115
 
116 116
 		$this->dataFactory->timing(
117
-			'wikibase.quality.constraints.check.timing.' .
118
-				$constraintTypeItemId . '-' .
117
+			'wikibase.quality.constraints.check.timing.'.
118
+				$constraintTypeItemId.'-'.
119 119
 				$constraintCheckerClassShortName,
120 120
 			$durationSeconds * 1000
121 121
 		);
122 122
 
123 123
 		// find the longest limit (and associated log level) that the duration exceeds
124
-		[ $limitSeconds, $logLevel ] = $this->findLimit(
124
+		[$limitSeconds, $logLevel] = $this->findLimit(
125 125
 			$this->constraintCheckDurationLimits,
126 126
 			$durationSeconds
127 127
 		);
128
-		if ( $limitSeconds === null ) {
128
+		if ($limitSeconds === null) {
129 129
 			return;
130 130
 		}
131
-		if ( $context->getType() !== Context::TYPE_STATEMENT ) {
131
+		if ($context->getType() !== Context::TYPE_STATEMENT) {
132 132
 			// TODO log less details but still log something
133 133
 			return;
134 134
 		}
135 135
 
136 136
 		$resultMessage = $result->getMessage();
137
-		if ( $resultMessage !== null ) {
137
+		if ($resultMessage !== null) {
138 138
 			$resultMessageKey = $resultMessage->getMessageKey();
139 139
 		} else {
140 140
 			$resultMessageKey = null;
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
 
143 143
 		$this->logger->log(
144 144
 			$logLevel,
145
-			'Constraint check with {constraintCheckerClassShortName} ' .
146
-			'took longer than {limitSeconds} second(s) ' .
145
+			'Constraint check with {constraintCheckerClassShortName} '.
146
+			'took longer than {limitSeconds} second(s) '.
147 147
 			'(duration: {durationSeconds} seconds).',
148 148
 			[
149 149
 				'method' => $method,
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 				'constraintId' => $constraint->getConstraintId(),
154 154
 				'constraintPropertyId' => $constraint->getPropertyId()->getSerialization(),
155 155
 				'constraintTypeItemId' => $constraintTypeItemId,
156
-				'constraintParameters' => json_encode( $constraint->getConstraintParameters() ),
156
+				'constraintParameters' => json_encode($constraint->getConstraintParameters()),
157 157
 				'constraintCheckerClass' => $constraintCheckerClass,
158 158
 				'constraintCheckerClassShortName' => $constraintCheckerClassShortName,
159 159
 				'entityId' => $context->getEntity()->getId()->getSerialization(),
@@ -188,18 +188,18 @@  discard block
 block discarded – undo
188 188
 		);
189 189
 
190 190
 		// find the longest limit (and associated log level) that the duration exceeds
191
-		[ $limitSeconds, $logLevel ] = $this->findLimit(
191
+		[$limitSeconds, $logLevel] = $this->findLimit(
192 192
 			$this->constraintCheckOnEntityDurationLimits,
193 193
 			$durationSeconds
194 194
 		);
195
-		if ( $limitSeconds === null ) {
195
+		if ($limitSeconds === null) {
196 196
 			return;
197 197
 		}
198 198
 
199 199
 		$this->logger->log(
200 200
 			$logLevel,
201
-			'Full constraint check on {entityId} ' .
202
-			'took longer than {limitSeconds} second(s) ' .
201
+			'Full constraint check on {entityId} '.
202
+			'took longer than {limitSeconds} second(s) '.
203 203
 			'(duration: {durationSeconds} seconds).',
204 204
 			[
205 205
 				'method' => $method,
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 *
218 218
 	 * @param EntityId $entityId
219 219
 	 */
220
-	public function logCheckConstraintsCacheHit( EntityId $entityId ) {
220
+	public function logCheckConstraintsCacheHit(EntityId $entityId) {
221 221
 		$this->dataFactory->increment(
222 222
 			'wikibase.quality.constraints.cache.entity.hit'
223 223
 		);
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
 	 *
229 229
 	 * @param EntityId[] $entityIds
230 230
 	 */
231
-	public function logCheckConstraintsCacheMisses( array $entityIds ) {
231
+	public function logCheckConstraintsCacheMisses(array $entityIds) {
232 232
 		$this->dataFactory->updateCount(
233 233
 			'wikibase.quality.constraints.cache.entity.miss',
234
-			count( $entityIds )
234
+			count($entityIds)
235 235
 		);
236 236
 	}
237 237
 
@@ -258,17 +258,17 @@  discard block
 block discarded – undo
258 258
 	 * @param EntityId[] $entityIds
259 259
 	 * @param int $maxRevisionIds
260 260
 	 */
261
-	public function logHugeDependencyMetadata( array $entityIds, $maxRevisionIds ) {
261
+	public function logHugeDependencyMetadata(array $entityIds, $maxRevisionIds) {
262 262
 		$this->logger->log(
263 263
 			'warning',
264
-			'Dependency metadata for constraint check result has huge set of entity IDs ' .
265
-			'(count ' . count( $entityIds ) . ', limit ' . $maxRevisionIds . '); ' .
264
+			'Dependency metadata for constraint check result has huge set of entity IDs '.
265
+			'(count '.count($entityIds).', limit '.$maxRevisionIds.'); '.
266 266
 			'caching disabled for this check result.',
267 267
 			[
268 268
 				'loggingMethod' => __METHOD__,
269 269
 				'entityIds' => json_encode(
270 270
 					array_map(
271
-						static function ( EntityId $entityId ) {
271
+						static function(EntityId $entityId) {
272 272
 							return $entityId->getSerialization();
273 273
 						},
274 274
 						$entityIds
@@ -287,17 +287,17 @@  discard block
 block discarded – undo
287 287
 			'Sparql API replied with status 429 and a retry-after header. Requesting to retry after {retryAfterTime}',
288 288
 			[
289 289
 				'retryAfterTime' => $retryAfterTime,
290
-				'responseHeaders' => json_encode( $request->getResponseHeaders() ),
290
+				'responseHeaders' => json_encode($request->getResponseHeaders()),
291 291
 				'responseContent' => $request->getContent(),
292 292
 			]
293 293
 		);
294 294
 	}
295 295
 
296
-	public function logSparqlHelperTooManyRequestsRetryAfterInvalid( MWHttpRequest $request ) {
296
+	public function logSparqlHelperTooManyRequestsRetryAfterInvalid(MWHttpRequest $request) {
297 297
 		$this->logger->warning(
298 298
 			'Sparql API replied with status 429 and no valid retry-after header.',
299 299
 			[
300
-				'responseHeaders' => json_encode( $request->getResponseHeaders() ),
300
+				'responseHeaders' => json_encode($request->getResponseHeaders()),
301 301
 				'responseContent' => $request->getContent(),
302 302
 			]
303 303
 		);
Please login to merge, or discard this patch.
src/ConstraintStore.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 *
16 16
 	 * @throws DBUnexpectedError
17 17
 	 */
18
-	public function insertBatch( array $constraints );
18
+	public function insertBatch(array $constraints);
19 19
 
20 20
 	/**
21 21
 	 * Delete all constraints for the property ID.
@@ -24,6 +24,6 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @throws DBUnexpectedError
26 26
 	 */
27
-	public function deleteForProperty( NumericPropertyId $propertyId );
27
+	public function deleteForProperty(NumericPropertyId $propertyId);
28 28
 
29 29
 }
Please login to merge, or discard this patch.
src/ConstraintRepositoryStore.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -24,16 +24,16 @@  discard block
 block discarded – undo
24 24
 	 * then using the main DBLoadBalancer service may be incorrect.
25 25
 	 * @param string|false $dbName Database name ($domain for ILoadBalancer methods).
26 26
 	 */
27
-	public function __construct( ILoadBalancer $lb, $dbName ) {
27
+	public function __construct(ILoadBalancer $lb, $dbName) {
28 28
 		$this->lb = $lb;
29 29
 		$this->dbName = $dbName;
30 30
 	}
31 31
 
32
-	private function encodeConstraintParameters( array $constraintParameters ) {
33
-		$json = json_encode( $constraintParameters, JSON_FORCE_OBJECT );
32
+	private function encodeConstraintParameters(array $constraintParameters) {
33
+		$json = json_encode($constraintParameters, JSON_FORCE_OBJECT);
34 34
 
35
-		if ( strlen( $json ) > 50000 ) {
36
-			$json = json_encode( [ '@error' => [ 'toolong' => true ] ] );
35
+		if (strlen($json) > 50000) {
36
+			$json = json_encode(['@error' => ['toolong' => true]]);
37 37
 		}
38 38
 
39 39
 		return $json;
@@ -44,28 +44,28 @@  discard block
 block discarded – undo
44 44
 	 *
45 45
 	 * @throws DBUnexpectedError
46 46
 	 */
47
-	public function insertBatch( array $constraints ) {
48
-		if ( !$constraints ) {
47
+	public function insertBatch(array $constraints) {
48
+		if (!$constraints) {
49 49
 			return;
50 50
 		}
51 51
 
52 52
 		$accumulator = array_map(
53
-			function ( Constraint $constraint ) {
53
+			function(Constraint $constraint) {
54 54
 				return [
55 55
 					'constraint_guid' => $constraint->getConstraintId(),
56 56
 					'pid' => $constraint->getPropertyId()->getNumericId(),
57 57
 					'constraint_type_qid' => $constraint->getConstraintTypeItemId(),
58
-					'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() ),
58
+					'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters()),
59 59
 				];
60 60
 			},
61 61
 			$constraints
62 62
 		);
63 63
 
64
-		$dbw = $this->lb->getConnection( ILoadBalancer::DB_PRIMARY, [], $this->dbName );
64
+		$dbw = $this->lb->getConnection(ILoadBalancer::DB_PRIMARY, [], $this->dbName);
65 65
 		$dbw->newInsertQueryBuilder()
66
-			->insertInto( 'wbqc_constraints' )
67
-			->rows( $accumulator )
68
-			->caller( __METHOD__ )
66
+			->insertInto('wbqc_constraints')
67
+			->rows($accumulator)
68
+			->caller(__METHOD__)
69 69
 			->execute();
70 70
 	}
71 71
 
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @throws DBUnexpectedError
78 78
 	 */
79
-	public function deleteForProperty( NumericPropertyId $propertyId ) {
80
-		$dbw = $this->lb->getConnection( ILoadBalancer::DB_PRIMARY, [], $this->dbName );
79
+	public function deleteForProperty(NumericPropertyId $propertyId) {
80
+		$dbw = $this->lb->getConnection(ILoadBalancer::DB_PRIMARY, [], $this->dbName);
81 81
 		$dbw->newDeleteQueryBuilder()
82
-			->deleteFrom( 'wbqc_constraints' )
83
-			->where( [
82
+			->deleteFrom('wbqc_constraints')
83
+			->where([
84 84
 				'pid' => $propertyId->getNumericId(),
85
-			] )
86
-			->caller( __METHOD__ )
85
+			])
86
+			->caller(__METHOD__)
87 87
 			->execute();
88 88
 	}
89 89
 
Please login to merge, or discard this patch.
src/ServiceWiring.php 1 patch
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -30,53 +30,53 @@  discard block
 block discarded – undo
30 30
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer;
31 31
 
32 32
 return [
33
-	ConstraintsServices::EXPIRY_LOCK => static function ( MediaWikiServices $services ): ExpiryLock {
34
-		return new ExpiryLock( $services->getObjectCacheFactory()->getInstance( CACHE_ANYTHING ) );
33
+	ConstraintsServices::EXPIRY_LOCK => static function(MediaWikiServices $services): ExpiryLock {
34
+		return new ExpiryLock($services->getObjectCacheFactory()->getInstance(CACHE_ANYTHING));
35 35
 	},
36 36
 
37
-	ConstraintsServices::LOGGING_HELPER => static function ( MediaWikiServices $services ): LoggingHelper {
37
+	ConstraintsServices::LOGGING_HELPER => static function(MediaWikiServices $services): LoggingHelper {
38 38
 		return new LoggingHelper(
39 39
 			$services->getStatsdDataFactory(),
40
-			LoggerFactory::getInstance( 'WikibaseQualityConstraints' ),
40
+			LoggerFactory::getInstance('WikibaseQualityConstraints'),
41 41
 			$services->getMainConfig()
42 42
 		);
43 43
 	},
44 44
 
45
-	ConstraintsServices::CONSTRAINT_STORE => static function ( MediaWikiServices $services ): ConstraintRepositoryStore {
46
-		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services );
47
-		$propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE );
48
-		if ( $propertySource === null ) {
49
-			throw new RuntimeException( 'Can\'t get a ConstraintStore for properties not stored in a database.' );
45
+	ConstraintsServices::CONSTRAINT_STORE => static function(MediaWikiServices $services): ConstraintRepositoryStore {
46
+		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services);
47
+		$propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE);
48
+		if ($propertySource === null) {
49
+			throw new RuntimeException('Can\'t get a ConstraintStore for properties not stored in a database.');
50 50
 		}
51 51
 
52
-		$localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName();
53
-		if ( $propertySource->getSourceName() !== $localEntitySourceName ) {
54
-			throw new RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' );
52
+		$localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName();
53
+		if ($propertySource->getSourceName() !== $localEntitySourceName) {
54
+			throw new RuntimeException('Can\'t get a ConstraintStore for a non local entity source.');
55 55
 		}
56 56
 
57 57
 		$dbName = $propertySource->getDatabaseName();
58 58
 		return new ConstraintRepositoryStore(
59
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
59
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
60 60
 			$dbName
61 61
 		);
62 62
 	},
63 63
 
64
-	ConstraintsServices::CONSTRAINT_LOOKUP => static function ( MediaWikiServices $services ): ConstraintLookup {
65
-		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services );
66
-		$propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE );
67
-		if ( $propertySource === null ) {
68
-			throw new RuntimeException( 'Can\'t get a ConstraintStore for properties not stored in a database.' );
64
+	ConstraintsServices::CONSTRAINT_LOOKUP => static function(MediaWikiServices $services): ConstraintLookup {
65
+		$sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services);
66
+		$propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE);
67
+		if ($propertySource === null) {
68
+			throw new RuntimeException('Can\'t get a ConstraintStore for properties not stored in a database.');
69 69
 		}
70 70
 
71 71
 		$dbName = $propertySource->getDatabaseName();
72 72
 		$rawLookup = new ConstraintRepositoryLookup(
73
-			$services->getDBLoadBalancerFactory()->getMainLB( $dbName ),
73
+			$services->getDBLoadBalancerFactory()->getMainLB($dbName),
74 74
 			$dbName
75 75
 		);
76
-		return new CachingConstraintLookup( $rawLookup );
76
+		return new CachingConstraintLookup($rawLookup);
77 77
 	},
78 78
 
79
-	ConstraintsServices::CHECK_RESULT_SERIALIZER => static function ( MediaWikiServices $services ): CheckResultSerializer {
79
+	ConstraintsServices::CHECK_RESULT_SERIALIZER => static function(MediaWikiServices $services): CheckResultSerializer {
80 80
 		return new CheckResultSerializer(
81 81
 			new ConstraintSerializer(
82 82
 				false // constraint parameters are not exposed
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 		);
88 88
 	},
89 89
 
90
-	ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function ( MediaWikiServices $services ): CheckResultDeserializer {
91
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
92
-		$dataValueFactory = WikibaseRepo::getDataValueFactory( $services );
90
+	ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function(MediaWikiServices $services): CheckResultDeserializer {
91
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
92
+		$dataValueFactory = WikibaseRepo::getDataValueFactory($services);
93 93
 
94 94
 		return new CheckResultDeserializer(
95 95
 			new ConstraintDeserializer(),
@@ -102,17 +102,17 @@  discard block
 block discarded – undo
102 102
 		);
103 103
 	},
104 104
 
105
-	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function (
105
+	ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function(
106 106
 		MediaWikiServices $services
107 107
 	): ViolationMessageSerializer {
108 108
 		return new ViolationMessageSerializer();
109 109
 	},
110 110
 
111
-	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function (
111
+	ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function(
112 112
 		MediaWikiServices $services
113 113
 	): ViolationMessageDeserializer {
114
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
115
-		$dataValueFactory = WikibaseRepo::getDataValueFactory( $services );
114
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
115
+		$dataValueFactory = WikibaseRepo::getDataValueFactory($services);
116 116
 
117 117
 		return new ViolationMessageDeserializer(
118 118
 			$entityIdParser,
@@ -120,39 +120,39 @@  discard block
 block discarded – undo
120 120
 		);
121 121
 	},
122 122
 
123
-	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function (
123
+	ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function(
124 124
 		MediaWikiServices $services
125 125
 	): ConstraintParameterParser {
126
-		$deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory( $services );
127
-		$entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services );
126
+		$deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory($services);
127
+		$entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services);
128 128
 
129 129
 		return new ConstraintParameterParser(
130 130
 			$services->getMainConfig(),
131 131
 			$deserializerFactory,
132
-			$entitySourceDefinitions->getDatabaseSourceForEntityType( 'item' )->getConceptBaseUri()
132
+			$entitySourceDefinitions->getDatabaseSourceForEntityType('item')->getConceptBaseUri()
133 133
 		);
134 134
 	},
135 135
 
136
-	ConstraintsServices::CONNECTION_CHECKER_HELPER => static function ( MediaWikiServices $services ): ConnectionCheckerHelper {
136
+	ConstraintsServices::CONNECTION_CHECKER_HELPER => static function(MediaWikiServices $services): ConnectionCheckerHelper {
137 137
 		return new ConnectionCheckerHelper();
138 138
 	},
139 139
 
140
-	ConstraintsServices::RANGE_CHECKER_HELPER => static function ( MediaWikiServices $services ): RangeCheckerHelper {
140
+	ConstraintsServices::RANGE_CHECKER_HELPER => static function(MediaWikiServices $services): RangeCheckerHelper {
141 141
 		return new RangeCheckerHelper(
142 142
 			$services->getMainConfig(),
143
-			WikibaseRepo::getUnitConverter( $services )
143
+			WikibaseRepo::getUnitConverter($services)
144 144
 		);
145 145
 	},
146 146
 
147
-	ConstraintsServices::SPARQL_HELPER => static function ( MediaWikiServices $services ): SparqlHelper {
148
-		$endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' );
149
-		if ( $endpoint === '' ) {
147
+	ConstraintsServices::SPARQL_HELPER => static function(MediaWikiServices $services): SparqlHelper {
148
+		$endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint');
149
+		if ($endpoint === '') {
150 150
 			return new DummySparqlHelper();
151 151
 		}
152 152
 
153
-		$rdfVocabulary = WikibaseRepo::getRdfVocabulary( $services );
154
-		$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
155
-		$propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup( $services );
153
+		$rdfVocabulary = WikibaseRepo::getRdfVocabulary($services);
154
+		$entityIdParser = WikibaseRepo::getEntityIdParser($services);
155
+		$propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup($services);
156 156
 
157 157
 		return new SparqlHelper(
158 158
 			$services->getMainConfig(),
@@ -160,128 +160,128 @@  discard block
 block discarded – undo
160 160
 			$entityIdParser,
161 161
 			$propertyDataTypeLookup,
162 162
 			$services->getMainWANObjectCache(),
163
-			ConstraintsServices::getViolationMessageSerializer( $services ),
164
-			ConstraintsServices::getViolationMessageDeserializer( $services ),
163
+			ConstraintsServices::getViolationMessageSerializer($services),
164
+			ConstraintsServices::getViolationMessageDeserializer($services),
165 165
 			$services->getStatsdDataFactory(),
166
-			ConstraintsServices::getExpiryLock( $services ),
167
-			ConstraintsServices::getLoggingHelper( $services ),
168
-			WikiMap::getCurrentWikiId() . ' WikibaseQualityConstraints ' . $services->getHttpRequestFactory()->getUserAgent(),
166
+			ConstraintsServices::getExpiryLock($services),
167
+			ConstraintsServices::getLoggingHelper($services),
168
+			WikiMap::getCurrentWikiId().' WikibaseQualityConstraints '.$services->getHttpRequestFactory()->getUserAgent(),
169 169
 			$services->getHttpRequestFactory()
170 170
 		);
171 171
 	},
172 172
 
173
-	ConstraintsServices::TYPE_CHECKER_HELPER => static function ( MediaWikiServices $services ): TypeCheckerHelper {
173
+	ConstraintsServices::TYPE_CHECKER_HELPER => static function(MediaWikiServices $services): TypeCheckerHelper {
174 174
 		return new TypeCheckerHelper(
175
-			WikibaseServices::getEntityLookup( $services ),
175
+			WikibaseServices::getEntityLookup($services),
176 176
 			$services->getMainConfig(),
177
-			ConstraintsServices::getSparqlHelper( $services ),
178
-			$services->getStatsFactory()->withComponent( 'WikibaseQualityConstraints' )
177
+			ConstraintsServices::getSparqlHelper($services),
178
+			$services->getStatsFactory()->withComponent('WikibaseQualityConstraints')
179 179
 		);
180 180
 	},
181 181
 
182
-	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function (
182
+	ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function(
183 183
 		MediaWikiServices $services
184 184
 	): DelegatingConstraintChecker {
185
-		$statementGuidParser = WikibaseRepo::getStatementGuidParser( $services );
185
+		$statementGuidParser = WikibaseRepo::getStatementGuidParser($services);
186 186
 
187 187
 		$config = $services->getMainConfig();
188 188
 		$checkerMap = [
189
-			$config->get( 'WBQualityConstraintsConflictsWithConstraintId' )
190
-				=> ConstraintCheckerServices::getConflictsWithChecker( $services ),
191
-			$config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' )
192
-				=> ConstraintCheckerServices::getItemChecker( $services ),
193
-			$config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' )
194
-				=> ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ),
195
-			$config->get( 'WBQualityConstraintsSymmetricConstraintId' )
196
-				=> ConstraintCheckerServices::getSymmetricChecker( $services ),
197
-			$config->get( 'WBQualityConstraintsInverseConstraintId' )
198
-				=> ConstraintCheckerServices::getInverseChecker( $services ),
199
-			$config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' )
200
-				=> ConstraintCheckerServices::getQualifierChecker( $services ),
201
-			$config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' )
202
-				=> ConstraintCheckerServices::getQualifiersChecker( $services ),
203
-			$config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' )
204
-				=> ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ),
205
-			$config->get( 'WBQualityConstraintsRangeConstraintId' )
206
-				=> ConstraintCheckerServices::getRangeChecker( $services ),
207
-			$config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' )
208
-				=> ConstraintCheckerServices::getDiffWithinRangeChecker( $services ),
209
-			$config->get( 'WBQualityConstraintsTypeConstraintId' )
210
-				=> ConstraintCheckerServices::getTypeChecker( $services ),
211
-			$config->get( 'WBQualityConstraintsValueTypeConstraintId' )
212
-				=> ConstraintCheckerServices::getValueTypeChecker( $services ),
213
-			$config->get( 'WBQualityConstraintsSingleValueConstraintId' )
214
-				=> ConstraintCheckerServices::getSingleValueChecker( $services ),
215
-			$config->get( 'WBQualityConstraintsMultiValueConstraintId' )
216
-				=> ConstraintCheckerServices::getMultiValueChecker( $services ),
217
-			$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' )
218
-				=> ConstraintCheckerServices::getUniqueValueChecker( $services ),
219
-			$config->get( 'WBQualityConstraintsFormatConstraintId' )
220
-				=> ConstraintCheckerServices::getFormatChecker( $services ),
221
-			$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' )
222
-				=> ConstraintCheckerServices::getCommonsLinkChecker( $services ),
223
-			$config->get( 'WBQualityConstraintsOneOfConstraintId' )
224
-				=> ConstraintCheckerServices::getOneOfChecker( $services ),
225
-			$config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' )
226
-				=> ConstraintCheckerServices::getValueOnlyChecker( $services ),
227
-			$config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' )
228
-				=> ConstraintCheckerServices::getReferenceChecker( $services ),
229
-			$config->get( 'WBQualityConstraintsNoBoundsConstraintId' )
230
-				=> ConstraintCheckerServices::getNoBoundsChecker( $services ),
231
-			$config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' )
232
-				=> ConstraintCheckerServices::getAllowedUnitsChecker( $services ),
233
-			$config->get( 'WBQualityConstraintsSingleBestValueConstraintId' )
234
-				=> ConstraintCheckerServices::getSingleBestValueChecker( $services ),
235
-			$config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' )
236
-				=> ConstraintCheckerServices::getEntityTypeChecker( $services ),
237
-			$config->get( 'WBQualityConstraintsNoneOfConstraintId' )
238
-				=> ConstraintCheckerServices::getNoneOfChecker( $services ),
239
-			$config->get( 'WBQualityConstraintsIntegerConstraintId' )
240
-				=> ConstraintCheckerServices::getIntegerChecker( $services ),
241
-			$config->get( 'WBQualityConstraintsCitationNeededConstraintId' )
242
-				=> ConstraintCheckerServices::getCitationNeededChecker( $services ),
243
-			$config->get( 'WBQualityConstraintsPropertyScopeConstraintId' )
244
-				=> ConstraintCheckerServices::getPropertyScopeChecker( $services ),
245
-			$config->get( 'WBQualityConstraintsContemporaryConstraintId' )
246
-				=> ConstraintCheckerServices::getContemporaryChecker( $services ),
247
-			$config->get( 'WBQualityConstraintsLexemeLanguageConstraintId' )
248
-				=> ConstraintCheckerServices::getLexemeLanguageChecker( $services ),
249
-			$config->get( 'WBQualityConstraintsLabelInLanguageConstraintId' )
250
-				=> ConstraintCheckerServices::getLabelInLanguageChecker( $services ),
189
+			$config->get('WBQualityConstraintsConflictsWithConstraintId')
190
+				=> ConstraintCheckerServices::getConflictsWithChecker($services),
191
+			$config->get('WBQualityConstraintsItemRequiresClaimConstraintId')
192
+				=> ConstraintCheckerServices::getItemChecker($services),
193
+			$config->get('WBQualityConstraintsValueRequiresClaimConstraintId')
194
+				=> ConstraintCheckerServices::getTargetRequiredClaimChecker($services),
195
+			$config->get('WBQualityConstraintsSymmetricConstraintId')
196
+				=> ConstraintCheckerServices::getSymmetricChecker($services),
197
+			$config->get('WBQualityConstraintsInverseConstraintId')
198
+				=> ConstraintCheckerServices::getInverseChecker($services),
199
+			$config->get('WBQualityConstraintsUsedAsQualifierConstraintId')
200
+				=> ConstraintCheckerServices::getQualifierChecker($services),
201
+			$config->get('WBQualityConstraintsAllowedQualifiersConstraintId')
202
+				=> ConstraintCheckerServices::getQualifiersChecker($services),
203
+			$config->get('WBQualityConstraintsMandatoryQualifierConstraintId')
204
+				=> ConstraintCheckerServices::getMandatoryQualifiersChecker($services),
205
+			$config->get('WBQualityConstraintsRangeConstraintId')
206
+				=> ConstraintCheckerServices::getRangeChecker($services),
207
+			$config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId')
208
+				=> ConstraintCheckerServices::getDiffWithinRangeChecker($services),
209
+			$config->get('WBQualityConstraintsTypeConstraintId')
210
+				=> ConstraintCheckerServices::getTypeChecker($services),
211
+			$config->get('WBQualityConstraintsValueTypeConstraintId')
212
+				=> ConstraintCheckerServices::getValueTypeChecker($services),
213
+			$config->get('WBQualityConstraintsSingleValueConstraintId')
214
+				=> ConstraintCheckerServices::getSingleValueChecker($services),
215
+			$config->get('WBQualityConstraintsMultiValueConstraintId')
216
+				=> ConstraintCheckerServices::getMultiValueChecker($services),
217
+			$config->get('WBQualityConstraintsDistinctValuesConstraintId')
218
+				=> ConstraintCheckerServices::getUniqueValueChecker($services),
219
+			$config->get('WBQualityConstraintsFormatConstraintId')
220
+				=> ConstraintCheckerServices::getFormatChecker($services),
221
+			$config->get('WBQualityConstraintsCommonsLinkConstraintId')
222
+				=> ConstraintCheckerServices::getCommonsLinkChecker($services),
223
+			$config->get('WBQualityConstraintsOneOfConstraintId')
224
+				=> ConstraintCheckerServices::getOneOfChecker($services),
225
+			$config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId')
226
+				=> ConstraintCheckerServices::getValueOnlyChecker($services),
227
+			$config->get('WBQualityConstraintsUsedAsReferenceConstraintId')
228
+				=> ConstraintCheckerServices::getReferenceChecker($services),
229
+			$config->get('WBQualityConstraintsNoBoundsConstraintId')
230
+				=> ConstraintCheckerServices::getNoBoundsChecker($services),
231
+			$config->get('WBQualityConstraintsAllowedUnitsConstraintId')
232
+				=> ConstraintCheckerServices::getAllowedUnitsChecker($services),
233
+			$config->get('WBQualityConstraintsSingleBestValueConstraintId')
234
+				=> ConstraintCheckerServices::getSingleBestValueChecker($services),
235
+			$config->get('WBQualityConstraintsAllowedEntityTypesConstraintId')
236
+				=> ConstraintCheckerServices::getEntityTypeChecker($services),
237
+			$config->get('WBQualityConstraintsNoneOfConstraintId')
238
+				=> ConstraintCheckerServices::getNoneOfChecker($services),
239
+			$config->get('WBQualityConstraintsIntegerConstraintId')
240
+				=> ConstraintCheckerServices::getIntegerChecker($services),
241
+			$config->get('WBQualityConstraintsCitationNeededConstraintId')
242
+				=> ConstraintCheckerServices::getCitationNeededChecker($services),
243
+			$config->get('WBQualityConstraintsPropertyScopeConstraintId')
244
+				=> ConstraintCheckerServices::getPropertyScopeChecker($services),
245
+			$config->get('WBQualityConstraintsContemporaryConstraintId')
246
+				=> ConstraintCheckerServices::getContemporaryChecker($services),
247
+			$config->get('WBQualityConstraintsLexemeLanguageConstraintId')
248
+				=> ConstraintCheckerServices::getLexemeLanguageChecker($services),
249
+			$config->get('WBQualityConstraintsLabelInLanguageConstraintId')
250
+				=> ConstraintCheckerServices::getLabelInLanguageChecker($services),
251 251
 		];
252 252
 
253 253
 		return new DelegatingConstraintChecker(
254
-			WikibaseServices::getEntityLookup( $services ),
254
+			WikibaseServices::getEntityLookup($services),
255 255
 			$checkerMap,
256
-			ConstraintsServices::getConstraintLookup( $services ),
257
-			ConstraintsServices::getConstraintParameterParser( $services ),
256
+			ConstraintsServices::getConstraintLookup($services),
257
+			ConstraintsServices::getConstraintParameterParser($services),
258 258
 			$statementGuidParser,
259
-			ConstraintsServices::getLoggingHelper( $services ),
260
-			$config->get( 'WBQualityConstraintsCheckQualifiers' ),
261
-			$config->get( 'WBQualityConstraintsCheckReferences' ),
262
-			$config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' )
259
+			ConstraintsServices::getLoggingHelper($services),
260
+			$config->get('WBQualityConstraintsCheckQualifiers'),
261
+			$config->get('WBQualityConstraintsCheckReferences'),
262
+			$config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers')
263 263
 		);
264 264
 	},
265 265
 
266
-	ConstraintsServices::RESULTS_SOURCE => static function ( MediaWikiServices $services ): ResultsSource {
266
+	ConstraintsServices::RESULTS_SOURCE => static function(MediaWikiServices $services): ResultsSource {
267 267
 		$config = $services->getMainConfig();
268 268
 		$resultsSource = new CheckingResultsSource(
269
-			ConstraintsServices::getDelegatingConstraintChecker( $services )
269
+			ConstraintsServices::getDelegatingConstraintChecker($services)
270 270
 		);
271 271
 
272 272
 		$cacheCheckConstraintsResults = false;
273 273
 
274
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
274
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
275 275
 			$cacheCheckConstraintsResults = true;
276 276
 			// check that we can use getLocalRepoWikiPageMetaDataAccessor()
277 277
 			// TODO we should always be able to cache constraint check results (T244726)
278
-			$entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources();
279
-			$localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName();
278
+			$entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources();
279
+			$localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName();
280 280
 
281
-			foreach ( $entitySources as $entitySource ) {
282
-				if ( $entitySource->getSourceName() !== $localEntitySourceName ) {
283
-					LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning(
284
-						'Cannot cache constraint check results for non-local source: ' .
281
+			foreach ($entitySources as $entitySource) {
282
+				if ($entitySource->getSourceName() !== $localEntitySourceName) {
283
+					LoggerFactory::getInstance('WikibaseQualityConstraints')->warning(
284
+						'Cannot cache constraint check results for non-local source: '.
285 285
 						$entitySource->getSourceName()
286 286
 					);
287 287
 					$cacheCheckConstraintsResults = false;
@@ -290,42 +290,42 @@  discard block
 block discarded – undo
290 290
 			}
291 291
 		}
292 292
 
293
-		if ( $cacheCheckConstraintsResults ) {
293
+		if ($cacheCheckConstraintsResults) {
294 294
 			$possiblyStaleConstraintTypes = [
295
-				$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
296
-				$config->get( 'WBQualityConstraintsTypeConstraintId' ),
297
-				$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
298
-				$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
295
+				$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
296
+				$config->get('WBQualityConstraintsTypeConstraintId'),
297
+				$config->get('WBQualityConstraintsValueTypeConstraintId'),
298
+				$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
299 299
 			];
300
-			$entityIdParser = WikibaseRepo::getEntityIdParser( $services );
300
+			$entityIdParser = WikibaseRepo::getEntityIdParser($services);
301 301
 			$wikiPageEntityMetaDataAccessor = WikibaseRepo::getLocalRepoWikiPageMetaDataAccessor(
302 302
 				$services );
303 303
 
304 304
 			$resultsSource = new CachingResultsSource(
305 305
 				$resultsSource,
306 306
 				ResultsCache::getDefaultInstance(),
307
-				ConstraintsServices::getCheckResultSerializer( $services ),
308
-				ConstraintsServices::getCheckResultDeserializer( $services ),
307
+				ConstraintsServices::getCheckResultSerializer($services),
308
+				ConstraintsServices::getCheckResultDeserializer($services),
309 309
 				$wikiPageEntityMetaDataAccessor,
310 310
 				$entityIdParser,
311
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
311
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
312 312
 				$possiblyStaleConstraintTypes,
313
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ),
314
-				ConstraintsServices::getLoggingHelper( $services )
313
+				$config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'),
314
+				ConstraintsServices::getLoggingHelper($services)
315 315
 			);
316 316
 		}
317 317
 
318 318
 		return $resultsSource;
319 319
 	},
320 320
 
321
-	ConstraintsServices::VIOLATION_MESSAGE_RENDERER_FACTORY => static function (
321
+	ConstraintsServices::VIOLATION_MESSAGE_RENDERER_FACTORY => static function(
322 322
 		MediaWikiServices $services
323 323
 	): ViolationMessageRendererFactory {
324 324
 		return new ViolationMessageRendererFactory(
325 325
 			$services->getMainConfig(),
326 326
 			$services->getLanguageNameUtils(),
327
-			WikibaseRepo::getEntityIdHtmlLinkFormatterFactory( $services ),
328
-			WikibaseRepo::getValueFormatterFactory( $services )
327
+			WikibaseRepo::getEntityIdHtmlLinkFormatterFactory($services),
328
+			WikibaseRepo::getValueFormatterFactory($services)
329 329
 		);
330 330
 	},
331 331
 ];
Please login to merge, or discard this patch.
maintenance/ImportConstraintStatements.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -10,10 +10,10 @@  discard block
 block discarded – undo
10 10
 use WikibaseQuality\ConstraintReport\Job\UpdateConstraintsTableJob;
11 11
 
12 12
 // @codeCoverageIgnoreStart
13
-$basePath = getenv( "MW_INSTALL_PATH" ) !== false
14
-	? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../..";
13
+$basePath = getenv("MW_INSTALL_PATH") !== false
14
+	? getenv("MW_INSTALL_PATH") : __DIR__."/../../..";
15 15
 
16
-require_once $basePath . "/maintenance/Maintenance.php";
16
+require_once $basePath."/maintenance/Maintenance.php";
17 17
 // @codeCoverageIgnoreEnd
18 18
 
19 19
 /**
@@ -42,56 +42,56 @@  discard block
 block discarded – undo
42 42
 
43 43
 	public function __construct() {
44 44
 		parent::__construct();
45
-		$this->newUpdateConstraintsTableJob = static function ( $propertyIdSerialization ) {
45
+		$this->newUpdateConstraintsTableJob = static function($propertyIdSerialization) {
46 46
 			return UpdateConstraintsTableJob::newFromGlobalState(
47 47
 				Title::newMainPage(),
48
-				[ 'propertyId' => $propertyIdSerialization ]
48
+				['propertyId' => $propertyIdSerialization]
49 49
 			);
50 50
 		};
51 51
 
52
-		$this->addDescription( 'Imports property constraints from statements on properties' );
53
-		$this->requireExtension( 'WikibaseQualityConstraints' );
54
-		$this->setBatchSize( 10 );
52
+		$this->addDescription('Imports property constraints from statements on properties');
53
+		$this->requireExtension('WikibaseQualityConstraints');
54
+		$this->setBatchSize(10);
55 55
 
56 56
 		// Wikibase classes are not yet loaded, so setup services in a callback run in execute
57 57
 		// that can be overridden in tests.
58
-		$this->setupServices = function () {
58
+		$this->setupServices = function() {
59 59
 			$services = MediaWikiServices::getInstance();
60
-			$this->propertyInfoLookup = WikibaseRepo::getStore( $services )->getPropertyInfoLookup();
60
+			$this->propertyInfoLookup = WikibaseRepo::getStore($services)->getPropertyInfoLookup();
61 61
 		};
62 62
 	}
63 63
 
64 64
 	public function execute() {
65
-		( $this->setupServices )();
66
-		if ( !$this->getConfig()->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) ) {
67
-			$this->error( 'Constraint statements are not enabled. Aborting.' );
65
+		($this->setupServices)();
66
+		if (!$this->getConfig()->get('WBQualityConstraintsEnableConstraintsImportFromStatements')) {
67
+			$this->error('Constraint statements are not enabled. Aborting.');
68 68
 			return;
69 69
 		}
70 70
 
71 71
 		$propertyInfos = $this->propertyInfoLookup->getAllPropertyInfo();
72
-		$propertyIds = array_keys( $propertyInfos );
72
+		$propertyIds = array_keys($propertyInfos);
73 73
 
74
-		foreach ( array_chunk( $propertyIds, $this->getBatchSize() ) as $propertyIdsChunk ) {
75
-			foreach ( $propertyIdsChunk as $propertyIdSerialization ) {
76
-				$this->output( sprintf(
74
+		foreach (array_chunk($propertyIds, $this->getBatchSize()) as $propertyIdsChunk) {
75
+			foreach ($propertyIdsChunk as $propertyIdSerialization) {
76
+				$this->output(sprintf(
77 77
 					'Importing constraint statements for % 6s... ',
78 78
 					$propertyIdSerialization ),
79 79
 					$propertyIdSerialization
80 80
 				);
81
-				$startTime = microtime( true );
82
-				$job = call_user_func( $this->newUpdateConstraintsTableJob, $propertyIdSerialization );
81
+				$startTime = microtime(true);
82
+				$job = call_user_func($this->newUpdateConstraintsTableJob, $propertyIdSerialization);
83 83
 				$job->run();
84
-				$endTime = microtime( true );
85
-				$millis = ( $endTime - $startTime ) * 1000;
86
-				$this->output( sprintf( 'done in % 6.2f ms.', $millis ), $propertyIdSerialization );
84
+				$endTime = microtime(true);
85
+				$millis = ($endTime - $startTime) * 1000;
86
+				$this->output(sprintf('done in % 6.2f ms.', $millis), $propertyIdSerialization);
87 87
 			}
88 88
 
89
-			$this->output( 'Waiting for replication... ', 'waitForReplication' );
90
-			$startTime = microtime( true );
89
+			$this->output('Waiting for replication... ', 'waitForReplication');
90
+			$startTime = microtime(true);
91 91
 			$this->waitForReplication();
92
-			$endTime = microtime( true );
93
-			$millis = ( $endTime - $startTime ) * 1000;
94
-			$this->output( sprintf( 'done in % 6.2f ms.', $millis ), 'waitForReplication' );
92
+			$endTime = microtime(true);
93
+			$millis = ($endTime - $startTime) * 1000;
94
+			$this->output(sprintf('done in % 6.2f ms.', $millis), 'waitForReplication');
95 95
 		}
96 96
 	}
97 97
 
Please login to merge, or discard this patch.
src/ConstraintCheckerServices.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -44,257 +44,257 @@
 block discarded – undo
44 44
 	public const LEXEME_LANGUAGE_CHECKER = 'WBQC_Lexeme_LanguageChecker';
45 45
 	public const LABEL_IN_LANGUAGE_CHECKER = 'WBQC_LabelInLanguageChecker';
46 46
 
47
-	private static function getService( ?MediaWikiServices $services, $name ) {
47
+	private static function getService(?MediaWikiServices $services, $name) {
48 48
 		$services ??= MediaWikiServices::getInstance();
49
-		return $services->getService( $name );
49
+		return $services->getService($name);
50 50
 	}
51 51
 
52 52
 	/**
53 53
 	 * @param MediaWikiServices|null $services
54 54
 	 * @return ConstraintChecker
55 55
 	 */
56
-	public static function getConflictsWithChecker( MediaWikiServices $services = null ) {
57
-		return self::getService( $services, self::CONFLICTS_WITH_CHECKER );
56
+	public static function getConflictsWithChecker(MediaWikiServices $services = null) {
57
+		return self::getService($services, self::CONFLICTS_WITH_CHECKER);
58 58
 	}
59 59
 
60 60
 	/**
61 61
 	 * @param MediaWikiServices|null $services
62 62
 	 * @return ConstraintChecker
63 63
 	 */
64
-	public static function getItemChecker( MediaWikiServices $services = null ) {
65
-		return self::getService( $services, self::ITEM_CHECKER );
64
+	public static function getItemChecker(MediaWikiServices $services = null) {
65
+		return self::getService($services, self::ITEM_CHECKER);
66 66
 	}
67 67
 
68 68
 	/**
69 69
 	 * @param MediaWikiServices|null $services
70 70
 	 * @return ConstraintChecker
71 71
 	 */
72
-	public static function getTargetRequiredClaimChecker( MediaWikiServices $services = null ) {
73
-		return self::getService( $services, self::TARGET_REQUIRED_CLAIM_CHECKER );
72
+	public static function getTargetRequiredClaimChecker(MediaWikiServices $services = null) {
73
+		return self::getService($services, self::TARGET_REQUIRED_CLAIM_CHECKER);
74 74
 	}
75 75
 
76 76
 	/**
77 77
 	 * @param MediaWikiServices|null $services
78 78
 	 * @return ConstraintChecker
79 79
 	 */
80
-	public static function getSymmetricChecker( MediaWikiServices $services = null ) {
81
-		return self::getService( $services, self::SYMMETRIC_CHECKER );
80
+	public static function getSymmetricChecker(MediaWikiServices $services = null) {
81
+		return self::getService($services, self::SYMMETRIC_CHECKER);
82 82
 	}
83 83
 
84 84
 	/**
85 85
 	 * @param MediaWikiServices|null $services
86 86
 	 * @return ConstraintChecker
87 87
 	 */
88
-	public static function getInverseChecker( MediaWikiServices $services = null ) {
89
-		return self::getService( $services, self::INVERSE_CHECKER );
88
+	public static function getInverseChecker(MediaWikiServices $services = null) {
89
+		return self::getService($services, self::INVERSE_CHECKER);
90 90
 	}
91 91
 
92 92
 	/**
93 93
 	 * @param MediaWikiServices|null $services
94 94
 	 * @return ConstraintChecker
95 95
 	 */
96
-	public static function getQualifierChecker( MediaWikiServices $services = null ) {
97
-		return self::getService( $services, self::QUALIFIER_CHECKER );
96
+	public static function getQualifierChecker(MediaWikiServices $services = null) {
97
+		return self::getService($services, self::QUALIFIER_CHECKER);
98 98
 	}
99 99
 
100 100
 	/**
101 101
 	 * @param MediaWikiServices|null $services
102 102
 	 * @return ConstraintChecker
103 103
 	 */
104
-	public static function getQualifiersChecker( MediaWikiServices $services = null ) {
105
-		return self::getService( $services, self::QUALIFIERS_CHECKER );
104
+	public static function getQualifiersChecker(MediaWikiServices $services = null) {
105
+		return self::getService($services, self::QUALIFIERS_CHECKER);
106 106
 	}
107 107
 
108 108
 	/**
109 109
 	 * @param MediaWikiServices|null $services
110 110
 	 * @return ConstraintChecker
111 111
 	 */
112
-	public static function getMandatoryQualifiersChecker( MediaWikiServices $services = null ) {
113
-		return self::getService( $services, self::MANDATORY_QUALIFIERS_CHECKER );
112
+	public static function getMandatoryQualifiersChecker(MediaWikiServices $services = null) {
113
+		return self::getService($services, self::MANDATORY_QUALIFIERS_CHECKER);
114 114
 	}
115 115
 
116 116
 	/**
117 117
 	 * @param MediaWikiServices|null $services
118 118
 	 * @return ConstraintChecker
119 119
 	 */
120
-	public static function getRangeChecker( MediaWikiServices $services = null ) {
121
-		return self::getService( $services, self::RANGE_CHECKER );
120
+	public static function getRangeChecker(MediaWikiServices $services = null) {
121
+		return self::getService($services, self::RANGE_CHECKER);
122 122
 	}
123 123
 
124 124
 	/**
125 125
 	 * @param MediaWikiServices|null $services
126 126
 	 * @return ConstraintChecker
127 127
 	 */
128
-	public static function getDiffWithinRangeChecker( MediaWikiServices $services = null ) {
129
-		return self::getService( $services, self::DIFF_WITHIN_RANGE_CHECKER );
128
+	public static function getDiffWithinRangeChecker(MediaWikiServices $services = null) {
129
+		return self::getService($services, self::DIFF_WITHIN_RANGE_CHECKER);
130 130
 	}
131 131
 
132 132
 	/**
133 133
 	 * @param MediaWikiServices|null $services
134 134
 	 * @return ConstraintChecker
135 135
 	 */
136
-	public static function getTypeChecker( MediaWikiServices $services = null ) {
137
-		return self::getService( $services, self::TYPE_CHECKER );
136
+	public static function getTypeChecker(MediaWikiServices $services = null) {
137
+		return self::getService($services, self::TYPE_CHECKER);
138 138
 	}
139 139
 
140 140
 	/**
141 141
 	 * @param MediaWikiServices|null $services
142 142
 	 * @return ConstraintChecker
143 143
 	 */
144
-	public static function getValueTypeChecker( MediaWikiServices $services = null ) {
145
-		return self::getService( $services, self::VALUE_TYPE_CHECKER );
144
+	public static function getValueTypeChecker(MediaWikiServices $services = null) {
145
+		return self::getService($services, self::VALUE_TYPE_CHECKER);
146 146
 	}
147 147
 
148 148
 	/**
149 149
 	 * @param MediaWikiServices|null $services
150 150
 	 * @return ConstraintChecker
151 151
 	 */
152
-	public static function getSingleValueChecker( MediaWikiServices $services = null ) {
153
-		return self::getService( $services, self::SINGLE_VALUE_CHECKER );
152
+	public static function getSingleValueChecker(MediaWikiServices $services = null) {
153
+		return self::getService($services, self::SINGLE_VALUE_CHECKER);
154 154
 	}
155 155
 
156 156
 	/**
157 157
 	 * @param MediaWikiServices|null $services
158 158
 	 * @return ConstraintChecker
159 159
 	 */
160
-	public static function getMultiValueChecker( MediaWikiServices $services = null ) {
161
-		return self::getService( $services, self::MULTI_VALUE_CHECKER );
160
+	public static function getMultiValueChecker(MediaWikiServices $services = null) {
161
+		return self::getService($services, self::MULTI_VALUE_CHECKER);
162 162
 	}
163 163
 
164 164
 	/**
165 165
 	 * @param MediaWikiServices|null $services
166 166
 	 * @return ConstraintChecker
167 167
 	 */
168
-	public static function getUniqueValueChecker( MediaWikiServices $services = null ) {
169
-		return self::getService( $services, self::UNIQUE_VALUE_CHECKER );
168
+	public static function getUniqueValueChecker(MediaWikiServices $services = null) {
169
+		return self::getService($services, self::UNIQUE_VALUE_CHECKER);
170 170
 	}
171 171
 
172 172
 	/**
173 173
 	 * @param MediaWikiServices|null $services
174 174
 	 * @return ConstraintChecker
175 175
 	 */
176
-	public static function getFormatChecker( MediaWikiServices $services = null ) {
177
-		return self::getService( $services, self::FORMAT_CHECKER );
176
+	public static function getFormatChecker(MediaWikiServices $services = null) {
177
+		return self::getService($services, self::FORMAT_CHECKER);
178 178
 	}
179 179
 
180 180
 	/**
181 181
 	 * @param MediaWikiServices|null $services
182 182
 	 * @return ConstraintChecker
183 183
 	 */
184
-	public static function getCommonsLinkChecker( MediaWikiServices $services = null ) {
185
-		return self::getService( $services, self::COMMONS_LINK_CHECKER );
184
+	public static function getCommonsLinkChecker(MediaWikiServices $services = null) {
185
+		return self::getService($services, self::COMMONS_LINK_CHECKER);
186 186
 	}
187 187
 
188 188
 	/**
189 189
 	 * @param MediaWikiServices|null $services
190 190
 	 * @return ConstraintChecker
191 191
 	 */
192
-	public static function getOneOfChecker( MediaWikiServices $services = null ) {
193
-		return self::getService( $services, self::ONE_OF_CHECKER );
192
+	public static function getOneOfChecker(MediaWikiServices $services = null) {
193
+		return self::getService($services, self::ONE_OF_CHECKER);
194 194
 	}
195 195
 
196 196
 	/**
197 197
 	 * @param MediaWikiServices|null $services
198 198
 	 * @return ConstraintChecker
199 199
 	 */
200
-	public static function getValueOnlyChecker( MediaWikiServices $services = null ) {
201
-		return self::getService( $services, self::VALUE_ONLY_CHECKER );
200
+	public static function getValueOnlyChecker(MediaWikiServices $services = null) {
201
+		return self::getService($services, self::VALUE_ONLY_CHECKER);
202 202
 	}
203 203
 
204 204
 	/**
205 205
 	 * @param MediaWikiServices|null $services
206 206
 	 * @return ConstraintChecker
207 207
 	 */
208
-	public static function getReferenceChecker( MediaWikiServices $services = null ) {
209
-		return self::getService( $services, self::REFERENCE_CHECKER );
208
+	public static function getReferenceChecker(MediaWikiServices $services = null) {
209
+		return self::getService($services, self::REFERENCE_CHECKER);
210 210
 	}
211 211
 
212 212
 	/**
213 213
 	 * @param MediaWikiServices|null $services
214 214
 	 * @return ConstraintChecker
215 215
 	 */
216
-	public static function getNoBoundsChecker( MediaWikiServices $services = null ) {
217
-		return self::getService( $services, self::NO_BOUNDS_CHECKER );
216
+	public static function getNoBoundsChecker(MediaWikiServices $services = null) {
217
+		return self::getService($services, self::NO_BOUNDS_CHECKER);
218 218
 	}
219 219
 
220 220
 	/**
221 221
 	 * @param MediaWikiServices|null $services
222 222
 	 * @return ConstraintChecker
223 223
 	 */
224
-	public static function getAllowedUnitsChecker( MediaWikiServices $services = null ) {
225
-		return self::getService( $services, self::ALLOWED_UNITS_CHECKER );
224
+	public static function getAllowedUnitsChecker(MediaWikiServices $services = null) {
225
+		return self::getService($services, self::ALLOWED_UNITS_CHECKER);
226 226
 	}
227 227
 
228 228
 	/**
229 229
 	 * @param MediaWikiServices|null $services
230 230
 	 * @return ConstraintChecker
231 231
 	 */
232
-	public static function getSingleBestValueChecker( MediaWikiServices $services = null ) {
233
-		return self::getService( $services, self::SINGLE_BEST_VALUE_CHECKER );
232
+	public static function getSingleBestValueChecker(MediaWikiServices $services = null) {
233
+		return self::getService($services, self::SINGLE_BEST_VALUE_CHECKER);
234 234
 	}
235 235
 
236 236
 	/**
237 237
 	 * @param MediaWikiServices|null $services
238 238
 	 * @return ConstraintChecker
239 239
 	 */
240
-	public static function getEntityTypeChecker( MediaWikiServices $services = null ) {
241
-		return self::getService( $services, self::ENTITY_TYPE_CHECKER );
240
+	public static function getEntityTypeChecker(MediaWikiServices $services = null) {
241
+		return self::getService($services, self::ENTITY_TYPE_CHECKER);
242 242
 	}
243 243
 
244 244
 	/**
245 245
 	 * @param MediaWikiServices|null $services
246 246
 	 * @return ConstraintChecker
247 247
 	 */
248
-	public static function getNoneOfChecker( MediaWikiServices $services = null ) {
249
-		return self::getService( $services, self::NONE_OF_CHECKER );
248
+	public static function getNoneOfChecker(MediaWikiServices $services = null) {
249
+		return self::getService($services, self::NONE_OF_CHECKER);
250 250
 	}
251 251
 
252 252
 	/**
253 253
 	 * @param MediaWikiServices|null $services
254 254
 	 * @return ConstraintChecker
255 255
 	 */
256
-	public static function getIntegerChecker( MediaWikiServices $services = null ) {
257
-		return self::getService( $services, self::INTEGER_CHECKER );
256
+	public static function getIntegerChecker(MediaWikiServices $services = null) {
257
+		return self::getService($services, self::INTEGER_CHECKER);
258 258
 	}
259 259
 
260 260
 	/**
261 261
 	 * @param MediaWikiServices|null $services
262 262
 	 * @return ConstraintChecker
263 263
 	 */
264
-	public static function getCitationNeededChecker( MediaWikiServices $services = null ) {
265
-		return self::getService( $services, self::CITATION_NEEDED_CHECKER );
264
+	public static function getCitationNeededChecker(MediaWikiServices $services = null) {
265
+		return self::getService($services, self::CITATION_NEEDED_CHECKER);
266 266
 	}
267 267
 
268 268
 	/**
269 269
 	 * @param MediaWikiServices|null $services
270 270
 	 * @return ConstraintChecker
271 271
 	 */
272
-	public static function getPropertyScopeChecker( MediaWikiServices $services = null ) {
273
-		return self::getService( $services, self::PROPERTY_SCOPE_CHECKER );
272
+	public static function getPropertyScopeChecker(MediaWikiServices $services = null) {
273
+		return self::getService($services, self::PROPERTY_SCOPE_CHECKER);
274 274
 	}
275 275
 
276 276
 	/**
277 277
 	 * @param MediaWikiServices|null $services
278 278
 	 * @return ConstraintChecker
279 279
 	 */
280
-	public static function getContemporaryChecker( MediaWikiServices $services = null ) {
281
-		return self::getService( $services, self::CONTEMPORARY_CHECKER );
280
+	public static function getContemporaryChecker(MediaWikiServices $services = null) {
281
+		return self::getService($services, self::CONTEMPORARY_CHECKER);
282 282
 	}
283 283
 
284 284
 	/**
285 285
 	 * @param MediaWikiServices|null $services
286 286
 	 * @return LanguageChecker
287 287
 	 */
288
-	public static function getLexemeLanguageChecker( MediaWikiServices $services = null ) {
289
-		return self::getService( $services, self::LEXEME_LANGUAGE_CHECKER );
288
+	public static function getLexemeLanguageChecker(MediaWikiServices $services = null) {
289
+		return self::getService($services, self::LEXEME_LANGUAGE_CHECKER);
290 290
 	}
291 291
 
292 292
 	/**
293 293
 	 * @param MediaWikiServices|null $services
294 294
 	 * @return LabelInLanguageChecker
295 295
 	 */
296
-	public static function getLabelInLanguageChecker( MediaWikiServices $services = null ) {
297
-		return self::getService( $services, self::LABEL_IN_LANGUAGE_CHECKER );
296
+	public static function getLabelInLanguageChecker(MediaWikiServices $services = null) {
297
+		return self::getService($services, self::LABEL_IN_LANGUAGE_CHECKER);
298 298
 	}
299 299
 
300 300
 }
Please login to merge, or discard this patch.
src/ConstraintsServices.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -40,91 +40,91 @@
 block discarded – undo
40 40
 	public const EXPIRY_LOCK = 'WBQC_ExpiryLock';
41 41
 	public const VIOLATION_MESSAGE_RENDERER_FACTORY = 'WBQC_ViolationMessageRendererFactory';
42 42
 
43
-	private static function getService( ?MediaWikiServices $services, $name ) {
43
+	private static function getService(?MediaWikiServices $services, $name) {
44 44
 		$services ??= MediaWikiServices::getInstance();
45
-		return $services->getService( $name );
45
+		return $services->getService($name);
46 46
 	}
47 47
 
48
-	public static function getLoggingHelper( MediaWikiServices $services = null ): LoggingHelper {
49
-		return self::getService( $services, self::LOGGING_HELPER );
48
+	public static function getLoggingHelper(MediaWikiServices $services = null): LoggingHelper {
49
+		return self::getService($services, self::LOGGING_HELPER);
50 50
 	}
51 51
 
52 52
 	public static function getConstraintStore(
53 53
 		MediaWikiServices $services = null
54 54
 	): ConstraintStore {
55
-		return self::getService( $services, self::CONSTRAINT_STORE );
55
+		return self::getService($services, self::CONSTRAINT_STORE);
56 56
 	}
57 57
 
58
-	public static function getConstraintLookup( MediaWikiServices $services = null ): ConstraintLookup {
59
-		return self::getService( $services, self::CONSTRAINT_LOOKUP );
58
+	public static function getConstraintLookup(MediaWikiServices $services = null): ConstraintLookup {
59
+		return self::getService($services, self::CONSTRAINT_LOOKUP);
60 60
 	}
61 61
 
62 62
 	public static function getCheckResultSerializer(
63 63
 		MediaWikiServices $services = null
64 64
 	): CheckResultSerializer {
65
-		return self::getService( $services, self::CHECK_RESULT_SERIALIZER );
65
+		return self::getService($services, self::CHECK_RESULT_SERIALIZER);
66 66
 	}
67 67
 
68 68
 	public static function getCheckResultDeserializer(
69 69
 		MediaWikiServices $services = null
70 70
 	): CheckResultDeserializer {
71
-		return self::getService( $services, self::CHECK_RESULT_DESERIALIZER );
71
+		return self::getService($services, self::CHECK_RESULT_DESERIALIZER);
72 72
 	}
73 73
 
74 74
 	public static function getViolationMessageSerializer(
75 75
 		MediaWikiServices $services = null
76 76
 	): ViolationMessageSerializer {
77
-		return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER );
77
+		return self::getService($services, self::VIOLATION_MESSAGE_SERIALIZER);
78 78
 	}
79 79
 
80 80
 	public static function getViolationMessageDeserializer(
81 81
 		MediaWikiServices $services = null
82 82
 	): ViolationMessageDeserializer {
83
-		return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER );
83
+		return self::getService($services, self::VIOLATION_MESSAGE_DESERIALIZER);
84 84
 	}
85 85
 
86 86
 	public static function getConstraintParameterParser(
87 87
 		MediaWikiServices $services = null
88 88
 	): ConstraintParameterParser {
89
-		return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER );
89
+		return self::getService($services, self::CONSTRAINT_PARAMETER_PARSER);
90 90
 	}
91 91
 
92 92
 	public static function getConnectionCheckerHelper(
93 93
 		MediaWikiServices $services = null
94 94
 	): ConnectionCheckerHelper {
95
-		return self::getService( $services, self::CONNECTION_CHECKER_HELPER );
95
+		return self::getService($services, self::CONNECTION_CHECKER_HELPER);
96 96
 	}
97 97
 
98
-	public static function getRangeCheckerHelper( MediaWikiServices $services = null ): RangeCheckerHelper {
99
-		return self::getService( $services, self::RANGE_CHECKER_HELPER );
98
+	public static function getRangeCheckerHelper(MediaWikiServices $services = null): RangeCheckerHelper {
99
+		return self::getService($services, self::RANGE_CHECKER_HELPER);
100 100
 	}
101 101
 
102
-	public static function getSparqlHelper( MediaWikiServices $services = null ): SparqlHelper {
103
-		return self::getService( $services, self::SPARQL_HELPER );
102
+	public static function getSparqlHelper(MediaWikiServices $services = null): SparqlHelper {
103
+		return self::getService($services, self::SPARQL_HELPER);
104 104
 	}
105 105
 
106
-	public static function getTypeCheckerHelper( MediaWikiServices $services = null ): TypeCheckerHelper {
107
-		return self::getService( $services, self::TYPE_CHECKER_HELPER );
106
+	public static function getTypeCheckerHelper(MediaWikiServices $services = null): TypeCheckerHelper {
107
+		return self::getService($services, self::TYPE_CHECKER_HELPER);
108 108
 	}
109 109
 
110 110
 	public static function getDelegatingConstraintChecker(
111 111
 		MediaWikiServices $services = null
112 112
 	): DelegatingConstraintChecker {
113
-		return self::getService( $services, self::DELEGATING_CONSTRAINT_CHECKER );
113
+		return self::getService($services, self::DELEGATING_CONSTRAINT_CHECKER);
114 114
 	}
115 115
 
116
-	public static function getResultsSource( MediaWikiServices $services = null ): ResultsSource {
117
-		return self::getService( $services, self::RESULTS_SOURCE );
116
+	public static function getResultsSource(MediaWikiServices $services = null): ResultsSource {
117
+		return self::getService($services, self::RESULTS_SOURCE);
118 118
 	}
119 119
 
120
-	public static function getExpiryLock( MediaWikiServices $services = null ): ExpiryLock {
121
-		return self::getService( $services, self::EXPIRY_LOCK );
120
+	public static function getExpiryLock(MediaWikiServices $services = null): ExpiryLock {
121
+		return self::getService($services, self::EXPIRY_LOCK);
122 122
 	}
123 123
 
124 124
 	public static function getViolationMessageRendererFactory(
125 125
 		MediaWikiServices $services = null
126 126
 	): ViolationMessageRendererFactory {
127
-		return self::getService( $services, self::VIOLATION_MESSAGE_RENDERER_FACTORY );
127
+		return self::getService($services, self::VIOLATION_MESSAGE_RENDERER_FACTORY);
128 128
 	}
129 129
 
130 130
 }
Please login to merge, or discard this patch.
src/WikibaseServices.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,33 +20,33 @@
 block discarded – undo
20 20
 	public const PROPERTY_DATA_TYPE_LOOKUP = 'WBQC_PropertyDataTypeLookup';
21 21
 	public const ENTITY_LOOKUP_WITHOUT_CACHE = 'WBQC_EntityLookupWithoutCache';
22 22
 
23
-	private static function getService( ?MediaWikiServices $services, $name ) {
23
+	private static function getService(?MediaWikiServices $services, $name) {
24 24
 		$services ??= MediaWikiServices::getInstance();
25
-		return $services->getService( $name );
25
+		return $services->getService($name);
26 26
 	}
27 27
 
28 28
 	/**
29 29
 	 * @param MediaWikiServices|null $services
30 30
 	 * @return EntityLookup
31 31
 	 */
32
-	public static function getEntityLookup( MediaWikiServices $services = null ) {
33
-		return self::getService( $services, self::ENTITY_LOOKUP );
32
+	public static function getEntityLookup(MediaWikiServices $services = null) {
33
+		return self::getService($services, self::ENTITY_LOOKUP);
34 34
 	}
35 35
 
36 36
 	/**
37 37
 	 * @param MediaWikiServices|null $services
38 38
 	 * @return PropertyDataTypeLookup
39 39
 	 */
40
-	public static function getPropertyDataTypeLookup( MediaWikiServices $services = null ) {
41
-		return self::getService( $services, self::PROPERTY_DATA_TYPE_LOOKUP );
40
+	public static function getPropertyDataTypeLookup(MediaWikiServices $services = null) {
41
+		return self::getService($services, self::PROPERTY_DATA_TYPE_LOOKUP);
42 42
 	}
43 43
 
44 44
 	/**
45 45
 	 * @param MediaWikiServices|null $services
46 46
 	 * @return EntityLookup
47 47
 	 */
48
-	public static function getEntityLookupWithoutCache( MediaWikiServices $services = null ) {
49
-		return self::getService( $services, self::ENTITY_LOOKUP_WITHOUT_CACHE );
48
+	public static function getEntityLookupWithoutCache(MediaWikiServices $services = null) {
49
+		return self::getService($services, self::ENTITY_LOOKUP_WITHOUT_CACHE);
50 50
 	}
51 51
 
52 52
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/DelegatingConstraintChecker.php 1 patch
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck;
6 6
 
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 		callable $defaultResultsPerEntity = null
124 124
 	): array {
125 125
 		$checkResults = [];
126
-		$entity = $this->entityLookup->getEntity( $entityId );
126
+		$entity = $this->entityLookup->getEntity($entityId);
127 127
 
128
-		if ( $entity instanceof StatementListProvidingEntity ) {
129
-			$startTime = microtime( true );
128
+		if ($entity instanceof StatementListProvidingEntity) {
129
+			$startTime = microtime(true);
130 130
 
131 131
 			$checkResults = $this->checkEveryStatement(
132 132
 				$entity,
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 				$defaultResultsPerContext
135 135
 			);
136 136
 
137
-			$endTime = microtime( true );
137
+			$endTime = microtime(true);
138 138
 
139
-			if ( $constraintIds === null ) { // only log full constraint checks
139
+			if ($constraintIds === null) { // only log full constraint checks
140 140
 				$this->loggingHelper->logConstraintCheckOnEntity(
141 141
 					$entityId,
142 142
 					$checkResults,
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 		}
148 148
 
149
-		if ( $defaultResultsPerEntity !== null ) {
150
-			$checkResults = array_merge( $defaultResultsPerEntity( $entityId ), $checkResults );
149
+		if ($defaultResultsPerEntity !== null) {
150
+			$checkResults = array_merge($defaultResultsPerEntity($entityId), $checkResults);
151 151
 		}
152 152
 
153
-		return $this->sortResult( $checkResults );
153
+		return $this->sortResult($checkResults);
154 154
 	}
155 155
 
156 156
 	/**
@@ -172,19 +172,19 @@  discard block
 block discarded – undo
172 172
 		callable $defaultResults = null
173 173
 	): array {
174 174
 
175
-		$parsedGuid = $this->statementGuidParser->parse( $guid );
175
+		$parsedGuid = $this->statementGuidParser->parse($guid);
176 176
 		$entityId = $parsedGuid->getEntityId();
177
-		$entity = $this->entityLookup->getEntity( $entityId );
178
-		if ( $entity instanceof StatementListProvidingEntity ) {
179
-			$statement = $entity->getStatements()->getFirstStatementWithGuid( $guid );
180
-			if ( $statement ) {
177
+		$entity = $this->entityLookup->getEntity($entityId);
178
+		if ($entity instanceof StatementListProvidingEntity) {
179
+			$statement = $entity->getStatements()->getFirstStatementWithGuid($guid);
180
+			if ($statement) {
181 181
 				$result = $this->checkStatement(
182 182
 					$entity,
183 183
 					$statement,
184 184
 					$constraintIds,
185 185
 					$defaultResults
186 186
 				);
187
-				$output = $this->sortResult( $result );
187
+				$output = $this->sortResult($result);
188 188
 				return $output;
189 189
 			}
190 190
 		}
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 		return [];
193 193
 	}
194 194
 
195
-	private function getValidContextTypes( Constraint $constraint ): array {
196
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
195
+	private function getValidContextTypes(Constraint $constraint): array {
196
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
197 197
 			return [
198 198
 				Context::TYPE_STATEMENT,
199 199
 				Context::TYPE_QUALIFIER,
@@ -201,21 +201,21 @@  discard block
 block discarded – undo
201 201
 			];
202 202
 		}
203 203
 
204
-		return array_keys( array_filter(
204
+		return array_keys(array_filter(
205 205
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedContextTypes(),
206
-			static fn ( $status ) => $status !== CheckResult::STATUS_NOT_IN_SCOPE
207
-		) );
206
+			static fn ($status) => $status !== CheckResult::STATUS_NOT_IN_SCOPE
207
+		));
208 208
 	}
209 209
 
210
-	private function getValidEntityTypes( Constraint $constraint ): array {
211
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
212
-			return array_keys( ConstraintChecker::ALL_ENTITY_TYPES_SUPPORTED );
210
+	private function getValidEntityTypes(Constraint $constraint): array {
211
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
212
+			return array_keys(ConstraintChecker::ALL_ENTITY_TYPES_SUPPORTED);
213 213
 		}
214 214
 
215
-		return array_keys( array_filter(
215
+		return array_keys(array_filter(
216 216
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedEntityTypes(),
217
-			static fn ( $status ) => $status !== CheckResult::STATUS_NOT_IN_SCOPE
218
-		) );
217
+			static fn ($status) => $status !== CheckResult::STATUS_NOT_IN_SCOPE
218
+		));
219 219
 	}
220 220
 
221 221
 	/**
@@ -226,38 +226,38 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @return ConstraintParameterException[]
228 228
 	 */
229
-	private function checkCommonConstraintParameters( Constraint $constraint ): array {
229
+	private function checkCommonConstraintParameters(Constraint $constraint): array {
230 230
 		$constraintParameters = $constraint->getConstraintParameters();
231 231
 		try {
232
-			$this->constraintParameterParser->checkError( $constraintParameters );
233
-		} catch ( ConstraintParameterException $e ) {
234
-			return [ $e ];
232
+			$this->constraintParameterParser->checkError($constraintParameters);
233
+		} catch (ConstraintParameterException $e) {
234
+			return [$e];
235 235
 		}
236 236
 
237 237
 		$problems = [];
238 238
 		try {
239
-			$this->constraintParameterParser->parseExceptionParameter( $constraintParameters );
240
-		} catch ( ConstraintParameterException $e ) {
239
+			$this->constraintParameterParser->parseExceptionParameter($constraintParameters);
240
+		} catch (ConstraintParameterException $e) {
241 241
 			$problems[] = $e;
242 242
 		}
243 243
 		try {
244
-			$this->constraintParameterParser->parseConstraintClarificationParameter( $constraintParameters );
245
-		} catch ( ConstraintParameterException $e ) {
244
+			$this->constraintParameterParser->parseConstraintClarificationParameter($constraintParameters);
245
+		} catch (ConstraintParameterException $e) {
246 246
 			$problems[] = $e;
247 247
 		}
248 248
 		try {
249
-			$this->constraintParameterParser->parseConstraintStatusParameter( $constraintParameters );
250
-		} catch ( ConstraintParameterException $e ) {
249
+			$this->constraintParameterParser->parseConstraintStatusParameter($constraintParameters);
250
+		} catch (ConstraintParameterException $e) {
251 251
 			$problems[] = $e;
252 252
 		}
253 253
 		try {
254 254
 			$this->constraintParameterParser->parseConstraintScopeParameters(
255 255
 				$constraintParameters,
256 256
 				$constraint->getConstraintTypeItemId(),
257
-				$this->getValidContextTypes( $constraint ),
258
-				$this->getValidEntityTypes( $constraint )
257
+				$this->getValidContextTypes($constraint),
258
+				$this->getValidEntityTypes($constraint)
259 259
 			);
260
-		} catch ( ConstraintParameterException $e ) {
260
+		} catch (ConstraintParameterException $e) {
261 261
 			$problems[] = $e;
262 262
 		}
263 263
 		return $problems;
@@ -270,16 +270,16 @@  discard block
 block discarded – undo
270 270
 	 * @return ConstraintParameterException[][] first level indexed by constraint ID,
271 271
 	 * second level like checkConstraintParametersOnConstraintId (but without possibility of null)
272 272
 	 */
273
-	public function checkConstraintParametersOnPropertyId( NumericPropertyId $propertyId ): array {
274
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
273
+	public function checkConstraintParametersOnPropertyId(NumericPropertyId $propertyId): array {
274
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
275 275
 		$result = [];
276 276
 
277
-		foreach ( $constraints as $constraint ) {
278
-			$problems = $this->checkCommonConstraintParameters( $constraint );
277
+		foreach ($constraints as $constraint) {
278
+			$problems = $this->checkCommonConstraintParameters($constraint);
279 279
 
280
-			if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
280
+			if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
281 281
 				$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
282
-				$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
282
+				$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
283 283
 			}
284 284
 
285 285
 			$result[$constraint->getConstraintId()] = $problems;
@@ -296,18 +296,18 @@  discard block
 block discarded – undo
296 296
 	 * @return ConstraintParameterException[]|null list of constraint parameter exceptions
297 297
 	 * (empty means all parameters okay), or null if constraint is not found
298 298
 	 */
299
-	public function checkConstraintParametersOnConstraintId( string $constraintId ): ?array {
300
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
299
+	public function checkConstraintParametersOnConstraintId(string $constraintId): ?array {
300
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
301 301
 		'@phan-var NumericPropertyId $propertyId';
302
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
302
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
303 303
 
304
-		foreach ( $constraints as $constraint ) {
305
-			if ( $constraint->getConstraintId() === $constraintId ) {
306
-				$problems = $this->checkCommonConstraintParameters( $constraint );
304
+		foreach ($constraints as $constraint) {
305
+			if ($constraint->getConstraintId() === $constraintId) {
306
+				$problems = $this->checkCommonConstraintParameters($constraint);
307 307
 
308
-				if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
308
+				if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
309 309
 					$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
310
-					$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
310
+					$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
311 311
 				}
312 312
 
313 313
 				return $problems;
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 		$result = [];
333 333
 
334 334
 		/** @var Statement $statement */
335
-		foreach ( $entity->getStatements() as $statement ) {
336
-			$result = array_merge( $result,
335
+		foreach ($entity->getStatements() as $statement) {
336
+			$result = array_merge($result,
337 337
 				$this->checkStatement(
338 338
 					$entity,
339 339
 					$statement,
340 340
 					$constraintIds,
341 341
 					$defaultResultsPerContext
342
-				) );
342
+				));
343 343
 		}
344 344
 
345 345
 		return $result;
@@ -361,32 +361,32 @@  discard block
 block discarded – undo
361 361
 	): array {
362 362
 		$result = [];
363 363
 
364
-		$result = array_merge( $result,
364
+		$result = array_merge($result,
365 365
 			$this->checkConstraintsForMainSnak(
366 366
 				$entity,
367 367
 				$statement,
368 368
 				$constraintIds,
369 369
 				$defaultResultsPerContext
370
-			) );
370
+			));
371 371
 
372
-		if ( $this->checkQualifiers ) {
373
-			$result = array_merge( $result,
372
+		if ($this->checkQualifiers) {
373
+			$result = array_merge($result,
374 374
 				$this->checkConstraintsForQualifiers(
375 375
 					$entity,
376 376
 					$statement,
377 377
 					$constraintIds,
378 378
 					$defaultResultsPerContext
379
-				) );
379
+				));
380 380
 		}
381 381
 
382
-		if ( $this->checkReferences ) {
383
-			$result = array_merge( $result,
382
+		if ($this->checkReferences) {
383
+			$result = array_merge($result,
384 384
 				$this->checkConstraintsForReferences(
385 385
 					$entity,
386 386
 					$statement,
387 387
 					$constraintIds,
388 388
 					$defaultResultsPerContext
389
-				) );
389
+				));
390 390
 		}
391 391
 
392 392
 		return $result;
@@ -401,17 +401,17 @@  discard block
 block discarded – undo
401 401
 	 * @param string[]|null $constraintIds
402 402
 	 * @return Constraint[]
403 403
 	 */
404
-	private function getConstraintsToUse( PropertyId $propertyId, ?array $constraintIds ): array {
405
-		if ( !( $propertyId instanceof NumericPropertyId ) ) {
404
+	private function getConstraintsToUse(PropertyId $propertyId, ?array $constraintIds): array {
405
+		if (!($propertyId instanceof NumericPropertyId)) {
406 406
 			throw new InvalidArgumentException(
407
-				'Non-numeric property ID not supported:' . $propertyId->getSerialization()
407
+				'Non-numeric property ID not supported:'.$propertyId->getSerialization()
408 408
 			);
409 409
 		}
410
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
411
-		if ( $constraintIds !== null ) {
410
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
411
+		if ($constraintIds !== null) {
412 412
 			$constraintsToUse = [];
413
-			foreach ( $constraints as $constraint ) {
414
-				if ( in_array( $constraint->getConstraintId(), $constraintIds ) ) {
413
+			foreach ($constraints as $constraint) {
414
+				if (in_array($constraint->getConstraintId(), $constraintIds)) {
415 415
 					$constraintsToUse[] = $constraint;
416 416
 				}
417 417
 			}
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
 		?array $constraintIds,
436 436
 		?callable $defaultResults
437 437
 	): array {
438
-		$context = new MainSnakContext( $entity, $statement );
438
+		$context = new MainSnakContext($entity, $statement);
439 439
 		$constraints = $this->getConstraintsToUse(
440 440
 			$statement->getPropertyId(),
441 441
 			$constraintIds
442 442
 		);
443
-		$result = $defaultResults !== null ? $defaultResults( $context ) : [];
443
+		$result = $defaultResults !== null ? $defaultResults($context) : [];
444 444
 
445
-		foreach ( $constraints as $constraint ) {
445
+		foreach ($constraints as $constraint) {
446 446
 			$parameters = $constraint->getConstraintParameters();
447 447
 			try {
448
-				$exceptions = $this->constraintParameterParser->parseExceptionParameter( $parameters );
449
-			} catch ( ConstraintParameterException $e ) {
448
+				$exceptions = $this->constraintParameterParser->parseExceptionParameter($parameters);
449
+			} catch (ConstraintParameterException $e) {
450 450
 				$result[] = new CheckResult(
451 451
 					$context,
452 452
 					$constraint,
@@ -456,13 +456,13 @@  discard block
 block discarded – undo
456 456
 				continue;
457 457
 			}
458 458
 
459
-			if ( in_array( $entity->getId(), $exceptions ) ) {
460
-				$message = new ViolationMessage( 'wbqc-violation-message-exception' );
461
-				$result[] = new CheckResult( $context, $constraint, CheckResult::STATUS_EXCEPTION, $message );
459
+			if (in_array($entity->getId(), $exceptions)) {
460
+				$message = new ViolationMessage('wbqc-violation-message-exception');
461
+				$result[] = new CheckResult($context, $constraint, CheckResult::STATUS_EXCEPTION, $message);
462 462
 				continue;
463 463
 			}
464 464
 
465
-			$result[] = $this->getCheckResultFor( $context, $constraint );
465
+			$result[] = $this->getCheckResultFor($context, $constraint);
466 466
 		}
467 467
 
468 468
 		return $result;
@@ -484,24 +484,24 @@  discard block
 block discarded – undo
484 484
 	): array {
485 485
 		$result = [];
486 486
 
487
-		if ( in_array(
487
+		if (in_array(
488 488
 			$statement->getPropertyId()->getSerialization(),
489 489
 			$this->propertiesWithViolatingQualifiers
490
-		) ) {
490
+		)) {
491 491
 			return $result;
492 492
 		}
493 493
 
494
-		foreach ( $statement->getQualifiers() as $qualifier ) {
495
-			$qualifierContext = new QualifierContext( $entity, $statement, $qualifier );
496
-			if ( $defaultResultsPerContext !== null ) {
497
-				$result = array_merge( $result, $defaultResultsPerContext( $qualifierContext ) );
494
+		foreach ($statement->getQualifiers() as $qualifier) {
495
+			$qualifierContext = new QualifierContext($entity, $statement, $qualifier);
496
+			if ($defaultResultsPerContext !== null) {
497
+				$result = array_merge($result, $defaultResultsPerContext($qualifierContext));
498 498
 			}
499 499
 			$qualifierConstraints = $this->getConstraintsToUse(
500 500
 				$qualifierContext->getSnak()->getPropertyId(),
501 501
 				$constraintIds
502 502
 			);
503
-			foreach ( $qualifierConstraints as $qualifierConstraint ) {
504
-				$result[] = $this->getCheckResultFor( $qualifierContext, $qualifierConstraint );
503
+			foreach ($qualifierConstraints as $qualifierConstraint) {
504
+				$result[] = $this->getCheckResultFor($qualifierContext, $qualifierConstraint);
505 505
 			}
506 506
 		}
507 507
 
@@ -525,19 +525,19 @@  discard block
 block discarded – undo
525 525
 		$result = [];
526 526
 
527 527
 		/** @var Reference $reference */
528
-		foreach ( $statement->getReferences() as $reference ) {
529
-			foreach ( $reference->getSnaks() as $snak ) {
528
+		foreach ($statement->getReferences() as $reference) {
529
+			foreach ($reference->getSnaks() as $snak) {
530 530
 				$referenceContext = new ReferenceContext(
531 531
 					$entity, $statement, $reference, $snak
532 532
 				);
533
-				if ( $defaultResultsPerContext !== null ) {
534
-					$result = array_merge( $result, $defaultResultsPerContext( $referenceContext ) );
533
+				if ($defaultResultsPerContext !== null) {
534
+					$result = array_merge($result, $defaultResultsPerContext($referenceContext));
535 535
 				}
536 536
 				$referenceConstraints = $this->getConstraintsToUse(
537 537
 					$referenceContext->getSnak()->getPropertyId(),
538 538
 					$constraintIds
539 539
 				);
540
-				foreach ( $referenceConstraints as $referenceConstraint ) {
540
+				foreach ($referenceConstraints as $referenceConstraint) {
541 541
 					$result[] = $this->getCheckResultFor(
542 542
 						$referenceContext,
543 543
 						$referenceConstraint
@@ -549,50 +549,50 @@  discard block
 block discarded – undo
549 549
 		return $result;
550 550
 	}
551 551
 
552
-	private function getCheckResultFor( Context $context, Constraint $constraint ): CheckResult {
553
-		if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
552
+	private function getCheckResultFor(Context $context, Constraint $constraint): CheckResult {
553
+		if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
554 554
 			$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
555
-			$result = $this->handleScope( $checker, $context, $constraint );
555
+			$result = $this->handleScope($checker, $context, $constraint);
556 556
 
557
-			if ( $result !== null ) {
558
-				$this->addMetadata( $context, $result );
557
+			if ($result !== null) {
558
+				$this->addMetadata($context, $result);
559 559
 				return $result;
560 560
 			}
561 561
 
562
-			$startTime = microtime( true );
562
+			$startTime = microtime(true);
563 563
 			try {
564
-				$result = $checker->checkConstraint( $context, $constraint );
565
-			} catch ( ConstraintParameterException $e ) {
564
+				$result = $checker->checkConstraint($context, $constraint);
565
+			} catch (ConstraintParameterException $e) {
566 566
 				$result = new CheckResult(
567 567
 					$context,
568 568
 					$constraint,
569 569
 					CheckResult::STATUS_BAD_PARAMETERS,
570 570
 					$e->getViolationMessage()
571 571
 				);
572
-			} catch ( SparqlHelperException $e ) {
573
-				$message = new ViolationMessage( 'wbqc-violation-message-sparql-error' );
574
-				$result = new CheckResult( $context, $constraint, CheckResult::STATUS_TODO, $message );
572
+			} catch (SparqlHelperException $e) {
573
+				$message = new ViolationMessage('wbqc-violation-message-sparql-error');
574
+				$result = new CheckResult($context, $constraint, CheckResult::STATUS_TODO, $message);
575 575
 			}
576
-			$endTime = microtime( true );
576
+			$endTime = microtime(true);
577 577
 
578
-			$this->addMetadata( $context, $result );
578
+			$this->addMetadata($context, $result);
579 579
 
580
-			$this->addConstraintClarification( $result );
580
+			$this->addConstraintClarification($result);
581 581
 
582
-			$this->downgradeResultStatus( $result );
582
+			$this->downgradeResultStatus($result);
583 583
 
584 584
 			$this->loggingHelper->logConstraintCheck(
585 585
 				$context,
586 586
 				$constraint,
587 587
 				$result,
588
-				get_class( $checker ),
588
+				get_class($checker),
589 589
 				$endTime - $startTime,
590 590
 				__METHOD__
591 591
 			);
592 592
 
593 593
 			return $result;
594 594
 		} else {
595
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_TODO, null );
595
+			return new CheckResult($context, $constraint, CheckResult::STATUS_TODO, null);
596 596
 		}
597 597
 	}
598 598
 
@@ -601,87 +601,87 @@  discard block
 block discarded – undo
601 601
 		Context $context,
602 602
 		Constraint $constraint
603 603
 	): ?CheckResult {
604
-		$validContextTypes = $this->getValidContextTypes( $constraint );
605
-		$validEntityTypes = $this->getValidEntityTypes( $constraint );
604
+		$validContextTypes = $this->getValidContextTypes($constraint);
605
+		$validEntityTypes = $this->getValidEntityTypes($constraint);
606 606
 		try {
607
-			[ $checkedContextTypes, $checkedEntityTypes ] = $this->constraintParameterParser->parseConstraintScopeParameters(
607
+			[$checkedContextTypes, $checkedEntityTypes] = $this->constraintParameterParser->parseConstraintScopeParameters(
608 608
 				$constraint->getConstraintParameters(),
609 609
 				$constraint->getConstraintTypeItemId(),
610 610
 				$validContextTypes,
611 611
 				$validEntityTypes
612 612
 			);
613
-		} catch ( ConstraintParameterException $e ) {
614
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
613
+		} catch (ConstraintParameterException $e) {
614
+			return new CheckResult($context, $constraint, CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
615 615
 		}
616 616
 
617 617
 		$checkedContextTypes ??= $checker->getDefaultContextTypes();
618 618
 		$contextType = $context->getType();
619
-		if ( !in_array( $contextType, $checkedContextTypes ) ) {
620
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE, null );
619
+		if (!in_array($contextType, $checkedContextTypes)) {
620
+			return new CheckResult($context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE, null);
621 621
 		}
622
-		if ( $checker->getSupportedContextTypes()[$contextType] === CheckResult::STATUS_TODO ) {
623
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_TODO, null );
622
+		if ($checker->getSupportedContextTypes()[$contextType] === CheckResult::STATUS_TODO) {
623
+			return new CheckResult($context, $constraint, CheckResult::STATUS_TODO, null);
624 624
 		}
625 625
 
626 626
 		$checkedEntityTypes ??= $validEntityTypes;
627 627
 		$entityType = $context->getEntity()->getType();
628
-		if ( !in_array( $entityType, $checkedEntityTypes ) ) {
629
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE, null );
628
+		if (!in_array($entityType, $checkedEntityTypes)) {
629
+			return new CheckResult($context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE, null);
630 630
 		}
631
-		if ( $checker->getSupportedEntityTypes()[$entityType] === CheckResult::STATUS_TODO ) {
632
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_TODO, null );
631
+		if ($checker->getSupportedEntityTypes()[$entityType] === CheckResult::STATUS_TODO) {
632
+			return new CheckResult($context, $constraint, CheckResult::STATUS_TODO, null);
633 633
 		}
634 634
 
635 635
 		return null;
636 636
 	}
637 637
 
638
-	private function addMetadata( Context $context, CheckResult $result ): void {
639
-		$result->withMetadata( Metadata::merge( [
638
+	private function addMetadata(Context $context, CheckResult $result): void {
639
+		$result->withMetadata(Metadata::merge([
640 640
 			$result->getMetadata(),
641
-			Metadata::ofDependencyMetadata( DependencyMetadata::merge( [
642
-				DependencyMetadata::ofEntityId( $context->getEntity()->getId() ),
643
-				DependencyMetadata::ofEntityId( $result->getConstraint()->getPropertyId() ),
644
-			] ) ),
645
-		] ) );
641
+			Metadata::ofDependencyMetadata(DependencyMetadata::merge([
642
+				DependencyMetadata::ofEntityId($context->getEntity()->getId()),
643
+				DependencyMetadata::ofEntityId($result->getConstraint()->getPropertyId()),
644
+			])),
645
+		]));
646 646
 	}
647 647
 
648
-	private function addConstraintClarification( CheckResult $result ): void {
648
+	private function addConstraintClarification(CheckResult $result): void {
649 649
 		$constraint = $result->getConstraint();
650 650
 		try {
651 651
 			$constraintClarification = $this->constraintParameterParser
652
-				->parseConstraintClarificationParameter( $constraint->getConstraintParameters() );
653
-			$result->setConstraintClarification( $constraintClarification );
654
-		} catch ( ConstraintParameterException $e ) {
655
-			$result->setStatus( CheckResult::STATUS_BAD_PARAMETERS );
656
-			$result->setMessage( $e->getViolationMessage() );
652
+				->parseConstraintClarificationParameter($constraint->getConstraintParameters());
653
+			$result->setConstraintClarification($constraintClarification);
654
+		} catch (ConstraintParameterException $e) {
655
+			$result->setStatus(CheckResult::STATUS_BAD_PARAMETERS);
656
+			$result->setMessage($e->getViolationMessage());
657 657
 		}
658 658
 	}
659 659
 
660
-	private function downgradeResultStatus( CheckResult $result ): void {
660
+	private function downgradeResultStatus(CheckResult $result): void {
661 661
 		$constraint = $result->getConstraint();
662 662
 		try {
663 663
 			$constraintStatus = $this->constraintParameterParser
664
-				->parseConstraintStatusParameter( $constraint->getConstraintParameters() );
665
-		} catch ( ConstraintParameterException $e ) {
666
-			$result->setStatus( CheckResult::STATUS_BAD_PARAMETERS );
667
-			$result->setMessage( $e->getViolationMessage() );
664
+				->parseConstraintStatusParameter($constraint->getConstraintParameters());
665
+		} catch (ConstraintParameterException $e) {
666
+			$result->setStatus(CheckResult::STATUS_BAD_PARAMETERS);
667
+			$result->setMessage($e->getViolationMessage());
668 668
 			return;
669 669
 		}
670
-		if ( $constraintStatus === null ) {
670
+		if ($constraintStatus === null) {
671 671
 			// downgrade violation to warning
672
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
673
-				$result->setStatus( CheckResult::STATUS_WARNING );
672
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
673
+				$result->setStatus(CheckResult::STATUS_WARNING);
674 674
 			}
675
-		} elseif ( $constraintStatus === 'suggestion' ) {
675
+		} elseif ($constraintStatus === 'suggestion') {
676 676
 			// downgrade violation to suggestion
677
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
678
-				$result->setStatus( CheckResult::STATUS_SUGGESTION );
677
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
678
+				$result->setStatus(CheckResult::STATUS_SUGGESTION);
679 679
 			}
680 680
 		} else {
681
-			if ( $constraintStatus !== 'mandatory' ) {
681
+			if ($constraintStatus !== 'mandatory') {
682 682
 				// @codeCoverageIgnoreStart
683 683
 				throw new LogicException(
684
-					"Unknown constraint status '$constraintStatus', " .
684
+					"Unknown constraint status '$constraintStatus', ".
685 685
 					"only known statuses are 'mandatory' and 'suggestion'"
686 686
 				);
687 687
 				// @codeCoverageIgnoreEnd
@@ -694,12 +694,12 @@  discard block
 block discarded – undo
694 694
 	 *
695 695
 	 * @return CheckResult[]
696 696
 	 */
697
-	private function sortResult( array $result ): array {
698
-		if ( count( $result ) < 2 ) {
697
+	private function sortResult(array $result): array {
698
+		if (count($result) < 2) {
699 699
 			return $result;
700 700
 		}
701 701
 
702
-		$sortFunction = static function ( CheckResult $a, CheckResult $b ) {
702
+		$sortFunction = static function(CheckResult $a, CheckResult $b) {
703 703
 			$orderNum = 0;
704 704
 			$order = [
705 705
 				CheckResult::STATUS_BAD_PARAMETERS => $orderNum++,
@@ -716,55 +716,55 @@  discard block
 block discarded – undo
716 716
 			$statusA = $a->getStatus();
717 717
 			$statusB = $b->getStatus();
718 718
 
719
-			$orderA = array_key_exists( $statusA, $order ) ? $order[ $statusA ] : $order[ 'other' ];
720
-			$orderB = array_key_exists( $statusB, $order ) ? $order[ $statusB ] : $order[ 'other' ];
719
+			$orderA = array_key_exists($statusA, $order) ? $order[$statusA] : $order['other'];
720
+			$orderB = array_key_exists($statusB, $order) ? $order[$statusB] : $order['other'];
721 721
 
722
-			if ( $orderA === $orderB ) {
722
+			if ($orderA === $orderB) {
723 723
 				$cursorA = $a->getContextCursor();
724 724
 				$cursorB = $b->getContextCursor();
725 725
 
726
-				if ( $cursorA instanceof EntityContextCursor ) {
726
+				if ($cursorA instanceof EntityContextCursor) {
727 727
 					return $cursorB instanceof EntityContextCursor ? 0 : -1;
728 728
 				}
729
-				if ( $cursorB instanceof EntityContextCursor ) {
729
+				if ($cursorB instanceof EntityContextCursor) {
730 730
 					return $cursorA instanceof EntityContextCursor ? 0 : 1;
731 731
 				}
732 732
 
733 733
 				$pidA = $cursorA->getSnakPropertyId();
734 734
 				$pidB = $cursorB->getSnakPropertyId();
735 735
 
736
-				if ( $pidA === $pidB ) {
736
+				if ($pidA === $pidB) {
737 737
 					$hashA = $cursorA->getSnakHash();
738 738
 					$hashB = $cursorB->getSnakHash();
739 739
 
740
-					if ( $hashA === $hashB ) {
741
-						if ( $a instanceof NullResult ) {
740
+					if ($hashA === $hashB) {
741
+						if ($a instanceof NullResult) {
742 742
 							return $b instanceof NullResult ? 0 : -1;
743 743
 						}
744
-						if ( $b instanceof NullResult ) {
744
+						if ($b instanceof NullResult) {
745 745
 							return $a instanceof NullResult ? 0 : 1;
746 746
 						}
747 747
 
748 748
 						$typeA = $a->getConstraint()->getConstraintTypeItemId();
749 749
 						$typeB = $b->getConstraint()->getConstraintTypeItemId();
750 750
 
751
-						if ( $typeA == $typeB ) {
751
+						if ($typeA == $typeB) {
752 752
 							return 0;
753 753
 						} else {
754
-							return ( $typeA > $typeB ) ? 1 : -1;
754
+							return ($typeA > $typeB) ? 1 : -1;
755 755
 						}
756 756
 					} else {
757
-						return ( $hashA > $hashB ) ? 1 : -1;
757
+						return ($hashA > $hashB) ? 1 : -1;
758 758
 					}
759 759
 				} else {
760
-					return ( $pidA > $pidB ) ? 1 : -1;
760
+					return ($pidA > $pidB) ? 1 : -1;
761 761
 				}
762 762
 			} else {
763
-				return ( $orderA > $orderB ) ? 1 : -1;
763
+				return ($orderA > $orderB) ? 1 : -1;
764 764
 			}
765 765
 		};
766 766
 
767
-		uasort( $result, $sortFunction );
767
+		uasort($result, $sortFunction);
768 768
 
769 769
 		return $result;
770 770
 	}
Please login to merge, or discard this patch.