Completed
Push — master ( da1419...363a80 )
by
unknown
05:28
created
src/ConstraintCheck/Checker/CommonsLinkChecker.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -79,22 +79,22 @@  discard block
 block discarded – undo
79 79
 	 * @return array first element is the namespace number (default namespace for TitleParser),
80 80
 	 * second element is a string to prepend to the title before giving it to the TitleParser
81 81
 	 */
82
-	private function getCommonsNamespace( $namespace ) {
82
+	private function getCommonsNamespace($namespace) {
83 83
 		// for namespace numbers see mediawiki-config repo, wmf-config/InitialiseSettings.php,
84 84
 		// 'wgExtraNamespaces' key, 'commonswiki' subkey
85
-		switch ( $namespace ) {
85
+		switch ($namespace) {
86 86
 			case '':
87
-				return [ NS_MAIN, '' ];
87
+				return [NS_MAIN, ''];
88 88
 			case 'Creator':
89
-				return [ 100, '' ];
89
+				return [100, ''];
90 90
 			case 'TimedText':
91
-				return [ 102, '' ];
91
+				return [102, ''];
92 92
 			case 'Sequence':
93
-				return [ 104, '' ];
93
+				return [104, ''];
94 94
 			case 'Institution':
95
-				return [ 106, '' ];
95
+				return [106, ''];
96 96
 			default:
97
-				return [ NS_MAIN, $namespace . ':' ];
97
+				return [NS_MAIN, $namespace.':'];
98 98
 		}
99 99
 	}
100 100
 
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
 	 * @throws ConstraintParameterException
108 108
 	 * @return CheckResult
109 109
 	 */
110
-	public function checkConstraint( Context $context, Constraint $constraint ) {
110
+	public function checkConstraint(Context $context, Constraint $constraint) {
111 111
 		$parameters = [];
112 112
 		$constraintParameters = $constraint->getConstraintParameters();
113
-		$namespace = $this->constraintParameterParser->parseNamespaceParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
114
-		$parameters['namespace'] = [ $namespace ];
113
+		$namespace = $this->constraintParameterParser->parseNamespaceParameter($constraintParameters, $constraint->getConstraintTypeItemId());
114
+		$parameters['namespace'] = [$namespace];
115 115
 
116 116
 		$snak = $context->getSnak();
117 117
 
118
-		if ( !$snak instanceof PropertyValueSnak ) {
118
+		if (!$snak instanceof PropertyValueSnak) {
119 119
 			// nothing to check
120
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
120
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
121 121
 		}
122 122
 
123 123
 		$dataValue = $snak->getDataValue();
@@ -127,46 +127,46 @@  discard block
 block discarded – undo
127 127
 		 *   type of $dataValue for properties with 'Commons link' constraint has to be 'string'
128 128
 		 *   parameter $namespace can be null, works for commons galleries
129 129
 		 */
130
-		if ( $dataValue->getType() !== 'string' ) {
131
-			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
132
-				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
133
-				->withDataValueType( 'string' );
134
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
130
+		if ($dataValue->getType() !== 'string') {
131
+			$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type'))
132
+				->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM)
133
+				->withDataValueType('string');
134
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
135 135
 		}
136 136
 
137 137
 		$commonsLink = $dataValue->getValue();
138 138
 
139 139
 		try {
140
-			if ( !$this->commonsLinkIsWellFormed( $commonsLink ) ) {
141
-				throw new MalformedTitleException( 'wbqc-violation-message-commons-link-not-well-formed', $commonsLink ); // caught below
140
+			if (!$this->commonsLinkIsWellFormed($commonsLink)) {
141
+				throw new MalformedTitleException('wbqc-violation-message-commons-link-not-well-formed', $commonsLink); // caught below
142 142
 			}
143
-			list( $defaultNamespace, $prefix ) = $this->getCommonsNamespace( $namespace );
144
-			$title = $this->titleParser->parseTitle( $prefix . $commonsLink, $defaultNamespace );
145
-			if ( $this->pageExists( $title ) ) {
143
+			list($defaultNamespace, $prefix) = $this->getCommonsNamespace($namespace);
144
+			$title = $this->titleParser->parseTitle($prefix.$commonsLink, $defaultNamespace);
145
+			if ($this->pageExists($title)) {
146 146
 				$message = null;
147 147
 				$status = CheckResult::STATUS_COMPLIANCE;
148 148
 			} else {
149
-				if ( $this->valueIncludesNamespace( $commonsLink, $namespace ) ) {
150
-					throw new MalformedTitleException( 'wbqc-violation-message-commons-link-not-well-formed', $commonsLink ); // caught below
149
+				if ($this->valueIncludesNamespace($commonsLink, $namespace)) {
150
+					throw new MalformedTitleException('wbqc-violation-message-commons-link-not-well-formed', $commonsLink); // caught below
151 151
 				} else {
152
-					$message = new ViolationMessage( 'wbqc-violation-message-commons-link-no-existent' );
152
+					$message = new ViolationMessage('wbqc-violation-message-commons-link-no-existent');
153 153
 					$status = CheckResult::STATUS_VIOLATION;
154 154
 				}
155 155
 			}
156
-		} catch ( MalformedTitleException $e ) {
157
-			$message = new ViolationMessage( 'wbqc-violation-message-commons-link-not-well-formed' );
156
+		} catch (MalformedTitleException $e) {
157
+			$message = new ViolationMessage('wbqc-violation-message-commons-link-not-well-formed');
158 158
 			$status = CheckResult::STATUS_VIOLATION;
159 159
 		}
160 160
 
161
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
161
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
162 162
 	}
163 163
 
164
-	public function checkConstraintParameters( Constraint $constraint ) {
164
+	public function checkConstraintParameters(Constraint $constraint) {
165 165
 		$constraintParameters = $constraint->getConstraintParameters();
166 166
 		$exceptions = [];
167 167
 		try {
168
-			$this->constraintParameterParser->parseNamespaceParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
169
-		} catch ( ConstraintParameterException $e ) {
168
+			$this->constraintParameterParser->parseNamespaceParameter($constraintParameters, $constraint->getConstraintTypeItemId());
169
+		} catch (ConstraintParameterException $e) {
170 170
 			$exceptions[] = $e;
171 171
 		}
172 172
 		return $exceptions;
@@ -177,19 +177,19 @@  discard block
 block discarded – undo
177 177
 	 *
178 178
 	 * @return bool
179 179
 	 */
180
-	private function pageExists( TitleValue $title ) {
180
+	private function pageExists(TitleValue $title) {
181 181
 		$commonsWikiId = 'commonswiki';
182
-		if ( defined( 'MW_PHPUNIT_TEST' ) ) {
182
+		if (defined('MW_PHPUNIT_TEST')) {
183 183
 			$commonsWikiId = false;
184 184
 		}
185 185
 
186
-		$dbLoadBalancer = wfGetLB( $commonsWikiId );
186
+		$dbLoadBalancer = wfGetLB($commonsWikiId);
187 187
 		$dbConnection = $dbLoadBalancer->getConnection(
188 188
 			DB_REPLICA, false, $commonsWikiId );
189
-		$row = $dbConnection->selectRow( 'page', '*', [
189
+		$row = $dbConnection->selectRow('page', '*', [
190 190
 			'page_title' => $title->getDBkey(),
191 191
 			'page_namespace' => $title->getNamespace()
192
-		] );
192
+		]);
193 193
 
194 194
 		return $row !== false;
195 195
 	}
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return bool
201 201
 	 */
202
-	private function commonsLinkIsWellFormed( $commonsLink ) {
203
-		$toReplace = [ "_", "%20" ];
204
-		$compareString = trim( str_replace( $toReplace, '', $commonsLink ) );
202
+	private function commonsLinkIsWellFormed($commonsLink) {
203
+		$toReplace = ["_", "%20"];
204
+		$compareString = trim(str_replace($toReplace, '', $commonsLink));
205 205
 		return $commonsLink === $compareString;
206 206
 	}
207 207
 
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
 	 *
215 215
 	 * @return bool
216 216
 	 */
217
-	private function valueIncludesNamespace( $value, $namespace ) {
217
+	private function valueIncludesNamespace($value, $namespace) {
218 218
 		return $namespace !== '' &&
219
-			strncasecmp( $value, $namespace . ':', strlen( $namespace ) + 1 ) === 0;
219
+			strncasecmp($value, $namespace.':', strlen($namespace) + 1) === 0;
220 220
 	}
221 221
 
222 222
 }
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
@@ -85,9 +85,9 @@  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 = [];
@@ -95,32 +95,32 @@  discard block
 block discarded – undo
95 95
 
96 96
 		$snak = $context->getSnak();
97 97
 
98
-		if ( !$snak instanceof PropertyValueSnak ) {
98
+		if (!$snak instanceof PropertyValueSnak) {
99 99
 			// nothing to check
100
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
100
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
101 101
 		}
102 102
 
103 103
 		$dataValue = $snak->getDataValue();
104 104
 
105
-		list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter(
105
+		list($min, $max) = $this->constraintParameterParser->parseRangeParameter(
106 106
 			$constraintParameters,
107 107
 			$constraint->getConstraintTypeItemId(),
108 108
 			$dataValue->getType()
109 109
 		);
110 110
 		$parameterKey = $dataValue->getType() === 'quantity' ? 'quantity' : 'date';
111
-		if ( $min !== null ) {
112
-			$parameters['minimum_' . $parameterKey] = [ $min ];
111
+		if ($min !== null) {
112
+			$parameters['minimum_'.$parameterKey] = [$min];
113 113
 		}
114
-		if ( $max !== null ) {
115
-			$parameters['maximum_' . $parameterKey] = [ $max ];
114
+		if ($max !== null) {
115
+			$parameters['maximum_'.$parameterKey] = [$max];
116 116
 		}
117 117
 
118
-		if ( $this->rangeCheckerHelper->getComparison( $min, $dataValue ) > 0 ||
119
-			 $this->rangeCheckerHelper->getComparison( $dataValue, $max ) > 0
118
+		if ($this->rangeCheckerHelper->getComparison($min, $dataValue) > 0 ||
119
+			 $this->rangeCheckerHelper->getComparison($dataValue, $max) > 0
120 120
 		) {
121 121
 			// at least one of $min, $max is set at this point, otherwise there could be no violation
122 122
 			$type = $dataValue->getType();
123
-			$openness = $min !== null ? ( $max !== null ? 'closed' : 'rightopen' ) : 'leftopen';
123
+			$openness = $min !== null ? ($max !== null ? 'closed' : 'rightopen') : 'leftopen';
124 124
 			// possible message keys:
125 125
 			// wbqc-violation-message-range-quantity-closed
126 126
 			// wbqc-violation-message-range-quantity-leftopen
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 			// wbqc-violation-message-range-time-closed
129 129
 			// wbqc-violation-message-range-time-leftopen
130 130
 			// wbqc-violation-message-range-time-rightopen
131
-			$message = ( new ViolationMessage( "wbqc-violation-message-range-$type-$openness" ) )
132
-				->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE )
133
-				->withDataValue( $dataValue, Role::OBJECT );
134
-			if ( $min !== null ) {
135
-				$message = $message->withDataValue( $min, Role::OBJECT );
131
+			$message = (new ViolationMessage("wbqc-violation-message-range-$type-$openness"))
132
+				->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)
133
+				->withDataValue($dataValue, Role::OBJECT);
134
+			if ($min !== null) {
135
+				$message = $message->withDataValue($min, Role::OBJECT);
136 136
 			}
137
-			if ( $max !== null ) {
138
-				$message = $message->withDataValue( $max, Role::OBJECT );
137
+			if ($max !== null) {
138
+				$message = $message->withDataValue($max, Role::OBJECT);
139 139
 			}
140 140
 			$status = CheckResult::STATUS_VIOLATION;
141 141
 		} else {
@@ -143,22 +143,22 @@  discard block
 block discarded – undo
143 143
 			$status = CheckResult::STATUS_COMPLIANCE;
144 144
 		}
145 145
 
146
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
146
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
147 147
 	}
148 148
 
149
-	public function checkConstraintParameters( Constraint $constraint ) {
149
+	public function checkConstraintParameters(Constraint $constraint) {
150 150
 		$constraintParameters = $constraint->getConstraintParameters();
151 151
 		$exceptions = [];
152 152
 		try {
153 153
 			// we don’t have a data value here, so get the type from the property instead
154 154
 			// (the distinction between data type and data value type is irrelevant for 'quantity' and 'time')
155
-			$type = $this->propertyDataTypeLookup->getDataTypeIdForProperty( $constraint->getPropertyId() );
155
+			$type = $this->propertyDataTypeLookup->getDataTypeIdForProperty($constraint->getPropertyId());
156 156
 			$this->constraintParameterParser->parseRangeParameter(
157 157
 				$constraintParameters,
158 158
 				$constraint->getConstraintTypeItemId(),
159 159
 				$type
160 160
 			);
161
-		} catch ( ConstraintParameterException $e ) {
161
+		} catch (ConstraintParameterException $e) {
162 162
 			$exceptions[] = $e;
163 163
 		}
164 164
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/InverseChecker.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -91,22 +91,22 @@  discard block
 block discarded – undo
91 91
 	 * @throws ConstraintParameterException
92 92
 	 * @return CheckResult
93 93
 	 */
94
-	public function checkConstraint( Context $context, Constraint $constraint ) {
95
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
96
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
94
+	public function checkConstraint(Context $context, Constraint $constraint) {
95
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
96
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
97 97
 		}
98 98
 
99 99
 		$parameters = [];
100 100
 		$constraintParameters = $constraint->getConstraintParameters();
101 101
 
102
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
103
-		$parameters['property'] = [ $propertyId ];
102
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
103
+		$parameters['property'] = [$propertyId];
104 104
 
105 105
 		$snak = $context->getSnak();
106 106
 
107
-		if ( !$snak instanceof PropertyValueSnak ) {
107
+		if (!$snak instanceof PropertyValueSnak) {
108 108
 			// nothing to check
109
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
109
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
110 110
 		}
111 111
 
112 112
 		$dataValue = $snak->getDataValue();
@@ -115,19 +115,19 @@  discard block
 block discarded – undo
115 115
 		 * error handling:
116 116
 		 *   type of $dataValue for properties with 'Inverse' constraint has to be 'wikibase-entityid'
117 117
 		 */
118
-		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
119
-			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
120
-				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
121
-				->withDataValueType( 'wikibase-entityid' );
122
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
118
+		if ($dataValue->getType() !== 'wikibase-entityid') {
119
+			$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type'))
120
+				->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM)
121
+				->withDataValueType('wikibase-entityid');
122
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
123 123
 		}
124 124
 		/** @var EntityIdValue $dataValue */
125 125
 
126 126
 		$targetEntityId = $dataValue->getEntityId();
127
-		$targetEntity = $this->entityLookup->getEntity( $targetEntityId );
128
-		if ( $targetEntity === null ) {
129
-			$message = new ViolationMessage( 'wbqc-violation-message-target-entity-must-exist' );
130
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
127
+		$targetEntity = $this->entityLookup->getEntity($targetEntityId);
128
+		if ($targetEntity === null) {
129
+			$message = new ViolationMessage('wbqc-violation-message-target-entity-must-exist');
130
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
131 131
 		}
132 132
 
133 133
 		$inverseStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue(
@@ -135,28 +135,28 @@  discard block
 block discarded – undo
135 135
 			$propertyId,
136 136
 			$context->getEntity()->getId()
137 137
 		);
138
-		if ( $inverseStatement !== null ) {
138
+		if ($inverseStatement !== null) {
139 139
 			$message = null;
140 140
 			$status = CheckResult::STATUS_COMPLIANCE;
141 141
 		} else {
142
-			$message = ( new ViolationMessage( 'wbqc-violation-message-inverse' ) )
143
-				->withEntityId( $targetEntityId, Role::SUBJECT )
144
-				->withEntityId( $propertyId, Role::PREDICATE )
145
-				->withEntityId( $context->getEntity()->getId(), Role::OBJECT );
142
+			$message = (new ViolationMessage('wbqc-violation-message-inverse'))
143
+				->withEntityId($targetEntityId, Role::SUBJECT)
144
+				->withEntityId($propertyId, Role::PREDICATE)
145
+				->withEntityId($context->getEntity()->getId(), Role::OBJECT);
146 146
 			$status = CheckResult::STATUS_VIOLATION;
147 147
 		}
148 148
 
149
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
150
-			->withMetadata( Metadata::ofDependencyMetadata(
151
-				DependencyMetadata::ofEntityId( $targetEntityId ) ) );
149
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
150
+			->withMetadata(Metadata::ofDependencyMetadata(
151
+				DependencyMetadata::ofEntityId($targetEntityId) ));
152 152
 	}
153 153
 
154
-	public function checkConstraintParameters( Constraint $constraint ) {
154
+	public function checkConstraintParameters(Constraint $constraint) {
155 155
 		$constraintParameters = $constraint->getConstraintParameters();
156 156
 		$exceptions = [];
157 157
 		try {
158
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
159
-		} catch ( ConstraintParameterException $e ) {
158
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
159
+		} catch (ConstraintParameterException $e) {
160 160
 			$exceptions[] = $e;
161 161
 		}
162 162
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ValueTypeChecker.php 1 patch
Spacing   +31 added lines, -31 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,19 +137,19 @@  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 = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
142
-				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
143
-				->withDataValueType( 'wikibase-entityid' );
144
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
140
+		if ($dataValue->getType() !== 'wikibase-entityid') {
141
+			$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type'))
142
+				->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM)
143
+				->withDataValueType('wikibase-entityid');
144
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
145 145
 		}
146 146
 		/** @var EntityIdValue $dataValue */
147 147
 
148
-		$item = $this->entityLookup->getEntity( $dataValue->getEntityId() );
148
+		$item = $this->entityLookup->getEntity($dataValue->getEntityId());
149 149
 
150
-		if ( !( $item instanceof StatementListProvider ) ) {
151
-			$message = new ViolationMessage( 'wbqc-violation-message-value-entity-must-exist' );
152
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
150
+		if (!($item instanceof StatementListProvider)) {
151
+			$message = new ViolationMessage('wbqc-violation-message-value-entity-must-exist');
152
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
153 153
 		}
154 154
 
155 155
 		$statements = $item->getStatements();
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			$classes
161 161
 		);
162 162
 
163
-		if ( $result->getBool() ) {
163
+		if ($result->getBool()) {
164 164
 			$message = null;
165 165
 			$status = CheckResult::STATUS_COMPLIANCE;
166 166
 		} else {
@@ -174,21 +174,21 @@  discard block
 block discarded – undo
174 174
 			$status = CheckResult::STATUS_VIOLATION;
175 175
 		}
176 176
 
177
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
178
-			->withMetadata( $result->getMetadata() );
177
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
178
+			->withMetadata($result->getMetadata());
179 179
 	}
180 180
 
181
-	public function checkConstraintParameters( Constraint $constraint ) {
181
+	public function checkConstraintParameters(Constraint $constraint) {
182 182
 		$constraintParameters = $constraint->getConstraintParameters();
183 183
 		$exceptions = [];
184 184
 		try {
185
-			$this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
186
-		} catch ( ConstraintParameterException $e ) {
185
+			$this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId());
186
+		} catch (ConstraintParameterException $e) {
187 187
 			$exceptions[] = $e;
188 188
 		}
189 189
 		try {
190
-			$this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
191
-		} catch ( ConstraintParameterException $e ) {
190
+			$this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId());
191
+		} catch (ConstraintParameterException $e) {
192 192
 			$exceptions[] = $e;
193 193
 		}
194 194
 		return $exceptions;
Please login to merge, or discard this patch.