Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/229642

Change subject: Improve type hints in EvaluateConstraintReportJobService
......................................................................

Improve type hints in EvaluateConstraintReportJobService

Change-Id: I883c0882745cd628d4ce7eaf647c8d78b261ab29
---
M includes/EvaluateConstraintReportJobService.php
1 file changed, 12 insertions(+), 10 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/42/229642/1

diff --git a/includes/EvaluateConstraintReportJobService.php 
b/includes/EvaluateConstraintReportJobService.php
index 8857ade..4f6106e 100644
--- a/includes/EvaluateConstraintReportJobService.php
+++ b/includes/EvaluateConstraintReportJobService.php
@@ -7,7 +7,6 @@
 use Wikibase\Repo\WikibaseRepo;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 
-
 /**
  * Class EvaluateConstraintReportJobService
  *
@@ -45,16 +44,17 @@
        }
 
        /**
-        * @param $results
+        * @param CheckResult[] $results
         *
         * @return string
         */
-       public function buildResultSummary( $results ) {
+       public function buildResultSummary( array $results ) {
                $summary = array();
 
                foreach ( $results as $result ) {
                        $constraintName = $result->getConstraintName();
                        $status = $result->getStatus();
+
                        if( !array_key_exists( $constraintName, $summary ) ) {
                                $summary[$constraintName] = array(
                                        CheckResult::STATUS_COMPLIANCE => 0,
@@ -63,6 +63,7 @@
                                        CheckResult::STATUS_TODO => 0
                                );
                        }
+
                        if( array_key_exists( $status, 
$summary[$constraintName] ) ) {
                                $summary[$constraintName][$status]++;
                        }
@@ -81,14 +82,15 @@
         * @return string
         */
        public function getResults( $params ) {
-               if ( !array_key_exists( 'results', $params ) ) {
-                       $lookup = 
WikibaseRepo::getDefaultInstance()->getEntityLookup();
-                       $constraintChecker = 
ConstraintReportFactory::getDefaultInstance()->getConstraintChecker();
-                       $entityId = $params['entityId'][0] === 'Q' ? new 
ItemId( $params['entityId'] ) : new PropertyId( $params['entityId'] );
-                       $results = $constraintChecker->checkAgainstConstraints( 
$lookup->getEntity( $entityId ) );
-                       return $this->buildResultSummary( $results );
-               } else {
+               if ( array_key_exists( 'results', $params ) ) {
                        return $params['results'];
                }
+
+               $lookup = WikibaseRepo::getDefaultInstance()->getEntityLookup();
+               $constraintChecker = 
ConstraintReportFactory::getDefaultInstance()->getConstraintChecker();
+               $entityId = $params['entityId'][0] === 'Q' ? new ItemId( 
$params['entityId'] ) : new PropertyId( $params['entityId'] );
+               $results = $constraintChecker->checkAgainstConstraints( 
$lookup->getEntity( $entityId ) );
+
+               return $this->buildResultSummary( $results );
        }
 }
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/229642
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I883c0882745cd628d4ce7eaf647c8d78b261ab29
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Jeroen De Dauw <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to