Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/365566 )

Change subject: Extract role constants into separate class
......................................................................

Extract role constants into separate class

We have enough role constants that it starts to make sense to pull them
out of ConstraintParameterRenderer, and this significantly reduces the
length of a lot of format* lines.

Change-Id: I3a1ca5c041648ad4956fde06d75e6c9792bfd12b
---
M includes/ConstraintCheck/Checker/CommonsLinkChecker.php
M includes/ConstraintCheck/Checker/ConflictsWithChecker.php
M includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
M includes/ConstraintCheck/Checker/FormatChecker.php
M includes/ConstraintCheck/Checker/InverseChecker.php
M includes/ConstraintCheck/Checker/ItemChecker.php
M includes/ConstraintCheck/Checker/MandatoryQualifiersChecker.php
M includes/ConstraintCheck/Checker/OneOfChecker.php
M includes/ConstraintCheck/Checker/QualifiersChecker.php
M includes/ConstraintCheck/Checker/RangeChecker.php
M includes/ConstraintCheck/Checker/SymmetricChecker.php
M includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
M includes/ConstraintCheck/Checker/UniqueValueChecker.php
M includes/ConstraintCheck/Helper/ConstraintParameterParser.php
M includes/ConstraintCheck/Helper/SparqlHelper.php
M includes/ConstraintCheck/Helper/TypeCheckerHelper.php
M includes/ConstraintParameterRenderer.php
A includes/Role.php
18 files changed, 184 insertions(+), 148 deletions(-)


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

diff --git a/includes/ConstraintCheck/Checker/CommonsLinkChecker.php 
b/includes/ConstraintCheck/Checker/CommonsLinkChecker.php
index d626450..0a81ff7 100644
--- a/includes/ConstraintCheck/Checker/CommonsLinkChecker.php
+++ b/includes/ConstraintCheck/Checker/CommonsLinkChecker.php
@@ -14,6 +14,7 @@
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\Constraint;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -76,7 +77,7 @@
                 */
                if ( !$mainSnak instanceof PropertyValueSnak ) {
                        $message = wfMessage( 
"wbqc-violation-message-value-needed" )
-                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
+                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
                                         ->escaped();
                        return new CheckResult( $entity->getId(), $statement, 
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
                }
@@ -91,7 +92,7 @@
                if ( $dataValue->getType() !== 'string' ) {
                        $message = wfMessage( 
"wbqc-violation-message-value-needed-of-type" )
                                         ->rawParams(
-                                                
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ),
+                                                
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
                                                 wfMessage( 
'datatypes-type-string' )->escaped()
                                         )
                                         ->escaped();
diff --git a/includes/ConstraintCheck/Checker/ConflictsWithChecker.php 
b/includes/ConstraintCheck/Checker/ConflictsWithChecker.php
index 96b8c7f..29326c3 100644
--- a/includes/ConstraintCheck/Checker/ConflictsWithChecker.php
+++ b/includes/ConstraintCheck/Checker/ConflictsWithChecker.php
@@ -12,6 +12,7 @@
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -87,8 +88,8 @@
                        if ( $this->connectionCheckerHelper->hasProperty( 
$entity->getStatements(), $propertyId->getSerialization() ) ) {
                                $message = wfMessage( 
"wbqc-violation-message-conflicts-with-property" )
                                                 ->rawParams(
-                                                        
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PROPERTY ),
-                                                        
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
ConstraintParameterRenderer::ROLE_PREDICATE )
+                                                        
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
+                                                        
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
Role::PREDICATE )
                                                 )
                                                 ->escaped();
                                $status = CheckResult::STATUS_VIOLATION;
@@ -101,9 +102,9 @@
                        if ( $result !== null ) {
                                $message = wfMessage( 
"wbqc-violation-message-conflicts-with-claim" )
                                                 ->rawParams(
-                                                        
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PROPERTY ),
-                                                        
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
ConstraintParameterRenderer::ROLE_PREDICATE ),
-                                                        
$this->constraintParameterRenderer->formatItemIdSnakValue( $result, 
ConstraintParameterRenderer::ROLE_OBJECT )
+                                                        
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
+                                                        
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
Role::PREDICATE ),
+                                                        
$this->constraintParameterRenderer->formatItemIdSnakValue( $result, 
Role::OBJECT )
                                                 )
                                                 ->escaped();
                                $status = CheckResult::STATUS_VIOLATION;
diff --git a/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php 
b/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
index 66a5461..e11a8ee 100644
--- a/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
+++ b/includes/ConstraintCheck/Checker/DiffWithinRangeChecker.php
@@ -12,6 +12,7 @@
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\RangeCheckerHelper;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -72,7 +73,7 @@
                 */
                if ( !$mainSnak instanceof PropertyValueSnak ) {
                        $message = wfMessage( 
"wbqc-violation-message-value-needed" )
-                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
+                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
                                         ->escaped();
                        return new CheckResult( $entity->getId(), $statement, 
$constraint,  $parameters, CheckResult::STATUS_VIOLATION, $message );
                }
