Completed
Push — master ( 377111...c4bc5c )
by
unknown
02:39
created
src/ConstraintCheck/Checker/QualifiersChecker.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -70,43 +70,43 @@  discard block
 block discarded – undo
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 = null;
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/MandatoryQualifiersChecker.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -70,43 +70,43 @@
 block discarded – undo
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
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
82
-		$parameters['property'] = [ $propertyId ];
81
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
82
+		$parameters['property'] = [$propertyId];
83 83
 
84
-		$message = wfMessage( "wbqc-violation-message-mandatory-qualifier" )
84
+		$message = wfMessage("wbqc-violation-message-mandatory-qualifier")
85 85
 				 ->rawParams(
86
-					 $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
87
-					 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::QUALIFIER_PREDICATE )
86
+					 $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
87
+					 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::QUALIFIER_PREDICATE)
88 88
 				 )
89 89
 				 ->escaped();
90 90
 		$status = CheckResult::STATUS_VIOLATION;
91 91
 
92 92
 		/** @var Snak $qualifier */
93
-		foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) {
94
-			if ( $propertyId->equals( $qualifier->getPropertyId() ) ) {
93
+		foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) {
94
+			if ($propertyId->equals($qualifier->getPropertyId())) {
95 95
 				$message = null;
96 96
 				$status = CheckResult::STATUS_COMPLIANCE;
97 97
 				break;
98 98
 			}
99 99
 		}
100 100
 
101
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
101
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
102 102
 	}
103 103
 
