@@ -31,58 +31,58 @@ discard block |
||
31 | 31 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
32 | 32 | |
33 | 33 | return [ |
34 | - ConstraintsServices::EXPIRY_LOCK => static function ( MediaWikiServices $services ): ExpiryLock { |
|
35 | - return new ExpiryLock( $services->getObjectCacheFactory()->getInstance( CACHE_ANYTHING ) ); |
|
34 | + ConstraintsServices::EXPIRY_LOCK => static function(MediaWikiServices $services): ExpiryLock { |
|
35 | + return new ExpiryLock($services->getObjectCacheFactory()->getInstance(CACHE_ANYTHING)); |
|
36 | 36 | }, |
37 | 37 | |
38 | - ConstraintsServices::LOGGER => static function ( MediaWikiServices $services ): LoggerInterface { |
|
39 | - return LoggerFactory::getInstance( 'WikibaseQualityConstraints' ); |
|
38 | + ConstraintsServices::LOGGER => static function(MediaWikiServices $services): LoggerInterface { |
|
39 | + return LoggerFactory::getInstance('WikibaseQualityConstraints'); |
|
40 | 40 | }, |
41 | 41 | |
42 | - ConstraintsServices::LOGGING_HELPER => static function ( MediaWikiServices $services ): LoggingHelper { |
|
42 | + ConstraintsServices::LOGGING_HELPER => static function(MediaWikiServices $services): LoggingHelper { |
|
43 | 43 | return new LoggingHelper( |
44 | - $services->getStatsFactory()->withComponent( 'WikibaseQualityConstraints' ), |
|
45 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
44 | + $services->getStatsFactory()->withComponent('WikibaseQualityConstraints'), |
|
45 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
46 | 46 | $services->getMainConfig() |
47 | 47 | ); |
48 | 48 | }, |
49 | 49 | |
50 | - ConstraintsServices::CONSTRAINT_STORE => static function ( MediaWikiServices $services ): ConstraintRepositoryStore { |
|
51 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
52 | - $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE ); |
|
53 | - if ( $propertySource === null ) { |
|
54 | - throw new RuntimeException( 'Can\'t get a ConstraintStore for properties not stored in a database.' ); |
|
50 | + ConstraintsServices::CONSTRAINT_STORE => static function(MediaWikiServices $services): ConstraintRepositoryStore { |
|
51 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
52 | + $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE); |
|
53 | + if ($propertySource === null) { |
|
54 | + throw new RuntimeException('Can\'t get a ConstraintStore for properties not stored in a database.'); |
|
55 | 55 | } |
56 | 56 | |
57 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
58 | - if ( $propertySource->getSourceName() !== $localEntitySourceName ) { |
|
59 | - throw new RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' ); |
|
57 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
58 | + if ($propertySource->getSourceName() !== $localEntitySourceName) { |
|
59 | + throw new RuntimeException('Can\'t get a ConstraintStore for a non local entity source.'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $dbName = $propertySource->getDatabaseName(); |
63 | 63 | return new ConstraintRepositoryStore( |
64 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
64 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
65 | 65 | $dbName |
66 | 66 | ); |
67 | 67 | }, |
68 | 68 | |
69 | - ConstraintsServices::CONSTRAINT_LOOKUP => static function ( MediaWikiServices $services ): ConstraintLookup { |
|
70 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
71 | - $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE ); |
|
72 | - if ( $propertySource === null ) { |
|
73 | - throw new RuntimeException( 'Can\'t get a ConstraintStore for properties not stored in a database.' ); |
|
69 | + ConstraintsServices::CONSTRAINT_LOOKUP => static function(MediaWikiServices $services): ConstraintLookup { |
|
70 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
71 | + $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE); |
|
72 | + if ($propertySource === null) { |
|
73 | + throw new RuntimeException('Can\'t get a ConstraintStore for properties not stored in a database.'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $dbName = $propertySource->getDatabaseName(); |
77 | 77 | $rawLookup = new ConstraintRepositoryLookup( |
78 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
78 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
79 | 79 | $dbName, |
80 | - ConstraintsServices::getLogger( $services ) |
|
80 | + ConstraintsServices::getLogger($services) |
|
81 | 81 | ); |
82 | - return new CachingConstraintLookup( $rawLookup ); |
|
82 | + return new CachingConstraintLookup($rawLookup); |
|
83 | 83 | }, |
84 | 84 | |
85 | - ConstraintsServices::CHECK_RESULT_SERIALIZER => static function ( MediaWikiServices $services ): CheckResultSerializer { |
|
85 | + ConstraintsServices::CHECK_RESULT_SERIALIZER => static function(MediaWikiServices $services): CheckResultSerializer { |
|
86 | 86 | return new CheckResultSerializer( |
87 | 87 | new ConstraintSerializer( |
88 | 88 | false // constraint parameters are not exposed |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | ); |
94 | 94 | }, |
95 | 95 | |
96 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function ( MediaWikiServices $services ): CheckResultDeserializer { |
|
97 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
98 | - $dataValueFactory = WikibaseRepo::getDataValueFactory( $services ); |
|
96 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function(MediaWikiServices $services): CheckResultDeserializer { |
|
97 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
98 | + $dataValueFactory = WikibaseRepo::getDataValueFactory($services); |
|
99 | 99 | |
100 | 100 | return new CheckResultDeserializer( |
101 | 101 | new ConstraintDeserializer(), |
@@ -108,17 +108,17 @@ discard block |
||
108 | 108 | ); |
109 | 109 | }, |
110 | 110 | |
111 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function ( |
|
111 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function( |
|
112 | 112 | MediaWikiServices $services |
113 | 113 | ): ViolationMessageSerializer { |
114 | 114 | return new ViolationMessageSerializer(); |
115 | 115 | }, |
116 | 116 | |
117 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function ( |
|
117 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function( |
|
118 | 118 | MediaWikiServices $services |
119 | 119 | ): ViolationMessageDeserializer { |
120 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
121 | - $dataValueFactory = WikibaseRepo::getDataValueFactory( $services ); |
|
120 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
121 | + $dataValueFactory = WikibaseRepo::getDataValueFactory($services); |
|
122 | 122 | |
123 | 123 | return new ViolationMessageDeserializer( |
124 | 124 | $entityIdParser, |
@@ -126,40 +126,40 @@ discard block |
||
126 | 126 | ); |
127 | 127 | }, |
128 | 128 | |
129 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function ( |
|
129 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function( |
|
130 | 130 | MediaWikiServices $services |
131 | 131 | ): ConstraintParameterParser { |
132 | - $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory( $services ); |
|
133 | - $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
132 | + $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory($services); |
|
133 | + $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
134 | 134 | |
135 | 135 | return new ConstraintParameterParser( |
136 | 136 | $services->getMainConfig(), |
137 | 137 | $deserializerFactory, |
138 | - $entitySourceDefinitions->getDatabaseSourceForEntityType( 'item' )->getConceptBaseUri() |
|
138 | + $entitySourceDefinitions->getDatabaseSourceForEntityType('item')->getConceptBaseUri() |
|
139 | 139 | ); |
140 | 140 | }, |
141 | 141 | |
142 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => static function ( MediaWikiServices $services ): ConnectionCheckerHelper { |
|
142 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => static function(MediaWikiServices $services): ConnectionCheckerHelper { |
|
143 | 143 | return new ConnectionCheckerHelper(); |
144 | 144 | }, |
145 | 145 | |
146 | - ConstraintsServices::RANGE_CHECKER_HELPER => static function ( MediaWikiServices $services ): RangeCheckerHelper { |
|
146 | + ConstraintsServices::RANGE_CHECKER_HELPER => static function(MediaWikiServices $services): RangeCheckerHelper { |
|
147 | 147 | return new RangeCheckerHelper( |
148 | 148 | $services->getMainConfig(), |
149 | - WikibaseRepo::getUnitConverter( $services ) |
|
149 | + WikibaseRepo::getUnitConverter($services) |
|
150 | 150 | ); |
151 | 151 | }, |
152 | 152 | |
153 | - ConstraintsServices::SPARQL_HELPER => static function ( MediaWikiServices $services ): SparqlHelper { |
|
154 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
155 | - if ( $endpoint === '' ) { |
|
153 | + ConstraintsServices::SPARQL_HELPER => static function(MediaWikiServices $services): SparqlHelper { |
|
154 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
155 | + if ($endpoint === '') { |
|
156 | 156 | return new DummySparqlHelper(); |
157 | 157 | } |
158 | 158 | |
159 | - $rdfVocabulary = WikibaseRepo::getRdfVocabulary( $services ); |
|
160 | - $valueSnakRdfBuilderFactory = WikibaseRepo::getValueSnakRdfBuilderFactory( $services ); |
|
161 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
162 | - $propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup( $services ); |
|
159 | + $rdfVocabulary = WikibaseRepo::getRdfVocabulary($services); |
|
160 | + $valueSnakRdfBuilderFactory = WikibaseRepo::getValueSnakRdfBuilderFactory($services); |
|
161 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
162 | + $propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup($services); |
|
163 | 163 | |
164 | 164 | return new SparqlHelper( |
165 | 165 | $services->getMainConfig(), |
@@ -168,128 +168,128 @@ discard block |
||
168 | 168 | $entityIdParser, |
169 | 169 | $propertyDataTypeLookup, |
170 | 170 | $services->getMainWANObjectCache(), |
171 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
172 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
173 | - $services->getStatsFactory()->withComponent( 'WikibaseQualityConstraints' ), |
|
174 | - ConstraintsServices::getExpiryLock( $services ), |
|
175 | - ConstraintsServices::getLoggingHelper( $services ), |
|
176 | - WikiMap::getCurrentWikiId() . ' WikibaseQualityConstraints ' . $services->getHttpRequestFactory()->getUserAgent(), |
|
171 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
172 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
173 | + $services->getStatsFactory()->withComponent('WikibaseQualityConstraints'), |
|
174 | + ConstraintsServices::getExpiryLock($services), |
|
175 | + ConstraintsServices::getLoggingHelper($services), |
|
176 | + WikiMap::getCurrentWikiId().' WikibaseQualityConstraints '.$services->getHttpRequestFactory()->getUserAgent(), |
|
177 | 177 | $services->getHttpRequestFactory() |
178 | 178 | ); |
179 | 179 | }, |
180 | 180 | |
181 | - ConstraintsServices::TYPE_CHECKER_HELPER => static function ( MediaWikiServices $services ): TypeCheckerHelper { |
|
181 | + ConstraintsServices::TYPE_CHECKER_HELPER => static function(MediaWikiServices $services): TypeCheckerHelper { |
|
182 | 182 | return new TypeCheckerHelper( |
183 | - WikibaseServices::getEntityLookup( $services ), |
|
183 | + WikibaseServices::getEntityLookup($services), |
|
184 | 184 | $services->getMainConfig(), |
185 | - ConstraintsServices::getSparqlHelper( $services ), |
|
186 | - $services->getStatsFactory()->withComponent( 'WikibaseQualityConstraints' ) |
|
185 | + ConstraintsServices::getSparqlHelper($services), |
|
186 | + $services->getStatsFactory()->withComponent('WikibaseQualityConstraints') |
|
187 | 187 | ); |
188 | 188 | }, |
189 | 189 | |
190 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function ( |
|
190 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function( |
|
191 | 191 | MediaWikiServices $services |
192 | 192 | ): DelegatingConstraintChecker { |
193 | - $statementGuidParser = WikibaseRepo::getStatementGuidParser( $services ); |
|
193 | + $statementGuidParser = WikibaseRepo::getStatementGuidParser($services); |
|
194 | 194 | |
195 | 195 | $config = $services->getMainConfig(); |
196 | 196 | $checkerMap = [ |
197 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
198 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
199 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
200 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
201 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
202 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
203 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
204 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
205 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
206 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
207 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
208 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
209 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
210 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
211 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
212 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
213 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
214 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
215 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
216 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
217 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
218 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
219 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
220 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
221 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
222 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
223 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
224 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
225 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
226 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
227 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
228 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
229 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
230 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
231 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
232 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
233 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
234 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
235 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
236 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
237 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
238 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
239 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
240 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
241 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
242 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
243 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
244 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
245 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
246 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
247 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
248 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
249 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
250 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
251 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
252 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
253 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
254 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
255 | - $config->get( 'WBQualityConstraintsLexemeLanguageConstraintId' ) |
|
256 | - => ConstraintCheckerServices::getLexemeLanguageChecker( $services ), |
|
257 | - $config->get( 'WBQualityConstraintsLabelInLanguageConstraintId' ) |
|
258 | - => ConstraintCheckerServices::getLabelInLanguageChecker( $services ), |
|
197 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
198 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
199 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
200 | + => ConstraintCheckerServices::getItemChecker($services), |
|
201 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
202 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
203 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
204 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
205 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
206 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
207 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
208 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
209 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
210 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
211 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
212 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
213 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
214 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
215 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
216 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
217 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
218 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
219 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
220 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
221 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
222 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
223 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
224 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
225 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
226 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
227 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
228 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
229 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
230 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
231 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
232 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
233 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
234 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
235 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
236 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
237 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
238 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
239 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
240 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
241 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
242 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
243 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
244 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
245 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
246 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
247 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
248 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
249 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
250 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
251 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
252 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
253 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
254 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
255 | + $config->get('WBQualityConstraintsLexemeLanguageConstraintId') |
|
256 | + => ConstraintCheckerServices::getLexemeLanguageChecker($services), |
|
257 | + $config->get('WBQualityConstraintsLabelInLanguageConstraintId') |
|
258 | + => ConstraintCheckerServices::getLabelInLanguageChecker($services), |
|
259 | 259 | ]; |
260 | 260 | |
261 | 261 | return new DelegatingConstraintChecker( |
262 | - WikibaseServices::getEntityLookup( $services ), |
|
262 | + WikibaseServices::getEntityLookup($services), |
|
263 | 263 | $checkerMap, |
264 | - ConstraintsServices::getConstraintLookup( $services ), |
|
265 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
264 | + ConstraintsServices::getConstraintLookup($services), |
|
265 | + ConstraintsServices::getConstraintParameterParser($services), |
|
266 | 266 | $statementGuidParser, |
267 | - ConstraintsServices::getLoggingHelper( $services ), |
|
268 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
269 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
270 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
267 | + ConstraintsServices::getLoggingHelper($services), |
|
268 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
269 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
270 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
271 | 271 | ); |
272 | 272 | }, |
273 | 273 | |
274 | - ConstraintsServices::RESULTS_SOURCE => static function ( MediaWikiServices $services ): ResultsSource { |
|
274 | + ConstraintsServices::RESULTS_SOURCE => static function(MediaWikiServices $services): ResultsSource { |
|
275 | 275 | $config = $services->getMainConfig(); |
276 | 276 | $resultsSource = new CheckingResultsSource( |
277 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
277 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
278 | 278 | ); |
279 | 279 | |
280 | 280 | $cacheCheckConstraintsResults = false; |
281 | 281 | |
282 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
282 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
283 | 283 | $cacheCheckConstraintsResults = true; |
284 | 284 | // check that we can use getLocalRepoWikiPageMetaDataAccessor() |
285 | 285 | // TODO we should always be able to cache constraint check results (T244726) |
286 | - $entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources(); |
|
287 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
286 | + $entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources(); |
|
287 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
288 | 288 | |
289 | - foreach ( $entitySources as $entitySource ) { |
|
290 | - if ( $entitySource->getSourceName() !== $localEntitySourceName ) { |
|
291 | - ConstraintsServices::getLogger( $services )->warning( |
|
292 | - 'Cannot cache constraint check results for non-local source: ' . |
|
289 | + foreach ($entitySources as $entitySource) { |
|
290 | + if ($entitySource->getSourceName() !== $localEntitySourceName) { |
|
291 | + ConstraintsServices::getLogger($services)->warning( |
|
292 | + 'Cannot cache constraint check results for non-local source: '. |
|
293 | 293 | $entitySource->getSourceName() |
294 | 294 | ); |
295 | 295 | $cacheCheckConstraintsResults = false; |
@@ -298,42 +298,42 @@ discard block |
||
298 | 298 | } |
299 | 299 | } |
300 | 300 | |
301 | - if ( $cacheCheckConstraintsResults ) { |
|
301 | + if ($cacheCheckConstraintsResults) { |
|
302 | 302 | $possiblyStaleConstraintTypes = [ |
303 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
304 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
305 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
306 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
303 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
304 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
305 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
306 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
307 | 307 | ]; |
308 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
308 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
309 | 309 | $wikiPageEntityMetaDataAccessor = WikibaseRepo::getLocalRepoWikiPageMetaDataAccessor( |
310 | 310 | $services ); |
311 | 311 | |
312 | 312 | $resultsSource = new CachingResultsSource( |
313 | 313 | $resultsSource, |
314 | 314 | ResultsCache::getDefaultInstance(), |
315 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
316 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
315 | + ConstraintsServices::getCheckResultSerializer($services), |
|
316 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
317 | 317 | $wikiPageEntityMetaDataAccessor, |
318 | 318 | $entityIdParser, |
319 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
319 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
320 | 320 | $possiblyStaleConstraintTypes, |
321 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
322 | - ConstraintsServices::getLoggingHelper( $services ) |
|
321 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
322 | + ConstraintsServices::getLoggingHelper($services) |
|
323 | 323 | ); |
324 | 324 | } |
325 | 325 | |
326 | 326 | return $resultsSource; |
327 | 327 | }, |
328 | 328 | |
329 | - ConstraintsServices::VIOLATION_MESSAGE_RENDERER_FACTORY => static function ( |
|
329 | + ConstraintsServices::VIOLATION_MESSAGE_RENDERER_FACTORY => static function( |
|
330 | 330 | MediaWikiServices $services |
331 | 331 | ): ViolationMessageRendererFactory { |
332 | 332 | return new ViolationMessageRendererFactory( |
333 | 333 | $services->getMainConfig(), |
334 | 334 | $services->getLanguageNameUtils(), |
335 | - WikibaseRepo::getEntityIdHtmlLinkFormatterFactory( $services ), |
|
336 | - WikibaseRepo::getValueFormatterFactory( $services ) |
|
335 | + WikibaseRepo::getEntityIdHtmlLinkFormatterFactory($services), |
|
336 | + WikibaseRepo::getValueFormatterFactory($services) |
|
337 | 337 | ); |
338 | 338 | }, |
339 | 339 | ]; |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | $this->statsFactory = $statsFactory; |
54 | 54 | $this->logger = $logger; |
55 | 55 | $this->constraintCheckDurationLimits = [ |
56 | - 'info' => $config->get( 'WBQualityConstraintsCheckDurationInfoSeconds' ), |
|
57 | - 'warning' => $config->get( 'WBQualityConstraintsCheckDurationWarningSeconds' ), |
|
56 | + 'info' => $config->get('WBQualityConstraintsCheckDurationInfoSeconds'), |
|
57 | + 'warning' => $config->get('WBQualityConstraintsCheckDurationWarningSeconds'), |
|
58 | 58 | ]; |
59 | 59 | $this->constraintCheckOnEntityDurationLimits = [ |
60 | - 'info' => $config->get( 'WBQualityConstraintsCheckOnEntityDurationInfoSeconds' ), |
|
61 | - 'warning' => $config->get( 'WBQualityConstraintsCheckOnEntityDurationWarningSeconds' ), |
|
60 | + 'info' => $config->get('WBQualityConstraintsCheckOnEntityDurationInfoSeconds'), |
|
61 | + 'warning' => $config->get('WBQualityConstraintsCheckOnEntityDurationWarningSeconds'), |
|
62 | 62 | ]; |
63 | 63 | } |
64 | 64 | |
@@ -70,23 +70,23 @@ discard block |
||
70 | 70 | * @param float $durationSeconds |
71 | 71 | * @return array [ $limitSeconds, $logLevel ] |
72 | 72 | */ |
73 | - private function findLimit( $limits, $durationSeconds ) { |
|
73 | + private function findLimit($limits, $durationSeconds) { |
|
74 | 74 | $limitSeconds = null; |
75 | 75 | $logLevel = null; |
76 | 76 | |
77 | - foreach ( $limits as $level => $limit ) { |
|
77 | + foreach ($limits as $level => $limit) { |
|
78 | 78 | if ( |
79 | 79 | // duration exceeds this limit |
80 | 80 | $limit !== null && $durationSeconds > $limit && |
81 | 81 | // this limit is longer than previous longest limit |
82 | - ( $limitSeconds === null || $limit > $limitSeconds ) |
|
82 | + ($limitSeconds === null || $limit > $limitSeconds) |
|
83 | 83 | ) { |
84 | 84 | $limitSeconds = $limit; |
85 | 85 | $logLevel = $level; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | - return [ $limitSeconds, $logLevel ]; |
|
89 | + return [$limitSeconds, $logLevel]; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | $durationSeconds, |
112 | 112 | $method |
113 | 113 | ) { |
114 | - $constraintCheckerClassShortName = substr( strrchr( $constraintCheckerClass, '\\' ), 1 ); |
|
114 | + $constraintCheckerClassShortName = substr(strrchr($constraintCheckerClass, '\\'), 1); |
|
115 | 115 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
116 | 116 | |
117 | 117 | $baseCheckTimingKey = 'wikibase.quality.constraints.check.timing'; |
118 | 118 | $this->statsFactory |
119 | - ->getTiming( 'check_constraint_duration_seconds' ) |
|
120 | - ->copyToStatsdAt( "$baseCheckTimingKey.$constraintTypeItemId-$constraintCheckerClassShortName" ) |
|
121 | - ->observe( $durationSeconds * 1000 ); |
|
119 | + ->getTiming('check_constraint_duration_seconds') |
|
120 | + ->copyToStatsdAt("$baseCheckTimingKey.$constraintTypeItemId-$constraintCheckerClassShortName") |
|
121 | + ->observe($durationSeconds * 1000); |
|
122 | 122 | |
123 | 123 | // find the longest limit (and associated log level) that the duration exceeds |
124 | - [ $limitSeconds, $logLevel ] = $this->findLimit( |
|
124 | + [$limitSeconds, $logLevel] = $this->findLimit( |
|
125 | 125 | $this->constraintCheckDurationLimits, |
126 | 126 | $durationSeconds |
127 | 127 | ); |
128 | - if ( $limitSeconds === null ) { |
|
128 | + if ($limitSeconds === null) { |
|
129 | 129 | return; |
130 | 130 | } |
131 | - if ( $context->getType() !== Context::TYPE_STATEMENT ) { |
|
131 | + if ($context->getType() !== Context::TYPE_STATEMENT) { |
|
132 | 132 | // TODO log less details but still log something |
133 | 133 | return; |
134 | 134 | } |
135 | 135 | |
136 | 136 | $resultMessage = $result->getMessage(); |
137 | - if ( $resultMessage !== null ) { |
|
137 | + if ($resultMessage !== null) { |
|
138 | 138 | $resultMessageKey = $resultMessage->getMessageKey(); |
139 | 139 | } else { |
140 | 140 | $resultMessageKey = null; |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | |
143 | 143 | $this->logger->log( |
144 | 144 | $logLevel, |
145 | - 'Constraint check with {constraintCheckerClassShortName} ' . |
|
146 | - 'took longer than {limitSeconds} second(s) ' . |
|
145 | + 'Constraint check with {constraintCheckerClassShortName} '. |
|
146 | + 'took longer than {limitSeconds} second(s) '. |
|
147 | 147 | '(duration: {durationSeconds} seconds).', |
148 | 148 | [ |
149 | 149 | 'method' => $method, |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'constraintId' => $constraint->getConstraintId(), |
154 | 154 | 'constraintPropertyId' => $constraint->getPropertyId()->getSerialization(), |
155 | 155 | 'constraintTypeItemId' => $constraintTypeItemId, |
156 | - 'constraintParameters' => json_encode( $constraint->getConstraintParameters() ), |
|
156 | + 'constraintParameters' => json_encode($constraint->getConstraintParameters()), |
|
157 | 157 | 'constraintCheckerClass' => $constraintCheckerClass, |
158 | 158 | 'constraintCheckerClassShortName' => $constraintCheckerClassShortName, |
159 | 159 | 'entityId' => $context->getEntity()->getId()->getSerialization(), |
@@ -185,23 +185,23 @@ discard block |
||
185 | 185 | ) { |
186 | 186 | $checkEntityTimingKey = 'wikibase.quality.constraints.check.entity.timing'; |
187 | 187 | $this->statsFactory |
188 | - ->getTiming( 'check_entity_constraint_duration_seconds' ) |
|
189 | - ->copyToStatsdAt( $checkEntityTimingKey ) |
|
190 | - ->observe( $durationSeconds * 1000 ); |
|
188 | + ->getTiming('check_entity_constraint_duration_seconds') |
|
189 | + ->copyToStatsdAt($checkEntityTimingKey) |
|
190 | + ->observe($durationSeconds * 1000); |
|
191 | 191 | |
192 | 192 | // find the longest limit (and associated log level) that the duration exceeds |
193 | - [ $limitSeconds, $logLevel ] = $this->findLimit( |
|
193 | + [$limitSeconds, $logLevel] = $this->findLimit( |
|
194 | 194 | $this->constraintCheckOnEntityDurationLimits, |
195 | 195 | $durationSeconds |
196 | 196 | ); |
197 | - if ( $limitSeconds === null ) { |
|
197 | + if ($limitSeconds === null) { |
|
198 | 198 | return; |
199 | 199 | } |
200 | 200 | |
201 | 201 | $this->logger->log( |
202 | 202 | $logLevel, |
203 | - 'Full constraint check on {entityId} ' . |
|
204 | - 'took longer than {limitSeconds} second(s) ' . |
|
203 | + 'Full constraint check on {entityId} '. |
|
204 | + 'took longer than {limitSeconds} second(s) '. |
|
205 | 205 | '(duration: {durationSeconds} seconds).', |
206 | 206 | [ |
207 | 207 | 'method' => $method, |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @param EntityId $entityId |
221 | 221 | */ |
222 | - public function logCheckConstraintsCacheHit( EntityId $entityId ) { |
|
222 | + public function logCheckConstraintsCacheHit(EntityId $entityId) { |
|
223 | 223 | $cacheEntityHitKey = 'wikibase.quality.constraints.cache.entity.hit'; |
224 | - $metric = $this->statsFactory->getCounter( 'cache_entity_hit_total' ); |
|
224 | + $metric = $this->statsFactory->getCounter('cache_entity_hit_total'); |
|
225 | 225 | $metric->copyToStatsdAt( |
226 | 226 | $cacheEntityHitKey, |
227 | 227 | )->increment(); |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @param EntityId[] $entityIds |
234 | 234 | */ |
235 | - public function logCheckConstraintsCacheMisses( array $entityIds ) { |
|
235 | + public function logCheckConstraintsCacheMisses(array $entityIds) { |
|
236 | 236 | $cacheEntityMissKey = 'wikibase.quality.constraints.cache.entity.miss'; |
237 | - $metric = $this->statsFactory->getCounter( 'cache_entity_miss_total' ); |
|
237 | + $metric = $this->statsFactory->getCounter('cache_entity_miss_total'); |
|
238 | 238 | $metric->copyToStatsdAt( |
239 | 239 | $cacheEntityMissKey, |
240 | - )->incrementBy( count( $entityIds ) ); |
|
240 | + )->incrementBy(count($entityIds)); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -263,17 +263,17 @@ discard block |
||
263 | 263 | * @param EntityId[] $entityIds |
264 | 264 | * @param int $maxRevisionIds |
265 | 265 | */ |
266 | - public function logHugeDependencyMetadata( array $entityIds, $maxRevisionIds ) { |
|
266 | + public function logHugeDependencyMetadata(array $entityIds, $maxRevisionIds) { |
|
267 | 267 | $this->logger->log( |
268 | 268 | 'warning', |
269 | - 'Dependency metadata for constraint check result has huge set of entity IDs ' . |
|
270 | - '(count ' . count( $entityIds ) . ', limit ' . $maxRevisionIds . '); ' . |
|
269 | + 'Dependency metadata for constraint check result has huge set of entity IDs '. |
|
270 | + '(count '.count($entityIds).', limit '.$maxRevisionIds.'); '. |
|
271 | 271 | 'caching disabled for this check result.', |
272 | 272 | [ |
273 | 273 | 'loggingMethod' => __METHOD__, |
274 | 274 | 'entityIds' => json_encode( |
275 | 275 | array_map( |
276 | - static function ( EntityId $entityId ) { |
|
276 | + static function(EntityId $entityId) { |
|
277 | 277 | return $entityId->getSerialization(); |
278 | 278 | }, |
279 | 279 | $entityIds |
@@ -292,17 +292,17 @@ discard block |
||
292 | 292 | 'Sparql API replied with status 429 and a retry-after header. Requesting to retry after {retryAfterTime}', |
293 | 293 | [ |
294 | 294 | 'retryAfterTime' => $retryAfterTime, |
295 | - 'responseHeaders' => json_encode( $request->getResponseHeaders() ), |
|
295 | + 'responseHeaders' => json_encode($request->getResponseHeaders()), |
|
296 | 296 | 'responseContent' => $request->getContent(), |
297 | 297 | ] |
298 | 298 | ); |
299 | 299 | } |
300 | 300 | |
301 | - public function logSparqlHelperTooManyRequestsRetryAfterInvalid( MWHttpRequest $request ) { |
|
301 | + public function logSparqlHelperTooManyRequestsRetryAfterInvalid(MWHttpRequest $request) { |
|
302 | 302 | $this->logger->warning( |
303 | 303 | 'Sparql API replied with status 429 and no valid retry-after header.', |
304 | 304 | [ |
305 | - 'responseHeaders' => json_encode( $request->getResponseHeaders() ), |
|
305 | + 'responseHeaders' => json_encode($request->getResponseHeaders()), |
|
306 | 306 | 'responseContent' => $request->getContent(), |
307 | 307 | ] |
308 | 308 | ); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\Api; |
6 | 6 | |
@@ -84,11 +84,11 @@ discard block |
||
84 | 84 | CheckResultsRendererFactory $checkResultsRendererFactory, |
85 | 85 | StatsFactory $statsFactory |
86 | 86 | ) { |
87 | - parent::__construct( $main, $name ); |
|
87 | + parent::__construct($main, $name); |
|
88 | 88 | $this->entityIdParser = $entityIdParser; |
89 | 89 | $this->statementGuidValidator = $statementGuidValidator; |
90 | - $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); |
|
91 | - $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
90 | + $this->resultBuilder = $apiHelperFactory->getResultBuilder($this); |
|
91 | + $this->errorReporter = $apiHelperFactory->getErrorReporter($this); |
|
92 | 92 | $this->resultsSource = $resultsSource; |
93 | 93 | $this->checkResultsRendererFactory = $checkResultsRendererFactory; |
94 | 94 | $this->statsFactory = $statsFactory; |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function execute() { |
101 | 101 | $baseKey = 'wikibase.quality.constraints.api.checkConstraints.execute'; |
102 | - $metric = $this->statsFactory->getCounter( 'check_constraints_execute_total' ); |
|
103 | - $metric->copyToStatsdAt( $baseKey )->increment(); |
|
102 | + $metric = $this->statsFactory->getCounter('check_constraints_execute_total'); |
|
103 | + $metric->copyToStatsdAt($baseKey)->increment(); |
|
104 | 104 | |
105 | 105 | $params = $this->extractRequestParams(); |
106 | 106 | |
107 | - $this->validateParameters( $params ); |
|
108 | - $entityIds = $this->parseEntityIds( $params ); |
|
109 | - $claimIds = $this->parseClaimIds( $params ); |
|
107 | + $this->validateParameters($params); |
|
108 | + $entityIds = $this->parseEntityIds($params); |
|
109 | + $claimIds = $this->parseClaimIds($params); |
|
110 | 110 | $constraintIDs = $params[self::PARAM_CONSTRAINT_ID]; |
111 | 111 | $statuses = $params[self::PARAM_STATUS]; |
112 | 112 | |
113 | 113 | $checkResultsRenderer = $this->checkResultsRendererFactory |
114 | - ->getCheckResultsRenderer( $this->getLanguage(), $this ); |
|
114 | + ->getCheckResultsRenderer($this->getLanguage(), $this); |
|
115 | 115 | |
116 | 116 | $this->getResult()->addValue( |
117 | 117 | null, |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | ) |
126 | 126 | )->getArray() |
127 | 127 | ); |
128 | - $this->resultBuilder->markSuccess( 1 ); |
|
128 | + $this->resultBuilder->markSuccess(1); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -133,24 +133,24 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return EntityId[] |
135 | 135 | */ |
136 | - private function parseEntityIds( array $params ): array { |
|
136 | + private function parseEntityIds(array $params): array { |
|
137 | 137 | $ids = $params[self::PARAM_ID]; |
138 | 138 | |
139 | - if ( $ids === null ) { |
|
139 | + if ($ids === null) { |
|
140 | 140 | return []; |
141 | - } elseif ( $ids === [] ) { |
|
141 | + } elseif ($ids === []) { |
|
142 | 142 | $this->errorReporter->dieError( |
143 | - 'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
143 | + 'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
144 | 144 | } |
145 | 145 | |
146 | - return array_map( function ( $id ) { |
|
146 | + return array_map(function($id) { |
|
147 | 147 | try { |
148 | - return $this->entityIdParser->parse( $id ); |
|
149 | - } catch ( EntityIdParsingException $e ) { |
|
148 | + return $this->entityIdParser->parse($id); |
|
149 | + } catch (EntityIdParsingException $e) { |
|
150 | 150 | $this->errorReporter->dieError( |
151 | - "Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] ); |
|
151 | + "Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] ); |
|
152 | 152 | } |
153 | - }, $ids ); |
|
153 | + }, $ids); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -158,35 +158,35 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @return string[] |
160 | 160 | */ |
161 | - private function parseClaimIds( array $params ): array { |
|
161 | + private function parseClaimIds(array $params): array { |
|
162 | 162 | $ids = $params[self::PARAM_CLAIM_ID]; |
163 | 163 | |
164 | - if ( $ids === null ) { |
|
164 | + if ($ids === null) { |
|
165 | 165 | return []; |
166 | - } elseif ( $ids === [] ) { |
|
166 | + } elseif ($ids === []) { |
|
167 | 167 | $this->errorReporter->dieError( |
168 | - 'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
168 | + 'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
169 | 169 | } |
170 | 170 | |
171 | - foreach ( $ids as $id ) { |
|
172 | - if ( !$this->statementGuidValidator->validate( $id ) ) { |
|
171 | + foreach ($ids as $id) { |
|
172 | + if (!$this->statementGuidValidator->validate($id)) { |
|
173 | 173 | $this->errorReporter->dieError( |
174 | - "Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] ); |
|
174 | + "Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] ); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | 178 | return $ids; |
179 | 179 | } |
180 | 180 | |
181 | - private function validateParameters( array $params ): void { |
|
182 | - if ( $params[self::PARAM_CONSTRAINT_ID] !== null |
|
183 | - && empty( $params[self::PARAM_CONSTRAINT_ID] ) |
|
181 | + private function validateParameters(array $params): void { |
|
182 | + if ($params[self::PARAM_CONSTRAINT_ID] !== null |
|
183 | + && empty($params[self::PARAM_CONSTRAINT_ID]) |
|
184 | 184 | ) { |
185 | 185 | $paramConstraintId = self::PARAM_CONSTRAINT_ID; |
186 | 186 | $this->errorReporter->dieError( |
187 | 187 | "If $paramConstraintId is specified, it must be nonempty.", 'no-data' ); |
188 | 188 | } |
189 | - if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) { |
|
189 | + if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) { |
|
190 | 190 | $paramId = self::PARAM_ID; |
191 | 191 | $paramClaimId = self::PARAM_CLAIM_ID; |
192 | 192 | $this->errorReporter->dieError( |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | ], |
228 | 228 | ParamValidator::PARAM_ISMULTI => true, |
229 | 229 | ParamValidator::PARAM_ALL => true, |
230 | - ParamValidator::PARAM_DEFAULT => implode( '|', CachingResultsSource::CACHED_STATUSES ), |
|
230 | + ParamValidator::PARAM_DEFAULT => implode('|', CachingResultsSource::CACHED_STATUSES), |
|
231 | 231 | ApiBase::PARAM_HELP_MSG_PER_VALUE => [], |
232 | 232 | ], |
233 | 233 | ]; |