@@ -40,243 +40,243 @@ |
||
40 | 40 | public const PROPERTY_SCOPE_CHECKER = 'WBQC_PropertyScopeChecker'; |
41 | 41 | public 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 | } |
@@ -24,22 +24,22 @@ |
||
24 | 24 | */ |
25 | 25 | private const NULL_PROPERTY_ID = 'P2147483647'; |
26 | 26 | |
27 | - public function __construct( ContextCursor $contextCursor ) { |
|
27 | + public function __construct(ContextCursor $contextCursor) { |
|
28 | 28 | $constraint = new Constraint( |
29 | 29 | 'null', |
30 | - new PropertyId( self::NULL_PROPERTY_ID ), |
|
30 | + new PropertyId(self::NULL_PROPERTY_ID), |
|
31 | 31 | 'none', |
32 | 32 | [] |
33 | 33 | ); |
34 | - parent::__construct( $contextCursor, $constraint ); |
|
34 | + parent::__construct($contextCursor, $constraint); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function getConstraint() { |
38 | - throw new DomainException( 'NullResult holds no constraint' ); |
|
38 | + throw new DomainException('NullResult holds no constraint'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function getConstraintId() { |
42 | - throw new DomainException( 'NullResult holds no constraint' ); |
|
42 | + throw new DomainException('NullResult holds no constraint'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | } |
@@ -20,35 +20,35 @@ |
||
20 | 20 | public const PROPERTY_DATA_TYPE_LOOKUP = 'WBQC_PropertyDataTypeLookup'; |
21 | 21 | public const ENTITY_LOOKUP_WITHOUT_CACHE = 'WBQC_EntityLookupWithoutCache'; |
22 | 22 | |
23 | - private static function getService( ?MediaWikiServices $services, $name ) { |
|
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 | } |
@@ -77,17 +77,17 @@ discard block |
||
77 | 77 | * @param ViolationMessage $violationMessage |
78 | 78 | * @return string |
79 | 79 | */ |
80 | - public function render( ViolationMessage $violationMessage ) { |
|
80 | + public function render(ViolationMessage $violationMessage) { |
|
81 | 81 | $messageKey = $violationMessage->getMessageKey(); |
82 | - $paramsLists = [ [] ]; |
|
83 | - foreach ( $violationMessage->getArguments() as $argument ) { |
|
84 | - $params = $this->renderArgument( $argument ); |
|
82 | + $paramsLists = [[]]; |
|
83 | + foreach ($violationMessage->getArguments() as $argument) { |
|
84 | + $params = $this->renderArgument($argument); |
|
85 | 85 | $paramsLists[] = $params; |
86 | 86 | } |
87 | - $allParams = call_user_func_array( 'array_merge', $paramsLists ); |
|
87 | + $allParams = call_user_func_array('array_merge', $paramsLists); |
|
88 | 88 | return $this->messageLocalizer |
89 | - ->msg( $messageKey ) |
|
90 | - ->params( $allParams ) |
|
89 | + ->msg($messageKey) |
|
90 | + ->params($allParams) |
|
91 | 91 | ->escaped(); |
92 | 92 | } |
93 | 93 | |
@@ -96,13 +96,13 @@ discard block |
||
96 | 96 | * @param string|null $role one of the Role::* constants |
97 | 97 | * @return string HTML |
98 | 98 | */ |
99 | - protected function addRole( $value, $role ) { |
|
100 | - if ( $role === null ) { |
|
99 | + protected function addRole($value, $role) { |
|
100 | + if ($role === null) { |
|
101 | 101 | return $value; |
102 | 102 | } |
103 | 103 | |
104 | - return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' . |
|
105 | - $value . |
|
104 | + return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'. |
|
105 | + $value. |
|
106 | 106 | '</span>'; |
107 | 107 | } |
108 | 108 | |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | * @param string $key message key |
111 | 111 | * @return string HTML |
112 | 112 | */ |
113 | - protected function msgEscaped( $key ) { |
|
114 | - return $this->messageLocalizer->msg( $key )->escaped(); |
|
113 | + protected function msgEscaped($key) { |
|
114 | + return $this->messageLocalizer->msg($key)->escaped(); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | 118 | * @param array $argument |
119 | 119 | * @return array[] params (for Message::params) |
120 | 120 | */ |
121 | - protected function renderArgument( array $argument ) { |
|
121 | + protected function renderArgument(array $argument) { |
|
122 | 122 | $methods = [ |
123 | 123 | ViolationMessage::TYPE_ENTITY_ID => 'renderEntityId', |
124 | 124 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'renderEntityIdList', |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | $value = $argument['value']; |
139 | 139 | $role = $argument['role']; |
140 | 140 | |
141 | - if ( array_key_exists( $type, $methods ) ) { |
|
141 | + if (array_key_exists($type, $methods)) { |
|
142 | 142 | $method = $methods[$type]; |
143 | - $params = $this->$method( $value, $role ); |
|
143 | + $params = $this->$method($value, $role); |
|
144 | 144 | } else { |
145 | 145 | throw new InvalidArgumentException( |
146 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
146 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
147 | 147 | ); |
148 | 148 | } |
149 | 149 | |
@@ -157,46 +157,46 @@ discard block |
||
157 | 157 | * and return a single-element array with a raw message param (i. e. [ Message::rawParam( … ) ]) |
158 | 158 | * @return array[] list of parameters as accepted by Message::params() |
159 | 159 | */ |
160 | - private function renderList( array $list, $role, callable $render ) { |
|
161 | - if ( $list === [] ) { |
|
160 | + private function renderList(array $list, $role, callable $render) { |
|
161 | + if ($list === []) { |
|
162 | 162 | return [ |
163 | - Message::numParam( 0 ), |
|
164 | - Message::rawParam( '<ul></ul>' ), |
|
163 | + Message::numParam(0), |
|
164 | + Message::rawParam('<ul></ul>'), |
|
165 | 165 | ]; |
166 | 166 | } |
167 | 167 | |
168 | - if ( count( $list ) > $this->maxListLength ) { |
|
169 | - $list = array_slice( $list, 0, $this->maxListLength ); |
|
168 | + if (count($list) > $this->maxListLength) { |
|
169 | + $list = array_slice($list, 0, $this->maxListLength); |
|
170 | 170 | $truncated = true; |
171 | 171 | } |
172 | 172 | |
173 | 173 | $renderedParamsLists = array_map( |
174 | 174 | $render, |
175 | 175 | $list, |
176 | - array_fill( 0, count( $list ), $role ) |
|
176 | + array_fill(0, count($list), $role) |
|
177 | 177 | ); |
178 | 178 | $renderedParams = array_map( |
179 | - function ( $params ) { |
|
179 | + function($params) { |
|
180 | 180 | return $params[0]; |
181 | 181 | }, |
182 | 182 | $renderedParamsLists |
183 | 183 | ); |
184 | 184 | $renderedElements = array_map( |
185 | - function ( $param ) { |
|
185 | + function($param) { |
|
186 | 186 | return $param['raw']; |
187 | 187 | }, |
188 | 188 | $renderedParams |
189 | 189 | ); |
190 | - if ( isset( $truncated ) ) { |
|
191 | - $renderedElements[] = $this->msgEscaped( 'ellipsis' ); |
|
190 | + if (isset($truncated)) { |
|
191 | + $renderedElements[] = $this->msgEscaped('ellipsis'); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | return array_merge( |
195 | 195 | [ |
196 | - Message::numParam( count( $list ) ), |
|
196 | + Message::numParam(count($list)), |
|
197 | 197 | Message::rawParam( |
198 | - '<ul><li>' . |
|
199 | - implode( '</li><li>', $renderedElements ) . |
|
198 | + '<ul><li>'. |
|
199 | + implode('</li><li>', $renderedElements). |
|
200 | 200 | '</li></ul>' |
201 | 201 | ), |
202 | 202 | ], |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | * @param string|null $role one of the Role::* constants |
210 | 210 | * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
211 | 211 | */ |
212 | - private function renderEntityId( EntityId $entityId, $role ) { |
|
213 | - return [ Message::rawParam( $this->addRole( |
|
214 | - $this->entityIdFormatter->formatEntityId( $entityId ), |
|
212 | + private function renderEntityId(EntityId $entityId, $role) { |
|
213 | + return [Message::rawParam($this->addRole( |
|
214 | + $this->entityIdFormatter->formatEntityId($entityId), |
|
215 | 215 | $role |
216 | - ) ) ]; |
|
216 | + ))]; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @param string|null $role one of the Role::* constants |
222 | 222 | * @return array[] list of parameters as accepted by Message::params() |
223 | 223 | */ |
224 | - private function renderEntityIdList( array $entityIdList, $role ) { |
|
225 | - return $this->renderList( $entityIdList, $role, [ $this, 'renderEntityId' ] ); |
|
224 | + private function renderEntityIdList(array $entityIdList, $role) { |
|
225 | + return $this->renderList($entityIdList, $role, [$this, 'renderEntityId']); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -230,24 +230,24 @@ discard block |
||
230 | 230 | * @param string|null $role one of the Role::* constants |
231 | 231 | * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
232 | 232 | */ |
233 | - private function renderItemIdSnakValue( ItemIdSnakValue $value, $role ) { |
|
234 | - switch ( true ) { |
|
233 | + private function renderItemIdSnakValue(ItemIdSnakValue $value, $role) { |
|
234 | + switch (true) { |
|
235 | 235 | case $value->isValue(): |
236 | - return $this->renderEntityId( $value->getItemId(), $role ); |
|
236 | + return $this->renderEntityId($value->getItemId(), $role); |
|
237 | 237 | case $value->isSomeValue(): |
238 | - return [ Message::rawParam( $this->addRole( |
|
239 | - '<span class="wikibase-snakview-variation-somevaluesnak">' . |
|
240 | - $this->msgEscaped( 'wikibase-snakview-snaktypeselector-somevalue' ) . |
|
238 | + return [Message::rawParam($this->addRole( |
|
239 | + '<span class="wikibase-snakview-variation-somevaluesnak">'. |
|
240 | + $this->msgEscaped('wikibase-snakview-snaktypeselector-somevalue'). |
|
241 | 241 | '</span>', |
242 | 242 | $role |
243 | - ) ) ]; |
|
243 | + ))]; |
|
244 | 244 | case $value->isNoValue(): |
245 | - return [ Message::rawParam( $this->addRole( |
|
246 | - '<span class="wikibase-snakview-variation-novaluesnak">' . |
|
247 | - $this->msgEscaped( 'wikibase-snakview-snaktypeselector-novalue' ) . |
|
245 | + return [Message::rawParam($this->addRole( |
|
246 | + '<span class="wikibase-snakview-variation-novaluesnak">'. |
|
247 | + $this->msgEscaped('wikibase-snakview-snaktypeselector-novalue'). |
|
248 | 248 | '</span>', |
249 | 249 | $role |
250 | - ) ) ]; |
|
250 | + ))]; |
|
251 | 251 | default: |
252 | 252 | // @codeCoverageIgnoreStart |
253 | 253 | throw new LogicException( |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | * @param string|null $role one of the Role::* constants |
263 | 263 | * @return array[] list of parameters as accepted by Message::params() |
264 | 264 | */ |
265 | - private function renderItemIdSnakValueList( array $valueList, $role ) { |
|
266 | - return $this->renderList( $valueList, $role, [ $this, 'renderItemIdSnakValue' ] ); |
|
265 | + private function renderItemIdSnakValueList(array $valueList, $role) { |
|
266 | + return $this->renderList($valueList, $role, [$this, 'renderItemIdSnakValue']); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | * @param string|null $role one of the Role::* constants |
272 | 272 | * @return array[] list of parameters as accepted by Message::params() |
273 | 273 | */ |
274 | - private function renderDataValue( DataValue $dataValue, $role ) { |
|
275 | - return [ Message::rawParam( $this->addRole( |
|
276 | - $this->dataValueFormatter->format( $dataValue ), |
|
274 | + private function renderDataValue(DataValue $dataValue, $role) { |
|
275 | + return [Message::rawParam($this->addRole( |
|
276 | + $this->dataValueFormatter->format($dataValue), |
|
277 | 277 | $role |
278 | - ) ) ]; |
|
278 | + ))]; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @param string|null $role one of the Role::* constants |
284 | 284 | * @return array[] list of parameters as accepted by Message::params() |
285 | 285 | */ |
286 | - private function renderDataValueType( $dataValueType, $role ) { |
|
286 | + private function renderDataValueType($dataValueType, $role) { |
|
287 | 287 | $messageKeys = [ |
288 | 288 | 'string' => 'datatypes-type-string', |
289 | 289 | 'monolingualtext' => 'datatypes-type-monolingualtext', |
@@ -292,15 +292,15 @@ discard block |
||
292 | 292 | 'wikibase-entityid' => 'wbqc-dataValueType-wikibase-entityid', |
293 | 293 | ]; |
294 | 294 | |
295 | - if ( array_key_exists( $dataValueType, $messageKeys ) ) { |
|
296 | - return [ Message::rawParam( $this->addRole( |
|
297 | - $this->msgEscaped( $messageKeys[$dataValueType] ), |
|
295 | + if (array_key_exists($dataValueType, $messageKeys)) { |
|
296 | + return [Message::rawParam($this->addRole( |
|
297 | + $this->msgEscaped($messageKeys[$dataValueType]), |
|
298 | 298 | $role |
299 | - ) ) ]; |
|
299 | + ))]; |
|
300 | 300 | } else { |
301 | 301 | // @codeCoverageIgnoreStart |
302 | 302 | throw new LogicException( |
303 | - 'Unknown data value type ' . $dataValueType |
|
303 | + 'Unknown data value type '.$dataValueType |
|
304 | 304 | ); |
305 | 305 | // @codeCoverageIgnoreEnd |
306 | 306 | } |
@@ -311,11 +311,11 @@ discard block |
||
311 | 311 | * @param string|null $role one of the Role::* constants |
312 | 312 | * @return array[] list of parameters as accepted by Message::params() |
313 | 313 | */ |
314 | - private function renderInlineCode( $code, $role ) { |
|
315 | - return [ Message::rawParam( $this->addRole( |
|
316 | - '<code>' . htmlspecialchars( $code ) . '</code>', |
|
314 | + private function renderInlineCode($code, $role) { |
|
315 | + return [Message::rawParam($this->addRole( |
|
316 | + '<code>'.htmlspecialchars($code).'</code>', |
|
317 | 317 | $role |
318 | - ) ) ]; |
|
318 | + ))]; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param string|null $role one of the Role::* constants |
324 | 324 | * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
325 | 325 | */ |
326 | - private function renderConstraintScope( $scope, $role ) { |
|
327 | - switch ( $scope ) { |
|
326 | + private function renderConstraintScope($scope, $role) { |
|
327 | + switch ($scope) { |
|
328 | 328 | case Context::TYPE_STATEMENT: |
329 | 329 | $itemId = $this->config->get( |
330 | 330 | 'WBQualityConstraintsConstraintCheckedOnMainValueId' |
@@ -344,10 +344,10 @@ discard block |
||
344 | 344 | // callers should never let this happen, but if it does happen, |
345 | 345 | // showing “unknown value” seems reasonable |
346 | 346 | // @codeCoverageIgnoreStart |
347 | - return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
347 | + return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
348 | 348 | // @codeCoverageIgnoreEnd |
349 | 349 | } |
350 | - return $this->renderEntityId( new ItemId( $itemId ), $role ); |
|
350 | + return $this->renderEntityId(new ItemId($itemId), $role); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -355,8 +355,8 @@ discard block |
||
355 | 355 | * @param string|null $role one of the Role::* constants |
356 | 356 | * @return array[] list of parameters as accepted by Message::params() |
357 | 357 | */ |
358 | - private function renderConstraintScopeList( array $scopeList, $role ) { |
|
359 | - return $this->renderList( $scopeList, $role, [ $this, 'renderConstraintScope' ] ); |
|
358 | + private function renderConstraintScopeList(array $scopeList, $role) { |
|
359 | + return $this->renderList($scopeList, $role, [$this, 'renderConstraintScope']); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | /** |
@@ -364,25 +364,25 @@ discard block |
||
364 | 364 | * @param string|null $role one of the Role::* constants |
365 | 365 | * @return array[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
366 | 366 | */ |
367 | - private function renderPropertyScope( $scope, $role ) { |
|
368 | - switch ( $scope ) { |
|
367 | + private function renderPropertyScope($scope, $role) { |
|
368 | + switch ($scope) { |
|
369 | 369 | case Context::TYPE_STATEMENT: |
370 | - $itemId = $this->config->get( 'WBQualityConstraintsAsMainValueId' ); |
|
370 | + $itemId = $this->config->get('WBQualityConstraintsAsMainValueId'); |
|
371 | 371 | break; |
372 | 372 | case Context::TYPE_QUALIFIER: |
373 | - $itemId = $this->config->get( 'WBQualityConstraintsAsQualifiersId' ); |
|
373 | + $itemId = $this->config->get('WBQualityConstraintsAsQualifiersId'); |
|
374 | 374 | break; |
375 | 375 | case Context::TYPE_REFERENCE: |
376 | - $itemId = $this->config->get( 'WBQualityConstraintsAsReferencesId' ); |
|
376 | + $itemId = $this->config->get('WBQualityConstraintsAsReferencesId'); |
|
377 | 377 | break; |
378 | 378 | default: |
379 | 379 | // callers should never let this happen, but if it does happen, |
380 | 380 | // showing “unknown value” seems reasonable |
381 | 381 | // @codeCoverageIgnoreStart |
382 | - return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
382 | + return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
383 | 383 | // @codeCoverageIgnoreEnd |
384 | 384 | } |
385 | - return $this->renderEntityId( new ItemId( $itemId ), $role ); |
|
385 | + return $this->renderEntityId(new ItemId($itemId), $role); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -390,8 +390,8 @@ discard block |
||
390 | 390 | * @param string|null $role one of the Role::* constants |
391 | 391 | * @return array[] list of parameters as accepted by Message::params() |
392 | 392 | */ |
393 | - private function renderPropertyScopeList( array $scopeList, $role ) { |
|
394 | - return $this->renderList( $scopeList, $role, [ $this, 'renderPropertyScope' ] ); |
|
393 | + private function renderPropertyScopeList(array $scopeList, $role) { |
|
394 | + return $this->renderList($scopeList, $role, [$this, 'renderPropertyScope']); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | /** |
@@ -399,10 +399,10 @@ discard block |
||
399 | 399 | * @param string|null $role one of the Role::* constants |
400 | 400 | * @return array[] list of parameters as accepted by Message::params() |
401 | 401 | */ |
402 | - private function renderLanguage( $languageCode, $role ) { |
|
402 | + private function renderLanguage($languageCode, $role) { |
|
403 | 403 | return [ |
404 | - Message::plaintextParam( Language::fetchLanguageName( $languageCode ) ), |
|
405 | - Message::plaintextParam( $languageCode ), |
|
404 | + Message::plaintextParam(Language::fetchLanguageName($languageCode)), |
|
405 | + Message::plaintextParam($languageCode), |
|
406 | 406 | ]; |
407 | 407 | } |
408 | 408 |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | * @param ViolationMessage $violationMessage |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - public function render( ViolationMessage $violationMessage ) { |
|
58 | - if ( !array_key_exists( $violationMessage->getMessageKey(), $this->alternativeMessageKeys ) ) { |
|
59 | - return parent::render( $violationMessage ); |
|
57 | + public function render(ViolationMessage $violationMessage) { |
|
58 | + if (!array_key_exists($violationMessage->getMessageKey(), $this->alternativeMessageKeys)) { |
|
59 | + return parent::render($violationMessage); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $arguments = $violationMessage->getArguments(); |
63 | - $multilingualTextArgument = array_pop( $arguments ); |
|
63 | + $multilingualTextArgument = array_pop($arguments); |
|
64 | 64 | $multilingualTextParams = $this->renderMultilingualText( |
65 | 65 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable TODO Ensure this is not an actual issue |
66 | 66 | $multilingualTextArgument['value'], |
@@ -68,22 +68,22 @@ discard block |
||
68 | 68 | $multilingualTextArgument['role'] |
69 | 69 | ); |
70 | 70 | |
71 | - $paramsLists = [ [] ]; |
|
72 | - foreach ( $arguments as $argument ) { |
|
73 | - $paramsLists[] = $this->renderArgument( $argument ); |
|
71 | + $paramsLists = [[]]; |
|
72 | + foreach ($arguments as $argument) { |
|
73 | + $paramsLists[] = $this->renderArgument($argument); |
|
74 | 74 | } |
75 | - $regularParams = call_user_func_array( 'array_merge', $paramsLists ); |
|
75 | + $regularParams = call_user_func_array('array_merge', $paramsLists); |
|
76 | 76 | |
77 | - if ( $multilingualTextParams === null ) { |
|
77 | + if ($multilingualTextParams === null) { |
|
78 | 78 | return $this->messageLocalizer |
79 | - ->msg( $this->alternativeMessageKeys[$violationMessage->getMessageKey()] ) |
|
80 | - ->params( $regularParams ) |
|
79 | + ->msg($this->alternativeMessageKeys[$violationMessage->getMessageKey()]) |
|
80 | + ->params($regularParams) |
|
81 | 81 | ->escaped(); |
82 | 82 | } else { |
83 | 83 | return $this->messageLocalizer |
84 | - ->msg( $violationMessage->getMessageKey() ) |
|
85 | - ->params( $regularParams ) |
|
86 | - ->params( $multilingualTextParams ) |
|
84 | + ->msg($violationMessage->getMessageKey()) |
|
85 | + ->params($regularParams) |
|
86 | + ->params($multilingualTextParams) |
|
87 | 87 | ->escaped(); |
88 | 88 | } |
89 | 89 | } |
@@ -94,18 +94,18 @@ discard block |
||
94 | 94 | * @return array[]|null list of parameters as accepted by Message::params(), |
95 | 95 | * or null if the text is not available in the user’s language |
96 | 96 | */ |
97 | - protected function renderMultilingualText( MultilingualTextValue $text, $role ) { |
|
97 | + protected function renderMultilingualText(MultilingualTextValue $text, $role) { |
|
98 | 98 | global $wgLang; |
99 | 99 | $languageCodes = $wgLang->getFallbackLanguages(); |
100 | - array_unshift( $languageCodes, $wgLang->getCode() ); |
|
100 | + array_unshift($languageCodes, $wgLang->getCode()); |
|
101 | 101 | |
102 | 102 | $texts = $text->getTexts(); |
103 | - foreach ( $languageCodes as $languageCode ) { |
|
104 | - if ( array_key_exists( $languageCode, $texts ) ) { |
|
105 | - return [ Message::rawParam( $this->addRole( |
|
106 | - htmlspecialchars( $texts[$languageCode]->getText() ), |
|
103 | + foreach ($languageCodes as $languageCode) { |
|
104 | + if (array_key_exists($languageCode, $texts)) { |
|
105 | + return [Message::rawParam($this->addRole( |
|
106 | + htmlspecialchars($texts[$languageCode]->getText()), |
|
107 | 107 | $role |
108 | - ) ) ]; |
|
108 | + ))]; |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param WANObjectCache $cache |
37 | 37 | * @param string $formatVersion The version of the API response format. |
38 | 38 | */ |
39 | - public function __construct( WANObjectCache $cache, $formatVersion ) { |
|
39 | + public function __construct(WANObjectCache $cache, $formatVersion) { |
|
40 | 40 | $this->cache = $cache; |
41 | 41 | $this->formatVersion = $formatVersion; |
42 | 42 | } |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param EntityId $entityId |
46 | 46 | * @return string cache key |
47 | 47 | */ |
48 | - public function makeKey( EntityId $entityId ) { |
|
48 | + public function makeKey(EntityId $entityId) { |
|
49 | 49 | return $this->cache->makeKey( |
50 | 50 | 'WikibaseQualityConstraints', // extension |
51 | 51 | 'checkConstraints', // action |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param mixed|null &$info |
62 | 62 | * @return mixed |
63 | 63 | */ |
64 | - public function get( EntityId $key, &$curTTL = null, array $checkKeys = [], &$info = null ) { |
|
65 | - return $this->cache->get( $this->makeKey( $key ), $curTTL, $checkKeys, $info ); |
|
64 | + public function get(EntityId $key, &$curTTL = null, array $checkKeys = [], &$info = null) { |
|
65 | + return $this->cache->get($this->makeKey($key), $curTTL, $checkKeys, $info); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | * @param array $opts |
73 | 73 | * @return bool |
74 | 74 | */ |
75 | - public function set( EntityId $key, $value, $ttl = 0, array $opts = [] ) { |
|
76 | - return $this->cache->set( $this->makeKey( $key ), $value, $ttl, $opts ); |
|
75 | + public function set(EntityId $key, $value, $ttl = 0, array $opts = []) { |
|
76 | + return $this->cache->set($this->makeKey($key), $value, $ttl, $opts); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @param EntityId $key |
81 | 81 | * @return bool |
82 | 82 | */ |
83 | - public function delete( EntityId $key ) { |
|
84 | - return $this->cache->delete( $this->makeKey( $key ) ); |
|
83 | + public function delete(EntityId $key) { |
|
84 | + return $this->cache->delete($this->makeKey($key)); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | } |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | DelegatingConstraintChecker $delegatingConstraintChecker |
79 | 79 | ): self { |
80 | 80 | $repo = WikibaseRepo::getDefaultInstance(); |
81 | - $helperFactory = $repo->getApiHelperFactory( RequestContext::getMain() ); |
|
81 | + $helperFactory = $repo->getApiHelperFactory(RequestContext::getMain()); |
|
82 | 82 | $language = $repo->getUserLanguage(); |
83 | 83 | |
84 | 84 | $entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory(); |
85 | 85 | $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory |
86 | - ->getEntityIdFormatter( $language ); |
|
86 | + ->getEntityIdFormatter($language); |
|
87 | 87 | $formatterOptions = new FormatterOptions(); |
88 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
88 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
89 | 89 | $dataValueFormatter = $valueFormatterFactory |
90 | - ->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
90 | + ->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
91 | 91 | $violationMessageRenderer = new MultilingualTextViolationMessageRenderer( |
92 | 92 | $entityIdHtmlLinkFormatter, |
93 | 93 | $dataValueFormatter, |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | StatementGuidParser $statementGuidParser, |
124 | 124 | IBufferingStatsdDataFactory $dataFactory |
125 | 125 | ) { |
126 | - parent::__construct( $main, $name ); |
|
126 | + parent::__construct($main, $name); |
|
127 | 127 | |
128 | - $this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
128 | + $this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this); |
|
129 | 129 | $this->delegatingConstraintChecker = $delegatingConstraintChecker; |
130 | 130 | $this->violationMessageRenderer = $violationMessageRenderer; |
131 | 131 | $this->statementGuidParser = $statementGuidParser; |
@@ -140,39 +140,39 @@ discard block |
||
140 | 140 | $params = $this->extractRequestParams(); |
141 | 141 | $result = $this->getResult(); |
142 | 142 | |
143 | - $propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] ); |
|
144 | - $constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] ); |
|
143 | + $propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]); |
|
144 | + $constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]); |
|
145 | 145 | |
146 | - $this->checkPropertyIds( $propertyIds, $result ); |
|
147 | - $this->checkConstraintIds( $constraintIds, $result ); |
|
146 | + $this->checkPropertyIds($propertyIds, $result); |
|
147 | + $this->checkConstraintIds($constraintIds, $result); |
|
148 | 148 | |
149 | - $result->addValue( null, 'success', 1 ); |
|
149 | + $result->addValue(null, 'success', 1); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
153 | 153 | * @param array|null $propertyIdSerializations |
154 | 154 | * @return PropertyId[] |
155 | 155 | */ |
156 | - private function parsePropertyIds( $propertyIdSerializations ) { |
|
157 | - if ( $propertyIdSerializations === null ) { |
|
156 | + private function parsePropertyIds($propertyIdSerializations) { |
|
157 | + if ($propertyIdSerializations === null) { |
|
158 | 158 | return []; |
159 | - } elseif ( empty( $propertyIdSerializations ) ) { |
|
159 | + } elseif (empty($propertyIdSerializations)) { |
|
160 | 160 | $this->apiErrorReporter->dieError( |
161 | - 'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.', |
|
161 | + 'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.', |
|
162 | 162 | 'no-data' |
163 | 163 | ); |
164 | 164 | } |
165 | 165 | |
166 | 166 | return array_map( |
167 | - function ( $propertyIdSerialization ) { |
|
167 | + function($propertyIdSerialization) { |
|
168 | 168 | try { |
169 | - return new PropertyId( $propertyIdSerialization ); |
|
170 | - } catch ( InvalidArgumentException $e ) { |
|
169 | + return new PropertyId($propertyIdSerialization); |
|
170 | + } catch (InvalidArgumentException $e) { |
|
171 | 171 | $this->apiErrorReporter->dieError( |
172 | 172 | "Invalid id: $propertyIdSerialization", |
173 | 173 | 'invalid-property-id', |
174 | 174 | 0, // default argument |
175 | - [ self::PARAM_PROPERTY_ID => $propertyIdSerialization ] |
|
175 | + [self::PARAM_PROPERTY_ID => $propertyIdSerialization] |
|
176 | 176 | ); |
177 | 177 | } |
178 | 178 | }, |
@@ -184,35 +184,35 @@ discard block |
||
184 | 184 | * @param array|null $constraintIds |
185 | 185 | * @return string[] |
186 | 186 | */ |
187 | - private function parseConstraintIds( $constraintIds ) { |
|
188 | - if ( $constraintIds === null ) { |
|
187 | + private function parseConstraintIds($constraintIds) { |
|
188 | + if ($constraintIds === null) { |
|
189 | 189 | return []; |
190 | - } elseif ( empty( $constraintIds ) ) { |
|
190 | + } elseif (empty($constraintIds)) { |
|
191 | 191 | $this->apiErrorReporter->dieError( |
192 | - 'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.', |
|
192 | + 'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.', |
|
193 | 193 | 'no-data' |
194 | 194 | ); |
195 | 195 | } |
196 | 196 | |
197 | 197 | return array_map( |
198 | - function ( $constraintId ) { |
|
198 | + function($constraintId) { |
|
199 | 199 | try { |
200 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
201 | - if ( !$propertyId instanceof PropertyId ) { |
|
200 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
201 | + if (!$propertyId instanceof PropertyId) { |
|
202 | 202 | $this->apiErrorReporter->dieError( |
203 | 203 | "Invalid property ID: {$propertyId->getSerialization()}", |
204 | 204 | 'invalid-property-id', |
205 | 205 | 0, // default argument |
206 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
206 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
207 | 207 | ); |
208 | 208 | } |
209 | 209 | return $constraintId; |
210 | - } catch ( StatementGuidParsingException $e ) { |
|
210 | + } catch (StatementGuidParsingException $e) { |
|
211 | 211 | $this->apiErrorReporter->dieError( |
212 | 212 | "Invalid statement GUID: $constraintId", |
213 | 213 | 'invalid-guid', |
214 | 214 | 0, // default argument |
215 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
215 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
216 | 216 | ); |
217 | 217 | } |
218 | 218 | }, |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | * @param PropertyId[] $propertyIds |
225 | 225 | * @param ApiResult $result |
226 | 226 | */ |
227 | - private function checkPropertyIds( array $propertyIds, ApiResult $result ) { |
|
228 | - foreach ( $propertyIds as $propertyId ) { |
|
229 | - $result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' ); |
|
227 | + private function checkPropertyIds(array $propertyIds, ApiResult $result) { |
|
228 | + foreach ($propertyIds as $propertyId) { |
|
229 | + $result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc'); |
|
230 | 230 | $allConstraintExceptions = $this->delegatingConstraintChecker |
231 | - ->checkConstraintParametersOnPropertyId( $propertyId ); |
|
232 | - foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) { |
|
231 | + ->checkConstraintParametersOnPropertyId($propertyId); |
|
232 | + foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) { |
|
233 | 233 | $this->addConstraintParameterExceptionsToResult( |
234 | 234 | $constraintId, |
235 | 235 | $constraintParameterExceptions, |
@@ -243,15 +243,15 @@ discard block |
||
243 | 243 | * @param string[] $constraintIds |
244 | 244 | * @param ApiResult $result |
245 | 245 | */ |
246 | - private function checkConstraintIds( array $constraintIds, ApiResult $result ) { |
|
247 | - foreach ( $constraintIds as $constraintId ) { |
|
248 | - if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) { |
|
246 | + private function checkConstraintIds(array $constraintIds, ApiResult $result) { |
|
247 | + foreach ($constraintIds as $constraintId) { |
|
248 | + if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) { |
|
249 | 249 | // already checked as part of checkPropertyIds() |
250 | 250 | continue; |
251 | 251 | } |
252 | 252 | $constraintParameterExceptions = $this->delegatingConstraintChecker |
253 | - ->checkConstraintParametersOnConstraintId( $constraintId ); |
|
254 | - $this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result ); |
|
253 | + ->checkConstraintParametersOnConstraintId($constraintId); |
|
254 | + $this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
@@ -259,18 +259,18 @@ discard block |
||
259 | 259 | * @param PropertyId $propertyId |
260 | 260 | * @return string[] |
261 | 261 | */ |
262 | - private function getResultPathForPropertyId( PropertyId $propertyId ) { |
|
263 | - return [ $this->getModuleName(), $propertyId->getSerialization() ]; |
|
262 | + private function getResultPathForPropertyId(PropertyId $propertyId) { |
|
263 | + return [$this->getModuleName(), $propertyId->getSerialization()]; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
267 | 267 | * @param string $constraintId |
268 | 268 | * @return string[] |
269 | 269 | */ |
270 | - private function getResultPathForConstraintId( $constraintId ) { |
|
271 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
270 | + private function getResultPathForConstraintId($constraintId) { |
|
271 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
272 | 272 | '@phan-var PropertyId $propertyId'; |
273 | - return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] ); |
|
273 | + return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | $constraintParameterExceptions, |
286 | 286 | ApiResult $result |
287 | 287 | ) { |
288 | - $path = $this->getResultPathForConstraintId( $constraintId ); |
|
289 | - if ( $constraintParameterExceptions === null ) { |
|
288 | + $path = $this->getResultPathForConstraintId($constraintId); |
|
289 | + if ($constraintParameterExceptions === null) { |
|
290 | 290 | $result->addValue( |
291 | 291 | $path, |
292 | 292 | self::KEY_STATUS, |
@@ -296,12 +296,12 @@ discard block |
||
296 | 296 | $result->addValue( |
297 | 297 | $path, |
298 | 298 | self::KEY_STATUS, |
299 | - empty( $constraintParameterExceptions ) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY |
|
299 | + empty($constraintParameterExceptions) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY |
|
300 | 300 | ); |
301 | 301 | $result->addValue( |
302 | 302 | $path, |
303 | 303 | self::KEY_PROBLEMS, |
304 | - array_map( [ $this, 'formatConstraintParameterException' ], $constraintParameterExceptions ) |
|
304 | + array_map([$this, 'formatConstraintParameterException'], $constraintParameterExceptions) |
|
305 | 305 | ); |
306 | 306 | } |
307 | 307 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @param ConstraintParameterException $e |
313 | 313 | * @return string[] |
314 | 314 | */ |
315 | - private function formatConstraintParameterException( ConstraintParameterException $e ) { |
|
315 | + private function formatConstraintParameterException(ConstraintParameterException $e) { |
|
316 | 316 | return [ |
317 | 317 | self::KEY_MESSAGE_HTML => $this->violationMessageRenderer->render( |
318 | 318 | $e->getViolationMessage() |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | return [ |
346 | 346 | 'action=wbcheckconstraintparameters&propertyid=P247' |
347 | 347 | => 'apihelp-wbcheckconstraintparameters-example-propertyid-1', |
348 | - 'action=wbcheckconstraintparameters&' . |
|
349 | - 'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|' . |
|
348 | + 'action=wbcheckconstraintparameters&'. |
|
349 | + 'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|'. |
|
350 | 350 | 'P225$cdc71e4a-47a0-12c5-dfb3-3f6fc0b6613f' |
351 | 351 | => 'apihelp-wbcheckconstraintparameters-example-constraintid-2', |
352 | 352 | ]; |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | |
87 | 87 | $language = $repo->getUserLanguage(); |
88 | 88 | $formatterOptions = new FormatterOptions(); |
89 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
90 | - $valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
89 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
90 | + $valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
91 | 91 | |
92 | 92 | $entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory(); |
93 | - $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language ); |
|
93 | + $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language); |
|
94 | 94 | $entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory(); |
95 | - $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language ); |
|
95 | + $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language); |
|
96 | 96 | |
97 | 97 | $checkResultsRenderer = new CheckResultsRenderer( |
98 | 98 | $entityTitleLookup, |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $name, |
111 | 111 | $entityIdParser, |
112 | 112 | $statementGuidValidator, |
113 | - $repo->getApiHelperFactory( RequestContext::getMain() ), |
|
113 | + $repo->getApiHelperFactory(RequestContext::getMain()), |
|
114 | 114 | $resultsSource, |
115 | 115 | $checkResultsRenderer, |
116 | 116 | $dataFactory |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | CheckResultsRenderer $checkResultsRenderer, |
138 | 138 | IBufferingStatsdDataFactory $dataFactory |
139 | 139 | ) { |
140 | - parent::__construct( $main, $name ); |
|
140 | + parent::__construct($main, $name); |
|
141 | 141 | $this->entityIdParser = $entityIdParser; |
142 | 142 | $this->statementGuidValidator = $statementGuidValidator; |
143 | - $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); |
|
144 | - $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
143 | + $this->resultBuilder = $apiHelperFactory->getResultBuilder($this); |
|
144 | + $this->errorReporter = $apiHelperFactory->getErrorReporter($this); |
|
145 | 145 | $this->resultsSource = $resultsSource; |
146 | 146 | $this->checkResultsRenderer = $checkResultsRenderer; |
147 | 147 | $this->dataFactory = $dataFactory; |
@@ -157,9 +157,9 @@ discard block |
||
157 | 157 | |
158 | 158 | $params = $this->extractRequestParams(); |
159 | 159 | |
160 | - $this->validateParameters( $params ); |
|
161 | - $entityIds = $this->parseEntityIds( $params ); |
|
162 | - $claimIds = $this->parseClaimIds( $params ); |
|
160 | + $this->validateParameters($params); |
|
161 | + $entityIds = $this->parseEntityIds($params); |
|
162 | + $claimIds = $this->parseClaimIds($params); |
|
163 | 163 | $constraintIDs = $params[self::PARAM_CONSTRAINT_ID]; |
164 | 164 | $statuses = $params[self::PARAM_STATUS]; |
165 | 165 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | ) |
176 | 176 | )->getArray() |
177 | 177 | ); |
178 | - $this->resultBuilder->markSuccess( 1 ); |
|
178 | + $this->resultBuilder->markSuccess(1); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -183,24 +183,24 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return EntityId[] |
185 | 185 | */ |
186 | - private function parseEntityIds( array $params ) { |
|
186 | + private function parseEntityIds(array $params) { |
|
187 | 187 | $ids = $params[self::PARAM_ID]; |
188 | 188 | |
189 | - if ( $ids === null ) { |
|
189 | + if ($ids === null) { |
|
190 | 190 | return []; |
191 | - } elseif ( $ids === [] ) { |
|
191 | + } elseif ($ids === []) { |
|
192 | 192 | $this->errorReporter->dieError( |
193 | - 'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
193 | + 'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
194 | 194 | } |
195 | 195 | |
196 | - return array_map( function ( $id ) { |
|
196 | + return array_map(function($id) { |
|
197 | 197 | try { |
198 | - return $this->entityIdParser->parse( $id ); |
|
199 | - } catch ( EntityIdParsingException $e ) { |
|
198 | + return $this->entityIdParser->parse($id); |
|
199 | + } catch (EntityIdParsingException $e) { |
|
200 | 200 | $this->errorReporter->dieError( |
201 | - "Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] ); |
|
201 | + "Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] ); |
|
202 | 202 | } |
203 | - }, $ids ); |
|
203 | + }, $ids); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -208,35 +208,35 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @return string[] |
210 | 210 | */ |
211 | - private function parseClaimIds( array $params ) { |
|
211 | + private function parseClaimIds(array $params) { |
|
212 | 212 | $ids = $params[self::PARAM_CLAIM_ID]; |
213 | 213 | |
214 | - if ( $ids === null ) { |
|
214 | + if ($ids === null) { |
|
215 | 215 | return []; |
216 | - } elseif ( $ids === [] ) { |
|
216 | + } elseif ($ids === []) { |
|
217 | 217 | $this->errorReporter->dieError( |
218 | - 'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
218 | + 'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
219 | 219 | } |
220 | 220 | |
221 | - foreach ( $ids as $id ) { |
|
222 | - if ( !$this->statementGuidValidator->validate( $id ) ) { |
|
221 | + foreach ($ids as $id) { |
|
222 | + if (!$this->statementGuidValidator->validate($id)) { |
|
223 | 223 | $this->errorReporter->dieError( |
224 | - "Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] ); |
|
224 | + "Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] ); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | 228 | return $ids; |
229 | 229 | } |
230 | 230 | |
231 | - private function validateParameters( array $params ) { |
|
232 | - if ( $params[self::PARAM_CONSTRAINT_ID] !== null |
|
233 | - && empty( $params[self::PARAM_CONSTRAINT_ID] ) |
|
231 | + private function validateParameters(array $params) { |
|
232 | + if ($params[self::PARAM_CONSTRAINT_ID] !== null |
|
233 | + && empty($params[self::PARAM_CONSTRAINT_ID]) |
|
234 | 234 | ) { |
235 | 235 | $paramConstraintId = self::PARAM_CONSTRAINT_ID; |
236 | 236 | $this->errorReporter->dieError( |
237 | 237 | "If $paramConstraintId is specified, it must be nonempty.", 'no-data' ); |
238 | 238 | } |
239 | - if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) { |
|
239 | + if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) { |
|
240 | 240 | $paramId = self::PARAM_ID; |
241 | 241 | $paramClaimId = self::PARAM_CLAIM_ID; |
242 | 242 | $this->errorReporter->dieError( |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | ], |
278 | 278 | ApiBase::PARAM_ISMULTI => true, |
279 | 279 | ApiBase::PARAM_ALL => true, |
280 | - ApiBase::PARAM_DFLT => implode( '|', CachingResultsSource::CACHED_STATUSES ), |
|
280 | + ApiBase::PARAM_DFLT => implode('|', CachingResultsSource::CACHED_STATUSES), |
|
281 | 281 | ApiBase::PARAM_HELP_MSG_PER_VALUE => [], |
282 | 282 | ], |
283 | 283 | ]; |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | */ |
39 | 39 | private const BATCH_SIZE = 50; |
40 | 40 | |
41 | - public static function newFromGlobalState( Title $title, array $params ) { |
|
42 | - Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' ); |
|
41 | + public static function newFromGlobalState(Title $title, array $params) { |
|
42 | + Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]'); |
|
43 | 43 | $services = MediaWikiServices::getInstance(); |
44 | 44 | $repo = WikibaseRepo::getDefaultInstance(); |
45 | 45 | return new UpdateConstraintsTableJob( |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | $services->getMainConfig(), |
51 | 51 | ConstraintsServices::getConstraintStore(), |
52 | 52 | $services->getDBLoadBalancerFactory(), |
53 | - $repo->getEntityRevisionLookup( Store::LOOKUP_CACHING_DISABLED ), |
|
54 | - WikibaseRepo::getBaseDataModelSerializerFactory( $services ) |
|
53 | + $repo->getEntityRevisionLookup(Store::LOOKUP_CACHING_DISABLED), |
|
54 | + WikibaseRepo::getBaseDataModelSerializerFactory($services) |
|
55 | 55 | ->newSnakSerializer() |
56 | 56 | ); |
57 | 57 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | EntityRevisionLookup $entityRevisionLookup, |
112 | 112 | Serializer $snakSerializer |
113 | 113 | ) { |
114 | - parent::__construct( 'constraintsTableUpdate', $title, $params ); |
|
114 | + parent::__construct('constraintsTableUpdate', $title, $params); |
|
115 | 115 | |
116 | 116 | $this->propertyId = $propertyId; |
117 | 117 | $this->revisionId = $revisionId; |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | $this->snakSerializer = $snakSerializer; |
123 | 123 | } |
124 | 124 | |
125 | - public function extractParametersFromQualifiers( SnakList $qualifiers ) { |
|
125 | + public function extractParametersFromQualifiers(SnakList $qualifiers) { |
|
126 | 126 | $parameters = []; |
127 | - foreach ( $qualifiers as $qualifier ) { |
|
127 | + foreach ($qualifiers as $qualifier) { |
|
128 | 128 | $qualifierId = $qualifier->getPropertyId()->getSerialization(); |
129 | - $paramSerialization = $this->snakSerializer->serialize( $qualifier ); |
|
129 | + $paramSerialization = $this->snakSerializer->serialize($qualifier); |
|
130 | 130 | $parameters[$qualifierId][] = $paramSerialization; |
131 | 131 | } |
132 | 132 | return $parameters; |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | '@phan-var \Wikibase\DataModel\Entity\EntityIdValue $dataValue'; |
144 | 144 | $entityId = $dataValue->getEntityId(); |
145 | 145 | $constraintTypeQid = $entityId->getSerialization(); |
146 | - $parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() ); |
|
146 | + $parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers()); |
|
147 | 147 | return new Constraint( |
148 | 148 | $constraintId, |
149 | 149 | $propertyId, |
@@ -158,24 +158,24 @@ discard block |
||
158 | 158 | PropertyId $propertyConstraintPropertyId |
159 | 159 | ) { |
160 | 160 | $constraintsStatements = $property->getStatements() |
161 | - ->getByPropertyId( $propertyConstraintPropertyId ) |
|
162 | - ->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] ); |
|
161 | + ->getByPropertyId($propertyConstraintPropertyId) |
|
162 | + ->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]); |
|
163 | 163 | $constraints = []; |
164 | - foreach ( $constraintsStatements->getIterator() as $constraintStatement ) { |
|
165 | - $constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement ); |
|
166 | - if ( count( $constraints ) >= self::BATCH_SIZE ) { |
|
167 | - $constraintStore->insertBatch( $constraints ); |
|
164 | + foreach ($constraintsStatements->getIterator() as $constraintStatement) { |
|
165 | + $constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement); |
|
166 | + if (count($constraints) >= self::BATCH_SIZE) { |
|
167 | + $constraintStore->insertBatch($constraints); |
|
168 | 168 | // interrupt transaction and wait for replication |
169 | - $connection = $this->lbFactory->getMainLB()->getConnection( DB_MASTER ); |
|
170 | - $connection->endAtomic( __CLASS__ ); |
|
171 | - if ( !$connection->explicitTrxActive() ) { |
|
169 | + $connection = $this->lbFactory->getMainLB()->getConnection(DB_MASTER); |
|
170 | + $connection->endAtomic(__CLASS__); |
|
171 | + if (!$connection->explicitTrxActive()) { |
|
172 | 172 | $this->lbFactory->waitForReplication(); |
173 | 173 | } |
174 | - $connection->startAtomic( __CLASS__ ); |
|
174 | + $connection->startAtomic(__CLASS__); |
|
175 | 175 | $constraints = []; |
176 | 176 | } |
177 | 177 | } |
178 | - $constraintStore->insertBatch( $constraints ); |
|
178 | + $constraintStore->insertBatch($constraints); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -186,24 +186,24 @@ discard block |
||
186 | 186 | public function run() { |
187 | 187 | // TODO in the future: only touch constraints affected by the edit (requires T163465) |
188 | 188 | |
189 | - $propertyId = new PropertyId( $this->propertyId ); |
|
189 | + $propertyId = new PropertyId($this->propertyId); |
|
190 | 190 | $propertyRevision = $this->entityRevisionLookup->getEntityRevision( |
191 | 191 | $propertyId, |
192 | 192 | 0, // latest |
193 | 193 | LookupConstants::LATEST_FROM_REPLICA |
194 | 194 | ); |
195 | 195 | |
196 | - if ( $this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId ) { |
|
197 | - JobQueueGroup::singleton()->push( $this ); |
|
196 | + if ($this->revisionId !== null && $propertyRevision->getRevisionId() < $this->revisionId) { |
|
197 | + JobQueueGroup::singleton()->push($this); |
|
198 | 198 | return true; |
199 | 199 | } |
200 | 200 | |
201 | - $connection = $this->lbFactory->getMainLB()->getConnection( DB_MASTER ); |
|
201 | + $connection = $this->lbFactory->getMainLB()->getConnection(DB_MASTER); |
|
202 | 202 | // start transaction (if not started yet) – using __CLASS__, not __METHOD__, |
203 | 203 | // because importConstraintsForProperty() can interrupt the transaction |
204 | - $connection->startAtomic( __CLASS__ ); |
|
204 | + $connection->startAtomic(__CLASS__); |
|
205 | 205 | |
206 | - $this->constraintStore->deleteForProperty( $propertyId ); |
|
206 | + $this->constraintStore->deleteForProperty($propertyId); |
|
207 | 207 | |
208 | 208 | /** @var Property $property */ |
209 | 209 | $property = $propertyRevision->getEntity(); |
@@ -211,10 +211,10 @@ discard block |
||
211 | 211 | $this->importConstraintsForProperty( |
212 | 212 | $property, |
213 | 213 | $this->constraintStore, |
214 | - new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ) |
|
214 | + new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')) |
|
215 | 215 | ); |
216 | 216 | |
217 | - $connection->endAtomic( __CLASS__ ); |
|
217 | + $connection->endAtomic(__CLASS__); |
|
218 | 218 | |
219 | 219 | return true; |
220 | 220 | } |