104
-	public function checkConstraintParameters( Constraint $constraint ) {
104
+	public function checkConstraintParameters(Constraint $constraint) {
105 105
 		$constraintParameters = $constraint->getConstraintParameters();
106 106
 		$exceptions = [];
107 107
 		try {
108
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
109
-		} catch ( ConstraintParameterException $e ) {
108
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
109
+		} catch (ConstraintParameterException $e) {
110 110
 			$exceptions[] = $e;
111 111
 		}
112 112
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/RangeChecker.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 	 * @throws ConstraintParameterException
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,42 +94,42 @@  discard block
 block discarded – undo
94 94
 
95 95
 		$snak = $context->getSnak();
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();
103 103
 
104
-		list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter(
104
+		list($min, $max) = $this->constraintParameterParser->parseRangeParameter(
105 105
 			$constraintParameters,
106 106
 			$constraint->getConstraintTypeItemId(),
107 107
 			$dataValue->getType()
108 108
 		);
109 109
 		$parameterKey = $dataValue->getType() === 'quantity' ? 'quantity' : 'date';
110
-		if ( $min !== null ) {
111
-			$parameters['minimum_' . $parameterKey] = [ $min ];
110
+		if ($min !== null) {
111
+			$parameters['minimum_'.$parameterKey] = [$min];
112 112
 		}
113
-		if ( $max !== null ) {
114
-			$parameters['maximum_' . $parameterKey] = [ $max ];
113
+		if ($max !== null) {
114
+			$parameters['maximum_'.$parameterKey] = [$max];
115 115
 		}
116 116
 
117
-		if ( $this->rangeCheckerHelper->getComparison( $min, $dataValue ) > 0 ||
118
-			 $this->rangeCheckerHelper->getComparison( $dataValue, $max ) > 0
117
+		if ($this->rangeCheckerHelper->getComparison($min, $dataValue) > 0 ||
118
+			 $this->rangeCheckerHelper->getComparison($dataValue, $max) > 0
119 119
 		) {
120 120
 			// at least one of $min, $max is set at this point, otherwise there could be no violation
121 121
 			$type = $dataValue->getType();
122
-			$openness = $min !== null ? ( $max !== null ? 'closed' : 'rightopen' ) : 'leftopen';
123
-			$message = wfMessage( "wbqc-violation-message-range-$type-$openness" );
122
+			$openness = $min !== null ? ($max !== null ? 'closed' : 'rightopen') : 'leftopen';
123
+			$message = wfMessage("wbqc-violation-message-range-$type-$openness");
124 124
 			$message->rawParams(
125
-				$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ),
126
-				$this->constraintParameterRenderer->formatDataValue( $dataValue, Role::OBJECT )
125
+				$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE),
126
+				$this->constraintParameterRenderer->formatDataValue($dataValue, Role::OBJECT)
127 127
 			);
128
-			if ( $min !== null ) {
129
-				$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) );
128
+			if ($min !== null) {
129
+				$message->rawParams($this->constraintParameterRenderer->formatDataValue($min, Role::OBJECT));
130 130
 			}
131
-			if ( $max !== null ) {
132
-				$message->rawParams( $this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) );
131
+			if ($max !== null) {
132
+				$message->rawParams($this->constraintParameterRenderer->formatDataValue($max, Role::OBJECT));
133 133
 			}
134 134
 			$message = $message->escaped();
135 135
 			$status = CheckResult::STATUS_VIOLATION;
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
 			$status = CheckResult::STATUS_COMPLIANCE;
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 148
 			// we don’t have a data value here, so get the type from the property instead
149 149
 			// (the distinction between data type and data value type is irrelevant for 'quantity' and 'time')
150
-			$type = $this->propertyDataTypeLookup->getDataTypeIdForProperty( $constraint->getPropertyId() );
150
+			$type = $this->propertyDataTypeLookup->getDataTypeIdForProperty($constraint->getPropertyId());
151 151
 			$this->constraintParameterParser->parseRangeParameter(
152 152
 				$constraintParameters,
153 153
 				$constraint->getConstraintTypeItemId(),
154 154
 				$type
155 155
 			);
156
-		} catch ( ConstraintParameterException $e ) {
156
+		} catch (ConstraintParameterException $e) {
157 157
 			$exceptions[] = $e;
158 158
 		}
159 159
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/TypeChecker.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -83,34 +83,34 @@  discard block
 block discarded – undo
83 83
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
84 84
 	 * @return CheckResult
85 85
 	 */
86
-	public function checkConstraint( Context $context, Constraint $constraint ) {
87
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
88
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
86
+	public function checkConstraint(Context $context, Constraint $constraint) {
87
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
88
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
89 89
 		}
90
-		if ( $context->getType() === Context::TYPE_REFERENCE ) {
91
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE );
90
+		if ($context->getType() === Context::TYPE_REFERENCE) {
91
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_NOT_IN_SCOPE);
92 92
 		}
93 93
 
94 94
 		$parameters = [];
95 95
 		$constraintParameters = $constraint->getConstraintParameters();
96 96
 
97
-		$classes = $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
97
+		$classes = $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
98 98
 		$parameters['class'] = array_map(
99
-			function( $id ) {
100
-				return new ItemId( $id );
99
+			function($id) {
100
+				return new ItemId($id);
101 101
 			},
102 102
 			$classes
103 103
 		);
104 104
 
105
-		$relation = $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
105
+		$relation = $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
106 106
 		$relationIds = [];
107
-		if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) {
108
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
107
+		if ($relation === 'instance' || $relation === 'instanceOrSubclass') {
108
+			$relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId');
109 109
 		}
110
-		if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) {
111
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
110
+		if ($relation === 'subclass' || $relation === 'instanceOrSubclass') {
111
+			$relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId');
112 112
 		}
113
-		$parameters['relation'] = [ $relation ];
113
+		$parameters['relation'] = [$relation];
114 114
 
115 115
 		$result = $this->typeCheckerHelper->hasClassInRelation(
116 116
 			$context->getEntity()->getStatements(),
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			$classes
119 119
 		);
120 120
 
121
-		if ( $result->getBool() ) {
121
+		if ($result->getBool()) {
122 122
 			$message = null;
123 123
 			$status = CheckResult::STATUS_COMPLIANCE;
124 124
 		} else {
@@ -132,21 +132,21 @@  discard block
 block discarded – undo
132 132
 			$status = CheckResult::STATUS_VIOLATION;
133 133
 		}
134 134
 
135
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
136
-			->withMetadata( $result->getMetadata() );
135
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
136
+			->withMetadata($result->getMetadata());
137 137
 	}
138 138
 
139
-	public function checkConstraintParameters( Constraint $constraint ) {
139
+	public function checkConstraintParameters(Constraint $constraint) {
140 140
 		$constraintParameters = $constraint->getConstraintParameters();
141 141
 		$exceptions = [];
142 142
 		try {
143
-			$this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
144
-		} catch ( ConstraintParameterException $e ) {
143
+			$this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
144
+		} catch (ConstraintParameterException $e) {
145 145
 			$exceptions[] = $e;
146 146
 		}
147 147
 		try {
148
-			$this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
149
-		} catch ( ConstraintParameterException $e ) {
148
+			$this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
149
+		} catch (ConstraintParameterException $e) {
150 150
 			$exceptions[] = $e;
151 151
 		}
152 152
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/UniqueValueChecker.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -72,22 +72,22 @@  discard block
 block discarded – undo
72 72
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
73 73
 	 * @return CheckResult
74 74
 	 */
75
-	public function checkConstraint( Context $context, Constraint $constraint ) {
76
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
77
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
75
+	public function checkConstraint(Context $context, Constraint $constraint) {
76
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
77
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
78 78
 		}
79 79
 
80 80
 		$parameters = [];
81 81
 
82
-		if ( $this->sparqlHelper !== null ) {
83
-			if ( $context->getType() === 'statement' ) {
82
+		if ($this->sparqlHelper !== null) {
83
+			if ($context->getType() === 'statement') {
84 84
 				$result = $this->sparqlHelper->findEntitiesWithSameStatement(
85 85
 					$context->getSnakStatement(),
86 86
 					true // ignore deprecated statements
87 87
 				);
88 88
 			} else {
89
-				if ( $context->getSnak()->getType() !== 'value' ) {
90
-					return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE );
89
+				if ($context->getSnak()->getType() !== 'value') {
90
+					return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE);
91 91
 				}
92 92
 				$result = $this->sparqlHelper->findEntitiesWithSameQualifierOrReference(
93 93
 					$context->getEntity()->getId(),
@@ -100,29 +100,29 @@  discard block
 block discarded – undo
100 100
 			$otherEntities = $result->getArray();
101 101
 			$metadata = $result->getMetadata();
102 102
 
103
-			if ( $otherEntities === [] ) {
103
+			if ($otherEntities === []) {
104 104
 				$status = CheckResult::STATUS_COMPLIANCE;
105 105
 				$message = null;
106 106
 			} else {
107 107
 				$status = CheckResult::STATUS_VIOLATION;
108
-				$message = wfMessage( 'wbqc-violation-message-unique-value' )
109
-						 ->numParams( count( $otherEntities ) )
110
-						 ->rawParams( $this->constraintParameterRenderer->formatEntityIdList( $otherEntities, Role::SUBJECT ) )
108
+				$message = wfMessage('wbqc-violation-message-unique-value')
109
+						 ->numParams(count($otherEntities))
110
+						 ->rawParams($this->constraintParameterRenderer->formatEntityIdList($otherEntities, Role::SUBJECT))
111 111
 						 ->escaped();
112 112
 			}
113 113
 		} else {
114 114
 			$status = CheckResult::STATUS_TODO;
115
-			$message = wfMessage( "wbqc-violation-message-not-yet-implemented" )
116
-					 ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) )
115
+			$message = wfMessage("wbqc-violation-message-not-yet-implemented")
116
+					 ->rawParams($this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM))
117 117
 					 ->escaped();
118 118
 			$metadata = Metadata::blank();
119 119
 		}
120 120
 
121
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
122
-			->withMetadata( $metadata );
121
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
122
+			->withMetadata($metadata);
123 123
 	}
124 124
 
125
-	public function checkConstraintParameters( Constraint $constraint ) {
125
+	public function checkConstraintParameters(Constraint $constraint) {
126 126
 		// no parameters
127 127
 		return [];
128 128
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ItemChecker.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -85,18 +85,18 @@  discard block
 block discarded – undo
85 85
 	 * @throws ConstraintParameterException
86 86
 	 * @return CheckResult
87 87
 	 */
88
-	public function checkConstraint( Context $context, Constraint $constraint ) {
89
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
90
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
88
+	public function checkConstraint(Context $context, Constraint $constraint) {
89
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
90
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
91 91
 		}
92 92
 
93 93
 		$parameters = [];
94 94
 		$constraintParameters = $constraint->getConstraintParameters();
95 95
 
96
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
97
-		$parameters['property'] = [ $propertyId ];
96
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
97
+		$parameters['property'] = [$propertyId];
98 98
 
99
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
99
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
100 100
 		$parameters['items'] = $items;
101 101
 
102 102
 		/*
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 		 *   a) a property only
105 105
 		 *   b) a property and a number of items (each combination of property and item forming an individual claim)
106 106
 		 */
107
-		if ( $items === [] ) {
107
+		if ($items === []) {
108 108
 			$requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty(
109 109
 				$context->getEntity()->getStatements(),
110 110
 				$propertyId
@@ -117,35 +117,35 @@  discard block
 block discarded – undo
117 117
 			);
118 118
 		}
119 119
 
120
-		if ( $requiredStatement !== null ) {
120
+		if ($requiredStatement !== null) {
121 121
 			$status = CheckResult::STATUS_COMPLIANCE;
122 122
 			$message = null;
123 123
 		} else {
124 124
 			$status = CheckResult::STATUS_VIOLATION;
125
-			$message = wfMessage( 'wbqc-violation-message-item' );
125
+			$message = wfMessage('wbqc-violation-message-item');
126 126
 			$message->rawParams(
127
-				$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
128
-				$this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE )
127
+				$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
128
+				$this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE)
129 129
 			);
130
-			$message->numParams( count( $items ) );
131
-			$message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) );
130
+			$message->numParams(count($items));
131
+			$message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT));
132 132
 			$message = $message->escaped();
133 133
 		}
134 134
 
135
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
135
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
136 136
 	}
137 137
 
138
-	public function checkConstraintParameters( Constraint $constraint ) {
138
+	public function checkConstraintParameters(Constraint $constraint) {
139 139
 		$constraintParameters = $constraint->getConstraintParameters();
140 140
 		$exceptions = [];
141 141
 		try {
142
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
143
-		} catch ( ConstraintParameterException $e ) {
142
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
143
+		} catch (ConstraintParameterException $e) {
144 144
 			$exceptions[] = $e;
145 145
 		}
146 146
 		try {
147
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
148
-		} catch ( ConstraintParameterException $e ) {
147
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
148
+		} catch (ConstraintParameterException $e) {
149 149
 			$exceptions[] = $e;
150 150
 		}
151 151
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/OneOfChecker.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -67,43 +67,43 @@
 block discarded – undo
67 67
 	 * @throws ConstraintParameterException
68 68
 	 * @return CheckResult
69 69
 	 */
70
-	public function checkConstraint( Context $context, Constraint $constraint ) {
71
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
72
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
70
+	public function checkConstraint(Context $context, Constraint $constraint) {
71
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
72
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
73 73
 		}
74 74
 
75 75
 		$parameters = [];
76 76
 		$constraintParameters = $constraint->getConstraintParameters();
77 77
 
78
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true );
78
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true);
79 79
 		$parameters['item'] = $items;
80 80
 
81 81
 		$snak = $context->getSnak();
82 82
 
83
-		$message = wfMessage( 'wbqc-violation-message-one-of' );
84
-		$message->rawParams( $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) );
85
-		$message->numParams( count( $items ) );
86
-		$message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) );
83
+		$message = wfMessage('wbqc-violation-message-one-of');
84
+		$message->rawParams($this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE));
85
+		$message->numParams(count($items));
86
+		$message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT));
87 87
 		$message = $message->escaped();