@@ -126,16 +127,16 @@
                                                $openness = $min !== null ? ( 
$max !== null ? '' : '-rightopen' ) : '-leftopen';
                                                $message = wfMessage( 
"wbqc-violation-message-diff-within-range$openness" );
                                                $message->rawParams(
-                                                       
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), ConstraintParameterRenderer::ROLE_PREDICATE ),
-                                                       
$this->constraintParameterRenderer->formatDataValue( $mainSnak->getDataValue(), 
ConstraintParameterRenderer::ROLE_OBJECT ),
-                                                       
$this->constraintParameterRenderer->formatEntityId( 
$otherStatement->getPropertyId(), ConstraintParameterRenderer::ROLE_PREDICATE ),
-                                                       
$this->constraintParameterRenderer->formatDataValue( 
$otherMainSnak->getDataValue(), ConstraintParameterRenderer::ROLE_OBJECT )
+                                                       
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), Role::PREDICATE ),
+                                                       
$this->constraintParameterRenderer->formatDataValue( $mainSnak->getDataValue(), 
Role::OBJECT ),
+                                                       
$this->constraintParameterRenderer->formatEntityId( 
$otherStatement->getPropertyId(), Role::PREDICATE ),
+                                                       
$this->constraintParameterRenderer->formatDataValue( 
$otherMainSnak->getDataValue(), Role::OBJECT )
                                                );
                                                if ( $min !== null ) {
-                                                       $message->rawParams( 
$this->constraintParameterRenderer->formatDataValue( $min, 
ConstraintParameterRenderer::ROLE_OBJECT ) );
+                                                       $message->rawParams( 
$this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) );
                                                }
                                                if ( $max !== null ) {
-                                                       $message->rawParams( 
$this->constraintParameterRenderer->formatDataValue( $max, 
ConstraintParameterRenderer::ROLE_OBJECT ) );
+                                                       $message->rawParams( 
$this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) );
                                                }
                                                $message = $message->escaped();
                                                $status = 
CheckResult::STATUS_VIOLATION;
diff --git a/includes/ConstraintCheck/Checker/FormatChecker.php 
b/includes/ConstraintCheck/Checker/FormatChecker.php
index b437046..479bfd9 100644
--- a/includes/ConstraintCheck/Checker/FormatChecker.php
+++ b/includes/ConstraintCheck/Checker/FormatChecker.php
@@ -14,6 +14,7 @@
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\SparqlHelper;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -85,7 +86,7 @@
                 */
                if ( !$mainSnak instanceof PropertyValueSnak ) {
                        $message = wfMessage( 
"wbqc-violation-message-value-needed" )
-                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
+                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
                                         ->escaped();
                        return new CheckResult( $entity->getId(), $statement, 
$constraint,  $parameters, CheckResult::STATUS_VIOLATION, $message );
                }
@@ -106,7 +107,7 @@
                        default:
                                $message = wfMessage( 
"wbqc-violation-message-value-needed-of-type" )
                                                 ->rawParams(
-                                                        
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ),
+                                                        
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
                                                         wfMessage( 
'datatypes-type-string' )->escaped(),
                                                         wfMessage( 
'datatypes-type-monolingualtext' )->escaped()
                                                 )
@@ -121,9 +122,9 @@
                        } else {
                                $message = wfMessage( 
'wbqc-violation-message-format' )
                                                 ->rawParams(
-                                                       
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PROPERTY ),
-                                                       
$this->constraintParameterRenderer->formatDataValue( new StringValue( $text ), 
ConstraintParameterRenderer::ROLE_OBJECT ),
-                                                       
$this->constraintParameterRenderer->formatByRole( 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_VALUE,
+                                                       
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
+                                                       
$this->constraintParameterRenderer->formatDataValue( new StringValue( $text ), 
Role::OBJECT ),
+                                                       
$this->constraintParameterRenderer->formatByRole( 
Role::CONSTRAINT_PARAMETER_VALUE,
                                                                
'<code><nowiki>' . htmlspecialchars( $format ) . '</nowiki></code>' )
                                                 )
                                                 ->escaped();
@@ -131,7 +132,7 @@
                        }
                } else {
                        $message = wfMessage( 
"wbqc-violation-message-security-reason" )
-                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
+                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
                                         ->escaped();
                        $status = CheckResult::STATUS_TODO;
                }
