Completed
Push — master ( 5e8a55...b1fecf )
by
unknown
12:06 queued 07:10
created
src/Api/CheckConstraints.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -77,21 +77,21 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return self
79 79
 	 */
80
-	public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) {
80
+	public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') {
81 81
 		$repo = WikibaseRepo::getDefaultInstance();
82 82
 
83 83
 		$language = $repo->getUserLanguage();
84 84
 		$formatterOptions = new FormatterOptions();
85
-		$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() );
85
+		$formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode());
86 86
 		$valueFormatterFactory = $repo->getValueFormatterFactory();
87
-		$valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions );
87
+		$valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions);
88 88
 
89 89
 		$languageFallbackLabelDescriptionLookupFactory = $repo->getLanguageFallbackLabelDescriptionLookupFactory();
90
-		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup( $language );
90
+		$labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup($language);
91 91
 		$entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory();
92
-		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
92
+		$entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
93 93
 		$entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory();
94
-		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup );
94
+		$entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelDescriptionLookup);
95 95
 		$config = MediaWikiServices::getInstance()->getMainConfig();
96 96
 		$titleParser = MediaWikiServices::getInstance()->getTitleParser();
97 97
 		$unitConverter = $repo->getUnitConverter();
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 			$repo->getEntityTitleLookup(),
125 125
 			$entityIdLabelFormatter,
126 126
 			$constraintParameterRenderer,
127
-			new ViolationMessageRenderer( $entityIdHtmlLinkFormatter, $valueFormatter ),
127
+			new ViolationMessageRenderer($entityIdHtmlLinkFormatter, $valueFormatter),
128 128
 			$config
129 129
 		);
130
-		if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) {
130
+		if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) {
131 131
 			$wikiPageEntityMetaDataAccessor = new WikiPageEntityMetaDataLookup(
132 132
 				$repo->getEntityNamespaceLookup()
133 133
 			);
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
 				ResultsCache::getDefaultInstance(),
139 139
 				$wikiPageEntityMetaDataAccessor,
140 140
 				$entityIdParser,
141
-				$config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ),
141
+				$config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'),
142 142
 				[
143
-					$config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ),
144
-					$config->get( 'WBQualityConstraintsTypeConstraintId' ),
145
-					$config->get( 'WBQualityConstraintsValueTypeConstraintId' ),
146
-					$config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ),
143
+					$config->get('WBQualityConstraintsCommonsLinkConstraintId'),
144
+					$config->get('WBQualityConstraintsTypeConstraintId'),
145
+					$config->get('WBQualityConstraintsValueTypeConstraintId'),
146
+					$config->get('WBQualityConstraintsDistinctValuesConstraintId'),
147 147
 				],
148 148
 				$dataFactory
149 149
 			);
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			$prefix,
156 156
 			$repo->getEntityIdParser(),
157 157
 			$repo->getStatementGuidValidator(),
158
-			$repo->getApiHelperFactory( RequestContext::getMain() ),
158
+			$repo->getApiHelperFactory(RequestContext::getMain()),
159 159
 			$resultsBuilder,
160 160
 			$dataFactory
161 161
 		);
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 		ResultsBuilder $resultsBuilder,
182 182
 		IBufferingStatsdDataFactory $dataFactory
183 183
 	) {
184
-		parent::__construct( $main, $name, $prefix );
184
+		parent::__construct($main, $name, $prefix);
185 185
 		$this->entityIdParser = $entityIdParser;
186 186
 		$this->statementGuidValidator = $statementGuidValidator;
187
-		$this->resultBuilder = $apiHelperFactory->getResultBuilder( $this );
188
-		$this->errorReporter = $apiHelperFactory->getErrorReporter( $this );
187
+		$this->resultBuilder = $apiHelperFactory->getResultBuilder($this);
188
+		$this->errorReporter = $apiHelperFactory->getErrorReporter($this);
189 189
 		$this->resultsBuilder = $resultsBuilder;
190 190
 		$this->dataFactory = $dataFactory;
191 191
 	}
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
 
