@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @throws ConstraintParameterException |
85 | 85 | * @return CheckResult |
86 | 86 | */ |
87 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
88 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
89 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
87 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
88 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
89 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | $parameters = []; |
@@ -97,13 +97,13 @@ discard block |
||
97 | 97 | $constraintParameters, |
98 | 98 | $constraintTypeItemId |
99 | 99 | ); |
100 | - $parameters['property'] = [ $propertyId ]; |
|
100 | + $parameters['property'] = [$propertyId]; |
|
101 | 101 | |
102 | 102 | $snak = $context->getSnak(); |
103 | 103 | |
104 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
104 | + if (!$snak instanceof PropertyValueSnak) { |
|
105 | 105 | // nothing to check |
106 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
106 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | $dataValue = $snak->getDataValue(); |
@@ -112,18 +112,18 @@ discard block |
||
112 | 112 | * error handling: |
113 | 113 | * type of $dataValue for properties with 'Inverse' constraint has to be 'wikibase-entityid' |
114 | 114 | */ |
115 | - if ( !$dataValue instanceof EntityIdValue ) { |
|
116 | - $message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) ) |
|
117 | - ->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM ) |
|
118 | - ->withDataValueType( 'wikibase-entityid' ); |
|
119 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
115 | + if (!$dataValue instanceof EntityIdValue) { |
|
116 | + $message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type')) |
|
117 | + ->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM) |
|
118 | + ->withDataValueType('wikibase-entityid'); |
|
119 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | $targetEntityId = $dataValue->getEntityId(); |
123 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
124 | - if ( !$targetEntity instanceof StatementListProvider ) { |
|
125 | - $message = new ViolationMessage( 'wbqc-violation-message-target-entity-must-exist' ); |
|
126 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
123 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
124 | + if (!$targetEntity instanceof StatementListProvider) { |
|
125 | + $message = new ViolationMessage('wbqc-violation-message-target-entity-must-exist'); |
|
126 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | $inverseStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue( |
@@ -131,23 +131,23 @@ discard block |
||
131 | 131 | $propertyId, |
132 | 132 | $context->getEntity()->getId() |
133 | 133 | ); |
134 | - if ( $inverseStatement !== null ) { |
|
134 | + if ($inverseStatement !== null) { |
|
135 | 135 | $message = null; |
136 | 136 | $status = CheckResult::STATUS_COMPLIANCE; |
137 | 137 | } else { |
138 | - $message = ( new ViolationMessage( 'wbqc-violation-message-inverse' ) ) |
|
139 | - ->withEntityId( $targetEntityId, Role::SUBJECT ) |
|
140 | - ->withEntityId( $propertyId, Role::PREDICATE ) |
|
141 | - ->withEntityId( $context->getEntity()->getId(), Role::OBJECT ); |
|
138 | + $message = (new ViolationMessage('wbqc-violation-message-inverse')) |
|
139 | + ->withEntityId($targetEntityId, Role::SUBJECT) |
|
140 | + ->withEntityId($propertyId, Role::PREDICATE) |
|
141 | + ->withEntityId($context->getEntity()->getId(), Role::OBJECT); |
|
142 | 142 | $status = CheckResult::STATUS_VIOLATION; |
143 | 143 | } |
144 | 144 | |
145 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
146 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
147 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
145 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
146 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
147 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
148 | 148 | } |
149 | 149 | |
150 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
150 | + public function checkConstraintParameters(Constraint $constraint) { |
|
151 | 151 | $constraintParameters = $constraint->getConstraintParameters(); |
152 | 152 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
153 | 153 | $exceptions = []; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $constraintParameters, |
157 | 157 | $constraintTypeItemId |
158 | 158 | ); |
159 | - } catch ( ConstraintParameterException $e ) { |
|
159 | + } catch (ConstraintParameterException $e) { |
|
160 | 160 | $exceptions[] = $e; |
161 | 161 | } |
162 | 162 | return $exceptions; |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | * @throws ConstraintParameterException |
83 | 83 | * @return CheckResult |
84 | 84 | */ |
85 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
86 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
87 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
85 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
86 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
87 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | $parameters = []; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | $constraintParameters, |
96 | 96 | $constraintTypeItemId |
97 | 97 | ); |
98 | - $parameters['property'] = [ $propertyId ]; |
|
98 | + $parameters['property'] = [$propertyId]; |
|
99 | 99 | |
100 | 100 | $items = $this->constraintParameterParser->parseItemsParameter( |
101 | 101 | $constraintParameters, |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | |
107 | 107 | $snak = $context->getSnak(); |
108 | 108 | |
109 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
109 | + if (!$snak instanceof PropertyValueSnak) { |
|
110 | 110 | // nothing to check |
111 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
111 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | $dataValue = $snak->getDataValue(); |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | * error handling: |
118 | 118 | * type of $dataValue for properties with 'Target required claim' constraint has to be 'wikibase-entityid' |
119 | 119 | */ |
120 | - if ( !$dataValue instanceof EntityIdValue ) { |
|
121 | - $message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) ) |
|
122 | - ->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM ) |
|
123 | - ->withDataValueType( 'wikibase-entityid' ); |
|
124 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
120 | + if (!$dataValue instanceof EntityIdValue) { |
|
121 | + $message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type')) |
|
122 | + ->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM) |
|
123 | + ->withDataValueType('wikibase-entityid'); |
|
124 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | $targetEntityId = $dataValue->getEntityId(); |
128 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
129 | - if ( !$targetEntity instanceof StatementListProvider ) { |
|
130 | - $message = new ViolationMessage( 'wbqc-violation-message-target-entity-must-exist' ); |
|
131 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
128 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
129 | + if (!$targetEntity instanceof StatementListProvider) { |
|
130 | + $message = new ViolationMessage('wbqc-violation-message-target-entity-must-exist'); |
|
131 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /* |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * a) a property only |
137 | 137 | * b) a property and a number of items (each combination forming an individual claim) |
138 | 138 | */ |
139 | - if ( $items === [] ) { |
|
139 | + if ($items === []) { |
|
140 | 140 | $requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty( |
141 | 141 | $targetEntity->getStatements(), |
142 | 142 | $propertyId |
@@ -149,23 +149,23 @@ discard block |
||
149 | 149 | ); |
150 | 150 | } |
151 | 151 | |
152 | - if ( $requiredStatement !== null ) { |
|
152 | + if ($requiredStatement !== null) { |
|
153 | 153 | $status = CheckResult::STATUS_COMPLIANCE; |
154 | 154 | $message = null; |
155 | 155 | } else { |
156 | 156 | $status = CheckResult::STATUS_VIOLATION; |
157 | - $message = ( new ViolationMessage( 'wbqc-violation-message-target-required-claim' ) ) |
|
158 | - ->withEntityId( $targetEntityId, Role::SUBJECT ) |
|
159 | - ->withEntityId( $propertyId, Role::PREDICATE ) |
|
160 | - ->withItemIdSnakValueList( $items, Role::OBJECT ); |
|
157 | + $message = (new ViolationMessage('wbqc-violation-message-target-required-claim')) |
|
158 | + ->withEntityId($targetEntityId, Role::SUBJECT) |
|
159 | + ->withEntityId($propertyId, Role::PREDICATE) |
|
160 | + ->withItemIdSnakValueList($items, Role::OBJECT); |
|
161 | 161 | } |
162 | 162 | |
163 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
164 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
165 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
163 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
164 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
165 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
166 | 166 | } |
167 | 167 | |
168 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
168 | + public function checkConstraintParameters(Constraint $constraint) { |
|
169 | 169 | $constraintParameters = $constraint->getConstraintParameters(); |
170 | 170 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
171 | 171 | $exceptions = []; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $constraintParameters, |
175 | 175 | $constraintTypeItemId |
176 | 176 | ); |
177 | - } catch ( ConstraintParameterException $e ) { |
|
177 | + } catch (ConstraintParameterException $e) { |
|
178 | 178 | $exceptions[] = $e; |
179 | 179 | } |
180 | 180 | try { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | $constraintTypeItemId, |
184 | 184 | false |
185 | 185 | ); |
186 | - } catch ( ConstraintParameterException $e ) { |
|
186 | + } catch (ConstraintParameterException $e) { |
|
187 | 187 | $exceptions[] = $e; |
188 | 188 | } |
189 | 189 | return $exceptions; |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs |
92 | 92 | * @return CheckResult |
93 | 93 | */ |
94 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
95 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
96 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
94 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
95 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
96 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | $parameters = []; |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | $constraintTypeItemId |
106 | 106 | ); |
107 | 107 | $parameters['class'] = array_map( |
108 | - function( $id ) { |
|
109 | - return new ItemId( $id ); |
|
108 | + function($id) { |
|
109 | + return new ItemId($id); |
|
110 | 110 | }, |
111 | 111 | $classes |
112 | 112 | ); |
@@ -116,19 +116,19 @@ discard block |
||
116 | 116 | $constraintTypeItemId |
117 | 117 | ); |
118 | 118 | $relationIds = []; |
119 | - if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) { |
|
120 | - $relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' ); |
|
119 | + if ($relation === 'instance' || $relation === 'instanceOrSubclass') { |
|
120 | + $relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId'); |
|
121 | 121 | } |
122 | - if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) { |
|
123 | - $relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' ); |
|
122 | + if ($relation === 'subclass' || $relation === 'instanceOrSubclass') { |
|
123 | + $relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId'); |
|
124 | 124 | } |
125 | - $parameters['relation'] = [ $relation ]; |
|
125 | + $parameters['relation'] = [$relation]; |
|
126 | 126 | |
127 | 127 | $snak = $context->getSnak(); |
128 | 128 | |
129 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
129 | + if (!$snak instanceof PropertyValueSnak) { |
|
130 | 130 | // nothing to check |
131 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
131 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $dataValue = $snak->getDataValue(); |
@@ -137,23 +137,23 @@ discard block |
||
137 | 137 | * error handling: |
138 | 138 | * type of $dataValue for properties with 'Value type' constraint has to be 'wikibase-entityid' |
139 | 139 | */ |
140 | - if ( !$dataValue instanceof EntityIdValue ) { |
|
141 | - $message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) ) |
|
142 | - ->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM ) |
|
143 | - ->withDataValueType( 'wikibase-entityid' ); |
|
144 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
140 | + if (!$dataValue instanceof EntityIdValue) { |
|
141 | + $message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type')) |
|
142 | + ->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM) |
|
143 | + ->withDataValueType('wikibase-entityid'); |
|
144 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | try { |
148 | - $item = $this->entityLookup->getEntity( $dataValue->getEntityId() ); |
|
149 | - } catch ( UnresolvedEntityRedirectException $e ) { |
|
148 | + $item = $this->entityLookup->getEntity($dataValue->getEntityId()); |
|
149 | + } catch (UnresolvedEntityRedirectException $e) { |
|
150 | 150 | // Edge case (double redirect): Pretend the entity doesn't exist |
151 | 151 | $item = null; |
152 | 152 | } |
153 | 153 | |
154 | - if ( !( $item instanceof StatementListProvider ) ) { |
|
155 | - $message = new ViolationMessage( 'wbqc-violation-message-value-entity-must-exist' ); |
|
156 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
154 | + if (!($item instanceof StatementListProvider)) { |
|
155 | + $message = new ViolationMessage('wbqc-violation-message-value-entity-must-exist'); |
|
156 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | $statements = $item->getStatements(); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $classes |
165 | 165 | ); |
166 | 166 | |
167 | - if ( $result->getBool() ) { |
|
167 | + if ($result->getBool()) { |
|
168 | 168 | $message = null; |
169 | 169 | $status = CheckResult::STATUS_COMPLIANCE; |
170 | 170 | } else { |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | $status = CheckResult::STATUS_VIOLATION; |
179 | 179 | } |
180 | 180 | |
181 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
182 | - ->withMetadata( $result->getMetadata() ); |
|
181 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
182 | + ->withMetadata($result->getMetadata()); |
|
183 | 183 | } |
184 | 184 | |
185 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
185 | + public function checkConstraintParameters(Constraint $constraint) { |
|
186 | 186 | $constraintParameters = $constraint->getConstraintParameters(); |
187 | 187 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
188 | 188 | $exceptions = []; |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $constraintParameters, |
192 | 192 | $constraintTypeItemId |
193 | 193 | ); |
194 | - } catch ( ConstraintParameterException $e ) { |
|
194 | + } catch (ConstraintParameterException $e) { |
|
195 | 195 | $exceptions[] = $e; |
196 | 196 | } |
197 | 197 | try { |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $constraintParameters, |
200 | 200 | $constraintTypeItemId |
201 | 201 | ); |
202 | - } catch ( ConstraintParameterException $e ) { |
|
202 | + } catch (ConstraintParameterException $e) { |
|
203 | 203 | $exceptions[] = $e; |
204 | 204 | } |
205 | 205 | return $exceptions; |
@@ -8,19 +8,19 @@ |
||
8 | 8 | use Wikibase\Store; |
9 | 9 | |
10 | 10 | return [ |
11 | - WikibaseServices::ENTITY_LOOKUP => function( MediaWikiServices $services ) { |
|
11 | + WikibaseServices::ENTITY_LOOKUP => function(MediaWikiServices $services) { |
|
12 | 12 | return new ExceptionIgnoringEntityLookup( |
13 | 13 | WikibaseRepo::getDefaultInstance()->getEntityLookup() |
14 | 14 | ); |
15 | 15 | }, |
16 | 16 | |
17 | - WikibaseServices::ENTITY_LOOKUP_WITHOUT_CACHE => function( MediaWikiServices $services ) { |
|
17 | + WikibaseServices::ENTITY_LOOKUP_WITHOUT_CACHE => function(MediaWikiServices $services) { |
|
18 | 18 | return new ExceptionIgnoringEntityLookup( |
19 | - WikibaseRepo::getDefaultInstance()->getEntityLookup( Store::LOOKUP_CACHING_RETRIEVE_ONLY ) |
|
19 | + WikibaseRepo::getDefaultInstance()->getEntityLookup(Store::LOOKUP_CACHING_RETRIEVE_ONLY) |
|
20 | 20 | ); |
21 | 21 | }, |
22 | 22 | |
23 | - WikibaseServices::PROPERTY_DATA_TYPE_LOOKUP => function( MediaWikiServices $services ) { |
|
23 | + WikibaseServices::PROPERTY_DATA_TYPE_LOOKUP => function(MediaWikiServices $services) { |
|
24 | 24 | return WikibaseRepo::getDefaultInstance()->getPropertyDataTypeLookup(); |
25 | 25 | }, |
26 | 26 | ]; |