@@ -80,23 +80,23 @@ discard block |
||
80 | 80 | * @return bool |
81 | 81 | * @throws OverflowException if $entitiesChecked exceeds the configured limit |
82 | 82 | */ |
83 | - private function isSubclassOf( EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0 ) { |
|
84 | - $maxEntities = $this->config->get( 'WBQualityConstraintsTypeCheckMaxEntities' ); |
|
83 | + private function isSubclassOf(EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0) { |
|
84 | + $maxEntities = $this->config->get('WBQualityConstraintsTypeCheckMaxEntities'); |
|
85 | 85 | if ( ++$entitiesChecked > $maxEntities ) { |
86 | - throw new OverflowException( 'Too many entities to check' ); |
|
86 | + throw new OverflowException('Too many entities to check'); |
|
87 | 87 | } |
88 | 88 | |
89 | - $item = $this->entityLookup->getEntity( $comparativeClass ); |
|
90 | - if ( !( $item instanceof StatementListProvider ) ) { |
|
89 | + $item = $this->entityLookup->getEntity($comparativeClass); |
|
90 | + if (!($item instanceof StatementListProvider)) { |
|
91 | 91 | return false; // lookup failed, probably because item doesn't exist |
92 | 92 | } |
93 | 93 | |
94 | - $subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfId' ); |
|
94 | + $subclassId = $this->config->get('WBQualityConstraintsSubclassOfId'); |
|
95 | 95 | /** @var Statement $statement */ |
96 | - foreach ( $item->getStatements()->getByPropertyId( new PropertyId( $subclassId ) ) as $statement ) { |
|
96 | + foreach ($item->getStatements()->getByPropertyId(new PropertyId($subclassId)) as $statement) { |
|
97 | 97 | $mainSnak = $statement->getMainSnak(); |
98 | 98 | |
99 | - if ( !( $this->hasCorrectType( $mainSnak ) ) ) { |
|
99 | + if (!($this->hasCorrectType($mainSnak))) { |
|
100 | 100 | continue; |
101 | 101 | } |
102 | 102 | /** @var PropertyValueSnak $mainSnak */ |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | $dataValue = $mainSnak->getDataValue(); |
106 | 106 | $comparativeClass = $dataValue->getEntityId(); |
107 | 107 | |
108 | - if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) { |
|
108 | + if (in_array($comparativeClass->getSerialization(), $classesToCheck)) { |
|
109 | 109 | return true; |
110 | 110 | } |
111 | 111 | |
112 | - if ( $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ) ) { |
|
112 | + if ($this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked)) { |
|
113 | 113 | return true; |
114 | 114 | } |
115 | 115 | } |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | * @return CachedBool |
131 | 131 | * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs |
132 | 132 | */ |
133 | - public function isSubclassOfWithSparqlFallback( EntityId $comparativeClass, array $classesToCheck ) { |
|
133 | + public function isSubclassOfWithSparqlFallback(EntityId $comparativeClass, array $classesToCheck) { |
|
134 | 134 | try { |
135 | 135 | return new CachedBool( |
136 | - $this->isSubclassOf( $comparativeClass, $classesToCheck ), |
|
136 | + $this->isSubclassOf($comparativeClass, $classesToCheck), |
|
137 | 137 | Metadata::blank() |
138 | 138 | ); |
139 | - } catch ( OverflowException $e ) { |
|
140 | - if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) { |
|
139 | + } catch (OverflowException $e) { |
|
140 | + if (!($this->sparqlHelper instanceof DummySparqlHelper)) { |
|
141 | 141 | $this->dataFactory->increment( |
142 | 142 | 'wikibase.quality.constraints.sparql.typeFallback' |
143 | 143 | ); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | /* withInstance = */ false |
148 | 148 | ); |
149 | 149 | } else { |
150 | - return new CachedBool( false, Metadata::blank() ); |
|
150 | + return new CachedBool(false, Metadata::blank()); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | * @return CachedBool |
166 | 166 | * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs |
167 | 167 | */ |
168 | - public function hasClassInRelation( StatementList $statements, array $relationIds, array $classesToCheck ) { |
|
168 | + public function hasClassInRelation(StatementList $statements, array $relationIds, array $classesToCheck) { |
|
169 | 169 | $metadatas = []; |
170 | 170 | |
171 | - foreach ( $this->getStatementsByPropertyIds( $statements, $relationIds ) as $statement ) { |
|
171 | + foreach ($this->getStatementsByPropertyIds($statements, $relationIds) as $statement) { |
|
172 | 172 | $mainSnak = $statement->getMainSnak(); |
173 | 173 | |
174 | - if ( !$this->hasCorrectType( $mainSnak ) ) { |
|
174 | + if (!$this->hasCorrectType($mainSnak)) { |
|
175 | 175 | continue; |
176 | 176 | } |
177 | 177 | /** @var PropertyValueSnak $mainSnak */ |
@@ -180,28 +180,28 @@ discard block |
||
180 | 180 | $dataValue = $mainSnak->getDataValue(); |
181 | 181 | $comparativeClass = $dataValue->getEntityId(); |
182 | 182 | |
183 | - if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) { |
|
183 | + if (in_array($comparativeClass->getSerialization(), $classesToCheck)) { |
|
184 | 184 | // discard $metadatas, we know this is fresh |
185 | - return new CachedBool( true, Metadata::blank() ); |
|
185 | + return new CachedBool(true, Metadata::blank()); |
|
186 | 186 | } |
187 | 187 | |
188 | - $result = $this->isSubclassOfWithSparqlFallback( $comparativeClass, $classesToCheck ); |
|
188 | + $result = $this->isSubclassOfWithSparqlFallback($comparativeClass, $classesToCheck); |
|
189 | 189 | $metadatas[] = $result->getMetadata(); |
190 | - if ( $result->getBool() ) { |
|
190 | + if ($result->getBool()) { |
|
191 | 191 | return new CachedBool( |
192 | 192 | true, |
193 | - Metadata::merge( $metadatas ) |
|
193 | + Metadata::merge($metadatas) |
|
194 | 194 | ); |
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | 198 | return new CachedBool( |
199 | 199 | false, |
200 | - Metadata::merge( $metadatas ) |
|
200 | + Metadata::merge($metadatas) |
|
201 | 201 | ); |
202 | 202 | } |
203 | 203 | |
204 | - private function hasCorrectType( Snak $mainSnak ) { |
|
204 | + private function hasCorrectType(Snak $mainSnak) { |
|
205 | 205 | return $mainSnak instanceof PropertyValueSnak |
206 | 206 | && $mainSnak->getDataValue()->getType() === 'wikibase-entityid'; |
207 | 207 | } |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | ) { |
219 | 219 | $statementArrays = []; |
220 | 220 | |
221 | - foreach ( $propertyIdSerializations as $propertyIdSerialization ) { |
|
222 | - $propertyId = new PropertyId( $propertyIdSerialization ); |
|
223 | - $statementArrays[] = $statements->getByPropertyId( $propertyId )->toArray(); |
|
221 | + foreach ($propertyIdSerializations as $propertyIdSerialization) { |
|
222 | + $propertyId = new PropertyId($propertyIdSerialization); |
|
223 | + $statementArrays[] = $statements->getByPropertyId($propertyId)->toArray(); |
|
224 | 224 | } |
225 | 225 | |
226 | - return call_user_func_array( 'array_merge', $statementArrays ); |
|
226 | + return call_user_func_array('array_merge', $statementArrays); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return ViolationMessage |
237 | 237 | */ |
238 | - public function getViolationMessage( PropertyId $propertyId, EntityId $entityId, array $classes, $checker, $relation ) { |
|
238 | + public function getViolationMessage(PropertyId $propertyId, EntityId $entityId, array $classes, $checker, $relation) { |
|
239 | 239 | $classes = array_map( |
240 | - function( $itemIdSerialization ) { |
|
241 | - return new ItemId( $itemIdSerialization ); |
|
240 | + function($itemIdSerialization) { |
|
241 | + return new ItemId($itemIdSerialization); |
|
242 | 242 | }, |
243 | 243 | $classes |
244 | 244 | ); |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | // wbqc-violation-message-valueType-instance |
251 | 251 | // wbqc-violation-message-valueType-subclass |
252 | 252 | // wbqc-violation-message-valueType-instanceOrSubclass |
253 | - return ( new ViolationMessage( 'wbqc-violation-message-' . $checker . '-' . $relation ) ) |
|
254 | - ->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY ) |
|
255 | - ->withEntityId( $entityId, Role::SUBJECT ) |
|
256 | - ->withEntityIdList( $classes, Role::OBJECT ); |
|
253 | + return (new ViolationMessage('wbqc-violation-message-'.$checker.'-'.$relation)) |
|
254 | + ->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY) |
|
255 | + ->withEntityId($entityId, Role::SUBJECT) |
|
256 | + ->withEntityIdList($classes, Role::OBJECT); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | } |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | // no parent::__construct() call |
23 | 23 | } |
24 | 24 | |
25 | - public function hasType( $id, array $classes, $withInstance ) { |
|
26 | - throw new LogicException( 'methods of this class should never be called' ); |
|
25 | + public function hasType($id, array $classes, $withInstance) { |
|
26 | + throw new LogicException('methods of this class should never be called'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | public function findEntitiesWithSameStatement( |
30 | 30 | Statement $statement, |
31 | 31 | $ignoreDeprecatedStatements |
32 | 32 | ) { |
33 | - throw new LogicException( 'methods of this class should never be called' ); |
|
33 | + throw new LogicException('methods of this class should never be called'); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | public function findEntitiesWithSameQualifierOrReference( |
@@ -39,15 +39,15 @@ discard block |
||
39 | 39 | $type, |
40 | 40 | $ignoreDeprecatedStatements |
41 | 41 | ) { |
42 | - throw new LogicException( 'methods of this class should never be called' ); |
|
42 | + throw new LogicException('methods of this class should never be called'); |
|
43 | 43 | } |
44 | 44 | |
45 | - public function matchesRegularExpression( $text, $regex ) { |
|
46 | - throw new LogicException( 'methods of this class should never be called' ); |
|
45 | + public function matchesRegularExpression($text, $regex) { |
|
46 | + throw new LogicException('methods of this class should never be called'); |
|
47 | 47 | } |
48 | 48 | |
49 | - public function runQuery( $query ) { |
|
50 | - throw new LogicException( 'methods of this class should never be called' ); |
|
49 | + public function runQuery($query) { |
|
50 | + throw new LogicException('methods of this class should never be called'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
@@ -64,22 +64,22 @@ discard block |
||
64 | 64 | * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs |
65 | 65 | * @return CheckResult |
66 | 66 | */ |
67 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
68 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
69 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
67 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
68 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
69 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $parameters = []; |
73 | 73 | |
74 | - if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) { |
|
75 | - if ( $context->getType() === 'statement' ) { |
|
74 | + if (!($this->sparqlHelper instanceof DummySparqlHelper)) { |
|
75 | + if ($context->getType() === 'statement') { |
|
76 | 76 | $result = $this->sparqlHelper->findEntitiesWithSameStatement( |
77 | 77 | $context->getSnakStatement(), |
78 | 78 | true // ignore deprecated statements |
79 | 79 | ); |
80 | 80 | } else { |
81 | - if ( $context->getSnak()->getType() !== 'value' ) { |
|
82 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE ); |
|
81 | + if ($context->getSnak()->getType() !== 'value') { |
|
82 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE); |
|
83 | 83 | } |
84 | 84 | $result = $this->sparqlHelper->findEntitiesWithSameQualifierOrReference( |
85 | 85 | $context->getEntity()->getId(), |
@@ -92,27 +92,27 @@ discard block |
||
92 | 92 | $otherEntities = $result->getArray(); |
93 | 93 | $metadata = $result->getMetadata(); |
94 | 94 | |
95 | - if ( $otherEntities === [] ) { |
|
95 | + if ($otherEntities === []) { |
|
96 | 96 | $status = CheckResult::STATUS_COMPLIANCE; |
97 | 97 | $message = null; |
98 | 98 | } else { |
99 | - $otherEntities = array_values( array_filter( $otherEntities ) ); // remove nulls |
|
99 | + $otherEntities = array_values(array_filter($otherEntities)); // remove nulls |
|
100 | 100 | $status = CheckResult::STATUS_VIOLATION; |
101 | - $message = ( new ViolationMessage( 'wbqc-violation-message-unique-value' ) ) |
|
102 | - ->withEntityIdList( $otherEntities, Role::SUBJECT ); |
|
101 | + $message = (new ViolationMessage('wbqc-violation-message-unique-value')) |
|
102 | + ->withEntityIdList($otherEntities, Role::SUBJECT); |
|
103 | 103 | } |
104 | 104 | } else { |
105 | 105 | $status = CheckResult::STATUS_TODO; |
106 | - $message = ( new ViolationMessage( 'wbqc-violation-message-not-yet-implemented' ) ) |
|
107 | - ->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM ); |
|
106 | + $message = (new ViolationMessage('wbqc-violation-message-not-yet-implemented')) |
|
107 | + ->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM); |
|
108 | 108 | $metadata = Metadata::blank(); |
109 | 109 | } |
110 | 110 | |
111 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
112 | - ->withMetadata( $metadata ); |
|
111 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
112 | + ->withMetadata($metadata); |
|
113 | 113 | } |
114 | 114 | |
115 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
115 | + public function checkConstraintParameters(Constraint $constraint) { |
|
116 | 116 | // no parameters |
117 | 117 | return []; |
118 | 118 | } |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | * @throws ConstraintParameterException |
86 | 86 | * @return CheckResult |
87 | 87 | */ |
88 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
88 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
89 | 89 | $parameters = []; |
90 | 90 | $constraintParameters = $constraint->getConstraintParameters(); |
91 | 91 | |
92 | - $format = $this->constraintParameterParser->parseFormatParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
93 | - $parameters['pattern'] = [ $format ]; |
|
92 | + $format = $this->constraintParameterParser->parseFormatParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
93 | + $parameters['pattern'] = [$format]; |
|
94 | 94 | |
95 | 95 | $syntaxClarifications = $this->constraintParameterParser->parseSyntaxClarificationParameter( |
96 | 96 | $constraintParameters |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | |
99 | 99 | $snak = $context->getSnak(); |
100 | 100 | |
101 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
101 | + if (!$snak instanceof PropertyValueSnak) { |
|
102 | 102 | // nothing to check |
103 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
103 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | $dataValue = $snak->getDataValue(); |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * error handling: |
110 | 110 | * type of $dataValue for properties with 'Format' constraint has to be 'string' or 'monolingualtext' |
111 | 111 | */ |
112 | - switch ( $dataValue->getType() ) { |
|
112 | + switch ($dataValue->getType()) { |
|
113 | 113 | case 'string': |
114 | 114 | $text = $dataValue->getValue(); |
115 | 115 | break; |
@@ -118,49 +118,49 @@ discard block |
||
118 | 118 | $text = $dataValue->getText(); |
119 | 119 | break; |
120 | 120 | default: |
121 | - $message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-types-2' ) ) |
|
122 | - ->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM ) |
|
123 | - ->withDataValueType( 'string' ) |
|
124 | - ->withDataValueType( 'monolingualtext' ); |
|
125 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
121 | + $message = (new ViolationMessage('wbqc-violation-message-value-needed-of-types-2')) |
|
122 | + ->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM) |
|
123 | + ->withDataValueType('string') |
|
124 | + ->withDataValueType('monolingualtext'); |
|
125 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | if ( |
129 | - !( $this->sparqlHelper instanceof DummySparqlHelper ) && |
|
130 | - $this->config->get( 'WBQualityConstraintsCheckFormatConstraint' ) |
|
129 | + !($this->sparqlHelper instanceof DummySparqlHelper) && |
|
130 | + $this->config->get('WBQualityConstraintsCheckFormatConstraint') |
|
131 | 131 | ) { |
132 | - if ( $this->sparqlHelper->matchesRegularExpression( $text, $format ) ) { |
|
132 | + if ($this->sparqlHelper->matchesRegularExpression($text, $format)) { |
|
133 | 133 | $message = null; |
134 | 134 | $status = CheckResult::STATUS_COMPLIANCE; |
135 | 135 | } else { |
136 | - $message = ( new ViolationMessage( 'wbqc-violation-message-format-clarification' ) ) |
|
137 | - ->withEntityId( $context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY ) |
|
138 | - ->withDataValue( new StringValue( $text ), Role::OBJECT ) |
|
139 | - ->withInlineCode( $format, Role::CONSTRAINT_PARAMETER_VALUE ) |
|
140 | - ->withMultilingualText( $syntaxClarifications, Role::CONSTRAINT_PARAMETER_VALUE ); |
|
136 | + $message = (new ViolationMessage('wbqc-violation-message-format-clarification')) |
|
137 | + ->withEntityId($context->getSnak()->getPropertyId(), Role::CONSTRAINT_PROPERTY) |
|
138 | + ->withDataValue(new StringValue($text), Role::OBJECT) |
|
139 | + ->withInlineCode($format, Role::CONSTRAINT_PARAMETER_VALUE) |
|
140 | + ->withMultilingualText($syntaxClarifications, Role::CONSTRAINT_PARAMETER_VALUE); |
|
141 | 141 | $status = CheckResult::STATUS_VIOLATION; |
142 | 142 | } |
143 | 143 | } else { |
144 | - $message = ( new ViolationMessage( 'wbqc-violation-message-security-reason' ) ) |
|
145 | - ->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM ); |
|
144 | + $message = (new ViolationMessage('wbqc-violation-message-security-reason')) |
|
145 | + ->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM); |
|
146 | 146 | $status = CheckResult::STATUS_TODO; |
147 | 147 | } |
148 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
148 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
149 | 149 | } |
150 | 150 | |
151 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
151 | + public function checkConstraintParameters(Constraint $constraint) { |
|
152 | 152 | $constraintParameters = $constraint->getConstraintParameters(); |
153 | 153 | $exceptions = []; |
154 | 154 | try { |
155 | - $this->constraintParameterParser->parseFormatParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
156 | - } catch ( ConstraintParameterException $e ) { |
|
155 | + $this->constraintParameterParser->parseFormatParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
156 | + } catch (ConstraintParameterException $e) { |
|
157 | 157 | $exceptions[] = $e; |
158 | 158 | } |
159 | 159 | try { |
160 | 160 | $this->constraintParameterParser->parseSyntaxClarificationParameter( |
161 | 161 | $constraintParameters |
162 | 162 | ); |
163 | - } catch ( ConstraintParameterException $e ) { |
|
163 | + } catch (ConstraintParameterException $e) { |
|
164 | 164 | $exceptions[] = $e; |
165 | 165 | } |
166 | 166 | return $exceptions; |
@@ -31,48 +31,48 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * @param DatabaseUpdater $updater |
33 | 33 | */ |
34 | - public static function onCreateSchema( DatabaseUpdater $updater ) { |
|
34 | + public static function onCreateSchema(DatabaseUpdater $updater) { |
|
35 | 35 | $updater->addExtensionTable( |
36 | 36 | 'wbqc_constraints', |
37 | - __DIR__ . '/../sql/create_wbqc_constraints.sql' |
|
37 | + __DIR__.'/../sql/create_wbqc_constraints.sql' |
|
38 | 38 | ); |
39 | 39 | $updater->addExtensionField( |
40 | 40 | 'wbqc_constraints', |
41 | 41 | 'constraint_id', |
42 | - __DIR__ . '/../sql/patch-wbqc_constraints-constraint_id.sql' |
|
42 | + __DIR__.'/../sql/patch-wbqc_constraints-constraint_id.sql' |
|
43 | 43 | ); |
44 | 44 | $updater->addExtensionIndex( |
45 | 45 | 'wbqc_constraints', |
46 | 46 | 'wbqc_constraints_guid_uniq', |
47 | - __DIR__ . '/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
47 | + __DIR__.'/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
48 | 48 | ); |
49 | 49 | } |
50 | 50 | |
51 | - public static function onWikibaseChange( Change $change ) { |
|
51 | + public static function onWikibaseChange(Change $change) { |
|
52 | 52 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
53 | - if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
54 | - self::isConstraintStatementsChange( $config, $change ) |
|
53 | + if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
54 | + self::isConstraintStatementsChange($config, $change) |
|
55 | 55 | ) { |
56 | 56 | /** @var EntityChange $change */ |
57 | 57 | $title = Title::newMainPage(); |
58 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
58 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
59 | 59 | JobQueueGroup::singleton()->push( |
60 | - new JobSpecification( 'constraintsTableUpdate', $params, [], $title ) |
|
60 | + new JobSpecification('constraintsTableUpdate', $params, [], $title) |
|
61 | 61 | ); |
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | - public static function isConstraintStatementsChange( Config $config, Change $change ) { |
|
66 | - if ( !( $change instanceof EntityChange ) || |
|
65 | + public static function isConstraintStatementsChange(Config $config, Change $change) { |
|
66 | + if (!($change instanceof EntityChange) || |
|
67 | 67 | $change->getAction() !== EntityChange::UPDATE || |
68 | - !( $change->getEntityId() instanceof PropertyId ) |
|
68 | + !($change->getEntityId() instanceof PropertyId) |
|
69 | 69 | ) { |
70 | 70 | return false; |
71 | 71 | } |
72 | 72 | |
73 | 73 | $info = $change->getInfo(); |
74 | 74 | |
75 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
75 | + if (!array_key_exists('compactDiff', $info)) { |
|
76 | 76 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
77 | 77 | // so we only know that the change *might* affect the constraint statements |
78 | 78 | return true; |
@@ -81,46 +81,46 @@ discard block |
||
81 | 81 | /** @var EntityDiffChangedAspects $aspects */ |
82 | 82 | $aspects = $info['compactDiff']; |
83 | 83 | |
84 | - $propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
85 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
84 | + $propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
85 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
86 | 86 | } |
87 | 87 | |
88 | - public static function onArticlePurge( WikiPage $wikiPage ) { |
|
88 | + public static function onArticlePurge(WikiPage $wikiPage) { |
|
89 | 89 | $repo = WikibaseRepo::getDefaultInstance(); |
90 | 90 | |
91 | 91 | $entityContentFactory = $repo->getEntityContentFactory(); |
92 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
93 | - $entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
94 | - if ( $entityId !== null ) { |
|
92 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
93 | + $entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle()); |
|
94 | + if ($entityId !== null) { |
|
95 | 95 | $resultsCache = ResultsCache::getDefaultInstance(); |
96 | - $resultsCache->delete( $entityId ); |
|
96 | + $resultsCache->delete($entityId); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { |
|
101 | + public static function onBeforePageDisplay(OutputPage $out, Skin $skin) { |
|
102 | 102 | $repo = WikibaseRepo::getDefaultInstance(); |
103 | 103 | |
104 | 104 | $lookup = $repo->getEntityNamespaceLookup(); |
105 | 105 | $title = $out->getTitle(); |
106 | - if ( $title === null ) { |
|
106 | + if ($title === null) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | - if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) { |
|
110 | + if (!$lookup->isEntityNamespace($title->getNamespace())) { |
|
111 | 111 | return; |
112 | 112 | } |
113 | - if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) { |
|
113 | + if (empty($out->getJsConfigVars()['wbIsEditView'])) { |
|
114 | 114 | return; |
115 | 115 | } |
116 | 116 | |
117 | - $out->addModules( 'wikibase.quality.constraints.suggestions' ); |
|
117 | + $out->addModules('wikibase.quality.constraints.suggestions'); |
|
118 | 118 | |
119 | - if ( !$out->getUser()->isLoggedIn() ) { |
|
119 | + if (!$out->getUser()->isLoggedIn()) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | 122 | |
123 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
123 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | * @param User $user |
130 | 130 | * @param array[] &$prefs |
131 | 131 | */ |
132 | - public static function onGetBetaFeaturePreferences( User $user, array &$prefs ) { |
|
132 | + public static function onGetBetaFeaturePreferences(User $user, array &$prefs) { |
|
133 | 133 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
134 | - $extensionAssetsPath = $config->get( 'ExtensionAssetsPath' ); |
|
135 | - if ( $config->get( 'WBQualityConstraintsSuggestionsBetaFeature' ) ) { |
|
134 | + $extensionAssetsPath = $config->get('ExtensionAssetsPath'); |
|
135 | + if ($config->get('WBQualityConstraintsSuggestionsBetaFeature')) { |
|
136 | 136 | $prefs['constraint-suggestions'] = [ |
137 | 137 | 'label-message' => 'wbqc-beta-feature-label-message', |
138 | 138 | 'desc-message' => 'wbqc-beta-feature-description-message', |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | * @param array &$vars |
157 | 157 | * @param OutputPage $out |
158 | 158 | */ |
159 | - public static function addVariables( &$vars, OutputPage $out ) { |
|
159 | + public static function addVariables(&$vars, OutputPage $out) { |
|
160 | 160 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
161 | 161 | |
162 | - $vars['wbQualityConstraintsPropertyConstraintId'] = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
163 | - $vars['wbQualityConstraintsOneOfConstraintId'] = $config->get( 'WBQualityConstraintsOneOfConstraintId' ); |
|
164 | - $vars['wbQualityConstraintsAllowedQualifierConstraintId'] = $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ); |
|
165 | - $vars['wbQualityConstraintsPropertyId'] = $config->get( 'WBQualityConstraintsPropertyId' ); |
|
166 | - $vars['wbQualityConstraintsQualifierOfPropertyConstraintId'] = $config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' ); |
|
162 | + $vars['wbQualityConstraintsPropertyConstraintId'] = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
163 | + $vars['wbQualityConstraintsOneOfConstraintId'] = $config->get('WBQualityConstraintsOneOfConstraintId'); |
|
164 | + $vars['wbQualityConstraintsAllowedQualifierConstraintId'] = $config->get('WBQualityConstraintsAllowedQualifiersConstraintId'); |
|
165 | + $vars['wbQualityConstraintsPropertyId'] = $config->get('WBQualityConstraintsPropertyId'); |
|
166 | + $vars['wbQualityConstraintsQualifierOfPropertyConstraintId'] = $config->get('WBQualityConstraintsQualifierOfPropertyConstraintId'); |
|
167 | 167 | |
168 | 168 | $vars['wbQualityConstraintsSuggestionsGloballyEnabled'] = false; |
169 | 169 | |
170 | - if ( $config->get( 'WBQualityConstraintsSuggestionsBetaFeature' ) && |
|
171 | - ExtensionRegistry::getInstance()->isLoaded( 'BetaFeatures' ) && |
|
172 | - BetaFeatures::isFeatureEnabled( $out->getUser(), 'constraint-suggestions' ) |
|
170 | + if ($config->get('WBQualityConstraintsSuggestionsBetaFeature') && |
|
171 | + ExtensionRegistry::getInstance()->isLoaded('BetaFeatures') && |
|
172 | + BetaFeatures::isFeatureEnabled($out->getUser(), 'constraint-suggestions') |
|
173 | 173 | ) { |
174 | 174 | $vars['wbQualityConstraintsSuggestionsGloballyEnabled'] = true; |
175 | 175 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | Config $config, |
137 | 137 | IBufferingStatsdDataFactory $dataFactory |
138 | 138 | ) { |
139 | - parent::__construct( 'ConstraintReport' ); |
|
139 | + parent::__construct('ConstraintReport'); |
|
140 | 140 | |
141 | 141 | $this->entityLookup = $entityLookup; |
142 | 142 | $this->entityTitleLookup = $entityTitleLookup; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $language = $this->getLanguage(); |
146 | 146 | |
147 | 147 | $formatterOptions = new FormatterOptions(); |
148 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
148 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
149 | 149 | $this->dataValueFormatter = $valueFormatterFactory->getValueFormatter( |
150 | 150 | SnakFormatter::FORMAT_HTML, |
151 | 151 | $formatterOptions |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * @return string |
206 | 206 | */ |
207 | 207 | public function getDescription() { |
208 | - return $this->msg( 'wbqc-constraintreport' )->escaped(); |
|
208 | + return $this->msg('wbqc-constraintreport')->escaped(); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -217,43 +217,43 @@ discard block |
||
217 | 217 | * @throws EntityIdParsingException |
218 | 218 | * @throws UnexpectedValueException |
219 | 219 | */ |
220 | - public function execute( $subPage ) { |
|
220 | + public function execute($subPage) { |
|
221 | 221 | $out = $this->getOutput(); |
222 | 222 | |
223 | - $postRequest = $this->getContext()->getRequest()->getVal( 'entityid' ); |
|
224 | - if ( $postRequest ) { |
|
225 | - $out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() ); |
|
223 | + $postRequest = $this->getContext()->getRequest()->getVal('entityid'); |
|
224 | + if ($postRequest) { |
|
225 | + $out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL()); |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
229 | 229 | $out->enableOOUI(); |
230 | - $out->addModules( $this->getModules() ); |
|
230 | + $out->addModules($this->getModules()); |
|
231 | 231 | |
232 | 232 | $this->setHeaders(); |
233 | 233 | |
234 | - $out->addHTML( $this->getExplanationText() ); |
|
234 | + $out->addHTML($this->getExplanationText()); |
|
235 | 235 | $this->buildEntityIdForm(); |
236 | 236 | |
237 | - if ( !$subPage ) { |
|
237 | + if (!$subPage) { |
|
238 | 238 | return; |
239 | 239 | } |
240 | 240 | |
241 | - if ( !is_string( $subPage ) ) { |
|
242 | - throw new InvalidArgumentException( '$subPage must be string.' ); |
|
241 | + if (!is_string($subPage)) { |
|
242 | + throw new InvalidArgumentException('$subPage must be string.'); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | try { |
246 | - $entityId = $this->entityIdParser->parse( $subPage ); |
|
247 | - } catch ( EntityIdParsingException $e ) { |
|
246 | + $entityId = $this->entityIdParser->parse($subPage); |
|
247 | + } catch (EntityIdParsingException $e) { |
|
248 | 248 | $out->addHTML( |
249 | - $this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true ) |
|
249 | + $this->buildNotice('wbqc-constraintreport-invalid-entity-id', true) |
|
250 | 250 | ); |
251 | 251 | return; |
252 | 252 | } |
253 | 253 | |
254 | - if ( !$this->entityLookup->hasEntity( $entityId ) ) { |
|
254 | + if (!$this->entityLookup->hasEntity($entityId)) { |
|
255 | 255 | $out->addHTML( |
256 | - $this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true ) |
|
256 | + $this->buildNotice('wbqc-constraintreport-not-existent-entity', true) |
|
257 | 257 | ); |
258 | 258 | return; |
259 | 259 | } |
@@ -261,18 +261,18 @@ discard block |
||
261 | 261 | $this->dataFactory->increment( |
262 | 262 | 'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck' |
263 | 263 | ); |
264 | - $results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId ); |
|
264 | + $results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId); |
|
265 | 265 | |
266 | - if ( $results !== [] ) { |
|
266 | + if ($results !== []) { |
|
267 | 267 | $out->addHTML( |
268 | - $this->buildResultHeader( $entityId ) |
|
269 | - . $this->buildSummary( $results ) |
|
270 | - . $this->buildResultTable( $entityId, $results ) |
|
268 | + $this->buildResultHeader($entityId) |
|
269 | + . $this->buildSummary($results) |
|
270 | + . $this->buildResultTable($entityId, $results) |
|
271 | 271 | ); |
272 | 272 | } else { |
273 | 273 | $out->addHTML( |
274 | - $this->buildResultHeader( $entityId ) |
|
275 | - . $this->buildNotice( 'wbqc-constraintreport-empty-result' ) |
|
274 | + $this->buildResultHeader($entityId) |
|
275 | + . $this->buildNotice('wbqc-constraintreport-empty-result') |
|
276 | 276 | ); |
277 | 277 | } |
278 | 278 | } |
@@ -288,15 +288,15 @@ discard block |
||
288 | 288 | 'name' => 'entityid', |
289 | 289 | 'label-message' => 'wbqc-constraintreport-form-entityid-label', |
290 | 290 | 'cssclass' => 'wbqc-constraintreport-form-entity-id', |
291 | - 'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped() |
|
291 | + 'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped() |
|
292 | 292 | ] |
293 | 293 | ]; |
294 | - $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' ); |
|
295 | - $htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() ); |
|
296 | - $htmlForm->setSubmitCallback( function() { |
|
294 | + $htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form'); |
|
295 | + $htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped()); |
|
296 | + $htmlForm->setSubmitCallback(function() { |
|
297 | 297 | return false; |
298 | 298 | } ); |
299 | - $htmlForm->setMethod( 'post' ); |
|
299 | + $htmlForm->setMethod('post'); |
|
300 | 300 | $htmlForm->show(); |
301 | 301 | } |
302 | 302 | |
@@ -310,16 +310,16 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @return string HTML |
312 | 312 | */ |
313 | - private function buildNotice( $messageKey, $error = false ) { |
|
314 | - if ( !is_string( $messageKey ) ) { |
|
315 | - throw new InvalidArgumentException( '$message must be string.' ); |
|
313 | + private function buildNotice($messageKey, $error = false) { |
|
314 | + if (!is_string($messageKey)) { |
|
315 | + throw new InvalidArgumentException('$message must be string.'); |
|
316 | 316 | } |
317 | - if ( !is_bool( $error ) ) { |
|
318 | - throw new InvalidArgumentException( '$error must be bool.' ); |
|
317 | + if (!is_bool($error)) { |
|
318 | + throw new InvalidArgumentException('$error must be bool.'); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | $cssClasses = 'wbqc-constraintreport-notice'; |
322 | - if ( $error ) { |
|
322 | + if ($error) { |
|
323 | 323 | $cssClasses .= ' wbqc-constraintreport-notice-error'; |
324 | 324 | } |
325 | 325 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | [ |
329 | 329 | 'class' => $cssClasses |
330 | 330 | ], |
331 | - $this->msg( $messageKey )->escaped() |
|
331 | + $this->msg($messageKey)->escaped() |
|
332 | 332 | ); |
333 | 333 | } |
334 | 334 | |
@@ -338,16 +338,16 @@ discard block |
||
338 | 338 | private function getExplanationText() { |
339 | 339 | return Html::rawElement( |
340 | 340 | 'div', |
341 | - [ 'class' => 'wbqc-explanation' ], |
|
341 | + ['class' => 'wbqc-explanation'], |
|
342 | 342 | Html::rawElement( |
343 | 343 | 'p', |
344 | 344 | [], |
345 | - $this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped() |
|
345 | + $this->msg('wbqc-constraintreport-explanation-part-one')->escaped() |
|
346 | 346 | ) |
347 | 347 | . Html::rawElement( |
348 | 348 | 'p', |
349 | 349 | [], |
350 | - $this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped() |
|
350 | + $this->msg('wbqc-constraintreport-explanation-part-two')->escaped() |
|
351 | 351 | ) |
352 | 352 | ); |
353 | 353 | } |
@@ -358,72 +358,72 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return string HTML |
360 | 360 | */ |
361 | - private function buildResultTable( EntityId $entityId, array $results ) { |
|
361 | + private function buildResultTable(EntityId $entityId, array $results) { |
|
362 | 362 | // Set table headers |
363 | 363 | $table = new HtmlTableBuilder( |
364 | 364 | [ |
365 | 365 | new HtmlTableHeaderBuilder( |
366 | - $this->msg( 'wbqc-constraintreport-result-table-header-status' )->escaped(), |
|
366 | + $this->msg('wbqc-constraintreport-result-table-header-status')->escaped(), |
|
367 | 367 | true |
368 | 368 | ), |
369 | 369 | new HtmlTableHeaderBuilder( |
370 | - $this->msg( 'wbqc-constraintreport-result-table-header-property' )->escaped(), |
|
370 | + $this->msg('wbqc-constraintreport-result-table-header-property')->escaped(), |
|
371 | 371 | true |
372 | 372 | ), |
373 | 373 | new HtmlTableHeaderBuilder( |
374 | - $this->msg( 'wbqc-constraintreport-result-table-header-message' )->escaped(), |
|
374 | + $this->msg('wbqc-constraintreport-result-table-header-message')->escaped(), |
|
375 | 375 | true |
376 | 376 | ), |
377 | 377 | new HtmlTableHeaderBuilder( |
378 | - $this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->escaped(), |
|
378 | + $this->msg('wbqc-constraintreport-result-table-header-constraint')->escaped(), |
|
379 | 379 | true |
380 | 380 | ) |
381 | 381 | ] |
382 | 382 | ); |
383 | 383 | |
384 | - foreach ( $results as $result ) { |
|
385 | - $table = $this->appendToResultTable( $table, $entityId, $result ); |
|
384 | + foreach ($results as $result) { |
|
385 | + $table = $this->appendToResultTable($table, $entityId, $result); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | return $table->toHtml(); |
389 | 389 | } |
390 | 390 | |
391 | - private function appendToResultTable( HtmlTableBuilder $table, EntityId $entityId, CheckResult $result ) { |
|
391 | + private function appendToResultTable(HtmlTableBuilder $table, EntityId $entityId, CheckResult $result) { |
|
392 | 392 | $message = $result->getMessage(); |
393 | - if ( $message === null ) { |
|
393 | + if ($message === null) { |
|
394 | 394 | // no row for this result |
395 | 395 | return $table; |
396 | 396 | } |
397 | 397 | |
398 | 398 | // Status column |
399 | - $statusColumn = $this->formatStatus( $result->getStatus() ); |
|
399 | + $statusColumn = $this->formatStatus($result->getStatus()); |
|
400 | 400 | |
401 | 401 | // Property column |
402 | - $propertyId = new PropertyId( $result->getContextCursor()->getSnakPropertyId() ); |
|
402 | + $propertyId = new PropertyId($result->getContextCursor()->getSnakPropertyId()); |
|
403 | 403 | $propertyColumn = $this->getClaimLink( |
404 | 404 | $entityId, |
405 | 405 | $propertyId, |
406 | - $this->entityIdLabelFormatter->formatEntityId( $propertyId ) |
|
406 | + $this->entityIdLabelFormatter->formatEntityId($propertyId) |
|
407 | 407 | ); |
408 | 408 | |
409 | 409 | // Message column |
410 | - $messageColumn = $this->violationMessageRenderer->render( $message ); |
|
410 | + $messageColumn = $this->violationMessageRenderer->render($message); |
|
411 | 411 | |
412 | 412 | // Constraint column |
413 | 413 | $constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId(); |
414 | 414 | try { |
415 | - $constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) ); |
|
416 | - } catch ( InvalidArgumentException $e ) { |
|
417 | - $constraintTypeLabel = htmlspecialchars( $constraintTypeItemId ); |
|
415 | + $constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId)); |
|
416 | + } catch (InvalidArgumentException $e) { |
|
417 | + $constraintTypeLabel = htmlspecialchars($constraintTypeItemId); |
|
418 | 418 | } |
419 | 419 | $constraintLink = $this->getClaimLink( |
420 | 420 | $propertyId, |
421 | - new PropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ), |
|
421 | + new PropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')), |
|
422 | 422 | $constraintTypeLabel |
423 | 423 | ); |
424 | 424 | $constraintColumn = $this->buildExpandableElement( |
425 | 425 | $constraintLink, |
426 | - $this->constraintParameterRenderer->formatParameters( $result->getParameters() ), |
|
426 | + $this->constraintParameterRenderer->formatParameters($result->getParameters()), |
|
427 | 427 | '[...]' |
428 | 428 | ); |
429 | 429 | |
@@ -463,15 +463,15 @@ discard block |
||
463 | 463 | * |
464 | 464 | * @return string HTML |
465 | 465 | */ |
466 | - protected function buildResultHeader( EntityId $entityId ) { |
|
467 | - $entityLink = sprintf( '%s (%s)', |
|
468 | - $this->entityIdLinkFormatter->formatEntityId( $entityId ), |
|
469 | - htmlspecialchars( $entityId->getSerialization() ) ); |
|
466 | + protected function buildResultHeader(EntityId $entityId) { |
|
467 | + $entityLink = sprintf('%s (%s)', |
|
468 | + $this->entityIdLinkFormatter->formatEntityId($entityId), |
|
469 | + htmlspecialchars($entityId->getSerialization())); |
|
470 | 470 | |
471 | 471 | return Html::rawElement( |
472 | 472 | 'h3', |
473 | 473 | [], |
474 | - sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink ) |
|
474 | + sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink) |
|
475 | 475 | ); |
476 | 476 | } |
477 | 477 | |
@@ -482,24 +482,24 @@ discard block |
||
482 | 482 | * |
483 | 483 | * @return string HTML |
484 | 484 | */ |
485 | - protected function buildSummary( array $results ) { |
|
485 | + protected function buildSummary(array $results) { |
|
486 | 486 | $statuses = []; |
487 | - foreach ( $results as $result ) { |
|
488 | - $status = strtolower( $result->getStatus() ); |
|
489 | - $statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1; |
|
487 | + foreach ($results as $result) { |
|
488 | + $status = strtolower($result->getStatus()); |
|
489 | + $statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1; |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | $statusElements = []; |
493 | - foreach ( $statuses as $status => $count ) { |
|
494 | - if ( $count > 0 ) { |
|
493 | + foreach ($statuses as $status => $count) { |
|
494 | + if ($count > 0) { |
|
495 | 495 | $statusElements[] = |
496 | - $this->formatStatus( $status ) |
|
496 | + $this->formatStatus($status) |
|
497 | 497 | . ': ' |
498 | 498 | . $count; |
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
502 | - return Html::rawElement( 'p', [], implode( ', ', $statusElements ) ); |
|
502 | + return Html::rawElement('p', [], implode(', ', $statusElements)); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
@@ -514,15 +514,15 @@ discard block |
||
514 | 514 | * |
515 | 515 | * @return string HTML |
516 | 516 | */ |
517 | - protected function buildExpandableElement( $content, $expandableContent, $indicator ) { |
|
518 | - if ( !is_string( $content ) ) { |
|
519 | - throw new InvalidArgumentException( '$content has to be string.' ); |
|
517 | + protected function buildExpandableElement($content, $expandableContent, $indicator) { |
|
518 | + if (!is_string($content)) { |
|
519 | + throw new InvalidArgumentException('$content has to be string.'); |
|
520 | 520 | } |
521 | - if ( $expandableContent && ( !is_string( $expandableContent ) ) ) { |
|
522 | - throw new InvalidArgumentException( '$tooltipContent, if provided, has to be string.' ); |
|
521 | + if ($expandableContent && (!is_string($expandableContent))) { |
|
522 | + throw new InvalidArgumentException('$tooltipContent, if provided, has to be string.'); |
|
523 | 523 | } |
524 | 524 | |
525 | - if ( empty( $expandableContent ) ) { |
|
525 | + if (empty($expandableContent)) { |
|
526 | 526 | return $content; |
527 | 527 | } |
528 | 528 | |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | $expandableContent |
543 | 543 | ); |
544 | 544 | |
545 | - return sprintf( '%s %s %s', $content, $tooltipIndicator, $expandableContent ); |
|
545 | + return sprintf('%s %s %s', $content, $tooltipIndicator, $expandableContent); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -554,8 +554,8 @@ discard block |
||
554 | 554 | * |
555 | 555 | * @return string HTML |
556 | 556 | */ |
557 | - private function formatStatus( $status ) { |
|
558 | - $messageName = "wbqc-constraintreport-status-" . strtolower( $status ); |
|
557 | + private function formatStatus($status) { |
|
558 | + $messageName = "wbqc-constraintreport-status-".strtolower($status); |
|
559 | 559 | $statusIcons = [ |
560 | 560 | CheckResult::STATUS_WARNING => [ |
561 | 561 | 'icon' => 'non-mandatory-constraint-violation', |
@@ -569,25 +569,25 @@ discard block |
||
569 | 569 | ], |
570 | 570 | ]; |
571 | 571 | |
572 | - if ( array_key_exists( $status, $statusIcons ) ) { |
|
573 | - $iconWidget = new IconWidget( $statusIcons[$status] ); |
|
574 | - $iconHtml = $iconWidget->toString() . ' '; |
|
572 | + if (array_key_exists($status, $statusIcons)) { |
|
573 | + $iconWidget = new IconWidget($statusIcons[$status]); |
|
574 | + $iconHtml = $iconWidget->toString().' '; |
|
575 | 575 | } else { |
576 | 576 | $iconHtml = ''; |
577 | 577 | } |
578 | 578 | |
579 | - $labelWidget = new LabelWidget( [ |
|
580 | - 'label' => $this->msg( $messageName )->text(), |
|
581 | - ] ); |
|
579 | + $labelWidget = new LabelWidget([ |
|
580 | + 'label' => $this->msg($messageName)->text(), |
|
581 | + ]); |
|
582 | 582 | $labelHtml = $labelWidget->toString(); |
583 | 583 | |
584 | 584 | $formattedStatus = |
585 | 585 | Html::rawElement( |
586 | 586 | 'span', |
587 | 587 | [ |
588 | - 'class' => 'wbqc-status wbqc-status-' . $status |
|
588 | + 'class' => 'wbqc-status wbqc-status-'.$status |
|
589 | 589 | ], |
590 | - $iconHtml . $labelHtml |
|
590 | + $iconHtml.$labelHtml |
|
591 | 591 | ); |
592 | 592 | |
593 | 593 | return $formattedStatus; |
@@ -603,26 +603,26 @@ discard block |
||
603 | 603 | * |
604 | 604 | * @return string HTML |
605 | 605 | */ |
606 | - protected function formatDataValues( $dataValues, $separator = ', ' ) { |
|
607 | - if ( $dataValues instanceof DataValue ) { |
|
608 | - $dataValues = [ $dataValues ]; |
|
609 | - } elseif ( !is_array( $dataValues ) ) { |
|
610 | - throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' ); |
|
606 | + protected function formatDataValues($dataValues, $separator = ', ') { |
|
607 | + if ($dataValues instanceof DataValue) { |
|
608 | + $dataValues = [$dataValues]; |
|
609 | + } elseif (!is_array($dataValues)) { |
|
610 | + throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.'); |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | $formattedDataValues = []; |
614 | - foreach ( $dataValues as $dataValue ) { |
|
615 | - if ( !( $dataValue instanceof DataValue ) ) { |
|
616 | - throw new InvalidArgumentException( '$dataValues has to be instance of DataValue or an array of DataValues.' ); |
|
614 | + foreach ($dataValues as $dataValue) { |
|
615 | + if (!($dataValue instanceof DataValue)) { |
|
616 | + throw new InvalidArgumentException('$dataValues has to be instance of DataValue or an array of DataValues.'); |
|
617 | 617 | } |
618 | - if ( $dataValue instanceof EntityIdValue ) { |
|
619 | - $formattedDataValues[ ] = $this->entityIdLabelFormatter->formatEntityId( $dataValue->getEntityId() ); |
|
618 | + if ($dataValue instanceof EntityIdValue) { |
|
619 | + $formattedDataValues[] = $this->entityIdLabelFormatter->formatEntityId($dataValue->getEntityId()); |
|
620 | 620 | } else { |
621 | - $formattedDataValues[ ] = $this->dataValueFormatter->format( $dataValue ); |
|
621 | + $formattedDataValues[] = $this->dataValueFormatter->format($dataValue); |
|
622 | 622 | } |
623 | 623 | } |
624 | 624 | |
625 | - return implode( $separator, $formattedDataValues ); |
|
625 | + return implode($separator, $formattedDataValues); |
|
626 | 626 | } |
627 | 627 | |
628 | 628 | /** |
@@ -634,11 +634,11 @@ discard block |
||
634 | 634 | * |
635 | 635 | * @return string HTML |
636 | 636 | */ |
637 | - private function getClaimLink( EntityId $entityId, PropertyId $propertyId, $text ) { |
|
637 | + private function getClaimLink(EntityId $entityId, PropertyId $propertyId, $text) { |
|
638 | 638 | return Html::rawElement( |
639 | 639 | 'a', |
640 | 640 | [ |
641 | - 'href' => $this->getClaimUrl( $entityId, $propertyId ), |
|
641 | + 'href' => $this->getClaimUrl($entityId, $propertyId), |
|
642 | 642 | 'target' => '_blank' |
643 | 643 | ], |
644 | 644 | $text |
@@ -653,9 +653,9 @@ discard block |
||
653 | 653 | * |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - private function getClaimUrl( EntityId $entityId, PropertyId $propertyId ) { |
|
657 | - $title = $this->entityTitleLookup->getTitleForId( $entityId ); |
|
658 | - $entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() ); |
|
656 | + private function getClaimUrl(EntityId $entityId, PropertyId $propertyId) { |
|
657 | + $title = $this->entityTitleLookup->getTitleForId($entityId); |
|
658 | + $entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization()); |
|
659 | 659 | |
660 | 660 | return $entityUrl; |
661 | 661 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @codeCoverageIgnore This method is purely declarative. |
78 | 78 | */ |
79 | 79 | public function getDefaultContextTypes() { |
80 | - return [ Context::TYPE_STATEMENT ]; |
|
80 | + return [Context::TYPE_STATEMENT]; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -89,20 +89,20 @@ discard block |
||
89 | 89 | * @return CheckResult |
90 | 90 | * @throws \ConfigException |
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 | $snak = $context->getSnak(); |
97 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
97 | + if (!$snak instanceof PropertyValueSnak) { |
|
98 | 98 | // nothing to check |
99 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE ); |
|
100 | - } elseif ( $snak->getDataValue()->getType() !== 'wikibase-entityid' ) { |
|
99 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE); |
|
100 | + } elseif ($snak->getDataValue()->getType() !== 'wikibase-entityid') { |
|
101 | 101 | // wrong data type |
102 | - $message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) ) |
|
103 | - ->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM ) |
|
104 | - ->withDataValueType( 'wikibase-entityid' ); |
|
105 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message ); |
|
102 | + $message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type')) |
|
103 | + ->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM) |
|
104 | + ->withDataValueType('wikibase-entityid'); |
|
105 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message); |
|
106 | 106 | } |
107 | 107 | /** @var EntityId $subjectId */ |
108 | 108 | $subjectId = $context->getEntity()->getId(); |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | /** @var Statement[] $subjectStatements */ |
112 | 112 | $subjectStatements = $context->getEntity()->getStatements()->toArray(); |
113 | 113 | /** @var Statement[] $objectStatements */ |
114 | - $objectStatements = $this->entityLookup->getEntity( $objectId )->getStatements()->toArray(); |
|
114 | + $objectStatements = $this->entityLookup->getEntity($objectId)->getStatements()->toArray(); |
|
115 | 115 | /** @var String[] $startPropertyIds */ |
116 | - $startPropertyIds = $this->config->get( self::CONFIG_VARIABLE_START_PROPERTY_IDS ); |
|
116 | + $startPropertyIds = $this->config->get(self::CONFIG_VARIABLE_START_PROPERTY_IDS); |
|
117 | 117 | /** @var String[] $endPropertyIds */ |
118 | - $endPropertyIds = $this->config->get( self::CONFIG_VARIABLE_END_PROPERTY_IDS ); |
|
118 | + $endPropertyIds = $this->config->get(self::CONFIG_VARIABLE_END_PROPERTY_IDS); |
|
119 | 119 | $subjectStartValue = $this->getExtremeValue( |
120 | 120 | $startPropertyIds, |
121 | 121 | $subjectStatements, |
@@ -137,15 +137,15 @@ discard block |
||
137 | 137 | 'end' |
138 | 138 | ); |
139 | 139 | if ( |
140 | - $this->rangeCheckerHelper->getComparison( $subjectStartValue, $subjectEndValue ) <= 0 && |
|
141 | - $this->rangeCheckerHelper->getComparison( $objectStartValue, $objectEndValue ) <= 0 && ( |
|
142 | - $this->rangeCheckerHelper->getComparison( $subjectEndValue, $objectStartValue ) < 0 || |
|
143 | - $this->rangeCheckerHelper->getComparison( $objectEndValue, $subjectStartValue ) < 0 |
|
140 | + $this->rangeCheckerHelper->getComparison($subjectStartValue, $subjectEndValue) <= 0 && |
|
141 | + $this->rangeCheckerHelper->getComparison($objectStartValue, $objectEndValue) <= 0 && ( |
|
142 | + $this->rangeCheckerHelper->getComparison($subjectEndValue, $objectStartValue) < 0 || |
|
143 | + $this->rangeCheckerHelper->getComparison($objectEndValue, $subjectStartValue) < 0 |
|
144 | 144 | ) |
145 | 145 | ) { |
146 | 146 | if ( |
147 | 147 | $subjectEndValue == null || |
148 | - $this->rangeCheckerHelper->getComparison( $objectEndValue, $subjectEndValue ) < 0 |
|
148 | + $this->rangeCheckerHelper->getComparison($objectEndValue, $subjectEndValue) < 0 |
|
149 | 149 | ) { |
150 | 150 | $earlierEntityId = $objectId; |
151 | 151 | $minEndValue = $objectEndValue; |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $message = null; |
169 | 169 | $status = CheckResult::STATUS_COMPLIANCE; |
170 | 170 | } |
171 | - return new CheckResult( $context, $constraint, [], $status, $message ); |
|
171 | + return new CheckResult($context, $constraint, [], $status, $message); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -178,19 +178,19 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @return DataValue|null |
180 | 180 | */ |
181 | - private function getExtremeValue( $extremePropertyIds, $statements, $startOrEnd ) { |
|
182 | - if ( $startOrEnd !== 'start' && $startOrEnd !== 'end' ) { |
|
183 | - throw new \InvalidArgumentException( '$startOrEnd must be \'start\' or \'end\'.' ); |
|
181 | + private function getExtremeValue($extremePropertyIds, $statements, $startOrEnd) { |
|
182 | + if ($startOrEnd !== 'start' && $startOrEnd !== 'end') { |
|
183 | + throw new \InvalidArgumentException('$startOrEnd must be \'start\' or \'end\'.'); |
|
184 | 184 | } |
185 | 185 | $extremeValue = null; |
186 | - foreach ( $extremePropertyIds as $extremePropertyId ) { |
|
187 | - $statementList = new StatementList( $statements ); |
|
188 | - $extremeStatements = $statementList->getByPropertyId( new PropertyId( $extremePropertyId ) ); |
|
186 | + foreach ($extremePropertyIds as $extremePropertyId) { |
|
187 | + $statementList = new StatementList($statements); |
|
188 | + $extremeStatements = $statementList->getByPropertyId(new PropertyId($extremePropertyId)); |
|
189 | 189 | /** @var Statement $extremeStatement */ |
190 | - foreach ( $extremeStatements as $extremeStatement ) { |
|
191 | - if ( $extremeStatement->getRank() !== Statement::RANK_DEPRECATED ) { |
|
190 | + foreach ($extremeStatements as $extremeStatement) { |
|
191 | + if ($extremeStatement->getRank() !== Statement::RANK_DEPRECATED) { |
|
192 | 192 | $snak = $extremeStatement->getMainSnak(); |
193 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
193 | + if (!$snak instanceof PropertyValueSnak) { |
|
194 | 194 | return null; |
195 | 195 | } else { |
196 | 196 | $comparison = $this->rangeCheckerHelper->getComparison( |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | ); |
200 | 200 | if ( |
201 | 201 | $extremeValue === null || |
202 | - ( $startOrEnd === 'start' && $comparison < 0 ) || |
|
203 | - ( $startOrEnd === 'end' && $comparison > 0 ) |
|
202 | + ($startOrEnd === 'start' && $comparison < 0) || |
|
203 | + ($startOrEnd === 'end' && $comparison > 0) |
|
204 | 204 | ) { |
205 | 205 | $extremeValue = $snak->getDataValue(); |
206 | 206 | } |
@@ -230,17 +230,16 @@ discard block |
||
230 | 230 | DataValue $maxStartValue |
231 | 231 | ) { |
232 | 232 | $messageKey = $earlierEntityId === $subjectId ? |
233 | - 'wbqc-violation-message-contemporary-subject-earlier' : |
|
234 | - 'wbqc-violation-message-contemporary-value-earlier'; |
|
235 | - return ( new ViolationMessage( $messageKey ) ) |
|
236 | - ->withEntityId( $subjectId, Role::SUBJECT ) |
|
237 | - ->withEntityId( $propertyId, Role::PREDICATE ) |
|
238 | - ->withEntityId( $objectId, Role::OBJECT ) |
|
239 | - ->withDataValue( $minEndValue, Role::OBJECT ) |
|
240 | - ->withDataValue( $maxStartValue, Role::OBJECT ); |
|
233 | + 'wbqc-violation-message-contemporary-subject-earlier' : 'wbqc-violation-message-contemporary-value-earlier'; |
|
234 | + return (new ViolationMessage($messageKey)) |
|
235 | + ->withEntityId($subjectId, Role::SUBJECT) |
|
236 | + ->withEntityId($propertyId, Role::PREDICATE) |
|
237 | + ->withEntityId($objectId, Role::OBJECT) |
|
238 | + ->withDataValue($minEndValue, Role::OBJECT) |
|
239 | + ->withDataValue($maxStartValue, Role::OBJECT); |
|
241 | 240 | } |
242 | 241 | |
243 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
242 | + public function checkConstraintParameters(Constraint $constraint) { |
|
244 | 243 | // no parameters |
245 | 244 | return []; |
246 | 245 | } |
@@ -19,27 +19,27 @@ |
||
19 | 19 | const ENTITY_LOOKUP = 'WBQC_EntityLookup'; |
20 | 20 | const PROPERTY_DATA_TYPE_LOOKUP = 'WBQC_PropertyDataTypeLookup'; |
21 | 21 | |
22 | - private static function getService( MediaWikiServices $services = null, $name ) { |
|
23 | - if ( $services === null ) { |
|
22 | + private static function getService(MediaWikiServices $services = null, $name) { |
|
23 | + if ($services === null) { |
|
24 | 24 | $services = MediaWikiServices::getInstance(); |
25 | 25 | } |
26 | - return $services->getService( $name ); |
|
26 | + return $services->getService($name); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @param MediaWikiServices|null $services |
31 | 31 | * @return EntityLookup |
32 | 32 | */ |
33 | - public static function getEntityLookup( MediaWikiServices $services = null ) { |
|
34 | - return self::getService( $services, self::ENTITY_LOOKUP ); |
|
33 | + public static function getEntityLookup(MediaWikiServices $services = null) { |
|
34 | + return self::getService($services, self::ENTITY_LOOKUP); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @param MediaWikiServices|null $services |
39 | 39 | * @return PropertyDataTypeLookup |
40 | 40 | */ |
41 | - public static function getPropertyDataTypeLookup( MediaWikiServices $services = null ) { |
|
42 | - return self::getService( $services, self::PROPERTY_DATA_TYPE_LOOKUP ); |
|
41 | + public static function getPropertyDataTypeLookup(MediaWikiServices $services = null) { |
|
42 | + return self::getService($services, self::PROPERTY_DATA_TYPE_LOOKUP); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | } |
@@ -39,243 +39,243 @@ |
||
39 | 39 | const PROPERTY_SCOPE_CHECKER = 'WBQC_PropertyScopeChecker'; |
40 | 40 | const CONTEMPORARY_CHECKER = 'WBQC_ContemporaryChecker'; |
41 | 41 | |
42 | - private static function getService( MediaWikiServices $services = null, $name ) { |
|
43 | - if ( $services === null ) { |
|
42 | + private static function getService(MediaWikiServices $services = null, $name) { |
|
43 | + if ($services === null) { |
|
44 | 44 | $services = MediaWikiServices::getInstance(); |
45 | 45 | } |
46 | - return $services->getService( $name ); |
|
46 | + return $services->getService($name); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @param MediaWikiServices|null $services |
51 | 51 | * @return ConstraintChecker |
52 | 52 | */ |
53 | - public static function getConflictsWithChecker( MediaWikiServices $services = null ) { |
|
54 | - return self::getService( $services, self::CONFLICTS_WITH_CHECKER ); |
|
53 | + public static function getConflictsWithChecker(MediaWikiServices $services = null) { |
|
54 | + return self::getService($services, self::CONFLICTS_WITH_CHECKER); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @param MediaWikiServices|null $services |
59 | 59 | * @return ConstraintChecker |
60 | 60 | */ |
61 | - public static function getItemChecker( MediaWikiServices $services = null ) { |
|
62 | - return self::getService( $services, self::ITEM_CHECKER ); |
|
61 | + public static function getItemChecker(MediaWikiServices $services = null) { |
|
62 | + return self::getService($services, self::ITEM_CHECKER); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
66 | 66 | * @param MediaWikiServices|null $services |
67 | 67 | * @return ConstraintChecker |
68 | 68 | */ |
69 | - public static function getTargetRequiredClaimChecker( MediaWikiServices $services = null ) { |
|
70 | - return self::getService( $services, self::TARGET_REQUIRED_CLAIM_CHECKER ); |
|
69 | + public static function getTargetRequiredClaimChecker(MediaWikiServices $services = null) { |
|
70 | + return self::getService($services, self::TARGET_REQUIRED_CLAIM_CHECKER); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
74 | 74 | * @param MediaWikiServices|null $services |
75 | 75 | * @return ConstraintChecker |
76 | 76 | */ |
77 | - public static function getSymmetricChecker( MediaWikiServices $services = null ) { |
|
78 | - return self::getService( $services, self::SYMMETRIC_CHECKER ); |
|
77 | + public static function getSymmetricChecker(MediaWikiServices $services = null) { |
|
78 | + return self::getService($services, self::SYMMETRIC_CHECKER); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
82 | 82 | * @param MediaWikiServices|null $services |
83 | 83 | * @return ConstraintChecker |
84 | 84 | */ |
85 | - public static function getInverseChecker( MediaWikiServices $services = null ) { |
|
86 | - return self::getService( $services, self::INVERSE_CHECKER ); |
|
85 | + public static function getInverseChecker(MediaWikiServices $services = null) { |
|
86 | + return self::getService($services, self::INVERSE_CHECKER); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
90 | 90 | * @param MediaWikiServices|null $services |
91 | 91 | * @return ConstraintChecker |
92 | 92 | */ |
93 | - public static function getQualifierChecker( MediaWikiServices $services = null ) { |
|
94 | - return self::getService( $services, self::QUALIFIER_CHECKER ); |
|
93 | + public static function getQualifierChecker(MediaWikiServices $services = null) { |
|
94 | + return self::getService($services, self::QUALIFIER_CHECKER); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
98 | 98 | * @param MediaWikiServices|null $services |
99 | 99 | * @return ConstraintChecker |
100 | 100 | */ |
101 | - public static function getQualifiersChecker( MediaWikiServices $services = null ) { |
|
102 | - return self::getService( $services, self::QUALIFIERS_CHECKER ); |
|
101 | + public static function getQualifiersChecker(MediaWikiServices $services = null) { |
|
102 | + return self::getService($services, self::QUALIFIERS_CHECKER); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | 106 | * @param MediaWikiServices|null $services |
107 | 107 | * @return ConstraintChecker |
108 | 108 | */ |
109 | - public static function getMandatoryQualifiersChecker( MediaWikiServices $services = null ) { |
|
110 | - return self::getService( $services, self::MANDATORY_QUALIFIERS_CHECKER ); |
|
109 | + public static function getMandatoryQualifiersChecker(MediaWikiServices $services = null) { |
|
110 | + return self::getService($services, self::MANDATORY_QUALIFIERS_CHECKER); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
114 | 114 | * @param MediaWikiServices|null $services |
115 | 115 | * @return ConstraintChecker |
116 | 116 | */ |
117 | - public static function getRangeChecker( MediaWikiServices $services = null ) { |
|
118 | - return self::getService( $services, self::RANGE_CHECKER ); |
|
117 | + public static function getRangeChecker(MediaWikiServices $services = null) { |
|
118 | + return self::getService($services, self::RANGE_CHECKER); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | 122 | * @param MediaWikiServices|null $services |
123 | 123 | * @return ConstraintChecker |
124 | 124 | */ |
125 | - public static function getDiffWithinRangeChecker( MediaWikiServices $services = null ) { |
|
126 | - return self::getService( $services, self::DIFF_WITHIN_RANGE_CHECKER ); |
|
125 | + public static function getDiffWithinRangeChecker(MediaWikiServices $services = null) { |
|
126 | + return self::getService($services, self::DIFF_WITHIN_RANGE_CHECKER); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | 130 | * @param MediaWikiServices|null $services |
131 | 131 | * @return ConstraintChecker |
132 | 132 | */ |
133 | - public static function getTypeChecker( MediaWikiServices $services = null ) { |
|
134 | - return self::getService( $services, self::TYPE_CHECKER ); |
|
133 | + public static function getTypeChecker(MediaWikiServices $services = null) { |
|
134 | + return self::getService($services, self::TYPE_CHECKER); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
138 | 138 | * @param MediaWikiServices|null $services |
139 | 139 | * @return ConstraintChecker |
140 | 140 | */ |
141 | - public static function getValueTypeChecker( MediaWikiServices $services = null ) { |
|
142 | - return self::getService( $services, self::VALUE_TYPE_CHECKER ); |
|
141 | + public static function getValueTypeChecker(MediaWikiServices $services = null) { |
|
142 | + return self::getService($services, self::VALUE_TYPE_CHECKER); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @param MediaWikiServices|null $services |
147 | 147 | * @return ConstraintChecker |
148 | 148 | */ |
149 | - public static function getSingleValueChecker( MediaWikiServices $services = null ) { |
|
150 | - return self::getService( $services, self::SINGLE_VALUE_CHECKER ); |
|
149 | + public static function getSingleValueChecker(MediaWikiServices $services = null) { |
|
150 | + return self::getService($services, self::SINGLE_VALUE_CHECKER); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | 154 | * @param MediaWikiServices|null $services |
155 | 155 | * @return ConstraintChecker |
156 | 156 | */ |
157 | - public static function getMultiValueChecker( MediaWikiServices $services = null ) { |
|
158 | - return self::getService( $services, self::MULTI_VALUE_CHECKER ); |
|
157 | + public static function getMultiValueChecker(MediaWikiServices $services = null) { |
|
158 | + return self::getService($services, self::MULTI_VALUE_CHECKER); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
162 | 162 | * @param MediaWikiServices|null $services |
163 | 163 | * @return ConstraintChecker |
164 | 164 | */ |
165 | - public static function getUniqueValueChecker( MediaWikiServices $services = null ) { |
|
166 | - return self::getService( $services, self::UNIQUE_VALUE_CHECKER ); |
|
165 | + public static function getUniqueValueChecker(MediaWikiServices $services = null) { |
|
166 | + return self::getService($services, self::UNIQUE_VALUE_CHECKER); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
170 | 170 | * @param MediaWikiServices|null $services |
171 | 171 | * @return ConstraintChecker |
172 | 172 | */ |
173 | - public static function getFormatChecker( MediaWikiServices $services = null ) { |
|
174 | - return self::getService( $services, self::FORMAT_CHECKER ); |
|
173 | + public static function getFormatChecker(MediaWikiServices $services = null) { |
|
174 | + return self::getService($services, self::FORMAT_CHECKER); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
178 | 178 | * @param MediaWikiServices|null $services |
179 | 179 | * @return ConstraintChecker |
180 | 180 | */ |
181 | - public static function getCommonsLinkChecker( MediaWikiServices $services = null ) { |
|
182 | - return self::getService( $services, self::COMMONS_LINK_CHECKER ); |
|
181 | + public static function getCommonsLinkChecker(MediaWikiServices $services = null) { |
|
182 | + return self::getService($services, self::COMMONS_LINK_CHECKER); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
186 | 186 | * @param MediaWikiServices|null $services |
187 | 187 | * @return ConstraintChecker |
188 | 188 | */ |
189 | - public static function getOneOfChecker( MediaWikiServices $services = null ) { |
|
190 | - return self::getService( $services, self::ONE_OF_CHECKER ); |
|
189 | + public static function getOneOfChecker(MediaWikiServices $services = null) { |
|
190 | + return self::getService($services, self::ONE_OF_CHECKER); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
194 | 194 | * @param MediaWikiServices|null $services |
195 | 195 | * @return ConstraintChecker |
196 | 196 | */ |
197 | - public static function getValueOnlyChecker( MediaWikiServices $services = null ) { |
|
198 | - return self::getService( $services, self::VALUE_ONLY_CHECKER ); |
|
197 | + public static function getValueOnlyChecker(MediaWikiServices $services = null) { |
|
198 | + return self::getService($services, self::VALUE_ONLY_CHECKER); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
202 | 202 | * @param MediaWikiServices|null $services |
203 | 203 | * @return ConstraintChecker |
204 | 204 | */ |
205 | - public static function getReferenceChecker( MediaWikiServices $services = null ) { |
|
206 | - return self::getService( $services, self::REFERENCE_CHECKER ); |
|
205 | + public static function getReferenceChecker(MediaWikiServices $services = null) { |
|
206 | + return self::getService($services, self::REFERENCE_CHECKER); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
210 | 210 | * @param MediaWikiServices|null $services |
211 | 211 | * @return ConstraintChecker |
212 | 212 | */ |
213 | - public static function getNoBoundsChecker( MediaWikiServices $services = null ) { |
|
214 | - return self::getService( $services, self::NO_BOUNDS_CHECKER ); |
|
213 | + public static function getNoBoundsChecker(MediaWikiServices $services = null) { |
|
214 | + return self::getService($services, self::NO_BOUNDS_CHECKER); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
218 | 218 | * @param MediaWikiServices|null $services |
219 | 219 | * @return ConstraintChecker |
220 | 220 | */ |
221 | - public static function getAllowedUnitsChecker( MediaWikiServices $services = null ) { |
|
222 | - return self::getService( $services, self::ALLOWED_UNITS_CHECKER ); |
|
221 | + public static function getAllowedUnitsChecker(MediaWikiServices $services = null) { |
|
222 | + return self::getService($services, self::ALLOWED_UNITS_CHECKER); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
226 | 226 | * @param MediaWikiServices|null $services |
227 | 227 | * @return ConstraintChecker |
228 | 228 | */ |
229 | - public static function getSingleBestValueChecker( MediaWikiServices $services = null ) { |
|
230 | - return self::getService( $services, self::SINGLE_BEST_VALUE_CHECKER ); |
|
229 | + public static function getSingleBestValueChecker(MediaWikiServices $services = null) { |
|
230 | + return self::getService($services, self::SINGLE_BEST_VALUE_CHECKER); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
234 | 234 | * @param MediaWikiServices|null $services |
235 | 235 | * @return ConstraintChecker |
236 | 236 | */ |
237 | - public static function getEntityTypeChecker( MediaWikiServices $services = null ) { |
|
238 | - return self::getService( $services, self::ENTITY_TYPE_CHECKER ); |
|
237 | + public static function getEntityTypeChecker(MediaWikiServices $services = null) { |
|
238 | + return self::getService($services, self::ENTITY_TYPE_CHECKER); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
242 | 242 | * @param MediaWikiServices|null $services |
243 | 243 | * @return ConstraintChecker |
244 | 244 | */ |
245 | - public static function getNoneOfChecker( MediaWikiServices $services = null ) { |
|
246 | - return self::getService( $services, self::NONE_OF_CHECKER ); |
|
245 | + public static function getNoneOfChecker(MediaWikiServices $services = null) { |
|
246 | + return self::getService($services, self::NONE_OF_CHECKER); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
250 | 250 | * @param MediaWikiServices|null $services |
251 | 251 | * @return ConstraintChecker |
252 | 252 | */ |
253 | - public static function getIntegerChecker( MediaWikiServices $services = null ) { |
|
254 | - return self::getService( $services, self::INTEGER_CHECKER ); |
|
253 | + public static function getIntegerChecker(MediaWikiServices $services = null) { |
|
254 | + return self::getService($services, self::INTEGER_CHECKER); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
258 | 258 | * @param MediaWikiServices|null $services |
259 | 259 | * @return ConstraintChecker |
260 | 260 | */ |
261 | - public static function getCitationNeededChecker( MediaWikiServices $services = null ) { |
|
262 | - return self::getService( $services, self::CITATION_NEEDED_CHECKER ); |
|
261 | + public static function getCitationNeededChecker(MediaWikiServices $services = null) { |
|
262 | + return self::getService($services, self::CITATION_NEEDED_CHECKER); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
266 | 266 | * @param MediaWikiServices|null $services |
267 | 267 | * @return ConstraintChecker |
268 | 268 | */ |
269 | - public static function getPropertyScopeChecker( MediaWikiServices $services = null ) { |
|
270 | - return self::getService( $services, self::PROPERTY_SCOPE_CHECKER ); |
|
269 | + public static function getPropertyScopeChecker(MediaWikiServices $services = null) { |
|
270 | + return self::getService($services, self::PROPERTY_SCOPE_CHECKER); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
274 | 274 | * @param MediaWikiServices|null $services |
275 | 275 | * @return ConstraintChecker |
276 | 276 | */ |
277 | - public static function getContemporaryChecker( MediaWikiServices $services = null ) { |
|
278 | - return self::getService( $services, self::CONTEMPORARY_CHECKER ); |
|
277 | + public static function getContemporaryChecker(MediaWikiServices $services = null) { |
|
278 | + return self::getService($services, self::CONTEMPORARY_CHECKER); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | } |