@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | Config $config, |
140 | 140 | IBufferingStatsdDataFactory $dataFactory |
141 | 141 | ) { |
142 | - parent::__construct( 'ConstraintReport' ); |
|
142 | + parent::__construct('ConstraintReport'); |
|
143 | 143 | |
144 | 144 | $this->entityLookup = $entityLookup; |
145 | 145 | $this->entityTitleLookup = $entityTitleLookup; |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | $language = $this->getLanguage(); |
149 | 149 | |
150 | 150 | $formatterOptions = new FormatterOptions(); |
151 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
151 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
152 | 152 | $this->dataValueFormatter = $valueFormatterFactory->getValueFormatter( |
153 | 153 | SnakFormatter::FORMAT_HTML, |
154 | 154 | $formatterOptions |
155 | 155 | ); |
156 | 156 | |
157 | - $labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup( $language ); |
|
157 | + $labelLookup = $fallbackLabelDescLookupFactory->newLabelDescriptionLookup($language); |
|
158 | 158 | |
159 | 159 | $this->entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( |
160 | 160 | $labelLookup |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * @return array |
183 | 183 | */ |
184 | 184 | private function getModules() { |
185 | - return [ 'SpecialConstraintReportPage' ]; |
|
185 | + return ['SpecialConstraintReportPage']; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @return string |
201 | 201 | */ |
202 | 202 | public function getDescription() { |
203 | - return $this->msg( 'wbqc-constraintreport' )->escaped(); |
|
203 | + return $this->msg('wbqc-constraintreport')->escaped(); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -212,42 +212,42 @@ discard block |
||
212 | 212 | * @throws EntityIdParsingException |
213 | 213 | * @throws UnexpectedValueException |
214 | 214 | */ |
215 | - public function execute( $subPage ) { |
|
215 | + public function execute($subPage) { |
|
216 | 216 | $out = $this->getOutput(); |
217 | 217 | |
218 | - $postRequest = $this->getContext()->getRequest()->getVal( 'entityid' ); |
|
219 | - if ( $postRequest ) { |
|
220 | - $out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() ); |
|
218 | + $postRequest = $this->getContext()->getRequest()->getVal('entityid'); |
|
219 | + if ($postRequest) { |
|
220 | + $out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL()); |
|
221 | 221 | return; |
222 | 222 | } |
223 | 223 | |
224 | - $out->addModules( $this->getModules() ); |
|
224 | + $out->addModules($this->getModules()); |
|
225 | 225 | |
226 | 226 | $this->setHeaders(); |
227 | 227 | |
228 | - $out->addHTML( $this->getExplanationText() ); |
|
228 | + $out->addHTML($this->getExplanationText()); |
|
229 | 229 | $this->buildEntityIdForm(); |
230 | 230 | |
231 | - if ( !$subPage ) { |
|
231 | + if (!$subPage) { |
|
232 | 232 | return; |
233 | 233 | } |
234 | 234 | |
235 | - if ( !is_string( $subPage ) ) { |
|
236 | - throw new InvalidArgumentException( '$subPage must be string.' ); |
|
235 | + if (!is_string($subPage)) { |
|
236 | + throw new InvalidArgumentException('$subPage must be string.'); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | try { |
240 | - $entityId = $this->entityIdParser->parse( $subPage ); |
|
241 | - } catch ( EntityIdParsingException $e ) { |
|
240 | + $entityId = $this->entityIdParser->parse($subPage); |
|
241 | + } catch (EntityIdParsingException $e) { |
|
242 | 242 | $out->addHTML( |
243 | - $this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true ) |
|
243 | + $this->buildNotice('wbqc-constraintreport-invalid-entity-id', true) |
|
244 | 244 | ); |
245 | 245 | return; |
246 | 246 | } |
247 | 247 | |
248 | - if ( !$this->entityLookup->hasEntity( $entityId ) ) { |
|
248 | + if (!$this->entityLookup->hasEntity($entityId)) { |
|
249 | 249 | $out->addHTML( |
250 | - $this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true ) |
|
250 | + $this->buildNotice('wbqc-constraintreport-not-existent-entity', true) |
|
251 | 251 | ); |
252 | 252 | return; |
253 | 253 | } |
@@ -255,18 +255,18 @@ discard block |
||
255 | 255 | $this->dataFactory->increment( |
256 | 256 | 'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck' |
257 | 257 | ); |
258 | - $results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId ); |
|
258 | + $results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId); |
|
259 | 259 | |
260 | - if ( count( $results ) > 0 ) { |
|
260 | + if (count($results) > 0) { |
|
261 | 261 | $out->addHTML( |
262 | - $this->buildResultHeader( $entityId ) |
|
263 | - . $this->buildSummary( $results ) |
|
264 | - . $this->buildResultTable( $entityId, $results ) |
|
262 | + $this->buildResultHeader($entityId) |
|
263 | + . $this->buildSummary($results) |
|
264 | + . $this->buildResultTable($entityId, $results) |
|
265 | 265 | ); |
266 | 266 | } else { |
267 | 267 | $out->addHTML( |
268 | - $this->buildResultHeader( $entityId ) |
|
269 | - . $this->buildNotice( 'wbqc-constraintreport-empty-result' ) |
|
268 | + $this->buildResultHeader($entityId) |
|
269 | + . $this->buildNotice('wbqc-constraintreport-empty-result') |
|
270 | 270 | ); |
271 | 271 | } |
272 | 272 | } |
@@ -282,15 +282,15 @@ discard block |
||
282 | 282 | 'name' => 'entityid', |
283 | 283 | 'label-message' => 'wbqc-constraintreport-form-entityid-label', |
284 | 284 | 'cssclass' => 'wbqc-constraintreport-form-entity-id', |
285 | - 'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped() |
|
285 | + 'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped() |
|
286 | 286 | ] |
287 | 287 | ]; |
288 | - $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' ); |
|
289 | - $htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() ); |
|
290 | - $htmlForm->setSubmitCallback( function() { |
|
288 | + $htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form'); |
|
289 | + $htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped()); |
|
290 | + $htmlForm->setSubmitCallback(function() { |
|
291 | 291 | return false; |
292 | 292 | } ); |
293 | - $htmlForm->setMethod( 'post' ); |
|
293 | + $htmlForm->setMethod('post'); |
|
294 | 294 | $htmlForm->show(); |
295 | 295 | } |
296 | 296 | |
@@ -304,16 +304,16 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @return string HTML |
306 | 306 | */ |
307 | - private function buildNotice( $messageKey, $error = false ) { |
|
308 | - if ( !is_string( $messageKey ) ) { |
|
309 | - throw new InvalidArgumentException( '$message must be string.' ); |
|
307 | + private function buildNotice($messageKey, $error = false) { |
|
308 | + if (!is_string($messageKey)) { |
|
309 | + throw new InvalidArgumentException('$message must be string.'); |
|
310 | 310 | } |
311 | - if ( !is_bool( $error ) ) { |
|
312 | - throw new InvalidArgumentException( '$error must be bool.' ); |
|
311 | + if (!is_bool($error)) { |
|
312 | + throw new InvalidArgumentException('$error must be bool.'); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | $cssClasses = 'wbqc-constraintreport-notice'; |
316 | - if ( $error ) { |
|
316 | + if ($error) { |
|
317 | 317 | $cssClasses .= ' wbqc-constraintreport-notice-error'; |
318 | 318 | } |
319 | 319 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | [ |
323 | 323 | 'class' => $cssClasses |
324 | 324 | ], |
325 | - $this->msg( $messageKey )->escaped() |
|
325 | + $this->msg($messageKey)->escaped() |
|
326 | 326 | ); |
327 | 327 | } |
328 | 328 | |
@@ -332,16 +332,16 @@ discard block |
||
332 | 332 | private function getExplanationText() { |
333 | 333 | return Html::rawElement( |
334 | 334 | 'div', |
335 | - [ 'class' => 'wbqc-explanation' ], |
|
335 | + ['class' => 'wbqc-explanation'], |
|
336 | 336 | Html::rawElement( |
337 | 337 | 'p', |
338 | 338 | [], |
339 | - $this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped() |
|
339 | + $this->msg('wbqc-constraintreport-explanation-part-one')->escaped() |
|
340 | 340 | ) |
341 | 341 | . Html::rawElement( |
342 | 342 | 'p', |
343 | 343 | [], |
344 | - $this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped() |
|
344 | + $this->msg('wbqc-constraintreport-explanation-part-two')->escaped() |
|
345 | 345 | ) |
346 | 346 | ); |
347 | 347 | } |
@@ -352,69 +352,69 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @return string HTML |
354 | 354 | */ |
355 | - private function buildResultTable( EntityId $entityId, array $results ) { |
|
355 | + private function buildResultTable(EntityId $entityId, array $results) { |
|
356 | 356 | // Set table headers |
357 | 357 | $table = new HtmlTableBuilder( |
358 | 358 | [ |
359 | 359 | new HtmlTableHeaderBuilder( |
360 | - $this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(), |
|
360 | + $this->msg('wbqc-constraintreport-result-table-header-status')->escaped(), |
|
361 | 361 | true |
362 | 362 | ), |
363 | 363 | new HtmlTableHeaderBuilder( |
364 | - $this->msg( 'wbqc-constraintreport-result-table-header-claim' )->escaped(), |
|
364 | + $this->msg('wbqc-constraintreport-result-table-header-claim')->escaped(), |
|
365 | 365 | true |
366 | 366 | ), |
367 | 367 | new HtmlTableHeaderBuilder( |
368 | - $this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(), |
|
368 | + $this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(), |
|
369 | 369 | true |
370 | 370 | ) |
371 | 371 | ] |
372 | 372 | ); |
373 | 373 | |
374 | - foreach ( $results as $result ) { |
|
375 | - $table = $this->appendToResultTable( $table, $entityId, $result ); |
|
374 | + foreach ($results as $result) { |
|
375 | + $table = $this->appendToResultTable($table, $entityId, $result); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | return $table->toHtml(); |
379 | 379 | } |
380 | 380 | |
381 | - private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) { |
|
381 | + private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) { |
|
382 | 382 | // Status column |
383 | 383 | $statusColumn = $this->buildTooltipElement( |
384 | - $this->formatStatus( $result->getStatus() ), |
|
384 | + $this->formatStatus($result->getStatus()), |
|
385 | 385 | $result->getMessage(), |
386 | 386 | '[?]' |
387 | 387 | ); |
388 | 388 | |
389 | 389 | // Claim column |
390 | - $property = $this->entityIdLabelFormatter->formatEntityId( $result->getContext()->getSnak()->getPropertyId() ); |
|
391 | - if ( $result->getSnakType() === 'value' ) { |
|
392 | - $value = $this->constraintParameterRenderer->formatValue( $result->getDataValue() ); |
|
390 | + $property = $this->entityIdLabelFormatter->formatEntityId($result->getContext()->getSnak()->getPropertyId()); |
|
391 | + if ($result->getSnakType() === 'value') { |
|
392 | + $value = $this->constraintParameterRenderer->formatValue($result->getDataValue()); |
|
393 | 393 | } else { |
394 | - $value = htmlspecialchars( $result->getSnakType() ); |
|
394 | + $value = htmlspecialchars($result->getSnakType()); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | $claimColumn = $this->getClaimLink( |
398 | 398 | $entityId, |
399 | 399 | $result->getContext()->getSnak()->getPropertyId(), |
400 | - $property . ': ' . $value |
|
400 | + $property.': '.$value |
|
401 | 401 | ); |
402 | 402 | |
403 | 403 | // Constraint column |
404 | 404 | $constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId(); |
405 | 405 | try { |
406 | - $constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) ); |
|
407 | - } catch ( InvalidArgumentException $e ) { |
|
408 | - $constraintTypeLabel = htmlspecialchars( $constraintTypeItemId ); |
|
406 | + $constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId)); |
|
407 | + } catch (InvalidArgumentException $e) { |
|
408 | + $constraintTypeLabel = htmlspecialchars($constraintTypeItemId); |
|
409 | 409 | } |
410 | 410 | $constraintLink = $this->getClaimLink( |
411 | 411 | $result->getContext()->getSnak()->getPropertyId(), |
412 | - new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ), |
|
412 | + new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')), |
|
413 | 413 | $constraintTypeLabel |
414 | 414 | ); |
415 | 415 | $constraintColumn = $this->buildExpandableElement( |
416 | 416 | $constraintLink, |
417 | - $this->constraintParameterRenderer->formatParameters( $result->getParameters() ), |
|
417 | + $this->constraintParameterRenderer->formatParameters($result->getParameters()), |
|
418 | 418 | '[...]' |
419 | 419 | ); |
420 | 420 | |
@@ -449,15 +449,15 @@ discard block |
||
449 | 449 | * |
450 | 450 | * @return string HTML |
451 | 451 | */ |
452 | - protected function buildResultHeader( EntityId $entityId ) { |
|
453 | - $entityLink = sprintf( '%s (%s)', |
|
454 | - $this->entityIdLinkFormatter->formatEntityId( $entityId ), |
|
455 | - htmlspecialchars( $entityId->getSerialization() ) ); |
|
452 | + protected function buildResultHeader(EntityId $entityId) { |
|
453 | + $entityLink = sprintf('%s (%s)', |
|
454 | + $this->entityIdLinkFormatter->formatEntityId($entityId), |
|
455 | + htmlspecialchars($entityId->getSerialization())); |
|
456 | 456 | |
457 | 457 | return Html::rawElement( |
458 | 458 | 'h3', |
459 | 459 | [], |
460 | - sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink ) |
|
460 | + sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink) |
|
461 | 461 | ); |
462 | 462 | } |
463 | 463 | |
@@ -468,24 +468,24 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @return string HTML |
470 | 470 | */ |
471 | - protected function buildSummary( array $results ) { |
|
471 | + protected function buildSummary(array $results) { |
|
472 | 472 | $statuses = []; |
473 | - foreach ( $results as $result ) { |
|
474 | - $status = strtolower( $result->getStatus() ); |
|
475 | - $statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1; |
|
473 | + foreach ($results as $result) { |
|
474 | + $status = strtolower($result->getStatus()); |
|
475 | + $statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1; |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | $statusElements = []; |
479 | - foreach ( $statuses as $status => $count ) { |
|
480 | - if ( $count > 0 ) { |
|
479 | + foreach ($statuses as $status => $count) { |
|
480 | + if ($count > 0) { |
|
481 | 481 | $statusElements[] = |
482 | - $this->formatStatus( $status ) |
|
482 | + $this->formatStatus($status) |
|
483 | 483 | . ': ' |
484 | 484 | . $count; |
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
488 | - return Html::rawElement( 'p', [], implode( ', ', $statusElements ) ); |
|
488 | + return Html::rawElement('p', [], implode(', ', $statusElements)); |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | /** |
@@ -500,15 +500,15 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @return string HTML |
502 | 502 | */ |
503 | - protected function buildTooltipElement( $content, $tooltipContent, $indicator ) { |
|
504 | - if ( !is_string( $content ) ) { |
|
505 | - throw new InvalidArgumentException( '$content has to be string.' ); |
|
503 | + protected function buildTooltipElement($content, $tooltipContent, $indicator) { |
|
504 | + if (!is_string($content)) { |
|
505 | + throw new InvalidArgumentException('$content has to be string.'); |
|
506 | 506 | } |
507 | - if ( $tooltipContent && ( !is_string( $tooltipContent ) ) ) { |
|
508 | - throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' ); |
|
507 | + if ($tooltipContent && (!is_string($tooltipContent))) { |
|
508 | + throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.'); |
|
509 | 509 | } |
510 | 510 | |
511 | - if ( empty( $tooltipContent ) ) { |
|
511 | + if (empty($tooltipContent)) { |
|
512 | 512 | return $content; |
513 | 513 | } |
514 | 514 | |
@@ -525,13 +525,13 @@ discard block |
||
525 | 525 | [ |
526 | 526 | 'class' => 'wbqc-indicator' |
527 | 527 | ], |
528 | - htmlspecialchars( $indicator ) . $tooltip |
|
528 | + htmlspecialchars($indicator).$tooltip |
|
529 | 529 | ); |
530 | 530 | |
531 | 531 | return Html::rawElement( |
532 | 532 | 'span', |
533 | 533 | [], |
534 | - sprintf( '%s %s', $content, $tooltipIndicator ) |
|
534 | + sprintf('%s %s', $content, $tooltipIndicator) |
|
535 | 535 | ); |
536 | 536 | } |
537 | 537 | |
@@ -547,15 +547,15 @@ discard block |
||
547 | 547 | * |
548 | 548 | * @return string HTML |
549 | 549 | */ |
550 | - protected function buildExpandableElement( $content, $expandableContent, $indicator ) { |
|
551 | - if ( !is_string( $content ) ) { |
|
552 | - throw new InvalidArgumentException( '$content has to be string.' ); |
|
550 | + protected function buildExpandableElement($content, $expandableContent, $indicator) { |
|
551 | + if (!is_string($content)) { |
|
552 | + throw new InvalidArgumentException('$content has to be string.'); |
|
553 | 553 | } |
554 | - if ( $expandableContent && ( !is_string( $expandableContent ) ) ) { |
|
555 | - throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' ); |
|
554 | + if ($expandableContent && (!is_string($expandableContent))) { |
|
555 | + throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.'); |
|
556 | 556 | } |
557 | 557 | |
558 | - if ( empty( $expandableContent ) ) { |
|
558 | + if (empty($expandableContent)) { |
|
559 | 559 | return $content; |
560 | 560 | } |
561 | 561 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | ); |
577 | 577 | |
578 | 578 | return |
579 | - sprintf( '%s %s %s', $content, $tooltipIndicator, $expandableContent ); |
|
579 | + sprintf('%s %s %s', $content, $tooltipIndicator, $expandableContent); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -588,16 +588,16 @@ discard block |
||
588 | 588 | * |
589 | 589 | * @return string HTML |
590 | 590 | */ |
591 | - private function formatStatus( $status ) { |
|
592 | - $messageName = "wbqc-constraintreport-status-" . strtolower( $status ); |
|
591 | + private function formatStatus($status) { |
|
592 | + $messageName = "wbqc-constraintreport-status-".strtolower($status); |
|
593 | 593 | |
594 | 594 | $formattedStatus = |
595 | 595 | Html::element( |
596 | 596 | 'span', |
597 | 597 | [ |
598 | - 'class' => 'wbqc-status wbqc-status-' . $status |
|
598 | + 'class' => 'wbqc-status wbqc-status-'.$status |
|
599 | 599 | ], |
600 | - $this->msg( $messageName )->text() |
|
600 | + $this->msg($messageName)->text() |
|
601 | 601 | ); |
602 | 602 | |
603 | 603 | return $formattedStatus; |
@@ -613,26 +613,26 @@ discard block |
||
613 | 613 | * |
614 | 614 | * @return string HTML |
615 | 615 | */ |
616 | - protected function formatDataValues( $dataValues, $separator = ', ' ) { |
|
617 | - if ( $dataValues instanceof DataValue ) { |
|
618 | - $dataValues = [ $dataValues ]; |
|
619 | - } elseif ( !is_array( $dataValues ) ) { |
|
620 | - throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' ); |
|
616 | + protected function formatDataValues($dataValues, $separator = ', ') { |
|
617 | + if ($dataValues instanceof DataValue) { |
|
618 | + $dataValues = [$dataValues]; |
|
619 | + } elseif (!is_array($dataValues)) { |
|
620 | + throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.'); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | $formattedDataValues = []; |
624 | - foreach ( $dataValues as $dataValue ) { |
|
625 | - if ( !( $dataValue instanceof DataValue ) ) { |
|
626 | - throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' ); |
|
624 | + foreach ($dataValues as $dataValue) { |
|
625 | + if (!($dataValue instanceof DataValue)) { |
|
626 | + throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.'); |
|
627 | 627 | } |
628 | - if ( $dataValue instanceof EntityIdValue ) { |
|
629 | - $formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() ); |
|
628 | + if ($dataValue instanceof EntityIdValue) { |
|
629 | + $formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId()); |
|
630 | 630 | } else { |
631 | - $formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue ); |
|
631 | + $formattedDataValues[] = $this->dataValueFormatter->format($dataValue); |
|
632 | 632 | } |
633 | 633 | } |
634 | 634 | |
635 | - return implode( $separator, $formattedDataValues ); |
|
635 | + return implode($separator, $formattedDataValues); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -644,12 +644,12 @@ discard block |
||
644 | 644 | * |
645 | 645 | * @return string HTML |
646 | 646 | */ |
647 | - private function getClaimLink( EntityId $entityId, PropertyId $propertyId, $text ) { |
|
647 | + private function getClaimLink(EntityId $entityId, PropertyId $propertyId, $text) { |
|
648 | 648 | return |
649 | 649 | Html::rawElement( |
650 | 650 | 'a', |
651 | 651 | [ |
652 | - 'href' => $this->getClaimUrl( $entityId, $propertyId ), |
|
652 | + 'href' => $this->getClaimUrl($entityId, $propertyId), |
|
653 | 653 | 'target' => '_blank' |
654 | 654 | ], |
655 | 655 | $text |
@@ -664,9 +664,9 @@ discard block |
||
664 | 664 | * |
665 | 665 | * @return string |
666 | 666 | */ |
667 | - private function getClaimUrl( EntityId $entityId, PropertyId $propertyId ) { |
|
668 | - $title = $this->entityTitleLookup->getTitleForId( $entityId ); |
|
669 | - $entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() ); |
|
667 | + private function getClaimUrl(EntityId $entityId, PropertyId $propertyId) { |
|
668 | + $title = $this->entityTitleLookup->getTitleForId($entityId); |
|
669 | + $entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization()); |
|
670 | 670 | |
671 | 671 | return $entityUrl; |
672 | 672 | } |
@@ -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 | } |
@@ -35,16 +35,16 @@ |
||
35 | 35 | ]; |
36 | 36 | } |
37 | 37 | |
38 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
39 | - if ( $context->getType() === Context::TYPE_STATEMENT ) { |
|
40 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE, '' ); |
|
38 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
39 | + if ($context->getType() === Context::TYPE_STATEMENT) { |
|
40 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE, ''); |
|
41 | 41 | } else { |
42 | - $message = wfMessage( 'wbqc-violation-message-valueOnly' )->escaped(); |
|
43 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message ); |
|
42 | + $message = wfMessage('wbqc-violation-message-valueOnly')->escaped(); |
|
43 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
47 | + public function checkConstraintParameters(Constraint $constraint) { |
|
48 | 48 | // no parameters |
49 | 49 | return []; |
50 | 50 | } |
@@ -35,16 +35,16 @@ |
||
35 | 35 | ]; |
36 | 36 | } |
37 | 37 | |
38 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
39 | - if ( $context->getType() === Context::TYPE_REFERENCE ) { |
|
40 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE, '' ); |
|
38 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
39 | + if ($context->getType() === Context::TYPE_REFERENCE) { |
|
40 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE, ''); |
|
41 | 41 | } else { |
42 | - $message = wfMessage( 'wbqc-violation-message-reference' )->escaped(); |
|
43 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message ); |
|
42 | + $message = wfMessage('wbqc-violation-message-reference')->escaped(); |
|
43 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message); |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
47 | + public function checkConstraintParameters(Constraint $constraint) { |
|
48 | 48 | // no parameters |
49 | 49 | return []; |
50 | 50 | } |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return CheckResult |
86 | 86 | */ |
87 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
88 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
89 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
87 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
88 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
89 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | $parameters = []; |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | $snak = $context->getSnak(); |
95 | 95 | $propertyId = $context->getSnak()->getPropertyId(); |
96 | 96 | |
97 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
97 | + if (!$snak instanceof PropertyValueSnak) { |
|
98 | 98 | // nothing to check |
99 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' ); |
|
99 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, ''); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $dataValue = $snak->getDataValue(); |
@@ -105,22 +105,22 @@ discard block |
||
105 | 105 | * error handling: |
106 | 106 | * type of $dataValue for properties with 'Symmetric' constraint has to be 'wikibase-entityid' |
107 | 107 | */ |
108 | - if ( $dataValue->getType() !== 'wikibase-entityid' ) { |
|
109 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
108 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
109 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
110 | 110 | ->rawParams( |
111 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
111 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
112 | 112 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
113 | 113 | ) |
114 | 114 | ->escaped(); |
115 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
115 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
116 | 116 | } |
117 | 117 | /** @var EntityIdValue $dataValue */ |
118 | 118 | |
119 | 119 | $targetEntityId = $dataValue->getEntityId(); |
120 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
121 | - if ( $targetEntity === null ) { |
|
122 | - $message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped(); |
|
123 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
120 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
121 | + if ($targetEntity === null) { |
|
122 | + $message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped(); |
|
123 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | $symmetricStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue( |
@@ -128,26 +128,26 @@ discard block |
||
128 | 128 | $propertyId, |
129 | 129 | $context->getEntity()->getId() |
130 | 130 | ); |
131 | - if ( $symmetricStatement !== null ) { |
|
131 | + if ($symmetricStatement !== null) { |
|
132 | 132 | $message = ''; |
133 | 133 | $status = CheckResult::STATUS_COMPLIANCE; |
134 | 134 | } else { |
135 | - $message = wfMessage( 'wbqc-violation-message-symmetric' ) |
|
135 | + $message = wfMessage('wbqc-violation-message-symmetric') |
|
136 | 136 | ->rawParams( |
137 | - $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ), |
|
138 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ), |
|
139 | - $this->constraintParameterRenderer->formatEntityId( $context->getEntity()->getId(), Role::OBJECT ) |
|
137 | + $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT), |
|
138 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE), |
|
139 | + $this->constraintParameterRenderer->formatEntityId($context->getEntity()->getId(), Role::OBJECT) |
|
140 | 140 | ) |
141 | 141 | ->escaped(); |
142 | 142 | $status = CheckResult::STATUS_VIOLATION; |
143 | 143 | } |
144 | 144 | |
145 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
146 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
147 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
145 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
146 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
147 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
148 | 148 | } |
149 | 149 | |
150 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
150 | + public function checkConstraintParameters(Constraint $constraint) { |
|
151 | 151 | // no parameters |
152 | 152 | return []; |
153 | 153 | } |
@@ -70,43 +70,43 @@ discard block |
||
70 | 70 | * @throws ConstraintParameterException |
71 | 71 | * @return CheckResult |
72 | 72 | */ |
73 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
74 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
75 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
73 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
74 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
75 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $parameters = []; |
79 | 79 | $constraintParameters = $constraint->getConstraintParameters(); |
80 | 80 | |
81 | - $properties = $this->constraintParameterParser->parsePropertiesParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
81 | + $properties = $this->constraintParameterParser->parsePropertiesParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
82 | 82 | $parameters['property'] = $properties; |
83 | 83 | |
84 | 84 | $message = ''; |
85 | 85 | $status = CheckResult::STATUS_COMPLIANCE; |
86 | 86 | |
87 | 87 | /** @var Snak $qualifier */ |
88 | - foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) { |
|
88 | + foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) { |
|
89 | 89 | $allowedQualifier = false; |
90 | - foreach ( $properties as $property ) { |
|
91 | - if ( $qualifier->getPropertyId()->equals( $property ) ) { |
|
90 | + foreach ($properties as $property) { |
|
91 | + if ($qualifier->getPropertyId()->equals($property)) { |
|
92 | 92 | $allowedQualifier = true; |
93 | 93 | break; |
94 | 94 | } |
95 | 95 | } |
96 | - if ( !$allowedQualifier ) { |
|
97 | - if ( empty( $properties ) || $properties === [ '' ] ) { |
|
98 | - $message = wfMessage( 'wbqc-violation-message-no-qualifiers' ); |
|
96 | + if (!$allowedQualifier) { |
|
97 | + if (empty($properties) || $properties === ['']) { |
|
98 | + $message = wfMessage('wbqc-violation-message-no-qualifiers'); |
|
99 | 99 | $message->rawParams( |
100 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ) |
|
100 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY) |
|
101 | 101 | ); |
102 | 102 | } else { |
103 | - $message = wfMessage( "wbqc-violation-message-qualifiers" ); |
|
103 | + $message = wfMessage("wbqc-violation-message-qualifiers"); |
|
104 | 104 | $message->rawParams( |
105 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
106 | - $this->constraintParameterRenderer->formatEntityId( $qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE ) |
|
105 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
106 | + $this->constraintParameterRenderer->formatEntityId($qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE) |
|
107 | 107 | ); |
108 | - $message->numParams( count( $properties ) ); |
|
109 | - $message->rawParams( $this->constraintParameterRenderer->formatPropertyIdList( $properties, Role::QUALIFIER_PREDICATE ) ); |
|
108 | + $message->numParams(count($properties)); |
|
109 | + $message->rawParams($this->constraintParameterRenderer->formatPropertyIdList($properties, Role::QUALIFIER_PREDICATE)); |
|
110 | 110 | } |
111 | 111 | $message = $message->escaped(); |
112 | 112 | $status = CheckResult::STATUS_VIOLATION; |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
117 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
118 | 118 | } |
119 | 119 | |
120 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
120 | + public function checkConstraintParameters(Constraint $constraint) { |
|
121 | 121 | $constraintParameters = $constraint->getConstraintParameters(); |
122 | 122 | $exceptions = []; |
123 | 123 | try { |
124 | - $this->constraintParameterParser->parsePropertiesParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
125 | - } catch ( ConstraintParameterException $e ) { |
|
124 | + $this->constraintParameterParser->parsePropertiesParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
125 | + } catch (ConstraintParameterException $e) { |
|
126 | 126 | $exceptions[] = $e; |
127 | 127 | } |
128 | 128 | return $exceptions; |
@@ -92,18 +92,18 @@ discard block |
||
92 | 92 | * @throws ConstraintParameterException |
93 | 93 | * @return CheckResult |
94 | 94 | */ |
95 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
96 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
97 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
95 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
96 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
97 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $parameters = []; |
101 | 101 | $constraintParameters = $constraint->getConstraintParameters(); |
102 | 102 | |
103 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
104 | - $parameters['property'] = [ $propertyId ]; |
|
103 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
104 | + $parameters['property'] = [$propertyId]; |
|
105 | 105 | |
106 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
106 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
107 | 107 | $parameters['items'] = $items; |
108 | 108 | |
109 | 109 | /* |
@@ -111,16 +111,16 @@ discard block |
||
111 | 111 | * a) a property only |
112 | 112 | * b) a property and a number of items (each combination of property and item forming an individual claim) |
113 | 113 | */ |
114 | - if ( $items === [] ) { |
|
114 | + if ($items === []) { |
|
115 | 115 | $offendingStatement = $this->connectionCheckerHelper->findStatementWithProperty( |
116 | 116 | $context->getEntity()->getStatements(), |
117 | 117 | $propertyId |
118 | 118 | ); |
119 | - if ( $offendingStatement !== null ) { |
|
120 | - $message = wfMessage( "wbqc-violation-message-conflicts-with-property" ) |
|
119 | + if ($offendingStatement !== null) { |
|
120 | + $message = wfMessage("wbqc-violation-message-conflicts-with-property") |
|
121 | 121 | ->rawParams( |
122 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
123 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ) |
|
122 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
123 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE) |
|
124 | 124 | ) |
125 | 125 | ->escaped(); |
126 | 126 | $status = CheckResult::STATUS_VIOLATION; |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | $propertyId, |
135 | 135 | $items |
136 | 136 | ); |
137 | - if ( $offendingStatement !== null ) { |
|
138 | - $offendingValue = ItemIdSnakValue::fromSnak( $offendingStatement->getMainSnak() ); |
|
139 | - $message = wfMessage( "wbqc-violation-message-conflicts-with-claim" ) |
|
137 | + if ($offendingStatement !== null) { |
|
138 | + $offendingValue = ItemIdSnakValue::fromSnak($offendingStatement->getMainSnak()); |
|
139 | + $message = wfMessage("wbqc-violation-message-conflicts-with-claim") |
|
140 | 140 | ->rawParams( |
141 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
142 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ), |
|
143 | - $this->constraintParameterRenderer->formatItemIdSnakValue( $offendingValue, Role::OBJECT ) |
|
141 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
142 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE), |
|
143 | + $this->constraintParameterRenderer->formatItemIdSnakValue($offendingValue, Role::OBJECT) |
|
144 | 144 | ) |
145 | 145 | ->escaped(); |
146 | 146 | $status = CheckResult::STATUS_VIOLATION; |
@@ -150,20 +150,20 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
153 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
154 | 154 | } |
155 | 155 | |
156 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
156 | + public function checkConstraintParameters(Constraint $constraint) { |
|
157 | 157 | $constraintParameters = $constraint->getConstraintParameters(); |
158 | 158 | $exceptions = []; |
159 | 159 | try { |
160 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
161 | - } catch ( ConstraintParameterException $e ) { |
|
160 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
161 | + } catch (ConstraintParameterException $e) { |
|
162 | 162 | $exceptions[] = $e; |
163 | 163 | } |
164 | 164 | try { |
165 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
166 | - } catch ( ConstraintParameterException $e ) { |
|
165 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
166 | + } catch (ConstraintParameterException $e) { |
|
167 | 167 | $exceptions[] = $e; |
168 | 168 | } |
169 | 169 | return $exceptions; |
@@ -91,18 +91,18 @@ discard block |
||
91 | 91 | * @throws ConstraintParameterException |
92 | 92 | * @return CheckResult |
93 | 93 | */ |
94 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
95 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
96 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
94 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
95 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
96 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | $parameters = []; |
100 | 100 | $constraintParameters = $constraint->getConstraintParameters(); |
101 | 101 | |
102 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
103 | - $parameters['property'] = [ $propertyId ]; |
|
102 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
103 | + $parameters['property'] = [$propertyId]; |
|
104 | 104 | |
105 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
105 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
106 | 106 | $parameters['items'] = $items; |
107 | 107 | |
108 | 108 | /* |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * a) a property only |
111 | 111 | * b) a property and a number of items (each combination of property and item forming an individual claim) |
112 | 112 | */ |
113 | - if ( $items === [] ) { |
|
113 | + if ($items === []) { |
|
114 | 114 | $requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty( |
115 | 115 | $context->getEntity()->getStatements(), |
116 | 116 | $propertyId |
@@ -123,35 +123,35 @@ discard block |
||
123 | 123 | ); |
124 | 124 | } |
125 | 125 | |
126 | - if ( $requiredStatement !== null ) { |
|
126 | + if ($requiredStatement !== null) { |
|
127 | 127 | $status = CheckResult::STATUS_COMPLIANCE; |
128 | 128 | $message = ''; |
129 | 129 | } else { |
130 | 130 | $status = CheckResult::STATUS_VIOLATION; |
131 | - $message = wfMessage( 'wbqc-violation-message-item' ); |
|
131 | + $message = wfMessage('wbqc-violation-message-item'); |
|
132 | 132 | $message->rawParams( |
133 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
134 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ) |
|
133 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
134 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE) |
|
135 | 135 | ); |
136 | - $message->numParams( count( $items ) ); |
|
137 | - $message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) ); |
|
136 | + $message->numParams(count($items)); |
|
137 | + $message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT)); |
|
138 | 138 | $message = $message->escaped(); |
139 | 139 | } |
140 | 140 | |
141 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
141 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
142 | 142 | } |
143 | 143 | |
144 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
144 | + public function checkConstraintParameters(Constraint $constraint) { |
|
145 | 145 | $constraintParameters = $constraint->getConstraintParameters(); |
146 | 146 | $exceptions = []; |
147 | 147 | try { |
148 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
149 | - } catch ( ConstraintParameterException $e ) { |
|
148 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
149 | + } catch (ConstraintParameterException $e) { |
|
150 | 150 | $exceptions[] = $e; |
151 | 151 | } |
152 | 152 | try { |
153 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
154 | - } catch ( ConstraintParameterException $e ) { |
|
153 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
154 | + } catch (ConstraintParameterException $e) { |
|
155 | 155 | $exceptions[] = $e; |
156 | 156 | } |
157 | 157 | return $exceptions; |
@@ -95,22 +95,22 @@ discard block |
||
95 | 95 | * @throws ConstraintParameterException |
96 | 96 | * @return CheckResult |
97 | 97 | */ |
98 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
99 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
100 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
98 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
99 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
100 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | $parameters = []; |
104 | 104 | $constraintParameters = $constraint->getConstraintParameters(); |
105 | 105 | |
106 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
107 | - $parameters['property'] = [ $propertyId ]; |
|
106 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
107 | + $parameters['property'] = [$propertyId]; |
|
108 | 108 | |
109 | 109 | $snak = $context->getSnak(); |
110 | 110 | |
111 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
111 | + if (!$snak instanceof PropertyValueSnak) { |
|
112 | 112 | // nothing to check |
113 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' ); |
|
113 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, ''); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | $dataValue = $snak->getDataValue(); |
@@ -119,22 +119,22 @@ discard block |
||
119 | 119 | * error handling: |
120 | 120 | * type of $dataValue for properties with 'Inverse' constraint has to be 'wikibase-entityid' |
121 | 121 | */ |
122 | - if ( $dataValue->getType() !== 'wikibase-entityid' ) { |
|
123 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
122 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
123 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
124 | 124 | ->rawParams( |
125 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
125 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
126 | 126 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
127 | 127 | ) |
128 | 128 | ->escaped(); |
129 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
129 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
130 | 130 | } |
131 | 131 | /** @var EntityIdValue $dataValue */ |
132 | 132 | |
133 | 133 | $targetEntityId = $dataValue->getEntityId(); |
134 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
135 | - if ( $targetEntity === null ) { |
|
136 | - $message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped(); |
|
137 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
134 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
135 | + if ($targetEntity === null) { |
|
136 | + $message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped(); |
|
137 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $inverseStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue( |
@@ -142,31 +142,31 @@ discard block |
||
142 | 142 | $propertyId, |
143 | 143 | $context->getEntity()->getId() |
144 | 144 | ); |
145 | - if ( $inverseStatement !== null ) { |
|
145 | + if ($inverseStatement !== null) { |
|
146 | 146 | $message = ''; |
147 | 147 | $status = CheckResult::STATUS_COMPLIANCE; |
148 | 148 | } else { |
149 | - $message = wfMessage( 'wbqc-violation-message-inverse' ) |
|
149 | + $message = wfMessage('wbqc-violation-message-inverse') |
|
150 | 150 | ->rawParams( |
151 | - $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ), |
|
152 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ), |
|
153 | - $this->constraintParameterRenderer->formatEntityId( $context->getEntity()->getId(), Role::OBJECT ) |
|
151 | + $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT), |
|
152 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE), |
|
153 | + $this->constraintParameterRenderer->formatEntityId($context->getEntity()->getId(), Role::OBJECT) |
|
154 | 154 | ) |
155 | 155 | ->escaped(); |
156 | 156 | $status = CheckResult::STATUS_VIOLATION; |
157 | 157 | } |
158 | 158 | |
159 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
160 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
161 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
159 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
160 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
161 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
162 | 162 | } |
163 | 163 | |
164 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
164 | + public function checkConstraintParameters(Constraint $constraint) { |
|
165 | 165 | $constraintParameters = $constraint->getConstraintParameters(); |
166 | 166 | $exceptions = []; |
167 | 167 | try { |
168 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
169 | - } catch ( ConstraintParameterException $e ) { |
|
168 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
169 | + } catch (ConstraintParameterException $e) { |
|
170 | 170 | $exceptions[] = $e; |
171 | 171 | } |
172 | 172 | return $exceptions; |