diff --git a/includes/ConstraintCheck/Checker/InverseChecker.php 
b/includes/ConstraintCheck/Checker/InverseChecker.php
index 8c0cbfe..3f891b8 100644
--- a/includes/ConstraintCheck/Checker/InverseChecker.php
+++ b/includes/ConstraintCheck/Checker/InverseChecker.php
@@ -14,6 +14,7 @@
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -85,7 +86,7 @@
                 */
                if ( !$mainSnak instanceof PropertyValueSnak ) {
                        $message = wfMessage( 
"wbqc-violation-message-value-needed" )
-                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
+                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
                                         ->escaped();
                        return new CheckResult( $entity->getId(), $statement, 
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
                }
@@ -99,7 +100,7 @@
                if ( $dataValue->getType() !== 'wikibase-entityid' ) {
                        $message = wfMessage( 
"wbqc-violation-message-value-needed-of-type" )
                                         ->rawParams(
-                                                
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ),
+                                                
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
                                                 'wikibase-entityid' // TODO is 
there a message for this type so we can localize it?
                                         )
                                         ->escaped();
@@ -120,9 +121,9 @@
                } else {
                        $message = wfMessage( 'wbqc-violation-message-inverse' )
                                         ->rawParams(
-                                                
$this->constraintParameterRenderer->formatEntityId( $targetItem->getId(), 
ConstraintParameterRenderer::ROLE_SUBJECT ),
-                                                
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
ConstraintParameterRenderer::ROLE_PREDICATE ),
-                                                
$this->constraintParameterRenderer->formatEntityId( $entity->getId(), 
ConstraintParameterRenderer::ROLE_OBJECT )
+                                                
$this->constraintParameterRenderer->formatEntityId( $targetItem->getId(), 
Role::SUBJECT ),
+                                                
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
Role::PREDICATE ),
+                                                
$this->constraintParameterRenderer->formatEntityId( $entity->getId(), 
Role::OBJECT )
                                         )
                                         ->escaped();
                        $status = CheckResult::STATUS_VIOLATION;
diff --git a/includes/ConstraintCheck/Checker/ItemChecker.php 
b/includes/ConstraintCheck/Checker/ItemChecker.php
index ec89cf0..96e8430 100644
--- a/includes/ConstraintCheck/Checker/ItemChecker.php
+++ b/includes/ConstraintCheck/Checker/ItemChecker.php
@@ -12,6 +12,7 @@
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -102,11 +103,11 @@
                } else {
                        $message = wfMessage( 'wbqc-violation-message-item' );
                        $message->rawParams(
-                               
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PROPERTY ),
-                               
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
ConstraintParameterRenderer::ROLE_PREDICATE )
+                               
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
+                               
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
Role::PREDICATE )
                        );
                        $message->numParams( count( $items ) );
-                       $message->rawParams( 
$this->constraintParameterRenderer->formatItemIdSnakValueList( $items, 
ConstraintParameterRenderer::ROLE_OBJECT ) );
+                       $message->rawParams( 
$this->constraintParameterRenderer->formatItemIdSnakValueList( $items, 
Role::OBJECT ) );
                        $message = $message->escaped();
                }
 
diff --git a/includes/ConstraintCheck/Checker/MandatoryQualifiersChecker.php 
b/includes/ConstraintCheck/Checker/MandatoryQualifiersChecker.php
index 65ebb67..66295ca 100644
--- a/includes/ConstraintCheck/Checker/MandatoryQualifiersChecker.php
+++ b/includes/ConstraintCheck/Checker/MandatoryQualifiersChecker.php
@@ -11,6 +11,7 @@
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -60,8 +61,8 @@
 
                $message = wfMessage( 
"wbqc-violation-message-mandatory-qualifier" )
                                 ->rawParams(
-                                        
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PROPERTY ),
-                                        
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
ConstraintParameterRenderer::ROLE_QUALIFIER_PREDICATE )
+                                        
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
+                                        
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
Role::QUALIFIER_PREDICATE )
                                 )
                                 ->escaped();
                $status = CheckResult::STATUS_VIOLATION;
diff --git a/includes/ConstraintCheck/Checker/OneOfChecker.php 
b/includes/ConstraintCheck/Checker/OneOfChecker.php
index 905bcdc..a1e52d3 100644
--- a/includes/ConstraintCheck/Checker/OneOfChecker.php
+++ b/includes/ConstraintCheck/Checker/OneOfChecker.php
@@ -10,6 +10,7 @@
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -60,9 +61,9 @@
                $mainSnak = $statement->getMainSnak();
 
                $message = wfMessage( 'wbqc-violation-message-one-of' );
-               $message->rawParams( 
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), ConstraintParameterRenderer::ROLE_PREDICATE ) );
+               $message->rawParams( 
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), Role::PREDICATE ) );
                $message->numParams( count( $items ) );
-               $message->rawParams( 
$this->constraintParameterRenderer->formatItemIdSnakValueList( $items, 
ConstraintParameterRenderer::ROLE_OBJECT ) );
+               $message->rawParams( 
$this->constraintParameterRenderer->formatItemIdSnakValueList( $items, 
Role::OBJECT ) );
                $message = $message->escaped();
                $status = CheckResult::STATUS_VIOLATION;
 