88 88
 		$status = CheckResult::STATUS_VIOLATION;
89 89
 
90
-		foreach ( $items as $item ) {
91
-			if ( $item->matchesSnak( $snak ) ) {
90
+		foreach ($items as $item) {
91
+			if ($item->matchesSnak($snak)) {
92 92
 				$message = null;
93 93
 				$status = CheckResult::STATUS_COMPLIANCE;
94 94
 				break;
95 95
 			}
96 96
 		}
97 97
 
98
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
98
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
99 99
 	}
100 100
 
101
-	public function checkConstraintParameters( Constraint $constraint ) {
101
+	public function checkConstraintParameters(Constraint $constraint) {
102 102
 		$constraintParameters = $constraint->getConstraintParameters();
103 103
 		$exceptions = [];
104 104
 		try {
105
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true );
106
-		} catch ( ConstraintParameterException $e ) {
105
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true);
106
+		} catch (ConstraintParameterException $e) {
107 107
 			$exceptions[] = $e;
108 108
 		}
109 109
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/InverseChecker.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -90,22 +90,22 @@  discard block
 block discarded – undo
90 90
 	 * @throws ConstraintParameterException
91 91
 	 * @return CheckResult
92 92
 	 */
93
-	public function checkConstraint( Context $context, Constraint $constraint ) {
94
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
95
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
93
+	public function checkConstraint(Context $context, Constraint $constraint) {
94
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
95
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
96 96
 		}
97 97
 
98 98
 		$parameters = [];
99 99
 		$constraintParameters = $constraint->getConstraintParameters();
100 100
 
101
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
102
-		$parameters['property'] = [ $propertyId ];
101
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
102
+		$parameters['property'] = [$propertyId];
103 103
 
104 104
 		$snak = $context->getSnak();
105 105
 
106
-		if ( !$snak instanceof PropertyValueSnak ) {
106
+		if (!$snak instanceof PropertyValueSnak) {
107 107
 			// nothing to check
108
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
108
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
109 109
 		}
110 110
 
111 111
 		$dataValue = $snak->getDataValue();
@@ -114,22 +114,22 @@  discard block
 block discarded – undo
114 114
 		 * error handling:
115 115
 		 *   type of $dataValue for properties with 'Inverse' constraint has to be 'wikibase-entityid'
116 116
 		 */
117
-		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
118
-			$message = wfMessage( "wbqc-violation-message-value-needed-of-type" )
117
+		if ($dataValue->getType() !== 'wikibase-entityid') {
118
+			$message = wfMessage("wbqc-violation-message-value-needed-of-type")
119 119
 					 ->rawParams(
120
-						 $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
120
+						 $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM),
121 121
 						 'wikibase-entityid' // TODO is there a message for this type so we can localize it?
122 122
 					 )
123 123
 					 ->escaped();
124
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
124
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
125 125
 		}
126 126
 		/** @var EntityIdValue $dataValue */
127 127
 
128 128
 		$targetEntityId = $dataValue->getEntityId();
129
-		$targetEntity = $this->entityLookup->getEntity( $targetEntityId );
130
-		if ( $targetEntity === null ) {
131
-			$message = new ViolationMessage( 'wbqc-violation-message-target-entity-must-exist' );
132
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
129
+		$targetEntity = $this->entityLookup->getEntity($targetEntityId);
130
+		if ($targetEntity === null) {
131
+			$message = new ViolationMessage('wbqc-violation-message-target-entity-must-exist');
132
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
133 133
 		}
134 134
 
135 135
 		$inverseStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue(
@@ -137,31 +137,31 @@  discard block
 block discarded – undo
137 137
 			$propertyId,
138 138
 			$context->getEntity()->getId()
139 139
 		);
140
-		if ( $inverseStatement !== null ) {
140
+		if ($inverseStatement !== null) {
141 141
 			$message = null;
142 142
 			$status = CheckResult::STATUS_COMPLIANCE;
143 143
 		} else {
144
-			$message = wfMessage( 'wbqc-violation-message-inverse' )
144
+			$message = wfMessage('wbqc-violation-message-inverse')
145 145
 					 ->rawParams(
146
-						 $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ),
147
-						 $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ),
148
-						 $this->constraintParameterRenderer->formatEntityId( $context->getEntity()->getId(), Role::OBJECT )
146
+						 $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT),
147
+						 $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE),
148
+						 $this->constraintParameterRenderer->formatEntityId($context->getEntity()->getId(), Role::OBJECT)
149 149
 					 )
150 150
 					 ->escaped();
151 151
 			$status = CheckResult::STATUS_VIOLATION;
152 152
 		}
