@@ -67,43 +67,43 @@ |
||
67 | 67 | * @throws ConstraintParameterException |
68 | 68 | * @return CheckResult |
69 | 69 | */ |
70 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
71 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
72 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
70 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
71 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
72 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | $parameters = []; |
76 | 76 | $constraintParameters = $constraint->getConstraintParameters(); |
77 | 77 | |
78 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true ); |
|
78 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true); |
|
79 | 79 | $parameters['item'] = $items; |
80 | 80 | |
81 | 81 | $snak = $context->getSnak(); |
82 | 82 | |
83 | - $message = wfMessage( 'wbqc-violation-message-one-of' ); |
|
84 | - $message->rawParams( $this->constraintParameterRenderer->formatEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) ); |
|
85 | - $message->numParams( count( $items ) ); |
|
86 | - $message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) ); |
|
83 | + $message = wfMessage('wbqc-violation-message-one-of'); |
|
84 | + $message->rawParams($this->constraintParameterRenderer->formatEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE)); |
|
85 | + $message->numParams(count($items)); |
|
86 | + $message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT)); |
|
87 | 87 | $message = $message->escaped(); |
88 | 88 | $status = CheckResult::STATUS_VIOLATION; |
89 | 89 | |
90 | - foreach ( $items as $item ) { |
|
91 | - if ( $item->matchesSnak( $snak ) ) { |
|
90 | + foreach ($items as $item) { |
|
91 | + if ($item->matchesSnak($snak)) { |
|
92 | 92 | $message = null; |
93 | 93 | $status = CheckResult::STATUS_COMPLIANCE; |
94 | 94 | break; |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
98 | + return new CheckResult($context, $constraint, $parameters, $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->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), true ); |
|
106 | - } catch ( ConstraintParameterException $e ) { |
|
105 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), true); |
|
106 | + } catch (ConstraintParameterException $e) { |
|
107 | 107 | $exceptions[] = $e; |
108 | 108 | } |
109 | 109 | return $exceptions; |
@@ -90,22 +90,22 @@ discard block |
||
90 | 90 | * @throws ConstraintParameterException |
91 | 91 | * @return CheckResult |
92 | 92 | */ |
93 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
94 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
95 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
93 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
94 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
95 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $parameters = []; |
99 | 99 | $constraintParameters = $constraint->getConstraintParameters(); |
100 | 100 | |
101 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
102 | - $parameters['property'] = [ $propertyId ]; |
|
101 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
102 | + $parameters['property'] = [$propertyId]; |
|
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 'Inverse' 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 = new ViolationMessage( 'wbqc-violation-message-target-entity-must-exist' ); |
|
132 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
129 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
130 | + if ($targetEntity === null) { |
|
131 | + $message = new ViolationMessage('wbqc-violation-message-target-entity-must-exist'); |
|
132 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $inverseStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue( |
@@ -137,31 +137,31 @@ discard block |
||
137 | 137 | $propertyId, |
138 | 138 | $context->getEntity()->getId() |
139 | 139 | ); |
140 | - if ( $inverseStatement !== null ) { |
|
140 | + if ($inverseStatement !== null) { |
|
141 | 141 | $message = null; |
142 | 142 | $status = CheckResult::STATUS_COMPLIANCE; |
143 | 143 | } else { |
144 | - $message = wfMessage( 'wbqc-violation-message-inverse' ) |
|
144 | + $message = wfMessage('wbqc-violation-message-inverse') |
|
145 | 145 | ->rawParams( |
146 | - $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ), |
|
147 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ), |
|
148 | - $this->constraintParameterRenderer->formatEntityId( $context->getEntity()->getId(), Role::OBJECT ) |
|
146 | + $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT), |
|
147 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE), |
|
148 | + $this->constraintParameterRenderer->formatEntityId($context->getEntity()->getId(), Role::OBJECT) |
|
149 | 149 | ) |
150 | 150 | ->escaped(); |
151 | 151 | $status = CheckResult::STATUS_VIOLATION; |
152 | 152 | } |
153 | 153 | |
154 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
155 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
156 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
154 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
155 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
156 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
157 | 157 | } |
158 | 158 | |
159 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
159 | + public function checkConstraintParameters(Constraint $constraint) { |
|
160 | 160 | $constraintParameters = $constraint->getConstraintParameters(); |
161 | 161 | $exceptions = []; |
162 | 162 | try { |
163 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
164 | - } catch ( ConstraintParameterException $e ) { |
|
163 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
164 | + } catch (ConstraintParameterException $e) { |
|
165 | 165 | $exceptions[] = $e; |
166 | 166 | } |
167 | 167 | return $exceptions; |
@@ -98,37 +98,37 @@ discard block |
||
98 | 98 | * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs |
99 | 99 | * @return CheckResult |
100 | 100 | */ |
101 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
102 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
103 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
101 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
102 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
103 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | $parameters = []; |
107 | 107 | $constraintParameters = $constraint->getConstraintParameters(); |
108 | 108 | |
109 | - $classes = $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
109 | + $classes = $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
110 | 110 | $parameters['class'] = array_map( |
111 | - function( $id ) { |
|
112 | - return new ItemId( $id ); |
|
111 | + function($id) { |
|
112 | + return new ItemId($id); |
|
113 | 113 | }, |
114 | 114 | $classes |
115 | 115 | ); |
116 | 116 | |
117 | - $relation = $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
117 | + $relation = $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
118 | 118 | $relationIds = []; |
119 | - if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) { |
|
120 | - $relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' ); |
|
119 | + if ($relation === 'instance' || $relation === 'instanceOrSubclass') { |
|
120 | + $relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId'); |
|
121 | 121 | } |
122 | - if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) { |
|
123 | - $relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' ); |
|
122 | + if ($relation === 'subclass' || $relation === 'instanceOrSubclass') { |
|
123 | + $relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId'); |
|
124 | 124 | } |
125 | - $parameters['relation'] = [ $relation ]; |
|
125 | + $parameters['relation'] = [$relation]; |
|
126 | 126 | |
127 | 127 | $snak = $context->getSnak(); |
128 | 128 | |
129 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
129 | + if (!$snak instanceof PropertyValueSnak) { |
|
130 | 130 | // nothing to check |
131 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
131 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | $dataValue = $snak->getDataValue(); |
@@ -137,22 +137,22 @@ 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->getType() !== 'wikibase-entityid' ) { |
|
141 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
140 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
141 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
142 | 142 | ->rawParams( |
143 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
143 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
144 | 144 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
145 | 145 | ) |
146 | 146 | ->escaped(); |
147 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
147 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
148 | 148 | } |
149 | 149 | /** @var EntityIdValue $dataValue */ |
150 | 150 | |
151 | - $item = $this->entityLookup->getEntity( $dataValue->getEntityId() ); |
|
151 | + $item = $this->entityLookup->getEntity($dataValue->getEntityId()); |
|
152 | 152 | |
153 | - if ( !( $item instanceof StatementListProvider ) ) { |
|
154 | - $message = new ViolationMessage( 'wbqc-violation-message-value-entity-must-exist' ); |
|
155 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
153 | + if (!($item instanceof StatementListProvider)) { |
|
154 | + $message = new ViolationMessage('wbqc-violation-message-value-entity-must-exist'); |
|
155 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | $statements = $item->getStatements(); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $classes |
164 | 164 | ); |
165 | 165 | |
166 | - if ( $result->getBool() ) { |
|
166 | + if ($result->getBool()) { |
|
167 | 167 | $message = null; |
168 | 168 | $status = CheckResult::STATUS_COMPLIANCE; |
169 | 169 | } else { |
@@ -177,21 +177,21 @@ discard block |
||
177 | 177 | $status = CheckResult::STATUS_VIOLATION; |
178 | 178 | } |
179 | 179 | |
180 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
181 | - ->withMetadata( $result->getMetadata() ); |
|
180 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
181 | + ->withMetadata($result->getMetadata()); |
|
182 | 182 | } |
183 | 183 | |
184 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
184 | + public function checkConstraintParameters(Constraint $constraint) { |
|
185 | 185 | $constraintParameters = $constraint->getConstraintParameters(); |
186 | 186 | $exceptions = []; |
187 | 187 | try { |
188 | - $this->constraintParameterParser->parseClassParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
189 | - } catch ( ConstraintParameterException $e ) { |
|
188 | + $this->constraintParameterParser->parseClassParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
189 | + } catch (ConstraintParameterException $e) { |
|
190 | 190 | $exceptions[] = $e; |
191 | 191 | } |
192 | 192 | try { |
193 | - $this->constraintParameterParser->parseRelationParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
194 | - } catch ( ConstraintParameterException $e ) { |
|
193 | + $this->constraintParameterParser->parseRelationParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
194 | + } catch (ConstraintParameterException $e) { |
|
195 | 195 | $exceptions[] = $e; |
196 | 196 | } |
197 | 197 | return $exceptions; |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return CheckResult |
82 | 82 | */ |
83 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
84 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
85 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
83 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
84 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
85 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $parameters = []; |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | $snak = $context->getSnak(); |
91 | 91 | $propertyId = $context->getSnak()->getPropertyId(); |
92 | 92 | |
93 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
93 | + if (!$snak instanceof PropertyValueSnak) { |
|
94 | 94 | // nothing to check |
95 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
95 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | $dataValue = $snak->getDataValue(); |
@@ -101,22 +101,22 @@ discard block |
||
101 | 101 | * error handling: |
102 | 102 | * type of $dataValue for properties with 'Symmetric' constraint has to be 'wikibase-entityid' |
103 | 103 | */ |
104 | - if ( $dataValue->getType() !== 'wikibase-entityid' ) { |
|
105 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
104 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
105 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
106 | 106 | ->rawParams( |
107 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
107 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
108 | 108 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
109 | 109 | ) |
110 | 110 | ->escaped(); |
111 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
111 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
112 | 112 | } |
113 | 113 | /** @var EntityIdValue $dataValue */ |
114 | 114 | |
115 | 115 | $targetEntityId = $dataValue->getEntityId(); |
116 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
117 | - if ( $targetEntity === null ) { |
|
118 | - $message = new ViolationMessage( 'wbqc-violation-message-target-entity-must-exist' ); |
|
119 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
116 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
117 | + if ($targetEntity === null) { |
|
118 | + $message = new ViolationMessage('wbqc-violation-message-target-entity-must-exist'); |
|
119 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | $symmetricStatement = $this->connectionCheckerHelper->findStatementWithPropertyAndEntityIdValue( |
@@ -124,26 +124,26 @@ discard block |
||
124 | 124 | $propertyId, |
125 | 125 | $context->getEntity()->getId() |
126 | 126 | ); |
127 | - if ( $symmetricStatement !== null ) { |
|
127 | + if ($symmetricStatement !== null) { |
|
128 | 128 | $message = null; |
129 | 129 | $status = CheckResult::STATUS_COMPLIANCE; |
130 | 130 | } else { |
131 | - $message = wfMessage( 'wbqc-violation-message-symmetric' ) |
|
131 | + $message = wfMessage('wbqc-violation-message-symmetric') |
|
132 | 132 | ->rawParams( |
133 | - $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ), |
|
134 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ), |
|
135 | - $this->constraintParameterRenderer->formatEntityId( $context->getEntity()->getId(), Role::OBJECT ) |
|
133 | + $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT), |
|
134 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE), |
|
135 | + $this->constraintParameterRenderer->formatEntityId($context->getEntity()->getId(), Role::OBJECT) |
|
136 | 136 | ) |
137 | 137 | ->escaped(); |
138 | 138 | $status = CheckResult::STATUS_VIOLATION; |
139 | 139 | } |
140 | 140 | |
141 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
142 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
143 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
141 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
142 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
143 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
144 | 144 | } |
145 | 145 | |
146 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
146 | + public function checkConstraintParameters(Constraint $constraint) { |
|
147 | 147 | // no parameters |
148 | 148 | return []; |
149 | 149 | } |
@@ -47,16 +47,16 @@ |
||
47 | 47 | * |
48 | 48 | * @return CheckResult |
49 | 49 | */ |
50 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
51 | - if ( $context->getType() === Context::TYPE_QUALIFIER ) { |
|
52 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE ); |
|
50 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
51 | + if ($context->getType() === Context::TYPE_QUALIFIER) { |
|
52 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE); |
|
53 | 53 | } else { |
54 | - $message = new ViolationMessage( 'wbqc-violation-message-qualifier' ); |
|
55 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message ); |
|
54 | + $message = new ViolationMessage('wbqc-violation-message-qualifier'); |
|
55 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message); |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
59 | + public function checkConstraintParameters(Constraint $constraint) { |
|
60 | 60 | // no parameters |
61 | 61 | return []; |
62 | 62 | } |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return CheckResult |
57 | 57 | */ |
58 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
59 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
60 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
58 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
59 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
60 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | $propertyId = $context->getSnak()->getPropertyId(); |
@@ -69,18 +69,18 @@ discard block |
||
69 | 69 | $propertyId |
70 | 70 | ); |
71 | 71 | |
72 | - if ( $propertyCount <= 1 ) { |
|
73 | - $message = new ViolationMessage( 'wbqc-violation-message-multi-value' ); |
|
72 | + if ($propertyCount <= 1) { |
|
73 | + $message = new ViolationMessage('wbqc-violation-message-multi-value'); |
|
74 | 74 | $status = CheckResult::STATUS_VIOLATION; |
75 | 75 | } else { |
76 | 76 | $message = null; |
77 | 77 | $status = CheckResult::STATUS_COMPLIANCE; |
78 | 78 | } |
79 | 79 | |
80 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
80 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
81 | 81 | } |
82 | 82 | |
83 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
83 | + public function checkConstraintParameters(Constraint $constraint) { |
|
84 | 84 | // no parameters |
85 | 85 | return []; |
86 | 86 | } |
@@ -36,16 +36,16 @@ |
||
36 | 36 | ]; |
37 | 37 | } |
38 | 38 | |
39 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
40 | - if ( $context->getType() === Context::TYPE_STATEMENT ) { |
|
41 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE ); |
|
39 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
40 | + if ($context->getType() === Context::TYPE_STATEMENT) { |
|
41 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE); |
|
42 | 42 | } else { |
43 | - $message = new ViolationMessage( 'wbqc-violation-message-valueOnly' ); |
|
44 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message ); |
|
43 | + $message = new ViolationMessage('wbqc-violation-message-valueOnly'); |
|
44 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
48 | + public function checkConstraintParameters(Constraint $constraint) { |
|
49 | 49 | // no parameters |
50 | 50 | return []; |
51 | 51 | } |
@@ -88,25 +88,25 @@ discard block |
||
88 | 88 | * @throws ConstraintParameterException |
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 | $parameters = []; |
97 | 97 | $constraintParameters = $constraint->getConstraintParameters(); |
98 | 98 | |
99 | - $propertyId = $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
100 | - $parameters['property'] = [ $propertyId ]; |
|
99 | + $propertyId = $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
100 | + $parameters['property'] = [$propertyId]; |
|
101 | 101 | |
102 | - $items = $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
102 | + $items = $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
103 | 103 | $parameters['items'] = $items; |
104 | 104 | |
105 | 105 | $snak = $context->getSnak(); |
106 | 106 | |
107 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
107 | + if (!$snak instanceof PropertyValueSnak) { |
|
108 | 108 | // nothing to check |
109 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
109 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | $dataValue = $snak->getDataValue(); |
@@ -115,22 +115,22 @@ discard block |
||
115 | 115 | * error handling: |
116 | 116 | * type of $dataValue for properties with 'Target required claim' constraint has to be 'wikibase-entityid' |
117 | 117 | */ |
118 | - if ( $dataValue->getType() !== 'wikibase-entityid' ) { |
|
119 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
118 | + if ($dataValue->getType() !== 'wikibase-entityid') { |
|
119 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
120 | 120 | ->rawParams( |
121 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
121 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
122 | 122 | 'wikibase-entityid' // TODO is there a message for this type so we can localize it? |
123 | 123 | ) |
124 | 124 | ->escaped(); |
125 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
125 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
126 | 126 | } |
127 | 127 | /** @var EntityIdValue $dataValue */ |
128 | 128 | |
129 | 129 | $targetEntityId = $dataValue->getEntityId(); |
130 | - $targetEntity = $this->entityLookup->getEntity( $targetEntityId ); |
|
131 | - if ( $targetEntity === null ) { |
|
132 | - $message = new ViolationMessage( 'wbqc-violation-message-target-entity-must-exist' ); |
|
133 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
130 | + $targetEntity = $this->entityLookup->getEntity($targetEntityId); |
|
131 | + if ($targetEntity === null) { |
|
132 | + $message = new ViolationMessage('wbqc-violation-message-target-entity-must-exist'); |
|
133 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /* |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * a) a property only |
139 | 139 | * b) a property and a number of items (each combination forming an individual claim) |
140 | 140 | */ |
141 | - if ( $items === [] ) { |
|
141 | + if ($items === []) { |
|
142 | 142 | $requiredStatement = $this->connectionCheckerHelper->findStatementWithProperty( |
143 | 143 | $targetEntity->getStatements(), |
144 | 144 | $propertyId |
@@ -151,37 +151,37 @@ discard block |
||
151 | 151 | ); |
152 | 152 | } |
153 | 153 | |
154 | - if ( $requiredStatement !== null ) { |
|
154 | + if ($requiredStatement !== null) { |
|
155 | 155 | $status = CheckResult::STATUS_COMPLIANCE; |
156 | 156 | $message = null; |
157 | 157 | } else { |
158 | 158 | $status = CheckResult::STATUS_VIOLATION; |
159 | - $message = wfMessage( 'wbqc-violation-message-target-required-claim' ); |
|
159 | + $message = wfMessage('wbqc-violation-message-target-required-claim'); |
|
160 | 160 | $message->rawParams( |
161 | - $this->constraintParameterRenderer->formatEntityId( $targetEntityId, Role::SUBJECT ), |
|
162 | - $this->constraintParameterRenderer->formatEntityId( $propertyId, Role::PREDICATE ) |
|
161 | + $this->constraintParameterRenderer->formatEntityId($targetEntityId, Role::SUBJECT), |
|
162 | + $this->constraintParameterRenderer->formatEntityId($propertyId, Role::PREDICATE) |
|
163 | 163 | ); |
164 | - $message->numParams( count( $items ) ); |
|
165 | - $message->rawParams( $this->constraintParameterRenderer->formatItemIdSnakValueList( $items, Role::OBJECT ) ); |
|
164 | + $message->numParams(count($items)); |
|
165 | + $message->rawParams($this->constraintParameterRenderer->formatItemIdSnakValueList($items, Role::OBJECT)); |
|
166 | 166 | $message = $message->escaped(); |
167 | 167 | } |
168 | 168 | |
169 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
170 | - ->withMetadata( Metadata::ofDependencyMetadata( |
|
171 | - DependencyMetadata::ofEntityId( $targetEntityId ) ) ); |
|
169 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
170 | + ->withMetadata(Metadata::ofDependencyMetadata( |
|
171 | + DependencyMetadata::ofEntityId($targetEntityId) )); |
|
172 | 172 | } |
173 | 173 | |
174 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
174 | + public function checkConstraintParameters(Constraint $constraint) { |
|
175 | 175 | $constraintParameters = $constraint->getConstraintParameters(); |
176 | 176 | $exceptions = []; |
177 | 177 | try { |
178 | - $this->constraintParameterParser->parsePropertyParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
179 | - } catch ( ConstraintParameterException $e ) { |
|
178 | + $this->constraintParameterParser->parsePropertyParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
179 | + } catch (ConstraintParameterException $e) { |
|
180 | 180 | $exceptions[] = $e; |
181 | 181 | } |
182 | 182 | try { |
183 | - $this->constraintParameterParser->parseItemsParameter( $constraintParameters, $constraint->getConstraintTypeItemId(), false ); |
|
184 | - } catch ( ConstraintParameterException $e ) { |
|
183 | + $this->constraintParameterParser->parseItemsParameter($constraintParameters, $constraint->getConstraintTypeItemId(), false); |
|
184 | + } catch (ConstraintParameterException $e) { |
|
185 | 185 | $exceptions[] = $e; |
186 | 186 | } |
187 | 187 | return $exceptions; |
@@ -36,16 +36,16 @@ |
||
36 | 36 | ]; |
37 | 37 | } |
38 | 38 | |
39 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
40 | - if ( $context->getType() === Context::TYPE_REFERENCE ) { |
|
41 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE ); |
|
39 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
40 | + if ($context->getType() === Context::TYPE_REFERENCE) { |
|
41 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE); |
|
42 | 42 | } else { |
43 | - $message = new ViolationMessage( 'wbqc-violation-message-reference' ); |
|
44 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message ); |
|
43 | + $message = new ViolationMessage('wbqc-violation-message-reference'); |
|
44 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
48 | + public function checkConstraintParameters(Constraint $constraint) { |
|
49 | 49 | // no parameters |
50 | 50 | return []; |
51 | 51 | } |