diff --git a/includes/ConstraintCheck/Checker/QualifiersChecker.php 
b/includes/ConstraintCheck/Checker/QualifiersChecker.php
index 677bc98..3a07e0f 100644
--- a/includes/ConstraintCheck/Checker/QualifiersChecker.php
+++ b/includes/ConstraintCheck/Checker/QualifiersChecker.php
@@ -11,6 +11,7 @@
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -74,16 +75,16 @@
                                if ( empty( $properties ) || $properties === [ 
'' ] ) {
                                        $message = wfMessage( 
'wbqc-violation-message-no-qualifiers' );
                                        $message->rawParams(
-                                               
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PROPERTY )
+                                               
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), Role::CONSTRAINT_PROPERTY )
                                        );
                                } else {
                                        $message = wfMessage( 
"wbqc-violation-message-qualifiers" );
                                        $message->rawParams(
-                                               
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PROPERTY ),
-                                               
$this->constraintParameterRenderer->formatEntityId( 
$qualifier->getPropertyId(), 
ConstraintParameterRenderer::ROLE_QUALIFIER_PREDICATE )
+                                               
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
+                                               
$this->constraintParameterRenderer->formatEntityId( 
$qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE )
                                        );
                                        $message->numParams( count( $properties 
) );
-                                       $message->rawParams( 
$this->constraintParameterRenderer->formatPropertyIdList( $properties, 
ConstraintParameterRenderer::ROLE_QUALIFIER_PREDICATE ) );
+                                       $message->rawParams( 
$this->constraintParameterRenderer->formatPropertyIdList( $properties, 
Role::QUALIFIER_PREDICATE ) );
                                }
                                $message = $message->escaped();
                                $status = CheckResult::STATUS_VIOLATION;
diff --git a/includes/ConstraintCheck/Checker/RangeChecker.php 
b/includes/ConstraintCheck/Checker/RangeChecker.php
index 7f3361d..76f5916 100644
--- a/includes/ConstraintCheck/Checker/RangeChecker.php
+++ b/includes/ConstraintCheck/Checker/RangeChecker.php
@@ -13,6 +13,7 @@
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\RangeCheckerHelper;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -81,7 +82,7 @@
                 */
                if ( !$mainSnak instanceof PropertyValueSnak ) {
                        $message = wfMessage( 
"wbqc-violation-message-value-needed" )
-                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
+                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
                                         ->escaped();
                        return new CheckResult( $entity->getId(), $statement, 
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
                }
@@ -108,14 +109,14 @@
                        $openness = $min !== null ? ( $max !== null ? 'closed' 
: 'rightopen' ) : 'leftopen';
                        $message = wfMessage( 
"wbqc-violation-message-range-$type-$openness" );
                        $message->rawParams(
-                               
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), ConstraintParameterRenderer::ROLE_PREDICATE ),
-                               
$this->constraintParameterRenderer->formatDataValue( $dataValue, 
ConstraintParameterRenderer::ROLE_OBJECT )
+                               
$this->constraintParameterRenderer->formatEntityId( 
$statement->getPropertyId(), Role::PREDICATE ),
+                               
$this->constraintParameterRenderer->formatDataValue( $dataValue, Role::OBJECT )
                        );
                        if ( $min !== null ) {
-                               $message->rawParams( 
$this->constraintParameterRenderer->formatDataValue( $min, 
ConstraintParameterRenderer::ROLE_OBJECT ) );
+                               $message->rawParams( 
$this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) );
                        }
                        if ( $max !== null ) {
-                               $message->rawParams( 
$this->constraintParameterRenderer->formatDataValue( $max, 
ConstraintParameterRenderer::ROLE_OBJECT ) );
+                               $message->rawParams( 
$this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) );
                        }
                        $message = $message->escaped();
                        $status = CheckResult::STATUS_VIOLATION;
diff --git a/includes/ConstraintCheck/Checker/SymmetricChecker.php 
b/includes/ConstraintCheck/Checker/SymmetricChecker.php
index 0534f8a..04d97ce 100644
--- a/includes/ConstraintCheck/Checker/SymmetricChecker.php
+++ b/includes/ConstraintCheck/Checker/SymmetricChecker.php
@@ -12,6 +12,7 @@
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConnectionCheckerHelper;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -72,7 +73,7 @@
                 */
                if ( !$mainSnak instanceof PropertyValueSnak ) {
                        $message = wfMessage( 
"wbqc-violation-message-value-needed" )
-                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
+                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
                                         ->escaped();
                        return new CheckResult( $entity->getId(), $statement, 
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
                }
@@ -86,7 +87,7 @@
                if ( $dataValue->getType() !== 'wikibase-entityid' ) {
                        $message = wfMessage( 
"wbqc-violation-message-value-needed-of-type" )
                                         ->rawParams(
-                                                
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ),
+                                                
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
                                                 'wikibase-entityid' // TODO is 
there a message for this type so we can localize it?
                                         )
                                         ->escaped();
@@ -107,9 +108,9 @@
                } else {
                        $message = wfMessage( 
'wbqc-violation-message-symmetric' )
                                         ->rawParams(
-                                                
$this->constraintParameterRenderer->formatEntityId( $targetItem->getId(), 
ConstraintParameterRenderer::ROLE_SUBJECT ),
-                                                
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
ConstraintParameterRenderer::ROLE_PREDICATE ),
-                                                
$this->constraintParameterRenderer->formatEntityId( $entity->getId(), 
ConstraintParameterRenderer::ROLE_OBJECT )
+                                                
$this->constraintParameterRenderer->formatEntityId( $targetItem->getId(), 
Role::SUBJECT ),
+                                                
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
Role::PREDICATE ),
+                                                
$this->constraintParameterRenderer->formatEntityId( $entity->getId(), 
Role::OBJECT )
                                         )
                                         ->escaped();
                        $status = CheckResult::STATUS_VIOLATION;
diff --git a/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php 
b/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
index 9221f61..b524945 100644
--- a/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
+++ b/includes/ConstraintCheck/Checker/TargetRequiredClaimChecker.php
@@ -14,6 +14,7 @@
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\ConstraintParameterParser;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -88,7 +89,7 @@
                 */
                if ( !$mainSnak instanceof PropertyValueSnak ) {
                        $message = wfMessage( 
"wbqc-violation-message-value-needed" )
-                               ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
+                               ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
                                ->escaped();
                        return new CheckResult( $entity->getId(), $statement, 
$constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
                }
@@ -102,7 +103,7 @@
                if ( $dataValue->getType() !== 'wikibase-entityid' ) {
                        $message = wfMessage( 
"wbqc-violation-message-value-needed-of-type" )
                                ->rawParams(
-                                       
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ),
+                                       
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
                                        'wikibase-entityid' // TODO is there a 
message for this type so we can localize it?
                                )
                                ->escaped();
@@ -142,11 +143,11 @@
                } else {
                        $message = wfMessage( 
'wbqc-violation-message-target-required-claim' );
                        $message->rawParams(
-                               
$this->constraintParameterRenderer->formatEntityId( $targetEntityId, 
ConstraintParameterRenderer::ROLE_SUBJECT ),
-                               
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
ConstraintParameterRenderer::ROLE_PREDICATE )
+                               
$this->constraintParameterRenderer->formatEntityId( $targetEntityId, 
Role::SUBJECT ),
+                               
$this->constraintParameterRenderer->formatEntityId( $propertyId, 
Role::PREDICATE )
                        );
                        $message->numParams( count( $items ) );
-                       $message->rawParams( 
$this->constraintParameterRenderer->formatItemIdSnakValueList( $items, 
ConstraintParameterRenderer::ROLE_OBJECT ) );
+                       $message->rawParams( 
$this->constraintParameterRenderer->formatItemIdSnakValueList( $items, 
Role::OBJECT ) );
                        $message = $message->escaped();
                }
 
diff --git a/includes/ConstraintCheck/Checker/UniqueValueChecker.php 
b/includes/ConstraintCheck/Checker/UniqueValueChecker.php
index 30bf0e8..e692d51 100644
--- a/includes/ConstraintCheck/Checker/UniqueValueChecker.php
+++ b/includes/ConstraintCheck/Checker/UniqueValueChecker.php
@@ -10,6 +10,7 @@
 use 
