@@ -44,257 +44,257 @@ |
||
44 | 44 | public const LEXEME_LANGUAGE_CHECKER = 'WBQC_Lexeme_LanguageChecker'; |
45 | 45 | public const LABEL_IN_LANGUAGE_CHECKER = 'WBQC_LabelInLanguageChecker'; |
46 | 46 | |
47 | - private static function getService( ?MediaWikiServices $services, string $name ) { |
|
47 | + private static function getService(?MediaWikiServices $services, string $name) { |
|
48 | 48 | $services ??= MediaWikiServices::getInstance(); |
49 | - return $services->getService( $name ); |
|
49 | + return $services->getService($name); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @param MediaWikiServices|null $services |
54 | 54 | * @return ConstraintChecker |
55 | 55 | */ |
56 | - public static function getConflictsWithChecker( ?MediaWikiServices $services = null ) { |
|
57 | - return self::getService( $services, self::CONFLICTS_WITH_CHECKER ); |
|
56 | + public static function getConflictsWithChecker(?MediaWikiServices $services = null) { |
|
57 | + return self::getService($services, self::CONFLICTS_WITH_CHECKER); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * @param MediaWikiServices|null $services |
62 | 62 | * @return ConstraintChecker |
63 | 63 | */ |
64 | - public static function getItemChecker( ?MediaWikiServices $services = null ) { |
|
65 | - return self::getService( $services, self::ITEM_CHECKER ); |
|
64 | + public static function getItemChecker(?MediaWikiServices $services = null) { |
|
65 | + return self::getService($services, self::ITEM_CHECKER); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @param MediaWikiServices|null $services |
70 | 70 | * @return ConstraintChecker |
71 | 71 | */ |
72 | - public static function getTargetRequiredClaimChecker( ?MediaWikiServices $services = null ) { |
|
73 | - return self::getService( $services, self::TARGET_REQUIRED_CLAIM_CHECKER ); |
|
72 | + public static function getTargetRequiredClaimChecker(?MediaWikiServices $services = null) { |
|
73 | + return self::getService($services, self::TARGET_REQUIRED_CLAIM_CHECKER); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | 77 | * @param MediaWikiServices|null $services |
78 | 78 | * @return ConstraintChecker |
79 | 79 | */ |
80 | - public static function getSymmetricChecker( ?MediaWikiServices $services = null ) { |
|
81 | - return self::getService( $services, self::SYMMETRIC_CHECKER ); |
|
80 | + public static function getSymmetricChecker(?MediaWikiServices $services = null) { |
|
81 | + return self::getService($services, self::SYMMETRIC_CHECKER); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @param MediaWikiServices|null $services |
86 | 86 | * @return ConstraintChecker |
87 | 87 | */ |
88 | - public static function getInverseChecker( ?MediaWikiServices $services = null ) { |
|
89 | - return self::getService( $services, self::INVERSE_CHECKER ); |
|
88 | + public static function getInverseChecker(?MediaWikiServices $services = null) { |
|
89 | + return self::getService($services, self::INVERSE_CHECKER); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | 93 | * @param MediaWikiServices|null $services |
94 | 94 | * @return ConstraintChecker |
95 | 95 | */ |
96 | - public static function getQualifierChecker( ?MediaWikiServices $services = null ) { |
|
97 | - return self::getService( $services, self::QUALIFIER_CHECKER ); |
|
96 | + public static function getQualifierChecker(?MediaWikiServices $services = null) { |
|
97 | + return self::getService($services, self::QUALIFIER_CHECKER); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | 101 | * @param MediaWikiServices|null $services |
102 | 102 | * @return ConstraintChecker |
103 | 103 | */ |
104 | - public static function getQualifiersChecker( ?MediaWikiServices $services = null ) { |
|
105 | - return self::getService( $services, self::QUALIFIERS_CHECKER ); |
|
104 | + public static function getQualifiersChecker(?MediaWikiServices $services = null) { |
|
105 | + return self::getService($services, self::QUALIFIERS_CHECKER); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
109 | 109 | * @param MediaWikiServices|null $services |
110 | 110 | * @return ConstraintChecker |
111 | 111 | */ |
112 | - public static function getMandatoryQualifiersChecker( ?MediaWikiServices $services = null ) { |
|
113 | - return self::getService( $services, self::MANDATORY_QUALIFIERS_CHECKER ); |
|
112 | + public static function getMandatoryQualifiersChecker(?MediaWikiServices $services = null) { |
|
113 | + return self::getService($services, self::MANDATORY_QUALIFIERS_CHECKER); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | 117 | * @param MediaWikiServices|null $services |
118 | 118 | * @return ConstraintChecker |
119 | 119 | */ |
120 | - public static function getRangeChecker( ?MediaWikiServices $services = null ) { |
|
121 | - return self::getService( $services, self::RANGE_CHECKER ); |
|
120 | + public static function getRangeChecker(?MediaWikiServices $services = null) { |
|
121 | + return self::getService($services, self::RANGE_CHECKER); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
125 | 125 | * @param MediaWikiServices|null $services |
126 | 126 | * @return ConstraintChecker |
127 | 127 | */ |
128 | - public static function getDiffWithinRangeChecker( ?MediaWikiServices $services = null ) { |
|
129 | - return self::getService( $services, self::DIFF_WITHIN_RANGE_CHECKER ); |
|
128 | + public static function getDiffWithinRangeChecker(?MediaWikiServices $services = null) { |
|
129 | + return self::getService($services, self::DIFF_WITHIN_RANGE_CHECKER); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
133 | 133 | * @param MediaWikiServices|null $services |
134 | 134 | * @return ConstraintChecker |
135 | 135 | */ |
136 | - public static function getTypeChecker( ?MediaWikiServices $services = null ) { |
|
137 | - return self::getService( $services, self::TYPE_CHECKER ); |
|
136 | + public static function getTypeChecker(?MediaWikiServices $services = null) { |
|
137 | + return self::getService($services, self::TYPE_CHECKER); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
141 | 141 | * @param MediaWikiServices|null $services |
142 | 142 | * @return ConstraintChecker |
143 | 143 | */ |
144 | - public static function getValueTypeChecker( ?MediaWikiServices $services = null ) { |
|
145 | - return self::getService( $services, self::VALUE_TYPE_CHECKER ); |
|
144 | + public static function getValueTypeChecker(?MediaWikiServices $services = null) { |
|
145 | + return self::getService($services, self::VALUE_TYPE_CHECKER); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
149 | 149 | * @param MediaWikiServices|null $services |
150 | 150 | * @return ConstraintChecker |
151 | 151 | */ |
152 | - public static function getSingleValueChecker( ?MediaWikiServices $services = null ) { |
|
153 | - return self::getService( $services, self::SINGLE_VALUE_CHECKER ); |
|
152 | + public static function getSingleValueChecker(?MediaWikiServices $services = null) { |
|
153 | + return self::getService($services, self::SINGLE_VALUE_CHECKER); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
157 | 157 | * @param MediaWikiServices|null $services |
158 | 158 | * @return ConstraintChecker |
159 | 159 | */ |
160 | - public static function getMultiValueChecker( ?MediaWikiServices $services = null ) { |
|
161 | - return self::getService( $services, self::MULTI_VALUE_CHECKER ); |
|
160 | + public static function getMultiValueChecker(?MediaWikiServices $services = null) { |
|
161 | + return self::getService($services, self::MULTI_VALUE_CHECKER); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * @param MediaWikiServices|null $services |
166 | 166 | * @return ConstraintChecker |
167 | 167 | */ |
168 | - public static function getUniqueValueChecker( ?MediaWikiServices $services = null ) { |
|
169 | - return self::getService( $services, self::UNIQUE_VALUE_CHECKER ); |
|
168 | + public static function getUniqueValueChecker(?MediaWikiServices $services = null) { |
|
169 | + return self::getService($services, self::UNIQUE_VALUE_CHECKER); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
173 | 173 | * @param MediaWikiServices|null $services |
174 | 174 | * @return ConstraintChecker |
175 | 175 | */ |
176 | - public static function getFormatChecker( ?MediaWikiServices $services = null ) { |
|
177 | - return self::getService( $services, self::FORMAT_CHECKER ); |
|
176 | + public static function getFormatChecker(?MediaWikiServices $services = null) { |
|
177 | + return self::getService($services, self::FORMAT_CHECKER); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
181 | 181 | * @param MediaWikiServices|null $services |
182 | 182 | * @return ConstraintChecker |
183 | 183 | */ |
184 | - public static function getCommonsLinkChecker( ?MediaWikiServices $services = null ) { |
|
185 | - return self::getService( $services, self::COMMONS_LINK_CHECKER ); |
|
184 | + public static function getCommonsLinkChecker(?MediaWikiServices $services = null) { |
|
185 | + return self::getService($services, self::COMMONS_LINK_CHECKER); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
189 | 189 | * @param MediaWikiServices|null $services |
190 | 190 | * @return ConstraintChecker |
191 | 191 | */ |
192 | - public static function getOneOfChecker( ?MediaWikiServices $services = null ) { |
|
193 | - return self::getService( $services, self::ONE_OF_CHECKER ); |
|
192 | + public static function getOneOfChecker(?MediaWikiServices $services = null) { |
|
193 | + return self::getService($services, self::ONE_OF_CHECKER); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
197 | 197 | * @param MediaWikiServices|null $services |
198 | 198 | * @return ConstraintChecker |
199 | 199 | */ |
200 | - public static function getValueOnlyChecker( ?MediaWikiServices $services = null ) { |
|
201 | - return self::getService( $services, self::VALUE_ONLY_CHECKER ); |
|
200 | + public static function getValueOnlyChecker(?MediaWikiServices $services = null) { |
|
201 | + return self::getService($services, self::VALUE_ONLY_CHECKER); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
205 | 205 | * @param MediaWikiServices|null $services |
206 | 206 | * @return ConstraintChecker |
207 | 207 | */ |
208 | - public static function getReferenceChecker( ?MediaWikiServices $services = null ) { |
|
209 | - return self::getService( $services, self::REFERENCE_CHECKER ); |
|
208 | + public static function getReferenceChecker(?MediaWikiServices $services = null) { |
|
209 | + return self::getService($services, self::REFERENCE_CHECKER); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
213 | 213 | * @param MediaWikiServices|null $services |
214 | 214 | * @return ConstraintChecker |
215 | 215 | */ |
216 | - public static function getNoBoundsChecker( ?MediaWikiServices $services = null ) { |
|
217 | - return self::getService( $services, self::NO_BOUNDS_CHECKER ); |
|
216 | + public static function getNoBoundsChecker(?MediaWikiServices $services = null) { |
|
217 | + return self::getService($services, self::NO_BOUNDS_CHECKER); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
221 | 221 | * @param MediaWikiServices|null $services |
222 | 222 | * @return ConstraintChecker |
223 | 223 | */ |
224 | - public static function getAllowedUnitsChecker( ?MediaWikiServices $services = null ) { |
|
225 | - return self::getService( $services, self::ALLOWED_UNITS_CHECKER ); |
|
224 | + public static function getAllowedUnitsChecker(?MediaWikiServices $services = null) { |
|
225 | + return self::getService($services, self::ALLOWED_UNITS_CHECKER); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
229 | 229 | * @param MediaWikiServices|null $services |
230 | 230 | * @return ConstraintChecker |
231 | 231 | */ |
232 | - public static function getSingleBestValueChecker( ?MediaWikiServices $services = null ) { |
|
233 | - return self::getService( $services, self::SINGLE_BEST_VALUE_CHECKER ); |
|
232 | + public static function getSingleBestValueChecker(?MediaWikiServices $services = null) { |
|
233 | + return self::getService($services, self::SINGLE_BEST_VALUE_CHECKER); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
237 | 237 | * @param MediaWikiServices|null $services |
238 | 238 | * @return ConstraintChecker |
239 | 239 | */ |
240 | - public static function getEntityTypeChecker( ?MediaWikiServices $services = null ) { |
|
241 | - return self::getService( $services, self::ENTITY_TYPE_CHECKER ); |
|
240 | + public static function getEntityTypeChecker(?MediaWikiServices $services = null) { |
|
241 | + return self::getService($services, self::ENTITY_TYPE_CHECKER); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
245 | 245 | * @param MediaWikiServices|null $services |
246 | 246 | * @return ConstraintChecker |
247 | 247 | */ |
248 | - public static function getNoneOfChecker( ?MediaWikiServices $services = null ) { |
|
249 | - return self::getService( $services, self::NONE_OF_CHECKER ); |
|
248 | + public static function getNoneOfChecker(?MediaWikiServices $services = null) { |
|
249 | + return self::getService($services, self::NONE_OF_CHECKER); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
253 | 253 | * @param MediaWikiServices|null $services |
254 | 254 | * @return ConstraintChecker |
255 | 255 | */ |
256 | - public static function getIntegerChecker( ?MediaWikiServices $services = null ) { |
|
257 | - return self::getService( $services, self::INTEGER_CHECKER ); |
|
256 | + public static function getIntegerChecker(?MediaWikiServices $services = null) { |
|
257 | + return self::getService($services, self::INTEGER_CHECKER); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | 261 | * @param MediaWikiServices|null $services |
262 | 262 | * @return ConstraintChecker |
263 | 263 | */ |
264 | - public static function getCitationNeededChecker( ?MediaWikiServices $services = null ) { |
|
265 | - return self::getService( $services, self::CITATION_NEEDED_CHECKER ); |
|
264 | + public static function getCitationNeededChecker(?MediaWikiServices $services = null) { |
|
265 | + return self::getService($services, self::CITATION_NEEDED_CHECKER); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | 269 | * @param MediaWikiServices|null $services |
270 | 270 | * @return ConstraintChecker |
271 | 271 | */ |
272 | - public static function getPropertyScopeChecker( ?MediaWikiServices $services = null ) { |
|
273 | - return self::getService( $services, self::PROPERTY_SCOPE_CHECKER ); |
|
272 | + public static function getPropertyScopeChecker(?MediaWikiServices $services = null) { |
|
273 | + return self::getService($services, self::PROPERTY_SCOPE_CHECKER); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
277 | 277 | * @param MediaWikiServices|null $services |
278 | 278 | * @return ConstraintChecker |
279 | 279 | */ |
280 | - public static function getContemporaryChecker( ?MediaWikiServices $services = null ) { |
|
281 | - return self::getService( $services, self::CONTEMPORARY_CHECKER ); |
|
280 | + public static function getContemporaryChecker(?MediaWikiServices $services = null) { |
|
281 | + return self::getService($services, self::CONTEMPORARY_CHECKER); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
285 | 285 | * @param MediaWikiServices|null $services |
286 | 286 | * @return LanguageChecker |
287 | 287 | */ |
288 | - public static function getLexemeLanguageChecker( ?MediaWikiServices $services = null ) { |
|
289 | - return self::getService( $services, self::LEXEME_LANGUAGE_CHECKER ); |
|
288 | + public static function getLexemeLanguageChecker(?MediaWikiServices $services = null) { |
|
289 | + return self::getService($services, self::LEXEME_LANGUAGE_CHECKER); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
293 | 293 | * @param MediaWikiServices|null $services |
294 | 294 | * @return LabelInLanguageChecker |
295 | 295 | */ |
296 | - public static function getLabelInLanguageChecker( ?MediaWikiServices $services = null ) { |
|
297 | - return self::getService( $services, self::LABEL_IN_LANGUAGE_CHECKER ); |
|
296 | + public static function getLabelInLanguageChecker(?MediaWikiServices $services = null) { |
|
297 | + return self::getService($services, self::LABEL_IN_LANGUAGE_CHECKER); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | } |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class ContextCursorDeserializer { |
13 | 13 | |
14 | - public function deserialize( array $serialization ): ContextCursor { |
|
15 | - switch ( $serialization['t'] ) { |
|
14 | + public function deserialize(array $serialization): ContextCursor { |
|
15 | + switch ($serialization['t']) { |
|
16 | 16 | case Context::TYPE_STATEMENT: |
17 | 17 | return new MainSnakContextCursor( |
18 | 18 | $serialization['i'], |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ); |
44 | 44 | default: |
45 | 45 | throw new InvalidArgumentException( |
46 | - 'Unknown serialization type ' . $serialization['t'] |
|
46 | + 'Unknown serialization type '.$serialization['t'] |
|
47 | 47 | ); |
48 | 48 | } |
49 | 49 | } |
@@ -39,23 +39,23 @@ discard block |
||
39 | 39 | $this->dataValueFactory = $dataValueFactory; |
40 | 40 | } |
41 | 41 | |
42 | - public function unabbreviateViolationMessageKey( string $messageKeySuffix ): string { |
|
43 | - return ViolationMessage::MESSAGE_KEY_PREFIX . $messageKeySuffix; |
|
42 | + public function unabbreviateViolationMessageKey(string $messageKeySuffix): string { |
|
43 | + return ViolationMessage::MESSAGE_KEY_PREFIX.$messageKeySuffix; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @param array $serialization |
48 | 48 | * @return ViolationMessage |
49 | 49 | */ |
50 | - public function deserialize( $serialization ) { |
|
51 | - Assert::parameterType( 'array', $serialization, '$serialization' ); |
|
50 | + public function deserialize($serialization) { |
|
51 | + Assert::parameterType('array', $serialization, '$serialization'); |
|
52 | 52 | |
53 | 53 | $message = new ViolationMessage( |
54 | - $this->unabbreviateViolationMessageKey( $serialization['k'] ) |
|
54 | + $this->unabbreviateViolationMessageKey($serialization['k']) |
|
55 | 55 | ); |
56 | 56 | |
57 | - foreach ( $serialization['a'] as $serializedArgument ) { |
|
58 | - $message = $this->deserializeArgument( $message, $serializedArgument ); |
|
57 | + foreach ($serialization['a'] as $serializedArgument) { |
|
58 | + $message = $this->deserializeArgument($message, $serializedArgument); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | return $message; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @param array $serializedArgument [ 't' => ViolationMessage::TYPE_*, 'v' => serialized value, 'r' => $role ] |
67 | 67 | * @return ViolationMessage $message with the deserialized argument appended |
68 | 68 | */ |
69 | - private function deserializeArgument( ViolationMessage $message, array $serializedArgument ) { |
|
69 | + private function deserializeArgument(ViolationMessage $message, array $serializedArgument) { |
|
70 | 70 | $methods = [ |
71 | 71 | ViolationMessage::TYPE_ENTITY_ID => 'deserializeEntityId', |
72 | 72 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'deserializeEntityIdList', |
@@ -88,23 +88,23 @@ discard block |
||
88 | 88 | $serializedValue = $serializedArgument['v']; |
89 | 89 | $role = $serializedArgument['r']; |
90 | 90 | |
91 | - if ( array_key_exists( $type, $methods ) ) { |
|
91 | + if (array_key_exists($type, $methods)) { |
|
92 | 92 | $method = $methods[$type]; |
93 | - $value = $this->$method( $serializedValue ); |
|
93 | + $value = $this->$method($serializedValue); |
|
94 | 94 | } else { |
95 | 95 | throw new InvalidArgumentException( |
96 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
96 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
97 | 97 | ); |
98 | 98 | } |
99 | 99 | |
100 | - return $message->withArgument( $type, $role, $value ); |
|
100 | + return $message->withArgument($type, $role, $value); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | 104 | * @param string $string any value that shall simply be deserialized into itself |
105 | 105 | * @return string that same value, unchanged |
106 | 106 | */ |
107 | - private function deserializeStringByIdentity( $string ) { |
|
107 | + private function deserializeStringByIdentity($string) { |
|
108 | 108 | return $string; |
109 | 109 | } |
110 | 110 | |
@@ -112,32 +112,32 @@ discard block |
||
112 | 112 | * @param string $entityIdSerialization entity ID serialization |
113 | 113 | * @return EntityId |
114 | 114 | */ |
115 | - private function deserializeEntityId( $entityIdSerialization ) { |
|
116 | - return $this->entityIdParser->parse( $entityIdSerialization ); |
|
115 | + private function deserializeEntityId($entityIdSerialization) { |
|
116 | + return $this->entityIdParser->parse($entityIdSerialization); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
120 | 120 | * @param string[] $entityIdSerializations entity ID serializations |
121 | 121 | * @return EntityId[] |
122 | 122 | */ |
123 | - private function deserializeEntityIdList( array $entityIdSerializations ) { |
|
124 | - return array_map( [ $this, 'deserializeEntityId' ], $entityIdSerializations ); |
|
123 | + private function deserializeEntityIdList(array $entityIdSerializations) { |
|
124 | + return array_map([$this, 'deserializeEntityId'], $entityIdSerializations); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | 128 | * @param string $valueSerialization entity ID serialization, '::somevalue' or '::novalue' |
129 | 129 | * @return ItemIdSnakValue |
130 | 130 | */ |
131 | - private function deserializeItemIdSnakValue( $valueSerialization ) { |
|
132 | - switch ( $valueSerialization ) { |
|
131 | + private function deserializeItemIdSnakValue($valueSerialization) { |
|
132 | + switch ($valueSerialization) { |
|
133 | 133 | case '::somevalue': |
134 | 134 | return ItemIdSnakValue::someValue(); |
135 | 135 | case '::novalue': |
136 | 136 | return ItemIdSnakValue::noValue(); |
137 | 137 | default: |
138 | - $itemId = $this->deserializeEntityId( $valueSerialization ); |
|
138 | + $itemId = $this->deserializeEntityId($valueSerialization); |
|
139 | 139 | '@phan-var \Wikibase\DataModel\Entity\ItemId $itemId'; |
140 | - return ItemIdSnakValue::fromItemId( $itemId ); |
|
140 | + return ItemIdSnakValue::fromItemId($itemId); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
@@ -145,24 +145,24 @@ discard block |
||
145 | 145 | * @param string[] $valueSerializations entity ID serializations, '::somevalue's or '::novalue's |
146 | 146 | * @return ItemIdSnakValue[] |
147 | 147 | */ |
148 | - private function deserializeItemIdSnakValueList( $valueSerializations ) { |
|
149 | - return array_map( [ $this, 'deserializeItemIdSnakValue' ], $valueSerializations ); |
|
148 | + private function deserializeItemIdSnakValueList($valueSerializations) { |
|
149 | + return array_map([$this, 'deserializeItemIdSnakValue'], $valueSerializations); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | 153 | * @param array $dataValueSerialization the data value in array form |
154 | 154 | * @return DataValue |
155 | 155 | */ |
156 | - private function deserializeDataValue( array $dataValueSerialization ) { |
|
157 | - return $this->dataValueFactory->newFromArray( $dataValueSerialization ); |
|
156 | + private function deserializeDataValue(array $dataValueSerialization) { |
|
157 | + return $this->dataValueFactory->newFromArray($dataValueSerialization); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
161 | 161 | * @param string $contextTypeAbbreviation |
162 | 162 | * @return string one of the Context::TYPE_* constants |
163 | 163 | */ |
164 | - private function deserializeContextType( $contextTypeAbbreviation ) { |
|
165 | - switch ( $contextTypeAbbreviation ) { |
|
164 | + private function deserializeContextType($contextTypeAbbreviation) { |
|
165 | + switch ($contextTypeAbbreviation) { |
|
166 | 166 | case 's': |
167 | 167 | return Context::TYPE_STATEMENT; |
168 | 168 | case 'q': |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | default: |
173 | 173 | // @codeCoverageIgnoreStart |
174 | 174 | throw new LogicException( |
175 | - 'Unknown context type abbreviation ' . $contextTypeAbbreviation |
|
175 | + 'Unknown context type abbreviation '.$contextTypeAbbreviation |
|
176 | 176 | ); |
177 | 177 | // @codeCoverageIgnoreEnd |
178 | 178 | } |
@@ -182,16 +182,16 @@ discard block |
||
182 | 182 | * @param string[] $contextTypeAbbreviations |
183 | 183 | * @return string[] Context::TYPE_* constants |
184 | 184 | */ |
185 | - private function deserializeContextTypeList( array $contextTypeAbbreviations ) { |
|
186 | - return array_map( [ $this, 'deserializeContextType' ], $contextTypeAbbreviations ); |
|
185 | + private function deserializeContextTypeList(array $contextTypeAbbreviations) { |
|
186 | + return array_map([$this, 'deserializeContextType'], $contextTypeAbbreviations); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
190 | 190 | * @param mixed $textSerialization {@see MultilingualTextValue::getArrayValue} |
191 | 191 | * @return MultilingualTextValue |
192 | 192 | */ |
193 | - private function deserializeMultilingualText( $textSerialization ) { |
|
194 | - return MultilingualTextValue::newFromArray( $textSerialization ); |
|
193 | + private function deserializeMultilingualText($textSerialization) { |
|
194 | + return MultilingualTextValue::newFromArray($textSerialization); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->config = $config; |
54 | 54 | $this->timeParser = new IsoTimestampParser(); |
55 | 55 | $this->timeCalculator = new TimeValueCalculator(); |
56 | - $this->timeValueComparer = new TimeValueComparer( $this->timeCalculator ); |
|
56 | + $this->timeValueComparer = new TimeValueComparer($this->timeCalculator); |
|
57 | 57 | $this->unitConverter = $unitConverter; |
58 | 58 | } |
59 | 59 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * @param UnboundedQuantityValue $value |
62 | 62 | * @return UnboundedQuantityValue $value converted to standard units if possible, otherwise unchanged $value. |
63 | 63 | */ |
64 | - private function standardize( UnboundedQuantityValue $value ) { |
|
65 | - if ( $this->unitConverter !== null ) { |
|
66 | - $standard = $this->unitConverter->toStandardUnits( $value ); |
|
67 | - if ( $standard !== null ) { |
|
64 | + private function standardize(UnboundedQuantityValue $value) { |
|
65 | + if ($this->unitConverter !== null) { |
|
66 | + $standard = $this->unitConverter->toStandardUnits($value); |
|
67 | + if ($standard !== null) { |
|
68 | 68 | return $standard; |
69 | 69 | } else { |
70 | 70 | return $value; |
@@ -86,33 +86,33 @@ discard block |
||
86 | 86 | * when $lhs is respectively less than, equal to, or greater than $rhs. |
87 | 87 | * (In other words, just like the “spaceship” operator <=>.) |
88 | 88 | */ |
89 | - public function getComparison( ?DataValue $lhs, ?DataValue $rhs ) { |
|
90 | - if ( $lhs === null || $rhs === null ) { |
|
89 | + public function getComparison(?DataValue $lhs, ?DataValue $rhs) { |
|
90 | + if ($lhs === null || $rhs === null) { |
|
91 | 91 | return 0; |
92 | 92 | } |
93 | 93 | |
94 | - if ( $lhs->getType() !== $rhs->getType() ) { |
|
95 | - throw new InvalidArgumentException( 'Different data value types' ); |
|
94 | + if ($lhs->getType() !== $rhs->getType()) { |
|
95 | + throw new InvalidArgumentException('Different data value types'); |
|
96 | 96 | } |
97 | 97 | |
98 | - switch ( $lhs->getType() ) { |
|
98 | + switch ($lhs->getType()) { |
|
99 | 99 | case 'time': |
100 | 100 | /** @var TimeValue $lhs */ |
101 | 101 | /** @var TimeValue $rhs */ |
102 | 102 | '@phan-var TimeValue $lhs'; |
103 | 103 | '@phan-var TimeValue $rhs'; |
104 | - return $this->timeValueComparer->getComparison( $lhs, $rhs ); |
|
104 | + return $this->timeValueComparer->getComparison($lhs, $rhs); |
|
105 | 105 | case 'quantity': |
106 | 106 | /** @var QuantityValue|UnboundedQuantityValue $lhs */ |
107 | 107 | /** @var QuantityValue|UnboundedQuantityValue $rhs */ |
108 | 108 | '@phan-var QuantityValue|UnboundedQuantityValue $lhs'; |
109 | 109 | '@phan-var QuantityValue|UnboundedQuantityValue $rhs'; |
110 | - $lhsStandard = $this->standardize( $lhs ); |
|
111 | - $rhsStandard = $this->standardize( $rhs ); |
|
112 | - return $lhsStandard->getAmount()->compare( $rhsStandard->getAmount() ); |
|
110 | + $lhsStandard = $this->standardize($lhs); |
|
111 | + $rhsStandard = $this->standardize($rhs); |
|
112 | + return $lhsStandard->getAmount()->compare($rhsStandard->getAmount()); |
|
113 | 113 | } |
114 | 114 | |
115 | - throw new InvalidArgumentException( 'Unsupported data value type' ); |
|
115 | + throw new InvalidArgumentException('Unsupported data value type'); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -127,71 +127,71 @@ discard block |
||
127 | 127 | * @throws InvalidArgumentException if the values do not both have the same, supported data value type |
128 | 128 | * @return UnboundedQuantityValue |
129 | 129 | */ |
130 | - public function getDifference( DataValue $minuend, DataValue $subtrahend ) { |
|
131 | - if ( $minuend->getType() === 'time' && $subtrahend->getType() === 'time' ) { |
|
132 | - $minuendSeconds = $this->timeCalculator->getTimestamp( $minuend ); |
|
133 | - $subtrahendSeconds = $this->timeCalculator->getTimestamp( $subtrahend ); |
|
130 | + public function getDifference(DataValue $minuend, DataValue $subtrahend) { |
|
131 | + if ($minuend->getType() === 'time' && $subtrahend->getType() === 'time') { |
|
132 | + $minuendSeconds = $this->timeCalculator->getTimestamp($minuend); |
|
133 | + $subtrahendSeconds = $this->timeCalculator->getTimestamp($subtrahend); |
|
134 | 134 | return UnboundedQuantityValue::newFromNumber( |
135 | 135 | $minuendSeconds - $subtrahendSeconds, |
136 | - $this->config->get( 'WBQualityConstraintsSecondUnit' ) |
|
136 | + $this->config->get('WBQualityConstraintsSecondUnit') |
|
137 | 137 | ); |
138 | 138 | } |
139 | - if ( $minuend->getType() === 'quantity' && $subtrahend->getType() === 'quantity' ) { |
|
140 | - $minuendStandard = $this->standardize( $minuend ); |
|
141 | - $subtrahendStandard = $this->standardize( $subtrahend ); |
|
139 | + if ($minuend->getType() === 'quantity' && $subtrahend->getType() === 'quantity') { |
|
140 | + $minuendStandard = $this->standardize($minuend); |
|
141 | + $subtrahendStandard = $this->standardize($subtrahend); |
|
142 | 142 | $minuendValue = $minuendStandard->getAmount()->getValueFloat(); |
143 | 143 | $subtrahendValue = $subtrahendStandard->getAmount()->getValueFloat(); |
144 | 144 | $diff = $minuendValue - $subtrahendValue; |
145 | 145 | // we don’t check whether both quantities have the same standard unit – |
146 | 146 | // that’s the job of a different constraint type, Units (T164372) |
147 | - return UnboundedQuantityValue::newFromNumber( $diff, $minuendStandard->getUnit() ); |
|
147 | + return UnboundedQuantityValue::newFromNumber($diff, $minuendStandard->getUnit()); |
|
148 | 148 | } |
149 | 149 | |
150 | - throw new InvalidArgumentException( 'Unsupported or different data value types' ); |
|
150 | + throw new InvalidArgumentException('Unsupported or different data value types'); |
|
151 | 151 | } |
152 | 152 | |
153 | - public function getDifferenceInYears( TimeValue $minuend, TimeValue $subtrahend ): DataValue { |
|
154 | - if ( !preg_match( '/^([-+]\d{1,16})-(.*)$/', $minuend->getTime(), $minuendMatches ) || |
|
155 | - !preg_match( '/^([-+]\d{1,16})-(.*)$/', $subtrahend->getTime(), $subtrahendMatches ) |
|
153 | + public function getDifferenceInYears(TimeValue $minuend, TimeValue $subtrahend): DataValue { |
|
154 | + if (!preg_match('/^([-+]\d{1,16})-(.*)$/', $minuend->getTime(), $minuendMatches) || |
|
155 | + !preg_match('/^([-+]\d{1,16})-(.*)$/', $subtrahend->getTime(), $subtrahendMatches) |
|
156 | 156 | ) { |
157 | - throw new InvalidArgumentException( 'TimeValue::getTime() did not match expected format' ); |
|
157 | + throw new InvalidArgumentException('TimeValue::getTime() did not match expected format'); |
|
158 | 158 | } |
159 | - $minuendYear = (float)$minuendMatches[1]; |
|
160 | - $subtrahendYear = (float)$subtrahendMatches[1]; |
|
159 | + $minuendYear = (float) $minuendMatches[1]; |
|
160 | + $subtrahendYear = (float) $subtrahendMatches[1]; |
|
161 | 161 | $minuendRest = $minuendMatches[2]; |
162 | 162 | $subtrahendRest = $subtrahendMatches[2]; |
163 | 163 | |
164 | 164 | // calculate difference of years |
165 | 165 | $diff = $minuendYear - $subtrahendYear; |
166 | - if ( $minuendYear > 0.0 && $subtrahendYear < 0.0 ) { |
|
166 | + if ($minuendYear > 0.0 && $subtrahendYear < 0.0) { |
|
167 | 167 | $diff -= 1.0; // there is no year 0, remove it from difference |
168 | - } elseif ( $minuendYear < 0.0 && $subtrahendYear > 0.0 ) { |
|
168 | + } elseif ($minuendYear < 0.0 && $subtrahendYear > 0.0) { |
|
169 | 169 | $diff -= -1.0; // there is no year 0, remove it from negative difference |
170 | 170 | } |
171 | 171 | |
172 | 172 | // adjust for date within year by parsing the month-day part within the same year |
173 | - $minuendDateValue = $this->timeParser->parse( '+0000000000001970-' . $minuendRest ); |
|
174 | - $subtrahendDateValue = $this->timeParser->parse( '+0000000000001970-' . $subtrahendRest ); |
|
175 | - $minuendDateSeconds = $this->timeCalculator->getTimestamp( $minuendDateValue ); |
|
176 | - $subtrahendDateSeconds = $this->timeCalculator->getTimestamp( $subtrahendDateValue ); |
|
177 | - if ( $minuendDateSeconds < $subtrahendDateSeconds ) { |
|
173 | + $minuendDateValue = $this->timeParser->parse('+0000000000001970-'.$minuendRest); |
|
174 | + $subtrahendDateValue = $this->timeParser->parse('+0000000000001970-'.$subtrahendRest); |
|
175 | + $minuendDateSeconds = $this->timeCalculator->getTimestamp($minuendDateValue); |
|
176 | + $subtrahendDateSeconds = $this->timeCalculator->getTimestamp($subtrahendDateValue); |
|
177 | + if ($minuendDateSeconds < $subtrahendDateSeconds) { |
|
178 | 178 | // difference in the last year is actually less than one full year |
179 | 179 | // e. g. 1975-03-01 - 1974-09-01 is just six months |
180 | 180 | // (we don’t need sub-year precision in the difference, adjusting by 0.5 is enough) |
181 | 181 | $diff -= 0.5; |
182 | - } elseif ( $minuendDateSeconds > $subtrahendDateSeconds ) { |
|
182 | + } elseif ($minuendDateSeconds > $subtrahendDateSeconds) { |
|
183 | 183 | // difference in the last year is actually more than one full year |
184 | 184 | // e. g. 1975-09-01 - 1974-03-01 is 18 months |
185 | 185 | // (we don’t need sub-year precision in the difference, adjusting by 0.5 is enough) |
186 | 186 | $diff += 0.5; |
187 | 187 | } |
188 | 188 | |
189 | - $unit = $this->config->get( 'WBQualityConstraintsYearUnit' ); |
|
190 | - return UnboundedQuantityValue::newFromNumber( $diff, $unit ); |
|
189 | + $unit = $this->config->get('WBQualityConstraintsYearUnit'); |
|
190 | + return UnboundedQuantityValue::newFromNumber($diff, $unit); |
|
191 | 191 | } |
192 | 192 | |
193 | - public function isFutureTime( TimeValue $timeValue ): bool { |
|
194 | - return $this->timeValueComparer->isFutureTime( $timeValue ); |
|
193 | + public function isFutureTime(TimeValue $timeValue): bool { |
|
194 | + return $this->timeValueComparer->isFutureTime($timeValue); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |
@@ -9,8 +9,8 @@ |
||
9 | 9 | */ |
10 | 10 | class SparqlHelperException extends RuntimeException { |
11 | 11 | |
12 | - public function __construct( string $msg = 'The SPARQL query endpoint returned an error.' ) { |
|
13 | - parent::__construct( $msg ); |
|
12 | + public function __construct(string $msg = 'The SPARQL query endpoint returned an error.') { |
|
13 | + parent::__construct($msg); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | } |
@@ -16,27 +16,27 @@ |
||
16 | 16 | */ |
17 | 17 | private $timeValueCalculator; |
18 | 18 | |
19 | - public function __construct( ?TimeValueCalculator $timeValueCalculator = null ) { |
|
19 | + public function __construct(?TimeValueCalculator $timeValueCalculator = null) { |
|
20 | 20 | $this->timeValueCalculator = $timeValueCalculator ?: new TimeValueCalculator(); |
21 | 21 | } |
22 | 22 | |
23 | - public function getComparison( TimeValue $lhs, TimeValue $rhs ): int { |
|
24 | - $lhsTimestamp = $this->timeValueCalculator->getTimestamp( $lhs ); |
|
25 | - $rhsTimestamp = $this->timeValueCalculator->getTimestamp( $rhs ); |
|
23 | + public function getComparison(TimeValue $lhs, TimeValue $rhs): int { |
|
24 | + $lhsTimestamp = $this->timeValueCalculator->getTimestamp($lhs); |
|
25 | + $rhsTimestamp = $this->timeValueCalculator->getTimestamp($rhs); |
|
26 | 26 | |
27 | - if ( $lhsTimestamp === $rhsTimestamp ) { |
|
27 | + if ($lhsTimestamp === $rhsTimestamp) { |
|
28 | 28 | return 0; |
29 | 29 | } |
30 | 30 | |
31 | 31 | return $lhsTimestamp < $rhsTimestamp ? -1 : 1; |
32 | 32 | } |
33 | 33 | |
34 | - public function getMinimum( TimeValue $timeValue1, TimeValue $timeValue2 ): TimeValue { |
|
35 | - return $this->getComparison( $timeValue1, $timeValue2 ) <= 0 ? $timeValue1 : $timeValue2; |
|
34 | + public function getMinimum(TimeValue $timeValue1, TimeValue $timeValue2): TimeValue { |
|
35 | + return $this->getComparison($timeValue1, $timeValue2) <= 0 ? $timeValue1 : $timeValue2; |
|
36 | 36 | } |
37 | 37 | |
38 | - public function isFutureTime( TimeValue $timeValue ): bool { |
|
39 | - return $this->getComparison( $timeValue, new NowValue() ) >= 0; |
|
38 | + public function isFutureTime(TimeValue $timeValue): bool { |
|
39 | + return $this->getComparison($timeValue, new NowValue()) >= 0; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | } |
@@ -10,14 +10,13 @@ |
||
10 | 10 | */ |
11 | 11 | class ConstraintDeserializer { |
12 | 12 | |
13 | - public function deserialize( array $serialization ): Constraint { |
|
13 | + public function deserialize(array $serialization): Constraint { |
|
14 | 14 | return new Constraint( |
15 | 15 | $serialization['id'], |
16 | - new NumericPropertyId( $serialization['pid'] ), |
|
16 | + new NumericPropertyId($serialization['pid']), |
|
17 | 17 | $serialization['qid'], |
18 | - array_key_exists( 'params', $serialization ) ? |
|
19 | - $serialization['params'] : |
|
20 | - [] |
|
18 | + array_key_exists('params', $serialization) ? |
|
19 | + $serialization['params'] : [] |
|
21 | 20 | ); |
22 | 21 | } |
23 | 22 |
@@ -40,91 +40,91 @@ |
||
40 | 40 | public const EXPIRY_LOCK = 'WBQC_ExpiryLock'; |
41 | 41 | public const VIOLATION_MESSAGE_RENDERER_FACTORY = 'WBQC_ViolationMessageRendererFactory'; |
42 | 42 | |
43 | - private static function getService( ?MediaWikiServices $services, string $name ) { |
|
43 | + private static function getService(?MediaWikiServices $services, string $name) { |
|
44 | 44 | $services ??= MediaWikiServices::getInstance(); |
45 | - return $services->getService( $name ); |
|
45 | + return $services->getService($name); |
|
46 | 46 | } |
47 | 47 | |
48 | - public static function getLoggingHelper( ?MediaWikiServices $services = null ): LoggingHelper { |
|
49 | - return self::getService( $services, self::LOGGING_HELPER ); |
|
48 | + public static function getLoggingHelper(?MediaWikiServices $services = null): LoggingHelper { |
|
49 | + return self::getService($services, self::LOGGING_HELPER); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public static function getConstraintStore( |
53 | 53 | ?MediaWikiServices $services = null |
54 | 54 | ): ConstraintStore { |
55 | - return self::getService( $services, self::CONSTRAINT_STORE ); |
|
55 | + return self::getService($services, self::CONSTRAINT_STORE); |
|
56 | 56 | } |
57 | 57 | |
58 | - public static function getConstraintLookup( ?MediaWikiServices $services = null ): ConstraintLookup { |
|
59 | - return self::getService( $services, self::CONSTRAINT_LOOKUP ); |
|
58 | + public static function getConstraintLookup(?MediaWikiServices $services = null): ConstraintLookup { |
|
59 | + return self::getService($services, self::CONSTRAINT_LOOKUP); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | public static function getCheckResultSerializer( |
63 | 63 | ?MediaWikiServices $services = null |
64 | 64 | ): CheckResultSerializer { |
65 | - return self::getService( $services, self::CHECK_RESULT_SERIALIZER ); |
|
65 | + return self::getService($services, self::CHECK_RESULT_SERIALIZER); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | public static function getCheckResultDeserializer( |
69 | 69 | ?MediaWikiServices $services = null |
70 | 70 | ): CheckResultDeserializer { |
71 | - return self::getService( $services, self::CHECK_RESULT_DESERIALIZER ); |
|
71 | + return self::getService($services, self::CHECK_RESULT_DESERIALIZER); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public static function getViolationMessageSerializer( |
75 | 75 | ?MediaWikiServices $services = null |
76 | 76 | ): ViolationMessageSerializer { |
77 | - return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER ); |
|
77 | + return self::getService($services, self::VIOLATION_MESSAGE_SERIALIZER); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | public static function getViolationMessageDeserializer( |
81 | 81 | ?MediaWikiServices $services = null |
82 | 82 | ): ViolationMessageDeserializer { |
83 | - return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER ); |
|
83 | + return self::getService($services, self::VIOLATION_MESSAGE_DESERIALIZER); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | public static function getConstraintParameterParser( |
87 | 87 | ?MediaWikiServices $services = null |
88 | 88 | ): ConstraintParameterParser { |
89 | - return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER ); |
|
89 | + return self::getService($services, self::CONSTRAINT_PARAMETER_PARSER); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | public static function getConnectionCheckerHelper( |
93 | 93 | ?MediaWikiServices $services = null |
94 | 94 | ): ConnectionCheckerHelper { |
95 | - return self::getService( $services, self::CONNECTION_CHECKER_HELPER ); |
|
95 | + return self::getService($services, self::CONNECTION_CHECKER_HELPER); |
|
96 | 96 | } |
97 | 97 | |
98 | - public static function getRangeCheckerHelper( ?MediaWikiServices $services = null ): RangeCheckerHelper { |
|
99 | - return self::getService( $services, self::RANGE_CHECKER_HELPER ); |
|
98 | + public static function getRangeCheckerHelper(?MediaWikiServices $services = null): RangeCheckerHelper { |
|
99 | + return self::getService($services, self::RANGE_CHECKER_HELPER); |
|
100 | 100 | } |
101 | 101 | |
102 | - public static function getSparqlHelper( ?MediaWikiServices $services = null ): SparqlHelper { |
|
103 | - return self::getService( $services, self::SPARQL_HELPER ); |
|
102 | + public static function getSparqlHelper(?MediaWikiServices $services = null): SparqlHelper { |
|
103 | + return self::getService($services, self::SPARQL_HELPER); |
|
104 | 104 | } |
105 | 105 | |
106 | - public static function getTypeCheckerHelper( ?MediaWikiServices $services = null ): TypeCheckerHelper { |
|
107 | - return self::getService( $services, self::TYPE_CHECKER_HELPER ); |
|
106 | + public static function getTypeCheckerHelper(?MediaWikiServices $services = null): TypeCheckerHelper { |
|
107 | + return self::getService($services, self::TYPE_CHECKER_HELPER); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | public static function getDelegatingConstraintChecker( |
111 | 111 | ?MediaWikiServices $services = null |
112 | 112 | ): DelegatingConstraintChecker { |
113 | - return self::getService( $services, self::DELEGATING_CONSTRAINT_CHECKER ); |
|
113 | + return self::getService($services, self::DELEGATING_CONSTRAINT_CHECKER); |
|
114 | 114 | } |
115 | 115 | |
116 | - public static function getResultsSource( ?MediaWikiServices $services = null ): ResultsSource { |
|
117 | - return self::getService( $services, self::RESULTS_SOURCE ); |
|
116 | + public static function getResultsSource(?MediaWikiServices $services = null): ResultsSource { |
|
117 | + return self::getService($services, self::RESULTS_SOURCE); |
|
118 | 118 | } |
119 | 119 | |
120 | - public static function getExpiryLock( ?MediaWikiServices $services = null ): ExpiryLock { |
|
121 | - return self::getService( $services, self::EXPIRY_LOCK ); |
|
120 | + public static function getExpiryLock(?MediaWikiServices $services = null): ExpiryLock { |
|
121 | + return self::getService($services, self::EXPIRY_LOCK); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | public static function getViolationMessageRendererFactory( |
125 | 125 | ?MediaWikiServices $services = null |
126 | 126 | ): ViolationMessageRendererFactory { |
127 | - return self::getService( $services, self::VIOLATION_MESSAGE_RENDERER_FACTORY ); |
|
127 | + return self::getService($services, self::VIOLATION_MESSAGE_RENDERER_FACTORY); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | } |
@@ -44,57 +44,56 @@ |
||
44 | 44 | ) { |
45 | 45 | $results = []; |
46 | 46 | $metadatas = []; |
47 | - $statusesFlipped = array_flip( $statuses ); |
|
48 | - foreach ( $entityIds as $entityId ) { |
|
47 | + $statusesFlipped = array_flip($statuses); |
|
48 | + foreach ($entityIds as $entityId) { |
|
49 | 49 | $entityResults = $this->delegatingConstraintChecker->checkAgainstConstraintsOnEntityId( |
50 | 50 | $entityId, |
51 | 51 | $constraintIds, |
52 | - [ $this, 'defaultResultsPerContext' ], |
|
53 | - [ $this, 'defaultResultsPerEntity' ] |
|
52 | + [$this, 'defaultResultsPerContext'], |
|
53 | + [$this, 'defaultResultsPerEntity'] |
|
54 | 54 | ); |
55 | - foreach ( $entityResults as $result ) { |
|
55 | + foreach ($entityResults as $result) { |
|
56 | 56 | $metadatas[] = $result->getMetadata(); |
57 | - if ( $this->statusSelected( $statusesFlipped, $result ) ) { |
|
57 | + if ($this->statusSelected($statusesFlipped, $result)) { |
|
58 | 58 | $results[] = $result; |
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
62 | - foreach ( $claimIds as $claimId ) { |
|
62 | + foreach ($claimIds as $claimId) { |
|
63 | 63 | $claimResults = $this->delegatingConstraintChecker->checkAgainstConstraintsOnClaimId( |
64 | 64 | $claimId, |
65 | 65 | $constraintIds, |
66 | - [ $this, 'defaultResultsPerContext' ] |
|
66 | + [$this, 'defaultResultsPerContext'] |
|
67 | 67 | ); |
68 | - foreach ( $claimResults as $result ) { |
|
68 | + foreach ($claimResults as $result) { |
|
69 | 69 | $metadatas[] = $result->getMetadata(); |
70 | - if ( $this->statusSelected( $statusesFlipped, $result ) ) { |
|
70 | + if ($this->statusSelected($statusesFlipped, $result)) { |
|
71 | 71 | $results[] = $result; |
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
75 | 75 | return new CachedCheckResults( |
76 | 76 | $results, |
77 | - Metadata::merge( $metadatas ) |
|
77 | + Metadata::merge($metadatas) |
|
78 | 78 | ); |
79 | 79 | } |
80 | 80 | |
81 | - public function defaultResultsPerContext( Context $context ): array { |
|
81 | + public function defaultResultsPerContext(Context $context): array { |
|
82 | 82 | return $context->getType() === Context::TYPE_STATEMENT ? |
83 | - [ new NullResult( $context->getCursor() ) ] : |
|
84 | - []; |
|
83 | + [new NullResult($context->getCursor())] : []; |
|
85 | 84 | } |
86 | 85 | |
87 | - public function defaultResultsPerEntity( EntityId $entityId ): array { |
|
86 | + public function defaultResultsPerEntity(EntityId $entityId): array { |
|
88 | 87 | return [ |
89 | - ( new NullResult( new EntityContextCursor( $entityId->getSerialization() ) ) ) |
|
90 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
91 | - DependencyMetadata::ofEntityId( $entityId ) |
|
92 | - ) ), |
|
88 | + (new NullResult(new EntityContextCursor($entityId->getSerialization()))) |
|
89 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
90 | + DependencyMetadata::ofEntityId($entityId) |
|
91 | + )), |
|
93 | 92 | ]; |
94 | 93 | } |
95 | 94 | |
96 | - public function statusSelected( array $statusesFlipped, CheckResult $result ): bool { |
|
97 | - return array_key_exists( $result->getStatus(), $statusesFlipped ) || |
|
95 | + public function statusSelected(array $statusesFlipped, CheckResult $result): bool { |
|
96 | + return array_key_exists($result->getStatus(), $statusesFlipped) || |
|
98 | 97 | $result instanceof NullResult; |
99 | 98 | } |
100 | 99 |