Completed
Push — master ( 6a30d5...22bc4b )
by
unknown
01:53
created
src/ConstraintCheckerServices.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -40,243 +40,243 @@
 block discarded – undo
40 40
 	const PROPERTY_SCOPE_CHECKER = 'WBQC_PropertyScopeChecker';
41 41
 	const CONTEMPORARY_CHECKER = 'WBQC_ContemporaryChecker';
42 42
 
43
-	private static function getService( ?MediaWikiServices $services, $name ) {
44
-		if ( $services === null ) {
43
+	private static function getService(?MediaWikiServices $services, $name) {
44
+		if ($services === null) {
45 45
 			$services = MediaWikiServices::getInstance();
46 46
 		}
47
-		return $services->getService( $name );
47
+		return $services->getService($name);
48 48
 	}
49 49
 
50 50
 	/**
51 51
 	 * @param MediaWikiServices|null $services
52 52
 	 * @return ConstraintChecker
53 53
 	 */
54
-	public static function getConflictsWithChecker( MediaWikiServices $services = null ) {
55
-		return self::getService( $services, self::CONFLICTS_WITH_CHECKER );
54
+	public static function getConflictsWithChecker(MediaWikiServices $services = null) {
55
+		return self::getService($services, self::CONFLICTS_WITH_CHECKER);
56 56
 	}
57 57
 
58 58
 	/**
59 59
 	 * @param MediaWikiServices|null $services
60 60
 	 * @return ConstraintChecker
61 61
 	 */
62
-	public static function getItemChecker( MediaWikiServices $services = null ) {
63
-		return self::getService( $services, self::ITEM_CHECKER );
62
+	public static function getItemChecker(MediaWikiServices $services = null) {
63
+		return self::getService($services, self::ITEM_CHECKER);
64 64
 	}
65 65
 
66 66
 	/**
67 67
 	 * @param MediaWikiServices|null $services
68 68
 	 * @return ConstraintChecker
69 69
 	 */
70
-	public static function getTargetRequiredClaimChecker( MediaWikiServices $services = null ) {
71
-		return self::getService( $services, self::TARGET_REQUIRED_CLAIM_CHECKER );
70
+	public static function getTargetRequiredClaimChecker(MediaWikiServices $services = null) {
71
+		return self::getService($services, self::TARGET_REQUIRED_CLAIM_CHECKER);
72 72
 	}
73 73
 
74 74
 	/**
75 75
 	 * @param MediaWikiServices|null $services
76 76
 	 * @return ConstraintChecker
77 77
 	 */
78
-	public static function getSymmetricChecker( MediaWikiServices $services = null ) {
79
-		return self::getService( $services, self::SYMMETRIC_CHECKER );
78
+	public static function getSymmetricChecker(MediaWikiServices $services = null) {
79
+		return self::getService($services, self::SYMMETRIC_CHECKER);
80 80
 	}
81 81
 
82 82
 	/**
83 83
 	 * @param MediaWikiServices|null $services
84 84
 	 * @return ConstraintChecker
85 85
 	 */
86
-	public static function getInverseChecker( MediaWikiServices $services = null ) {
87
-		return self::getService( $services, self::INVERSE_CHECKER );
86
+	public static function getInverseChecker(MediaWikiServices $services = null) {
87
+		return self::getService($services, self::INVERSE_CHECKER);
88 88
 	}
89 89
 
90 90
 	/**
91 91
 	 * @param MediaWikiServices|null $services
92 92
 	 * @return ConstraintChecker
93 93
 	 */
94
-	public static function getQualifierChecker( MediaWikiServices $services = null ) {
95
-		return self::getService( $services, self::QUALIFIER_CHECKER );
94
+	public static function getQualifierChecker(MediaWikiServices $services = null) {
95
+		return self::getService($services, self::QUALIFIER_CHECKER);
96 96
 	}
97 97
 
98 98
 	/**
99 99
 	 * @param MediaWikiServices|null $services
100 100
 	 * @return ConstraintChecker
101 101
 	 */
102
-	public static function getQualifiersChecker( MediaWikiServices $services = null ) {
103
-		return self::getService( $services, self::QUALIFIERS_CHECKER );
102
+	public static function getQualifiersChecker(MediaWikiServices $services = null) {
103
+		return self::getService($services, self::QUALIFIERS_CHECKER);
104 104
 	}
105 105
 
106 106
 	/**
107 107
 	 * @param MediaWikiServices|null $services
108 108
 	 * @return ConstraintChecker
109 109
 	 */
110
-	public static function getMandatoryQualifiersChecker( MediaWikiServices $services = null ) {
111
-		return self::getService( $services, self::MANDATORY_QUALIFIERS_CHECKER );
110
+	public static function getMandatoryQualifiersChecker(MediaWikiServices $services = null) {
111
+		return self::getService($services, self::MANDATORY_QUALIFIERS_CHECKER);
112 112
 	}
113 113
 
114 114
 	/**
115 115
 	 * @param MediaWikiServices|null $services
116 116
 	 * @return ConstraintChecker
117 117
 	 */
118
-	public static function getRangeChecker( MediaWikiServices $services = null ) {
119
-		return self::getService( $services, self::RANGE_CHECKER );
118
+	public static function getRangeChecker(MediaWikiServices $services = null) {
119
+		return self::getService($services, self::RANGE_CHECKER);
120 120
 	}
121 121
 
122 122
 	/**
123 123
 	 * @param MediaWikiServices|null $services
124 124
 	 * @return ConstraintChecker
125 125
 	 */
126
-	public static function getDiffWithinRangeChecker( MediaWikiServices $services = null ) {
127
-		return self::getService( $services, self::DIFF_WITHIN_RANGE_CHECKER );
126
+	public static function getDiffWithinRangeChecker(MediaWikiServices $services = null) {
127
+		return self::getService($services, self::DIFF_WITHIN_RANGE_CHECKER);
128 128
 	}
129 129
 
130 130
 	/**
131 131
 	 * @param MediaWikiServices|null $services
132 132
 	 * @return ConstraintChecker
133 133
 	 */
134
-	public static function getTypeChecker( MediaWikiServices $services = null ) {
135
-		return self::getService( $services, self::TYPE_CHECKER );
134
+	public static function getTypeChecker(MediaWikiServices $services = null) {
135
+		return self::getService($services, self::TYPE_CHECKER);
136 136
 	}
137 137
 
138 138
 	/**
139 139
 	 * @param MediaWikiServices|null $services
140 140
 	 * @return ConstraintChecker
141 141
 	 */
142
-	public static function getValueTypeChecker( MediaWikiServices $services = null ) {
143
-		return self::getService( $services, self::VALUE_TYPE_CHECKER );
142
+	public static function getValueTypeChecker(MediaWikiServices $services = null) {
143
+		return self::getService($services, self::VALUE_TYPE_CHECKER);
144 144
 	}
145 145
 
146 146
 	/**
147 147
 	 * @param MediaWikiServices|null $services
148 148
 	 * @return ConstraintChecker
149 149
 	 */
150
-	public static function getSingleValueChecker( MediaWikiServices $services = null ) {
151
-		return self::getService( $services, self::SINGLE_VALUE_CHECKER );
150
+	public static function getSingleValueChecker(MediaWikiServices $services = null) {
151
+		return self::getService($services, self::SINGLE_VALUE_CHECKER);
152 152
 	}
153 153
 
154 154
 	/**
155 155
 	 * @param MediaWikiServices|null $services
156 156
 	 * @return ConstraintChecker
157 157
 	 */
158
-	public static function getMultiValueChecker( MediaWikiServices $services = null ) {
159
-		return self::getService( $services, self::MULTI_VALUE_CHECKER );
158
+	public static function getMultiValueChecker(MediaWikiServices $services = null) {
159
+		return self::getService($services, self::MULTI_VALUE_CHECKER);
160 160
 	}
161 161
 
162 162
 	/**
163 163
 	 * @param MediaWikiServices|null $services
164 164
 	 * @return ConstraintChecker
165 165
 	 */
166
-	public static function getUniqueValueChecker( MediaWikiServices $services = null ) {
167
-		return self::getService( $services, self::UNIQUE_VALUE_CHECKER );
166
+	public static function getUniqueValueChecker(MediaWikiServices $services = null) {
167
+		return self::getService($services, self::UNIQUE_VALUE_CHECKER);
168 168
 	}
169 169
 
170 170
 	/**
171 171
 	 * @param MediaWikiServices|null $services
172 172
 	 * @return ConstraintChecker
173 173
 	 */
174
-	public static function getFormatChecker( MediaWikiServices $services = null ) {
175
-		return self::getService( $services, self::FORMAT_CHECKER );
174
+	public static function getFormatChecker(MediaWikiServices $services = null) {
175
+		return self::getService($services, self::FORMAT_CHECKER);
176 176
 	}
177 177
 
178 178
 	/**
179 179
 	 * @param MediaWikiServices|null $services
180 180
 	 * @return ConstraintChecker
181 181
 	 */
182
-	public static function getCommonsLinkChecker( MediaWikiServices $services = null ) {
183
-		return self::getService( $services, self::COMMONS_LINK_CHECKER );
182
+	public static function getCommonsLinkChecker(MediaWikiServices $services = null) {
183
+		return self::getService($services, self::COMMONS_LINK_CHECKER);
184 184
 	}
185 185
 
186 186
 	/**
187 187
 	 * @param MediaWikiServices|null $services
188 188
 	 * @return ConstraintChecker
189 189
 	 */
190
-	public static function getOneOfChecker( MediaWikiServices $services = null ) {
191
-		return self::getService( $services, self::ONE_OF_CHECKER );
190
+	public static function getOneOfChecker(MediaWikiServices $services = null) {
191
+		return self::getService($services, self::ONE_OF_CHECKER);
192 192
 	}
193 193
 
194 194
 	/**
195 195
 	 * @param MediaWikiServices|null $services
196 196
 	 * @return ConstraintChecker
197 197
 	 */
198
-	public static function getValueOnlyChecker( MediaWikiServices $services = null ) {
199
-		return self::getService( $services, self::VALUE_ONLY_CHECKER );
198
+	public static function getValueOnlyChecker(MediaWikiServices $services = null) {
199
+		return self::getService($services, self::VALUE_ONLY_CHECKER);
200 200
 	}
201 201
 
202 202
 	/**
203 203
 	 * @param MediaWikiServices|null $services
204 204
 	 * @return ConstraintChecker
205 205
 	 */
206
-	public static function getReferenceChecker( MediaWikiServices $services = null ) {
207
-		return self::getService( $services, self::REFERENCE_CHECKER );
206
+	public static function getReferenceChecker(MediaWikiServices $services = null) {
207
+		return self::getService($services, self::REFERENCE_CHECKER);
208 208
 	}
209 209
 
210 210
 	/**
211 211
 	 * @param MediaWikiServices|null $services
212 212
 	 * @return ConstraintChecker
213 213
 	 */
214
-	public static function getNoBoundsChecker( MediaWikiServices $services = null ) {
215
-		return self::getService( $services, self::NO_BOUNDS_CHECKER );
214
+	public static function getNoBoundsChecker(MediaWikiServices $services = null) {
215
+		return self::getService($services, self::NO_BOUNDS_CHECKER);
216 216
 	}
217 217
 
218 218
 	/**
219 219
 	 * @param MediaWikiServices|null $services
220 220
 	 * @return ConstraintChecker
221 221
 	 */
222
-	public static function getAllowedUnitsChecker( MediaWikiServices $services = null ) {
223
-		return self::getService( $services, self::ALLOWED_UNITS_CHECKER );
222
+	public static function getAllowedUnitsChecker(MediaWikiServices $services = null) {
223
+		return self::getService($services, self::ALLOWED_UNITS_CHECKER);
224 224
 	}
225 225
 
226 226
 	/**
227 227
 	 * @param MediaWikiServices|null $services
228 228
 	 * @return ConstraintChecker
229 229
 	 */
230
-	public static function getSingleBestValueChecker( MediaWikiServices $services = null ) {
231
-		return self::getService( $services, self::SINGLE_BEST_VALUE_CHECKER );
230
+	public static function getSingleBestValueChecker(MediaWikiServices $services = null) {
231
+		return self::getService($services, self::SINGLE_BEST_VALUE_CHECKER);
232 232
 	}
233 233
 
234 234
 	/**
235 235
 	 * @param MediaWikiServices|null $services
236 236
 	 * @return ConstraintChecker
237 237
 	 */
238
-	public static function getEntityTypeChecker( MediaWikiServices $services = null ) {
239
-		return self::getService( $services, self::ENTITY_TYPE_CHECKER );
238
+	public static function getEntityTypeChecker(MediaWikiServices $services = null) {
239
+		return self::getService($services, self::ENTITY_TYPE_CHECKER);
240 240
 	}
241 241
 
242 242
 	/**
243 243
 	 * @param MediaWikiServices|null $services
244 244
 	 * @return ConstraintChecker
245 245
 	 */
246
-	public static function getNoneOfChecker( MediaWikiServices $services = null ) {
247
-		return self::getService( $services, self::NONE_OF_CHECKER );
246
+	public static function getNoneOfChecker(MediaWikiServices $services = null) {
247
+		return self::getService($services, self::NONE_OF_CHECKER);
248 248
 	}
249 249
 
250 250
 	/**
251 251
 	 * @param MediaWikiServices|null $services
252 252
 	 * @return ConstraintChecker
253 253
 	 */
254
-	public static function getIntegerChecker( MediaWikiServices $services = null ) {
255
-		return self::getService( $services, self::INTEGER_CHECKER );
254
+	public static function getIntegerChecker(MediaWikiServices $services = null) {
255
+		return self::getService($services, self::INTEGER_CHECKER);
256 256
 	}
257 257
 
258 258
 	/**
259 259
 	 * @param MediaWikiServices|null $services
260 260
 	 * @return ConstraintChecker
261 261
 	 */
262
-	public static function getCitationNeededChecker( MediaWikiServices $services = null ) {
263
-		return self::getService( $services, self::CITATION_NEEDED_CHECKER );
262
+	public static function getCitationNeededChecker(MediaWikiServices $services = null) {
263
+		return self::getService($services, self::CITATION_NEEDED_CHECKER);
264 264
 	}
265 265
 
266 266
 	/**
267 267
 	 * @param MediaWikiServices|null $services
268 268
 	 * @return ConstraintChecker
269 269
 	 */
270
-	public static function getPropertyScopeChecker( MediaWikiServices $services = null ) {
271
-		return self::getService( $services, self::PROPERTY_SCOPE_CHECKER );
270
+	public static function getPropertyScopeChecker(MediaWikiServices $services = null) {
271
+		return self::getService($services, self::PROPERTY_SCOPE_CHECKER);
272 272
 	}
273 273
 
274 274
 	/**
275 275
 	 * @param MediaWikiServices|null $services
276 276
 	 * @return ConstraintChecker
277 277
 	 */
278
-	public static function getContemporaryChecker( MediaWikiServices $services = null ) {
279
-		return self::getService( $services, self::CONTEMPORARY_CHECKER );
278
+	public static function getContemporaryChecker(MediaWikiServices $services = null) {
279
+		return self::getService($services, self::CONTEMPORARY_CHECKER);
280 280
 	}
281 281
 
282 282
 }
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
@@ -38,90 +38,90 @@
 block discarded – undo
38 38
 	const RESULTS_SOURCE = 'WBQC_ResultsSource';
39 39
 	const EXPIRY_LOCK = 'WBQC_ExpiryLock';
40 40
 
41
-	private static function getService( ?MediaWikiServices $services, $name ) {
42
-		if ( $services === null ) {
41
+	private static function getService(?MediaWikiServices $services, $name) {
42
+		if ($services === null) {
43 43
 			$services = MediaWikiServices::getInstance();
44 44
 		}
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 getConstraintRepository(
53 53
 		MediaWikiServices $services = null
54 54
 	): ConstraintRepository {
55
-		return self::getService( $services, self::CONSTRAINT_REPOSITORY );
55
+		return self::getService($services, self::CONSTRAINT_REPOSITORY);
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 120
 	/**
121 121
 	 * @return ExpiryLock
122 122
 	 */
123
-	public static function getExpiryLock( MediaWikiServices $services = null ) {
124
-		return self::getService( $services, self::EXPIRY_LOCK );
123
+	public static function getExpiryLock(MediaWikiServices $services = null) {
124
+		return self::getService($services, self::EXPIRY_LOCK);
125 125
 	}
126 126
 
127 127
 }
Please login to merge, or discard this patch.
src/Api/CachingResultsSource.php 1 patch
Spacing   +77 added lines, -78 removed lines patch added patch discarded remove patch
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
 	) {
144 144
 		$results = [];
145 145
 		$metadatas = [];
146
-		if ( $this->canUseStoredResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
146
+		if ($this->canUseStoredResults($entityIds, $claimIds, $constraintIds, $statuses)) {
147 147
 			$storedEntityIds = [];
148
-			foreach ( $entityIds as $entityId ) {
149
-				$storedResults = $this->getStoredResults( $entityId );
150
-				if ( $storedResults !== null ) {
151
-					$this->loggingHelper->logCheckConstraintsCacheHit( $entityId );
152
-					foreach ( $storedResults->getArray() as $checkResult ) {
153
-						if ( $this->statusSelected( $statuses, $checkResult ) ) {
148
+			foreach ($entityIds as $entityId) {
149
+				$storedResults = $this->getStoredResults($entityId);
150
+				if ($storedResults !== null) {
151
+					$this->loggingHelper->logCheckConstraintsCacheHit($entityId);
152
+					foreach ($storedResults->getArray() as $checkResult) {
153
+						if ($this->statusSelected($statuses, $checkResult)) {
154 154
 							$results[] = $checkResult;
155 155
 						}
156 156
 					}
@@ -158,19 +158,19 @@  discard block
 block discarded – undo
158 158
 					$storedEntityIds[] = $entityId;
159 159
 				}
160 160
 			}
161
-			$entityIds = array_values( array_diff( $entityIds, $storedEntityIds ) );
161
+			$entityIds = array_values(array_diff($entityIds, $storedEntityIds));
162 162
 		}
163
-		if ( $entityIds !== [] || $claimIds !== [] ) {
164
-			if ( $entityIds !== [] ) {
165
-				$this->loggingHelper->logCheckConstraintsCacheMisses( $entityIds );
163
+		if ($entityIds !== [] || $claimIds !== []) {
164
+			if ($entityIds !== []) {
165
+				$this->loggingHelper->logCheckConstraintsCacheMisses($entityIds);
166 166
 			}
167
-			$response = $this->getAndStoreResults( $entityIds, $claimIds, $constraintIds, $statuses );
168
-			$results = array_merge( $results, $response->getArray() );
167
+			$response = $this->getAndStoreResults($entityIds, $claimIds, $constraintIds, $statuses);
168
+			$results = array_merge($results, $response->getArray());
169 169
 			$metadatas[] = $response->getMetadata();
170 170
 		}
171 171
 		return new CachedCheckResults(
172 172
 			$results,
173
-			Metadata::merge( $metadatas )
173
+			Metadata::merge($metadatas)
174 174
 		);
175 175
 	}
176 176
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 		?array $constraintIds,
194 194
 		array $statuses
195 195
 	) {
196
-		if ( $claimIds !== [] ) {
196
+		if ($claimIds !== []) {
197 197
 			return false;
198 198
 		}
199
-		if ( $constraintIds !== null ) {
199
+		if ($constraintIds !== null) {
200 200
 			return false;
201 201
 		}
202
-		if ( array_diff( $statuses, self::CACHED_STATUSES ) !== [] ) {
202
+		if (array_diff($statuses, self::CACHED_STATUSES) !== []) {
203 203
 			return false;
204 204
 		}
205 205
 		return true;
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 * @param CheckResult $result
215 215
 	 * @return bool
216 216
 	 */
217
-	private function statusSelected( array $statuses, CheckResult $result ) {
218
-		return in_array( $result->getStatus(), $statuses, true ) ||
217
+	private function statusSelected(array $statuses, CheckResult $result) {
218
+		return in_array($result->getStatus(), $statuses, true) ||
219 219
 			$result instanceof NullResult;
220 220
 	}
221 221
 
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
 		?array $constraintIds,
233 233
 		array $statuses
234 234
 	) {
235
-		$results = $this->resultsSource->getResults( $entityIds, $claimIds, $constraintIds, $statuses );
235
+		$results = $this->resultsSource->getResults($entityIds, $claimIds, $constraintIds, $statuses);
236 236
 
237
-		if ( $this->canStoreResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) {
238
-			foreach ( $entityIds as $entityId ) {
239
-				$this->storeResults( $entityId, $results );
237
+		if ($this->canStoreResults($entityIds, $claimIds, $constraintIds, $statuses)) {
238
+			foreach ($entityIds as $entityId) {
239
+				$this->storeResults($entityId, $results);
240 240
 			}
241 241
 		}
242 242
 
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 		?array $constraintIds,
268 268
 		array $statuses
269 269
 	) {
270
-		if ( $constraintIds !== null ) {
270
+		if ($constraintIds !== null) {
271 271
 			return false;
272 272
 		}
273
-		if ( array_diff( self::CACHED_STATUSES, $statuses ) !== [] ) {
273
+		if (array_diff(self::CACHED_STATUSES, $statuses) !== []) {
274 274
 			return false;
275 275
 		}
276 276
 		return true;
@@ -284,21 +284,21 @@  discard block
 block discarded – undo
284 284
 	 * May include check results for other entity IDs as well,
285 285
 	 * or check results with statuses that we’re not interested in caching.
286 286
 	 */
287
-	private function storeResults( EntityId $entityId, CachedCheckResults $results ) {
287
+	private function storeResults(EntityId $entityId, CachedCheckResults $results) {
288 288
 		$latestRevisionIds = $this->getLatestRevisionIds(
289 289
 			$results->getMetadata()->getDependencyMetadata()->getEntityIds()
290 290
 		);
291
-		if ( $latestRevisionIds === null ) {
291
+		if ($latestRevisionIds === null) {
292 292
 			return;
293 293
 		}
294 294
 
295 295
 		$resultSerializations = [];
296
-		foreach ( $results->getArray() as $checkResult ) {
297
-			if ( $checkResult->getContextCursor()->getEntityId() !== $entityId->getSerialization() ) {
296
+		foreach ($results->getArray() as $checkResult) {
297
+			if ($checkResult->getContextCursor()->getEntityId() !== $entityId->getSerialization()) {
298 298
 				continue;
299 299
 			}
300
-			if ( $this->statusSelected( self::CACHED_STATUSES, $checkResult ) ) {
301
-				$resultSerializations[] = $this->checkResultSerializer->serialize( $checkResult );
300
+			if ($this->statusSelected(self::CACHED_STATUSES, $checkResult)) {
301
+				$resultSerializations[] = $this->checkResultSerializer->serialize($checkResult);
302 302
 			}
303 303
 		}
304 304
 
@@ -307,11 +307,11 @@  discard block
 block discarded – undo
307 307
 			'latestRevisionIds' => $latestRevisionIds,
308 308
 		];
309 309
 		$futureTime = $results->getMetadata()->getDependencyMetadata()->getFutureTime();
310
-		if ( $futureTime !== null ) {
310
+		if ($futureTime !== null) {
311 311
 			$value['futureTime'] = $futureTime->getArrayValue();
312 312
 		}
313 313
 
314
-		$this->cache->set( $entityId, $value, $this->ttlInSeconds );
314
+		$this->cache->set($entityId, $value, $this->ttlInSeconds);
315 315
 	}
316 316
 
317 317
 	/**
@@ -325,31 +325,30 @@  discard block
 block discarded – undo
325 325
 		EntityId $entityId,
326 326
 		$forRevision = 0
327 327
 	) {
328
-		$value = $this->cache->get( $entityId, $curTTL, [], $asOf );
329
-		$now = call_user_func( $this->microtime, true );
328
+		$value = $this->cache->get($entityId, $curTTL, [], $asOf);
329
+		$now = call_user_func($this->microtime, true);
330 330
 
331
-		$dependencyMetadata = $this->checkDependencyMetadata( $value,
332
-			[ $entityId->getSerialization() => $forRevision ] );
333
-		if ( $dependencyMetadata === null ) {
331
+		$dependencyMetadata = $this->checkDependencyMetadata($value,
332
+			[$entityId->getSerialization() => $forRevision]);
333
+		if ($dependencyMetadata === null) {
334 334
 			return null;
335 335
 		}
336 336
 
337
-		$ageInSeconds = (int)ceil( $now - $asOf );
337
+		$ageInSeconds = (int) ceil($now - $asOf);
338 338
 		$cachingMetadata = $ageInSeconds > 0 ?
339
-			CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) :
340
-			CachingMetadata::fresh();
339
+			CachingMetadata::ofMaximumAgeInSeconds($ageInSeconds) : CachingMetadata::fresh();
341 340
 
342 341
 		$results = [];
343
-		foreach ( $value['results'] as $resultSerialization ) {
344
-			$results[] = $this->deserializeCheckResult( $resultSerialization, $cachingMetadata );
342
+		foreach ($value['results'] as $resultSerialization) {
343
+			$results[] = $this->deserializeCheckResult($resultSerialization, $cachingMetadata);
345 344
 		}
346 345
 
347 346
 		return new CachedCheckResults(
348 347
 			$results,
349
-			Metadata::merge( [
350
-				Metadata::ofCachingMetadata( $cachingMetadata ),
351
-				Metadata::ofDependencyMetadata( $dependencyMetadata ),
352
-			] )
348
+			Metadata::merge([
349
+				Metadata::ofCachingMetadata($cachingMetadata),
350
+				Metadata::ofDependencyMetadata($dependencyMetadata),
351
+			])
353 352
 		);
354 353
 	}
355 354
 
@@ -365,43 +364,43 @@  discard block
 block discarded – undo
365 364
 	 * @return DependencyMetadata|null the dependency metadata,
366 365
 	 * or null if $value should no longer be used
367 366
 	 */
368
-	private function checkDependencyMetadata( $value, $paramRevs ) {
369
-		if ( $value === false ) {
367
+	private function checkDependencyMetadata($value, $paramRevs) {
368
+		if ($value === false) {
370 369
 			return null;
371 370
 		}
372 371
 
373
-		if ( array_key_exists( 'futureTime', $value ) ) {
374
-			$futureTime = TimeValue::newFromArray( $value['futureTime'] );
375
-			if ( !$this->timeValueComparer->isFutureTime( $futureTime ) ) {
372
+		if (array_key_exists('futureTime', $value)) {
373
+			$futureTime = TimeValue::newFromArray($value['futureTime']);
374
+			if (!$this->timeValueComparer->isFutureTime($futureTime)) {
376 375
 				return null;
377 376
 			}
378
-			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime( $futureTime );
377
+			$futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime($futureTime);
379 378
 		} else {
380 379
 			$futureTimeDependencyMetadata = DependencyMetadata::blank();
381 380
 		}
382 381
 
383
-		foreach ( $paramRevs as $id => $revision ) {
384
-			if ( $revision > 0 ) {
385
-				$value['latestRevisionIds'][$id] = min( $revision, $value['latestRevisionIds'][$id] ?? PHP_INT_MAX );
382
+		foreach ($paramRevs as $id => $revision) {
383
+			if ($revision > 0) {
384
+				$value['latestRevisionIds'][$id] = min($revision, $value['latestRevisionIds'][$id] ?? PHP_INT_MAX);
386 385
 			}
387 386
 		}
388 387
 
389 388
 		$dependedEntityIds = array_map(
390
-			[ $this->entityIdParser, "parse" ],
391
-			array_keys( $value['latestRevisionIds'] )
389
+			[$this->entityIdParser, "parse"],
390
+			array_keys($value['latestRevisionIds'])
392 391
 		);
393 392
 
394
-		if ( $value['latestRevisionIds'] !== $this->getLatestRevisionIds( $dependedEntityIds ) ) {
393
+		if ($value['latestRevisionIds'] !== $this->getLatestRevisionIds($dependedEntityIds)) {
395 394
 			return null;
396 395
 		}
397 396
 
398 397
 		return array_reduce(
399 398
 			$dependedEntityIds,
400
-			function( DependencyMetadata $metadata, EntityId $entityId ) {
401
-				return DependencyMetadata::merge( [
399
+			function(DependencyMetadata $metadata, EntityId $entityId) {
400
+				return DependencyMetadata::merge([
402 401
 					$metadata,
403
-					DependencyMetadata::ofEntityId( $entityId )
404
-				] );
402
+					DependencyMetadata::ofEntityId($entityId)
403
+				]);
405 404
 			},
406 405
 			$futureTimeDependencyMetadata
407 406
 		);
@@ -421,13 +420,13 @@  discard block
 block discarded – undo
421 420
 		array $resultSerialization,
422 421
 		CachingMetadata $cachingMetadata
423 422
 	) {
424
-		$result = $this->checkResultDeserializer->deserialize( $resultSerialization );
425
-		if ( $this->isPossiblyStaleResult( $result ) ) {
423
+		$result = $this->checkResultDeserializer->deserialize($resultSerialization);
424
+		if ($this->isPossiblyStaleResult($result)) {
426 425
 			$result->withMetadata(
427
-				Metadata::merge( [
426
+				Metadata::merge([
428 427
 					$result->getMetadata(),
429
-					Metadata::ofCachingMetadata( $cachingMetadata ),
430
-				] )
428
+					Metadata::ofCachingMetadata($cachingMetadata),
429
+				])
431 430
 			);
432 431
 		}
433 432
 		return $result;
@@ -437,8 +436,8 @@  discard block
 block discarded – undo
437 436
 	 * @param CheckResult $result
438 437
 	 * @return bool
439 438
 	 */
440
-	private function isPossiblyStaleResult( CheckResult $result ) {
441
-		if ( $result instanceof NullResult ) {
439
+	private function isPossiblyStaleResult(CheckResult $result) {
440
+		if ($result instanceof NullResult) {
442 441
 			return false;
443 442
 		}
444 443
 
@@ -453,14 +452,14 @@  discard block
 block discarded – undo
453 452
 	 * @return int[]|null array from entity ID serializations to revision ID,
454 453
 	 * or null to indicate that not all revision IDs could be loaded
455 454
 	 */
456
-	private function getLatestRevisionIds( array $entityIds ) {
457
-		if ( $entityIds === [] ) {
455
+	private function getLatestRevisionIds(array $entityIds) {
456
+		if ($entityIds === []) {
458 457
 			$this->loggingHelper->logEmptyDependencyMetadata();
459 458
 			return [];
460 459
 		}
461
-		if ( count( $entityIds ) > $this->maxRevisionIds ) {
460
+		if (count($entityIds) > $this->maxRevisionIds) {
462 461
 			// one of those entities will probably be edited soon, so might as well skip caching
463
-			$this->loggingHelper->logHugeDependencyMetadata( $entityIds, $this->maxRevisionIds );
462
+			$this->loggingHelper->logHugeDependencyMetadata($entityIds, $this->maxRevisionIds);
464 463
 			return null;
465 464
 		}
466 465
 
@@ -468,7 +467,7 @@  discard block
 block discarded – undo
468 467
 			$entityIds,
469 468
 			EntityRevisionLookup::LATEST_FROM_REPLICA
470 469
 		);
471
-		if ( $this->hasFalseElements( $latestRevisionIds ) ) {
470
+		if ($this->hasFalseElements($latestRevisionIds)) {
472 471
 			return null;
473 472
 		}
474 473
 		return $latestRevisionIds;
@@ -478,8 +477,8 @@  discard block
 block discarded – undo
478 477
 	 * @param array $array
479 478
 	 * @return bool
480 479
 	 */
481
-	private function hasFalseElements( array $array ) {
482
-		return in_array( false, $array, true );
480
+	private function hasFalseElements(array $array) {
481
+		return in_array(false, $array, true);
483 482
 	}
484 483
 
485 484
 	/**
@@ -487,7 +486,7 @@  discard block
 block discarded – undo
487 486
 	 *
488 487
 	 * @param callable $microtime
489 488
 	 */
490
-	public function setMicrotimeFunction( callable $microtime ) {
489
+	public function setMicrotimeFunction(callable $microtime) {
491 490
 		$this->microtime = $microtime;
492 491
 	}
493 492
 
Please login to merge, or discard this patch.
src/ConstraintCheck/ItemIdSnakValue.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param ItemId $itemId
45 45
 	 * @return self
46 46
 	 */
47
-	public static function fromItemId( ItemId $itemId ) {
47
+	public static function fromItemId(ItemId $itemId) {
48 48
 		$ret = new self;
49 49
 		$ret->itemId = $itemId;
50 50
 		return $ret;
@@ -80,14 +80,14 @@  discard block
 block discarded – undo
80 80
 	 * @throws InvalidArgumentException
81 81
 	 * @return self
82 82
 	 */
83
-	public static function fromSnak( Snak $snak ) {
84
-		switch ( true ) {
83
+	public static function fromSnak(Snak $snak) {
84
+		switch (true) {
85 85
 			case $snak instanceof PropertyValueSnak:
86 86
 				$dataValue = $snak->getDataValue();
87
-				if ( $dataValue instanceof EntityIdValue ) {
87
+				if ($dataValue instanceof EntityIdValue) {
88 88
 					$itemId = $dataValue->getEntityId();
89
-					if ( $itemId instanceof ItemId ) {
90
-						return self::fromItemId( $itemId );
89
+					if ($itemId instanceof ItemId) {
90
+						return self::fromItemId($itemId);
91 91
 					}
92 92
 				}
93 93
 				break;
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 				return self::noValue();
98 98
 		}
99 99
 
100
-		throw new InvalidArgumentException( 'Snak must contain item ID value or be a somevalue / novalue snak' );
100
+		throw new InvalidArgumentException('Snak must contain item ID value or be a somevalue / novalue snak');
101 101
 	}
102 102
 
103 103
 	/**
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 * @return ItemId
136 136
 	 */
137 137
 	public function getItemId() {
138
-		if ( !$this->isValue() ) {
139
-			throw new DomainException( 'This value does not contain an item ID.' );
138
+		if (!$this->isValue()) {
139
+			throw new DomainException('This value does not contain an item ID.');
140 140
 		}
141 141
 		return $this->itemId;
142 142
 	}
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 	 * @param Snak $snak
149 149
 	 * @return bool
150 150
 	 */
151
-	public function matchesSnak( Snak $snak ) {
152
-		switch ( true ) {
151
+	public function matchesSnak(Snak $snak) {
152
+		switch (true) {
153 153
 			case $snak instanceof PropertyValueSnak:
154 154
 				$dataValue = $snak->getDataValue();
155 155
 				return $this->isValue() &&
156 156
 					$dataValue instanceof EntityIdValue &&
157 157
 					$dataValue->getEntityId() instanceof ItemId &&
158
-					$dataValue->getEntityId()->equals( $this->getItemId() );
158
+					$dataValue->getEntityId()->equals($this->getItemId());
159 159
 			case $snak instanceof PropertySomeValueSnak:
160 160
 				return $this->isSomeValue();
161 161
 			case $snak instanceof PropertyNoValueSnak:
Please login to merge, or discard this patch.
src/Job/CheckConstraintsJob.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -37,25 +37,25 @@  discard block
 block discarded – undo
37 37
 	 * @param Title $title
38 38
 	 * @param string[] $params should contain 'entityId' => 'Q1234'
39 39
 	 */
40
-	public function __construct( Title $title, array $params ) {
41
-		parent::__construct( self::COMMAND, $title, $params );
40
+	public function __construct(Title $title, array $params) {
41
+		parent::__construct(self::COMMAND, $title, $params);
42 42
 		$this->removeDuplicates = true;
43 43
 
44
-		Assert::parameterType( 'string', $params['entityId'], '$params[\'entityId\']' );
44
+		Assert::parameterType('string', $params['entityId'], '$params[\'entityId\']');
45 45
 
46
-		$resultSource = ConstraintsServices::getResultsSource( MediaWikiServices::getInstance() );
46
+		$resultSource = ConstraintsServices::getResultsSource(MediaWikiServices::getInstance());
47 47
 		'@phan-var CachingResultsSource $resultSource';
48 48
 		// This job should only ever be used when caching result sources are used.
49
-		$this->setResultsSource( $resultSource );
49
+		$this->setResultsSource($resultSource);
50 50
 
51
-		$this->setEntityIdParser( WikibaseRepo::getDefaultInstance()->getEntityIdParser() );
51
+		$this->setEntityIdParser(WikibaseRepo::getDefaultInstance()->getEntityIdParser());
52 52
 	}
53 53
 
54
-	public function setResultsSource( CachingResultsSource $resultsSource ) {
54
+	public function setResultsSource(CachingResultsSource $resultsSource) {
55 55
 		$this->resultsSource = $resultsSource;
56 56
 	}
57 57
 
58
-	public function setEntityIdParser( EntityIdParser $parser ) {
58
+	public function setEntityIdParser(EntityIdParser $parser) {
59 59
 		$this->entityIdParser = $parser;
60 60
 	}
61 61
 
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function run() {
68 68
 		try {
69
-			$entityId = $this->entityIdParser->parse( $this->params['entityId'] );
70
-		} catch ( EntityIdParsingException $e ) {
69
+			$entityId = $this->entityIdParser->parse($this->params['entityId']);
70
+		} catch (EntityIdParsingException $e) {
71 71
 			return false;
72 72
 		}
73 73
 
74
-		$this->checkConstraints( $entityId );
74
+		$this->checkConstraints($entityId);
75 75
 
76 76
 		return true;
77 77
 	}
78 78
 
79
-	private function checkConstraints( EntityId $entityId ) {
79
+	private function checkConstraints(EntityId $entityId) {
80 80
 		$this->resultsSource->getResults(
81
-			[ $entityId ],
81
+			[$entityId],
82 82
 			[],
83 83
 			null,
84 84
 			[]
Please login to merge, or discard this patch.
src/Job/UpdateConstraintsTableJob.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 
29 29
 	const BATCH_SIZE = 10;
30 30
 
31
-	public static function newFromGlobalState( Title $title, array $params ) {
32
-		Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' );
31
+	public static function newFromGlobalState(Title $title, array $params) {
32
+		Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]');
33 33
 		$repo = WikibaseRepo::getDefaultInstance();
34 34
 		return new UpdateConstraintsTableJob(
35 35
 			$title,
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 			$params['revisionId'] ?? null,
39 39
 			MediaWikiServices::getInstance()->getMainConfig(),
40 40
 			ConstraintsServices::getConstraintRepository(),
41
-			$repo->getEntityRevisionLookup( Store::LOOKUP_CACHING_DISABLED ),
41
+			$repo->getEntityRevisionLookup(Store::LOOKUP_CACHING_DISABLED),
42 42
 			$repo->getBaseDataModelSerializerFactory()->newSnakSerializer()
43 43
 		);
44 44
 	}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		EntityRevisionLookup $entityRevisionLookup,
94 94
 		Serializer $snakSerializer
95 95
 	) {
96
-		parent::__construct( 'constraintsTableUpdate', $title, $params );
96
+		parent::__construct('constraintsTableUpdate', $title, $params);
97 97
 
98 98
 		$this->propertyId = $propertyId;
99 99
 		$this->revisionId = $revisionId;
@@ -103,11 +103,11 @@  discard block
 block discarded – undo
103 103
 		$this->snakSerializer = $snakSerializer;
104 104
 	}
105 105
 
106
-	public function extractParametersFromQualifiers( SnakList $qualifiers ) {
106
+	public function extractParametersFromQualifiers(SnakList $qualifiers) {
107 107
 		$parameters = [];
108
-		foreach ( $qualifiers as $qualifier ) {
108
+		foreach ($qualifiers as $qualifier) {
109 109
 			$qualifierId = $qualifier->getPropertyId()->getSerialization();
110
-			$paramSerialization = $this->snakSerializer->serialize( $qualifier );
110
+			$paramSerialization = $this->snakSerializer->serialize($qualifier);
111 111
 			$parameters[$qualifierId][] = $paramSerialization;
112 112
 		}
113 113
 		return $parameters;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		'@phan-var \Wikibase\DataModel\Entity\EntityIdValue $dataValue';
125 125
 		$entityId = $dataValue->getEntityId();
126 126
 		$constraintTypeQid = $entityId->getSerialization();
127
-		$parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() );
127
+		$parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers());
128 128
 		return new Constraint(
129 129
 			$constraintId,
130 130
 			$propertyId,
@@ -139,17 +139,17 @@  discard block
 block discarded – undo
139 139
 		PropertyId $propertyConstraintPropertyId
140 140
 	) {
141 141
 		$constraintsStatements = $property->getStatements()
142
-			->getByPropertyId( $propertyConstraintPropertyId )
143
-			->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] );
142
+			->getByPropertyId($propertyConstraintPropertyId)
143
+			->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]);
144 144
 		$constraints = [];
145
-		foreach ( $constraintsStatements->getIterator() as $constraintStatement ) {
146
-			$constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement );
147
-			if ( count( $constraints ) >= self::BATCH_SIZE ) {
148
-				$constraintRepo->insertBatch( $constraints );
145
+		foreach ($constraintsStatements->getIterator() as $constraintStatement) {
146
+			$constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement);
147
+			if (count($constraints) >= self::BATCH_SIZE) {
148
+				$constraintRepo->insertBatch($constraints);
149 149
 				$constraints = [];
150 150
 			}
151 151
 		}
152
-		$constraintRepo->insertBatch( $constraints );
152
+		$constraintRepo->insertBatch($constraints);
153 153
 	}
154 154
 
155 155
 	/**
@@ -160,19 +160,19 @@  discard block
 block discarded – undo
160 160
 	public function run() {
161 161
 		// TODO in the future: only touch constraints affected by the edit (requires T163465)
162 162
 
163
-		$propertyId = new PropertyId( $this->propertyId );
163
+		$propertyId = new PropertyId($this->propertyId);
164 164
 		$propertyRevision = $this->entityRevisionLookup->getEntityRevision(
165 165
 			$propertyId,
166 166
 			0, // latest
167 167
 			EntityRevisionLookup::LATEST_FROM_REPLICA
168 168
 		);
169 169
 
170
-		if ( $this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId ) {
171
-			JobQueueGroup::singleton()->push( $this );
170
+		if ($this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId) {
171
+			JobQueueGroup::singleton()->push($this);
172 172
 			return true;
173 173
 		}
174 174
 
175
-		$this->constraintRepo->deleteForProperty( $propertyId );
175
+		$this->constraintRepo->deleteForProperty($propertyId);
176 176
 
177 177
 		/** @var Property $property */
178 178
 		$property = $propertyRevision->getEntity();
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		$this->importConstraintsForProperty(
181 181
 			$property,
182 182
 			$this->constraintRepo,
183
-			new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) )
183
+			new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId'))
184 184
 		);
185 185
 
186 186
 		return true;
Please login to merge, or discard this patch.
src/ConstraintRepository.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	/** @var string|false */
22 22
 	private $dbName;
23 23
 
24
-	public function __construct( ILoadBalancer $lb, $dbName ) {
24
+	public function __construct(ILoadBalancer $lb, $dbName) {
25 25
 		$this->lb = $lb;
26 26
 		$this->dbName = $dbName;
27 27
 	}
@@ -31,27 +31,27 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @return Constraint[]
33 33
 	 */
34
-	public function queryConstraintsForProperty( PropertyId $propertyId ) {
35
-		$dbr = $this->lb->getConnection( ILoadBalancer::DB_REPLICA, [], $this->dbName );
34
+	public function queryConstraintsForProperty(PropertyId $propertyId) {
35
+		$dbr = $this->lb->getConnection(ILoadBalancer::DB_REPLICA, [], $this->dbName);
36 36
 
37 37
 		$results = $dbr->select(
38 38
 			'wbqc_constraints',
39 39
 			'*',
40
-			[ 'pid' => $propertyId->getNumericId() ]
40
+			['pid' => $propertyId->getNumericId()]
41 41
 		);
42 42
 
43
-		if ( $this->dbName !== false ) {
44
-			$this->lb->reuseConnection( $dbr );
43
+		if ($this->dbName !== false) {
44
+			$this->lb->reuseConnection($dbr);
45 45
 		}
46 46
 
47
-		return $this->convertToConstraints( $results );
47
+		return $this->convertToConstraints($results);
48 48
 	}
49 49
 
50
-	private function encodeConstraintParameters( array $constraintParameters ) {
51
-		$json = json_encode( $constraintParameters, JSON_FORCE_OBJECT );
50
+	private function encodeConstraintParameters(array $constraintParameters) {
51
+		$json = json_encode($constraintParameters, JSON_FORCE_OBJECT);
52 52
 
53
-		if ( strlen( $json ) > 50000 ) {
54
-			$json = json_encode( [ '@error' => [ 'toolong' => true ] ] );
53
+		if (strlen($json) > 50000) {
54
+			$json = json_encode(['@error' => ['toolong' => true]]);
55 55
 		}
56 56
 
57 57
 		return $json;
@@ -63,25 +63,25 @@  discard block
 block discarded – undo
63 63
 	 * @throws DBUnexpectedError
64 64
 	 * @return bool
65 65
 	 */
66
-	public function insertBatch( array $constraints ) {
67
-		if ( $this->dbName !== false ) {
68
-			throw new LogicException( __METHOD__ . ' should not be called when constraints defined in non-local database.' );
66
+	public function insertBatch(array $constraints) {
67
+		if ($this->dbName !== false) {
68
+			throw new LogicException(__METHOD__.' should not be called when constraints defined in non-local database.');
69 69
 		}
70 70
 
71 71
 		$accumulator = array_map(
72
-			function ( Constraint $constraint ) {
72
+			function(Constraint $constraint) {
73 73
 				return [
74 74
 					'constraint_guid' => $constraint->getConstraintId(),
75 75
 					'pid' => $constraint->getPropertyId()->getNumericId(),
76 76
 					'constraint_type_qid' => $constraint->getConstraintTypeItemId(),
77
-					'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() )
77
+					'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters())
78 78
 				];
79 79
 			},
80 80
 			$constraints
81 81
 		);
82 82
 
83
-		$dbw = $this->lb->getConnection( ILoadBalancer::DB_MASTER );
84
-		return $dbw->insert( 'wbqc_constraints', $accumulator );
83
+		$dbw = $this->lb->getConnection(ILoadBalancer::DB_MASTER);
84
+		return $dbw->insert('wbqc_constraints', $accumulator);
85 85
 	}
86 86
 
87 87
 	/**
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @throws DBUnexpectedError
93 93
 	 */
94
-	public function deleteForProperty( PropertyId $propertyId ) {
95
-		if ( $this->dbName !== false ) {
96
-			throw new LogicException( __METHOD__ . ' should not be called when constraints defined in non-local database.' );
94
+	public function deleteForProperty(PropertyId $propertyId) {
95
+		if ($this->dbName !== false) {
96
+			throw new LogicException(__METHOD__.' should not be called when constraints defined in non-local database.');
97 97
 		}
98 98
 
99
-		$dbw = $this->lb->getConnection( ILoadBalancer::DB_MASTER );
99
+		$dbw = $this->lb->getConnection(ILoadBalancer::DB_MASTER);
100 100
 		$dbw->delete(
101 101
 			'wbqc_constraints',
102 102
 			[
@@ -110,26 +110,26 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return Constraint[]
112 112
 	 */
113
-	private function convertToConstraints( IResultWrapper $results ) {
113
+	private function convertToConstraints(IResultWrapper $results) {
114 114
 		$constraints = [];
115
-		foreach ( $results as $result ) {
115
+		foreach ($results as $result) {
116 116
 			$constraintTypeItemId = $result->constraint_type_qid;
117
-			$constraintParameters = json_decode( $result->constraint_parameters, true );
117
+			$constraintParameters = json_decode($result->constraint_parameters, true);
118 118
 
119
-			if ( $constraintParameters === null ) {
119
+			if ($constraintParameters === null) {
120 120
 				// T171295
121
-				LoggerFactory::getInstance( 'WikibaseQualityConstraints' )
122
-					->warning( 'Constraint {constraintId} has invalid constraint parameters.', [
121
+				LoggerFactory::getInstance('WikibaseQualityConstraints')
122
+					->warning('Constraint {constraintId} has invalid constraint parameters.', [
123 123
 						'method' => __METHOD__,
124 124
 						'constraintId' => $result->constraint_guid,
125 125
 						'constraintParameters' => $result->constraint_parameters,
126
-					] );
127
-				$constraintParameters = [ '@error' => [ /* unknown */ ] ];
126
+					]);
127
+				$constraintParameters = ['@error' => [/* unknown */]];
128 128
 			}
129 129
 
130 130
 			$constraints[] = new Constraint(
131 131
 				$result->constraint_guid,
132
-				PropertyId::newFromNumber( $result->pid ),
132
+				PropertyId::newFromNumber($result->pid),
133 133
 				$constraintTypeItemId,
134 134
 				$constraintParameters
135 135
 			);
Please login to merge, or discard this patch.
src/Api/CheckConstraintParameters.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -75,17 +75,17 @@  discard block
 block discarded – undo
75 75
 		DelegatingConstraintChecker $delegatingConstraintChecker
76 76
 	): self {
77 77
 		$repo = WikibaseRepo::getDefaultInstance();
78
-		$helperFactory = $repo->getApiHelperFactory( RequestContext::getMain() );
78
+		$helperFactory = $repo->getApiHelperFactory(RequestContext::getMain());
79 79
 		$language = $repo->getUserLanguage();
80 80
 
81 81
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
82 82
 		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory
83
-			->getEntityIdFormatter( $language );
83
+			->getEntityIdFormatter($language);
84 84
 		$formatterOptions = new FormatterOptions();
85
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
85
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
86 86
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
87 87
 		$dataValueFormatter = $valueFormatterFactory
88
-			->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
88
+			->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
89 89
 		$violationMessageRenderer = new MultilingualTextViolationMessageRenderer(
90 90
 			$entityIdHtmlLinkFormatter,
91 91
 			$dataValueFormatter,
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 		StatementGuidParser $statementGuidParser,
122 122
 		IBufferingStatsdDataFactory $dataFactory
123 123
 	) {
124
-		parent::__construct( $main, $name );
124
+		parent::__construct($main, $name);
125 125
 
126
-		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this );
126
+		$this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this);
127 127
 		$this->delegatingConstraintChecker = $delegatingConstraintChecker;
128 128
 		$this->violationMessageRenderer = $violationMessageRenderer;
129 129
 		$this->statementGuidParser = $statementGuidParser;
@@ -138,39 +138,39 @@  discard block
 block discarded – undo
138 138
 		$params = $this->extractRequestParams();
139 139
 		$result = $this->getResult();
140 140
 
141
-		$propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] );
142
-		$constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] );
141
+		$propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]);
142
+		$constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]);
143 143
 
144
-		$this->checkPropertyIds( $propertyIds, $result );
145
-		$this->checkConstraintIds( $constraintIds, $result );
144
+		$this->checkPropertyIds($propertyIds, $result);
145
+		$this->checkConstraintIds($constraintIds, $result);
146 146
 
147
-		$result->addValue( null, 'success', 1 );
147
+		$result->addValue(null, 'success', 1);
148 148
 	}
149 149
 
150 150
 	/**
151 151
 	 * @param array|null $propertyIdSerializations
152 152
 	 * @return PropertyId[]
153 153
 	 */
154
-	private function parsePropertyIds( $propertyIdSerializations ) {
155
-		if ( $propertyIdSerializations === null ) {
154
+	private function parsePropertyIds($propertyIdSerializations) {
155
+		if ($propertyIdSerializations === null) {
156 156
 			return [];
157
-		} elseif ( empty( $propertyIdSerializations ) ) {
157
+		} elseif (empty($propertyIdSerializations)) {
158 158
 			$this->apiErrorReporter->dieError(
159
-				'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.',
159
+				'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.',
160 160
 				'no-data'
161 161
 			);
162 162
 		}
163 163
 
164 164
 		return array_map(
165
-			function( $propertyIdSerialization ) {
165
+			function($propertyIdSerialization) {
166 166
 				try {
167
-					return new PropertyId( $propertyIdSerialization );
168
-				} catch ( InvalidArgumentException $e ) {
167
+					return new PropertyId($propertyIdSerialization);
168
+				} catch (InvalidArgumentException $e) {
169 169
 					$this->apiErrorReporter->dieError(
170 170
 						"Invalid id: $propertyIdSerialization",
171 171
 						'invalid-property-id',
172 172
 						0, // default argument
173
-						[ self::PARAM_PROPERTY_ID => $propertyIdSerialization ]
173
+						[self::PARAM_PROPERTY_ID => $propertyIdSerialization]
174 174
 					);
175 175
 				}
176 176
 			},
@@ -182,35 +182,35 @@  discard block
 block discarded – undo
182 182
 	 * @param array|null $constraintIds
183 183
 	 * @return string[]
184 184
 	 */
185
-	private function parseConstraintIds( $constraintIds ) {
186
-		if ( $constraintIds === null ) {
185
+	private function parseConstraintIds($constraintIds) {
186
+		if ($constraintIds === null) {
187 187
 			return [];
188
-		} elseif ( empty( $constraintIds ) ) {
188
+		} elseif (empty($constraintIds)) {
189 189
 			$this->apiErrorReporter->dieError(
190
-				'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.',
190
+				'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.',
191 191
 				'no-data'
192 192
 			);
193 193
 		}
194 194
 
195 195
 		return array_map(
196
-			function( $constraintId ) {
196
+			function($constraintId) {
197 197
 				try {
198
-					$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
199
-					if ( !$propertyId instanceof PropertyId ) {
198
+					$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
199
+					if (!$propertyId instanceof PropertyId) {
200 200
 						$this->apiErrorReporter->dieError(
201 201
 							"Invalid property ID: {$propertyId->getSerialization()}",
202 202
 							'invalid-property-id',
203 203
 							0, // default argument
204
-							[ self::PARAM_CONSTRAINT_ID => $constraintId ]
204
+							[self::PARAM_CONSTRAINT_ID => $constraintId]
205 205
 						);
206 206
 					}
207 207
 					return $constraintId;
208
-				} catch ( StatementGuidParsingException $e ) {
208
+				} catch (StatementGuidParsingException $e) {
209 209
 					$this->apiErrorReporter->dieError(
210 210
 						"Invalid statement GUID: $constraintId",
211 211
 						'invalid-guid',
212 212
 						0, // default argument
213
-						[ self::PARAM_CONSTRAINT_ID => $constraintId ]
213
+						[self::PARAM_CONSTRAINT_ID => $constraintId]
214 214
 					);
215 215
 				}
216 216
 			},
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 	 * @param PropertyId[] $propertyIds
223 223
 	 * @param ApiResult $result
224 224
 	 */
225
-	private function checkPropertyIds( array $propertyIds, ApiResult $result ) {
226
-		foreach ( $propertyIds as $propertyId ) {
227
-			$result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' );
225
+	private function checkPropertyIds(array $propertyIds, ApiResult $result) {
226
+		foreach ($propertyIds as $propertyId) {
227
+			$result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc');
228 228
 			$allConstraintExceptions = $this->delegatingConstraintChecker
229
-				->checkConstraintParametersOnPropertyId( $propertyId );
230
-			foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) {
229
+				->checkConstraintParametersOnPropertyId($propertyId);
230
+			foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) {
231 231
 				$this->addConstraintParameterExceptionsToResult(
232 232
 					$constraintId,
233 233
 					$constraintParameterExceptions,
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
 	 * @param string[] $constraintIds
242 242
 	 * @param ApiResult $result
243 243
 	 */
244
-	private function checkConstraintIds( array $constraintIds, ApiResult $result ) {
245
-		foreach ( $constraintIds as $constraintId ) {
246
-			if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) {
244
+	private function checkConstraintIds(array $constraintIds, ApiResult $result) {
245
+		foreach ($constraintIds as $constraintId) {
246
+			if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) {
247 247
 				// already checked as part of checkPropertyIds()
248 248
 				continue;
249 249
 			}
250 250
 			$constraintParameterExceptions = $this->delegatingConstraintChecker
251
-				->checkConstraintParametersOnConstraintId( $constraintId );
252
-			$this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result );
251
+				->checkConstraintParametersOnConstraintId($constraintId);
252
+			$this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result);
253 253
 		}
254 254
 	}
255 255
 
@@ -257,18 +257,18 @@  discard block
 block discarded – undo
257 257
 	 * @param PropertyId $propertyId
258 258
 	 * @return string[]
259 259
 	 */
260
-	private function getResultPathForPropertyId( PropertyId $propertyId ) {
261
-		return [ $this->getModuleName(), $propertyId->getSerialization() ];
260
+	private function getResultPathForPropertyId(PropertyId $propertyId) {
261
+		return [$this->getModuleName(), $propertyId->getSerialization()];
262 262
 	}
263 263
 
264 264
 	/**
265 265
 	 * @param string $constraintId
266 266
 	 * @return string[]
267 267
 	 */
268
-	private function getResultPathForConstraintId( $constraintId ) {
269
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
268
+	private function getResultPathForConstraintId($constraintId) {
269
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
270 270
 		'@phan-var PropertyId $propertyId';
271
-		return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] );
271
+		return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]);
272 272
 	}
273 273
 
274 274
 	/**
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 		$constraintParameterExceptions,
284 284
 		ApiResult $result
285 285
 	) {
286
-		$path = $this->getResultPathForConstraintId( $constraintId );
287
-		if ( $constraintParameterExceptions === null ) {
286
+		$path = $this->getResultPathForConstraintId($constraintId);
287
+		if ($constraintParameterExceptions === null) {
288 288
 			$result->addValue(
289 289
 				$path,
290 290
 				self::KEY_STATUS,
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
 			$result->addValue(
295 295
 				$path,
296 296
 				self::KEY_STATUS,
297
-				empty( $constraintParameterExceptions ) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY
297
+				empty($constraintParameterExceptions) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY
298 298
 			);
299 299
 			$result->addValue(
300 300
 				$path,
301 301
 				self::KEY_PROBLEMS,
302
-				array_map( [ $this, 'formatConstraintParameterException' ], $constraintParameterExceptions )
302
+				array_map([$this, 'formatConstraintParameterException'], $constraintParameterExceptions)
303 303
 			);
304 304
 		}
305 305
 	}
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	 * @param ConstraintParameterException $e
311 311
 	 * @return string[]
312 312
 	 */
313
-	private function formatConstraintParameterException( ConstraintParameterException $e ) {
313
+	private function formatConstraintParameterException(ConstraintParameterException $e) {
314 314
 		return [
315 315
 			self::KEY_MESSAGE_HTML => $this->violationMessageRenderer->render(
316 316
 				$e->getViolationMessage()
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 		return [
344 344
 			'action=wbcheckconstraintparameters&propertyid=P247'
345 345
 				=> 'apihelp-wbcheckconstraintparameters-example-propertyid-1',
346
-			'action=wbcheckconstraintparameters&' .
347
-			'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|' .
346
+			'action=wbcheckconstraintparameters&'.
347
+			'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|'.
348 348
 			'P225$cdc71e4a-47a0-12c5-dfb3-3f6fc0b6613f'
349 349
 				=> 'apihelp-wbcheckconstraintparameters-example-constraintid-2',
350 350
 		];
Please login to merge, or discard this patch.
src/Api/CheckConstraints.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
 
84 84
 		$language = $repo->getUserLanguage();
85 85
 		$formatterOptions = new FormatterOptions();
86
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
86
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
87 87
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
88
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
88
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
89 89
 
90 90
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
91
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language );
91
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language);
92 92
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
93
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language );
93
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language);
94 94
 
95 95
 		$checkResultsRenderer = new CheckResultsRenderer(
96 96
 			$repo->getEntityTitleLookup(),
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 			$name,
109 109
 			$repo->getEntityIdParser(),
110 110
 			$repo->getStatementGuidValidator(),
111
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
111
+			$repo->getApiHelperFactory(RequestContext::getMain()),
112 112
 			$resultsSource,
113 113
 			$checkResultsRenderer,
114 114
 			$dataFactory
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 		CheckResultsRenderer $checkResultsRenderer,
136 136
 		IBufferingStatsdDataFactory $dataFactory
137 137
 	) {
138
-		parent::__construct( $main, $name );
138
+		parent::__construct($main, $name);
139 139
 		$this->entityIdParser = $entityIdParser;
140 140
 		$this->statementGuidValidator = $statementGuidValidator;
141
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
142
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
141
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
142
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
143 143
 		$this->resultsSource = $resultsSource;
144 144
 		$this->checkResultsRenderer = $checkResultsRenderer;
145 145
 		$this->dataFactory = $dataFactory;
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 
156 156
 		$params = $this->extractRequestParams();
157 157
 
158
-		$this->validateParameters( $params );
159
-		$entityIds = $this->parseEntityIds( $params );
160
-		$claimIds = $this->parseClaimIds( $params );
158
+		$this->validateParameters($params);
159
+		$entityIds = $this->parseEntityIds($params);
160
+		$claimIds = $this->parseClaimIds($params);
161 161
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
162 162
 		$statuses = $params[self::PARAM_STATUS];
163 163
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 				)
174 174
 			)->getArray()
175 175
 		);
176
-		$this->resultBuilder->markSuccess( 1 );
176
+		$this->resultBuilder->markSuccess(1);
177 177
 	}
178 178
 
179 179
 	/**
@@ -181,24 +181,24 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return EntityId[]
183 183
 	 */
184
-	private function parseEntityIds( array $params ) {
184
+	private function parseEntityIds(array $params) {
185 185
 		$ids = $params[self::PARAM_ID];
186 186
 
187
-		if ( $ids === null ) {
187
+		if ($ids === null) {
188 188
 			return [];
189
-		} elseif ( $ids === [] ) {
189
+		} elseif ($ids === []) {
190 190
 			$this->errorReporter->dieError(
191
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
191
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
192 192
 		}
193 193
 
194
-		return array_map( function ( $id ) {
194
+		return array_map(function($id) {
195 195
 			try {
196
-				return $this->entityIdParser->parse( $id );
197
-			} catch ( EntityIdParsingException $e ) {
196
+				return $this->entityIdParser->parse($id);
197
+			} catch (EntityIdParsingException $e) {
198 198
 				$this->errorReporter->dieError(
199
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
199
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
200 200
 			}
201
-		}, $ids );
201
+		}, $ids);
202 202
 	}
203 203
 
204 204
 	/**
@@ -206,36 +206,36 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @return string[]
208 208
 	 */
209
-	private function parseClaimIds( array $params ) {
209
+	private function parseClaimIds(array $params) {
210 210
 		$ids = $params[self::PARAM_CLAIM_ID];
211 211
 
212
-		if ( $ids === null ) {
212
+		if ($ids === null) {
213 213
 			return [];
214
-		} elseif ( $ids === [] ) {
214
+		} elseif ($ids === []) {
215 215
 			$this->errorReporter->dieError(
216
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
216
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
217 217
 		}
218 218
 
219
-		foreach ( $ids as $id ) {
220
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
219
+		foreach ($ids as $id) {
220
+			if (!$this->statementGuidValidator->validate($id)) {
221 221
 				$this->errorReporter->dieError(
222
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
222
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
223 223
 			}
224 224
 		}
225 225
 
226 226
 		return $ids;
227 227
 	}
228 228
 
229
-	private function validateParameters( array $params ) {
230
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
231
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
229
+	private function validateParameters(array $params) {
230
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
231
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
232 232
 		) {
233 233
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
234 234
 			$this->errorReporter->dieError(
235 235
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
236 236
 		}
237 237
 		// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset
238
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
238
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
239 239
 			$paramId = self::PARAM_ID;
240 240
 			$paramClaimId = self::PARAM_CLAIM_ID;
241 241
 			$this->errorReporter->dieError(
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 				],
277 277
 				ApiBase::PARAM_ISMULTI => true,
278 278
 				ApiBase::PARAM_ALL => true,
279
-				ApiBase::PARAM_DFLT => implode( '|', CachingResultsSource::CACHED_STATUSES ),
279
+				ApiBase::PARAM_DFLT => implode('|', CachingResultsSource::CACHED_STATUSES),
280 280
 				ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
281 281
 			],
282 282
 		];
Please login to merge, or discard this patch.