WikibaseQuality\ConstraintReport\ConstraintCheck\Helper\SparqlHelperException;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResult;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 use Wikibase\DataModel\Statement\Statement;
 
 /**
@@ -65,13 +66,13 @@
                                $status = CheckResult::STATUS_VIOLATION;
                                $message = wfMessage( 
'wbqc-violation-message-unique-value' )
                                                 ->numParams( count( 
$otherEntities ) )
-                                                ->rawParams( 
$this->constraintParameterRenderer->formatItemIdList( $otherEntities, 
ConstraintParameterRenderer::ROLE_SUBJECT ) )
+                                                ->rawParams( 
$this->constraintParameterRenderer->formatItemIdList( $otherEntities, 
Role::SUBJECT ) )
                                                 ->escaped();
                        }
                } else {
                        $status = CheckResult::STATUS_TODO;
                        $message = wfMessage( 
"wbqc-violation-message-not-yet-implemented" )
-                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
+                                        ->rawParams( 
$this->constraintParameterRenderer->formatItemId( 
$constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
                                         ->escaped();
                }
 
diff --git a/includes/ConstraintCheck/Helper/ConstraintParameterParser.php 
b/includes/ConstraintCheck/Helper/ConstraintParameterParser.php
index 2899ae7..fb162bf 100644
--- a/includes/ConstraintCheck/Helper/ConstraintParameterParser.php
+++ b/includes/ConstraintCheck/Helper/ConstraintParameterParser.php
@@ -20,6 +20,7 @@
 use Wikibase\Repo\Parsers\TimeParserFactory;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\ItemIdSnakValue;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 
 /**
  * Helper for parsing constraint parameters
@@ -80,7 +81,7 @@
                if ( count( $parameters[$parameterId] ) !== 1 ) {
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-single' )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ) )
                                        ->escaped()
                        );
                }
@@ -97,7 +98,7 @@
                if ( !( $snak instanceof PropertyValueSnak ) ) {
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-value' )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ) )
                                        ->escaped()
                        );
                }
@@ -120,8 +121,8 @@
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-entity' )
                                        ->rawParams(
-                                               
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ),
-                                               
$this->constraintParameterRenderer->formatDataValue( $value, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_VALUE )
+                                               
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ),
+                                               
$this->constraintParameterRenderer->formatDataValue( $value, 
Role::CONSTRAINT_PARAMETER_VALUE )
                                        )
                                        ->escaped()
                        );
@@ -156,8 +157,8 @@
                } else {
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-needed' )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $classId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
Role::CONSTRAINT_TYPE_ITEM ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $classId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ) )
                                        ->escaped()
                        );
                }
@@ -177,9 +178,9 @@
                        default:
                                throw new ConstraintParameterException(
                                        wfMessage( 
'wbqc-violation-message-parameter-oneof' )
-                                               ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $relationId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ) )
+                                               ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $relationId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ) )
                                                ->numParams( 2 )
-                                               ->rawParams( 
$this->constraintParameterRenderer->formatItemIdList( [ $instanceId, 
$subclassId ], ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_VALUE ) )
+                                               ->rawParams( 
$this->constraintParameterRenderer->formatItemIdList( [ $instanceId, 
$subclassId ], Role::CONSTRAINT_PARAMETER_VALUE ) )
                                                ->escaped()
                                );
                }
@@ -212,8 +213,8 @@
                } else {
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-needed' )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $relationId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
Role::CONSTRAINT_TYPE_ITEM ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $relationId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ) )
                                        ->escaped()
                        );
                }
@@ -239,8 +240,8 @@
                throw new ConstraintParameterException(
                        wfMessage( 'wbqc-violation-message-parameter-property' )
                                ->rawParams(
-                                       
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ),
-                                       
$this->constraintParameterRenderer->formatDataValue( $value, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_VALUE )
+                                       
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ),
+                                       
$this->constraintParameterRenderer->formatDataValue( $value, 
Role::CONSTRAINT_PARAMETER_VALUE )
                                )
                                ->escaped()
                );
@@ -260,8 +261,8 @@
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-property' )
                                        ->rawParams(
-                                               
$this->constraintParameterRenderer->formatPropertyId( 'property', 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ),
-                                               
$this->constraintParameterRenderer->formatDataValue( new StringValue( 
$constraintParameters['property'] ), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_VALUE )
+                                               
$this->constraintParameterRenderer->formatPropertyId( 'property', 
Role::CONSTRAINT_PARAMETER_PROPERTY ),
+                                               
$this->constraintParameterRenderer->formatDataValue( new StringValue( 
$constraintParameters['property'] ), Role::CONSTRAINT_PARAMETER_VALUE )
                                        )
                                        ->escaped()
                        );
@@ -283,8 +284,8 @@
                } else {
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-needed' )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $propertyId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
Role::CONSTRAINT_TYPE_ITEM ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $propertyId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ) )
                                        ->escaped()
                        );
                }
@@ -298,8 +299,8 @@
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-item' )
                                        ->rawParams(
-                                               
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ),
-                                               
$this->constraintParameterRenderer->formatDataValue( $snak->getDataValue(), 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_VALUE )
+                                               
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ),
+                                               
$this->constraintParameterRenderer->formatDataValue( $snak->getDataValue(), 
Role::CONSTRAINT_PARAMETER_VALUE )
                                        )
                                        ->escaped()
                        );
@@ -369,8 +370,8 @@
                        if ( $required ) {
                                throw new ConstraintParameterException(
                                        wfMessage( 
'wbqc-violation-message-parameter-needed' )
-                                               ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
-                                               ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $qualifierId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ) )
+                                               ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
Role::CONSTRAINT_TYPE_ITEM ) )
+                                               ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $qualifierId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ) )
                                                ->escaped()
                                );
                        } else {
@@ -405,8 +406,8 @@
                                        throw new ConstraintParameterException(
                                                wfMessage( 
'wbqc-violation-message-parameter-property' )
                                                        ->rawParams(
-                                                               
$this->constraintParameterRenderer->formatPropertyId( 'property', 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ),
-                                                               
$this->constraintParameterRenderer->formatDataValue( new StringValue( $property 
), ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_VALUE )
+                                                               
$this->constraintParameterRenderer->formatPropertyId( 'property', 
Role::CONSTRAINT_PARAMETER_PROPERTY ),
+                                                               
$this->constraintParameterRenderer->formatDataValue( new StringValue( $property 
), Role::CONSTRAINT_PARAMETER_VALUE )
                                                        )
                                                        ->escaped()
                                        );
@@ -431,8 +432,8 @@
                } else {
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-needed' )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $propertyId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
Role::CONSTRAINT_TYPE_ITEM ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $propertyId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ) )
                                        ->escaped()
                        );
                }
@@ -453,7 +454,7 @@
                } else {
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-value-or-novalue' )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ) )
                                        ->escaped()
                        );
                }
@@ -551,10 +552,10 @@
                                wfMessage( 
'wbqc-violation-message-range-parameters-needed' )
                                        ->rawParams(
                                                wfMessage( 'datatypes-type-' . 
$type )->escaped(),
-                                               
$this->constraintParameterRenderer->formatPropertyId( $minimumId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ),
-                                               
$this->constraintParameterRenderer->formatPropertyId( $maximumId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY )
+                                               
$this->constraintParameterRenderer->formatPropertyId( $minimumId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ),
+                                               
$this->constraintParameterRenderer->formatPropertyId( $maximumId, 
Role::CONSTRAINT_PARAMETER_PROPERTY )
                                        )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
Role::CONSTRAINT_TYPE_ITEM ) )
                                        ->escaped()
                        );
                }
@@ -577,8 +578,8 @@
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-string' )
                                        ->rawParams(
-                                               
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ),
-                                               
$this->constraintParameterRenderer->formatDataValue( $value, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_VALUE )
+                                               
$this->constraintParameterRenderer->formatPropertyId( $parameterId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ),
+                                               
$this->constraintParameterRenderer->formatDataValue( $value, 
Role::CONSTRAINT_PARAMETER_VALUE )
                                        )
                                        ->escaped()
                        );
@@ -641,8 +642,8 @@
                } else {
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-needed' )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_TYPE_ITEM ) )
-                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $formatId, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatItemId( $constraintTypeItemId, 
Role::CONSTRAINT_TYPE_ITEM ) )
+                                       ->rawParams( 
$this->constraintParameterRenderer->formatPropertyId( $formatId, 
Role::CONSTRAINT_PARAMETER_PROPERTY ) )
                                        ->escaped()
                        );
                }
@@ -677,8 +678,8 @@
                                        throw new ConstraintParameterException(
                                                wfMessage( 
'wbqc-violation-message-parameter-entity' )
                                                        ->rawParams(
-                                                               
$this->constraintParameterRenderer->formatPropertyId( 'known_exception', 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_PROPERTY ),
-                                                               
$this->constraintParameterRenderer->formatDataValue( $value, 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_VALUE )
+                                                               
$this->constraintParameterRenderer->formatPropertyId( 'known_exception', 
Role::CONSTRAINT_PARAMETER_PROPERTY ),
+                                                               
$this->constraintParameterRenderer->formatDataValue( $value, 
Role::CONSTRAINT_PARAMETER_VALUE )
                                                        )
                                                        ->escaped()
                                        );
diff --git a/includes/ConstraintCheck/Helper/SparqlHelper.php 
b/includes/ConstraintCheck/Helper/SparqlHelper.php
index d73a042..42c92f5 100644
--- a/includes/ConstraintCheck/Helper/SparqlHelper.php
+++ b/includes/ConstraintCheck/Helper/SparqlHelper.php
@@ -11,6 +11,7 @@
 use Wikibase\DataModel\Statement\Statement;
 use Wikibase\Rdf\RdfVocabulary;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 
 /**
  * Class for running a SPARQL query on some endpoint and getting the results.
@@ -181,7 +182,7 @@
                        // empty result: regex broken
                        throw new ConstraintParameterException(
                                wfMessage( 
'wbqc-violation-message-parameter-regex' )
-                                       ->rawParams( 
ConstraintParameterRenderer::formatByRole( 
ConstraintParameterRenderer::ROLE_CONSTRAINT_PARAMETER_VALUE,
+                                       ->rawParams( 
ConstraintParameterRenderer::formatByRole( Role::CONSTRAINT_PARAMETER_VALUE,
                                                '<code><nowiki>' . 
htmlspecialchars( $regex ) . '</nowiki></code>' ) )
                                        ->escaped()
                        );
diff --git a/includes/ConstraintCheck/Helper/TypeCheckerHelper.php 
b/includes/ConstraintCheck/Helper/TypeCheckerHelper.php
index ad4373e..d7cb13a 100644
--- a/includes/ConstraintCheck/Helper/TypeCheckerHelper.php
+++ b/includes/ConstraintCheck/Helper/TypeCheckerHelper.php
@@ -14,6 +14,7 @@
 use Wikibase\DataModel\Statement\StatementList;
 use Wikibase\DataModel\Statement\StatementListProvider;
 use WikibaseQuality\ConstraintReport\ConstraintParameterRenderer;
+use WikibaseQuality\ConstraintReport\Role;
 
 /**
  * Class for helper functions for range checkers.
@@ -188,11 +189,11 @@
                $message = wfMessage( 'wbqc-violation-message-' . $checker . 
'-' . $relation );
 
                $message->rawParams(
-                       $this->constraintParameterRenderer->formatEntityId( 
$propertyId, ConstraintParameterRenderer::ROLE_CONSTRAINT_PROPERTY ),
-                       $this->constraintParameterRenderer->formatEntityId( 
$entityId, ConstraintParameterRenderer::ROLE_SUBJECT )
+                       $this->constraintParameterRenderer->formatEntityId( 
$propertyId, Role::CONSTRAINT_PROPERTY ),
+                       $this->constraintParameterRenderer->formatEntityId( 
$entityId, Role::SUBJECT )
                );
                $message->numParams( count( $classes ) );
-               $message->rawParams( 
$this->constraintParameterRenderer->formatItemIdList( $classes, 
ConstraintParameterRenderer::ROLE_OBJECT ) );
+               $message->rawParams( 
$this->constraintParameterRenderer->formatItemIdList( $classes, Role::OBJECT ) 
);
 
                return $message->escaped();
        }
diff --git a/includes/ConstraintParameterRenderer.php 
b/includes/ConstraintParameterRenderer.php
index 9a0a795..12b6256 100644
--- a/includes/ConstraintParameterRenderer.php
+++ b/includes/ConstraintParameterRenderer.php
@@ -9,6 +9,7 @@
 use Wikibase\DataModel\Entity\PropertyId;
 use Wikibase\DataModel\Services\EntityId\EntityIdFormatter;
 use WikibaseQuality\ConstraintReport\ConstraintCheck\ItemIdSnakValue;
+use WikibaseQuality\ConstraintReport\Role;
 
 /**
  * Class ConstraintParameterRenderer
@@ -28,62 +29,6 @@
         * @var int
         */
        const MAX_PARAMETER_ARRAY_LENGTH = 10;
