@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param EntityId $entityId An entity ID from which the value was derived. |
38 | 38 | * @return self Indication that a value was derived from the entity with the given ID. |
39 | 39 | */ |
40 | - public static function ofEntityId( EntityId $entityId ) { |
|
40 | + public static function ofEntityId(EntityId $entityId) { |
|
41 | 41 | $ret = new self; |
42 | 42 | $ret->entityIds[] = $entityId; |
43 | 43 | return $ret; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return self Indication that a value will only remain valid |
50 | 50 | * as long as the given time value is in the future, not in the past. |
51 | 51 | */ |
52 | - public static function ofFutureTime( TimeValue $timeValue ) { |
|
52 | + public static function ofFutureTime(TimeValue $timeValue) { |
|
53 | 53 | $ret = new self; |
54 | 54 | $ret->timeValue = $timeValue; |
55 | 55 | return $ret; |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | * @param self[] $metadatas |
60 | 60 | * @return self |
61 | 61 | */ |
62 | - public static function merge( array $metadatas ) { |
|
63 | - Assert::parameterElementType( self::class, $metadatas, '$metadatas' ); |
|
62 | + public static function merge(array $metadatas) { |
|
63 | + Assert::parameterElementType(self::class, $metadatas, '$metadatas'); |
|
64 | 64 | $ret = new self; |
65 | 65 | $entityIds = []; |
66 | - foreach ( $metadatas as $metadata ) { |
|
67 | - foreach ( $metadata->entityIds as $entityId ) { |
|
66 | + foreach ($metadatas as $metadata) { |
|
67 | + foreach ($metadata->entityIds as $entityId) { |
|
68 | 68 | $entityIds[$entityId->getSerialization()] = $entityId; |
69 | 69 | } |
70 | - $ret->timeValue = self::minTimeValue( $ret->timeValue, $metadata->timeValue ); |
|
70 | + $ret->timeValue = self::minTimeValue($ret->timeValue, $metadata->timeValue); |
|
71 | 71 | } |
72 | - $ret->entityIds = array_values( $entityIds ); |
|
72 | + $ret->entityIds = array_values($entityIds); |
|
73 | 73 | return $ret; |
74 | 74 | } |
75 | 75 | |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | * @param TimeValue|null $t2 |
79 | 79 | * @return TimeValue|null |
80 | 80 | */ |
81 | - private static function minTimeValue( TimeValue $t1 = null, TimeValue $t2 = null ) { |
|
82 | - if ( $t1 === null ) { |
|
81 | + private static function minTimeValue(TimeValue $t1 = null, TimeValue $t2 = null) { |
|
82 | + if ($t1 === null) { |
|
83 | 83 | return $t2; |
84 | 84 | } |
85 | - if ( $t2 === null ) { |
|
85 | + if ($t2 === null) { |
|
86 | 86 | return $t1; |
87 | 87 | } |
88 | - return ( new TimeValueComparer() )->getMinimum( $t1, $t2 ); |
|
88 | + return (new TimeValueComparer())->getMinimum($t1, $t2); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | $this->dataFactory = $dataFactory; |
48 | 48 | $this->logger = $logger; |
49 | 49 | $this->constraintCheckDurationLimits = [ |
50 | - 'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ), |
|
51 | - 'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ), |
|
50 | + 'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'), |
|
51 | + 'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'), |
|
52 | 52 | ]; |
53 | 53 | } |
54 | 54 | |
@@ -74,46 +74,46 @@ discard block |
||
74 | 74 | $durationSeconds, |
75 | 75 | $method |
76 | 76 | ) { |
77 | - $constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 ); |
|
77 | + $constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1); |
|
78 | 78 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
79 | 79 | |
80 | 80 | $this->dataFactory->timing( |
81 | - 'wikibase.quality.constraints.check.timing.' . |
|
82 | - $constraintTypeItemId . '-' . |
|
81 | + 'wikibase.quality.constraints.check.timing.'. |
|
82 | + $constraintTypeItemId.'-'. |
|
83 | 83 | $constraintCheckerClassShortName, |
84 | 84 | $durationSeconds * 1000 |
85 | 85 | ); |
86 | 86 | |
87 | 87 | // find the longest limit (and associated log level) that the duration exceeds |
88 | - foreach ( $this->constraintCheckDurationLimits as $level => $limit ) { |
|
88 | + foreach ($this->constraintCheckDurationLimits as $level => $limit) { |
|
89 | 89 | if ( |
90 | 90 | // duration exceeds this limit |
91 | - isset( $limit ) && $durationSeconds > $limit && |
|
91 | + isset($limit) && $durationSeconds > $limit && |
|
92 | 92 | // this limit is longer than previous longest limit |
93 | - ( !isset( $limitSeconds ) || $limit > $limitSeconds ) |
|
93 | + (!isset($limitSeconds) || $limit > $limitSeconds) |
|
94 | 94 | ) { |
95 | 95 | $limitSeconds = $limit; |
96 | 96 | $logLevel = $level; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - if ( !isset( $limitSeconds ) ) { |
|
100 | + if (!isset($limitSeconds)) { |
|
101 | 101 | return; |
102 | 102 | } |
103 | - if ( $context->getType() !== Context::TYPE_STATEMENT ) { |
|
103 | + if ($context->getType() !== Context::TYPE_STATEMENT) { |
|
104 | 104 | // TODO log less details but still log something |
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | 108 | $resultMessage = $result->getMessage(); |
109 | - if ( $resultMessage instanceof ViolationMessage ) { |
|
109 | + if ($resultMessage instanceof ViolationMessage) { |
|
110 | 110 | $resultMessage = $resultMessage->getMessageKey(); |
111 | 111 | } |
112 | 112 | |
113 | 113 | $this->logger->log( |
114 | 114 | $logLevel, |
115 | - 'Constraint check with {constraintCheckerClassShortName} ' . |
|
116 | - 'took longer than {limitSeconds} second(s) ' . |
|
115 | + 'Constraint check with {constraintCheckerClassShortName} '. |
|
116 | + 'took longer than {limitSeconds} second(s) '. |
|
117 | 117 | '(duration: {durationSeconds} seconds).', |
118 | 118 | [ |
119 | 119 | 'method' => $method, |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @param EntityId $entityId |
142 | 142 | */ |
143 | - public function logCheckConstraintsCacheHit( EntityId $entityId ) { |
|
143 | + public function logCheckConstraintsCacheHit(EntityId $entityId) { |
|
144 | 144 | $this->dataFactory->increment( |
145 | 145 | 'wikibase.quality.constraints.cache.entity.hit' |
146 | 146 | ); |
@@ -151,10 +151,10 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @param EntityId[] $entityIds |
153 | 153 | */ |
154 | - public function logCheckConstraintsCacheMisses( array $entityIds ) { |
|
154 | + public function logCheckConstraintsCacheMisses(array $entityIds) { |
|
155 | 155 | $this->dataFactory->updateCount( |
156 | 156 | 'wikibase.quality.constraints.cache.entity.miss', |
157 | - count( $entityIds ) |
|
157 | + count($entityIds) |
|
158 | 158 | ); |
159 | 159 | } |
160 | 160 | |
@@ -181,16 +181,16 @@ discard block |
||
181 | 181 | * @param EntityId[] $entityIds |
182 | 182 | * @param int $maxRevisionIds |
183 | 183 | */ |
184 | - public function logHugeDependencyMetadata( array $entityIds, $maxRevisionIds ) { |
|
184 | + public function logHugeDependencyMetadata(array $entityIds, $maxRevisionIds) { |
|
185 | 185 | $this->logger->log( |
186 | 186 | 'warning', |
187 | - 'Dependency metadata for constraint check result has huge set of entity IDs ' . |
|
188 | - '(count ' . count( $entityIds ) . ', limit ' . $maxRevisionIds . '); ' . |
|
187 | + 'Dependency metadata for constraint check result has huge set of entity IDs '. |
|
188 | + '(count '.count($entityIds).', limit '.$maxRevisionIds.'); '. |
|
189 | 189 | 'caching disabled for this check result.', |
190 | 190 | [ |
191 | 191 | 'loggingMethod' => __METHOD__, |
192 | 192 | 'entityIds' => array_map( |
193 | - function ( EntityId $entityId ) { |
|
193 | + function(EntityId $entityId) { |
|
194 | 194 | return $entityId->getSerialization(); |
195 | 195 | }, |
196 | 196 | $entityIds |
@@ -86,6 +86,6 @@ |
||
86 | 86 | * @param array|null $result |
87 | 87 | * @param array[] &$container |
88 | 88 | */ |
89 | - public function storeCheckResultInArray( array $result = null, array &$container ); |
|
89 | + public function storeCheckResultInArray(array $result = null, array &$container); |
|
90 | 90 | |
91 | 91 | } |
@@ -122,12 +122,12 @@ discard block |
||
122 | 122 | $status = self::STATUS_TODO, |
123 | 123 | $message = null |
124 | 124 | ) { |
125 | - if ( $contextCursor instanceof Context ) { |
|
125 | + if ($contextCursor instanceof Context) { |
|
126 | 126 | $context = $contextCursor; |
127 | 127 | $this->contextCursor = $context->getCursor(); |
128 | 128 | $this->snakType = $context->getSnak()->getType(); |
129 | 129 | $mainSnak = $context->getSnak(); |
130 | - if ( $mainSnak instanceof PropertyValueSnak ) { |
|
130 | + if ($mainSnak instanceof PropertyValueSnak) { |
|
131 | 131 | $this->dataValue = $mainSnak->getDataValue(); |
132 | 132 | } else { |
133 | 133 | $this->dataValue = null; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param string $key |
191 | 191 | * @param string $value |
192 | 192 | */ |
193 | - public function addParameter( $key, $value ) { |
|
193 | + public function addParameter($key, $value) { |
|
194 | 194 | $this->parameters[$key][] = $value; |
195 | 195 | } |
196 | 196 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | /** |
205 | 205 | * @param string $status |
206 | 206 | */ |
207 | - public function setStatus( $status ) { |
|
207 | + public function setStatus($status) { |
|
208 | 208 | $this->status = $status; |
209 | 209 | } |
210 | 210 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | * @param Metadata $metadata |
220 | 220 | * @return self |
221 | 221 | */ |
222 | - public function withMetadata( Metadata $metadata ) { |
|
222 | + public function withMetadata(Metadata $metadata) { |
|
223 | 223 | $this->metadata = $metadata; |
224 | 224 | return $this; |
225 | 225 | } |
@@ -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,7 +33,7 @@ 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 | 39 | public function getCursor() { |
@@ -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,7 +43,7 @@ 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 |
@@ -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,7 +41,7 @@ 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 | 47 | public function getCursor() { |
@@ -92,43 +92,43 @@ |
||
92 | 92 | return $this->referenceHash; |
93 | 93 | } |
94 | 94 | |
95 | - protected function &getMainArray( array &$container ) { |
|
96 | - $statementArray = &$this->getStatementArray( $container ); |
|
95 | + protected function &getMainArray(array &$container) { |
|
96 | + $statementArray = &$this->getStatementArray($container); |
|
97 | 97 | |
98 | - if ( !array_key_exists( 'references', $statementArray ) ) { |
|
98 | + if (!array_key_exists('references', $statementArray)) { |
|
99 | 99 | $statementArray['references'] = []; |
100 | 100 | } |
101 | 101 | $referencesArray = &$statementArray['references']; |
102 | 102 | |
103 | 103 | $referenceHash = $this->getReferenceHash(); |
104 | - foreach ( $referencesArray as &$potentialReferenceArray ) { |
|
105 | - if ( $potentialReferenceArray['hash'] === $referenceHash ) { |
|
104 | + foreach ($referencesArray as &$potentialReferenceArray) { |
|
105 | + if ($potentialReferenceArray['hash'] === $referenceHash) { |
|
106 | 106 | $referenceArray = &$potentialReferenceArray; |
107 | 107 | break; |
108 | 108 | } |
109 | 109 | } |
110 | - if ( !isset( $referenceArray ) ) { |
|
111 | - $referenceArray = [ 'hash' => $referenceHash, 'snaks' => [] ]; |
|
110 | + if (!isset($referenceArray)) { |
|
111 | + $referenceArray = ['hash' => $referenceHash, 'snaks' => []]; |
|
112 | 112 | $referencesArray[] = &$referenceArray; |
113 | 113 | } |
114 | 114 | |
115 | 115 | $snaksArray = &$referenceArray['snaks']; |
116 | 116 | |
117 | 117 | $snakPropertyId = $this->getSnakPropertyId(); |
118 | - if ( !array_key_exists( $snakPropertyId, $snaksArray ) ) { |
|
118 | + if (!array_key_exists($snakPropertyId, $snaksArray)) { |
|
119 | 119 | $snaksArray[$snakPropertyId] = []; |
120 | 120 | } |
121 | 121 | $propertyArray = &$snaksArray[$snakPropertyId]; |
122 | 122 | |
123 | 123 | $snakHash = $this->getSnakHash(); |
124 | - foreach ( $propertyArray as &$potentialSnakArray ) { |
|
125 | - if ( $potentialSnakArray['hash'] === $snakHash ) { |
|
124 | + foreach ($propertyArray as &$potentialSnakArray) { |
|
125 | + if ($potentialSnakArray['hash'] === $snakHash) { |
|
126 | 126 | $snakArray = &$potentialSnakArray; |
127 | 127 | break; |
128 | 128 | } |
129 | 129 | } |
130 | - if ( !isset( $snakArray ) ) { |
|
131 | - $snakArray = [ 'hash' => $snakHash ]; |
|
130 | + if (!isset($snakArray)) { |
|
131 | + $snakArray = ['hash' => $snakHash]; |
|
132 | 132 | $propertyArray[] = &$snakArray; |
133 | 133 | } |
134 | 134 |
@@ -80,29 +80,29 @@ |
||
80 | 80 | return $this->snakHash; |
81 | 81 | } |
82 | 82 | |
83 | - protected function &getMainArray( array &$container ) { |
|
84 | - $statementArray = &$this->getStatementArray( $container ); |
|
83 | + protected function &getMainArray(array &$container) { |
|
84 | + $statementArray = &$this->getStatementArray($container); |
|
85 | 85 | |
86 | - if ( !array_key_exists( 'qualifiers', $statementArray ) ) { |
|
86 | + if (!array_key_exists('qualifiers', $statementArray)) { |
|
87 | 87 | $statementArray['qualifiers'] = []; |
88 | 88 | } |
89 | 89 | $qualifiersArray = &$statementArray['qualifiers']; |
90 | 90 | |
91 | 91 | $snakPropertyId = $this->getSnakPropertyId(); |
92 | - if ( !array_key_exists( $snakPropertyId, $qualifiersArray ) ) { |
|
92 | + if (!array_key_exists($snakPropertyId, $qualifiersArray)) { |
|
93 | 93 | $qualifiersArray[$snakPropertyId] = []; |
94 | 94 | } |
95 | 95 | $propertyArray = &$qualifiersArray[$snakPropertyId]; |
96 | 96 | |
97 | 97 | $snakHash = $this->getSnakHash(); |
98 | - foreach ( $propertyArray as &$potentialQualifierArray ) { |
|
99 | - if ( $potentialQualifierArray['hash'] === $snakHash ) { |
|
98 | + foreach ($propertyArray as &$potentialQualifierArray) { |
|
99 | + if ($potentialQualifierArray['hash'] === $snakHash) { |
|
100 | 100 | $qualifierArray = &$potentialQualifierArray; |
101 | 101 | break; |
102 | 102 | } |
103 | 103 | } |
104 | - if ( !isset( $qualifierArray ) ) { |
|
105 | - $qualifierArray = [ 'hash' => $snakHash ]; |
|
104 | + if (!isset($qualifierArray)) { |
|
105 | + $qualifierArray = ['hash' => $snakHash]; |
|
106 | 106 | $propertyArray[] = &$qualifierArray; |
107 | 107 | } |
108 | 108 |