@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | use Wikibase\Repo\WikibaseRepo; |
19 | 19 | |
20 | 20 | // @codeCoverageIgnoreStart |
21 | -$basePath = getenv( "MW_INSTALL_PATH" ) !== false |
|
22 | - ? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../.."; |
|
21 | +$basePath = getenv("MW_INSTALL_PATH") !== false |
|
22 | + ? getenv("MW_INSTALL_PATH") : __DIR__."/../../.."; |
|
23 | 23 | |
24 | -require_once $basePath . "/maintenance/Maintenance.php"; |
|
24 | +require_once $basePath."/maintenance/Maintenance.php"; |
|
25 | 25 | // @codeCoverageIgnoreEnd |
26 | 26 | |
27 | 27 | /** |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | parent::__construct(); |
61 | 61 | |
62 | 62 | $this->addDescription( |
63 | - 'Import entities needed for constraint checks ' . |
|
63 | + 'Import entities needed for constraint checks '. |
|
64 | 64 | 'from Wikidata into the local repository.' |
65 | 65 | ); |
66 | 66 | $this->addOption( |
67 | 67 | 'config-format', |
68 | - 'The format in which the resulting configuration will be omitted: ' . |
|
69 | - '"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), ' . |
|
68 | + 'The format in which the resulting configuration will be omitted: '. |
|
69 | + '"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), '. |
|
70 | 70 | 'or "wgConf" for printing parts of arrays suitable for inclusion in $wgConf->settings.' |
71 | 71 | ); |
72 | 72 | $this->addOption( |
73 | 73 | 'dry-run', |
74 | 74 | 'Don’t actually import entities, just print which ones would be imported.' |
75 | 75 | ); |
76 | - $this->requireExtension( 'WikibaseQualityConstraints' ); |
|
76 | + $this->requireExtension('WikibaseQualityConstraints'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | */ |
82 | 82 | private function setupServices() { |
83 | 83 | $services = MediaWikiServices::getInstance(); |
84 | - $this->entitySerializer = WikibaseRepo::getAllTypesEntitySerializer( $services ); |
|
85 | - $this->entityDeserializer = WikibaseRepo::getInternalFormatEntityDeserializer( $services ); |
|
86 | - $this->entityStore = WikibaseRepo::getEntityStore( $services ); |
|
84 | + $this->entitySerializer = WikibaseRepo::getAllTypesEntitySerializer($services); |
|
85 | + $this->entityDeserializer = WikibaseRepo::getInternalFormatEntityDeserializer($services); |
|
86 | + $this->entityStore = WikibaseRepo::getEntityStore($services); |
|
87 | 87 | $this->httpRequestFactory = $services->getHttpRequestFactory(); |
88 | - if ( !$this->getOption( 'dry-run', false ) ) { |
|
89 | - $this->user = User::newSystemUser( 'WikibaseQualityConstraints importer' ); |
|
88 | + if (!$this->getOption('dry-run', false)) { |
|
89 | + $this->user = User::newSystemUser('WikibaseQualityConstraints importer'); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -95,21 +95,21 @@ discard block |
||
95 | 95 | |
96 | 96 | $configUpdates = []; |
97 | 97 | |
98 | - $extensionJsonFile = __DIR__ . '/../extension.json'; |
|
99 | - $extensionJsonText = file_get_contents( $extensionJsonFile ); |
|
100 | - $extensionJson = json_decode( $extensionJsonText, /* assoc = */ true ); |
|
98 | + $extensionJsonFile = __DIR__.'/../extension.json'; |
|
99 | + $extensionJsonText = file_get_contents($extensionJsonFile); |
|
100 | + $extensionJson = json_decode($extensionJsonText, /* assoc = */ true); |
|
101 | 101 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable |
102 | - $wikidataEntityIds = $this->getEntitiesToImport( $extensionJson['config'], $this->getConfig() ); |
|
102 | + $wikidataEntityIds = $this->getEntitiesToImport($extensionJson['config'], $this->getConfig()); |
|
103 | 103 | |
104 | - foreach ( $wikidataEntityIds as $key => $wikidataEntityId ) { |
|
105 | - $localEntityId = $this->importEntityFromWikidata( $wikidataEntityId ); |
|
104 | + foreach ($wikidataEntityIds as $key => $wikidataEntityId) { |
|
105 | + $localEntityId = $this->importEntityFromWikidata($wikidataEntityId); |
|
106 | 106 | $configUpdates[$key] = [ |
107 | 107 | 'wikidata' => $wikidataEntityId, |
108 | 108 | 'local' => $localEntityId, |
109 | 109 | ]; |
110 | 110 | } |
111 | 111 | |
112 | - $this->outputConfigUpdates( $configUpdates ); |
|
112 | + $this->outputConfigUpdates($configUpdates); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | * @param Config $wikiConfig |
118 | 118 | * @return string[] |
119 | 119 | */ |
120 | - private function getEntitiesToImport( array $extensionJsonConfig, Config $wikiConfig ) { |
|
120 | + private function getEntitiesToImport(array $extensionJsonConfig, Config $wikiConfig) { |
|
121 | 121 | $wikidataEntityIds = []; |
122 | 122 | |
123 | - foreach ( $extensionJsonConfig as $key => $value ) { |
|
124 | - if ( !preg_match( '/Id$/', $key ) ) { |
|
123 | + foreach ($extensionJsonConfig as $key => $value) { |
|
124 | + if (!preg_match('/Id$/', $key)) { |
|
125 | 125 | continue; |
126 | 126 | } |
127 | 127 | |
128 | 128 | $wikidataEntityId = $value['value']; |
129 | - $localEntityId = $wikiConfig->get( $key ); |
|
129 | + $localEntityId = $wikiConfig->get($key); |
|
130 | 130 | |
131 | - if ( $localEntityId === $wikidataEntityId ) { |
|
131 | + if ($localEntityId === $wikidataEntityId) { |
|
132 | 132 | $wikidataEntityIds[$key] = $wikidataEntityId; |
133 | 133 | } |
134 | 134 | } |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | * @param string $wikidataEntityId |
141 | 141 | * @return string local entity ID |
142 | 142 | */ |
143 | - private function importEntityFromWikidata( $wikidataEntityId ) { |
|
143 | + private function importEntityFromWikidata($wikidataEntityId) { |
|
144 | 144 | $wikidataEntityUrl = "https://www.wikidata.org/wiki/Special:EntityData/$wikidataEntityId.json"; |
145 | - $wikidataEntitiesJson = $this->httpRequestFactory->get( $wikidataEntityUrl, [], __METHOD__ ); |
|
146 | - return $this->importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ); |
|
145 | + $wikidataEntitiesJson = $this->httpRequestFactory->get($wikidataEntityUrl, [], __METHOD__); |
|
146 | + return $this->importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -151,24 +151,24 @@ discard block |
||
151 | 151 | * @param string $wikidataEntitiesJson |
152 | 152 | * @return string local entity ID |
153 | 153 | */ |
154 | - private function importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ) { |
|
154 | + private function importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson) { |
|
155 | 155 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable |
156 | - $wikidataEntityArray = json_decode( $wikidataEntitiesJson, true )['entities'][$wikidataEntityId]; |
|
157 | - $wikidataEntity = $this->entityDeserializer->deserialize( $wikidataEntityArray ); |
|
156 | + $wikidataEntityArray = json_decode($wikidataEntitiesJson, true)['entities'][$wikidataEntityId]; |
|
157 | + $wikidataEntity = $this->entityDeserializer->deserialize($wikidataEntityArray); |
|
158 | 158 | |
159 | - $wikidataEntity->setId( null ); |
|
159 | + $wikidataEntity->setId(null); |
|
160 | 160 | |
161 | - if ( $wikidataEntity instanceof StatementListProvider ) { |
|
161 | + if ($wikidataEntity instanceof StatementListProvider) { |
|
162 | 162 | $wikidataEntity->getStatements()->clear(); |
163 | 163 | } |
164 | 164 | |
165 | - if ( $wikidataEntity instanceof Item ) { |
|
166 | - $wikidataEntity->setSiteLinkList( new SiteLinkList() ); |
|
165 | + if ($wikidataEntity instanceof Item) { |
|
166 | + $wikidataEntity->setSiteLinkList(new SiteLinkList()); |
|
167 | 167 | } |
168 | 168 | |
169 | - if ( $this->getOption( 'dry-run', false ) ) { |
|
170 | - $wikidataEntityJson = json_encode( $this->entitySerializer->serialize( $wikidataEntity ) ); |
|
171 | - $this->output( $wikidataEntityJson . "\n" ); |
|
169 | + if ($this->getOption('dry-run', false)) { |
|
170 | + $wikidataEntityJson = json_encode($this->entitySerializer->serialize($wikidataEntity)); |
|
171 | + $this->output($wikidataEntityJson."\n"); |
|
172 | 172 | return "-$wikidataEntityId"; |
173 | 173 | } |
174 | 174 | |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | )->getEntity(); |
182 | 182 | |
183 | 183 | return $localEntity->getId()->getSerialization(); |
184 | - } catch ( StorageException $storageException ) { |
|
185 | - return $this->storageExceptionToEntityId( $storageException ); |
|
184 | + } catch (StorageException $storageException) { |
|
185 | + return $this->storageExceptionToEntityId($storageException); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - private function storageExceptionToEntityId( StorageException $storageException ) { |
|
189 | + private function storageExceptionToEntityId(StorageException $storageException) { |
|
190 | 190 | $message = $storageException->getMessage(); |
191 | 191 | // example messages: |
192 | 192 | // * Item [[Item:Q475|Q475]] already has label "as references" |
@@ -196,25 +196,25 @@ discard block |
||
196 | 196 | // * Property [[Property:P694|P694]] already has label "instance of" |
197 | 197 | // associated with language code en. |
198 | 198 | $pattern = '/[[|]([^][|]*)]] already has label .* associated with language code/'; |
199 | - if ( preg_match( $pattern, $message, $matches ) ) { |
|
199 | + if (preg_match($pattern, $message, $matches)) { |
|
200 | 200 | return $matches[1]; |
201 | 201 | } else { |
202 | 202 | throw $storageException; |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | - private function outputConfigUpdates( array $configUpdates ) { |
|
207 | - $configFormat = $this->getOption( 'config-format', 'globals' ); |
|
208 | - switch ( $configFormat ) { |
|
206 | + private function outputConfigUpdates(array $configUpdates) { |
|
207 | + $configFormat = $this->getOption('config-format', 'globals'); |
|
208 | + switch ($configFormat) { |
|
209 | 209 | case 'globals': |
210 | - $this->outputConfigUpdatesGlobals( $configUpdates ); |
|
210 | + $this->outputConfigUpdatesGlobals($configUpdates); |
|
211 | 211 | break; |
212 | 212 | case 'wgConf': |
213 | - $this->outputConfigUpdatesWgConf( $configUpdates ); |
|
213 | + $this->outputConfigUpdatesWgConf($configUpdates); |
|
214 | 214 | break; |
215 | 215 | default: |
216 | - $this->error( "Invalid config format \"$configFormat\", using \"globals\"" ); |
|
217 | - $this->outputConfigUpdatesGlobals( $configUpdates ); |
|
216 | + $this->error("Invalid config format \"$configFormat\", using \"globals\""); |
|
217 | + $this->outputConfigUpdatesGlobals($configUpdates); |
|
218 | 218 | break; |
219 | 219 | } |
220 | 220 | } |
@@ -222,22 +222,22 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * @param array[] $configUpdates |
224 | 224 | */ |
225 | - private function outputConfigUpdatesGlobals( array $configUpdates ) { |
|
226 | - foreach ( $configUpdates as $key => $value ) { |
|
227 | - $localValueCode = var_export( $value['local'], true ); |
|
228 | - $this->output( "\$wg$key = $localValueCode;\n" ); |
|
225 | + private function outputConfigUpdatesGlobals(array $configUpdates) { |
|
226 | + foreach ($configUpdates as $key => $value) { |
|
227 | + $localValueCode = var_export($value['local'], true); |
|
228 | + $this->output("\$wg$key = $localValueCode;\n"); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
233 | 233 | * @param array[] $configUpdates |
234 | 234 | */ |
235 | - private function outputConfigUpdatesWgConf( array $configUpdates ) { |
|
236 | - $wikiIdCode = var_export( WikiMap::getCurrentWikiId(), true ); |
|
237 | - foreach ( $configUpdates as $key => $value ) { |
|
238 | - $keyCode = var_export( "wg$key", true ); |
|
239 | - $wikidataValueCode = var_export( $value['wikidata'], true ); |
|
240 | - $localValueCode = var_export( $value['local'], true ); |
|
235 | + private function outputConfigUpdatesWgConf(array $configUpdates) { |
|
236 | + $wikiIdCode = var_export(WikiMap::getCurrentWikiId(), true); |
|
237 | + foreach ($configUpdates as $key => $value) { |
|
238 | + $keyCode = var_export("wg$key", true); |
|
239 | + $wikidataValueCode = var_export($value['wikidata'], true); |
|
240 | + $localValueCode = var_export($value['local'], true); |
|
241 | 241 | $block = <<< EOF |
242 | 242 | $keyCode => [ |
243 | 243 | 'default' => $wikidataValueCode, |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | |
248 | 248 | EOF; |
249 | - $this->output( $block ); |
|
249 | + $this->output($block); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Result; |
6 | 6 | |
@@ -110,12 +110,12 @@ discard block |
||
110 | 110 | string $status = self::STATUS_TODO, |
111 | 111 | ViolationMessage $message = null |
112 | 112 | ) { |
113 | - if ( $contextCursor instanceof Context ) { |
|
113 | + if ($contextCursor instanceof Context) { |
|
114 | 114 | $context = $contextCursor; |
115 | 115 | $this->contextCursor = $context->getCursor(); |
116 | 116 | $this->snakType = $context->getSnak()->getType(); |
117 | 117 | $mainSnak = $context->getSnak(); |
118 | - if ( $mainSnak instanceof PropertyValueSnak ) { |
|
118 | + if ($mainSnak instanceof PropertyValueSnak) { |
|
119 | 119 | $this->dataValue = $mainSnak->getDataValue(); |
120 | 120 | } else { |
121 | 121 | $this->dataValue = null; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | $this->status = $status; |
130 | 130 | $this->message = $message; |
131 | 131 | $this->metadata = Metadata::blank(); |
132 | - $this->constraintClarification = new MultilingualTextValue( [] ); |
|
132 | + $this->constraintClarification = new MultilingualTextValue([]); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | public function getContextCursor(): ContextCursor { |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | return $this->status; |
166 | 166 | } |
167 | 167 | |
168 | - public function setStatus( string $status ): void { |
|
168 | + public function setStatus(string $status): void { |
|
169 | 169 | $this->status = $status; |
170 | 170 | } |
171 | 171 | |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | return $this->message; |
174 | 174 | } |
175 | 175 | |
176 | - public function setMessage( ?ViolationMessage $message ) { |
|
176 | + public function setMessage(?ViolationMessage $message) { |
|
177 | 177 | $this->message = $message; |
178 | 178 | } |
179 | 179 | |
180 | - public function withMetadata( Metadata $metadata ): self { |
|
180 | + public function withMetadata(Metadata $metadata): self { |
|
181 | 181 | $this->metadata = $metadata; |
182 | 182 | return $this; |
183 | 183 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | return $this->constraintClarification; |
191 | 191 | } |
192 | 192 | |
193 | - public function setConstraintClarification( MultilingualTextValue $constraintClarification ) { |
|
193 | + public function setConstraintClarification(MultilingualTextValue $constraintClarification) { |
|
194 | 194 | $this->constraintClarification = $constraintClarification; |
195 | 195 | } |
196 | 196 |
@@ -89,9 +89,9 @@ discard block |
||
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 | $constraintParameters = $constraint->getConstraintParameters(); |
@@ -104,9 +104,9 @@ discard block |
||
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, CheckResult::STATUS_COMPLIANCE ); |
|
109 | + return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | $dataValue = $snak->getDataValue(); |
@@ -115,18 +115,18 @@ discard block |
||
115 | 115 | * error handling: |
116 | 116 | * type of $dataValue for properties with 'Inverse' constraint has to be 'wikibase-entityid' |
117 | 117 | */ |
118 | - if ( !$dataValue instanceof EntityIdValue ) { |
|
119 | - $message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) ) |
|
120 | - ->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM ) |
|
121 | - ->withDataValueType( 'wikibase-entityid' ); |
|
122 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message ); |
|
118 | + if (!$dataValue instanceof EntityIdValue) { |
|
119 | + $message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type')) |
|
120 | + ->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM) |
|
121 | + ->withDataValueType('wikibase-entityid'); |
|
122 | + return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | $targetEntityId = $dataValue->getEntityId(); |
126 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
127 | - if ( !$targetEntity instanceof StatementListProvider ) { |
|
128 | - $message = new ViolationMessage( 'wbqc-violation-message-target-entity-must-exist' ); |
|
129 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message ); |
|
126 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
127 | + if (!$targetEntity instanceof StatementListProvider) { |
|
128 | + $message = new ViolationMessage('wbqc-violation-message-target-entity-must-exist'); |
|
129 | + return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | $inverseStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue( |
@@ -134,23 +134,23 @@ discard block |
||
134 | 134 | $propertyId, |
135 | 135 | $context->getEntity()->getId() |
136 | 136 | ); |
137 | - if ( $inverseStatement !== null ) { |
|
137 | + if ($inverseStatement !== null) { |
|
138 | 138 | $message = null; |
139 | 139 | $status = CheckResult::STATUS_COMPLIANCE; |
140 | 140 | } else { |
141 | - $message = ( new ViolationMessage( 'wbqc-violation-message-inverse' ) ) |
|
142 | - ->withEntityId( $targetEntityId, Role::SUBJECT ) |
|
143 | - ->withEntityId( $propertyId, Role::PREDICATE ) |
|
144 | - ->withEntityId( $context->getEntity()->getId(), Role::OBJECT ); |
|
141 | + $message = (new ViolationMessage('wbqc-violation-message-inverse')) |
|
142 | + ->withEntityId($targetEntityId, Role::SUBJECT) |
|
143 | + ->withEntityId($propertyId, Role::PREDICATE) |
|
144 | + ->withEntityId($context->getEntity()->getId(), Role::OBJECT); |
|
145 | 145 | $status = CheckResult::STATUS_VIOLATION; |
146 | 146 | } |
147 | 147 | |
148 | - return ( new CheckResult( $context, $constraint, $status, $message ) ) |
|
149 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
150 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
148 | + return (new CheckResult($context, $constraint, $status, $message)) |
|
149 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
150 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
151 | 151 | } |
152 | 152 | |
153 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
153 | + public function checkConstraintParameters(Constraint $constraint) { |
|
154 | 154 | $constraintParameters = $constraint->getConstraintParameters(); |
155 | 155 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
156 | 156 | $exceptions = []; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $constraintParameters, |
160 | 160 | $constraintTypeItemId |
161 | 161 | ); |
162 | - } catch ( ConstraintParameterException $e ) { |
|
162 | + } catch (ConstraintParameterException $e) { |
|
163 | 163 | $exceptions[] = $e; |
164 | 164 | } |
165 | 165 | return $exceptions; |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * @throws ConstraintParameterException |
80 | 80 | * @return CheckResult |
81 | 81 | */ |
82 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
83 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
84 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED ); |
|
82 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
83 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
84 | + return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | $constraintParameters = $constraint->getConstraintParameters(); |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | |
101 | 101 | $snak = $context->getSnak(); |
102 | 102 | |
103 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
103 | + if (!$snak instanceof PropertyValueSnak) { |
|
104 | 104 | // nothing to check |
105 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE ); |
|
105 | + return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | $dataValue = $snak->getDataValue(); |
@@ -111,18 +111,18 @@ discard block |
||
111 | 111 | * error handling: |
112 | 112 | * type of $dataValue for properties with 'Target required claim' constraint has to be 'wikibase-entityid' |
113 | 113 | */ |
114 | - if ( !$dataValue instanceof EntityIdValue ) { |
|
115 | - $message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) ) |
|
116 | - ->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM ) |
|
117 | - ->withDataValueType( 'wikibase-entityid' ); |
|
118 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message ); |
|
114 | + if (!$dataValue instanceof EntityIdValue) { |
|
115 | + $message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type')) |
|
116 | + ->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM) |
|
117 | + ->withDataValueType('wikibase-entityid'); |
|
118 | + return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $targetEntityId = $dataValue->getEntityId(); |
122 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
123 | - if ( !$targetEntity instanceof StatementListProvider ) { |
|
124 | - $message = new ViolationMessage( 'wbqc-violation-message-target-entity-must-exist' ); |
|
125 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message ); |
|
122 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
123 | + if (!$targetEntity instanceof StatementListProvider) { |
|
124 | + $message = new ViolationMessage('wbqc-violation-message-target-entity-must-exist'); |
|
125 | + return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /* |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * a) a property only |
131 | 131 | * b) a property and a number of items (each combination forming an individual claim) |
132 | 132 | */ |
133 | - if ( $items === [] ) { |
|
133 | + if ($items === []) { |
|
134 | 134 | $requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty( |
135 | 135 | $targetEntity->getStatements(), |
136 | 136 | $propertyId |
@@ -143,23 +143,23 @@ discard block |
||
143 | 143 | ); |
144 | 144 | } |
145 | 145 | |
146 | - if ( $requiredStatement !== null ) { |
|
146 | + if ($requiredStatement !== null) { |
|
147 | 147 | $status = CheckResult::STATUS_COMPLIANCE; |
148 | 148 | $message = null; |
149 | 149 | } else { |
150 | 150 | $status = CheckResult::STATUS_VIOLATION; |
151 | - $message = ( new ViolationMessage( 'wbqc-violation-message-target-required-claim' ) ) |
|
152 | - ->withEntityId( $targetEntityId, Role::SUBJECT ) |
|
153 | - ->withEntityId( $propertyId, Role::PREDICATE ) |
|
154 | - ->withItemIdSnakValueList( $items, Role::OBJECT ); |
|
151 | + $message = (new ViolationMessage('wbqc-violation-message-target-required-claim')) |
|
152 | + ->withEntityId($targetEntityId, Role::SUBJECT) |
|
153 | + ->withEntityId($propertyId, Role::PREDICATE) |
|
154 | + ->withItemIdSnakValueList($items, Role::OBJECT); |
|
155 | 155 | } |
156 | 156 | |
157 | - return ( new CheckResult( $context, $constraint, $status, $message ) ) |
|
158 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
159 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
157 | + return (new CheckResult($context, $constraint, $status, $message)) |
|
158 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
159 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
160 | 160 | } |
161 | 161 | |
162 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
162 | + public function checkConstraintParameters(Constraint $constraint) { |
|
163 | 163 | $constraintParameters = $constraint->getConstraintParameters(); |
164 | 164 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
165 | 165 | $exceptions = []; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $constraintParameters, |
169 | 169 | $constraintTypeItemId |
170 | 170 | ); |
171 | - } catch ( ConstraintParameterException $e ) { |
|
171 | + } catch (ConstraintParameterException $e) { |
|
172 | 172 | $exceptions[] = $e; |
173 | 173 | } |
174 | 174 | try { |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $constraintTypeItemId, |
178 | 178 | false |
179 | 179 | ); |
180 | - } catch ( ConstraintParameterException $e ) { |
|
180 | + } catch (ConstraintParameterException $e) { |
|
181 | 181 | $exceptions[] = $e; |
182 | 182 | } |
183 | 183 | return $exceptions; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @codeCoverageIgnore This method is purely declarative. |
31 | 31 | */ |
32 | 32 | public function getDefaultContextTypes() { |
33 | - return [ Context::TYPE_STATEMENT ]; |
|
33 | + return [Context::TYPE_STATEMENT]; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** @codeCoverageIgnore This method is purely declarative. */ |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | return self::ALL_ENTITY_TYPES_SUPPORTED; |
39 | 39 | } |
40 | 40 | |
41 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
41 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
42 | 42 | $referenceList = $context->getSnakStatement()->getReferences(); |
43 | 43 | |
44 | - if ( $referenceList->isEmpty() ) { |
|
45 | - $message = ( new ViolationMessage( 'wbqc-violation-message-citationNeeded' ) ) |
|
46 | - ->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ); |
|
44 | + if ($referenceList->isEmpty()) { |
|
45 | + $message = (new ViolationMessage('wbqc-violation-message-citationNeeded')) |
|
46 | + ->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY); |
|
47 | 47 | return new CheckResult( |
48 | 48 | $context, |
49 | 49 | $constraint, |
@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | ); |
53 | 53 | } |
54 | 54 | |
55 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE ); |
|
55 | + return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE); |
|
56 | 56 | } |
57 | 57 | |
58 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
58 | + public function checkConstraintParameters(Constraint $constraint) { |
|
59 | 59 | // no parameters |
60 | 60 | return []; |
61 | 61 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @throws ConstraintParameterException |
58 | 58 | * @return CheckResult |
59 | 59 | */ |
60 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
61 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
62 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED ); |
|
60 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
61 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
62 | + return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | $constraintParameters = $constraint->getConstraintParameters(); |
@@ -76,20 +76,20 @@ discard block |
||
76 | 76 | $message = null; |
77 | 77 | $status = CheckResult::STATUS_COMPLIANCE; |
78 | 78 | |
79 | - foreach ( $items as $item ) { |
|
80 | - if ( $item->matchesSnak( $snak ) ) { |
|
81 | - $message = ( new ViolationMessage( 'wbqc-violation-message-none-of' ) ) |
|
82 | - ->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) |
|
83 | - ->withItemIdSnakValueList( $items, Role::OBJECT ); |
|
79 | + foreach ($items as $item) { |
|
80 | + if ($item->matchesSnak($snak)) { |
|
81 | + $message = (new ViolationMessage('wbqc-violation-message-none-of')) |
|
82 | + ->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE) |
|
83 | + ->withItemIdSnakValueList($items, Role::OBJECT); |
|
84 | 84 | $status = CheckResult::STATUS_VIOLATION; |
85 | 85 | break; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | - return new CheckResult( $context, $constraint, $status, $message ); |
|
89 | + return new CheckResult($context, $constraint, $status, $message); |
|
90 | 90 | } |
91 | 91 | |
92 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
92 | + public function checkConstraintParameters(Constraint $constraint) { |
|
93 | 93 | $constraintParameters = $constraint->getConstraintParameters(); |
94 | 94 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
95 | 95 | $exceptions = []; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $constraintTypeItemId, |
100 | 100 | true |
101 | 101 | ); |
102 | - } catch ( ConstraintParameterException $e ) { |
|
102 | + } catch (ConstraintParameterException $e) { |
|
103 | 103 | $exceptions[] = $e; |
104 | 104 | } |
105 | 105 | return $exceptions; |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | * @throws ConstraintParameterException |
58 | 58 | * @return CheckResult |
59 | 59 | */ |
60 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
61 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
62 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED ); |
|
60 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
61 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
62 | + return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | $constraintParameters = $constraint->getConstraintParameters(); |
@@ -73,23 +73,23 @@ discard block |
||
73 | 73 | |
74 | 74 | $snak = $context->getSnak(); |
75 | 75 | |
76 | - $message = ( new ViolationMessage( 'wbqc-violation-message-one-of' ) ) |
|
77 | - ->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) |
|
78 | - ->withItemIdSnakValueList( $items, Role::OBJECT ); |
|
76 | + $message = (new ViolationMessage('wbqc-violation-message-one-of')) |
|
77 | + ->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE) |
|
78 | + ->withItemIdSnakValueList($items, Role::OBJECT); |
|
79 | 79 | $status = CheckResult::STATUS_VIOLATION; |
80 | 80 | |
81 | - foreach ( $items as $item ) { |
|
82 | - if ( $item->matchesSnak( $snak ) ) { |
|
81 | + foreach ($items as $item) { |
|
82 | + if ($item->matchesSnak($snak)) { |
|
83 | 83 | $message = null; |
84 | 84 | $status = CheckResult::STATUS_COMPLIANCE; |
85 | 85 | break; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | - return new CheckResult( $context, $constraint, $status, $message ); |
|
89 | + return new CheckResult($context, $constraint, $status, $message); |
|
90 | 90 | } |
91 | 91 | |
92 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
92 | + public function checkConstraintParameters(Constraint $constraint) { |
|
93 | 93 | $constraintParameters = $constraint->getConstraintParameters(); |
94 | 94 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
95 | 95 | $exceptions = []; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $constraintTypeItemId, |
100 | 100 | true |
101 | 101 | ); |
102 | - } catch ( ConstraintParameterException $e ) { |
|
102 | + } catch (ConstraintParameterException $e) { |
|
103 | 103 | $exceptions[] = $e; |
104 | 104 | } |
105 | 105 | return $exceptions; |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return CheckResult |
65 | 65 | */ |
66 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
67 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
68 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED ); |
|
66 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
67 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
68 | + return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $separators = $this->constraintParameterParser->parseSeparatorsParameter( |
@@ -74,13 +74,13 @@ discard block |
||
74 | 74 | |
75 | 75 | $propertyId = $context->getSnak()->getPropertyId(); |
76 | 76 | $bestRankCount = $this->valueCountCheckerHelper->getPropertyCount( |
77 | - $context->getSnakGroup( Context::GROUP_BEST_RANK, $separators ), |
|
77 | + $context->getSnakGroup(Context::GROUP_BEST_RANK, $separators), |
|
78 | 78 | $propertyId |
79 | 79 | ); |
80 | 80 | |
81 | - if ( $bestRankCount > 1 ) { |
|
81 | + if ($bestRankCount > 1) { |
|
82 | 82 | $nonDeprecatedCount = $this->valueCountCheckerHelper->getPropertyCount( |
83 | - $context->getSnakGroup( Context::GROUP_NON_DEPRECATED ), |
|
83 | + $context->getSnakGroup(Context::GROUP_NON_DEPRECATED), |
|
84 | 84 | $propertyId |
85 | 85 | ); |
86 | 86 | $message = $this->getViolationMessage( |
@@ -95,15 +95,15 @@ discard block |
||
95 | 95 | $status = CheckResult::STATUS_COMPLIANCE; |
96 | 96 | } |
97 | 97 | |
98 | - return new CheckResult( $context, $constraint, $status, $message ); |
|
98 | + return new CheckResult($context, $constraint, $status, $message); |
|
99 | 99 | } |
100 | 100 | |
101 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
101 | + public function checkConstraintParameters(Constraint $constraint) { |
|
102 | 102 | $constraintParameters = $constraint->getConstraintParameters(); |
103 | 103 | $exceptions = []; |
104 | 104 | try { |
105 | - $this->constraintParameterParser->parseSeparatorsParameter( $constraintParameters ); |
|
106 | - } catch ( ConstraintParameterException $e ) { |
|
105 | + $this->constraintParameterParser->parseSeparatorsParameter($constraintParameters); |
|
106 | + } catch (ConstraintParameterException $e) { |
|
107 | 107 | $exceptions[] = $e; |
108 | 108 | } |
109 | 109 | return $exceptions; |
@@ -122,23 +122,23 @@ discard block |
||
122 | 122 | $separators, |
123 | 123 | $propertyId |
124 | 124 | ) { |
125 | - if ( $bestRankCount === $nonDeprecatedCount ) { |
|
126 | - if ( $separators === [] ) { |
|
125 | + if ($bestRankCount === $nonDeprecatedCount) { |
|
126 | + if ($separators === []) { |
|
127 | 127 | $messageKey = 'wbqc-violation-message-single-best-value-no-preferred'; |
128 | 128 | } else { |
129 | 129 | $messageKey = 'wbqc-violation-message-single-best-value-no-preferred-separators'; |
130 | 130 | } |
131 | 131 | } else { |
132 | - if ( $separators === [] ) { |
|
132 | + if ($separators === []) { |
|
133 | 133 | $messageKey = 'wbqc-violation-message-single-best-value-multi-preferred'; |
134 | 134 | } else { |
135 | 135 | $messageKey = 'wbqc-violation-message-single-best-value-multi-preferred-separators'; |
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | - return ( new ViolationMessage( $messageKey ) ) |
|
140 | - ->withEntityId( $propertyId ) |
|
141 | - ->withEntityIdList( $separators ); |
|
139 | + return (new ViolationMessage($messageKey)) |
|
140 | + ->withEntityId($propertyId) |
|
141 | + ->withEntityIdList($separators); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | } |
@@ -88,9 +88,9 @@ discard block |
||
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 ) { |
|
92 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
93 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED ); |
|
91 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
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 |
||
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 |
||
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 $e ) { |
|
137 | + $item = $this->entityLookup->getEntity($dataValue->getEntityId()); |
|
138 | + } catch (UnresolvedEntityRedirectException $e) { |
|
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 |
||
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 |
||
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 ) { |
|
174 | + public function checkConstraintParameters(Constraint $constraint) { |
|
175 | 175 | $constraintParameters = $constraint->getConstraintParameters(); |
176 | 176 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
177 | 177 | $exceptions = []; |
@@ -180,7 +180,7 @@ discard block |
||
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 |
||
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; |