@@ -46,16 +46,16 @@ |
||
46 | 46 | * |
47 | 47 | * @return CheckResult |
48 | 48 | */ |
49 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
50 | - if ( $context->getType() === Context::TYPE_QUALIFIER ) { |
|
51 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE ); |
|
49 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
50 | + if ($context->getType() === Context::TYPE_QUALIFIER) { |
|
51 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE); |
|
52 | 52 | } else { |
53 | - $message = wfMessage( 'wbqc-violation-message-qualifier' )->escaped(); |
|
54 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message ); |
|
53 | + $message = wfMessage('wbqc-violation-message-qualifier')->escaped(); |
|
54 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message); |
|
55 | 55 | } |
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 | } |
@@ -97,37 +97,37 @@ discard block |
||
97 | 97 | * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs |
98 | 98 | * @return CheckResult |
99 | 99 | */ |
100 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
101 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
102 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
100 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
101 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
102 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | $parameters = []; |
106 | 106 | $constraintParameters = $constraint->getConstraintParameters(); |
107 | 107 | |
108 | - $classes = $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
108 | + $classes = $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
109 | 109 | $parameters['class'] = array_map( |
110 | - function( $id ) { |
|
111 | - return new ItemId( $id ); |
|
110 | + function($id) { |
|
111 | + return new ItemId($id); |
|
112 | 112 | }, |
113 | 113 | $classes |
114 | 114 | ); |
115 | 115 | |
116 | - $relation = $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
116 | + $relation = $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
117 | 117 | $relationIds = []; |
118 | - if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) { |
|
119 | - $relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' ); |
|
118 | + if ($relation === 'instance' || $relation === 'instanceOrSubclass') { |
|
119 | + $relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId'); |
|
120 | 120 | } |
121 | - if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) { |
|
122 | - $relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' ); |
|
121 | + if ($relation === 'subclass' || $relation === 'instanceOrSubclass') { |
|
122 | + $relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId'); |
|
123 | 123 | } |
124 | - $parameters['relation'] = [ $relation ]; |
|
124 | + $parameters['relation'] = [$relation]; |
|
125 | 125 | |
126 | 126 | $snak = $context->getSnak(); |
127 | 127 | |
128 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
128 | + if (!$snak instanceof PropertyValueSnak) { |
|
129 | 129 | // nothing to check |
130 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
130 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | $dataValue = $snak->getDataValue(); |
@@ -136,22 +136,22 @@ discard block |
||
136 | 136 | * error handling: |
137 | 137 | * type of $dataValue for properties with 'Value type' constraint has to be 'wikibase-entityid' |
138 | 138 | */ |
139 | - if ( $dataValue->getType() !== 'wikibase-entityid' ) { |
|
140 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
139 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
140 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
141 | 141 | ->rawParams( |
142 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
142 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
143 | 143 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
144 | 144 | ) |
145 | 145 | ->escaped(); |
146 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
146 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
147 | 147 | } |
148 | 148 | /** @var EntityIdValue $dataValue */ |
149 | 149 | |
150 | - $item = $this->entityLookup->getEntity( $dataValue->getEntityId() ); |
|
150 | + $item = $this->entityLookup->getEntity($dataValue->getEntityId()); |
|
151 | 151 | |
152 | - if ( !( $item instanceof StatementListProvider ) ) { |
|
153 | - $message = wfMessage( "wbqc-violation-message-value-entity-must-exist" )->escaped(); |
|
154 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
152 | + if (!($item instanceof StatementListProvider)) { |
|
153 | + $message = wfMessage("wbqc-violation-message-value-entity-must-exist")->escaped(); |
|
154 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | $statements = $item->getStatements(); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $classes |
163 | 163 | ); |
164 | 164 | |
165 | - if ( $result->getBool() ) { |
|
165 | + if ($result->getBool()) { |
|
166 | 166 | $message = null; |
167 | 167 | $status = CheckResult::STATUS_COMPLIANCE; |
168 | 168 | } else { |
@@ -176,21 +176,21 @@ discard block |
||
176 | 176 | $status = CheckResult::STATUS_VIOLATION; |
177 | 177 | } |
178 | 178 | |
179 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
180 | - ->withMetadata( $result->getMetadata() ); |
|
179 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
180 | + ->withMetadata($result->getMetadata()); |
|
181 | 181 | } |
182 | 182 | |
183 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
183 | + public function checkConstraintParameters(Constraint $constraint) { |
|
184 | 184 | $constraintParameters = $constraint->getConstraintParameters(); |
185 | 185 | $exceptions = []; |
186 | 186 | try { |
187 | - $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
188 | - } catch ( ConstraintParameterException $e ) { |
|
187 | + $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
188 | + } catch (ConstraintParameterException $e) { |
|
189 | 189 | $exceptions[] = $e; |
190 | 190 | } |
191 | 191 | try { |
192 | - $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
193 | - } catch ( ConstraintParameterException $e ) { |
|
192 | + $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
193 | + } catch (ConstraintParameterException $e) { |
|
194 | 194 | $exceptions[] = $e; |
195 | 195 | } |
196 | 196 | return $exceptions; |
@@ -93,26 +93,26 @@ discard block |
||
93 | 93 | * @throws ConstraintParameterException |
94 | 94 | * @return CheckResult |
95 | 95 | */ |
96 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
96 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
97 | 97 | $parameters = []; |
98 | 98 | $constraintParameters = $constraint->getConstraintParameters(); |
99 | 99 | |
100 | - $format = $this->constraintParameterParser->parseFormatParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
101 | - $parameters['pattern'] = [ $format ]; |
|
100 | + $format = $this->constraintParameterParser->parseFormatParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
101 | + $parameters['pattern'] = [$format]; |
|
102 | 102 | |
103 | 103 | $syntaxClarification = $this->constraintParameterParser->parseSyntaxClarificationParameter( |
104 | 104 | $constraintParameters, |
105 | 105 | WikibaseRepo::getDefaultInstance()->getUserLanguage() // TODO make this part of the Context? |
106 | 106 | ); |
107 | - if ( $syntaxClarification !== null ) { |
|
108 | - $parameters['clarification'] = [ $syntaxClarification ]; |
|
107 | + if ($syntaxClarification !== null) { |
|
108 | + $parameters['clarification'] = [$syntaxClarification]; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | $snak = $context->getSnak(); |
112 | 112 | |
113 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
113 | + if (!$snak instanceof PropertyValueSnak) { |
|
114 | 114 | // nothing to check |
115 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
115 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | $dataValue = $snak->getDataValue(); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * error handling: |
122 | 122 | * type of $dataValue for properties with 'Format' constraint has to be 'string' or 'monolingualtext' |
123 | 123 | */ |
124 | - switch ( $dataValue->getType() ) { |
|
124 | + switch ($dataValue->getType()) { |
|
125 | 125 | case 'string': |
126 | 126 | $text = $dataValue->getValue(); |
127 | 127 | break; |
@@ -130,60 +130,59 @@ discard block |
||
130 | 130 | $text = $dataValue->getText(); |
131 | 131 | break; |
132 | 132 | default: |
133 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
133 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
134 | 134 | ->rawParams( |
135 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
136 | - wfMessage( 'datatypes-type-string' )->escaped(), |
|
137 | - wfMessage( 'datatypes-type-monolingualtext' )->escaped() |
|
135 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
136 | + wfMessage('datatypes-type-string')->escaped(), |
|
137 | + wfMessage('datatypes-type-monolingualtext')->escaped() |
|
138 | 138 | ) |
139 | 139 | ->escaped(); |
140 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
140 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
141 | 141 | } |
142 | 142 | |
143 | - if ( $this->sparqlHelper !== null && $this->config->get( 'WBQualityConstraintsCheckFormatConstraint' ) ) { |
|
144 | - if ( $this->sparqlHelper->matchesRegularExpression( $text, $format ) ) { |
|
143 | + if ($this->sparqlHelper !== null && $this->config->get('WBQualityConstraintsCheckFormatConstraint')) { |
|
144 | + if ($this->sparqlHelper->matchesRegularExpression($text, $format)) { |
|
145 | 145 | $message = null; |
146 | 146 | $status = CheckResult::STATUS_COMPLIANCE; |
147 | 147 | } else { |
148 | 148 | $message = wfMessage( |
149 | 149 | $syntaxClarification !== null ? |
150 | - 'wbqc-violation-message-format-clarification' : |
|
151 | - 'wbqc-violation-message-format' |
|
150 | + 'wbqc-violation-message-format-clarification' : 'wbqc-violation-message-format' |
|
152 | 151 | )->rawParams( |
153 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
154 | - $this->constraintParameterRenderer->formatDataValue( new StringValue( $text ), Role::OBJECT ), |
|
155 | - $this->constraintParameterRenderer->formatByRole( Role::CONSTRAINT_PARAMETER_VALUE, |
|
156 | - '<code><nowiki>' . htmlspecialchars( $format ) . '</nowiki></code>' ) |
|
152 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
153 | + $this->constraintParameterRenderer->formatDataValue(new StringValue($text), Role::OBJECT), |
|
154 | + $this->constraintParameterRenderer->formatByRole(Role::CONSTRAINT_PARAMETER_VALUE, |
|
155 | + '<code><nowiki>'.htmlspecialchars($format).'</nowiki></code>') |
|
157 | 156 | ); |
158 | - if ( $syntaxClarification !== null ) { |
|
159 | - $message->params( $syntaxClarification ); |
|
157 | + if ($syntaxClarification !== null) { |
|
158 | + $message->params($syntaxClarification); |
|
160 | 159 | } |
161 | 160 | $message = $message->escaped(); |
162 | 161 | $status = CheckResult::STATUS_VIOLATION; |
163 | 162 | } |
164 | 163 | } else { |
165 | - $message = wfMessage( "wbqc-violation-message-security-reason" ) |
|
166 | - ->rawParams( $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ) ) |
|
164 | + $message = wfMessage("wbqc-violation-message-security-reason") |
|
165 | + ->rawParams($this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM)) |
|
167 | 166 | ->escaped(); |
168 | 167 | $status = CheckResult::STATUS_TODO; |
169 | 168 | } |
170 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
169 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
171 | 170 | } |
172 | 171 | |
173 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
172 | + public function checkConstraintParameters(Constraint $constraint) { |
|
174 | 173 | $constraintParameters = $constraint->getConstraintParameters(); |
175 | 174 | $exceptions = []; |
176 | 175 | try { |
177 | - $this->constraintParameterParser->parseFormatParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
178 | - } catch ( ConstraintParameterException $e ) { |
|
176 | + $this->constraintParameterParser->parseFormatParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
177 | + } catch (ConstraintParameterException $e) { |
|
179 | 178 | $exceptions[] = $e; |
180 | 179 | } |
181 | 180 | try { |
182 | 181 | $this->constraintParameterParser->parseSyntaxClarificationParameter( |
183 | 182 | $constraintParameters, |
184 | - Language::factory( 'en' ) // errors are reported independent of language requested |
|
183 | + Language::factory('en') // errors are reported independent of language requested |
|
185 | 184 | ); |
186 | - } catch ( ConstraintParameterException $e ) { |
|
185 | + } catch (ConstraintParameterException $e) { |
|
187 | 186 | $exceptions[] = $e; |
188 | 187 | } |
189 | 188 | return $exceptions; |
@@ -70,43 +70,43 @@ discard block |
||
70 | 70 | * @throws ConstraintParameterException |
71 | 71 | * @return CheckResult |
72 | 72 | */ |
73 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
74 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
75 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
73 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
74 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
75 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $parameters = []; |
79 | 79 | $constraintParameters = $constraint->getConstraintParameters(); |
80 | 80 | |
81 | - $properties = $this->constraintParameterParser->parsePropertiesParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
81 | + $properties = $this->constraintParameterParser->parsePropertiesParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
82 | 82 | $parameters['property'] = $properties; |
83 | 83 | |
84 | 84 | $message = null; |
85 | 85 | $status = CheckResult::STATUS_COMPLIANCE; |
86 | 86 | |
87 | 87 | /** @var Snak $qualifier */ |
88 | - foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) { |
|
88 | + foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) { |
|
89 | 89 | $allowedQualifier = false; |
90 | - foreach ( $properties as $property ) { |
|
91 | - if ( $qualifier->getPropertyId()->equals( $property ) ) { |
|
90 | + foreach ($properties as $property) { |
|
91 | + if ($qualifier->getPropertyId()->equals($property)) { |
|
92 | 92 | $allowedQualifier = true; |
93 | 93 | break; |
94 | 94 | } |
95 | 95 | } |
96 | - if ( !$allowedQualifier ) { |
|
97 | - if ( empty( $properties ) || $properties === [ '' ] ) { |
|
98 | - $message = wfMessage( 'wbqc-violation-message-no-qualifiers' ); |
|
96 | + if (!$allowedQualifier) { |
|
97 | + if (empty($properties) || $properties === ['']) { |
|
98 | + $message = wfMessage('wbqc-violation-message-no-qualifiers'); |
|
99 | 99 | $message->rawParams( |
100 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ) |
|
100 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY) |
|
101 | 101 | ); |
102 | 102 | } else { |
103 | - $message = wfMessage( "wbqc-violation-message-qualifiers" ); |
|
103 | + $message = wfMessage("wbqc-violation-message-qualifiers"); |
|
104 | 104 | $message->rawParams( |
105 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
106 | - $this->constraintParameterRenderer->formatEntityId( $qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE ) |
|
105 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
106 | + $this->constraintParameterRenderer->formatEntityId($qualifier->getPropertyId(), Role::QUALIFIER_PREDICATE) |
|
107 | 107 | ); |
108 | - $message->numParams( count( $properties ) ); |
|
109 | - $message->rawParams( $this->constraintParameterRenderer->formatPropertyIdList( $properties, Role::QUALIFIER_PREDICATE ) ); |
|
108 | + $message->numParams(count($properties)); |
|
109 | + $message->rawParams($this->constraintParameterRenderer->formatPropertyIdList($properties, Role::QUALIFIER_PREDICATE)); |
|
110 | 110 | } |
111 | 111 | $message = $message->escaped(); |
112 | 112 | $status = CheckResult::STATUS_VIOLATION; |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
117 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
117 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
118 | 118 | } |
119 | 119 | |
120 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
120 | + public function checkConstraintParameters(Constraint $constraint) { |
|
121 | 121 | $constraintParameters = $constraint->getConstraintParameters(); |
122 | 122 | $exceptions = []; |
123 | 123 | try { |
124 | - $this->constraintParameterParser->parsePropertiesParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
125 | - } catch ( ConstraintParameterException $e ) { |
|
124 | + $this->constraintParameterParser->parsePropertiesParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
125 | + } catch (ConstraintParameterException $e) { |
|
126 | 126 | $exceptions[] = $e; |
127 | 127 | } |
128 | 128 | return $exceptions; |
@@ -89,22 +89,22 @@ 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 | $parameters = []; |
98 | 98 | $constraintParameters = $constraint->getConstraintParameters(); |
99 | 99 | |
100 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
101 | - $parameters['property'] = [ $propertyId ]; |
|
100 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
101 | + $parameters['property'] = [$propertyId]; |
|
102 | 102 | |
103 | 103 | $snak = $context->getSnak(); |
104 | 104 | |
105 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
105 | + if (!$snak instanceof PropertyValueSnak) { |
|
106 | 106 | // nothing to check |
107 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
107 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | $dataValue = $snak->getDataValue(); |
@@ -113,22 +113,22 @@ discard block |
||
113 | 113 | * error handling: |
114 | 114 | * type of $dataValue for properties with 'Inverse' constraint has to be 'wikibase-entityid' |
115 | 115 | */ |
116 | - if ( $dataValue->getType() !== 'wikibase-entityid' ) { |
|
117 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
116 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
117 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
118 | 118 | ->rawParams( |
119 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
119 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
120 | 120 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
121 | 121 | ) |
122 | 122 | ->escaped(); |
123 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
123 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
124 | 124 | } |
125 | 125 | /** @var EntityIdValue $dataValue */ |
126 | 126 | |
127 | 127 | $targetEntityId = $dataValue->getEntityId(); |
128 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
129 | - if ( $targetEntity === null ) { |
|
130 | - $message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped(); |
|
131 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
128 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
129 | + if ($targetEntity === null) { |
|
130 | + $message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped(); |
|
131 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $inverseStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue( |
@@ -136,31 +136,31 @@ discard block |
||
136 | 136 | $propertyId, |
137 | 137 | $context->getEntity()->getId() |
138 | 138 | ); |
139 | - if ( $inverseStatement !== null ) { |
|
139 | + if ($inverseStatement !== null) { |
|
140 | 140 | $message = null; |
141 | 141 | $status = CheckResult::STATUS_COMPLIANCE; |
142 | 142 | } else { |
143 | - $message = wfMessage( 'wbqc-violation-message-inverse' ) |
|
143 | + $message = wfMessage('wbqc-violation-message-inverse') |
|
144 | 144 | ->rawParams( |
145 | - $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ), |
|
146 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ), |
|
147 | - $this->constraintParameterRenderer->formatEntityId( $context->getEntity()->getId(), Role::OBJECT ) |
|
145 | + $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT), |
|
146 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE), |
|
147 | + $this->constraintParameterRenderer->formatEntityId($context->getEntity()->getId(), Role::OBJECT) |
|
148 | 148 | ) |
149 | 149 | ->escaped(); |
150 | 150 | $status = CheckResult::STATUS_VIOLATION; |
151 | 151 | } |
152 | 152 | |
153 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
154 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
155 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
153 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
154 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
155 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
156 | 156 | } |
157 | 157 | |
158 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
158 | + public function checkConstraintParameters(Constraint $constraint) { |
|
159 | 159 | $constraintParameters = $constraint->getConstraintParameters(); |
160 | 160 | $exceptions = []; |
161 | 161 | try { |
162 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
163 | - } catch ( ConstraintParameterException $e ) { |
|
162 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
163 | + } catch (ConstraintParameterException $e) { |
|
164 | 164 | $exceptions[] = $e; |
165 | 165 | } |
166 | 166 | return $exceptions; |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | * |
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 | $parameters = []; |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | $snak = $context->getSnak(); |
90 | 90 | $propertyId = $context->getSnak()->getPropertyId(); |
91 | 91 | |
92 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
92 | + if (!$snak instanceof PropertyValueSnak) { |
|
93 | 93 | // nothing to check |
94 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
94 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $dataValue = $snak->getDataValue(); |
@@ -100,22 +100,22 @@ discard block |
||
100 | 100 | * error handling: |
101 | 101 | * type of $dataValue for properties with 'Symmetric' constraint has to be 'wikibase-entityid' |
102 | 102 | */ |
103 | - if ( $dataValue->getType() !== 'wikibase-entityid' ) { |
|
104 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
103 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
104 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
105 | 105 | ->rawParams( |
106 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
106 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
107 | 107 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
108 | 108 | ) |
109 | 109 | ->escaped(); |
110 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
110 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
111 | 111 | } |
112 | 112 | /** @var EntityIdValue $dataValue */ |
113 | 113 | |
114 | 114 | $targetEntityId = $dataValue->getEntityId(); |
115 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
116 | - if ( $targetEntity === null ) { |
|
117 | - $message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped(); |
|
118 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
115 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
116 | + if ($targetEntity === null) { |
|
117 | + $message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped(); |
|
118 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | $symmetricStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue( |
@@ -123,26 +123,26 @@ discard block |
||
123 | 123 | $propertyId, |
124 | 124 | $context->getEntity()->getId() |
125 | 125 | ); |
126 | - if ( $symmetricStatement !== null ) { |
|
126 | + if ($symmetricStatement !== null) { |
|
127 | 127 | $message = null; |
128 | 128 | $status = CheckResult::STATUS_COMPLIANCE; |
129 | 129 | } else { |
130 | - $message = wfMessage( 'wbqc-violation-message-symmetric' ) |
|
130 | + $message = wfMessage('wbqc-violation-message-symmetric') |
|
131 | 131 | ->rawParams( |
132 | - $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ), |
|
133 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ), |
|
134 | - $this->constraintParameterRenderer->formatEntityId( $context->getEntity()->getId(), Role::OBJECT ) |
|
132 | + $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT), |
|
133 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE), |
|
134 | + $this->constraintParameterRenderer->formatEntityId($context->getEntity()->getId(), Role::OBJECT) |
|
135 | 135 | ) |
136 | 136 | ->escaped(); |
137 | 137 | $status = CheckResult::STATUS_VIOLATION; |
138 | 138 | } |
139 | 139 | |
140 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
141 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
142 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
140 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
141 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
142 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
143 | 143 | } |
144 | 144 | |
145 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
145 | + public function checkConstraintParameters(Constraint $constraint) { |
|
146 | 146 | // no parameters |
147 | 147 | return []; |
148 | 148 | } |
@@ -70,43 +70,43 @@ |
||
70 | 70 | * @throws ConstraintParameterException |
71 | 71 | * @return CheckResult |
72 | 72 | */ |
73 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
74 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
75 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
73 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
74 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
75 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $parameters = []; |
79 | 79 | $constraintParameters = $constraint->getConstraintParameters(); |
80 | 80 | |
81 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
82 | - $parameters['property'] = [ $propertyId ]; |
|
81 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
82 | + $parameters['property'] = [$propertyId]; |
|
83 | 83 | |
84 | - $message = wfMessage( "wbqc-violation-message-mandatory-qualifier" ) |
|
84 | + $message = wfMessage("wbqc-violation-message-mandatory-qualifier") |
|
85 | 85 | ->rawParams( |
86 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ), |
|
87 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::QUALIFIER_PREDICATE ) |
|
86 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY), |
|
87 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::QUALIFIER_PREDICATE) |
|
88 | 88 | ) |
89 | 89 | ->escaped(); |
90 | 90 | $status = CheckResult::STATUS_VIOLATION; |
91 | 91 | |
92 | 92 | /** @var Snak $qualifier */ |
93 | - foreach ( $context->getSnakStatement()->getQualifiers() as $qualifier ) { |
|
94 | - if ( $propertyId->equals( $qualifier->getPropertyId() ) ) { |
|
93 | + foreach ($context->getSnakStatement()->getQualifiers() as $qualifier) { |
|
94 | + if ($propertyId->equals($qualifier->getPropertyId())) { |
|
95 | 95 | $message = null; |
96 | 96 | $status = CheckResult::STATUS_COMPLIANCE; |
97 | 97 | break; |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
101 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
102 | 102 | } |
103 | 103 | |
104 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
104 | + public function checkConstraintParameters(Constraint $constraint) { |
|
105 | 105 | $constraintParameters = $constraint->getConstraintParameters(); |
106 | 106 | $exceptions = []; |
107 | 107 | try { |
108 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
109 | - } catch ( ConstraintParameterException $e ) { |
|
108 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
109 | + } catch (ConstraintParameterException $e) { |
|
110 | 110 | $exceptions[] = $e; |
111 | 111 | } |
112 | 112 | return $exceptions; |
@@ -87,25 +87,25 @@ discard block |
||
87 | 87 | * @throws ConstraintParameterException |
88 | 88 | * @return CheckResult |
89 | 89 | */ |
90 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
91 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
92 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
90 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
91 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
92 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | $parameters = []; |
96 | 96 | $constraintParameters = $constraint->getConstraintParameters(); |
97 | 97 | |
98 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
99 | - $parameters['property'] = [ $propertyId ]; |
|
98 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
99 | + $parameters['property'] = [$propertyId]; |
|
100 | 100 | |
101 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
101 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
102 | 102 | $parameters['items'] = $items; |
103 | 103 | |
104 | 104 | $snak = $context->getSnak(); |
105 | 105 | |
106 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
106 | + if (!$snak instanceof PropertyValueSnak) { |
|
107 | 107 | // nothing to check |
108 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
108 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | $dataValue = $snak->getDataValue(); |
@@ -114,22 +114,22 @@ discard block |
||
114 | 114 | * error handling: |
115 | 115 | * type of $dataValue for properties with 'Target required claim' constraint has to be 'wikibase-entityid' |
116 | 116 | */ |
117 | - if ( $dataValue->getType() !== 'wikibase-entityid' ) { |
|
118 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
117 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
118 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
119 | 119 | ->rawParams( |
120 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
120 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
121 | 121 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
122 | 122 | ) |
123 | 123 | ->escaped(); |
124 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
124 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
125 | 125 | } |
126 | 126 | /** @var EntityIdValue $dataValue */ |
127 | 127 | |
128 | 128 | $targetEntityId = $dataValue->getEntityId(); |
129 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
130 | - if ( $targetEntity === null ) { |
|
131 | - $message = wfMessage( "wbqc-violation-message-target-entity-must-exist" )->escaped(); |
|
132 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
129 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
130 | + if ($targetEntity === null) { |
|
131 | + $message = wfMessage("wbqc-violation-message-target-entity-must-exist")->escaped(); |
|
132 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /* |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * a) a property only |
138 | 138 | * b) a property and a number of items (each combination forming an individual claim) |
139 | 139 | */ |
140 | - if ( $items === [] ) { |
|
140 | + if ($items === []) { |
|
141 | 141 | $requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty( |
142 | 142 | $targetEntity->getStatements(), |
143 | 143 | $propertyId |
@@ -150,37 +150,37 @@ discard block |
||
150 | 150 | ); |
151 | 151 | } |
152 | 152 | |
153 | - if ( $requiredStatement !== null ) { |
|
153 | + if ($requiredStatement !== null) { |
|
154 | 154 | $status = CheckResult::STATUS_COMPLIANCE; |
155 | 155 | $message = null; |
156 | 156 | } else { |
157 | 157 | $status = CheckResult::STATUS_VIOLATION; |
158 | - $message = wfMessage( 'wbqc-violation-message-target-required-claim' ); |
|
158 | + $message = wfMessage('wbqc-violation-message-target-required-claim'); |
|
159 | 159 | $message->rawParams( |
160 | - $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ), |
|
161 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ) |
|
160 | + $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT), |
|
161 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE) |
|
162 | 162 | ); |
163 | - $message->numParams( count( $items ) ); |
|
164 | - $message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) ); |
|
163 | + $message->numParams(count($items)); |
|
164 | + $message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT)); |
|
165 | 165 | $message = $message->escaped(); |
166 | 166 | } |
167 | 167 | |
168 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
169 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
170 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
168 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
169 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
170 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
171 | 171 | } |
172 | 172 | |
173 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
173 | + public function checkConstraintParameters(Constraint $constraint) { |
|
174 | 174 | $constraintParameters = $constraint->getConstraintParameters(); |
175 | 175 | $exceptions = []; |
176 | 176 | try { |
177 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
178 | - } catch ( ConstraintParameterException $e ) { |
|
177 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
178 | + } catch (ConstraintParameterException $e) { |
|
179 | 179 | $exceptions[] = $e; |
180 | 180 | } |
181 | 181 | try { |
182 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
183 | - } catch ( ConstraintParameterException $e ) { |
|
182 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
183 | + } catch (ConstraintParameterException $e) { |
|
184 | 184 | $exceptions[] = $e; |
185 | 185 | } |
186 | 186 | return $exceptions; |
@@ -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 = []; |
@@ -94,42 +94,42 @@ discard block |
||
94 | 94 | |
95 | 95 | $snak = $context->getSnak(); |
96 | 96 | |
97 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
97 | + if (!$snak instanceof PropertyValueSnak) { |
|
98 | 98 | // nothing to check |
99 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
99 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $dataValue = $snak->getDataValue(); |
103 | 103 | |
104 | - list( $min, $max ) = $this->constraintParameterParser->parseRangeParameter( |
|
104 | + list($min, $max) = $this->constraintParameterParser->parseRangeParameter( |
|
105 | 105 | $constraintParameters, |
106 | 106 | $constraint->getConstraintTypeItemId(), |
107 | 107 | $dataValue->getType() |
108 | 108 | ); |
109 | 109 | $parameterKey = $dataValue->getType() === 'quantity' ? 'quantity' : 'date'; |
110 | - if ( $min !== null ) { |
|
111 | - $parameters['minimum_' . $parameterKey] = [ $min ]; |
|
110 | + if ($min !== null) { |
|
111 | + $parameters['minimum_'.$parameterKey] = [$min]; |
|
112 | 112 | } |
113 | - if ( $max !== null ) { |
|
114 | - $parameters['maximum_' . $parameterKey] = [ $max ]; |
|
113 | + if ($max !== null) { |
|
114 | + $parameters['maximum_'.$parameterKey] = [$max]; |
|
115 | 115 | } |
116 | 116 | |
117 | - if ( $this->rangeCheckerHelper->getComparison( $min, $dataValue ) > 0 || |
|
118 | - $this->rangeCheckerHelper->getComparison( $dataValue, $max ) > 0 |
|
117 | + if ($this->rangeCheckerHelper->getComparison($min, $dataValue) > 0 || |
|
118 | + $this->rangeCheckerHelper->getComparison($dataValue, $max) > 0 |
|
119 | 119 | ) { |
120 | 120 | // at least one of $min, $max is set at this point, otherwise there could be no violation |
121 | 121 | $type = $dataValue->getType(); |
122 | - $openness = $min !== null ? ( $max !== null ? 'closed' : 'rightopen' ) : 'leftopen'; |
|
123 | - $message = wfMessage( "wbqc-violation-message-range-$type-$openness" ); |
|
122 | + $openness = $min !== null ? ($max !== null ? 'closed' : 'rightopen') : 'leftopen'; |
|
123 | + $message = wfMessage("wbqc-violation-message-range-$type-$openness"); |
|
124 | 124 | $message->rawParams( |
125 | - $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ), |
|
126 | - $this->constraintParameterRenderer->formatDataValue( $dataValue, Role::OBJECT ) |
|
125 | + $this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE), |
|
126 | + $this->constraintParameterRenderer->formatDataValue($dataValue, Role::OBJECT) |
|
127 | 127 | ); |
128 | - if ( $min !== null ) { |
|
129 | - $message->rawParams( $this->constraintParameterRenderer->formatDataValue( $min, Role::OBJECT ) ); |
|
128 | + if ($min !== null) { |
|
129 | + $message->rawParams($this->constraintParameterRenderer->formatDataValue($min, Role::OBJECT)); |
|
130 | 130 | } |
131 | - if ( $max !== null ) { |
|
132 | - $message->rawParams( $this->constraintParameterRenderer->formatDataValue( $max, Role::OBJECT ) ); |
|
131 | + if ($max !== null) { |
|
132 | + $message->rawParams($this->constraintParameterRenderer->formatDataValue($max, Role::OBJECT)); |
|
133 | 133 | } |
134 | 134 | $message = $message->escaped(); |
135 | 135 | $status = CheckResult::STATUS_VIOLATION; |
@@ -138,22 +138,22 @@ discard block |
||
138 | 138 | $status = CheckResult::STATUS_COMPLIANCE; |
139 | 139 | } |
140 | 140 | |
141 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
141 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
142 | 142 | } |
143 | 143 | |
144 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
144 | + public function checkConstraintParameters(Constraint $constraint) { |
|
145 | 145 | $constraintParameters = $constraint->getConstraintParameters(); |
146 | 146 | $exceptions = []; |
147 | 147 | try { |
148 | 148 | // we don’t have a data value here, so get the type from the property instead |
149 | 149 | // (the distinction between data type and data value type is irrelevant for 'quantity' and 'time') |
150 | - $type = $this->propertyDataTypeLookup->getDataTypeIdForProperty( $constraint->getPropertyId() ); |
|
150 | + $type = $this->propertyDataTypeLookup->getDataTypeIdForProperty($constraint->getPropertyId()); |
|
151 | 151 | $this->constraintParameterParser->parseRangeParameter( |
152 | 152 | $constraintParameters, |
153 | 153 | $constraint->getConstraintTypeItemId(), |
154 | 154 | $type |
155 | 155 | ); |
156 | - } catch ( ConstraintParameterException $e ) { |
|
156 | + } catch (ConstraintParameterException $e) { |
|
157 | 157 | $exceptions[] = $e; |
158 | 158 | } |
159 | 159 | return $exceptions; |