@@ -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, $needsPrefixes = true ) { |
|
50 | - throw new LogicException( 'methods of this class should never be called' ); |
|
49 | + public function runQuery($query, $needsPrefixes = true) { |
|
50 | + throw new LogicException('methods of this class should never be called'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
@@ -27,28 +27,28 @@ discard block |
||
27 | 27 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
28 | 28 | |
29 | 29 | return [ |
30 | - ConstraintsServices::EXPIRY_LOCK => function( MediaWikiServices $services ) { |
|
31 | - return new ExpiryLock( ObjectCache::getInstance( CACHE_ANYTHING ) ); |
|
30 | + ConstraintsServices::EXPIRY_LOCK => function(MediaWikiServices $services) { |
|
31 | + return new ExpiryLock(ObjectCache::getInstance(CACHE_ANYTHING)); |
|
32 | 32 | }, |
33 | 33 | |
34 | - ConstraintsServices::LOGGING_HELPER => function( MediaWikiServices $services ) { |
|
34 | + ConstraintsServices::LOGGING_HELPER => function(MediaWikiServices $services) { |
|
35 | 35 | return new LoggingHelper( |
36 | 36 | $services->getStatsdDataFactory(), |
37 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
37 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
38 | 38 | $services->getMainConfig() |
39 | 39 | ); |
40 | 40 | }, |
41 | 41 | |
42 | - ConstraintsServices::CONSTRAINT_REPOSITORY => function( MediaWikiServices $services ) { |
|
42 | + ConstraintsServices::CONSTRAINT_REPOSITORY => function(MediaWikiServices $services) { |
|
43 | 43 | return new ConstraintRepository(); |
44 | 44 | }, |
45 | 45 | |
46 | - ConstraintsServices::CONSTRAINT_LOOKUP => function( MediaWikiServices $services ) { |
|
47 | - $constraintRepository = ConstraintsServices::getConstraintRepository( $services ); |
|
48 | - return new CachingConstraintLookup( $constraintRepository ); |
|
46 | + ConstraintsServices::CONSTRAINT_LOOKUP => function(MediaWikiServices $services) { |
|
47 | + $constraintRepository = ConstraintsServices::getConstraintRepository($services); |
|
48 | + return new CachingConstraintLookup($constraintRepository); |
|
49 | 49 | }, |
50 | 50 | |
51 | - ConstraintsServices::CHECK_RESULT_SERIALIZER => function( MediaWikiServices $services ) { |
|
51 | + ConstraintsServices::CHECK_RESULT_SERIALIZER => function(MediaWikiServices $services) { |
|
52 | 52 | return new CheckResultSerializer( |
53 | 53 | new ConstraintSerializer( |
54 | 54 | false // constraint parameters are not exposed |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ); |
60 | 60 | }, |
61 | 61 | |
62 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => function( MediaWikiServices $services ) { |
|
62 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => function(MediaWikiServices $services) { |
|
63 | 63 | // TODO in the future, get EntityIdParser and DataValueFactory from $services? |
64 | 64 | $repo = WikibaseRepo::getDefaultInstance(); |
65 | 65 | $entityIdParser = $repo->getEntityIdParser(); |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | ); |
77 | 77 | }, |
78 | 78 | |
79 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function( MediaWikiServices $services ) { |
|
79 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function(MediaWikiServices $services) { |
|
80 | 80 | return new ViolationMessageSerializer(); |
81 | 81 | }, |
82 | 82 | |
83 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function( MediaWikiServices $services ) { |
|
83 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function(MediaWikiServices $services) { |
|
84 | 84 | // TODO in the future, get EntityIdParser and DataValueFactory from $services? |
85 | 85 | $repo = WikibaseRepo::getDefaultInstance(); |
86 | 86 | $entityIdParser = $repo->getEntityIdParser(); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | ); |
93 | 93 | }, |
94 | 94 | |
95 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function( MediaWikiServices $services ) { |
|
95 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) { |
|
96 | 96 | // TODO in the future, get DeserializerFactory and concept base URIs from $services? |
97 | 97 | $repo = WikibaseRepo::getDefaultInstance(); |
98 | 98 | $deserializerFactory = $repo->getBaseDataModelDeserializerFactory(); |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | ); |
106 | 106 | }, |
107 | 107 | |
108 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
108 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
109 | 109 | return new ConnectionCheckerHelper(); |
110 | 110 | }, |
111 | 111 | |
112 | - ConstraintsServices::RANGE_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
112 | + ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
113 | 113 | // TODO in the future, get UnitConverter from $services? |
114 | 114 | $repo = WikibaseRepo::getDefaultInstance(); |
115 | 115 | $unitConverter = $repo->getUnitConverter(); |
@@ -120,9 +120,9 @@ discard block |
||
120 | 120 | ); |
121 | 121 | }, |
122 | 122 | |
123 | - ConstraintsServices::SPARQL_HELPER => function( MediaWikiServices $services ) { |
|
124 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
125 | - if ( $endpoint === '' ) { |
|
123 | + ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) { |
|
124 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
125 | + if ($endpoint === '') { |
|
126 | 126 | return new DummySparqlHelper(); |
127 | 127 | } |
128 | 128 | |
@@ -138,117 +138,117 @@ discard block |
||
138 | 138 | $entityIdParser, |
139 | 139 | $propertyDataTypeLookup, |
140 | 140 | $services->getMainWANObjectCache(), |
141 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
142 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
141 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
142 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
143 | 143 | $services->getStatsdDataFactory(), |
144 | - ConstraintsServices::getExpiryLock( $services ), |
|
144 | + ConstraintsServices::getExpiryLock($services), |
|
145 | 145 | ConstraintsServices::getLoggingHelper(), |
146 | - wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(), |
|
146 | + wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(), |
|
147 | 147 | $services->getHttpRequestFactory() |
148 | 148 | ); |
149 | 149 | }, |
150 | 150 | |
151 | - ConstraintsServices::TYPE_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
151 | + ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
152 | 152 | return new TypeCheckerHelper( |
153 | - WikibaseServices::getEntityLookup( $services ), |
|
153 | + WikibaseServices::getEntityLookup($services), |
|
154 | 154 | $services->getMainConfig(), |
155 | - ConstraintsServices::getSparqlHelper( $services ), |
|
155 | + ConstraintsServices::getSparqlHelper($services), |
|
156 | 156 | $services->getStatsdDataFactory() |
157 | 157 | ); |
158 | 158 | }, |
159 | 159 | |
160 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function( MediaWikiServices $services ) { |
|
160 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) { |
|
161 | 161 | // TODO in the future, get StatementGuidParser from $services? |
162 | 162 | $repo = WikibaseRepo::getDefaultInstance(); |
163 | 163 | $statementGuidParser = $repo->getStatementGuidParser(); |
164 | 164 | |
165 | 165 | $config = $services->getMainConfig(); |
166 | 166 | $checkerMap = [ |
167 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
168 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
169 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
170 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
171 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
172 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
173 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
174 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
175 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
176 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
177 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
178 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
179 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
180 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
181 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
182 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
183 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
184 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
185 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
186 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
187 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
188 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
189 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
190 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
191 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
192 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
193 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
194 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
195 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
196 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
197 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
198 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
199 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
200 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
201 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
202 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
203 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
204 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
205 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
206 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
207 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
208 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
209 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
210 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
211 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
212 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
213 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
214 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
215 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
216 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
217 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
218 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
219 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
220 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
221 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
222 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
223 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
224 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
167 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
168 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
169 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
170 | + => ConstraintCheckerServices::getItemChecker($services), |
|
171 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
172 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
173 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
174 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
175 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
176 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
177 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
178 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
179 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
180 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
181 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
182 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
183 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
184 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
185 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
186 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
187 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
188 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
189 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
190 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
191 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
192 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
193 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
194 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
195 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
196 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
197 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
198 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
199 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
200 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
201 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
202 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
203 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
204 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
205 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
206 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
207 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
208 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
209 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
210 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
211 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
212 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
213 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
214 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
215 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
216 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
217 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
218 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
219 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
220 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
221 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
222 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
223 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
224 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
225 | 225 | ]; |
226 | 226 | |
227 | 227 | return new DelegatingConstraintChecker( |
228 | - WikibaseServices::getEntityLookup( $services ), |
|
228 | + WikibaseServices::getEntityLookup($services), |
|
229 | 229 | $checkerMap, |
230 | - ConstraintsServices::getConstraintLookup( $services ), |
|
231 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
230 | + ConstraintsServices::getConstraintLookup($services), |
|
231 | + ConstraintsServices::getConstraintParameterParser($services), |
|
232 | 232 | $statementGuidParser, |
233 | - ConstraintsServices::getLoggingHelper( $services ), |
|
234 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
235 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
236 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
233 | + ConstraintsServices::getLoggingHelper($services), |
|
234 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
235 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
236 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
237 | 237 | ); |
238 | 238 | }, |
239 | 239 | |
240 | - ConstraintsServices::RESULTS_SOURCE => function( MediaWikiServices $services ) { |
|
240 | + ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) { |
|
241 | 241 | $config = $services->getMainConfig(); |
242 | 242 | $resultsSource = new CheckingResultsSource( |
243 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
243 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
244 | 244 | ); |
245 | 245 | |
246 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
246 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
247 | 247 | $possiblyStaleConstraintTypes = [ |
248 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
249 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
250 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
251 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
248 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
249 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
250 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
251 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
252 | 252 | ]; |
253 | 253 | // TODO in the future, get EntityIdParser and WikiPageEntityMetaDataAccessor from $services? |
254 | 254 | $repo = WikibaseRepo::getDefaultInstance(); |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | $resultsSource = new CachingResultsSource( |
259 | 259 | $resultsSource, |
260 | 260 | ResultsCache::getDefaultInstance(), |
261 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
262 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
261 | + ConstraintsServices::getCheckResultSerializer($services), |
|
262 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
263 | 263 | $wikiPageEntityMetaDataAccessor, |
264 | 264 | $entityIdParser, |
265 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
265 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
266 | 266 | $possiblyStaleConstraintTypes, |
267 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
268 | - ConstraintsServices::getLoggingHelper( $services ) |
|
267 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
268 | + ConstraintsServices::getLoggingHelper($services) |
|
269 | 269 | ); |
270 | 270 | } |
271 | 271 |
@@ -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,21 +89,21 @@ 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 ); |
|
99 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE); |
|
100 | 100 | } |
101 | - if ( $snak->getDataValue()->getType() !== 'wikibase-entityid' ) { |
|
101 | + if ($snak->getDataValue()->getType() !== 'wikibase-entityid') { |
|
102 | 102 | // wrong data type |
103 | - $message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) ) |
|
104 | - ->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM ) |
|
105 | - ->withDataValueType( 'wikibase-entityid' ); |
|
106 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_VIOLATION, $message ); |
|
103 | + $message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type')) |
|
104 | + ->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM) |
|
105 | + ->withDataValueType('wikibase-entityid'); |
|
106 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_VIOLATION, $message); |
|
107 | 107 | } |
108 | 108 | /** @var EntityId $subjectId */ |
109 | 109 | $subjectId = $context->getEntity()->getId(); |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | /** @var Statement[] $subjectStatements */ |
113 | 113 | $subjectStatements = $context->getEntity()->getStatements()->toArray(); |
114 | 114 | /** @var Statement[] $objectStatements */ |
115 | - $objectStatements = $this->entityLookup->getEntity( $objectId )->getStatements()->toArray(); |
|
115 | + $objectStatements = $this->entityLookup->getEntity($objectId)->getStatements()->toArray(); |
|
116 | 116 | /** @var String[] $startPropertyIds */ |
117 | - $startPropertyIds = $this->config->get( self::CONFIG_VARIABLE_START_PROPERTY_IDS ); |
|
117 | + $startPropertyIds = $this->config->get(self::CONFIG_VARIABLE_START_PROPERTY_IDS); |
|
118 | 118 | /** @var String[] $endPropertyIds */ |
119 | - $endPropertyIds = $this->config->get( self::CONFIG_VARIABLE_END_PROPERTY_IDS ); |
|
119 | + $endPropertyIds = $this->config->get(self::CONFIG_VARIABLE_END_PROPERTY_IDS); |
|
120 | 120 | $subjectStartValue = $this->getExtremeValue( |
121 | 121 | $startPropertyIds, |
122 | 122 | $subjectStatements, |
@@ -138,15 +138,15 @@ discard block |
||
138 | 138 | 'end' |
139 | 139 | ); |
140 | 140 | if ( |
141 | - $this->rangeCheckerHelper->getComparison( $subjectStartValue, $subjectEndValue ) <= 0 && |
|
142 | - $this->rangeCheckerHelper->getComparison( $objectStartValue, $objectEndValue ) <= 0 && ( |
|
143 | - $this->rangeCheckerHelper->getComparison( $subjectEndValue, $objectStartValue ) < 0 || |
|
144 | - $this->rangeCheckerHelper->getComparison( $objectEndValue, $subjectStartValue ) < 0 |
|
141 | + $this->rangeCheckerHelper->getComparison($subjectStartValue, $subjectEndValue) <= 0 && |
|
142 | + $this->rangeCheckerHelper->getComparison($objectStartValue, $objectEndValue) <= 0 && ( |
|
143 | + $this->rangeCheckerHelper->getComparison($subjectEndValue, $objectStartValue) < 0 || |
|
144 | + $this->rangeCheckerHelper->getComparison($objectEndValue, $subjectStartValue) < 0 |
|
145 | 145 | ) |
146 | 146 | ) { |
147 | 147 | if ( |
148 | 148 | $subjectEndValue == null || |
149 | - $this->rangeCheckerHelper->getComparison( $objectEndValue, $subjectEndValue ) < 0 |
|
149 | + $this->rangeCheckerHelper->getComparison($objectEndValue, $subjectEndValue) < 0 |
|
150 | 150 | ) { |
151 | 151 | $earlierEntityId = $objectId; |
152 | 152 | $minEndValue = $objectEndValue; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $message = null; |
170 | 170 | $status = CheckResult::STATUS_COMPLIANCE; |
171 | 171 | } |
172 | - return new CheckResult( $context, $constraint, [], $status, $message ); |
|
172 | + return new CheckResult($context, $constraint, [], $status, $message); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -179,19 +179,19 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return DataValue|null |
181 | 181 | */ |
182 | - private function getExtremeValue( $extremePropertyIds, $statements, $startOrEnd ) { |
|
183 | - if ( $startOrEnd !== 'start' && $startOrEnd !== 'end' ) { |
|
184 | - throw new \InvalidArgumentException( '$startOrEnd must be \'start\' or \'end\'.' ); |
|
182 | + private function getExtremeValue($extremePropertyIds, $statements, $startOrEnd) { |
|
183 | + if ($startOrEnd !== 'start' && $startOrEnd !== 'end') { |
|
184 | + throw new \InvalidArgumentException('$startOrEnd must be \'start\' or \'end\'.'); |
|
185 | 185 | } |
186 | 186 | $extremeValue = null; |
187 | - foreach ( $extremePropertyIds as $extremePropertyId ) { |
|
188 | - $statementList = new StatementList( $statements ); |
|
189 | - $extremeStatements = $statementList->getByPropertyId( new PropertyId( $extremePropertyId ) ); |
|
187 | + foreach ($extremePropertyIds as $extremePropertyId) { |
|
188 | + $statementList = new StatementList($statements); |
|
189 | + $extremeStatements = $statementList->getByPropertyId(new PropertyId($extremePropertyId)); |
|
190 | 190 | /** @var Statement $extremeStatement */ |
191 | - foreach ( $extremeStatements as $extremeStatement ) { |
|
192 | - if ( $extremeStatement->getRank() !== Statement::RANK_DEPRECATED ) { |
|
191 | + foreach ($extremeStatements as $extremeStatement) { |
|
192 | + if ($extremeStatement->getRank() !== Statement::RANK_DEPRECATED) { |
|
193 | 193 | $snak = $extremeStatement->getMainSnak(); |
194 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
194 | + if (!$snak instanceof PropertyValueSnak) { |
|
195 | 195 | return null; |
196 | 196 | } else { |
197 | 197 | $comparison = $this->rangeCheckerHelper->getComparison( |
@@ -200,8 +200,8 @@ discard block |
||
200 | 200 | ); |
201 | 201 | if ( |
202 | 202 | $extremeValue === null || |
203 | - ( $startOrEnd === 'start' && $comparison < 0 ) || |
|
204 | - ( $startOrEnd === 'end' && $comparison > 0 ) |
|
203 | + ($startOrEnd === 'start' && $comparison < 0) || |
|
204 | + ($startOrEnd === 'end' && $comparison > 0) |
|
205 | 205 | ) { |
206 | 206 | $extremeValue = $snak->getDataValue(); |
207 | 207 | } |
@@ -231,17 +231,16 @@ discard block |
||
231 | 231 | DataValue $maxStartValue |
232 | 232 | ) { |
233 | 233 | $messageKey = $earlierEntityId === $subjectId ? |
234 | - 'wbqc-violation-message-contemporary-subject-earlier' : |
|
235 | - 'wbqc-violation-message-contemporary-value-earlier'; |
|
236 | - return ( new ViolationMessage( $messageKey ) ) |
|
237 | - ->withEntityId( $subjectId, Role::SUBJECT ) |
|
238 | - ->withEntityId( $propertyId, Role::PREDICATE ) |
|
239 | - ->withEntityId( $objectId, Role::OBJECT ) |
|
240 | - ->withDataValue( $minEndValue, Role::OBJECT ) |
|
241 | - ->withDataValue( $maxStartValue, Role::OBJECT ); |
|
234 | + 'wbqc-violation-message-contemporary-subject-earlier' : '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); |
|
242 | 241 | } |
243 | 242 | |
244 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
243 | + public function checkConstraintParameters(Constraint $constraint) { |
|
245 | 244 | // no parameters |
246 | 245 | return []; |
247 | 246 | } |