@@ -28,31 +28,31 @@ discard block |
||
28 | 28 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
29 | 29 | |
30 | 30 | return [ |
31 | - ConstraintsServices::EXPIRY_LOCK => function( MediaWikiServices $services ) { |
|
32 | - return new ExpiryLock( ObjectCache::getInstance( CACHE_ANYTHING ) ); |
|
31 | + ConstraintsServices::EXPIRY_LOCK => function(MediaWikiServices $services) { |
|
32 | + return new ExpiryLock(ObjectCache::getInstance(CACHE_ANYTHING)); |
|
33 | 33 | }, |
34 | 34 | |
35 | - ConstraintsServices::LOGGING_HELPER => function( MediaWikiServices $services ) { |
|
35 | + ConstraintsServices::LOGGING_HELPER => function(MediaWikiServices $services) { |
|
36 | 36 | return new LoggingHelper( |
37 | 37 | $services->getStatsdDataFactory(), |
38 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
38 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
39 | 39 | $services->getMainConfig() |
40 | 40 | ); |
41 | 41 | }, |
42 | 42 | |
43 | - ConstraintsServices::CONSTRAINT_REPOSITORY => function( MediaWikiServices $services ) { |
|
43 | + ConstraintsServices::CONSTRAINT_REPOSITORY => function(MediaWikiServices $services) { |
|
44 | 44 | $sourceDefinitions = WikibaseRepo::getDefaultInstance()->getEntitySourceDefinitions(); |
45 | - $propertySource = $sourceDefinitions->getSourceForEntityType( Property::ENTITY_TYPE ); |
|
45 | + $propertySource = $sourceDefinitions->getSourceForEntityType(Property::ENTITY_TYPE); |
|
46 | 46 | |
47 | - return new ConstraintRepository( $services->getDBLoadBalancer(), $propertySource->getDatabaseName() ); |
|
47 | + return new ConstraintRepository($services->getDBLoadBalancer(), $propertySource->getDatabaseName()); |
|
48 | 48 | }, |
49 | 49 | |
50 | - ConstraintsServices::CONSTRAINT_LOOKUP => function( MediaWikiServices $services ) { |
|
51 | - $constraintRepository = ConstraintsServices::getConstraintRepository( $services ); |
|
52 | - return new CachingConstraintLookup( $constraintRepository ); |
|
50 | + ConstraintsServices::CONSTRAINT_LOOKUP => function(MediaWikiServices $services) { |
|
51 | + $constraintRepository = ConstraintsServices::getConstraintRepository($services); |
|
52 | + return new CachingConstraintLookup($constraintRepository); |
|
53 | 53 | }, |
54 | 54 | |
55 | - ConstraintsServices::CHECK_RESULT_SERIALIZER => function( MediaWikiServices $services ) { |
|
55 | + ConstraintsServices::CHECK_RESULT_SERIALIZER => function(MediaWikiServices $services) { |
|
56 | 56 | return new CheckResultSerializer( |
57 | 57 | new ConstraintSerializer( |
58 | 58 | false // constraint parameters are not exposed |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ); |
64 | 64 | }, |
65 | 65 | |
66 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => function( MediaWikiServices $services ) { |
|
66 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => function(MediaWikiServices $services) { |
|
67 | 67 | // TODO in the future, get EntityIdParser and DataValueFactory from $services? |
68 | 68 | $repo = WikibaseRepo::getDefaultInstance(); |
69 | 69 | $entityIdParser = $repo->getEntityIdParser(); |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | ); |
81 | 81 | }, |
82 | 82 | |
83 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function( MediaWikiServices $services ) { |
|
83 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function(MediaWikiServices $services) { |
|
84 | 84 | return new ViolationMessageSerializer(); |
85 | 85 | }, |
86 | 86 | |
87 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function( MediaWikiServices $services ) { |
|
87 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function(MediaWikiServices $services) { |
|
88 | 88 | // TODO in the future, get EntityIdParser and DataValueFactory from $services? |
89 | 89 | $repo = WikibaseRepo::getDefaultInstance(); |
90 | 90 | $entityIdParser = $repo->getEntityIdParser(); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | ); |
97 | 97 | }, |
98 | 98 | |
99 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function( MediaWikiServices $services ) { |
|
99 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) { |
|
100 | 100 | // TODO in the future, get DeserializerFactory and concept base URIs from $services? |
101 | 101 | $repo = WikibaseRepo::getDefaultInstance(); |
102 | 102 | $deserializerFactory = $repo->getBaseDataModelDeserializerFactory(); |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | ); |
110 | 110 | }, |
111 | 111 | |
112 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
112 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
113 | 113 | return new ConnectionCheckerHelper(); |
114 | 114 | }, |
115 | 115 | |
116 | - ConstraintsServices::RANGE_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
116 | + ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
117 | 117 | // TODO in the future, get UnitConverter from $services? |
118 | 118 | $repo = WikibaseRepo::getDefaultInstance(); |
119 | 119 | $unitConverter = $repo->getUnitConverter(); |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | ); |
125 | 125 | }, |
126 | 126 | |
127 | - ConstraintsServices::SPARQL_HELPER => function( MediaWikiServices $services ) { |
|
128 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
129 | - if ( $endpoint === '' ) { |
|
127 | + ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) { |
|
128 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
129 | + if ($endpoint === '') { |
|
130 | 130 | return new DummySparqlHelper(); |
131 | 131 | } |
132 | 132 | |
@@ -142,117 +142,117 @@ discard block |
||
142 | 142 | $entityIdParser, |
143 | 143 | $propertyDataTypeLookup, |
144 | 144 | $services->getMainWANObjectCache(), |
145 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
146 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
145 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
146 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
147 | 147 | $services->getStatsdDataFactory(), |
148 | - ConstraintsServices::getExpiryLock( $services ), |
|
148 | + ConstraintsServices::getExpiryLock($services), |
|
149 | 149 | ConstraintsServices::getLoggingHelper(), |
150 | - wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(), |
|
150 | + wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(), |
|
151 | 151 | $services->getHttpRequestFactory() |
152 | 152 | ); |
153 | 153 | }, |
154 | 154 | |
155 | - ConstraintsServices::TYPE_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
155 | + ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
156 | 156 | return new TypeCheckerHelper( |
157 | - WikibaseServices::getEntityLookup( $services ), |
|
157 | + WikibaseServices::getEntityLookup($services), |
|
158 | 158 | $services->getMainConfig(), |
159 | - ConstraintsServices::getSparqlHelper( $services ), |
|
159 | + ConstraintsServices::getSparqlHelper($services), |
|
160 | 160 | $services->getStatsdDataFactory() |
161 | 161 | ); |
162 | 162 | }, |
163 | 163 | |
164 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function( MediaWikiServices $services ) { |
|
164 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) { |
|
165 | 165 | // TODO in the future, get StatementGuidParser from $services? |
166 | 166 | $repo = WikibaseRepo::getDefaultInstance(); |
167 | 167 | $statementGuidParser = $repo->getStatementGuidParser(); |
168 | 168 | |
169 | 169 | $config = $services->getMainConfig(); |
170 | 170 | $checkerMap = [ |
171 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
172 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
173 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
174 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
175 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
176 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
177 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
178 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
179 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
180 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
181 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
182 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
183 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
184 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
185 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
186 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
187 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
188 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
189 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
190 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
191 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
192 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
193 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
194 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
195 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
196 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
197 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
198 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
199 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
200 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
201 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
202 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
203 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
204 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
205 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
206 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
207 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
208 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
209 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
210 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
211 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
212 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
213 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
214 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
215 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
216 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
217 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
218 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
219 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
220 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
221 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
222 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
223 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
224 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
225 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
226 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
227 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
228 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
171 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
172 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
173 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
174 | + => ConstraintCheckerServices::getItemChecker($services), |
|
175 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
176 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
177 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
178 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
179 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
180 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
181 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
182 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
183 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
184 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
185 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
186 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
187 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
188 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
189 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
190 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
191 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
192 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
193 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
194 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
195 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
196 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
197 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
198 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
199 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
200 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
201 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
202 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
203 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
204 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
205 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
206 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
207 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
208 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
209 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
210 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
211 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
212 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
213 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
214 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
215 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
216 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
217 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
218 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
219 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
220 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
221 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
222 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
223 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
224 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
225 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
226 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
227 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
228 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
229 | 229 | ]; |
230 | 230 | |
231 | 231 | return new DelegatingConstraintChecker( |
232 | - WikibaseServices::getEntityLookup( $services ), |
|
232 | + WikibaseServices::getEntityLookup($services), |
|
233 | 233 | $checkerMap, |
234 | - ConstraintsServices::getConstraintLookup( $services ), |
|
235 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
234 | + ConstraintsServices::getConstraintLookup($services), |
|
235 | + ConstraintsServices::getConstraintParameterParser($services), |
|
236 | 236 | $statementGuidParser, |
237 | - ConstraintsServices::getLoggingHelper( $services ), |
|
238 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
239 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
240 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
237 | + ConstraintsServices::getLoggingHelper($services), |
|
238 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
239 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
240 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
241 | 241 | ); |
242 | 242 | }, |
243 | 243 | |
244 | - ConstraintsServices::RESULTS_SOURCE => function( MediaWikiServices $services ) { |
|
244 | + ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) { |
|
245 | 245 | $config = $services->getMainConfig(); |
246 | 246 | $resultsSource = new CheckingResultsSource( |
247 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
247 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
248 | 248 | ); |
249 | 249 | |
250 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
250 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
251 | 251 | $possiblyStaleConstraintTypes = [ |
252 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
253 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
254 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
255 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
252 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
253 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
254 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
255 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
256 | 256 | ]; |
257 | 257 | // TODO in the future, get EntityIdParser and WikiPageEntityMetaDataAccessor from $services? |
258 | 258 | $repo = WikibaseRepo::getDefaultInstance(); |
@@ -262,14 +262,14 @@ discard block |
||
262 | 262 | $resultsSource = new CachingResultsSource( |
263 | 263 | $resultsSource, |
264 | 264 | ResultsCache::getDefaultInstance(), |
265 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
266 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
265 | + ConstraintsServices::getCheckResultSerializer($services), |
|
266 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
267 | 267 | $wikiPageEntityMetaDataAccessor, |
268 | 268 | $entityIdParser, |
269 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
269 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
270 | 270 | $possiblyStaleConstraintTypes, |
271 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
272 | - ConstraintsServices::getLoggingHelper( $services ) |
|
271 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
272 | + ConstraintsServices::getLoggingHelper($services) |
|
273 | 273 | ); |
274 | 274 | } |
275 | 275 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /** @var string|false */ |
22 | 22 | private $dbName; |
23 | 23 | |
24 | - public function __construct( ILoadBalancer $lb, $dbName ) { |
|
24 | + public function __construct(ILoadBalancer $lb, $dbName) { |
|
25 | 25 | $this->lb = $lb; |
26 | 26 | $this->dbName = $dbName; |
27 | 27 | } |
@@ -31,27 +31,27 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return Constraint[] |
33 | 33 | */ |
34 | - public function queryConstraintsForProperty( PropertyId $propertyId ) { |
|
35 | - $dbr = $this->lb->getConnection( ILoadBalancer::DB_REPLICA, [], $this->dbName ); |
|
34 | + public function queryConstraintsForProperty(PropertyId $propertyId) { |
|
35 | + $dbr = $this->lb->getConnection(ILoadBalancer::DB_REPLICA, [], $this->dbName); |
|
36 | 36 | |
37 | 37 | $results = $dbr->select( |
38 | 38 | 'wbqc_constraints', |
39 | 39 | '*', |
40 | - [ 'pid' => $propertyId->getNumericId() ] |
|
40 | + ['pid' => $propertyId->getNumericId()] |
|
41 | 41 | ); |
42 | 42 | |
43 | - if ( $this->dbName !== false ) { |
|
44 | - $this->lb->reuseConnection( $dbr ); |
|
43 | + if ($this->dbName !== false) { |
|
44 | + $this->lb->reuseConnection($dbr); |
|
45 | 45 | } |
46 | 46 | |
47 | - return $this->convertToConstraints( $results ); |
|
47 | + return $this->convertToConstraints($results); |
|
48 | 48 | } |
49 | 49 | |
50 | - private function encodeConstraintParameters( array $constraintParameters ) { |
|
51 | - $json = json_encode( $constraintParameters, JSON_FORCE_OBJECT ); |
|
50 | + private function encodeConstraintParameters(array $constraintParameters) { |
|
51 | + $json = json_encode($constraintParameters, JSON_FORCE_OBJECT); |
|
52 | 52 | |
53 | - if ( strlen( $json ) > 50000 ) { |
|
54 | - $json = json_encode( [ '@error' => [ 'toolong' => true ] ] ); |
|
53 | + if (strlen($json) > 50000) { |
|
54 | + $json = json_encode(['@error' => ['toolong' => true]]); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | return $json; |
@@ -63,25 +63,25 @@ discard block |
||
63 | 63 | * @throws DBUnexpectedError |
64 | 64 | * @return bool |
65 | 65 | */ |
66 | - public function insertBatch( array $constraints ) { |
|
67 | - if ( $this->dbName !== false ) { |
|
68 | - throw new LogicException( __METHOD__ . ' should not be called when constraints defined in non-local database.' ); |
|
66 | + public function insertBatch(array $constraints) { |
|
67 | + if ($this->dbName !== false) { |
|
68 | + throw new LogicException(__METHOD__.' should not be called when constraints defined in non-local database.'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $accumulator = array_map( |
72 | - function ( Constraint $constraint ) { |
|
72 | + function(Constraint $constraint) { |
|
73 | 73 | return [ |
74 | 74 | 'constraint_guid' => $constraint->getConstraintId(), |
75 | 75 | 'pid' => $constraint->getPropertyId()->getNumericId(), |
76 | 76 | 'constraint_type_qid' => $constraint->getConstraintTypeItemId(), |
77 | - 'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() ) |
|
77 | + 'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters()) |
|
78 | 78 | ]; |
79 | 79 | }, |
80 | 80 | $constraints |
81 | 81 | ); |
82 | 82 | |
83 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_MASTER ); |
|
84 | - return $dbw->insert( 'wbqc_constraints', $accumulator ); |
|
83 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_MASTER); |
|
84 | + return $dbw->insert('wbqc_constraints', $accumulator); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @throws DBUnexpectedError |
93 | 93 | */ |
94 | - public function deleteForProperty( PropertyId $propertyId ) { |
|
95 | - if ( $this->dbName !== false ) { |
|
96 | - throw new LogicException( __METHOD__ . ' should not be called when constraints defined in non-local database.' ); |
|
94 | + public function deleteForProperty(PropertyId $propertyId) { |
|
95 | + if ($this->dbName !== false) { |
|
96 | + throw new LogicException(__METHOD__.' should not be called when constraints defined in non-local database.'); |
|
97 | 97 | } |
98 | 98 | |
99 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_MASTER ); |
|
99 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_MASTER); |
|
100 | 100 | $dbw->delete( |
101 | 101 | 'wbqc_constraints', |
102 | 102 | [ |
@@ -110,26 +110,26 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return Constraint[] |
112 | 112 | */ |
113 | - private function convertToConstraints( IResultWrapper $results ) { |
|
113 | + private function convertToConstraints(IResultWrapper $results) { |
|
114 | 114 | $constraints = []; |
115 | - foreach ( $results as $result ) { |
|
115 | + foreach ($results as $result) { |
|
116 | 116 | $constraintTypeItemId = $result->constraint_type_qid; |
117 | - $constraintParameters = json_decode( $result->constraint_parameters, true ); |
|
117 | + $constraintParameters = json_decode($result->constraint_parameters, true); |
|
118 | 118 | |
119 | - if ( $constraintParameters === null ) { |
|
119 | + if ($constraintParameters === null) { |
|
120 | 120 | // T171295 |
121 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ) |
|
122 | - ->warning( 'Constraint {constraintId} has invalid constraint parameters.', [ |
|
121 | + LoggerFactory::getInstance('WikibaseQualityConstraints') |
|
122 | + ->warning('Constraint {constraintId} has invalid constraint parameters.', [ |
|
123 | 123 | 'method' => __METHOD__, |
124 | 124 | 'constraintId' => $result->constraint_guid, |
125 | 125 | 'constraintParameters' => $result->constraint_parameters, |
126 | - ] ); |
|
127 | - $constraintParameters = [ '@error' => [ /* unknown */ ] ]; |
|
126 | + ]); |
|
127 | + $constraintParameters = ['@error' => [/* unknown */]]; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | $constraints[] = new Constraint( |
131 | 131 | $result->constraint_guid, |
132 | - PropertyId::newFromNumber( $result->pid ), |
|
132 | + PropertyId::newFromNumber($result->pid), |
|
133 | 133 | $constraintTypeItemId, |
134 | 134 | $constraintParameters |
135 | 135 | ); |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | DelegatingConstraintChecker $delegatingConstraintChecker |
76 | 76 | ): self { |
77 | 77 | $repo = WikibaseRepo::getDefaultInstance(); |
78 | - $helperFactory = $repo->getApiHelperFactory( RequestContext::getMain() ); |
|
78 | + $helperFactory = $repo->getApiHelperFactory(RequestContext::getMain()); |
|
79 | 79 | $language = $repo->getUserLanguage(); |
80 | 80 | |
81 | 81 | $entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory(); |
82 | 82 | $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory |
83 | - ->getEntityIdFormatter( $language ); |
|
83 | + ->getEntityIdFormatter($language); |
|
84 | 84 | $formatterOptions = new FormatterOptions(); |
85 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
85 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
86 | 86 | $valueFormatterFactory = $repo->getValueFormatterFactory(); |
87 | 87 | $dataValueFormatter = $valueFormatterFactory |
88 | - ->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
88 | + ->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
89 | 89 | $violationMessageRenderer = new MultilingualTextViolationMessageRenderer( |
90 | 90 | $entityIdHtmlLinkFormatter, |
91 | 91 | $dataValueFormatter, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | StatementGuidParser $statementGuidParser, |
122 | 122 | IBufferingStatsdDataFactory $dataFactory |
123 | 123 | ) { |
124 | - parent::__construct( $main, $name ); |
|
124 | + parent::__construct($main, $name); |
|
125 | 125 | |
126 | - $this->apiErrorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
126 | + $this->apiErrorReporter = $apiHelperFactory->getErrorReporter($this); |
|
127 | 127 | $this->delegatingConstraintChecker = $delegatingConstraintChecker; |
128 | 128 | $this->violationMessageRenderer = $violationMessageRenderer; |
129 | 129 | $this->statementGuidParser = $statementGuidParser; |
@@ -138,39 +138,39 @@ discard block |
||
138 | 138 | $params = $this->extractRequestParams(); |
139 | 139 | $result = $this->getResult(); |
140 | 140 | |
141 | - $propertyIds = $this->parsePropertyIds( $params[self::PARAM_PROPERTY_ID] ); |
|
142 | - $constraintIds = $this->parseConstraintIds( $params[self::PARAM_CONSTRAINT_ID] ); |
|
141 | + $propertyIds = $this->parsePropertyIds($params[self::PARAM_PROPERTY_ID]); |
|
142 | + $constraintIds = $this->parseConstraintIds($params[self::PARAM_CONSTRAINT_ID]); |
|
143 | 143 | |
144 | - $this->checkPropertyIds( $propertyIds, $result ); |
|
145 | - $this->checkConstraintIds( $constraintIds, $result ); |
|
144 | + $this->checkPropertyIds($propertyIds, $result); |
|
145 | + $this->checkConstraintIds($constraintIds, $result); |
|
146 | 146 | |
147 | - $result->addValue( null, 'success', 1 ); |
|
147 | + $result->addValue(null, 'success', 1); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
151 | 151 | * @param array|null $propertyIdSerializations |
152 | 152 | * @return PropertyId[] |
153 | 153 | */ |
154 | - private function parsePropertyIds( $propertyIdSerializations ) { |
|
155 | - if ( $propertyIdSerializations === null ) { |
|
154 | + private function parsePropertyIds($propertyIdSerializations) { |
|
155 | + if ($propertyIdSerializations === null) { |
|
156 | 156 | return []; |
157 | - } elseif ( empty( $propertyIdSerializations ) ) { |
|
157 | + } elseif (empty($propertyIdSerializations)) { |
|
158 | 158 | $this->apiErrorReporter->dieError( |
159 | - 'If ' . self::PARAM_PROPERTY_ID . ' is specified, it must be nonempty.', |
|
159 | + 'If '.self::PARAM_PROPERTY_ID.' is specified, it must be nonempty.', |
|
160 | 160 | 'no-data' |
161 | 161 | ); |
162 | 162 | } |
163 | 163 | |
164 | 164 | return array_map( |
165 | - function( $propertyIdSerialization ) { |
|
165 | + function($propertyIdSerialization) { |
|
166 | 166 | try { |
167 | - return new PropertyId( $propertyIdSerialization ); |
|
168 | - } catch ( InvalidArgumentException $e ) { |
|
167 | + return new PropertyId($propertyIdSerialization); |
|
168 | + } catch (InvalidArgumentException $e) { |
|
169 | 169 | $this->apiErrorReporter->dieError( |
170 | 170 | "Invalid id: $propertyIdSerialization", |
171 | 171 | 'invalid-property-id', |
172 | 172 | 0, // default argument |
173 | - [ self::PARAM_PROPERTY_ID => $propertyIdSerialization ] |
|
173 | + [self::PARAM_PROPERTY_ID => $propertyIdSerialization] |
|
174 | 174 | ); |
175 | 175 | } |
176 | 176 | }, |
@@ -182,35 +182,35 @@ discard block |
||
182 | 182 | * @param array|null $constraintIds |
183 | 183 | * @return string[] |
184 | 184 | */ |
185 | - private function parseConstraintIds( $constraintIds ) { |
|
186 | - if ( $constraintIds === null ) { |
|
185 | + private function parseConstraintIds($constraintIds) { |
|
186 | + if ($constraintIds === null) { |
|
187 | 187 | return []; |
188 | - } elseif ( empty( $constraintIds ) ) { |
|
188 | + } elseif (empty($constraintIds)) { |
|
189 | 189 | $this->apiErrorReporter->dieError( |
190 | - 'If ' . self::PARAM_CONSTRAINT_ID . ' is specified, it must be nonempty.', |
|
190 | + 'If '.self::PARAM_CONSTRAINT_ID.' is specified, it must be nonempty.', |
|
191 | 191 | 'no-data' |
192 | 192 | ); |
193 | 193 | } |
194 | 194 | |
195 | 195 | return array_map( |
196 | - function( $constraintId ) { |
|
196 | + function($constraintId) { |
|
197 | 197 | try { |
198 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
199 | - if ( !$propertyId instanceof PropertyId ) { |
|
198 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
199 | + if (!$propertyId instanceof PropertyId) { |
|
200 | 200 | $this->apiErrorReporter->dieError( |
201 | 201 | "Invalid property ID: {$propertyId->getSerialization()}", |
202 | 202 | 'invalid-property-id', |
203 | 203 | 0, // default argument |
204 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
204 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
205 | 205 | ); |
206 | 206 | } |
207 | 207 | return $constraintId; |
208 | - } catch ( StatementGuidParsingException $e ) { |
|
208 | + } catch (StatementGuidParsingException $e) { |
|
209 | 209 | $this->apiErrorReporter->dieError( |
210 | 210 | "Invalid statement GUID: $constraintId", |
211 | 211 | 'invalid-guid', |
212 | 212 | 0, // default argument |
213 | - [ self::PARAM_CONSTRAINT_ID => $constraintId ] |
|
213 | + [self::PARAM_CONSTRAINT_ID => $constraintId] |
|
214 | 214 | ); |
215 | 215 | } |
216 | 216 | }, |
@@ -222,12 +222,12 @@ discard block |
||
222 | 222 | * @param PropertyId[] $propertyIds |
223 | 223 | * @param ApiResult $result |
224 | 224 | */ |
225 | - private function checkPropertyIds( array $propertyIds, ApiResult $result ) { |
|
226 | - foreach ( $propertyIds as $propertyId ) { |
|
227 | - $result->addArrayType( $this->getResultPathForPropertyId( $propertyId ), 'assoc' ); |
|
225 | + private function checkPropertyIds(array $propertyIds, ApiResult $result) { |
|
226 | + foreach ($propertyIds as $propertyId) { |
|
227 | + $result->addArrayType($this->getResultPathForPropertyId($propertyId), 'assoc'); |
|
228 | 228 | $allConstraintExceptions = $this->delegatingConstraintChecker |
229 | - ->checkConstraintParametersOnPropertyId( $propertyId ); |
|
230 | - foreach ( $allConstraintExceptions as $constraintId => $constraintParameterExceptions ) { |
|
229 | + ->checkConstraintParametersOnPropertyId($propertyId); |
|
230 | + foreach ($allConstraintExceptions as $constraintId => $constraintParameterExceptions) { |
|
231 | 231 | $this->addConstraintParameterExceptionsToResult( |
232 | 232 | $constraintId, |
233 | 233 | $constraintParameterExceptions, |
@@ -241,15 +241,15 @@ discard block |
||
241 | 241 | * @param string[] $constraintIds |
242 | 242 | * @param ApiResult $result |
243 | 243 | */ |
244 | - private function checkConstraintIds( array $constraintIds, ApiResult $result ) { |
|
245 | - foreach ( $constraintIds as $constraintId ) { |
|
246 | - if ( $result->getResultData( $this->getResultPathForConstraintId( $constraintId ) ) ) { |
|
244 | + private function checkConstraintIds(array $constraintIds, ApiResult $result) { |
|
245 | + foreach ($constraintIds as $constraintId) { |
|
246 | + if ($result->getResultData($this->getResultPathForConstraintId($constraintId))) { |
|
247 | 247 | // already checked as part of checkPropertyIds() |
248 | 248 | continue; |
249 | 249 | } |
250 | 250 | $constraintParameterExceptions = $this->delegatingConstraintChecker |
251 | - ->checkConstraintParametersOnConstraintId( $constraintId ); |
|
252 | - $this->addConstraintParameterExceptionsToResult( $constraintId, $constraintParameterExceptions, $result ); |
|
251 | + ->checkConstraintParametersOnConstraintId($constraintId); |
|
252 | + $this->addConstraintParameterExceptionsToResult($constraintId, $constraintParameterExceptions, $result); |
|
253 | 253 | } |
254 | 254 | } |
255 | 255 | |
@@ -257,18 +257,18 @@ discard block |
||
257 | 257 | * @param PropertyId $propertyId |
258 | 258 | * @return string[] |
259 | 259 | */ |
260 | - private function getResultPathForPropertyId( PropertyId $propertyId ) { |
|
261 | - return [ $this->getModuleName(), $propertyId->getSerialization() ]; |
|
260 | + private function getResultPathForPropertyId(PropertyId $propertyId) { |
|
261 | + return [$this->getModuleName(), $propertyId->getSerialization()]; |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
265 | 265 | * @param string $constraintId |
266 | 266 | * @return string[] |
267 | 267 | */ |
268 | - private function getResultPathForConstraintId( $constraintId ) { |
|
269 | - $propertyId = $this->statementGuidParser->parse( $constraintId )->getEntityId(); |
|
268 | + private function getResultPathForConstraintId($constraintId) { |
|
269 | + $propertyId = $this->statementGuidParser->parse($constraintId)->getEntityId(); |
|
270 | 270 | '@phan-var PropertyId $propertyId'; |
271 | - return array_merge( $this->getResultPathForPropertyId( $propertyId ), [ $constraintId ] ); |
|
271 | + return array_merge($this->getResultPathForPropertyId($propertyId), [$constraintId]); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -283,8 +283,8 @@ discard block |
||
283 | 283 | $constraintParameterExceptions, |
284 | 284 | ApiResult $result |
285 | 285 | ) { |
286 | - $path = $this->getResultPathForConstraintId( $constraintId ); |
|
287 | - if ( $constraintParameterExceptions === null ) { |
|
286 | + $path = $this->getResultPathForConstraintId($constraintId); |
|
287 | + if ($constraintParameterExceptions === null) { |
|
288 | 288 | $result->addValue( |
289 | 289 | $path, |
290 | 290 | self::KEY_STATUS, |
@@ -294,12 +294,12 @@ discard block |
||
294 | 294 | $result->addValue( |
295 | 295 | $path, |
296 | 296 | self::KEY_STATUS, |
297 | - empty( $constraintParameterExceptions ) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY |
|
297 | + empty($constraintParameterExceptions) ? self::STATUS_OKAY : self::STATUS_NOT_OKAY |
|
298 | 298 | ); |
299 | 299 | $result->addValue( |
300 | 300 | $path, |
301 | 301 | self::KEY_PROBLEMS, |
302 | - array_map( [ $this, 'formatConstraintParameterException' ], $constraintParameterExceptions ) |
|
302 | + array_map([$this, 'formatConstraintParameterException'], $constraintParameterExceptions) |
|
303 | 303 | ); |
304 | 304 | } |
305 | 305 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | * @param ConstraintParameterException $e |
311 | 311 | * @return string[] |
312 | 312 | */ |
313 | - private function formatConstraintParameterException( ConstraintParameterException $e ) { |
|
313 | + private function formatConstraintParameterException(ConstraintParameterException $e) { |
|
314 | 314 | return [ |
315 | 315 | self::KEY_MESSAGE_HTML => $this->violationMessageRenderer->render( |
316 | 316 | $e->getViolationMessage() |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | return [ |
344 | 344 | 'action=wbcheckconstraintparameters&propertyid=P247' |
345 | 345 | => 'apihelp-wbcheckconstraintparameters-example-propertyid-1', |
346 | - 'action=wbcheckconstraintparameters&' . |
|
347 | - 'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|' . |
|
346 | + 'action=wbcheckconstraintparameters&'. |
|
347 | + 'constraintid=P247$0fe1711e-4c0f-82ce-3af0-830b721d0fba|'. |
|
348 | 348 | 'P225$cdc71e4a-47a0-12c5-dfb3-3f6fc0b6613f' |
349 | 349 | => 'apihelp-wbcheckconstraintparameters-example-constraintid-2', |
350 | 350 | ]; |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | |
84 | 84 | $language = $repo->getUserLanguage(); |
85 | 85 | $formatterOptions = new FormatterOptions(); |
86 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
86 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
87 | 87 | $valueFormatterFactory = $repo->getValueFormatterFactory(); |
88 | - $valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
88 | + $valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
89 | 89 | |
90 | 90 | $entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory(); |
91 | - $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language ); |
|
91 | + $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language); |
|
92 | 92 | $entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory(); |
93 | - $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language ); |
|
93 | + $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language); |
|
94 | 94 | |
95 | 95 | $checkResultsRenderer = new CheckResultsRenderer( |
96 | 96 | $repo->getEntityTitleLookup(), |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $name, |
109 | 109 | $repo->getEntityIdParser(), |
110 | 110 | $repo->getStatementGuidValidator(), |
111 | - $repo->getApiHelperFactory( RequestContext::getMain() ), |
|
111 | + $repo->getApiHelperFactory(RequestContext::getMain()), |
|
112 | 112 | $resultsSource, |
113 | 113 | $checkResultsRenderer, |
114 | 114 | $dataFactory |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | CheckResultsRenderer $checkResultsRenderer, |
136 | 136 | IBufferingStatsdDataFactory $dataFactory |
137 | 137 | ) { |
138 | - parent::__construct( $main, $name ); |
|
138 | + parent::__construct($main, $name); |
|
139 | 139 | $this->entityIdParser = $entityIdParser; |
140 | 140 | $this->statementGuidValidator = $statementGuidValidator; |
141 | - $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); |
|
142 | - $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
141 | + $this->resultBuilder = $apiHelperFactory->getResultBuilder($this); |
|
142 | + $this->errorReporter = $apiHelperFactory->getErrorReporter($this); |
|
143 | 143 | $this->resultsSource = $resultsSource; |
144 | 144 | $this->checkResultsRenderer = $checkResultsRenderer; |
145 | 145 | $this->dataFactory = $dataFactory; |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | |
156 | 156 | $params = $this->extractRequestParams(); |
157 | 157 | |
158 | - $this->validateParameters( $params ); |
|
159 | - $entityIds = $this->parseEntityIds( $params ); |
|
160 | - $claimIds = $this->parseClaimIds( $params ); |
|
158 | + $this->validateParameters($params); |
|
159 | + $entityIds = $this->parseEntityIds($params); |
|
160 | + $claimIds = $this->parseClaimIds($params); |
|
161 | 161 | $constraintIDs = $params[self::PARAM_CONSTRAINT_ID]; |
162 | 162 | $statuses = $params[self::PARAM_STATUS]; |
163 | 163 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | ) |
174 | 174 | )->getArray() |
175 | 175 | ); |
176 | - $this->resultBuilder->markSuccess( 1 ); |
|
176 | + $this->resultBuilder->markSuccess(1); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -181,24 +181,24 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return EntityId[] |
183 | 183 | */ |
184 | - private function parseEntityIds( array $params ) { |
|
184 | + private function parseEntityIds(array $params) { |
|
185 | 185 | $ids = $params[self::PARAM_ID]; |
186 | 186 | |
187 | - if ( $ids === null ) { |
|
187 | + if ($ids === null) { |
|
188 | 188 | return []; |
189 | - } elseif ( $ids === [] ) { |
|
189 | + } elseif ($ids === []) { |
|
190 | 190 | $this->errorReporter->dieError( |
191 | - 'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
191 | + 'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
192 | 192 | } |
193 | 193 | |
194 | - return array_map( function ( $id ) { |
|
194 | + return array_map(function($id) { |
|
195 | 195 | try { |
196 | - return $this->entityIdParser->parse( $id ); |
|
197 | - } catch ( EntityIdParsingException $e ) { |
|
196 | + return $this->entityIdParser->parse($id); |
|
197 | + } catch (EntityIdParsingException $e) { |
|
198 | 198 | $this->errorReporter->dieError( |
199 | - "Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] ); |
|
199 | + "Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] ); |
|
200 | 200 | } |
201 | - }, $ids ); |
|
201 | + }, $ids); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -206,36 +206,36 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return string[] |
208 | 208 | */ |
209 | - private function parseClaimIds( array $params ) { |
|
209 | + private function parseClaimIds(array $params) { |
|
210 | 210 | $ids = $params[self::PARAM_CLAIM_ID]; |
211 | 211 | |
212 | - if ( $ids === null ) { |
|
212 | + if ($ids === null) { |
|
213 | 213 | return []; |
214 | - } elseif ( $ids === [] ) { |
|
214 | + } elseif ($ids === []) { |
|
215 | 215 | $this->errorReporter->dieError( |
216 | - 'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
216 | + 'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
217 | 217 | } |
218 | 218 | |
219 | - foreach ( $ids as $id ) { |
|
220 | - if ( !$this->statementGuidValidator->validate( $id ) ) { |
|
219 | + foreach ($ids as $id) { |
|
220 | + if (!$this->statementGuidValidator->validate($id)) { |
|
221 | 221 | $this->errorReporter->dieError( |
222 | - "Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] ); |
|
222 | + "Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] ); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | 226 | return $ids; |
227 | 227 | } |
228 | 228 | |
229 | - private function validateParameters( array $params ) { |
|
230 | - if ( $params[self::PARAM_CONSTRAINT_ID] !== null |
|
231 | - && empty( $params[self::PARAM_CONSTRAINT_ID] ) |
|
229 | + private function validateParameters(array $params) { |
|
230 | + if ($params[self::PARAM_CONSTRAINT_ID] !== null |
|
231 | + && empty($params[self::PARAM_CONSTRAINT_ID]) |
|
232 | 232 | ) { |
233 | 233 | $paramConstraintId = self::PARAM_CONSTRAINT_ID; |
234 | 234 | $this->errorReporter->dieError( |
235 | 235 | "If $paramConstraintId is specified, it must be nonempty.", 'no-data' ); |
236 | 236 | } |
237 | 237 | // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset |
238 | - if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) { |
|
238 | + if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) { |
|
239 | 239 | $paramId = self::PARAM_ID; |
240 | 240 | $paramClaimId = self::PARAM_CLAIM_ID; |
241 | 241 | $this->errorReporter->dieError( |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | ], |
277 | 277 | ApiBase::PARAM_ISMULTI => true, |
278 | 278 | ApiBase::PARAM_ALL => true, |
279 | - ApiBase::PARAM_DFLT => implode( '|', CachingResultsSource::CACHED_STATUSES ), |
|
279 | + ApiBase::PARAM_DFLT => implode('|', CachingResultsSource::CACHED_STATUSES), |
|
280 | 280 | ApiBase::PARAM_HELP_MSG_PER_VALUE => [], |
281 | 281 | ], |
282 | 282 | ]; |