@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string HTML |
66 | 66 | */ |
67 | - public function formatValue( $value ) { |
|
68 | - if ( is_string( $value ) ) { |
|
67 | + public function formatValue($value) { |
|
68 | + if (is_string($value)) { |
|
69 | 69 | // Cases like 'Format' 'pattern' or 'minimum'/'maximum' values, which we have stored as |
70 | 70 | // strings |
71 | - return htmlspecialchars( $value ); |
|
72 | - } elseif ( $value instanceof EntityId ) { |
|
71 | + return htmlspecialchars($value); |
|
72 | + } elseif ($value instanceof EntityId) { |
|
73 | 73 | // Cases like 'Conflicts with' 'property', to which we can link |
74 | - return $this->formatEntityId( $value ); |
|
75 | - } elseif ( $value instanceof ItemIdSnakValue ) { |
|
74 | + return $this->formatEntityId($value); |
|
75 | + } elseif ($value instanceof ItemIdSnakValue) { |
|
76 | 76 | // Cases like EntityId but can also be somevalue or novalue |
77 | - return $this->formatItemIdSnakValue( $value ); |
|
77 | + return $this->formatItemIdSnakValue($value); |
|
78 | 78 | } else { |
79 | 79 | // Cases where we format a DataValue |
80 | - return $this->formatDataValue( $value ); |
|
80 | + return $this->formatDataValue($value); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | |
@@ -88,23 +88,23 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string HTML |
90 | 90 | */ |
91 | - public function formatParameters( $parameters ) { |
|
92 | - if ( $parameters === null || count( $parameters ) == 0 ) { |
|
91 | + public function formatParameters($parameters) { |
|
92 | + if ($parameters === null || count($parameters) == 0) { |
|
93 | 93 | return null; |
94 | 94 | } |
95 | 95 | |
96 | - $valueFormatter = function ( $value ) { |
|
97 | - return $this->formatValue( $value ); |
|
96 | + $valueFormatter = function($value) { |
|
97 | + return $this->formatValue($value); |
|
98 | 98 | }; |
99 | 99 | |
100 | 100 | $formattedParameters = []; |
101 | - foreach ( $parameters as $parameterName => $parameterValue ) { |
|
102 | - $formattedParameterValues = implode( ', ', |
|
103 | - $this->limitArrayLength( array_map( $valueFormatter, $parameterValue ) ) ); |
|
104 | - $formattedParameters[] = sprintf( '%s: %s', $parameterName, $formattedParameterValues ); |
|
101 | + foreach ($parameters as $parameterName => $parameterValue) { |
|
102 | + $formattedParameterValues = implode(', ', |
|
103 | + $this->limitArrayLength(array_map($valueFormatter, $parameterValue))); |
|
104 | + $formattedParameters[] = sprintf('%s: %s', $parameterName, $formattedParameterValues); |
|
105 | 105 | } |
106 | 106 | |
107 | - return implode( '; ', $formattedParameters ); |
|
107 | + return implode('; ', $formattedParameters); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return array |
116 | 116 | */ |
117 | - private function limitArrayLength( array $array ) { |
|
118 | - if ( count( $array ) > self::MAX_PARAMETER_ARRAY_LENGTH ) { |
|
119 | - $array = array_slice( $array, 0, self::MAX_PARAMETER_ARRAY_LENGTH ); |
|
120 | - array_push( $array, '...' ); |
|
117 | + private function limitArrayLength(array $array) { |
|
118 | + if (count($array) > self::MAX_PARAMETER_ARRAY_LENGTH) { |
|
119 | + $array = array_slice($array, 0, self::MAX_PARAMETER_ARRAY_LENGTH); |
|
120 | + array_push($array, '...'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | return $array; |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | * @param string $value HTML |
131 | 131 | * @return string HTML |
132 | 132 | */ |
133 | - public static function formatByRole( $role, $value ) { |
|
134 | - if ( $role === null ) { |
|
133 | + public static function formatByRole($role, $value) { |
|
134 | + if ($role === null) { |
|
135 | 135 | return $value; |
136 | 136 | } |
137 | 137 | |
138 | - return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' |
|
138 | + return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">' |
|
139 | 139 | . $value |
140 | 140 | . '</span>'; |
141 | 141 | } |
@@ -145,9 +145,9 @@ discard block |
||
145 | 145 | * @param string|null $role one of the Role constants or null |
146 | 146 | * @return string HTML |
147 | 147 | */ |
148 | - public function formatDataValue( DataValue $value, $role = null ) { |
|
149 | - return self::formatByRole( $role, |
|
150 | - $this->dataValueFormatter->format( $value ) ); |
|
148 | + public function formatDataValue(DataValue $value, $role = null) { |
|
149 | + return self::formatByRole($role, |
|
150 | + $this->dataValueFormatter->format($value)); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | * @param string|null $role one of the Role constants or null |
156 | 156 | * @return string HTML |
157 | 157 | */ |
158 | - public function formatEntityId( EntityId $entityId, $role = null ) { |
|
159 | - return self::formatByRole( $role, |
|
160 | - $this->entityIdLabelFormatter->formatEntityId( $entityId ) ); |
|
158 | + public function formatEntityId(EntityId $entityId, $role = null) { |
|
159 | + return self::formatByRole($role, |
|
160 | + $this->entityIdLabelFormatter->formatEntityId($entityId)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -169,18 +169,18 @@ discard block |
||
169 | 169 | * @param string|null $role one of the Role constants or null |
170 | 170 | * @return string HTML |
171 | 171 | */ |
172 | - public function formatPropertyId( $propertyId, $role = null ) { |
|
173 | - if ( $propertyId instanceof PropertyId ) { |
|
174 | - return $this->formatEntityId( $propertyId, $role ); |
|
175 | - } elseif ( is_string( $propertyId ) ) { |
|
172 | + public function formatPropertyId($propertyId, $role = null) { |
|
173 | + if ($propertyId instanceof PropertyId) { |
|
174 | + return $this->formatEntityId($propertyId, $role); |
|
175 | + } elseif (is_string($propertyId)) { |
|
176 | 176 | try { |
177 | - return $this->formatEntityId( new PropertyId( $propertyId ), $role ); |
|
178 | - } catch ( InvalidArgumentException $e ) { |
|
179 | - return self::formatByRole( $role, |
|
180 | - htmlspecialchars( $propertyId ) ); |
|
177 | + return $this->formatEntityId(new PropertyId($propertyId), $role); |
|
178 | + } catch (InvalidArgumentException $e) { |
|
179 | + return self::formatByRole($role, |
|
180 | + htmlspecialchars($propertyId)); |
|
181 | 181 | } |
182 | 182 | } else { |
183 | - throw new InvalidArgumentException( '$propertyId must be either PropertyId or string' ); |
|
183 | + throw new InvalidArgumentException('$propertyId must be either PropertyId or string'); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -193,18 +193,18 @@ discard block |
||
193 | 193 | * @param string|null $role one of the Role constants or null |
194 | 194 | * @return string HTML |
195 | 195 | */ |
196 | - public function formatItemId( $itemId, $role = null ) { |
|
197 | - if ( $itemId instanceof ItemId ) { |
|
198 | - return $this->formatEntityId( $itemId, $role ); |
|
199 | - } elseif ( is_string( $itemId ) ) { |
|
196 | + public function formatItemId($itemId, $role = null) { |
|
197 | + if ($itemId instanceof ItemId) { |
|
198 | + return $this->formatEntityId($itemId, $role); |
|
199 | + } elseif (is_string($itemId)) { |
|
200 | 200 | try { |
201 | - return $this->formatEntityId( new ItemId( $itemId ), $role ); |
|
202 | - } catch ( InvalidArgumentException $e ) { |
|
203 | - return self::formatByRole( $role, |
|
204 | - htmlspecialchars( $itemId ) ); |
|
201 | + return $this->formatEntityId(new ItemId($itemId), $role); |
|
202 | + } catch (InvalidArgumentException $e) { |
|
203 | + return self::formatByRole($role, |
|
204 | + htmlspecialchars($itemId)); |
|
205 | 205 | } |
206 | 206 | } else { |
207 | - throw new InvalidArgumentException( '$itemId must be either ItemId or string' ); |
|
207 | + throw new InvalidArgumentException('$itemId must be either ItemId or string'); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
@@ -215,20 +215,20 @@ discard block |
||
215 | 215 | * @param string|null $role one of the Role constants or null |
216 | 216 | * @return string HTML |
217 | 217 | */ |
218 | - public function formatItemIdSnakValue( ItemIdSnakValue $value, $role = null ) { |
|
219 | - switch ( true ) { |
|
218 | + public function formatItemIdSnakValue(ItemIdSnakValue $value, $role = null) { |
|
219 | + switch (true) { |
|
220 | 220 | case $value->isValue(): |
221 | - return $this->formatEntityId( $value->getItemId(), $role ); |
|
221 | + return $this->formatEntityId($value->getItemId(), $role); |
|
222 | 222 | case $value->isSomeValue(): |
223 | - return self::formatByRole( $role, |
|
223 | + return self::formatByRole($role, |
|
224 | 224 | '<span class="wikibase-snakview-variation-somevaluesnak">' |
225 | - . wfMessage( 'wikibase-snakview-snaktypeselector-somevalue' )->escaped() |
|
226 | - . '</span>' ); |
|
225 | + . wfMessage('wikibase-snakview-snaktypeselector-somevalue')->escaped() |
|
226 | + . '</span>'); |
|
227 | 227 | case $value->isNoValue(): |
228 | - return self::formatByRole( $role, |
|
228 | + return self::formatByRole($role, |
|
229 | 229 | '<span class="wikibase-snakview-variation-novaluesnak">' |
230 | - . wfMessage( 'wikibase-snakview-snaktypeselector-novalue' )->escaped() |
|
231 | - . '</span>' ); |
|
230 | + . wfMessage('wikibase-snakview-snaktypeselector-novalue')->escaped() |
|
231 | + . '</span>'); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | * @param string|null $role one of the Role constants or null |
240 | 240 | * @return string HTML |
241 | 241 | */ |
242 | - public function formatConstraintScope( $scope, $role = null ) { |
|
243 | - switch ( $scope ) { |
|
242 | + public function formatConstraintScope($scope, $role = null) { |
|
243 | + switch ($scope) { |
|
244 | 244 | case Context::TYPE_STATEMENT: |
245 | 245 | $itemId = $this->config->get( |
246 | 246 | 'WBQualityConstraintsConstraintCheckedOnMainValueId' |
@@ -260,10 +260,10 @@ discard block |
||
260 | 260 | // callers should never let this happen, but if it does happen, |
261 | 261 | // showing “unknown value” seems reasonable |
262 | 262 | // @codeCoverageIgnoreStart |
263 | - return $this->formatItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
263 | + return $this->formatItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
264 | 264 | // @codeCoverageIgnoreEnd |
265 | 265 | } |
266 | - return $this->formatItemId( $itemId, $role ); |
|
266 | + return $this->formatItemId($itemId, $role); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
@@ -276,15 +276,15 @@ discard block |
||
276 | 276 | * @param string|null $role one of the Role constants or null |
277 | 277 | * @return string[] HTML |
278 | 278 | */ |
279 | - public function formatPropertyIdList( array $propertyIds, $role = null ) { |
|
280 | - if ( empty( $propertyIds ) ) { |
|
281 | - return [ '<ul></ul>' ]; |
|
279 | + public function formatPropertyIdList(array $propertyIds, $role = null) { |
|
280 | + if (empty($propertyIds)) { |
|
281 | + return ['<ul></ul>']; |
|
282 | 282 | } |
283 | - $propertyIds = $this->limitArrayLength( $propertyIds ); |
|
284 | - $formattedPropertyIds = array_map( [ $this, "formatPropertyId" ], $propertyIds, array_fill( 0, count( $propertyIds ), $role ) ); |
|
283 | + $propertyIds = $this->limitArrayLength($propertyIds); |
|
284 | + $formattedPropertyIds = array_map([$this, "formatPropertyId"], $propertyIds, array_fill(0, count($propertyIds), $role)); |
|
285 | 285 | array_unshift( |
286 | 286 | $formattedPropertyIds, |
287 | - '<ul><li>' . implode( '</li><li>', $formattedPropertyIds ) . '</li></ul>' |
|
287 | + '<ul><li>'.implode('</li><li>', $formattedPropertyIds).'</li></ul>' |
|
288 | 288 | ); |
289 | 289 | return $formattedPropertyIds; |
290 | 290 | } |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | * @param string|null $role one of the Role constants or null |
300 | 300 | * @return string[] HTML |
301 | 301 | */ |
302 | - public function formatItemIdList( array $itemIds, $role = null ) { |
|
303 | - if ( empty( $itemIds ) ) { |
|
304 | - return [ '<ul></ul>' ]; |
|
302 | + public function formatItemIdList(array $itemIds, $role = null) { |
|
303 | + if (empty($itemIds)) { |
|
304 | + return ['<ul></ul>']; |
|
305 | 305 | } |
306 | - $itemIds = $this->limitArrayLength( $itemIds ); |
|
307 | - $formattedItemIds = array_map( [ $this, "formatItemId" ], $itemIds, array_fill( 0, count( $itemIds ), $role ) ); |
|
306 | + $itemIds = $this->limitArrayLength($itemIds); |
|
307 | + $formattedItemIds = array_map([$this, "formatItemId"], $itemIds, array_fill(0, count($itemIds), $role)); |
|
308 | 308 | array_unshift( |
309 | 309 | $formattedItemIds, |
310 | - '<ul><li>' . implode( '</li><li>', $formattedItemIds ) . '</li></ul>' |
|
310 | + '<ul><li>'.implode('</li><li>', $formattedItemIds).'</li></ul>' |
|
311 | 311 | ); |
312 | 312 | return $formattedItemIds; |
313 | 313 | } |
@@ -322,23 +322,23 @@ discard block |
||
322 | 322 | * @param string|null $role one of the Role constants or null |
323 | 323 | * @return string[] HTML |
324 | 324 | */ |
325 | - public function formatEntityIdList( array $entityIds, $role = null ) { |
|
326 | - if ( empty( $entityIds ) ) { |
|
327 | - return [ '<ul></ul>' ]; |
|
325 | + public function formatEntityIdList(array $entityIds, $role = null) { |
|
326 | + if (empty($entityIds)) { |
|
327 | + return ['<ul></ul>']; |
|
328 | 328 | } |
329 | 329 | $formattedEntityIds = []; |
330 | - foreach ( $entityIds as $entityId ) { |
|
331 | - if ( count( $formattedEntityIds ) >= self::MAX_PARAMETER_ARRAY_LENGTH ) { |
|
330 | + foreach ($entityIds as $entityId) { |
|
331 | + if (count($formattedEntityIds) >= self::MAX_PARAMETER_ARRAY_LENGTH) { |
|
332 | 332 | $formattedEntityIds[] = '...'; |
333 | 333 | break; |
334 | 334 | } |
335 | - if ( $entityId !== null ) { |
|
336 | - $formattedEntityIds[] = $this->formatEntityId( $entityId, $role ); |
|
335 | + if ($entityId !== null) { |
|
336 | + $formattedEntityIds[] = $this->formatEntityId($entityId, $role); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | array_unshift( |
340 | 340 | $formattedEntityIds, |
341 | - '<ul><li>' . implode( '</li><li>', $formattedEntityIds ) . '</li></ul>' |
|
341 | + '<ul><li>'.implode('</li><li>', $formattedEntityIds).'</li></ul>' |
|
342 | 342 | ); |
343 | 343 | return $formattedEntityIds; |
344 | 344 | } |
@@ -353,24 +353,24 @@ discard block |
||
353 | 353 | * @param string|null $role one of the Role constants or null |
354 | 354 | * @return string[] HTML |
355 | 355 | */ |
356 | - public function formatItemIdSnakValueList( array $values, $role = null ) { |
|
357 | - if ( empty( $values ) ) { |
|
358 | - return [ '<ul></ul>' ]; |
|
356 | + public function formatItemIdSnakValueList(array $values, $role = null) { |
|
357 | + if (empty($values)) { |
|
358 | + return ['<ul></ul>']; |
|
359 | 359 | } |
360 | - $values = $this->limitArrayLength( $values ); |
|
360 | + $values = $this->limitArrayLength($values); |
|
361 | 361 | $formattedValues = array_map( |
362 | - function( $value ) use ( $role ) { |
|
363 | - if ( $value === '...' ) { |
|
362 | + function($value) use ($role) { |
|
363 | + if ($value === '...') { |
|
364 | 364 | return '...'; |
365 | 365 | } else { |
366 | - return $this->formatItemIdSnakValue( $value, $role ); |
|
366 | + return $this->formatItemIdSnakValue($value, $role); |
|
367 | 367 | } |
368 | 368 | }, |
369 | 369 | $values |
370 | 370 | ); |
371 | 371 | array_unshift( |
372 | 372 | $formattedValues, |
373 | - '<ul><li>' . implode( '</li><li>', $formattedValues ) . '</li></ul>' |
|
373 | + '<ul><li>'.implode('</li><li>', $formattedValues).'</li></ul>' |
|
374 | 374 | ); |
375 | 375 | return $formattedValues; |
376 | 376 | } |
@@ -385,24 +385,24 @@ discard block |
||
385 | 385 | * @param string|null $role one of the Role constants or null |
386 | 386 | * @return string[] HTML |
387 | 387 | */ |
388 | - public function formatConstraintScopeList( array $scopes, $role = null ) { |
|
389 | - if ( empty( $scopes ) ) { |
|
390 | - return [ '<ul></ul>' ]; |
|
388 | + public function formatConstraintScopeList(array $scopes, $role = null) { |
|
389 | + if (empty($scopes)) { |
|
390 | + return ['<ul></ul>']; |
|
391 | 391 | } |
392 | - $scopes = $this->limitArrayLength( $scopes ); |
|
392 | + $scopes = $this->limitArrayLength($scopes); |
|
393 | 393 | $formattedScopes = array_map( |
394 | - function( $scope ) use ( $role ) { |
|
395 | - if ( $scope === '...' ) { |
|
394 | + function($scope) use ($role) { |
|
395 | + if ($scope === '...') { |
|
396 | 396 | return '...'; |
397 | 397 | } else { |
398 | - return $this->formatConstraintScope( $scope, $role ); |
|
398 | + return $this->formatConstraintScope($scope, $role); |
|
399 | 399 | } |
400 | 400 | }, |
401 | 401 | $scopes |
402 | 402 | ); |
403 | 403 | array_unshift( |
404 | 404 | $formattedScopes, |
405 | - '<ul><li>' . implode( '</li><li>', $formattedScopes ) . '</li></ul>' |
|
405 | + '<ul><li>'.implode('</li><li>', $formattedScopes).'</li></ul>' |
|
406 | 406 | ); |
407 | 407 | return $formattedScopes; |
408 | 408 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param ItemId $itemId |
45 | 45 | * @return self |
46 | 46 | */ |
47 | - public static function fromItemId( ItemId $itemId ) { |
|
47 | + public static function fromItemId(ItemId $itemId) { |
|
48 | 48 | $ret = new self; |
49 | 49 | $ret->itemId = $itemId; |
50 | 50 | return $ret; |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | * @throws InvalidArgumentException |
81 | 81 | * @return self |
82 | 82 | */ |
83 | - public static function fromSnak( Snak $snak ) { |
|
84 | - switch ( true ) { |
|
83 | + public static function fromSnak(Snak $snak) { |
|
84 | + switch (true) { |
|
85 | 85 | case $snak instanceof PropertyValueSnak: |
86 | 86 | $dataValue = $snak->getDataValue(); |
87 | - if ( $dataValue instanceof EntityIdValue |
|
87 | + if ($dataValue instanceof EntityIdValue |
|
88 | 88 | && $dataValue->getEntityId() instanceof ItemId |
89 | 89 | ) { |
90 | - return self::fromItemId( $dataValue->getEntityId() ); |
|
90 | + return self::fromItemId($dataValue->getEntityId()); |
|
91 | 91 | } |
92 | 92 | break; |
93 | 93 | case $snak instanceof PropertySomeValueSnak: |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | return self::noValue(); |
97 | 97 | } |
98 | 98 | |
99 | - throw new InvalidArgumentException( 'Snak must contain item ID value or be a somevalue / novalue snak' ); |
|
99 | + throw new InvalidArgumentException('Snak must contain item ID value or be a somevalue / novalue snak'); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @return ItemId |
134 | 134 | */ |
135 | 135 | public function getItemId() { |
136 | - if ( ! $this->isValue() ) { |
|
137 | - throw new DomainException( 'This value does not contain an item ID.' ); |
|
136 | + if (!$this->isValue()) { |
|
137 | + throw new DomainException('This value does not contain an item ID.'); |
|
138 | 138 | } |
139 | 139 | return $this->itemId; |
140 | 140 | } |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * @param Snak $snak |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | - public function matchesSnak( Snak $snak ) { |
|
150 | - switch ( true ) { |
|
149 | + public function matchesSnak(Snak $snak) { |
|
150 | + switch (true) { |
|
151 | 151 | case $snak instanceof PropertyValueSnak: |
152 | 152 | return $this->isValue() && |
153 | 153 | $snak->getDataValue() instanceof EntityIdValue && |
154 | 154 | $snak->getDataValue()->getEntityId() instanceof ItemId && |
155 | - $snak->getDataValue()->getEntityId()->equals( $this->getItemId() ); |
|
155 | + $snak->getDataValue()->getEntityId()->equals($this->getItemId()); |
|
156 | 156 | case $snak instanceof PropertySomeValueSnak: |
157 | 157 | return $this->isSomeValue(); |
158 | 158 | case $snak instanceof PropertyNoValueSnak: |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | StatementList $statementList, |
31 | 31 | PropertyId $propertyId |
32 | 32 | ) { |
33 | - $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); |
|
34 | - if ( $statementListByPropertyId->isEmpty() ) { |
|
33 | + $statementListByPropertyId = $statementList->getByPropertyId($propertyId); |
|
34 | + if ($statementListByPropertyId->isEmpty()) { |
|
35 | 35 | return null; |
36 | 36 | } else { |
37 | 37 | return $statementListByPropertyId->toArray()[0]; |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | PropertyId $propertyId, |
53 | 53 | EntityId $value |
54 | 54 | ) { |
55 | - $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); |
|
55 | + $statementListByPropertyId = $statementList->getByPropertyId($propertyId); |
|
56 | 56 | /** @var Statement $statement */ |
57 | - foreach ( $statementListByPropertyId as $statement ) { |
|
57 | + foreach ($statementListByPropertyId as $statement) { |
|
58 | 58 | $snak = $statement->getMainSnak(); |
59 | - if ( $snak instanceof PropertyValueSnak ) { |
|
59 | + if ($snak instanceof PropertyValueSnak) { |
|
60 | 60 | $dataValue = $snak->getDataValue(); |
61 | - if ( $dataValue instanceof EntityIdValue && |
|
62 | - $dataValue->getEntityId()->equals( $value ) |
|
61 | + if ($dataValue instanceof EntityIdValue && |
|
62 | + $dataValue->getEntityId()->equals($value) |
|
63 | 63 | ) { |
64 | 64 | return $statement; |
65 | 65 | } |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | PropertyId $propertyId, |
83 | 83 | array $values |
84 | 84 | ) { |
85 | - $statementListByPropertyId = $statementList->getByPropertyId( $propertyId ); |
|
85 | + $statementListByPropertyId = $statementList->getByPropertyId($propertyId); |
|
86 | 86 | /** @var Statement $statement */ |
87 | - foreach ( $statementListByPropertyId as $statement ) { |
|
87 | + foreach ($statementListByPropertyId as $statement) { |
|
88 | 88 | $snak = $statement->getMainSnak(); |
89 | - foreach ( $values as $value ) { |
|
90 | - if ( $value->matchesSnak( $snak ) ) { |
|
89 | + foreach ($values as $value) { |
|
90 | + if ($value->matchesSnak($snak)) { |
|
91 | 91 | return $statement; |
92 | 92 | } |
93 | 93 | } |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | const BATCH_SIZE = 10; |
28 | 28 | |
29 | - public static function newFromGlobalState( Title $title, array $params ) { |
|
30 | - Assert::parameterType( 'string', $params['propertyId'], '$params["propertyId"]' ); |
|
29 | + public static function newFromGlobalState(Title $title, array $params) { |
|
30 | + Assert::parameterType('string', $params['propertyId'], '$params["propertyId"]'); |
|
31 | 31 | $repo = WikibaseRepo::getDefaultInstance(); |
32 | 32 | return new UpdateConstraintsTableJob( |
33 | 33 | $title, |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | EntityLookup $entityLookup, |
84 | 84 | Serializer $snakSerializer |
85 | 85 | ) { |
86 | - parent::__construct( 'constraintsTableUpdate', $title, $params ); |
|
86 | + parent::__construct('constraintsTableUpdate', $title, $params); |
|
87 | 87 | |
88 | 88 | $this->propertyId = $propertyId; |
89 | 89 | $this->config = $config; |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | $this->snakSerializer = $snakSerializer; |
93 | 93 | } |
94 | 94 | |
95 | - public function extractParametersFromQualifiers( SnakList $qualifiers ) { |
|
95 | + public function extractParametersFromQualifiers(SnakList $qualifiers) { |
|
96 | 96 | $parameters = []; |
97 | - foreach ( $qualifiers as $qualifier ) { |
|
97 | + foreach ($qualifiers as $qualifier) { |
|
98 | 98 | $qualifierId = $qualifier->getPropertyId()->getSerialization(); |
99 | - $paramSerialization = $this->snakSerializer->serialize( $qualifier ); |
|
99 | + $paramSerialization = $this->snakSerializer->serialize($qualifier); |
|
100 | 100 | $parameters[$qualifierId][] = $paramSerialization; |
101 | 101 | } |
102 | 102 | return $parameters; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ) { |
109 | 109 | $constraintId = $constraintStatement->getGuid(); |
110 | 110 | $constraintTypeQid = $constraintStatement->getMainSnak()->getDataValue()->getEntityId()->getSerialization(); |
111 | - $parameters = $this->extractParametersFromQualifiers( $constraintStatement->getQualifiers() ); |
|
111 | + $parameters = $this->extractParametersFromQualifiers($constraintStatement->getQualifiers()); |
|
112 | 112 | return new Constraint( |
113 | 113 | $constraintId, |
114 | 114 | $propertyId, |
@@ -123,17 +123,17 @@ discard block |
||
123 | 123 | PropertyId $propertyConstraintPropertyId |
124 | 124 | ) { |
125 | 125 | $constraintsStatements = $property->getStatements() |
126 | - ->getByPropertyId( $propertyConstraintPropertyId ) |
|
127 | - ->getByRank( [ Statement::RANK_PREFERRED, Statement::RANK_NORMAL ] ); |
|
126 | + ->getByPropertyId($propertyConstraintPropertyId) |
|
127 | + ->getByRank([Statement::RANK_PREFERRED, Statement::RANK_NORMAL]); |
|
128 | 128 | $constraints = []; |
129 | - foreach ( $constraintsStatements->getIterator() as $constraintStatement ) { |
|
130 | - $constraints[] = $this->extractConstraintFromStatement( $property->getId(), $constraintStatement ); |
|
131 | - if ( count( $constraints ) >= self::BATCH_SIZE ) { |
|
132 | - $constraintRepo->insertBatch( $constraints ); |
|
129 | + foreach ($constraintsStatements->getIterator() as $constraintStatement) { |
|
130 | + $constraints[] = $this->extractConstraintFromStatement($property->getId(), $constraintStatement); |
|
131 | + if (count($constraints) >= self::BATCH_SIZE) { |
|
132 | + $constraintRepo->insertBatch($constraints); |
|
133 | 133 | $constraints = []; |
134 | 134 | } |
135 | 135 | } |
136 | - $constraintRepo->insertBatch( $constraints ); |
|
136 | + $constraintRepo->insertBatch($constraints); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | public function run() { |
145 | 145 | // TODO in the future: only touch constraints affected by the edit (requires T163465) |
146 | 146 | |
147 | - $propertyId = new PropertyId( $this->propertyId ); |
|
148 | - $this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId( $propertyId ); |
|
147 | + $propertyId = new PropertyId($this->propertyId); |
|
148 | + $this->constraintRepo->deleteForPropertyWhereConstraintIdIsStatementId($propertyId); |
|
149 | 149 | |
150 | 150 | /** @var Property $property */ |
151 | - $property = $this->entityLookup->getEntity( $propertyId ); |
|
151 | + $property = $this->entityLookup->getEntity($propertyId); |
|
152 | 152 | $this->importConstraintsForProperty( |
153 | 153 | $property, |
154 | 154 | $this->constraintRepo, |
155 | - new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ) |
|
155 | + new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')) |
|
156 | 156 | ); |
157 | 157 | |
158 | 158 | return true; |
@@ -134,11 +134,11 @@ discard block |
||
134 | 134 | ) { |
135 | 135 | $results = []; |
136 | 136 | $metadatas = []; |
137 | - if ( $this->canUseStoredResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) { |
|
137 | + if ($this->canUseStoredResults($entityIds, $claimIds, $constraintIds, $statuses)) { |
|
138 | 138 | $storedEntityIds = []; |
139 | - foreach ( $entityIds as $entityId ) { |
|
140 | - $storedResults = $this->getStoredResults( $entityId ); |
|
141 | - if ( $storedResults !== null ) { |
|
139 | + foreach ($entityIds as $entityId) { |
|
140 | + $storedResults = $this->getStoredResults($entityId); |
|
141 | + if ($storedResults !== null) { |
|
142 | 142 | $this->dataFactory->increment( |
143 | 143 | 'wikibase.quality.constraints.cache.entity.hit' |
144 | 144 | ); |
@@ -147,20 +147,20 @@ discard block |
||
147 | 147 | $storedEntityIds[] = $entityId; |
148 | 148 | } |
149 | 149 | } |
150 | - $entityIds = array_values( array_diff( $entityIds, $storedEntityIds ) ); |
|
150 | + $entityIds = array_values(array_diff($entityIds, $storedEntityIds)); |
|
151 | 151 | } |
152 | - if ( $entityIds !== [] || $claimIds !== [] ) { |
|
152 | + if ($entityIds !== [] || $claimIds !== []) { |
|
153 | 153 | $this->dataFactory->updateCount( |
154 | 154 | 'wikibase.quality.constraints.cache.entity.miss', |
155 | - count( $entityIds ) |
|
155 | + count($entityIds) |
|
156 | 156 | ); |
157 | - $response = $this->getAndStoreResults( $entityIds, $claimIds, $constraintIds, $statuses ); |
|
157 | + $response = $this->getAndStoreResults($entityIds, $claimIds, $constraintIds, $statuses); |
|
158 | 158 | $results += $response->getArray(); |
159 | 159 | $metadatas[] = $response->getMetadata(); |
160 | 160 | } |
161 | 161 | return new CachedCheckConstraintsResponse( |
162 | 162 | $results, |
163 | - Metadata::merge( $metadatas ) |
|
163 | + Metadata::merge($metadatas) |
|
164 | 164 | ); |
165 | 165 | } |
166 | 166 | |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | array $constraintIds = null, |
190 | 190 | array $statuses |
191 | 191 | ) { |
192 | - if ( $claimIds !== [] ) { |
|
192 | + if ($claimIds !== []) { |
|
193 | 193 | return false; |
194 | 194 | } |
195 | - if ( $constraintIds !== null ) { |
|
195 | + if ($constraintIds !== null) { |
|
196 | 196 | return false; |
197 | 197 | } |
198 | - if ( $statuses != $this->cachedStatuses ) { |
|
198 | + if ($statuses != $this->cachedStatuses) { |
|
199 | 199 | return false; |
200 | 200 | } |
201 | 201 | return true; |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | array $constraintIds = null, |
215 | 215 | array $statuses |
216 | 216 | ) { |
217 | - $results = $this->resultsBuilder->getResults( $entityIds, $claimIds, $constraintIds, $statuses ); |
|
217 | + $results = $this->resultsBuilder->getResults($entityIds, $claimIds, $constraintIds, $statuses); |
|
218 | 218 | |
219 | - if ( $this->canStoreResults( $entityIds, $claimIds, $constraintIds, $statuses ) ) { |
|
220 | - foreach ( $entityIds as $entityId ) { |
|
219 | + if ($this->canStoreResults($entityIds, $claimIds, $constraintIds, $statuses)) { |
|
220 | + foreach ($entityIds as $entityId) { |
|
221 | 221 | $value = [ |
222 | 222 | 'results' => $results->getArray()[$entityId->getSerialization()], |
223 | 223 | 'latestRevisionIds' => $this->getLatestRevisionIds( |
224 | 224 | $results->getMetadata()->getDependencyMetadata()->getEntityIds() |
225 | 225 | ), |
226 | 226 | ]; |
227 | - $this->cache->set( $entityId, $value, $this->ttlInSeconds ); |
|
227 | + $this->cache->set($entityId, $value, $this->ttlInSeconds); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
@@ -256,10 +256,10 @@ discard block |
||
256 | 256 | array $constraintIds = null, |
257 | 257 | array $statuses |
258 | 258 | ) { |
259 | - if ( $constraintIds !== null ) { |
|
259 | + if ($constraintIds !== null) { |
|
260 | 260 | return false; |
261 | 261 | } |
262 | - if ( $statuses != $this->cachedStatuses ) { |
|
262 | + if ($statuses != $this->cachedStatuses) { |
|
263 | 263 | return false; |
264 | 264 | } |
265 | 265 | return true; |
@@ -272,45 +272,44 @@ discard block |
||
272 | 272 | public function getStoredResults( |
273 | 273 | EntityId $entityId |
274 | 274 | ) { |
275 | - $value = $this->cache->get( $entityId, $curTTL, [], $asOf ); |
|
276 | - $now = call_user_func( $this->microtime, true ); |
|
275 | + $value = $this->cache->get($entityId, $curTTL, [], $asOf); |
|
276 | + $now = call_user_func($this->microtime, true); |
|
277 | 277 | |
278 | - if ( $value === false ) { |
|
278 | + if ($value === false) { |
|
279 | 279 | return null; |
280 | 280 | } |
281 | 281 | |
282 | - $ageInSeconds = (int)ceil( $now - $asOf ); |
|
282 | + $ageInSeconds = (int) ceil($now - $asOf); |
|
283 | 283 | |
284 | 284 | $dependedEntityIds = array_map( |
285 | - [ $this->entityIdParser, "parse" ], |
|
286 | - array_keys( $value['latestRevisionIds'] ) |
|
285 | + [$this->entityIdParser, "parse"], |
|
286 | + array_keys($value['latestRevisionIds']) |
|
287 | 287 | ); |
288 | 288 | |
289 | - if ( $value['latestRevisionIds'] !== $this->getLatestRevisionIds( $dependedEntityIds ) ) { |
|
289 | + if ($value['latestRevisionIds'] !== $this->getLatestRevisionIds($dependedEntityIds)) { |
|
290 | 290 | return null; |
291 | 291 | } |
292 | 292 | |
293 | 293 | $cachingMetadata = $ageInSeconds > 0 ? |
294 | - CachingMetadata::ofMaximumAgeInSeconds( $ageInSeconds ) : |
|
295 | - CachingMetadata::fresh(); |
|
294 | + CachingMetadata::ofMaximumAgeInSeconds($ageInSeconds) : CachingMetadata::fresh(); |
|
296 | 295 | |
297 | - if ( is_array( $value['results'] ) ) { |
|
298 | - array_walk( $value['results'], [ $this, 'updateCachingMetadata' ], $cachingMetadata ); |
|
296 | + if (is_array($value['results'])) { |
|
297 | + array_walk($value['results'], [$this, 'updateCachingMetadata'], $cachingMetadata); |
|
299 | 298 | } |
300 | 299 | |
301 | 300 | return new CachedCheckConstraintsResponse( |
302 | - [ $entityId->getSerialization() => $value['results'] ], |
|
301 | + [$entityId->getSerialization() => $value['results']], |
|
303 | 302 | array_reduce( |
304 | 303 | $dependedEntityIds, |
305 | - function( Metadata $metadata, EntityId $entityId ) { |
|
306 | - return Metadata::merge( [ |
|
304 | + function(Metadata $metadata, EntityId $entityId) { |
|
305 | + return Metadata::merge([ |
|
307 | 306 | $metadata, |
308 | 307 | Metadata::ofDependencyMetadata( |
309 | - DependencyMetadata::ofEntityId( $entityId ) |
|
308 | + DependencyMetadata::ofEntityId($entityId) |
|
310 | 309 | ) |
311 | - ] ); |
|
310 | + ]); |
|
312 | 311 | }, |
313 | - Metadata::ofCachingMetadata( $cachingMetadata ) |
|
312 | + Metadata::ofCachingMetadata($cachingMetadata) |
|
314 | 313 | ) |
315 | 314 | ); |
316 | 315 | } |
@@ -319,39 +318,39 @@ discard block |
||
319 | 318 | * @param EntityId[] $entityIds |
320 | 319 | * @return int[] |
321 | 320 | */ |
322 | - private function getLatestRevisionIds( array $entityIds ) { |
|
321 | + private function getLatestRevisionIds(array $entityIds) { |
|
323 | 322 | $revisionInformations = $this->wikiPageEntityMetaDataAccessor->loadRevisionInformation( |
324 | 323 | $entityIds, |
325 | 324 | EntityRevisionLookup::LATEST_FROM_REPLICA |
326 | 325 | ); |
327 | 326 | $latestRevisionIds = []; |
328 | - foreach ( $revisionInformations as $serialization => $revisionInformation ) { |
|
327 | + foreach ($revisionInformations as $serialization => $revisionInformation) { |
|
329 | 328 | $latestRevisionIds[$serialization] = $revisionInformation->page_latest; |
330 | 329 | } |
331 | 330 | return $latestRevisionIds; |
332 | 331 | } |
333 | 332 | |
334 | - public function updateCachingMetadata( &$element, $key, CachingMetadata $cachingMetadata ) { |
|
335 | - if ( $key === 'cached' ) { |
|
336 | - $element = CachingMetadata::merge( [ |
|
333 | + public function updateCachingMetadata(&$element, $key, CachingMetadata $cachingMetadata) { |
|
334 | + if ($key === 'cached') { |
|
335 | + $element = CachingMetadata::merge([ |
|
337 | 336 | $cachingMetadata, |
338 | - CachingMetadata::ofArray( $element ), |
|
339 | - ] )->toArray(); |
|
337 | + CachingMetadata::ofArray($element), |
|
338 | + ])->toArray(); |
|
340 | 339 | } |
341 | 340 | if ( |
342 | - is_array( $element ) && |
|
343 | - array_key_exists( 'constraint', $element ) && |
|
344 | - in_array( $element['constraint']['type'], $this->possiblyStaleConstraintTypes, true ) |
|
341 | + is_array($element) && |
|
342 | + array_key_exists('constraint', $element) && |
|
343 | + in_array($element['constraint']['type'], $this->possiblyStaleConstraintTypes, true) |
|
345 | 344 | ) { |
346 | - $element['cached'] = CachingMetadata::merge( [ |
|
345 | + $element['cached'] = CachingMetadata::merge([ |
|
347 | 346 | $cachingMetadata, |
348 | 347 | CachingMetadata::ofArray( |
349 | - array_key_exists( 'cached', $element ) ? $element['cached'] : null |
|
348 | + array_key_exists('cached', $element) ? $element['cached'] : null |
|
350 | 349 | ), |
351 | - ] )->toArray(); |
|
350 | + ])->toArray(); |
|
352 | 351 | } |
353 | - if ( is_array( $element ) ) { |
|
354 | - array_walk( $element, [ $this, __FUNCTION__ ], $cachingMetadata ); |
|
352 | + if (is_array($element)) { |
|
353 | + array_walk($element, [$this, __FUNCTION__], $cachingMetadata); |
|
355 | 354 | } |
356 | 355 | } |
357 | 356 | |
@@ -360,7 +359,7 @@ discard block |
||
360 | 359 | * |
361 | 360 | * @param callable $microtime |
362 | 361 | */ |
363 | - public function setMicrotimeFunction( callable $microtime ) { |
|
362 | + public function setMicrotimeFunction(callable $microtime) { |
|
364 | 363 | $this->microtime = $microtime; |
365 | 364 | } |
366 | 365 |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | protected $snak; |
25 | 25 | |
26 | - public function __construct( EntityDocument $entity, Snak $snak ) { |
|
26 | + public function __construct(EntityDocument $entity, Snak $snak) { |
|
27 | 27 | $this->entity = $entity; |
28 | 28 | $this->snak = $snak; |
29 | 29 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | Statement $statement, |
24 | 24 | Snak $snak |
25 | 25 | ) { |
26 | - parent::__construct( $entity, $snak ); |
|
26 | + parent::__construct($entity, $snak); |
|
27 | 27 | $this->statement = $statement; |
28 | 28 | } |
29 | 29 | |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | |
34 | 34 | public function getSnakGroup() { |
35 | 35 | $snaks = $this->statement->getQualifiers(); |
36 | - return array_values( $snaks->getArrayCopy() ); |
|
36 | + return array_values($snaks->getArrayCopy()); |
|
37 | 37 | } |
38 | 38 | |
39 | - protected function &getMainArray( array &$container ) { |
|
39 | + protected function &getMainArray(array &$container) { |
|
40 | 40 | $statementArray = &$this->getStatementArray( |
41 | 41 | $container, |
42 | 42 | $this->entity->getId()->getSerialization(), |
@@ -44,25 +44,25 @@ discard block |
||
44 | 44 | $this->statement->getGuid() |
45 | 45 | ); |
46 | 46 | |
47 | - if ( !array_key_exists( 'qualifiers', $statementArray ) ) { |
|
47 | + if (!array_key_exists('qualifiers', $statementArray)) { |
|
48 | 48 | $statementArray['qualifiers'] = []; |
49 | 49 | } |
50 | 50 | $qualifiersArray = &$statementArray['qualifiers']; |
51 | 51 | |
52 | 52 | $propertyId = $this->getSnak()->getPropertyId()->getSerialization(); |
53 | - if ( !array_key_exists( $propertyId, $qualifiersArray ) ) { |
|
53 | + if (!array_key_exists($propertyId, $qualifiersArray)) { |
|
54 | 54 | $qualifiersArray[$propertyId] = []; |
55 | 55 | } |
56 | 56 | $propertyArray = &$qualifiersArray[$propertyId]; |
57 | 57 | |
58 | - foreach ( $propertyArray as &$potentialQualifierArray ) { |
|
59 | - if ( $potentialQualifierArray['hash'] === $this->getSnak()->getHash() ) { |
|
58 | + foreach ($propertyArray as &$potentialQualifierArray) { |
|
59 | + if ($potentialQualifierArray['hash'] === $this->getSnak()->getHash()) { |
|
60 | 60 | $qualifierArray = &$potentialQualifierArray; |
61 | 61 | break; |
62 | 62 | } |
63 | 63 | } |
64 | - if ( !isset( $qualifierArray ) ) { |
|
65 | - $qualifierArray = [ 'hash' => $this->getSnak()->getHash() ]; |
|
64 | + if (!isset($qualifierArray)) { |
|
65 | + $qualifierArray = ['hash' => $this->getSnak()->getHash()]; |
|
66 | 66 | $propertyArray[] = &$qualifierArray; |
67 | 67 | } |
68 | 68 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | Reference $reference, |
31 | 31 | Snak $snak |
32 | 32 | ) { |
33 | - parent::__construct( $entity, $snak ); |
|
33 | + parent::__construct($entity, $snak); |
|
34 | 34 | $this->statement = $statement; |
35 | 35 | $this->reference = $reference; |
36 | 36 | } |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | |
42 | 42 | public function getSnakGroup() { |
43 | 43 | $snaks = $this->reference->getSnaks(); |
44 | - return array_values( $snaks->getArrayCopy() ); |
|
44 | + return array_values($snaks->getArrayCopy()); |
|
45 | 45 | } |
46 | 46 | |
47 | - protected function &getMainArray( array &$container ) { |
|
47 | + protected function &getMainArray(array &$container) { |
|
48 | 48 | $statementArray = &$this->getStatementArray( |
49 | 49 | $container, |
50 | 50 | $this->entity->getId()->getSerialization(), |
@@ -52,38 +52,38 @@ discard block |
||
52 | 52 | $this->statement->getGuid() |
53 | 53 | ); |
54 | 54 | |
55 | - if ( !array_key_exists( 'references', $statementArray ) ) { |
|
55 | + if (!array_key_exists('references', $statementArray)) { |
|
56 | 56 | $statementArray['references'] = []; |
57 | 57 | } |
58 | 58 | $referencesArray = &$statementArray['references']; |
59 | 59 | |
60 | - foreach ( $referencesArray as &$potentialReferenceArray ) { |
|
61 | - if ( $potentialReferenceArray['hash'] === $this->reference->getHash() ) { |
|
60 | + foreach ($referencesArray as &$potentialReferenceArray) { |
|
61 | + if ($potentialReferenceArray['hash'] === $this->reference->getHash()) { |
|
62 | 62 | $referenceArray = &$potentialReferenceArray; |
63 | 63 | break; |
64 | 64 | } |
65 | 65 | } |
66 | - if ( !isset( $referenceArray ) ) { |
|
67 | - $referenceArray = [ 'hash' => $this->reference->getHash(), 'snaks' => [] ]; |
|
66 | + if (!isset($referenceArray)) { |
|
67 | + $referenceArray = ['hash' => $this->reference->getHash(), 'snaks' => []]; |
|
68 | 68 | $referencesArray[] = &$referenceArray; |
69 | 69 | } |
70 | 70 | |
71 | 71 | $snaksArray = &$referenceArray['snaks']; |
72 | 72 | |
73 | 73 | $propertyId = $this->getSnak()->getPropertyId()->getSerialization(); |
74 | - if ( !array_key_exists( $propertyId, $snaksArray ) ) { |
|
74 | + if (!array_key_exists($propertyId, $snaksArray)) { |
|
75 | 75 | $snaksArray[$propertyId] = []; |
76 | 76 | } |
77 | 77 | $propertyArray = &$snaksArray[$propertyId]; |
78 | 78 | |
79 | - foreach ( $propertyArray as &$potentialSnakArray ) { |
|
80 | - if ( $potentialSnakArray['hash'] === $this->getSnak()->getHash() ) { |
|
79 | + foreach ($propertyArray as &$potentialSnakArray) { |
|
80 | + if ($potentialSnakArray['hash'] === $this->getSnak()->getHash()) { |
|
81 | 81 | $snakArray = &$potentialSnakArray; |
82 | 82 | break; |
83 | 83 | } |
84 | 84 | } |
85 | - if ( !isset( $snakArray ) ) { |
|
86 | - $snakArray = [ 'hash' => $this->getSnak()->getHash() ]; |
|
85 | + if (!isset($snakArray)) { |
|
86 | + $snakArray = ['hash' => $this->getSnak()->getHash()]; |
|
87 | 87 | $propertyArray[] = &$snakArray; |
88 | 88 | } |
89 | 89 |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | */ |
21 | 21 | private $statement; |
22 | 22 | |
23 | - public function __construct( EntityDocument $entity, Statement $statement ) { |
|
24 | - Assert::parameterType( StatementListProvider::class, $entity, '$entity' ); |
|
25 | - parent::__construct( $entity, $statement->getMainSnak() ); |
|
23 | + public function __construct(EntityDocument $entity, Statement $statement) { |
|
24 | + Assert::parameterType(StatementListProvider::class, $entity, '$entity'); |
|
25 | + parent::__construct($entity, $statement->getMainSnak()); |
|
26 | 26 | |
27 | 27 | $this->statement = $statement; |
28 | 28 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | /** @var StatementList $statements */ |
44 | 44 | $statements = $this->entity->getStatements(); |
45 | 45 | return $statements |
46 | - ->getByRank( [ Statement::RANK_NORMAL, Statement::RANK_PREFERRED ] ) |
|
46 | + ->getByRank([Statement::RANK_NORMAL, Statement::RANK_PREFERRED]) |
|
47 | 47 | ->getMainSnaks(); |
48 | 48 | } |
49 | 49 | |
50 | - protected function &getMainArray( array &$container ) { |
|
50 | + protected function &getMainArray(array &$container) { |
|
51 | 51 | $statementArray = &$this->getStatementArray( |
52 | 52 | $container, |
53 | 53 | $this->entity->getId()->getSerialization(), |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | $this->statement->getGuid() |
56 | 56 | ); |
57 | 57 | |
58 | - if ( !array_key_exists( 'mainsnak', $statementArray ) ) { |
|
59 | - $statementArray['mainsnak'] = [ 'hash' => $this->statement->getMainSnak()->getHash() ]; |
|
58 | + if (!array_key_exists('mainsnak', $statementArray)) { |
|
59 | + $statementArray['mainsnak'] = ['hash' => $this->statement->getMainSnak()->getHash()]; |
|
60 | 60 | } |
61 | 61 | $mainsnakArray = &$statementArray['mainsnak']; |
62 | 62 |