-
-       /**
-        * Indicates that a formatted value acts as the subject of a statement.
-        *
-        * @var string
-        */
-       const ROLE_SUBJECT = 'subject';
-
-       /**
-        * Indicates that a formatted value acts as the predicate of a 
statement.
-        *
-        * @var string
-        */
-       const ROLE_PREDICATE = 'predicate';
-
-       /**
-        * Indicates that a formatted value acts as the object of a statement.
-        *
-        * @var string
-        */
-       const ROLE_OBJECT = 'object';
-
-       /**
-        * Indicates that a formatted value is the property that introduced a 
constraint.
-        *
-        * @var string
-        */
-       const ROLE_CONSTRAINT_PROPERTY = 'constraint-property';
-
-       /**
-        * Indicates that a formatted value acts as the predicate of a 
qualifier.
-        *
-        * @var string
-        */
-       const ROLE_QUALIFIER_PREDICATE = 'qualifier-predicate';
-
-       /**
-        * Indicates that a formatted value is the property for a constraint 
parameter.
-        *
-        * @var string
-        */
-       const ROLE_CONSTRAINT_PARAMETER_PROPERTY = 
'constraint-parameter-property';
-
-       /**
-        * Indicates that a formatted value is the value for a constraint 
parameter.
-        *
-        * @var string
-        */
-       const ROLE_CONSTRAINT_PARAMETER_VALUE = 'constraint-parameter-value';
-
-       /**
-        * Indicates that a formatted value is the item for a constraint type.
-        *
-        * @var string
-        */
-       const ROLE_CONSTRAINT_TYPE_ITEM = 'constraint-type-item';
 
        /**
         *
@@ -177,7 +122,7 @@
        /**
         * If $role is non-null, wrap $value in a span with the CSS classes 
wdqc-role and wdqc-role-$role.
         *
-        * @param string|null $role one of the self::ROLE_* constants or null
+        * @param string|null $role one of the Role constants or null
         * @param string $value HTML
         * @return string HTML
         */