201 201
 		$params = $this->extractRequestParams();
202 202
 
203
-		$this->validateParameters( $params );
204
-		$entityIds = $this->parseEntityIds( $params );
205
-		$claimIds = $this->parseClaimIds( $params );
203
+		$this->validateParameters($params);
204
+		$entityIds = $this->parseEntityIds($params);
205
+		$claimIds = $this->parseClaimIds($params);
206 206
 		$constraintIDs = $params[self::PARAM_CONSTRAINT_ID];
207 207
 		$statuses = $params[self::PARAM_STATUS];
208 208
 
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
 			)->getArray()
218 218
 		);
219 219
 		// ensure that result contains the given entity IDs even if they have no statements
220
-		foreach ( $entityIds as $entityId ) {
220
+		foreach ($entityIds as $entityId) {
221 221
 			$this->getResult()->addArrayType(
222
-				[ $this->getModuleName(), $entityId->getSerialization() ],
222
+				[$this->getModuleName(), $entityId->getSerialization()],
223 223
 				'assoc'
224 224
 			);
225 225
 		}
226
-		$this->resultBuilder->markSuccess( 1 );
226
+		$this->resultBuilder->markSuccess(1);
227 227
 	}
228 228
 
229 229
 	/**
@@ -231,24 +231,24 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @return EntityId[]
233 233
 	 */
