@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @throws InvalidArgumentException |
33 | 33 | */ |
34 | - public function __construct( $content, array $attributes = [] ) { |
|
35 | - Assert::parameterType( [ 'string', HtmlArmor::class ], $content, '$content' ); |
|
34 | + public function __construct($content, array $attributes = []) { |
|
35 | + Assert::parameterType(['string', HtmlArmor::class], $content, '$content'); |
|
36 | 36 | |
37 | 37 | $this->content = $content; |
38 | 38 | $this->attributes = $attributes; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @return string HTML |
43 | 43 | */ |
44 | 44 | public function getContent() { |
45 | - return HtmlArmor::getHtml( $this->content ); |
|
45 | + return HtmlArmor::getHtml($this->content); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @return string HTML |
57 | 57 | */ |
58 | 58 | public function toHtml() { |
59 | - return Html::rawElement( 'td', $this->getAttributes(), $this->getContent() ); |
|
59 | + return Html::rawElement('td', $this->getAttributes(), $this->getContent()); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\Api; |
6 | 6 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | StatementGuidParser $statementGuidParser, |
80 | 80 | IBufferingStatsdDataFactory $dataFactory |
81 | 81 | ) { |
82 | - parent::__construct( $main, $name ); |
|
82 | + parent::__construct($main, $name); |
|
83 | 83 | |
84 | - $this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
84 | + $this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this); |
|
85 | 85 | $this->languageFallbackChainFactory = $languageFallbackChainFactory; |
86 | 86 | $this->delegatingConstraintChecker = $delegatingConstraintChecker; |
87 | 87 | $this->violationMessageRendererFactory = $violationMessageRendererFactory; |
@@ -97,39 +97,39 @@ discard block |
||
97 | 97 | $params = $this->extractRequestParams(); |
98 | 98 | $result = $this->getResult(); |
99 | 99 | |
100 | - $propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] ); |
|
101 | - $constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] ); |
|
100 | + $propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]); |
|
101 | + $constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]); |
|
102 | 102 | |
103 | - $this->checkPropertyIds( $propertyIds, $result ); |
|
104 | - $this->checkConstraintIds( $constraintIds, $result ); |
|
103 | + $this->checkPropertyIds($propertyIds, $result); |
|
104 | + $this->checkConstraintIds($constraintIds, $result); |
|
105 | 105 | |
106 | - $result->addValue( null, 'success', 1 ); |
|
106 | + $result->addValue(null, 'success', 1); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @param array|null $propertyIdSerializations |
111 | 111 | * @return NumericPropertyId[] |
112 | 112 | */ |
113 | - private function parsePropertyIds( ?array $propertyIdSerializations ): array { |
|
114 | - if ( $propertyIdSerializations === null ) { |
|
113 | + private function parsePropertyIds(?array $propertyIdSerializations): array { |
|
114 | + if ($propertyIdSerializations === null) { |
|
115 | 115 | return []; |
116 | - } elseif ( $propertyIdSerializations === [] ) { |
|
116 | + } elseif ($propertyIdSerializations === []) { |
|
117 | 117 | $this->apiErrorReporter->dieError( |
118 | - 'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.', |
|
118 | + 'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.', |
|
119 | 119 | 'no-data' |
120 | 120 | ); |
121 | 121 | } |
122 | 122 | |
123 | 123 | return array_map( |
124 | - function ( $propertyIdSerialization ) { |
|
124 | + function($propertyIdSerialization) { |
|
125 | 125 | try { |
126 | - return new NumericPropertyId( $propertyIdSerialization ); |
|
127 | - } catch ( InvalidArgumentException $e ) { |
|
126 | + return new NumericPropertyId($propertyIdSerialization); |
|
127 | + } catch (InvalidArgumentException $e) { |
|
128 | 128 | $this->apiErrorReporter->dieError( |
129 | 129 | "Invalid id: $propertyIdSerialization", |
130 | 130 | 'invalid-property-id', |
131 | 131 | 0, // default argument |
132 | - [ self::PARAM_PROPERTY_ID => $propertyIdSerialization ] |
|
132 | + [self::PARAM_PROPERTY_ID => $propertyIdSerialization] |
|
133 | 133 | ); |
134 | 134 | } |
135 | 135 | }, |
@@ -141,35 +141,35 @@ discard block |
||
141 | 141 | * @param array|null $constraintIds |
142 | 142 | * @return string[] |
143 | 143 | */ |
144 | - private function parseConstraintIds( ?array $constraintIds ): array { |
|
145 | - if ( $constraintIds === null ) { |
|
144 | + private function parseConstraintIds(?array $constraintIds): array { |
|
145 | + if ($constraintIds === null) { |
|
146 | 146 | return []; |
147 | - } elseif ( $constraintIds === [] ) { |
|
147 | + } elseif ($constraintIds === []) { |
|
148 | 148 | $this->apiErrorReporter->dieError( |
149 | - 'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.', |
|
149 | + 'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.', |
|
150 | 150 | 'no-data' |
151 | 151 | ); |
152 | 152 | } |
153 | 153 | |
154 | 154 | return array_map( |
155 | - function ( $constraintId ) { |
|
155 | + function($constraintId) { |
|
156 | 156 | try { |
157 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
158 | - if ( !$propertyId instanceof NumericPropertyId ) { |
|
157 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
158 | + if (!$propertyId instanceof NumericPropertyId) { |
|
159 | 159 | $this->apiErrorReporter->dieError( |
160 | 160 | "Invalid property ID: {$propertyId->getSerialization()}", |
161 | 161 | 'invalid-property-id', |
162 | 162 | 0, // default argument |
163 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
163 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
164 | 164 | ); |
165 | 165 | } |
166 | 166 | return $constraintId; |
167 | - } catch ( StatementGuidParsingException $e ) { |
|
167 | + } catch (StatementGuidParsingException $e) { |
|
168 | 168 | $this->apiErrorReporter->dieError( |
169 | 169 | "Invalid statement GUID: $constraintId", |
170 | 170 | 'invalid-guid', |
171 | 171 | 0, // default argument |
172 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
172 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
173 | 173 | ); |
174 | 174 | } |
175 | 175 | }, |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | * @param NumericPropertyId[] $propertyIds |
182 | 182 | * @param ApiResult $result |
183 | 183 | */ |
184 | - private function checkPropertyIds( array $propertyIds, ApiResult $result ): void { |
|
185 | - foreach ( $propertyIds as $propertyId ) { |
|
186 | - $result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' ); |
|
184 | + private function checkPropertyIds(array $propertyIds, ApiResult $result): void { |
|
185 | + foreach ($propertyIds as $propertyId) { |
|
186 | + $result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc'); |
|
187 | 187 | $allConstraintExceptions = $this->delegatingConstraintChecker |
188 | - ->checkConstraintParametersOnPropertyId( $propertyId ); |
|
189 | - foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) { |
|
188 | + ->checkConstraintParametersOnPropertyId($propertyId); |
|
189 | + foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) { |
|
190 | 190 | $this->addConstraintParameterExceptionsToResult( |
191 | 191 | $constraintId, |
192 | 192 | $constraintParameterExceptions, |
@@ -200,15 +200,15 @@ discard block |
||
200 | 200 | * @param string[] $constraintIds |
201 | 201 | * @param ApiResult $result |
202 | 202 | */ |
203 | - private function checkConstraintIds( array $constraintIds, ApiResult $result ): void { |
|
204 | - foreach ( $constraintIds as $constraintId ) { |
|
205 | - if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) { |
|
203 | + private function checkConstraintIds(array $constraintIds, ApiResult $result): void { |
|
204 | + foreach ($constraintIds as $constraintId) { |
|
205 | + if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) { |
|
206 | 206 | // already checked as part of checkPropertyIds() |
207 | 207 | continue; |
208 | 208 | } |
209 | 209 | $constraintParameterExceptions = $this->delegatingConstraintChecker |
210 | - ->checkConstraintParametersOnConstraintId( $constraintId ); |
|
211 | - $this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result ); |
|
210 | + ->checkConstraintParametersOnConstraintId($constraintId); |
|
211 | + $this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
@@ -216,18 +216,18 @@ discard block |
||
216 | 216 | * @param NumericPropertyId $propertyId |
217 | 217 | * @return string[] |
218 | 218 | */ |
219 | - private function getResultPathForPropertyId( NumericPropertyId $propertyId ): array { |
|
220 | - return [ $this->getModuleName(), $propertyId->getSerialization() ]; |
|
219 | + private function getResultPathForPropertyId(NumericPropertyId $propertyId): array { |
|
220 | + return [$this->getModuleName(), $propertyId->getSerialization()]; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
224 | 224 | * @param string $constraintId |
225 | 225 | * @return string[] |
226 | 226 | */ |
227 | - private function getResultPathForConstraintId( string $constraintId ): array { |
|
228 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
227 | + private function getResultPathForConstraintId(string $constraintId): array { |
|
228 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
229 | 229 | '@phan-var NumericPropertyId $propertyId'; |
230 | - return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] ); |
|
230 | + return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | ?array $constraintParameterExceptions, |
243 | 243 | ApiResult $result |
244 | 244 | ): void { |
245 | - $path = $this->getResultPathForConstraintId( $constraintId ); |
|
246 | - if ( $constraintParameterExceptions === null ) { |
|
245 | + $path = $this->getResultPathForConstraintId($constraintId); |
|
246 | + if ($constraintParameterExceptions === null) { |
|
247 | 247 | $result->addValue( |
248 | 248 | $path, |
249 | 249 | self::KEY_STATUS, |
@@ -260,11 +260,11 @@ discard block |
||
260 | 260 | $violationMessageRenderer = $this->violationMessageRendererFactory |
261 | 261 | ->getViolationMessageRenderer( |
262 | 262 | $language, |
263 | - $this->languageFallbackChainFactory->newFromLanguage( $language ), |
|
263 | + $this->languageFallbackChainFactory->newFromLanguage($language), |
|
264 | 264 | $this |
265 | 265 | ); |
266 | 266 | $problems = []; |
267 | - foreach ( $constraintParameterExceptions as $constraintParameterException ) { |
|
267 | + foreach ($constraintParameterExceptions as $constraintParameterException) { |
|
268 | 268 | $problems[] = [ |
269 | 269 | self::KEY_MESSAGE_HTML => $violationMessageRenderer->render( |
270 | 270 | $constraintParameterException->getViolationMessage() ), |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | return [ |
304 | 304 | 'action=wbcheckconstraintparameters&propertyid=P247' |
305 | 305 | => 'apihelp-wbcheckconstraintparameters-example-propertyid-1', |
306 | - 'action=wbcheckconstraintparameters&' . |
|
307 | - 'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|' . |
|
306 | + 'action=wbcheckconstraintparameters&'. |
|
307 | + 'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|'. |
|
308 | 308 | 'P225$cdc71e4a-47a0-12c5-dfb3-3f6fc0b6613f' |
309 | 309 | => 'apihelp-wbcheckconstraintparameters-example-constraintid-2', |
310 | 310 | ]; |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | $this->dataFactory = $dataFactory; |
54 | 54 | $this->logger = $logger; |
55 | 55 | $this->constraintCheckDurationLimits = [ |
56 | - 'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ), |
|
57 | - 'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ), |
|
56 | + 'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'), |
|
57 | + 'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'), |
|
58 | 58 | ]; |
59 | 59 | $this->constraintCheckOnEntityDurationLimits = [ |
60 | - 'info' => $config->get( 'WBQualityConstraintsCheckOnEntityDurationInfoSeconds' ), |
|
61 | - 'warning' => $config->get( 'WBQualityConstraintsCheckOnEntityDurationWarningSeconds' ), |
|
60 | + 'info' => $config->get('WBQualityConstraintsCheckOnEntityDurationInfoSeconds'), |
|
61 | + 'warning' => $config->get('WBQualityConstraintsCheckOnEntityDurationWarningSeconds'), |
|
62 | 62 | ]; |
63 | 63 | } |
64 | 64 | |
@@ -69,23 +69,23 @@ discard block |
||
69 | 69 | * @param float $durationSeconds |
70 | 70 | * @return array [ $limitSeconds, $logLevel ] |
71 | 71 | */ |
72 | - private function findLimit( $limits, $durationSeconds ) { |
|
72 | + private function findLimit($limits, $durationSeconds) { |
|
73 | 73 | $limitSeconds = null; |
74 | 74 | $logLevel = null; |
75 | 75 | |
76 | - foreach ( $limits as $level => $limit ) { |
|
76 | + foreach ($limits as $level => $limit) { |
|
77 | 77 | if ( |
78 | 78 | // duration exceeds this limit |
79 | 79 | $limit !== null && $durationSeconds > $limit && |
80 | 80 | // this limit is longer than previous longest limit |
81 | - ( $limitSeconds === null || $limit > $limitSeconds ) |
|
81 | + ($limitSeconds === null || $limit > $limitSeconds) |
|
82 | 82 | ) { |
83 | 83 | $limitSeconds = $limit; |
84 | 84 | $logLevel = $level; |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - return [ $limitSeconds, $logLevel ]; |
|
88 | + return [$limitSeconds, $logLevel]; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -110,31 +110,31 @@ discard block |
||
110 | 110 | $durationSeconds, |
111 | 111 | $method |
112 | 112 | ) { |
113 | - $constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 ); |
|
113 | + $constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1); |
|
114 | 114 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
115 | 115 | |
116 | 116 | $this->dataFactory->timing( |
117 | - 'wikibase.quality.constraints.check.timing.' . |
|
118 | - $constraintTypeItemId . '-' . |
|
117 | + 'wikibase.quality.constraints.check.timing.'. |
|
118 | + $constraintTypeItemId.'-'. |
|
119 | 119 | $constraintCheckerClassShortName, |
120 | 120 | $durationSeconds * 1000 |
121 | 121 | ); |
122 | 122 | |
123 | 123 | // find the longest limit (and associated log level) that the duration exceeds |
124 | - [ $limitSeconds, $logLevel ] = $this->findLimit( |
|
124 | + [$limitSeconds, $logLevel] = $this->findLimit( |
|
125 | 125 | $this->constraintCheckDurationLimits, |
126 | 126 | $durationSeconds |
127 | 127 | ); |
128 | - if ( $limitSeconds === null ) { |
|
128 | + if ($limitSeconds === null) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | - if ( $context->getType() !== Context::TYPE_STATEMENT ) { |
|
131 | + if ($context->getType() !== Context::TYPE_STATEMENT) { |
|
132 | 132 | // TODO log less details but still log something |
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | 136 | $resultMessage = $result->getMessage(); |
137 | - if ( $resultMessage !== null ) { |
|
137 | + if ($resultMessage !== null) { |
|
138 | 138 | $resultMessageKey = $resultMessage->getMessageKey(); |
139 | 139 | } else { |
140 | 140 | $resultMessageKey = null; |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | |
143 | 143 | $this->logger->log( |
144 | 144 | $logLevel, |
145 | - 'Constraint check with {constraintCheckerClassShortName} ' . |
|
146 | - 'took longer than {limitSeconds} second(s) ' . |
|
145 | + 'Constraint check with {constraintCheckerClassShortName} '. |
|
146 | + 'took longer than {limitSeconds} second(s) '. |
|
147 | 147 | '(duration: {durationSeconds} seconds).', |
148 | 148 | [ |
149 | 149 | 'method' => $method, |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'constraintId' => $constraint->getConstraintId(), |
154 | 154 | 'constraintPropertyId' => $constraint->getPropertyId()->getSerialization(), |
155 | 155 | 'constraintTypeItemId' => $constraintTypeItemId, |
156 | - 'constraintParameters' => json_encode( $constraint->getConstraintParameters() ), |
|
156 | + 'constraintParameters' => json_encode($constraint->getConstraintParameters()), |
|
157 | 157 | 'constraintCheckerClass' => $constraintCheckerClass, |
158 | 158 | 'constraintCheckerClassShortName' => $constraintCheckerClassShortName, |
159 | 159 | 'entityId' => $context->getEntity()->getId()->getSerialization(), |
@@ -188,18 +188,18 @@ discard block |
||
188 | 188 | ); |
189 | 189 | |
190 | 190 | // find the longest limit (and associated log level) that the duration exceeds |
191 | - [ $limitSeconds, $logLevel ] = $this->findLimit( |
|
191 | + [$limitSeconds, $logLevel] = $this->findLimit( |
|
192 | 192 | $this->constraintCheckOnEntityDurationLimits, |
193 | 193 | $durationSeconds |
194 | 194 | ); |
195 | - if ( $limitSeconds === null ) { |
|
195 | + if ($limitSeconds === null) { |
|
196 | 196 | return; |
197 | 197 | } |
198 | 198 | |
199 | 199 | $this->logger->log( |
200 | 200 | $logLevel, |
201 | - 'Full constraint check on {entityId} ' . |
|
202 | - 'took longer than {limitSeconds} second(s) ' . |
|
201 | + 'Full constraint check on {entityId} '. |
|
202 | + 'took longer than {limitSeconds} second(s) '. |
|
203 | 203 | '(duration: {durationSeconds} seconds).', |
204 | 204 | [ |
205 | 205 | 'method' => $method, |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * |
218 | 218 | * @param EntityId $entityId |
219 | 219 | */ |
220 | - public function logCheckConstraintsCacheHit( EntityId $entityId ) { |
|
220 | + public function logCheckConstraintsCacheHit(EntityId $entityId) { |
|
221 | 221 | $this->dataFactory->increment( |
222 | 222 | 'wikibase.quality.constraints.cache.entity.hit' |
223 | 223 | ); |
@@ -228,10 +228,10 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @param EntityId[] $entityIds |
230 | 230 | */ |
231 | - public function logCheckConstraintsCacheMisses( array $entityIds ) { |
|
231 | + public function logCheckConstraintsCacheMisses(array $entityIds) { |
|
232 | 232 | $this->dataFactory->updateCount( |
233 | 233 | 'wikibase.quality.constraints.cache.entity.miss', |
234 | - count( $entityIds ) |
|
234 | + count($entityIds) |
|
235 | 235 | ); |
236 | 236 | } |
237 | 237 | |
@@ -258,17 +258,17 @@ discard block |
||
258 | 258 | * @param EntityId[] $entityIds |
259 | 259 | * @param int $maxRevisionIds |
260 | 260 | */ |
261 | - public function logHugeDependencyMetadata( array $entityIds, $maxRevisionIds ) { |
|
261 | + public function logHugeDependencyMetadata(array $entityIds, $maxRevisionIds) { |
|
262 | 262 | $this->logger->log( |
263 | 263 | 'warning', |
264 | - 'Dependency metadata for constraint check result has huge set of entity IDs ' . |
|
265 | - '(count ' . count( $entityIds ) . ', limit ' . $maxRevisionIds . '); ' . |
|
264 | + 'Dependency metadata for constraint check result has huge set of entity IDs '. |
|
265 | + '(count '.count($entityIds).', limit '.$maxRevisionIds.'); '. |
|
266 | 266 | 'caching disabled for this check result.', |
267 | 267 | [ |
268 | 268 | 'loggingMethod' => __METHOD__, |
269 | 269 | 'entityIds' => json_encode( |
270 | 270 | array_map( |
271 | - static function ( EntityId $entityId ) { |
|
271 | + static function(EntityId $entityId) { |
|
272 | 272 | return $entityId->getSerialization(); |
273 | 273 | }, |
274 | 274 | $entityIds |
@@ -287,17 +287,17 @@ discard block |
||
287 | 287 | 'Sparql API replied with status 429 and a retry-after header. Requesting to retry after {retryAfterTime}', |
288 | 288 | [ |
289 | 289 | 'retryAfterTime' => $retryAfterTime, |
290 | - 'responseHeaders' => json_encode( $request->getResponseHeaders() ), |
|
290 | + 'responseHeaders' => json_encode($request->getResponseHeaders()), |
|
291 | 291 | 'responseContent' => $request->getContent(), |
292 | 292 | ] |
293 | 293 | ); |
294 | 294 | } |
295 | 295 | |
296 | - public function logSparqlHelperTooManyRequestsRetryAfterInvalid( MWHttpRequest $request ) { |
|
296 | + public function logSparqlHelperTooManyRequestsRetryAfterInvalid(MWHttpRequest $request) { |
|
297 | 297 | $this->logger->warning( |
298 | 298 | 'Sparql API replied with status 429 and no valid retry-after header.', |
299 | 299 | [ |
300 | - 'responseHeaders' => json_encode( $request->getResponseHeaders() ), |
|
300 | + 'responseHeaders' => json_encode($request->getResponseHeaders()), |
|
301 | 301 | 'responseContent' => $request->getContent(), |
302 | 302 | ] |
303 | 303 | ); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @throws DBUnexpectedError |
17 | 17 | */ |
18 | - public function insertBatch( array $constraints ); |
|
18 | + public function insertBatch(array $constraints); |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Delete all constraints for the property ID. |
@@ -24,6 +24,6 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @throws DBUnexpectedError |
26 | 26 | */ |
27 | - public function deleteForProperty( NumericPropertyId $propertyId ); |
|
27 | + public function deleteForProperty(NumericPropertyId $propertyId); |
|
28 | 28 | |
29 | 29 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Checker; |
6 | 6 | |
@@ -64,18 +64,18 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs |
66 | 66 | */ |
67 | - public function checkConstraint( Context $context, Constraint $constraint ): CheckResult { |
|
68 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
69 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED ); |
|
67 | + public function checkConstraint(Context $context, Constraint $constraint): CheckResult { |
|
68 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
69 | + return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED); |
|
70 | 70 | } |
71 | 71 | |
72 | - if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) { |
|
72 | + if (!($this->sparqlHelper instanceof DummySparqlHelper)) { |
|
73 | 73 | |
74 | 74 | $separators = $this->constraintParameterParser->parseSeparatorsParameter( |
75 | 75 | $constraint->getConstraintParameters() |
76 | 76 | ); |
77 | 77 | |
78 | - if ( $context->getType() === 'statement' ) { |
|
78 | + if ($context->getType() === 'statement') { |
|
79 | 79 | $statement = $context->getSnakStatement(); |
80 | 80 | '@phan-var Statement $statement'; |
81 | 81 | $result = $this->sparqlHelper->findEntitiesWithSameStatement( |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | ); |
85 | 85 | } else { |
86 | 86 | $snak = $context->getSnak(); |
87 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
87 | + if (!$snak instanceof PropertyValueSnak) { |
|
88 | 88 | // nothing to check |
89 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE ); |
|
89 | + return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE); |
|
90 | 90 | } |
91 | 91 | $result = $this->sparqlHelper->findEntitiesWithSameQualifierOrReference( |
92 | 92 | $context->getEntity()->getId(), |
@@ -99,31 +99,31 @@ discard block |
||
99 | 99 | $otherEntities = $result->getArray(); |
100 | 100 | $metadata = $result->getMetadata(); |
101 | 101 | |
102 | - if ( $otherEntities === [] ) { |
|
102 | + if ($otherEntities === []) { |
|
103 | 103 | $status = CheckResult::STATUS_COMPLIANCE; |
104 | 104 | $message = null; |
105 | 105 | } else { |
106 | 106 | $status = CheckResult::STATUS_VIOLATION; |
107 | - $message = ( new ViolationMessage( 'wbqc-violation-message-unique-value' ) ) |
|
108 | - ->withEntityIdList( $otherEntities, Role::SUBJECT ); |
|
107 | + $message = (new ViolationMessage('wbqc-violation-message-unique-value')) |
|
108 | + ->withEntityIdList($otherEntities, Role::SUBJECT); |
|
109 | 109 | } |
110 | 110 | } else { |
111 | 111 | $status = CheckResult::STATUS_TODO; |
112 | - $message = ( new ViolationMessage( 'wbqc-violation-message-not-yet-implemented' ) ) |
|
113 | - ->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM ); |
|
112 | + $message = (new ViolationMessage('wbqc-violation-message-not-yet-implemented')) |
|
113 | + ->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM); |
|
114 | 114 | $metadata = Metadata::blank(); |
115 | 115 | } |
116 | 116 | |
117 | - return ( new CheckResult( $context, $constraint, $status, $message ) ) |
|
118 | - ->withMetadata( $metadata ); |
|
117 | + return (new CheckResult($context, $constraint, $status, $message)) |
|
118 | + ->withMetadata($metadata); |
|
119 | 119 | } |
120 | 120 | |
121 | - public function checkConstraintParameters( Constraint $constraint ): array { |
|
121 | + public function checkConstraintParameters(Constraint $constraint): array { |
|
122 | 122 | $constraintParameters = $constraint->getConstraintParameters(); |
123 | 123 | $exceptions = []; |
124 | 124 | try { |
125 | - $this->constraintParameterParser->parseSeparatorsParameter( $constraintParameters ); |
|
126 | - } catch ( ConstraintParameterException $e ) { |
|
125 | + $this->constraintParameterParser->parseSeparatorsParameter($constraintParameters); |
|
126 | + } catch (ConstraintParameterException $e) { |
|
127 | 127 | $exceptions[] = $e; |
128 | 128 | } |
129 | 129 | return $exceptions; |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Cache; |
6 | 6 |
@@ -15,12 +15,12 @@ |
||
15 | 15 | /** |
16 | 16 | * @param DatabaseUpdater $updater |
17 | 17 | */ |
18 | - public function onLoadExtensionSchemaUpdates( $updater ) { |
|
19 | - $dir = dirname( __DIR__ ) . '/sql/'; |
|
18 | + public function onLoadExtensionSchemaUpdates($updater) { |
|
19 | + $dir = dirname(__DIR__).'/sql/'; |
|
20 | 20 | |
21 | 21 | $updater->addExtensionTable( |
22 | 22 | 'wbqc_constraints', |
23 | - $dir . "/{$updater->getDB()->getType()}/tables-generated.sql" |
|
23 | + $dir."/{$updater->getDB()->getType()}/tables-generated.sql" |
|
24 | 24 | ); |
25 | 25 | } |
26 | 26 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Checker; |
6 | 6 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | private ConstraintParameterParser $constraintParameterParser; |
24 | 24 | |
25 | - public function __construct( ConstraintParameterParser $constraintParameterParser ) { |
|
25 | + public function __construct(ConstraintParameterParser $constraintParameterParser) { |
|
26 | 26 | $this->constraintParameterParser = $constraintParameterParser; |
27 | 27 | } |
28 | 28 | |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @throws ConstraintParameterException |
66 | 66 | */ |
67 | - public function checkConstraint( Context $context, Constraint $constraint ): CheckResult { |
|
68 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
69 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED ); |
|
67 | + public function checkConstraint(Context $context, Constraint $constraint): CheckResult { |
|
68 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
69 | + return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $constraintParameters = $constraint->getConstraintParameters(); |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | ); |
78 | 78 | |
79 | 79 | $status = CheckResult::STATUS_VIOLATION; |
80 | - $message = ( new ViolationMessage( 'wbqc-violation-message-label-lacking' ) ) |
|
81 | - ->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) |
|
82 | - ->withLanguages( $languages ); |
|
80 | + $message = (new ViolationMessage('wbqc-violation-message-label-lacking')) |
|
81 | + ->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE) |
|
82 | + ->withLanguages($languages); |
|
83 | 83 | |
84 | 84 | /** @var LabelsProvider $entity */ |
85 | 85 | $entity = $context->getEntity(); |
86 | 86 | '@phan-var LabelsProvider $entity'; |
87 | 87 | $labels = $entity->getLabels(); |
88 | 88 | |
89 | - if ( $labels->hasTermForLanguage( 'mul' ) ) { |
|
89 | + if ($labels->hasTermForLanguage('mul')) { |
|
90 | 90 | $message = null; |
91 | 91 | $status = CheckResult::STATUS_COMPLIANCE; |
92 | 92 | } else { |
93 | - foreach ( $languages as $language ) { |
|
94 | - if ( $labels->hasTermForLanguage( $language ) ) { |
|
93 | + foreach ($languages as $language) { |
|
94 | + if ($labels->hasTermForLanguage($language)) { |
|
95 | 95 | $message = null; |
96 | 96 | $status = CheckResult::STATUS_COMPLIANCE; |
97 | 97 | break; |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - return new CheckResult( $context, $constraint, $status, $message ); |
|
102 | + return new CheckResult($context, $constraint, $status, $message); |
|
103 | 103 | } |
104 | 104 | |
105 | - public function checkConstraintParameters( Constraint $constraint ): array { |
|
105 | + public function checkConstraintParameters(Constraint $constraint): array { |
|
106 | 106 | $constraintParameters = $constraint->getConstraintParameters(); |
107 | 107 | $exceptions = []; |
108 | 108 | try { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $constraintParameters, |
111 | 111 | $constraint->getConstraintTypeItemId() |
112 | 112 | ); |
113 | - } catch ( ConstraintParameterException $e ) { |
|
113 | + } catch (ConstraintParameterException $e) { |
|
114 | 114 | $exceptions[] = $e; |
115 | 115 | } |
116 | 116 | return $exceptions; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\Html; |
6 | 6 | |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @throws InvalidArgumentException |
35 | 35 | */ |
36 | - public function __construct( $content, bool $isSortable = false ) { |
|
37 | - Assert::parameterType( [ 'string', HtmlArmor::class ], $content, '$content' ); |
|
36 | + public function __construct($content, bool $isSortable = false) { |
|
37 | + Assert::parameterType(['string', HtmlArmor::class], $content, '$content'); |
|
38 | 38 | |
39 | 39 | $this->content = $content; |
40 | 40 | $this->isSortable = $isSortable; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return string HTML |
45 | 45 | */ |
46 | 46 | public function getContent(): string { |
47 | - return HtmlArmor::getHtml( $this->content ); |
|
47 | + return HtmlArmor::getHtml($this->content); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function getIsSortable(): bool { |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | * @return string HTML |
58 | 58 | */ |
59 | 59 | public function toHtml(): string { |
60 | - $attributes = [ 'role' => 'columnheader button' ]; |
|
60 | + $attributes = ['role' => 'columnheader button']; |
|
61 | 61 | |
62 | - if ( !$this->isSortable ) { |
|
62 | + if (!$this->isSortable) { |
|
63 | 63 | $attributes['class'] = 'unsortable'; |
64 | 64 | } |
65 | 65 | |
66 | - return Html::rawElement( 'th', $attributes, $this->getContent() ); |
|
66 | + return Html::rawElement('th', $attributes, $this->getContent()); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | } |