@@ -20,35 +20,35 @@ |
||
20 | 20 | const PROPERTY_DATA_TYPE_LOOKUP = 'WBQC_PropertyDataTypeLookup'; |
21 | 21 | const ENTITY_LOOKUP_WITHOUT_CACHE = 'WBQC_EntityLookupWithoutCache'; |
22 | 22 | |
23 | - private static function getService( ?MediaWikiServices $services, $name ) { |
|
24 | - if ( $services === null ) { |
|
23 | + private static function getService(?MediaWikiServices $services, $name) { |
|
24 | + if ($services === null) { |
|
25 | 25 | $services = MediaWikiServices::getInstance(); |
26 | 26 | } |
27 | - return $services->getService( $name ); |
|
27 | + return $services->getService($name); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @param MediaWikiServices|null $services |
32 | 32 | * @return EntityLookup |
33 | 33 | */ |
34 | - public static function getEntityLookup( MediaWikiServices $services = null ) { |
|
35 | - return self::getService( $services, self::ENTITY_LOOKUP ); |
|
34 | + public static function getEntityLookup(MediaWikiServices $services = null) { |
|
35 | + return self::getService($services, self::ENTITY_LOOKUP); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @param MediaWikiServices|null $services |
40 | 40 | * @return PropertyDataTypeLookup |
41 | 41 | */ |
42 | - public static function getPropertyDataTypeLookup( MediaWikiServices $services = null ) { |
|
43 | - return self::getService( $services, self::PROPERTY_DATA_TYPE_LOOKUP ); |
|
42 | + public static function getPropertyDataTypeLookup(MediaWikiServices $services = null) { |
|
43 | + return self::getService($services, self::PROPERTY_DATA_TYPE_LOOKUP); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @param MediaWikiServices|null $services |
48 | 48 | * @return EntityLookup |
49 | 49 | */ |
50 | - public static function getEntityLookupWithoutCache( MediaWikiServices $services = null ) { |
|
51 | - return self::getService( $services, self::ENTITY_LOOKUP_WITHOUT_CACHE ); |
|
50 | + public static function getEntityLookupWithoutCache(MediaWikiServices $services = null) { |
|
51 | + return self::getService($services, self::ENTITY_LOOKUP_WITHOUT_CACHE); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | } |
@@ -40,243 +40,243 @@ |
||
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 | } |
@@ -38,90 +38,90 @@ |
||
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 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | CheckResult::STATUS_WARNING, |
144 | 144 | CheckResult::STATUS_BAD_PARAMETERS, |
145 | 145 | ]; |
146 | - $this->cachedStatusesFlipped = array_flip( $this->cachedStatuses ); |
|
146 | + $this->cachedStatusesFlipped = array_flip($this->cachedStatuses); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | public function getResults( |
@@ -154,15 +154,15 @@ discard block |
||
154 | 154 | ) { |
155 | 155 | $results = []; |
156 | 156 | $metadatas = []; |
157 | - $statusesFlipped = array_flip( $statuses ); |
|
158 | - if ( $this->canUseStoredResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) { |
|
157 | + $statusesFlipped = array_flip($statuses); |
|
158 | + if ($this->canUseStoredResults($entityIds, $claimIds, $constraintIds, $statuses)) { |
|
159 | 159 | $storedEntityIds = []; |
160 | - foreach ( $entityIds as $entityId ) { |
|
161 | - $storedResults = $this->getStoredResults( $entityId ); |
|
162 | - if ( $storedResults !== null ) { |
|
163 | - $this->loggingHelper->logCheckConstraintsCacheHit( $entityId ); |
|
164 | - foreach ( $storedResults->getArray() as $checkResult ) { |
|
165 | - if ( $this->statusSelected( $statusesFlipped, $checkResult ) ) { |
|
160 | + foreach ($entityIds as $entityId) { |
|
161 | + $storedResults = $this->getStoredResults($entityId); |
|
162 | + if ($storedResults !== null) { |
|
163 | + $this->loggingHelper->logCheckConstraintsCacheHit($entityId); |
|
164 | + foreach ($storedResults->getArray() as $checkResult) { |
|
165 | + if ($this->statusSelected($statusesFlipped, $checkResult)) { |
|
166 | 166 | $results[] = $checkResult; |
167 | 167 | } |
168 | 168 | } |
@@ -170,19 +170,19 @@ discard block |
||
170 | 170 | $storedEntityIds[] = $entityId; |
171 | 171 | } |
172 | 172 | } |
173 | - $entityIds = array_values( array_diff( $entityIds, $storedEntityIds ) ); |
|
173 | + $entityIds = array_values(array_diff($entityIds, $storedEntityIds)); |
|
174 | 174 | } |
175 | - if ( $entityIds !== [] || $claimIds !== [] ) { |
|
176 | - if ( $entityIds !== [] ) { |
|
177 | - $this->loggingHelper->logCheckConstraintsCacheMisses( $entityIds ); |
|
175 | + if ($entityIds !== [] || $claimIds !== []) { |
|
176 | + if ($entityIds !== []) { |
|
177 | + $this->loggingHelper->logCheckConstraintsCacheMisses($entityIds); |
|
178 | 178 | } |
179 | - $response = $this->getAndStoreResults( $entityIds, $claimIds, $constraintIds, $statuses ); |
|
180 | - $results = array_merge( $results, $response->getArray() ); |
|
179 | + $response = $this->getAndStoreResults($entityIds, $claimIds, $constraintIds, $statuses); |
|
180 | + $results = array_merge($results, $response->getArray()); |
|
181 | 181 | $metadatas[] = $response->getMetadata(); |
182 | 182 | } |
183 | 183 | return new CachedCheckResults( |
184 | 184 | $results, |
185 | - Metadata::merge( $metadatas ) |
|
185 | + Metadata::merge($metadatas) |
|
186 | 186 | ); |
187 | 187 | } |
188 | 188 | |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | ?array $constraintIds, |
206 | 206 | array $statuses |
207 | 207 | ) { |
208 | - if ( $claimIds !== [] ) { |
|
208 | + if ($claimIds !== []) { |
|
209 | 209 | return false; |
210 | 210 | } |
211 | - if ( $constraintIds !== null ) { |
|
211 | + if ($constraintIds !== null) { |
|
212 | 212 | return false; |
213 | 213 | } |
214 | - if ( array_diff( $statuses, $this->cachedStatuses ) !== [] ) { |
|
214 | + if (array_diff($statuses, $this->cachedStatuses) !== []) { |
|
215 | 215 | return false; |
216 | 216 | } |
217 | 217 | return true; |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | * @param CheckResult $result |
227 | 227 | * @return bool |
228 | 228 | */ |
229 | - private function statusSelected( array $statusesFlipped, CheckResult $result ) { |
|
230 | - return array_key_exists( $result->getStatus(), $statusesFlipped ) || |
|
229 | + private function statusSelected(array $statusesFlipped, CheckResult $result) { |
|
230 | + return array_key_exists($result->getStatus(), $statusesFlipped) || |
|
231 | 231 | $result instanceof NullResult; |
232 | 232 | } |
233 | 233 | |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | ?array $constraintIds, |
245 | 245 | array $statuses |
246 | 246 | ) { |
247 | - $results = $this->resultsSource->getResults( $entityIds, $claimIds, $constraintIds, $statuses ); |
|
247 | + $results = $this->resultsSource->getResults($entityIds, $claimIds, $constraintIds, $statuses); |
|
248 | 248 | |
249 | - if ( $this->canStoreResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) { |
|
250 | - foreach ( $entityIds as $entityId ) { |
|
251 | - $this->storeResults( $entityId, $results ); |
|
249 | + if ($this->canStoreResults($entityIds, $claimIds, $constraintIds, $statuses)) { |
|
250 | + foreach ($entityIds as $entityId) { |
|
251 | + $this->storeResults($entityId, $results); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
@@ -279,10 +279,10 @@ discard block |
||
279 | 279 | ?array $constraintIds, |
280 | 280 | array $statuses |
281 | 281 | ) { |
282 | - if ( $constraintIds !== null ) { |
|
282 | + if ($constraintIds !== null) { |
|
283 | 283 | return false; |
284 | 284 | } |
285 | - if ( array_diff( $this->cachedStatuses, $statuses ) !== [] ) { |
|
285 | + if (array_diff($this->cachedStatuses, $statuses) !== []) { |
|
286 | 286 | return false; |
287 | 287 | } |
288 | 288 | return true; |
@@ -296,21 +296,21 @@ discard block |
||
296 | 296 | * May include check results for other entity IDs as well, |
297 | 297 | * or check results with statuses that we’re not interested in caching. |
298 | 298 | */ |
299 | - private function storeResults( EntityId $entityId, CachedCheckResults $results ) { |
|
299 | + private function storeResults(EntityId $entityId, CachedCheckResults $results) { |
|
300 | 300 | $latestRevisionIds = $this->getLatestRevisionIds( |
301 | 301 | $results->getMetadata()->getDependencyMetadata()->getEntityIds() |
302 | 302 | ); |
303 | - if ( $latestRevisionIds === null ) { |
|
303 | + if ($latestRevisionIds === null) { |
|
304 | 304 | return; |
305 | 305 | } |
306 | 306 | |
307 | 307 | $resultSerializations = []; |
308 | - foreach ( $results->getArray() as $checkResult ) { |
|
309 | - if ( $checkResult->getContextCursor()->getEntityId() !== $entityId->getSerialization() ) { |
|
308 | + foreach ($results->getArray() as $checkResult) { |
|
309 | + if ($checkResult->getContextCursor()->getEntityId() !== $entityId->getSerialization()) { |
|
310 | 310 | continue; |
311 | 311 | } |
312 | - if ( $this->statusSelected( $this->cachedStatusesFlipped, $checkResult ) ) { |
|
313 | - $resultSerializations[] = $this->checkResultSerializer->serialize( $checkResult ); |
|
312 | + if ($this->statusSelected($this->cachedStatusesFlipped, $checkResult)) { |
|
313 | + $resultSerializations[] = $this->checkResultSerializer->serialize($checkResult); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
@@ -319,11 +319,11 @@ discard block |
||
319 | 319 | 'latestRevisionIds' => $latestRevisionIds, |
320 | 320 | ]; |
321 | 321 | $futureTime = $results->getMetadata()->getDependencyMetadata()->getFutureTime(); |
322 | - if ( $futureTime !== null ) { |
|
322 | + if ($futureTime !== null) { |
|
323 | 323 | $value['futureTime'] = $futureTime->getArrayValue(); |
324 | 324 | } |
325 | 325 | |
326 | - $this->cache->set( $entityId, $value, $this->ttlInSeconds ); |
|
326 | + $this->cache->set($entityId, $value, $this->ttlInSeconds); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -337,31 +337,30 @@ discard block |
||
337 | 337 | EntityId $entityId, |
338 | 338 | $forRevision = 0 |
339 | 339 | ) { |
340 | - $value = $this->cache->get( $entityId, $curTTL, [], $asOf ); |
|
341 | - $now = call_user_func( $this->microtime, true ); |
|
340 | + $value = $this->cache->get($entityId, $curTTL, [], $asOf); |
|
341 | + $now = call_user_func($this->microtime, true); |
|
342 | 342 | |
343 | - $dependencyMetadata = $this->checkDependencyMetadata( $value, |
|
344 | - [ $entityId->getSerialization() => $forRevision ] ); |
|
345 | - if ( $dependencyMetadata === null ) { |
|
343 | + $dependencyMetadata = $this->checkDependencyMetadata($value, |
|
344 | + [$entityId->getSerialization() => $forRevision]); |
|
345 | + if ($dependencyMetadata === null) { |
|
346 | 346 | return null; |
347 | 347 | } |
348 | 348 | |
349 | - $ageInSeconds = (int)ceil( $now - $asOf ); |
|
349 | + $ageInSeconds = (int) ceil($now - $asOf); |
|
350 | 350 | $cachingMetadata = $ageInSeconds > 0 ? |
351 | - CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) : |
|
352 | - CachingMetadata::fresh(); |
|
351 | + CachingMetadata::ofMaximumAgeInSeconds($ageInSeconds) : CachingMetadata::fresh(); |
|
353 | 352 | |
354 | 353 | $results = []; |
355 | - foreach ( $value['results'] as $resultSerialization ) { |
|
356 | - $results[] = $this->deserializeCheckResult( $resultSerialization, $cachingMetadata ); |
|
354 | + foreach ($value['results'] as $resultSerialization) { |
|
355 | + $results[] = $this->deserializeCheckResult($resultSerialization, $cachingMetadata); |
|
357 | 356 | } |
358 | 357 | |
359 | 358 | return new CachedCheckResults( |
360 | 359 | $results, |
361 | - Metadata::merge( [ |
|
362 | - Metadata::ofCachingMetadata( $cachingMetadata ), |
|
363 | - Metadata::ofDependencyMetadata( $dependencyMetadata ), |
|
364 | - ] ) |
|
360 | + Metadata::merge([ |
|
361 | + Metadata::ofCachingMetadata($cachingMetadata), |
|
362 | + Metadata::ofDependencyMetadata($dependencyMetadata), |
|
363 | + ]) |
|
365 | 364 | ); |
366 | 365 | } |
367 | 366 | |
@@ -377,43 +376,43 @@ discard block |
||
377 | 376 | * @return DependencyMetadata|null the dependency metadata, |
378 | 377 | * or null if $value should no longer be used |
379 | 378 | */ |
380 | - private function checkDependencyMetadata( $value, $paramRevs ) { |
|
381 | - if ( $value === false ) { |
|
379 | + private function checkDependencyMetadata($value, $paramRevs) { |
|
380 | + if ($value === false) { |
|
382 | 381 | return null; |
383 | 382 | } |
384 | 383 | |
385 | - if ( array_key_exists( 'futureTime', $value ) ) { |
|
386 | - $futureTime = TimeValue::newFromArray( $value['futureTime'] ); |
|
387 | - if ( !$this->timeValueComparer->isFutureTime( $futureTime ) ) { |
|
384 | + if (array_key_exists('futureTime', $value)) { |
|
385 | + $futureTime = TimeValue::newFromArray($value['futureTime']); |
|
386 | + if (!$this->timeValueComparer->isFutureTime($futureTime)) { |
|
388 | 387 | return null; |
389 | 388 | } |
390 | - $futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime( $futureTime ); |
|
389 | + $futureTimeDependencyMetadata = DependencyMetadata::ofFutureTime($futureTime); |
|
391 | 390 | } else { |
392 | 391 | $futureTimeDependencyMetadata = DependencyMetadata::blank(); |
393 | 392 | } |
394 | 393 | |
395 | - foreach ( $paramRevs as $id => $revision ) { |
|
396 | - if ( $revision > 0 ) { |
|
397 | - $value['latestRevisionIds'][$id] = min( $revision, $value['latestRevisionIds'][$id] ?? PHP_INT_MAX ); |
|
394 | + foreach ($paramRevs as $id => $revision) { |
|
395 | + if ($revision > 0) { |
|
396 | + $value['latestRevisionIds'][$id] = min($revision, $value['latestRevisionIds'][$id] ?? PHP_INT_MAX); |
|
398 | 397 | } |
399 | 398 | } |
400 | 399 | |
401 | 400 | $dependedEntityIds = array_map( |
402 | - [ $this->entityIdParser, "parse" ], |
|
403 | - array_keys( $value['latestRevisionIds'] ) |
|
401 | + [$this->entityIdParser, "parse"], |
|
402 | + array_keys($value['latestRevisionIds']) |
|
404 | 403 | ); |
405 | 404 | |
406 | - if ( $value['latestRevisionIds'] !== $this->getLatestRevisionIds( $dependedEntityIds ) ) { |
|
405 | + if ($value['latestRevisionIds'] !== $this->getLatestRevisionIds($dependedEntityIds)) { |
|
407 | 406 | return null; |
408 | 407 | } |
409 | 408 | |
410 | 409 | return array_reduce( |
411 | 410 | $dependedEntityIds, |
412 | - function( DependencyMetadata $metadata, EntityId $entityId ) { |
|
413 | - return DependencyMetadata::merge( [ |
|
411 | + function(DependencyMetadata $metadata, EntityId $entityId) { |
|
412 | + return DependencyMetadata::merge([ |
|
414 | 413 | $metadata, |
415 | - DependencyMetadata::ofEntityId( $entityId ) |
|
416 | - ] ); |
|
414 | + DependencyMetadata::ofEntityId($entityId) |
|
415 | + ]); |
|
417 | 416 | }, |
418 | 417 | $futureTimeDependencyMetadata |
419 | 418 | ); |
@@ -433,13 +432,13 @@ discard block |
||
433 | 432 | array $resultSerialization, |
434 | 433 | CachingMetadata $cachingMetadata |
435 | 434 | ) { |
436 | - $result = $this->checkResultDeserializer->deserialize( $resultSerialization ); |
|
437 | - if ( $this->isPossiblyStaleResult( $result ) ) { |
|
435 | + $result = $this->checkResultDeserializer->deserialize($resultSerialization); |
|
436 | + if ($this->isPossiblyStaleResult($result)) { |
|
438 | 437 | $result->withMetadata( |
439 | - Metadata::merge( [ |
|
438 | + Metadata::merge([ |
|
440 | 439 | $result->getMetadata(), |
441 | - Metadata::ofCachingMetadata( $cachingMetadata ), |
|
442 | - ] ) |
|
440 | + Metadata::ofCachingMetadata($cachingMetadata), |
|
441 | + ]) |
|
443 | 442 | ); |
444 | 443 | } |
445 | 444 | return $result; |
@@ -449,8 +448,8 @@ discard block |
||
449 | 448 | * @param CheckResult $result |
450 | 449 | * @return bool |
451 | 450 | */ |
452 | - private function isPossiblyStaleResult( CheckResult $result ) { |
|
453 | - if ( $result instanceof NullResult ) { |
|
451 | + private function isPossiblyStaleResult(CheckResult $result) { |
|
452 | + if ($result instanceof NullResult) { |
|
454 | 453 | return false; |
455 | 454 | } |
456 | 455 | |
@@ -465,14 +464,14 @@ discard block |
||
465 | 464 | * @return int[]|null array from entity ID serializations to revision ID, |
466 | 465 | * or null to indicate that not all revision IDs could be loaded |
467 | 466 | */ |
468 | - private function getLatestRevisionIds( array $entityIds ) { |
|
469 | - if ( $entityIds === [] ) { |
|
467 | + private function getLatestRevisionIds(array $entityIds) { |
|
468 | + if ($entityIds === []) { |
|
470 | 469 | $this->loggingHelper->logEmptyDependencyMetadata(); |
471 | 470 | return []; |
472 | 471 | } |
473 | - if ( count( $entityIds ) > $this->maxRevisionIds ) { |
|
472 | + if (count($entityIds) > $this->maxRevisionIds) { |
|
474 | 473 | // one of those entities will probably be edited soon, so might as well skip caching |
475 | - $this->loggingHelper->logHugeDependencyMetadata( $entityIds, $this->maxRevisionIds ); |
|
474 | + $this->loggingHelper->logHugeDependencyMetadata($entityIds, $this->maxRevisionIds); |
|
476 | 475 | return null; |
477 | 476 | } |
478 | 477 | |
@@ -480,7 +479,7 @@ discard block |
||
480 | 479 | $entityIds, |
481 | 480 | EntityRevisionLookup::LATEST_FROM_REPLICA |
482 | 481 | ); |
483 | - if ( $this->hasFalseElements( $latestRevisionIds ) ) { |
|
482 | + if ($this->hasFalseElements($latestRevisionIds)) { |
|
484 | 483 | return null; |
485 | 484 | } |
486 | 485 | return $latestRevisionIds; |
@@ -490,8 +489,8 @@ discard block |
||
490 | 489 | * @param array $array |
491 | 490 | * @return bool |
492 | 491 | */ |
493 | - private function hasFalseElements( array $array ) { |
|
494 | - return in_array( false, $array, true ); |
|
492 | + private function hasFalseElements(array $array) { |
|
493 | + return in_array(false, $array, true); |
|
495 | 494 | } |
496 | 495 | |
497 | 496 | /** |
@@ -499,7 +498,7 @@ discard block |
||
499 | 498 | * |
500 | 499 | * @param callable $microtime |
501 | 500 | */ |
502 | - public function setMicrotimeFunction( callable $microtime ) { |
|
501 | + public function setMicrotimeFunction(callable $microtime) { |
|
503 | 502 | $this->microtime = $microtime; |
504 | 503 | } |
505 | 504 |