234
-	private function parseEntityIds( array $params ) {
234
+	private function parseEntityIds(array $params) {
235 235
 		$ids = $params[self::PARAM_ID];
236 236
 
237
-		if ( $ids === null ) {
237
+		if ($ids === null) {
238 238
 			return [];
239
-		} elseif ( $ids === [] ) {
239
+		} elseif ($ids === []) {
240 240
 			$this->errorReporter->dieError(
241
-				'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' );
241
+				'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' );
242 242
 		}
243 243
 
244
-		return array_map( function ( $id ) {
244
+		return array_map(function($id) {
245 245
 			try {
246
-				return $this->entityIdParser->parse( $id );
247
-			} catch ( EntityIdParsingException $e ) {
246
+				return $this->entityIdParser->parse($id);
247
+			} catch (EntityIdParsingException $e) {
248 248
 				$this->errorReporter->dieError(
249
-					"Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] );
249
+					"Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] );
250 250
 			}
251
-		}, $ids );
251
+		}, $ids);
252 252
 	}
253 253
 
254 254
 	/**
@@ -256,35 +256,35 @@  discard block
 block discarded – undo
256 256
 	 *
257 257
 	 * @return string[]
258 258
 	 */
259
-	private function parseClaimIds( array $params ) {
259
+	private function parseClaimIds(array $params) {
260 260
 		$ids = $params[self::PARAM_CLAIM_ID];
261 261
 
262
-		if ( $ids === null ) {
262
+		if ($ids === null) {
263 263
 			return [];
264
-		} elseif ( $ids === [] ) {
264
+		} elseif ($ids === []) {
265 265
 			$this->errorReporter->dieError(
266
-				'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' );
266
+				'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' );
267 267
 		}
268 268
 
269
-		foreach ( $ids as $id ) {
270
-			if ( !$this->statementGuidValidator->validate( $id ) ) {
269
+		foreach ($ids as $id) {
270
+			if (!$this->statementGuidValidator->validate($id)) {
271 271
 				$this->errorReporter->dieError(
272
-					"Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] );
272
+					"Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] );
273 273
 			}
274 274
 		}
275 275
 
276 276
 		return $ids;
277 277
 	}
278 278
 
279
-	private function validateParameters( array $params ) {
280
-		if ( $params[self::PARAM_CONSTRAINT_ID] !== null
281
-			 && empty( $params[self::PARAM_CONSTRAINT_ID] )
279
+	private function validateParameters(array $params) {
280
+		if ($params[self::PARAM_CONSTRAINT_ID] !== null
281
+			 && empty($params[self::PARAM_CONSTRAINT_ID])
282 282
 		) {
283 283
 			$paramConstraintId = self::PARAM_CONSTRAINT_ID;
284 284
 			$this->errorReporter->dieError(
285 285
 				"If $paramConstraintId is specified, it must be nonempty.", 'no-data' );
286 286
 		}
287
-		if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) {
287
+		if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) {
288 288
 			$paramId = self::PARAM_ID;
289 289
 			$paramClaimId = self::PARAM_CLAIM_ID;
290 290
 			$this->errorReporter->dieError(
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/FormatChecker.php 1 patch
Spacing   +30 added lines, -31 removed lines patch added patch discarded remove patch
@@ -95,26 +95,26 @@  discard block
 block discarded – undo
95 95
 	 * @throws ConstraintParameterException
96 96
 	 * @return CheckResult
97 97
 	 */
98
-	public function checkConstraint( Context $context, Constraint $constraint ) {
98
+	public function checkConstraint(Context $context, Constraint $constraint) {
99 99
 		$parameters = [];
100 100
 		$constraintParameters = $constraint->getConstraintParameters();
101 101
 
102
-		$format = $this->constraintParameterParser->parseFormatParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
103
-		$parameters['pattern'] = [ $format ];
102
+		$format = $this->constraintParameterParser->parseFormatParameter($constraintParameters, $constraint->getConstraintTypeItemId());
103
+		$parameters['pattern'] = [$format];
104 104
 
105 105
 		$syntaxClarification = $this->constraintParameterParser->parseSyntaxClarificationParameter(
106 106
 			$constraintParameters,
107 107
 			WikibaseRepo::getDefaultInstance()->getUserLanguage() // TODO make this part of the Context?
108 108
 		);
109
-		if ( $syntaxClarification !== null ) {
110
-			$parameters['clarification'] = [ $syntaxClarification ];
109
+		if ($syntaxClarification !== null) {
110
+			$parameters['clarification'] = [$syntaxClarification];
111 111
 		}
112 112
 
113 113
 		$snak = $context->getSnak();
114 114
 
115
-		if ( !$snak instanceof PropertyValueSnak ) {
115
+		if (!$snak instanceof PropertyValueSnak) {
116 116
 			// nothing to check
117
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
117
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
118 118
 		}
119 119
 
120 120
 		$dataValue = $snak->getDataValue();
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		 * error handling:
124 124
 		 *   type of $dataValue for properties with 'Format' constraint has to be 'string' or 'monolingualtext'
125 125
 		 */
126
-		switch ( $dataValue->getType() ) {
126
+		switch ($dataValue->getType()) {
127 127
 			case 'string':
128 128
 				$text = $dataValue->getValue();
129 129
 				break;
@@ -132,56 +132,55 @@  discard block
 block discarded – undo
132 132
 				$text = $dataValue->getText();
133 133
 				break;
134 134
 			default:
135
-				$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-types-2' ) )
136
-					->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
137
-					->withDataValueType( 'string' )
138
-					->withDataValueType( 'monolingualtext' );
139
-				return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
135
+				$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-types-2'))
136
+					->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM)
137
+					->withDataValueType('string')
138
+					->withDataValueType('monolingualtext');
139
+				return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
140 140
 		}
141 141
 
142
-		if ( $this->sparqlHelper !== null && $this->config->get( 'WBQualityConstraintsCheckFormatConstraint' ) ) {
143
-			if ( $this->sparqlHelper->matchesRegularExpression( $text, $format ) ) {
142
+		if ($this->sparqlHelper !== null && $this->config->get('WBQualityConstraintsCheckFormatConstraint')) {
143
+			if ($this->sparqlHelper->matchesRegularExpression($text, $format)) {
144 144
 				$message = null;
145 145
 				$status = CheckResult::STATUS_COMPLIANCE;
146 146
 			} else {
147 147
 				$message = wfMessage(
148 148
 					$syntaxClarification !== null ?
149
-						'wbqc-violation-message-format-clarification' :
150
-						'wbqc-violation-message-format'
149
+						'wbqc-violation-message-format-clarification' : 'wbqc-violation-message-format'
151 150
 				)->rawParams(
152
-					$this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ),
153
-					$this->constraintParameterRenderer->formatDataValue( new StringValue( $text ), Role::OBJECT ),
154
-					$this->constraintParameterRenderer->formatByRole( Role::CONSTRAINT_PARAMETER_VALUE,
155
-						'<code><nowiki>' . htmlspecialchars( $format ) . '</nowiki></code>' )
151
+					$this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY),
152
+					$this->constraintParameterRenderer->formatDataValue(new StringValue($text), Role::OBJECT),
153
+					$this->constraintParameterRenderer->formatByRole(Role::CONSTRAINT_PARAMETER_VALUE,
154
+						'<code><nowiki>'.htmlspecialchars($format).'</nowiki></code>')
156 155
 				);
157
-				if ( $syntaxClarification !== null ) {
158
-					$message->params( $syntaxClarification );
156
+				if ($syntaxClarification !== null) {
157
+					$message->params($syntaxClarification);
159 158
 				}
160 159
 				$message = $message->escaped();
161 160
 				$status = CheckResult::STATUS_VIOLATION;
162 161
 			}
163 162
 		} else {
164
-			$message = ( new ViolationMessage( 'wbqc-violation-message-security-reason' ) )
165
-				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM );
163
+			$message = (new ViolationMessage('wbqc-violation-message-security-reason'))
164
+				->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM);
166 165
 			$status = CheckResult::STATUS_TODO;
167 166
 		}
168
-		return new CheckResult( $context, $constraint, $parameters, $status, $message );
167
+		return new CheckResult($context, $constraint, $parameters, $status, $message);
169 168
 	}
170 169
 
171
-	public function checkConstraintParameters( Constraint $constraint ) {
170
+	public function checkConstraintParameters(Constraint $constraint) {
172 171
 		$constraintParameters = $constraint->getConstraintParameters();
173 172
 		$exceptions = [];
174 173
 		try {
175
-			$this->constraintParameterParser->parseFormatParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
176
-		} catch ( ConstraintParameterException $e ) {
174
+			$this->constraintParameterParser->parseFormatParameter($constraintParameters, $constraint->getConstraintTypeItemId());
175
+		} catch (ConstraintParameterException $e) {
177 176
 			$exceptions[] = $e;
178 177
 		}
179 178
 		try {
180 179
 			$this->constraintParameterParser->parseSyntaxClarificationParameter(
181 180
 				$constraintParameters,
182
-				Language::factory( 'en' ) // errors are reported independent of language requested
181
+				Language::factory('en') // errors are reported independent of language requested
183 182
 			);
184
-		} catch ( ConstraintParameterException $e ) {
183
+		} catch (ConstraintParameterException $e) {
185 184
 			$exceptions[] = $e;
186 185
 		}
187 186
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/SymmetricChecker.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 	 *
82 82
 	 * @return CheckResult
83 83
 	 */
84
-	public function checkConstraint( Context $context, Constraint $constraint ) {
85
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
86
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
84
+	public function checkConstraint(Context $context, Constraint $constraint) {
85
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
86
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
87 87
 		}
88 88
 
89 89
 		$parameters = [];
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 		$snak = $context->getSnak();
92 92
 		$propertyId = $context->getSnak()->getPropertyId();
93 93
 
94
-		if ( !$snak instanceof PropertyValueSnak ) {
94
+		if (!$snak instanceof PropertyValueSnak) {
95 95
 			// nothing to check
96
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
96
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
97 97
 		}
98 98
 
99 99
 		$dataValue = $snak->getDataValue();
@@ -102,19 +102,19 @@  discard block
 block discarded – undo
102 102
 		 * error handling:
103 103
 		 *   type of $dataValue for properties with 'Symmetric' constraint has to be 'wikibase-entityid'
104 104
 		 */
105
-		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
106
-			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
107
-				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
108
-				->withDataValueType( 'wikibase-entityid' );
109
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
105
+		if ($dataValue->getType() !== 'wikibase-entityid') {
106
+			$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type'))
107
+				->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM)
108
+				->withDataValueType('wikibase-entityid');
109
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
110 110
 		}
111 111
 		/** @var EntityIdValue $dataValue */
112 112
 
113 113
 		$targetEntityId = $dataValue->getEntityId();
114
-		$targetEntity = $this->entityLookup->getEntity( $targetEntityId );
115
-		if ( $targetEntity === null ) {
116
-			$message = new ViolationMessage( 'wbqc-violation-message-target-entity-must-exist' );
117
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
114
+		$targetEntity = $this->entityLookup->getEntity($targetEntityId);
115
+		if ($targetEntity === null) {
116
+			$message = new ViolationMessage('wbqc-violation-message-target-entity-must-exist');
117
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
118 118
 		}
119 119
 
120 120
 		$symmetricStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue(
@@ -122,23 +122,23 @@  discard block
 block discarded – undo
122 122
 			$propertyId,
123 123
 			$context->getEntity()->getId()
124 124
 		);
125
-		if ( $symmetricStatement !== null ) {
125
+		if ($symmetricStatement !== null) {
126 126
 			$message = null;
127 127
 			$status = CheckResult::STATUS_COMPLIANCE;
128 128
 		} else {
129
-			$message = ( new ViolationMessage( 'wbqc-violation-message-symmetric' ) )
130
-				->withEntityId( $targetEntityId, Role::SUBJECT )
131
-				->withEntityId( $propertyId, Role::PREDICATE )
132
-				->withEntityId( $context->getEntity()->getId(), Role::OBJECT );
129
+			$message = (new ViolationMessage('wbqc-violation-message-symmetric'))
130
+				->withEntityId($targetEntityId, Role::SUBJECT)
131
+				->withEntityId($propertyId, Role::PREDICATE)
132
+				->withEntityId($context->getEntity()->getId(), Role::OBJECT);
133 133
 			$status = CheckResult::STATUS_VIOLATION;
134 134
 		}
135 135
 
136
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
137
-			->withMetadata( Metadata::ofDependencyMetadata(
138
-				DependencyMetadata::ofEntityId( $targetEntityId ) ) );
136
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
137
+			->withMetadata(Metadata::ofDependencyMetadata(
138
+				DependencyMetadata::ofEntityId($targetEntityId) ));
139 139
 	}
140 140
 
141
-	public function checkConstraintParameters( Constraint $constraint ) {
141
+	public function checkConstraintParameters(Constraint $constraint) {
142 142
 		// no parameters
143 143
 		return [];
144 144
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/TargetRequiredClaimChecker.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -89,25 +89,25 @@  discard block
 block discarded – undo
89 89
 	 * @throws ConstraintParameterException
90 90
 	 * @return CheckResult
91 91
 	 */
92
-	public function checkConstraint( Context $context, Constraint $constraint ) {
93
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
94
-			return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED );
92
+	public function checkConstraint(Context $context, Constraint $constraint) {
93
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
94
+			return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED);
95 95
 		}
96 96
 
97 97
 		$parameters = [];
98 98
 		$constraintParameters = $constraint->getConstraintParameters();
99 99
 
100
-		$propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
101
-		$parameters['property'] = [ $propertyId ];
100
+		$propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
101
+		$parameters['property'] = [$propertyId];
102 102
 
103
-		$items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
103
+		$items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
104 104
 		$parameters['items'] = $items;
105 105
 
106 106
 		$snak = $context->getSnak();
107 107
 
108
-		if ( !$snak instanceof PropertyValueSnak ) {
108
+		if (!$snak instanceof PropertyValueSnak) {
109 109
 			// nothing to check
110
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE );
110
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE);
111 111
 		}
112 112
 
113 113
 		$dataValue = $snak->getDataValue();
@@ -116,19 +116,19 @@  discard block
 block discarded – undo
116 116
 		 * error handling:
117 117
 		 *   type of $dataValue for properties with 'Target required claim' constraint has to be 'wikibase-entityid'
118 118
 		 */
119
-		if ( $dataValue->getType() !== 'wikibase-entityid' ) {
120
-			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
121
-				->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM )
122
-				->withDataValueType( 'wikibase-entityid' );
123
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
119
+		if ($dataValue->getType() !== 'wikibase-entityid') {
120
+			$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type'))
121
+				->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM)
122
+				->withDataValueType('wikibase-entityid');
123
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
124 124
 		}
125 125
 		/** @var EntityIdValue $dataValue */
126 126
 
127 127
 		$targetEntityId = $dataValue->getEntityId();
128
-		$targetEntity = $this->entityLookup->getEntity( $targetEntityId );
129
-		if ( $targetEntity === null ) {
130
-			$message = new ViolationMessage( 'wbqc-violation-message-target-entity-must-exist' );
131
-			return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message );
128
+		$targetEntity = $this->entityLookup->getEntity($targetEntityId);
129
+		if ($targetEntity === null) {
130
+			$message = new ViolationMessage('wbqc-violation-message-target-entity-must-exist');
131
+			return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message);
132 132
 		}
133 133
 
134 134
 		/*
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		 *   a) a property only
137 137
 		 *   b) a property and a number of items (each combination forming an individual claim)
138 138
 		 */
139
-		if ( $items === [] ) {
139
+		if ($items === []) {
140 140
 			$requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty(
141 141
 				$targetEntity->getStatements(),
142 142
 				$propertyId
@@ -149,33 +149,33 @@  discard block
 block discarded – undo
149 149
 			);
150 150
 		}
151 151
 
152
-		if ( $requiredStatement !== null ) {
152
+		if ($requiredStatement !== null) {
153 153
 			$status = CheckResult::STATUS_COMPLIANCE;
154 154
 			$message = null;
155 155
 		} else {
156 156
 			$status = CheckResult::STATUS_VIOLATION;
157
-			$message = ( new ViolationMessage( 'wbqc-violation-message-target-required-claim' ) )
158
-				->withEntityId( $targetEntityId, Role::SUBJECT )
159
-				->withEntityId( $propertyId, Role::PREDICATE )
160
-				->withItemIdSnakValueList( $items, Role::OBJECT );
157
+			$message = (new ViolationMessage('wbqc-violation-message-target-required-claim'))
158
+				->withEntityId($targetEntityId, Role::SUBJECT)
159
+				->withEntityId($propertyId, Role::PREDICATE)
160
+				->withItemIdSnakValueList($items, Role::OBJECT);
161 161
 		}
162 162
 
163
-		return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) )
164
-			->withMetadata( Metadata::ofDependencyMetadata(
165
-				DependencyMetadata::ofEntityId( $targetEntityId ) ) );
163
+		return (new CheckResult($context, $constraint, $parameters, $status, $message))
164
+			->withMetadata(Metadata::ofDependencyMetadata(
165
+				DependencyMetadata::ofEntityId($targetEntityId) ));
166 166
 	}
167 167
 
168
-	public function checkConstraintParameters( Constraint $constraint ) {
168
+	public function checkConstraintParameters(Constraint $constraint) {
169 169
 		$constraintParameters = $constraint->getConstraintParameters();
170 170
 		$exceptions = [];
171 171
 		try {
172
-			$this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() );
173
-		} catch ( ConstraintParameterException $e ) {
172
+			$this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId());
173
+		} catch (ConstraintParameterException $e) {
174 174
 			$exceptions[] = $e;
175 175
 		}
176 176
 		try {
177
-			$this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false );
178
-		} catch ( ConstraintParameterException $e ) {
177
+			$this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false);
178
+		} catch (ConstraintParameterException $e) {
179 179
 			$exceptions[] = $e;
180 180
 		}
181 181
 		return $exceptions;
Please login to merge, or discard this patch.
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/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.