153 153
 
154
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
155
-			->withMetadata( Metadata::ofDependencyMetadata(
156
-				DependencyMetadata::ofEntityId( $targetEntityId ) ) );
154
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
155
+			->withMetadata(Metadata::ofDependencyMetadata(
156
+				DependencyMetadata::ofEntityId($targetEntityId) ));
157 157
 	}
158 158
 
159
-	public function checkConstraintParameters( Constraint $constraint ) {
159
+	public function checkConstraintParameters(Constraint $constraint) {
160 160
 		$constraintParameters = $constraint->getConstraintParameters();
161 161
 		$exceptions = [];
162 162
 		try {
163
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
164
-		} catch ( ConstraintParameterException $e ) {
163
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
164
+		} catch (ConstraintParameterException $e) {
165 165
 			$exceptions[] = $e;
166 166
 		}
167 167
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ValueTypeChecker.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -98,37 +98,37 @@  discard block
 block discarded – undo
98 98
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
99 99
 	 * @return CheckResult
100 100
 	 */
101
-	public function checkConstraint( Context $context, Constraint $constraint ) {
102
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
103
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
101
+	public function checkConstraint(Context $context, Constraint $constraint) {
102
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
103
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
104 104
 		}
105 105
 
106 106
 		$parameters = [];
107 107
 		$constraintParameters = $constraint->getConstraintParameters();
108 108
 
109
-		$classes = $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
109
+		$classes = $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
110 110
 		$parameters['class'] = array_map(
111
-			function( $id ) {
112
-				return new ItemId( $id );
111
+			function($id) {
112
+				return new ItemId($id);
113 113
 			},
114 114
 			$classes
115 115
 		);
116 116
 
117
-		$relation = $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
117
+		$relation = $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
118 118
 		$relationIds = [];
119
-		if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) {
120
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
119
+		if ($relation === 'instance' || $relation === 'instanceOrSubclass') {
120
+			$relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId');
121 121
 		}
122
-		if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) {
123
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
122
+		if ($relation === 'subclass' || $relation === 'instanceOrSubclass') {
123
+			$relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId');
124 124
 		}
125
-		$parameters['relation'] = [ $relation ];
125
+		$parameters['relation'] = [$relation];
126 126
 
127 127
 		$snak = $context->getSnak();
128 128
 
129
-		if ( !$snak instanceof PropertyValueSnak ) {
129
+		if (!$snak instanceof PropertyValueSnak) {
130 130
 			// nothing to check
131
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
131
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
132 132
 		}
133 133
 
134 134
 		$dataValue = $snak->getDataValue();
@@ -137,22 +137,22 @@  discard block
 block discarded – undo
137 137
 		 * error handling:
138 138
 		 *   type of $dataValue for properties with 'Value type' constraint has to be 'wikibase-entityid'
139 139
 		 */
140
-		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
141
-			$message = wfMessage( "wbqc-violation-message-value-needed-of-type" )
140
+		if ($dataValue->getType() !== 'wikibase-entityid') {
141
+			$message = wfMessage("wbqc-violation-message-value-needed-of-type")
142 142
 				->rawParams(
143
-					$this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ),
143
+					$this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM),
144 144
 					'wikibase-entityid' // TODO is there a message for this type so we can localize it?
145 145
 				)
146 146
 				->escaped();
147
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
147
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
148 148
 		}
149 149
 		/** @var EntityIdValue $dataValue */
150 150
 
151
-		$item = $this->entityLookup->getEntity( $dataValue->getEntityId() );
151
+		$item = $this->entityLookup->getEntity($dataValue->getEntityId());
152 152
 
153
-		if ( !( $item instanceof StatementListProvider ) ) {
154
-			$message = new ViolationMessage( 'wbqc-violation-message-value-entity-must-exist' );
155
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
153
+		if (!($item instanceof StatementListProvider)) {
154
+			$message = new ViolationMessage('wbqc-violation-message-value-entity-must-exist');
155
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
156 156
 		}
157 157
 
158 158
 		$statements = $item->getStatements();
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 			$classes
164 164
 		);
165 165
 
166
-		if ( $result->getBool() ) {
166
+		if ($result->getBool()) {
167 167
 			$message = null;
168 168
 			$status = CheckResult::STATUS_COMPLIANCE;
169 169
 		} else {
@@ -177,21 +177,21 @@  discard block
 block discarded – undo
177 177
 			$status = CheckResult::STATUS_VIOLATION;
178 178
 		}
179 179
 
180
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
181
-			->withMetadata( $result->getMetadata() );
180
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
181
+			->withMetadata($result->getMetadata());
182 182
 	}
183 183
 
184
-	public function checkConstraintParameters( Constraint $constraint ) {
184
+	public function checkConstraintParameters(Constraint $constraint) {
185 185
 		$constraintParameters = $constraint->getConstraintParameters();
186 186
 		$exceptions = [];
187 187
 		try {
188
-			$this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
189
-		} catch ( ConstraintParameterException $e ) {
188
+			$this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
189
+		} catch (ConstraintParameterException $e) {
190 190
 			$exceptions[] = $e;
191 191
 		}
192 192
 		try {
193
-			$this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
194
-		} catch ( ConstraintParameterException $e ) {
193
+			$this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
194
+		} catch (ConstraintParameterException $e) {
195 195
 			$exceptions[] = $e;
196 196
 		}
197 197
 		return $exceptions;
Please login to merge, or discard this patch.