Completed
Push — master ( c6464d...264e6e )
by
unknown
19s
created
src/WikibaseQualityConstraintsHooks.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -20,47 +20,47 @@
 block discarded – undo
20 20
 {
21 21
 
22 22
 	/** @inheritDoc */
23
-	public function onArticlePurge( $wikiPage ) {
23
+	public function onArticlePurge($wikiPage) {
24 24
 		$entityContentFactory = WikibaseRepo::getEntityContentFactory();
25
-		if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) {
25
+		if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) {
26 26
 			$entityIdLookup = WikibaseRepo::getEntityIdLookup();
27
-			$entityId = $entityIdLookup->getEntityIdForTitle( $wikiPage->getTitle() );
28
-			if ( $entityId !== null ) {
27
+			$entityId = $entityIdLookup->getEntityIdForTitle($wikiPage->getTitle());
28
+			if ($entityId !== null) {
29 29
 				$resultsCache = ResultsCache::getDefaultInstance();
30
-				$resultsCache->delete( $entityId );
30
+				$resultsCache->delete($entityId);
31 31
 			}
32 32
 		}
33 33
 	}
34 34
 
35 35
 	/** @inheritDoc */
36
-	public function onBeforePageDisplay( $out, $skin ): void {
36
+	public function onBeforePageDisplay($out, $skin): void {
37 37
 		$lookup = WikibaseRepo::getEntityNamespaceLookup();
38 38
 		$title = $out->getTitle();
39
-		if ( $title === null ) {
39
+		if ($title === null) {
40 40
 			return;
41 41
 		}
42 42
 
43
-		if ( !$lookup->isNamespaceWithEntities( $title->getNamespace() ) ) {
43
+		if (!$lookup->isNamespaceWithEntities($title->getNamespace())) {
44 44
 			return;
45 45
 		}
46
-		if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) {
46
+		if (empty($out->getJsConfigVars()['wbIsEditView'])) {
47 47
 			return;
48 48
 		}
49 49
 
50 50
 		$services = MediaWikiServices::getInstance();
51 51
 		$config = $services->getMainConfig();
52 52
 
53
-		$isMobileView = ExtensionRegistry::getInstance()->isLoaded( 'MobileFrontend' ) &&
54
-			$services->getService( 'MobileFrontend.Context' )->shouldDisplayMobileView();
55
-		if ( $isMobileView ) {
53
+		$isMobileView = ExtensionRegistry::getInstance()->isLoaded('MobileFrontend') &&
54
+			$services->getService('MobileFrontend.Context')->shouldDisplayMobileView();
55
+		if ($isMobileView) {
56 56
 			return;
57 57
 		}
58 58
 
59
-		$out->addModules( 'wikibase.quality.constraints.suggestions' );
59
+		$out->addModules('wikibase.quality.constraints.suggestions');
60 60
 
61
-		if ( $config->get( 'WBQualityConstraintsShowConstraintViolationToNonLoggedInUsers' )
62
-			|| $out->getUser()->isRegistered() ) {
63
-				$out->addModules( 'wikibase.quality.constraints.gadget' );
61
+		if ($config->get('WBQualityConstraintsShowConstraintViolationToNonLoggedInUsers')
62
+			|| $out->getUser()->isRegistered()) {
63
+				$out->addModules('wikibase.quality.constraints.gadget');
64 64
 		}
65 65
 	}
66 66
 
Please login to merge, or discard this patch.
src/WikibaseChangeNotificationHookHandler.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport;
6 6
 
@@ -33,55 +33,55 @@  discard block
 block discarded – undo
33 33
 	}
34 34
 
35 35
 	/** @inheritDoc */
36
-	public function onWikibaseChangeNotification( Change $change ): void {
37
-		if ( !( $change instanceof EntityChange ) ) {
36
+	public function onWikibaseChangeNotification(Change $change): void {
37
+		if (!($change instanceof EntityChange)) {
38 38
 			return;
39 39
 		}
40 40
 		/** @var EntityChange $change */
41 41
 
42 42
 		// If jobs are enabled and the results would be stored in some way run a job.
43 43
 		if (
44
-			$this->config->get( 'WBQualityConstraintsEnableConstraintsCheckJobs' ) &&
45
-			$this->config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) &&
44
+			$this->config->get('WBQualityConstraintsEnableConstraintsCheckJobs') &&
45
+			$this->config->get('WBQualityConstraintsCacheCheckConstraintsResults') &&
46 46
 			$this->isSelectedForJobRunBasedOnPercentage()
47 47
 		) {
48
-			$params = [ 'entityId' => $change->getEntityId()->getSerialization() ];
48
+			$params = ['entityId' => $change->getEntityId()->getSerialization()];
49 49
 			$this->jobQueueGroup->lazyPush(
50
-				new JobSpecification( CheckConstraintsJob::COMMAND, $params )
50
+				new JobSpecification(CheckConstraintsJob::COMMAND, $params)
51 51
 			);
52 52
 		}
53 53
 
54
-		if ( $this->config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) &&
55
-			$this->isConstraintStatementsChange( $change )
54
+		if ($this->config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') &&
55
+			$this->isConstraintStatementsChange($change)
56 56
 		) {
57
-			$params = [ 'propertyId' => $change->getEntityId()->getSerialization() ];
57
+			$params = ['propertyId' => $change->getEntityId()->getSerialization()];
58 58
 			$metadata = $change->getMetadata();
59
-			if ( array_key_exists( 'rev_id', $metadata ) ) {
59
+			if (array_key_exists('rev_id', $metadata)) {
60 60
 				$params['revisionId'] = $metadata['rev_id'];
61 61
 			}
62 62
 			$this->jobQueueGroup->push(
63
-				new JobSpecification( 'constraintsTableUpdate', $params )
63
+				new JobSpecification('constraintsTableUpdate', $params)
64 64
 			);
65 65
 		}
66 66
 	}
67 67
 
68 68
 	private function isSelectedForJobRunBasedOnPercentage(): bool {
69
-		$percentage = $this->config->get( 'WBQualityConstraintsEnableConstraintsCheckJobsRatio' );
69
+		$percentage = $this->config->get('WBQualityConstraintsEnableConstraintsCheckJobsRatio');
70 70
 
71
-		return mt_rand( 1, 100 ) <= $percentage;
71
+		return mt_rand(1, 100) <= $percentage;
72 72
 	}
73 73
 
74
-	private function isConstraintStatementsChange( Change $change ): bool {
75
-		if ( !( $change instanceof EntityChange ) ||
74
+	private function isConstraintStatementsChange(Change $change): bool {
75
+		if (!($change instanceof EntityChange) ||
76 76
 			 $change->getAction() !== EntityChange::UPDATE ||
77
-			 !( $change->getEntityId() instanceof NumericPropertyId )
77
+			 !($change->getEntityId() instanceof NumericPropertyId)
78 78
 		) {
79 79
 			return false;
80 80
 		}
81 81
 
82 82
 		$info = $change->getInfo();
83 83
 
84
-		if ( !array_key_exists( 'compactDiff', $info ) ) {
84
+		if (!array_key_exists('compactDiff', $info)) {
85 85
 			// the non-compact diff ($info['diff']) does not contain statement diffs (T110996),
86 86
 			// so we only know that the change *might* affect the constraint statements
87 87
 			return true;
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
 		/** @var EntityDiffChangedAspects $aspects */
91 91
 		$aspects = $info['compactDiff'];
92 92
 
93
-		$propertyConstraintId = $this->config->get( 'WBQualityConstraintsPropertyConstraintId' );
94
-		return in_array( $propertyConstraintId, $aspects->getStatementChanges() );
93
+		$propertyConstraintId = $this->config->get('WBQualityConstraintsPropertyConstraintId');
94
+		return in_array($propertyConstraintId, $aspects->getStatementChanges());
95 95
 	}
96 96
 
97 97
 }
Please login to merge, or discard this patch.
src/Html/HtmlTableBuilder.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	private $isSortable;
31 31
 
32
-	public function __construct( array $headers ) {
33
-		foreach ( $headers as $header ) {
34
-			$this->addHeader( $header );
32
+	public function __construct(array $headers) {
33
+		foreach ($headers as $header) {
34
+			$this->addHeader($header);
35 35
 		}
36 36
 	}
37 37
 
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @throws InvalidArgumentException
42 42
 	 */
43
-	private function addHeader( $header ) {
44
-		Assert::parameterType( [ 'string', HtmlTableHeaderBuilder::class ], $header, '$header' );
43
+	private function addHeader($header) {
44
+		Assert::parameterType(['string', HtmlTableHeaderBuilder::class], $header, '$header');
45 45
 
46
-		if ( is_string( $header ) ) {
47
-			$header = new HtmlTableHeaderBuilder( $header );
46
+		if (is_string($header)) {
47
+			$header = new HtmlTableHeaderBuilder($header);
48 48
 		}
49 49
 
50 50
 		$this->headers[] = $header;
51 51
 
52
-		if ( $header->getIsSortable() ) {
52
+		if ($header->getIsSortable()) {
53 53
 			$this->isSortable = true;
54 54
 		}
55 55
 	}
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 * @throws InvalidArgumentException
84 84
 	 */
85
-	public function appendRow( array $cells ) {
86
-		foreach ( $cells as $key => $cell ) {
87
-			if ( is_string( $cell ) ) {
88
-				$cells[$key] = new HtmlTableCellBuilder( $cell );
89
-			} elseif ( !( $cell instanceof HtmlTableCellBuilder ) ) {
90
-				throw new InvalidArgumentException( '$cells must be array of HtmlTableCell objects.' );
85
+	public function appendRow(array $cells) {
86
+		foreach ($cells as $key => $cell) {
87
+			if (is_string($cell)) {
88
+				$cells[$key] = new HtmlTableCellBuilder($cell);
89
+			} elseif (!($cell instanceof HtmlTableCellBuilder)) {
90
+				throw new InvalidArgumentException('$cells must be array of HtmlTableCell objects.');
91 91
 			}
92 92
 		}
93 93
 
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @throws InvalidArgumentException
103 103
 	 */
104
-	public function appendRows( array $rows ) {
105
-		foreach ( $rows as $cells ) {
106
-			if ( !is_array( $cells ) ) {
107
-				throw new InvalidArgumentException( '$rows must be array of arrays of HtmlTableCell objects.' );
104
+	public function appendRows(array $rows) {
105
+		foreach ($rows as $cells) {
106
+			if (!is_array($cells)) {
107
+				throw new InvalidArgumentException('$rows must be array of arrays of HtmlTableCell objects.');
108 108
 			}
109 109
 
110
-			$this->appendRow( $cells );
110
+			$this->appendRow($cells);
111 111
 		}
112 112
 	}
113 113
 
@@ -119,38 +119,38 @@  discard block
 block discarded – undo
119 119
 	public function toHtml() {
120 120
 		// Open table
121 121
 		$tableClasses = 'wikitable';
122
-		if ( $this->isSortable ) {
122
+		if ($this->isSortable) {
123 123
 			$tableClasses .= ' sortable';
124 124
 		}
125
-		$html = Html::openElement( 'table', [ 'class' => $tableClasses ] );
125
+		$html = Html::openElement('table', ['class' => $tableClasses]);
126 126
 
127 127
 		// Write headers
128
-		$html .= Html::openElement( 'thead' );
129
-		$html .= Html::openElement( 'tr' );
130
-		foreach ( $this->headers as $header ) {
128
+		$html .= Html::openElement('thead');
129
+		$html .= Html::openElement('tr');
130
+		foreach ($this->headers as $header) {
131 131
 			$html .= $header->toHtml();
132 132
 		}
133
-		$html .= Html::closeElement( 'tr' );
134
-		$html .= Html::closeElement( 'thead' );
135
-		$html .= Html::openElement( 'tbody' );
133
+		$html .= Html::closeElement('tr');
134
+		$html .= Html::closeElement('thead');
135
+		$html .= Html::openElement('tbody');
136 136
 
137 137
 		// Write rows
138
-		foreach ( $this->rows as $row ) {
139
-			$html .= Html::openElement( 'tr' );
138
+		foreach ($this->rows as $row) {
139
+			$html .= Html::openElement('tr');
140 140
 
141 141
 			/**
142 142
 			 * @var HtmlTableCellBuilder $cell
143 143
 			 */
144
-			foreach ( $row as $cell ) {
144
+			foreach ($row as $cell) {
145 145
 				$html .= $cell->toHtml();
146 146
 			}
147 147
 
148
-			$html .= Html::closeElement( 'tr' );
148
+			$html .= Html::closeElement('tr');
149 149
 		}
150 150
 
151 151
 		// Close table
152
-		$html .= Html::closeElement( 'tbody' );
153
-		$html .= Html::closeElement( 'table' );
152
+		$html .= Html::closeElement('tbody');
153
+		$html .= Html::closeElement('table');
154 154
 
155 155
 		return $html;
156 156
 	}
Please login to merge, or discard this patch.
src/ConstraintCheck/Message/ViolationMessage.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
 	public function __construct(
129 129
 		$messageKey
130 130
 	) {
131
-		if ( strpos( $messageKey, self::MESSAGE_KEY_PREFIX ) !== 0 ) {
131
+		if (strpos($messageKey, self::MESSAGE_KEY_PREFIX) !== 0) {
132 132
 			throw new InvalidArgumentException(
133
-				'ViolationMessage key ⧼' .
134
-				$messageKey .
135
-				'⧽ should start with "' .
136
-				self::MESSAGE_KEY_PREFIX .
133
+				'ViolationMessage key ⧼'.
134
+				$messageKey.
135
+				'⧽ should start with "'.
136
+				self::MESSAGE_KEY_PREFIX.
137 137
 				'".'
138 138
 			);
139 139
 		}
140 140
 
141
-		$this->messageKeySuffix = substr( $messageKey, strlen( self::MESSAGE_KEY_PREFIX ) );
141
+		$this->messageKeySuffix = substr($messageKey, strlen(self::MESSAGE_KEY_PREFIX));
142 142
 		$this->arguments = [];
143 143
 	}
144 144
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return string
148 148
 	 */
149 149
 	public function getMessageKey() {
150
-		return self::MESSAGE_KEY_PREFIX . $this->messageKeySuffix;
150
+		return self::MESSAGE_KEY_PREFIX.$this->messageKeySuffix;
151 151
 	}
152 152
 
153 153
 	/**
@@ -167,9 +167,9 @@  discard block
 block discarded – undo
167 167
 	 * @param mixed $value the value, which should match the $type
168 168
 	 * @return self
169 169
 	 */
170
-	public function withArgument( $type, $role, $value ) {
170
+	public function withArgument($type, $role, $value) {
171 171
 		$ret = clone $this;
172
-		$ret->arguments[] = [ 'type' => $type, 'role' => $role, 'value' => $value ];
172
+		$ret->arguments[] = ['type' => $type, 'role' => $role, 'value' => $value];
173 173
 		return $ret;
174 174
 	}
175 175
 
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
 	 * @param string|null $role one of the Role::* constants
182 182
 	 * @return self
183 183
 	 */
184
-	public function withEntityId( EntityId $entityId, $role = null ) {
185
-		return $this->withArgument( self::TYPE_ENTITY_ID, $role, $entityId );
184
+	public function withEntityId(EntityId $entityId, $role = null) {
185
+		return $this->withArgument(self::TYPE_ENTITY_ID, $role, $entityId);
186 186
 	}
187 187
 
188 188
 	/**
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	 * @param string|null $role one of the Role::* constants
200 200
 	 * @return self
201 201
 	 */
202
-	public function withEntityIdList( array $entityIdList, $role = null ) {
203
-		return $this->withArgument( self::TYPE_ENTITY_ID_LIST, $role, $entityIdList );
202
+	public function withEntityIdList(array $entityIdList, $role = null) {
203
+		return $this->withArgument(self::TYPE_ENTITY_ID_LIST, $role, $entityIdList);
204 204
 	}
205 205
 
206 206
 	/**
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
 	 * @param string|null $role one of the Role::* constants
212 212
 	 * @return self
213 213
 	 */
214
-	public function withItemIdSnakValue( ItemIdSnakValue $value, $role = null ) {
215
-		return $this->withArgument( self::TYPE_ITEM_ID_SNAK_VALUE, $role, $value );
214
+	public function withItemIdSnakValue(ItemIdSnakValue $value, $role = null) {
215
+		return $this->withArgument(self::TYPE_ITEM_ID_SNAK_VALUE, $role, $value);
216 216
 	}
217 217
 
218 218
 	/**
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 	 * @param string|null $role one of the Role::* constants
230 230
 	 * @return self
231 231
 	 */
232
-	public function withItemIdSnakValueList( array $valueList, $role = null ) {
233
-		return $this->withArgument( self::TYPE_ITEM_ID_SNAK_VALUE_LIST, $role, $valueList );
232
+	public function withItemIdSnakValueList(array $valueList, $role = null) {
233
+		return $this->withArgument(self::TYPE_ITEM_ID_SNAK_VALUE_LIST, $role, $valueList);
234 234
 	}
235 235
 
236 236
 	/**
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 	 * @param string|null $role one of the Role::* constants
242 242
 	 * @return self
243 243
 	 */
244
-	public function withDataValue( DataValue $dataValue, $role = null ) {
245
-		return $this->withArgument( self::TYPE_DATA_VALUE, $role, $dataValue );
244
+	public function withDataValue(DataValue $dataValue, $role = null) {
245
+		return $this->withArgument(self::TYPE_DATA_VALUE, $role, $dataValue);
246 246
 	}
247 247
 
248 248
 	/**
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 	 * @param string|null $role one of the Role::* constants
258 258
 	 * @return self
259 259
 	 */
260
-	public function withDataValueType( $dataValueType, $role = null ) {
261
-		return $this->withArgument( self::TYPE_DATA_VALUE_TYPE, $role, $dataValueType );
260
+	public function withDataValueType($dataValueType, $role = null) {
261
+		return $this->withArgument(self::TYPE_DATA_VALUE_TYPE, $role, $dataValueType);
262 262
 	}
263 263
 
264 264
 	/**
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 	 * @param string|null $role one of the Role::* constants
270 270
 	 * @return self
271 271
 	 */
272
-	public function withInlineCode( $code, $role = null ) {
273
-		return $this->withArgument( self::TYPE_INLINE_CODE, $role, $code );
272
+	public function withInlineCode($code, $role = null) {
273
+		return $this->withArgument(self::TYPE_INLINE_CODE, $role, $code);
274 274
 	}
275 275
 
276 276
 	/**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param string|null $role one of the Role::* constants
282 282
 	 * @return self
283 283
 	 */
284
-	public function withConstraintScope( $scope, $role = null ) {
285
-		return $this->withArgument( self::TYPE_CONSTRAINT_SCOPE, $role, $scope );
284
+	public function withConstraintScope($scope, $role = null) {
285
+		return $this->withArgument(self::TYPE_CONSTRAINT_SCOPE, $role, $scope);
286 286
 	}
287 287
 
288 288
 	/**
@@ -293,8 +293,8 @@  discard block
 block discarded – undo
293 293
 	 * @param string|null $role one of the Role::* constants
294 294
 	 * @return self
295 295
 	 */
296
-	public function withConstraintScopeList( array $scopeList, $role = null ) {
297
-		return $this->withArgument( self::TYPE_CONSTRAINT_SCOPE_LIST, $role, $scopeList );
296
+	public function withConstraintScopeList(array $scopeList, $role = null) {
297
+		return $this->withArgument(self::TYPE_CONSTRAINT_SCOPE_LIST, $role, $scopeList);
298 298
 	}
299 299
 
300 300
 	/**
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 	 * @param string|null $role one of the Role::* constants
306 306
 	 * @return self
307 307
 	 */
308
-	public function withPropertyScope( $scope, $role = null ) {
309
-		return $this->withArgument( self::TYPE_PROPERTY_SCOPE, $role, $scope );
308
+	public function withPropertyScope($scope, $role = null) {
309
+		return $this->withArgument(self::TYPE_PROPERTY_SCOPE, $role, $scope);
310 310
 	}
311 311
 
312 312
 	/**
@@ -317,8 +317,8 @@  discard block
 block discarded – undo
317 317
 	 * @param string|null $role one of the Role::* constants
318 318
 	 * @return self
319 319
 	 */
320
-	public function withPropertyScopeList( array $scopeList, $role = null ) {
321
-		return $this->withArgument( self::TYPE_PROPERTY_SCOPE_LIST, $role, $scopeList );
320
+	public function withPropertyScopeList(array $scopeList, $role = null) {
321
+		return $this->withArgument(self::TYPE_PROPERTY_SCOPE_LIST, $role, $scopeList);
322 322
 	}
323 323
 
324 324
 	/**
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 	 * @param string $languageCode
334 334
 	 * @return self
335 335
 	 */
336
-	public function withLanguage( $languageCode ) {
337
-		return $this->withArgument( self::TYPE_LANGUAGE, null, $languageCode );
336
+	public function withLanguage($languageCode) {
337
+		return $this->withArgument(self::TYPE_LANGUAGE, null, $languageCode);
338 338
 	}
339 339
 
340 340
 	/**
@@ -349,8 +349,8 @@  discard block
 block discarded – undo
349 349
 	 * @param string[] $languageCodes
350 350
 	 * @return self
351 351
 	 */
352
-	public function withLanguages( $languageCodes ) {
353
-		return $this->withArgument( self::TYPE_LANGUAGE_LIST, null, $languageCodes );
352
+	public function withLanguages($languageCodes) {
353
+		return $this->withArgument(self::TYPE_LANGUAGE_LIST, null, $languageCodes);
354 354
 	}
355 355
 
356 356
 	/**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param string|null $role one of the Role::* constants
366 366
 	 * @return self
367 367
 	 */
368
-	public function withMultilingualText( MultilingualTextValue $text, $role = null ) {
369
-		return $this->withArgument( self::TYPE_MULTILINGUAL_TEXT, $role, $text );
368
+	public function withMultilingualText(MultilingualTextValue $text, $role = null) {
369
+		return $this->withArgument(self::TYPE_MULTILINGUAL_TEXT, $role, $text);
370 370
 	}
371 371
 
372 372
 }
Please login to merge, or discard this patch.
src/ConstraintCheck/Helper/ConstraintParameterException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,9 +18,9 @@
 block discarded – undo
18 18
 	 */
19 19
 	private $violationMessage;
20 20
 
21
-	public function __construct( ViolationMessage $violationMessage ) {
22
-		$message = '⧼' . $violationMessage->getMessageKey() . '⧽';
23
-		parent::__construct( $message );
21
+	public function __construct(ViolationMessage $violationMessage) {
22
+		$message = '⧼'.$violationMessage->getMessageKey().'⧽';
23
+		parent::__construct($message);
24 24
 
25 25
 		$this->violationMessage = $violationMessage;
26 26
 	}
Please login to merge, or discard this patch.
src/Job/CheckConstraintsJob.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -37,25 +37,25 @@  discard block
 block discarded – undo
37 37
 	 * @param Title $title
38 38
 	 * @param string[] $params should contain 'entityId' => 'Q1234'
39 39
 	 */
40
-	public function __construct( Title $title, array $params ) {
41
-		parent::__construct( self::COMMAND, $title, $params );
40
+	public function __construct(Title $title, array $params) {
41
+		parent::__construct(self::COMMAND, $title, $params);
42 42
 		$this->removeDuplicates = true;
43 43
 
44
-		Assert::parameterType( 'string', $params['entityId'], '$params[\'entityId\']' );
44
+		Assert::parameterType('string', $params['entityId'], '$params[\'entityId\']');
45 45
 
46
-		$resultSource = ConstraintsServices::getResultsSource( MediaWikiServices::getInstance() );
46
+		$resultSource = ConstraintsServices::getResultsSource(MediaWikiServices::getInstance());
47 47
 		'@phan-var CachingResultsSource $resultSource';
48 48
 		// This job should only ever be used when caching result sources are used.
49
-		$this->setResultsSource( $resultSource );
49
+		$this->setResultsSource($resultSource);
50 50
 
51
-		$this->setEntityIdParser( WikibaseRepo::getEntityIdParser() );
51
+		$this->setEntityIdParser(WikibaseRepo::getEntityIdParser());
52 52
 	}
53 53
 
54
-	public function setResultsSource( CachingResultsSource $resultsSource ) {
54
+	public function setResultsSource(CachingResultsSource $resultsSource) {
55 55
 		$this->resultsSource = $resultsSource;
56 56
 	}
57 57
 
58
-	public function setEntityIdParser( EntityIdParser $parser ) {
58
+	public function setEntityIdParser(EntityIdParser $parser) {
59 59
 		$this->entityIdParser = $parser;
60 60
 	}
61 61
 
@@ -66,19 +66,19 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function run() {
68 68
 		try {
69
-			$entityId = $this->entityIdParser->parse( $this->params['entityId'] );
70
-		} catch ( EntityIdParsingException ) {
69
+			$entityId = $this->entityIdParser->parse($this->params['entityId']);
70
+		} catch (EntityIdParsingException) {
71 71
 			return false;
72 72
 		}
73 73
 
74
-		$this->checkConstraints( $entityId );
74
+		$this->checkConstraints($entityId);
75 75
 
76 76
 		return true;
77 77
 	}
78 78
 
79
-	private function checkConstraints( EntityId $entityId ) {
79
+	private function checkConstraints(EntityId $entityId) {
80 80
 		$this->resultsSource->getResults(
81
-			[ $entityId ],
81
+			[$entityId],
82 82
 			[],
83 83
 			null,
84 84
 			[]
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/FormatChecker.php 1 patch
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 		$this->sparqlHelper = $sparqlHelper;
75 75
 		$this->shellboxClientFactory = $shellboxClientFactory;
76 76
 		$this->knownGoodPatternsAsKeys = array_fill_keys(
77
-			$this->config->get( 'WBQualityConstraintsFormatCheckerKnownGoodRegexPatterns' ),
77
+			$this->config->get('WBQualityConstraintsFormatCheckerKnownGoodRegexPatterns'),
78 78
 			null
79 79
 		);
80 80
 		$this->logger = $logger ?? new NullLogger();
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * @throws ConstraintParameterException
109 109
 	 * @return CheckResult
110 110
 	 */
111
-	public function checkConstraint( Context $context, Constraint $constraint ): CheckResult {
111
+	public function checkConstraint(Context $context, Constraint $constraint): CheckResult {
112 112
 		$constraintParameters = $constraint->getConstraintParameters();
113 113
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
114 114
 
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 
124 124
 		$snak = $context->getSnak();
125 125
 
126
-		if ( !$snak instanceof PropertyValueSnak ) {
126
+		if (!$snak instanceof PropertyValueSnak) {
127 127
 			// nothing to check
128
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE );
128
+			return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE);
129 129
 		}
130 130
 
131 131
 		$dataValue = $snak->getDataValue();
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		 * error handling:
135 135
 		 *   type of $dataValue for properties with 'Format' constraint has to be 'string' or 'monolingualtext'
136 136
 		 */
137
-		switch ( $dataValue->getType() ) {
137
+		switch ($dataValue->getType()) {
138 138
 			case 'string':
139 139
 				$text = $dataValue->getValue();
140 140
 				break;
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 				$text = $dataValue->getText();
145 145
 				break;
146 146
 			default:
147
-				$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-types-2' ) )
148
-					->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
149
-					->withDataValueType( 'string' )
150
-					->withDataValueType( 'monolingualtext' );
151
-				return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message );
147
+				$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-types-2'))
148
+					->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
149
+					->withDataValueType('string')
150
+					->withDataValueType('monolingualtext');
151
+				return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message);
152 152
 		}
153
-		$status = $this->runRegexCheck( $text, $format );
153
+		$status = $this->runRegexCheck($text, $format);
154 154
 		$message = $this->formatMessage(
155 155
 			$status,
156 156
 			$text,
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			$syntaxClarifications,
160 160
 			$constraintTypeItemId
161 161
 		);
162
-		return new CheckResult( $context, $constraint, $status, $message );
162
+		return new CheckResult($context, $constraint, $status, $message);
163 163
 	}
164 164
 
165 165
 	private function formatMessage(
@@ -171,43 +171,43 @@  discard block
 block discarded – undo
171 171
 		string $constraintTypeItemId
172 172
 	): ?ViolationMessage {
173 173
 		$message = null;
174
-		if ( $status === CheckResult::STATUS_VIOLATION ) {
175
-			$message = ( new ViolationMessage( 'wbqc-violation-message-format-clarification' ) )
176
-				->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY )
177
-				->withDataValue( new StringValue( $text ), Role::OBJECT )
178
-				->withInlineCode( $format, Role::CONSTRAINT_PARAMETER_VALUE )
179
-				->withMultilingualText( $syntaxClarifications, Role::CONSTRAINT_PARAMETER_VALUE );
180
-		} elseif ( $status === CheckResult::STATUS_TODO ) {
181
-			$message = ( new ViolationMessage( 'wbqc-violation-message-security-reason' ) )
182
-				->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM );
174
+		if ($status === CheckResult::STATUS_VIOLATION) {
175
+			$message = (new ViolationMessage('wbqc-violation-message-format-clarification'))
176
+				->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY)
177
+				->withDataValue(new StringValue($text), Role::OBJECT)
178
+				->withInlineCode($format, Role::CONSTRAINT_PARAMETER_VALUE)
179
+				->withMultilingualText($syntaxClarifications, Role::CONSTRAINT_PARAMETER_VALUE);
180
+		} elseif ($status === CheckResult::STATUS_TODO) {
181
+			$message = (new ViolationMessage('wbqc-violation-message-security-reason'))
182
+				->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM);
183 183
 		}
184 184
 
185 185
 		return $message;
186 186
 	}
187 187
 
188 188
 	/** @throws ConstraintParameterException */
189
-	private function runRegexCheck( string $text, string $format ): string {
190
-		if ( !$this->config->get( 'WBQualityConstraintsCheckFormatConstraint' ) ) {
189
+	private function runRegexCheck(string $text, string $format): string {
190
+		if (!$this->config->get('WBQualityConstraintsCheckFormatConstraint')) {
191 191
 			return CheckResult::STATUS_TODO;
192 192
 		}
193
-		if ( \array_key_exists( $format, $this->knownGoodPatternsAsKeys ) ) {
194
-			$checkResult = FormatCheckerHelper::runRegexCheck( $format, $text );
193
+		if (\array_key_exists($format, $this->knownGoodPatternsAsKeys)) {
194
+			$checkResult = FormatCheckerHelper::runRegexCheck($format, $text);
195 195
 		} elseif (
196
-			$this->config->get( 'WBQualityConstraintsFormatCheckerShellboxRatio' ) > (float)wfRandom()
196
+			$this->config->get('WBQualityConstraintsFormatCheckerShellboxRatio') > (float) wfRandom()
197 197
 		) {
198
-			$checkResult = $this->runRegexCheckUsingShellbox( $text, $format );
198
+			$checkResult = $this->runRegexCheckUsingShellbox($text, $format);
199 199
 		} else {
200
-			return $this->runRegexCheckUsingSparql( $text, $format );
200
+			return $this->runRegexCheckUsingSparql($text, $format);
201 201
 		}
202 202
 
203
-		if ( $checkResult === 1 ) {
203
+		if ($checkResult === 1) {
204 204
 			return CheckResult::STATUS_COMPLIANCE;
205
-		} elseif ( $checkResult === 0 ) {
205
+		} elseif ($checkResult === 0) {
206 206
 			return CheckResult::STATUS_VIOLATION;
207
-		} elseif ( $checkResult === false ) {
207
+		} elseif ($checkResult === false) {
208 208
 			throw new ConstraintParameterException(
209
-				( new ViolationMessage( 'wbqc-violation-message-parameter-regex' ) )
210
-					->withInlineCode( $format, Role::CONSTRAINT_PARAMETER_VALUE )
209
+				(new ViolationMessage('wbqc-violation-message-parameter-regex'))
210
+					->withInlineCode($format, Role::CONSTRAINT_PARAMETER_VALUE)
211 211
 			);
212 212
 		} else {
213 213
 			return $checkResult;
@@ -221,51 +221,51 @@  discard block
 block discarded – undo
221 221
 	 *   - FALSE if $format is invalid regex
222 222
 	 *   - CheckResult::STATUS_TODO if Shellbox is not enabled
223 223
 	 */
224
-	private function runRegexCheckUsingShellbox( string $text, string $format ) {
225
-		if ( !$this->shellboxClientFactory->isEnabled( 'constraint-regex-checker' ) ) {
224
+	private function runRegexCheckUsingShellbox(string $text, string $format) {
225
+		if (!$this->shellboxClientFactory->isEnabled('constraint-regex-checker')) {
226 226
 			return CheckResult::STATUS_TODO;
227 227
 		}
228 228
 
229 229
 		try {
230
-			return $this->shellboxClientFactory->getClient( [
231
-				'timeout' => $this->config->get( 'WBQualityConstraintsSparqlMaxMillis' ) / 1000,
230
+			return $this->shellboxClientFactory->getClient([
231
+				'timeout' => $this->config->get('WBQualityConstraintsSparqlMaxMillis') / 1000,
232 232
 				'service' => 'constraint-regex-checker',
233
-			] )->call(
233
+			])->call(
234 234
 				'constraint-regex-checker',
235
-				[ FormatCheckerHelper::class, 'runRegexCheck' ],
236
-				[ $format, $text ],
237
-				[ 'classes' => [ FormatCheckerHelper::class ] ],
235
+				[FormatCheckerHelper::class, 'runRegexCheck'],
236
+				[$format, $text],
237
+				['classes' => [FormatCheckerHelper::class]],
238 238
 			);
239
-		} catch ( ClientExceptionInterface $ce ) {
240
-			$this->logger->notice( __METHOD__ . ': Network error, skipping check: {exception}', [
239
+		} catch (ClientExceptionInterface $ce) {
240
+			$this->logger->notice(__METHOD__.': Network error, skipping check: {exception}', [
241 241
 				'exception' => $ce,
242 242
 				'text' => $text,
243 243
 				'format' => $format,
244
-			] );
244
+			]);
245 245
 			return CheckResult::STATUS_TODO;
246
-		} catch ( ShellboxError $e ) {
247
-			$this->logger->error( __METHOD__ . ': Shellbox error, skipping check: {exception}', [
246
+		} catch (ShellboxError $e) {
247
+			$this->logger->error(__METHOD__.': Shellbox error, skipping check: {exception}', [
248 248
 				'exception' => $e,
249 249
 				'text' => $text,
250 250
 				'format' => $format,
251
-			] );
251
+			]);
252 252
 			return CheckResult::STATUS_TODO;
253 253
 		}
254 254
 	}
255 255
 
256
-	private function runRegexCheckUsingSparql( string $text, string $format ): string {
257
-		if ( $this->sparqlHelper instanceof DummySparqlHelper ) {
256
+	private function runRegexCheckUsingSparql(string $text, string $format): string {
257
+		if ($this->sparqlHelper instanceof DummySparqlHelper) {
258 258
 			return CheckResult::STATUS_TODO;
259 259
 		}
260 260
 
261
-		if ( $this->sparqlHelper->matchesRegularExpression( $text, $format ) ) {
261
+		if ($this->sparqlHelper->matchesRegularExpression($text, $format)) {
262 262
 			return CheckResult::STATUS_COMPLIANCE;
263 263
 		} else {
264 264
 			return CheckResult::STATUS_VIOLATION;
265 265
 		}
266 266
 	}
267 267
 
268
-	public function checkConstraintParameters( Constraint $constraint ): array {
268
+	public function checkConstraintParameters(Constraint $constraint): array {
269 269
 		$constraintParameters = $constraint->getConstraintParameters();
270 270
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
271 271
 		$exceptions = [];
@@ -274,14 +274,14 @@  discard block
 block discarded – undo
274 274
 				$constraintParameters,
275 275
 				$constraintTypeItemId
276 276
 			);
277
-		} catch ( ConstraintParameterException $e ) {
277
+		} catch (ConstraintParameterException $e) {
278 278
 			$exceptions[] = $e;
279 279
 		}
280 280
 		try {
281 281
 			$this->constraintParameterParser->parseSyntaxClarificationParameter(
282 282
 				$constraintParameters
283 283
 			);
284
-		} catch ( ConstraintParameterException $e ) {
284
+		} catch (ConstraintParameterException $e) {
285 285
 			$exceptions[] = $e;
286 286
 		}
287 287
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/Checker/ValueTypeChecker.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -88,9 +88,9 @@  discard block
 block discarded – undo
88 88
 	 * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs
89 89
 	 * @return CheckResult
90 90
 	 */
91
-	public function checkConstraint( Context $context, Constraint $constraint ): CheckResult {
92
-		if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) {
93
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED );
91
+	public function checkConstraint(Context $context, Constraint $constraint): CheckResult {
92
+		if ($context->getSnakRank() === Statement::RANK_DEPRECATED) {
93
+			return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED);
94 94
 		}
95 95
 
96 96
 		$constraintParameters = $constraint->getConstraintParameters();
@@ -106,18 +106,18 @@  discard block
 block discarded – undo
106 106
 			$constraintTypeItemId
107 107
 		);
108 108
 		$relationIds = [];
109
-		if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) {
110
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' );
109
+		if ($relation === 'instance' || $relation === 'instanceOrSubclass') {
110
+			$relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId');
111 111
 		}
112
-		if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) {
113
-			$relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' );
112
+		if ($relation === 'subclass' || $relation === 'instanceOrSubclass') {
113
+			$relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId');
114 114
 		}
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, CheckResult::STATUS_COMPLIANCE );
120
+			return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE);
121 121
 		}
122 122
 
123 123
 		$dataValue = $snak->getDataValue();
@@ -126,23 +126,23 @@  discard block
 block discarded – undo
126 126
 		 * error handling:
127 127
 		 *   type of $dataValue for properties with 'Value type' constraint has to be 'wikibase-entityid'
128 128
 		 */
129
-		if ( !$dataValue instanceof EntityIdValue ) {
130
-			$message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) )
131
-				->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM )
132
-				->withDataValueType( 'wikibase-entityid' );
133
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message );
129
+		if (!$dataValue instanceof EntityIdValue) {
130
+			$message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type'))
131
+				->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM)
132
+				->withDataValueType('wikibase-entityid');
133
+			return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message);
134 134
 		}
135 135
 
136 136
 		try {
137
-			$item = $this->entityLookup->getEntity( $dataValue->getEntityId() );
138
-		} catch ( UnresolvedEntityRedirectException ) {
137
+			$item = $this->entityLookup->getEntity($dataValue->getEntityId());
138
+		} catch (UnresolvedEntityRedirectException) {
139 139
 			// Edge case (double redirect): Pretend the entity doesn't exist
140 140
 			$item = null;
141 141
 		}
142 142
 
143
-		if ( !( $item instanceof StatementListProvidingEntity ) ) {
144
-			$message = new ViolationMessage( 'wbqc-violation-message-value-entity-must-exist' );
145
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message );
143
+		if (!($item instanceof StatementListProvidingEntity)) {
144
+			$message = new ViolationMessage('wbqc-violation-message-value-entity-must-exist');
145
+			return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message);
146 146
 		}
147 147
 
148 148
 		$statements = $item->getStatements();
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 			$classes
154 154
 		);
155 155
 
156
-		if ( $result->getBool() ) {
156
+		if ($result->getBool()) {
157 157
 			$message = null;
158 158
 			$status = CheckResult::STATUS_COMPLIANCE;
159 159
 		} else {
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 			$status = CheckResult::STATUS_VIOLATION;
168 168
 		}
169 169
 
170
-		return ( new CheckResult( $context, $constraint, $status, $message ) )
171
-			->withMetadata( $result->getMetadata() );
170
+		return (new CheckResult($context, $constraint, $status, $message))
171
+			->withMetadata($result->getMetadata());
172 172
 	}
173 173
 
174
-	public function checkConstraintParameters( Constraint $constraint ): array {
174
+	public function checkConstraintParameters(Constraint $constraint): array {
175 175
 		$constraintParameters = $constraint->getConstraintParameters();
176 176
 		$constraintTypeItemId = $constraint->getConstraintTypeItemId();
177 177
 		$exceptions = [];
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 				$constraintParameters,
181 181
 				$constraintTypeItemId
182 182
 			);
183
-		} catch ( ConstraintParameterException $e ) {
183
+		} catch (ConstraintParameterException $e) {
184 184
 			$exceptions[] = $e;
185 185
 		}
186 186
 		try {
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 				$constraintParameters,
189 189
 				$constraintTypeItemId
190 190
 			);
191
-		} catch ( ConstraintParameterException $e ) {
191
+		} catch (ConstraintParameterException $e) {
192 192
 			$exceptions[] = $e;
193 193
 		}
194 194
 		return $exceptions;
Please login to merge, or discard this patch.
src/ConstraintCheck/DelegatingConstraintChecker.php 1 patch
Spacing   +167 added lines, -167 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare( strict_types = 1 );
3
+declare(strict_types=1);
4 4
 
5 5
 namespace WikibaseQuality\ConstraintReport\ConstraintCheck;
6 6
 
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 		?callable $defaultResultsPerEntity = null
124 124
 	): array {
125 125
 		$checkResults = [];
126
-		$entity = $this->entityLookup->getEntity( $entityId );
126
+		$entity = $this->entityLookup->getEntity($entityId);
127 127
 
128
-		if ( $entity instanceof StatementListProvidingEntity ) {
129
-			$startTime = microtime( true );
128
+		if ($entity instanceof StatementListProvidingEntity) {
129
+			$startTime = microtime(true);
130 130
 
131 131
 			$checkResults = $this->checkEveryStatement(
132 132
 				$entity,
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 				$defaultResultsPerContext
135 135
 			);
136 136
 
137
-			$endTime = microtime( true );
137
+			$endTime = microtime(true);
138 138
 
139
-			if ( $constraintIds === null ) { // only log full constraint checks
139
+			if ($constraintIds === null) { // only log full constraint checks
140 140
 				$this->loggingHelper->logConstraintCheckOnEntity(
141 141
 					$entityId,
142 142
 					$checkResults,
@@ -146,11 +146,11 @@  discard block
 block discarded – undo
146 146
 			}
147 147
 		}
148 148
 
149
-		if ( $defaultResultsPerEntity !== null ) {
150
-			$checkResults = array_merge( $defaultResultsPerEntity( $entityId ), $checkResults );
149
+		if ($defaultResultsPerEntity !== null) {
150
+			$checkResults = array_merge($defaultResultsPerEntity($entityId), $checkResults);
151 151
 		}
152 152
 
153
-		return $this->sortResult( $checkResults );
153
+		return $this->sortResult($checkResults);
154 154
 	}
155 155
 
156 156
 	/**
@@ -172,19 +172,19 @@  discard block
 block discarded – undo
172 172
 		?callable $defaultResults = null
173 173
 	): array {
174 174
 
175
-		$parsedGuid = $this->statementGuidParser->parse( $guid );
175
+		$parsedGuid = $this->statementGuidParser->parse($guid);
176 176
 		$entityId = $parsedGuid->getEntityId();
177
-		$entity = $this->entityLookup->getEntity( $entityId );
178
-		if ( $entity instanceof StatementListProvidingEntity ) {
179
-			$statement = $entity->getStatements()->getFirstStatementWithGuid( $guid );
180
-			if ( $statement ) {
177
+		$entity = $this->entityLookup->getEntity($entityId);
178
+		if ($entity instanceof StatementListProvidingEntity) {
179
+			$statement = $entity->getStatements()->getFirstStatementWithGuid($guid);
180
+			if ($statement) {
181 181
 				$result = $this->checkStatement(
182 182
 					$entity,
183 183
 					$statement,
184 184
 					$constraintIds,
185 185
 					$defaultResults
186 186
 				);
187
-				$output = $this->sortResult( $result );
187
+				$output = $this->sortResult($result);
188 188
 				return $output;
189 189
 			}
190 190
 		}
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 		return [];
193 193
 	}
194 194
 
195
-	private function getValidContextTypes( Constraint $constraint ): array {
196
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
195
+	private function getValidContextTypes(Constraint $constraint): array {
196
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
197 197
 			return [
198 198
 				Context::TYPE_STATEMENT,
199 199
 				Context::TYPE_QUALIFIER,
@@ -201,21 +201,21 @@  discard block
 block discarded – undo
201 201
 			];
202 202
 		}
203 203
 
204
-		return array_keys( array_filter(
204
+		return array_keys(array_filter(
205 205
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedContextTypes(),
206
-			static fn ( $status ) => $status !== CheckResult::STATUS_NOT_IN_SCOPE
207
-		) );
206
+			static fn ($status) => $status !== CheckResult::STATUS_NOT_IN_SCOPE
207
+		));
208 208
 	}
209 209
 
210
-	private function getValidEntityTypes( Constraint $constraint ): array {
211
-		if ( !array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
212
-			return array_keys( ConstraintChecker::ALL_ENTITY_TYPES_SUPPORTED );
210
+	private function getValidEntityTypes(Constraint $constraint): array {
211
+		if (!array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
212
+			return array_keys(ConstraintChecker::ALL_ENTITY_TYPES_SUPPORTED);
213 213
 		}
214 214
 
215
-		return array_keys( array_filter(
215
+		return array_keys(array_filter(
216 216
 			$this->checkerMap[$constraint->getConstraintTypeItemId()]->getSupportedEntityTypes(),
217
-			static fn ( $status ) => $status !== CheckResult::STATUS_NOT_IN_SCOPE
218
-		) );
217
+			static fn ($status) => $status !== CheckResult::STATUS_NOT_IN_SCOPE
218
+		));
219 219
 	}
220 220
 
221 221
 	/**
@@ -226,38 +226,38 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @return ConstraintParameterException[]
228 228
 	 */
229
-	private function checkCommonConstraintParameters( Constraint $constraint ): array {
229
+	private function checkCommonConstraintParameters(Constraint $constraint): array {
230 230
 		$constraintParameters = $constraint->getConstraintParameters();
231 231
 		try {
232
-			$this->constraintParameterParser->checkError( $constraintParameters );
233
-		} catch ( ConstraintParameterException $e ) {
234
-			return [ $e ];
232
+			$this->constraintParameterParser->checkError($constraintParameters);
233
+		} catch (ConstraintParameterException $e) {
234
+			return [$e];
235 235
 		}
236 236
 
237 237
 		$problems = [];
238 238
 		try {
239
-			$this->constraintParameterParser->parseExceptionParameter( $constraintParameters );
240
-		} catch ( ConstraintParameterException $e ) {
239
+			$this->constraintParameterParser->parseExceptionParameter($constraintParameters);
240
+		} catch (ConstraintParameterException $e) {
241 241
 			$problems[] = $e;
242 242
 		}
243 243
 		try {
244
-			$this->constraintParameterParser->parseConstraintClarificationParameter( $constraintParameters );
245
-		} catch ( ConstraintParameterException $e ) {
244
+			$this->constraintParameterParser->parseConstraintClarificationParameter($constraintParameters);
245
+		} catch (ConstraintParameterException $e) {
246 246
 			$problems[] = $e;
247 247
 		}
248 248
 		try {
249
-			$this->constraintParameterParser->parseConstraintStatusParameter( $constraintParameters );
250
-		} catch ( ConstraintParameterException $e ) {
249
+			$this->constraintParameterParser->parseConstraintStatusParameter($constraintParameters);
250
+		} catch (ConstraintParameterException $e) {
251 251
 			$problems[] = $e;
252 252
 		}
253 253
 		try {
254 254
 			$this->constraintParameterParser->parseConstraintScopeParameters(
255 255
 				$constraintParameters,
256 256
 				$constraint->getConstraintTypeItemId(),
257
-				$this->getValidContextTypes( $constraint ),
258
-				$this->getValidEntityTypes( $constraint )
257
+				$this->getValidContextTypes($constraint),
258
+				$this->getValidEntityTypes($constraint)
259 259
 			);
260
-		} catch ( ConstraintParameterException $e ) {
260
+		} catch (ConstraintParameterException $e) {
261 261
 			$problems[] = $e;
262 262
 		}
263 263
 		return $problems;
@@ -270,16 +270,16 @@  discard block
 block discarded – undo
270 270
 	 * @return ConstraintParameterException[][] first level indexed by constraint ID,
271 271
 	 * second level like checkConstraintParametersOnConstraintId (but without possibility of null)
272 272
 	 */
273
-	public function checkConstraintParametersOnPropertyId( NumericPropertyId $propertyId ): array {
274
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
273
+	public function checkConstraintParametersOnPropertyId(NumericPropertyId $propertyId): array {
274
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
275 275
 		$result = [];
276 276
 
277
-		foreach ( $constraints as $constraint ) {
278
-			$problems = $this->checkCommonConstraintParameters( $constraint );
277
+		foreach ($constraints as $constraint) {
278
+			$problems = $this->checkCommonConstraintParameters($constraint);
279 279
 
280
-			if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
280
+			if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
281 281
 				$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
282
-				$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
282
+				$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
283 283
 			}
284 284
 
285 285
 			$result[$constraint->getConstraintId()] = $problems;
@@ -296,18 +296,18 @@  discard block
 block discarded – undo
296 296
 	 * @return ConstraintParameterException[]|null list of constraint parameter exceptions
297 297
 	 * (empty means all parameters okay), or null if constraint is not found
298 298
 	 */
299
-	public function checkConstraintParametersOnConstraintId( string $constraintId ): ?array {
300
-		$propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId();
299
+	public function checkConstraintParametersOnConstraintId(string $constraintId): ?array {
300
+		$propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId();
301 301
 		'@phan-var NumericPropertyId $propertyId';
302
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
302
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
303 303
 
304
-		foreach ( $constraints as $constraint ) {
305
-			if ( $constraint->getConstraintId() === $constraintId ) {
306
-				$problems = $this->checkCommonConstraintParameters( $constraint );
304
+		foreach ($constraints as $constraint) {
305
+			if ($constraint->getConstraintId() === $constraintId) {
306
+				$problems = $this->checkCommonConstraintParameters($constraint);
307 307
 
308
-				if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
308
+				if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
309 309
 					$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
310
-					$problems = array_merge( $problems, $checker->checkConstraintParameters( $constraint ) );
310
+					$problems = array_merge($problems, $checker->checkConstraintParameters($constraint));
311 311
 				}
312 312
 
313 313
 				return $problems;
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 		$result = [];
333 333
 
334 334
 		/** @var Statement $statement */
335
-		foreach ( $entity->getStatements() as $statement ) {
336
-			$result = array_merge( $result,
335
+		foreach ($entity->getStatements() as $statement) {
336
+			$result = array_merge($result,
337 337
 				$this->checkStatement(
338 338
 					$entity,
339 339
 					$statement,
340 340
 					$constraintIds,
341 341
 					$defaultResultsPerContext
342
-				) );
342
+				));
343 343
 		}
344 344
 
345 345
 		return $result;
@@ -361,32 +361,32 @@  discard block
 block discarded – undo
361 361
 	): array {
362 362
 		$result = [];
363 363
 
364
-		$result = array_merge( $result,
364
+		$result = array_merge($result,
365 365
 			$this->checkConstraintsForMainSnak(
366 366
 				$entity,
367 367
 				$statement,
368 368
 				$constraintIds,
369 369
 				$defaultResultsPerContext
370
-			) );
370
+			));
371 371
 
372
-		if ( $this->checkQualifiers ) {
373
-			$result = array_merge( $result,
372
+		if ($this->checkQualifiers) {
373
+			$result = array_merge($result,
374 374
 				$this->checkConstraintsForQualifiers(
375 375
 					$entity,
376 376
 					$statement,
377 377
 					$constraintIds,
378 378
 					$defaultResultsPerContext
379
-				) );
379
+				));
380 380
 		}
381 381
 
382
-		if ( $this->checkReferences ) {
383
-			$result = array_merge( $result,
382
+		if ($this->checkReferences) {
383
+			$result = array_merge($result,
384 384
 				$this->checkConstraintsForReferences(
385 385
 					$entity,
386 386
 					$statement,
387 387
 					$constraintIds,
388 388
 					$defaultResultsPerContext
389
-				) );
389
+				));
390 390
 		}
391 391
 
392 392
 		return $result;
@@ -401,17 +401,17 @@  discard block
 block discarded – undo
401 401
 	 * @param string[]|null $constraintIds
402 402
 	 * @return Constraint[]
403 403
 	 */
404
-	private function getConstraintsToUse( PropertyId $propertyId, ?array $constraintIds ): array {
405
-		if ( !( $propertyId instanceof NumericPropertyId ) ) {
404
+	private function getConstraintsToUse(PropertyId $propertyId, ?array $constraintIds): array {
405
+		if (!($propertyId instanceof NumericPropertyId)) {
406 406
 			throw new InvalidArgumentException(
407
-				'Non-numeric property ID not supported:' . $propertyId->getSerialization()
407
+				'Non-numeric property ID not supported:'.$propertyId->getSerialization()
408 408
 			);
409 409
 		}
410
-		$constraints = $this->constraintLookup->queryConstraintsForProperty( $propertyId );
411
-		if ( $constraintIds !== null ) {
410
+		$constraints = $this->constraintLookup->queryConstraintsForProperty($propertyId);
411
+		if ($constraintIds !== null) {
412 412
 			$constraintsToUse = [];
413
-			foreach ( $constraints as $constraint ) {
414
-				if ( in_array( $constraint->getConstraintId(), $constraintIds ) ) {
413
+			foreach ($constraints as $constraint) {
414
+				if (in_array($constraint->getConstraintId(), $constraintIds)) {
415 415
 					$constraintsToUse[] = $constraint;
416 416
 				}
417 417
 			}
@@ -435,18 +435,18 @@  discard block
 block discarded – undo
435 435
 		?array $constraintIds,
436 436
 		?callable $defaultResults
437 437
 	): array {
438
-		$context = new MainSnakContext( $entity, $statement );
438
+		$context = new MainSnakContext($entity, $statement);
439 439
 		$constraints = $this->getConstraintsToUse(
440 440
 			$statement->getPropertyId(),
441 441
 			$constraintIds
442 442
 		);
443
-		$result = $defaultResults !== null ? $defaultResults( $context ) : [];
443
+		$result = $defaultResults !== null ? $defaultResults($context) : [];
444 444
 
445
-		foreach ( $constraints as $constraint ) {
445
+		foreach ($constraints as $constraint) {
446 446
 			$parameters = $constraint->getConstraintParameters();
447 447
 			try {
448
-				$exceptions = $this->constraintParameterParser->parseExceptionParameter( $parameters );
449
-			} catch ( ConstraintParameterException $e ) {
448
+				$exceptions = $this->constraintParameterParser->parseExceptionParameter($parameters);
449
+			} catch (ConstraintParameterException $e) {
450 450
 				$result[] = new CheckResult(
451 451
 					$context,
452 452
 					$constraint,
@@ -456,13 +456,13 @@  discard block
 block discarded – undo
456 456
 				continue;
457 457
 			}
458 458
 
459
-			if ( in_array( $entity->getId(), $exceptions ) ) {
460
-				$message = new ViolationMessage( 'wbqc-violation-message-exception' );
461
-				$result[] = new CheckResult( $context, $constraint, CheckResult::STATUS_EXCEPTION, $message );
459
+			if (in_array($entity->getId(), $exceptions)) {
460
+				$message = new ViolationMessage('wbqc-violation-message-exception');
461
+				$result[] = new CheckResult($context, $constraint, CheckResult::STATUS_EXCEPTION, $message);
462 462
 				continue;
463 463
 			}
464 464
 
465
-			$result[] = $this->getCheckResultFor( $context, $constraint );
465
+			$result[] = $this->getCheckResultFor($context, $constraint);
466 466
 		}
467 467
 
468 468
 		return $result;
@@ -484,24 +484,24 @@  discard block
 block discarded – undo
484 484
 	): array {
485 485
 		$result = [];
486 486
 
487
-		if ( in_array(
487
+		if (in_array(
488 488
 			$statement->getPropertyId()->getSerialization(),
489 489
 			$this->propertiesWithViolatingQualifiers
490
-		) ) {
490
+		)) {
491 491
 			return $result;
492 492
 		}
493 493
 
494
-		foreach ( $statement->getQualifiers() as $qualifier ) {
495
-			$qualifierContext = new QualifierContext( $entity, $statement, $qualifier );
496
-			if ( $defaultResultsPerContext !== null ) {
497
-				$result = array_merge( $result, $defaultResultsPerContext( $qualifierContext ) );
494
+		foreach ($statement->getQualifiers() as $qualifier) {
495
+			$qualifierContext = new QualifierContext($entity, $statement, $qualifier);
496
+			if ($defaultResultsPerContext !== null) {
497
+				$result = array_merge($result, $defaultResultsPerContext($qualifierContext));
498 498
 			}
499 499
 			$qualifierConstraints = $this->getConstraintsToUse(
500 500
 				$qualifierContext->getSnak()->getPropertyId(),
501 501
 				$constraintIds
502 502
 			);
503
-			foreach ( $qualifierConstraints as $qualifierConstraint ) {
504
-				$result[] = $this->getCheckResultFor( $qualifierContext, $qualifierConstraint );
503
+			foreach ($qualifierConstraints as $qualifierConstraint) {
504
+				$result[] = $this->getCheckResultFor($qualifierContext, $qualifierConstraint);
505 505
 			}
506 506
 		}
507 507
 
@@ -525,19 +525,19 @@  discard block
 block discarded – undo
525 525
 		$result = [];
526 526
 
527 527
 		/** @var Reference $reference */
528
-		foreach ( $statement->getReferences() as $reference ) {
529
-			foreach ( $reference->getSnaks() as $snak ) {
528
+		foreach ($statement->getReferences() as $reference) {
529
+			foreach ($reference->getSnaks() as $snak) {
530 530
 				$referenceContext = new ReferenceContext(
531 531
 					$entity, $statement, $reference, $snak
532 532
 				);
533
-				if ( $defaultResultsPerContext !== null ) {
534
-					$result = array_merge( $result, $defaultResultsPerContext( $referenceContext ) );
533
+				if ($defaultResultsPerContext !== null) {
534
+					$result = array_merge($result, $defaultResultsPerContext($referenceContext));
535 535
 				}
536 536
 				$referenceConstraints = $this->getConstraintsToUse(
537 537
 					$referenceContext->getSnak()->getPropertyId(),
538 538
 					$constraintIds
539 539
 				);
540
-				foreach ( $referenceConstraints as $referenceConstraint ) {
540
+				foreach ($referenceConstraints as $referenceConstraint) {
541 541
 					$result[] = $this->getCheckResultFor(
542 542
 						$referenceContext,
543 543
 						$referenceConstraint
@@ -549,50 +549,50 @@  discard block
 block discarded – undo
549 549
 		return $result;
550 550
 	}
551 551
 
552
-	private function getCheckResultFor( Context $context, Constraint $constraint ): CheckResult {
553
-		if ( array_key_exists( $constraint->getConstraintTypeItemId(), $this->checkerMap ) ) {
552
+	private function getCheckResultFor(Context $context, Constraint $constraint): CheckResult {
553
+		if (array_key_exists($constraint->getConstraintTypeItemId(), $this->checkerMap)) {
554 554
 			$checker = $this->checkerMap[$constraint->getConstraintTypeItemId()];
555
-			$result = $this->handleScope( $checker, $context, $constraint );
555
+			$result = $this->handleScope($checker, $context, $constraint);
556 556
 
557
-			if ( $result !== null ) {
558
-				$this->addMetadata( $context, $result );
557
+			if ($result !== null) {
558
+				$this->addMetadata($context, $result);
559 559
 				return $result;
560 560
 			}
561 561
 
562
-			$startTime = microtime( true );
562
+			$startTime = microtime(true);
563 563
 			try {
564
-				$result = $checker->checkConstraint( $context, $constraint );
565
-			} catch ( ConstraintParameterException $e ) {
564
+				$result = $checker->checkConstraint($context, $constraint);
565
+			} catch (ConstraintParameterException $e) {
566 566
 				$result = new CheckResult(
567 567
 					$context,
568 568
 					$constraint,
569 569
 					CheckResult::STATUS_BAD_PARAMETERS,
570 570
 					$e->getViolationMessage()
571 571
 				);
572
-			} catch ( SparqlHelperException ) {
573
-				$message = new ViolationMessage( 'wbqc-violation-message-sparql-error' );
574
-				$result = new CheckResult( $context, $constraint, CheckResult::STATUS_TODO, $message );
572
+			} catch (SparqlHelperException) {
573
+				$message = new ViolationMessage('wbqc-violation-message-sparql-error');
574
+				$result = new CheckResult($context, $constraint, CheckResult::STATUS_TODO, $message);
575 575
 			}
576
-			$endTime = microtime( true );
576
+			$endTime = microtime(true);
577 577
 
578
-			$this->addMetadata( $context, $result );
578
+			$this->addMetadata($context, $result);
579 579
 
580
-			$this->addConstraintClarification( $result );
580
+			$this->addConstraintClarification($result);
581 581
 
582
-			$this->downgradeResultStatus( $result );
582
+			$this->downgradeResultStatus($result);
583 583
 
584 584
 			$this->loggingHelper->logConstraintCheck(
585 585
 				$context,
586 586
 				$constraint,
587 587
 				$result,
588
-				get_class( $checker ),
588
+				get_class($checker),
589 589
 				$endTime - $startTime,
590 590
 				__METHOD__
591 591
 			);
592 592
 
593 593
 			return $result;
594 594
 		} else {
595
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_TODO, null );
595
+			return new CheckResult($context, $constraint, CheckResult::STATUS_TODO, null);
596 596
 		}
597 597
 	}
598 598
 
@@ -601,87 +601,87 @@  discard block
 block discarded – undo
601 601
 		Context $context,
602 602
 		Constraint $constraint
603 603
 	): ?CheckResult {
604
-		$validContextTypes = $this->getValidContextTypes( $constraint );
605
-		$validEntityTypes = $this->getValidEntityTypes( $constraint );
604
+		$validContextTypes = $this->getValidContextTypes($constraint);
605
+		$validEntityTypes = $this->getValidEntityTypes($constraint);
606 606
 		try {
607
-			[ $checkedContextTypes, $checkedEntityTypes ] = $this->constraintParameterParser->parseConstraintScopeParameters(
607
+			[$checkedContextTypes, $checkedEntityTypes] = $this->constraintParameterParser->parseConstraintScopeParameters(
608 608
 				$constraint->getConstraintParameters(),
609 609
 				$constraint->getConstraintTypeItemId(),
610 610
 				$validContextTypes,
611 611
 				$validEntityTypes
612 612
 			);
613
-		} catch ( ConstraintParameterException $e ) {
614
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage() );
613
+		} catch (ConstraintParameterException $e) {
614
+			return new CheckResult($context, $constraint, CheckResult::STATUS_BAD_PARAMETERS, $e->getViolationMessage());
615 615
 		}
616 616
 
617 617
 		$checkedContextTypes ??= $checker->getDefaultContextTypes();
618 618
 		$contextType = $context->getType();
619
-		if ( !in_array( $contextType, $checkedContextTypes ) ) {
620
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE, null );
619
+		if (!in_array($contextType, $checkedContextTypes)) {
620
+			return new CheckResult($context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE, null);
621 621
 		}
622
-		if ( $checker->getSupportedContextTypes()[$contextType] === CheckResult::STATUS_TODO ) {
623
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_TODO, null );
622
+		if ($checker->getSupportedContextTypes()[$contextType] === CheckResult::STATUS_TODO) {
623
+			return new CheckResult($context, $constraint, CheckResult::STATUS_TODO, null);
624 624
 		}
625 625
 
626 626
 		$checkedEntityTypes ??= $validEntityTypes;
627 627
 		$entityType = $context->getEntity()->getType();
628
-		if ( !in_array( $entityType, $checkedEntityTypes ) ) {
629
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE, null );
628
+		if (!in_array($entityType, $checkedEntityTypes)) {
629
+			return new CheckResult($context, $constraint, CheckResult::STATUS_NOT_IN_SCOPE, null);
630 630
 		}
631
-		if ( $checker->getSupportedEntityTypes()[$entityType] === CheckResult::STATUS_TODO ) {
632
-			return new CheckResult( $context, $constraint, CheckResult::STATUS_TODO, null );
631
+		if ($checker->getSupportedEntityTypes()[$entityType] === CheckResult::STATUS_TODO) {
632
+			return new CheckResult($context, $constraint, CheckResult::STATUS_TODO, null);
633 633
 		}
634 634
 
635 635
 		return null;
636 636
 	}
637 637
 
638
-	private function addMetadata( Context $context, CheckResult $result ): void {
639
-		$result->withMetadata( Metadata::merge( [
638
+	private function addMetadata(Context $context, CheckResult $result): void {
639
+		$result->withMetadata(Metadata::merge([
640 640
 			$result->getMetadata(),
641
-			Metadata::ofDependencyMetadata( DependencyMetadata::merge( [
642
-				DependencyMetadata::ofEntityId( $context->getEntity()->getId() ),
643
-				DependencyMetadata::ofEntityId( $result->getConstraint()->getPropertyId() ),
644
-			] ) ),
645
-		] ) );
641
+			Metadata::ofDependencyMetadata(DependencyMetadata::merge([
642
+				DependencyMetadata::ofEntityId($context->getEntity()->getId()),
643
+				DependencyMetadata::ofEntityId($result->getConstraint()->getPropertyId()),
644
+			])),
645
+		]));
646 646
 	}
647 647
 
648
-	private function addConstraintClarification( CheckResult $result ): void {
648
+	private function addConstraintClarification(CheckResult $result): void {
649 649
 		$constraint = $result->getConstraint();
650 650
 		try {
651 651
 			$constraintClarification = $this->constraintParameterParser
652
-				->parseConstraintClarificationParameter( $constraint->getConstraintParameters() );
653
-			$result->setConstraintClarification( $constraintClarification );
654
-		} catch ( ConstraintParameterException $e ) {
655
-			$result->setStatus( CheckResult::STATUS_BAD_PARAMETERS );
656
-			$result->setMessage( $e->getViolationMessage() );
652
+				->parseConstraintClarificationParameter($constraint->getConstraintParameters());
653
+			$result->setConstraintClarification($constraintClarification);
654
+		} catch (ConstraintParameterException $e) {
655
+			$result->setStatus(CheckResult::STATUS_BAD_PARAMETERS);
656
+			$result->setMessage($e->getViolationMessage());
657 657
 		}
658 658
 	}
659 659
 
660
-	private function downgradeResultStatus( CheckResult $result ): void {
660
+	private function downgradeResultStatus(CheckResult $result): void {
661 661
 		$constraint = $result->getConstraint();
662 662
 		try {
663 663
 			$constraintStatus = $this->constraintParameterParser
664
-				->parseConstraintStatusParameter( $constraint->getConstraintParameters() );
665
-		} catch ( ConstraintParameterException $e ) {
666
-			$result->setStatus( CheckResult::STATUS_BAD_PARAMETERS );
667
-			$result->setMessage( $e->getViolationMessage() );
664
+				->parseConstraintStatusParameter($constraint->getConstraintParameters());
665
+		} catch (ConstraintParameterException $e) {
666
+			$result->setStatus(CheckResult::STATUS_BAD_PARAMETERS);
667
+			$result->setMessage($e->getViolationMessage());
668 668
 			return;
669 669
 		}
670
-		if ( $constraintStatus === null ) {
670
+		if ($constraintStatus === null) {
671 671
 			// downgrade violation to warning
672
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
673
-				$result->setStatus( CheckResult::STATUS_WARNING );
672
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
673
+				$result->setStatus(CheckResult::STATUS_WARNING);
674 674
 			}
675
-		} elseif ( $constraintStatus === 'suggestion' ) {
675
+		} elseif ($constraintStatus === 'suggestion') {
676 676
 			// downgrade violation to suggestion
677
-			if ( $result->getStatus() === CheckResult::STATUS_VIOLATION ) {
678
-				$result->setStatus( CheckResult::STATUS_SUGGESTION );
677
+			if ($result->getStatus() === CheckResult::STATUS_VIOLATION) {
678
+				$result->setStatus(CheckResult::STATUS_SUGGESTION);
679 679
 			}
680 680
 		} else {
681
-			if ( $constraintStatus !== 'mandatory' ) {
681
+			if ($constraintStatus !== 'mandatory') {
682 682
 				// @codeCoverageIgnoreStart
683 683
 				throw new LogicException(
684
-					"Unknown constraint status '$constraintStatus', " .
684
+					"Unknown constraint status '$constraintStatus', ".
685 685
 					"only known statuses are 'mandatory' and 'suggestion'"
686 686
 				);
687 687
 				// @codeCoverageIgnoreEnd
@@ -694,12 +694,12 @@  discard block
 block discarded – undo
694 694
 	 *
695 695
 	 * @return CheckResult[]
696 696
 	 */
697
-	private function sortResult( array $result ): array {
698
-		if ( count( $result ) < 2 ) {
697
+	private function sortResult(array $result): array {
698
+		if (count($result) < 2) {
699 699
 			return $result;
700 700
 		}
701 701
 
702
-		$sortFunction = static function ( CheckResult $a, CheckResult $b ) {
702
+		$sortFunction = static function(CheckResult $a, CheckResult $b) {
703 703
 			$orderNum = 0;
704 704
 			$order = [
705 705
 				CheckResult::STATUS_BAD_PARAMETERS => $orderNum++,
@@ -716,55 +716,55 @@  discard block
 block discarded – undo
716 716
 			$statusA = $a->getStatus();
717 717
 			$statusB = $b->getStatus();
718 718
 
719
-			$orderA = array_key_exists( $statusA, $order ) ? $order[ $statusA ] : $order[ 'other' ];
720
-			$orderB = array_key_exists( $statusB, $order ) ? $order[ $statusB ] : $order[ 'other' ];
719
+			$orderA = array_key_exists($statusA, $order) ? $order[$statusA] : $order['other'];
720
+			$orderB = array_key_exists($statusB, $order) ? $order[$statusB] : $order['other'];
721 721
 
722
-			if ( $orderA === $orderB ) {
722
+			if ($orderA === $orderB) {
723 723
 				$cursorA = $a->getContextCursor();
724 724
 				$cursorB = $b->getContextCursor();
725 725
 
726
-				if ( $cursorA instanceof EntityContextCursor ) {
726
+				if ($cursorA instanceof EntityContextCursor) {
727 727
 					return $cursorB instanceof EntityContextCursor ? 0 : -1;
728 728
 				}
729
-				if ( $cursorB instanceof EntityContextCursor ) {
729
+				if ($cursorB instanceof EntityContextCursor) {
730 730
 					return $cursorA instanceof EntityContextCursor ? 0 : 1;
731 731
 				}
732 732
 
733 733
 				$pidA = $cursorA->getSnakPropertyId();
734 734
 				$pidB = $cursorB->getSnakPropertyId();
735 735
 
736
-				if ( $pidA === $pidB ) {
736
+				if ($pidA === $pidB) {
737 737
 					$hashA = $cursorA->getSnakHash();
738 738
 					$hashB = $cursorB->getSnakHash();
739 739
 
740
-					if ( $hashA === $hashB ) {
741
-						if ( $a instanceof NullResult ) {
740
+					if ($hashA === $hashB) {
741
+						if ($a instanceof NullResult) {
742 742
 							return $b instanceof NullResult ? 0 : -1;
743 743
 						}
744
-						if ( $b instanceof NullResult ) {
744
+						if ($b instanceof NullResult) {
745 745
 							return $a instanceof NullResult ? 0 : 1;
746 746
 						}
747 747
 
748 748
 						$typeA = $a->getConstraint()->getConstraintTypeItemId();
749 749
 						$typeB = $b->getConstraint()->getConstraintTypeItemId();
750 750
 
751
-						if ( $typeA == $typeB ) {
751
+						if ($typeA == $typeB) {
752 752
 							return 0;
753 753
 						} else {
754
-							return ( $typeA > $typeB ) ? 1 : -1;
754
+							return ($typeA > $typeB) ? 1 : -1;
755 755
 						}
756 756
 					} else {
757
-						return ( $hashA > $hashB ) ? 1 : -1;
757
+						return ($hashA > $hashB) ? 1 : -1;
758 758
 					}
759 759
 				} else {
760
-					return ( $pidA > $pidB ) ? 1 : -1;
760
+					return ($pidA > $pidB) ? 1 : -1;
761 761
 				}
762 762
 			} else {
763
-				return ( $orderA > $orderB ) ? 1 : -1;
763
+				return ($orderA > $orderB) ? 1 : -1;
764 764
 			}
765 765
 		};
766 766
 
767
-		uasort( $result, $sortFunction );
767
+		uasort($result, $sortFunction);
768 768
 
769 769
 		return $result;
770 770
 	}
Please login to merge, or discard this patch.