diff --git a/includes/Role.php b/includes/Role.php
new file mode 100644
index 0000000..a950a34
--- /dev/null
+++ b/includes/Role.php
@@ -0,0 +1,75 @@
+<?php
+namespace WikibaseQuality\ConstraintReport;
+
+use LogicException;
+
+/**
+ * Enum of possible roles of a value for ConstraintParameterRenderer.
+ *
+ * @package WikibaseQuality\ConstraintReport
+ * @author Lucas Werkmeister
+ * @license GNU GPL v2+
+ */
+class Role {
+
+       /**
+        * Indicates that a formatted value acts as the subject of a statement.
+        *
+        * @var string
+        */
+       const SUBJECT = 'subject';
+
+       /**
+        * Indicates that a formatted value acts as the predicate of a 
statement.
+        *
+        * @var string
+        */
+       const PREDICATE = 'predicate';
+
+       /**
+        * Indicates that a formatted value acts as the object of a statement.
+        *
+        * @var string
+        */
+       const OBJECT = 'object';
+
+       /**
+        * Indicates that a formatted value is the property that introduced a 
constraint.
+        *
+        * @var string
+        */
+       const CONSTRAINT_PROPERTY = 'constraint-property';
+
+       /**
+        * Indicates that a formatted value acts as the predicate of a 
qualifier.
+        *
+        * @var string
+        */
+       const QUALIFIER_PREDICATE = 'qualifier-predicate';
+
+       /**
+        * Indicates that a formatted value is the property for a constraint 
parameter.
+        *
+        * @var string
+        */
+       const CONSTRAINT_PARAMETER_PROPERTY = 'constraint-parameter-property';
+
+       /**
+        * Indicates that a formatted value is the value for a constraint 
parameter.
+        *
+        * @var string
+        */
+       const CONSTRAINT_PARAMETER_VALUE = 'constraint-parameter-value';
+
+       /**
+        * Indicates that a formatted value is the item for a constraint type.
+        *
+        * @var string
+        */
+       const CONSTRAINT_TYPE_ITEM = 'constraint-type-item';
+
+       private function __construct() {
+               throw new LogicException( 'This class should never be 
instantiated.' );
+       }
+
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3a1ca5c041648ad4956fde06d75e6c9792bfd12b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) <[email protected]>

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

Reply via email to