@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | * then using the main DBLoadBalancer service may be incorrect. |
25 | 25 | * @param string|false $dbName Database name ($domain for ILoadBalancer methods). |
26 | 26 | */ |
27 | - public function __construct( ILoadBalancer $lb, $dbName ) { |
|
27 | + public function __construct(ILoadBalancer $lb, $dbName) { |
|
28 | 28 | $this->lb = $lb; |
29 | 29 | $this->dbName = $dbName; |
30 | 30 | } |
31 | 31 | |
32 | - private function encodeConstraintParameters( array $constraintParameters ) { |
|
33 | - $json = json_encode( $constraintParameters, JSON_FORCE_OBJECT ); |
|
32 | + private function encodeConstraintParameters(array $constraintParameters) { |
|
33 | + $json = json_encode($constraintParameters, JSON_FORCE_OBJECT); |
|
34 | 34 | |
35 | - if ( strlen( $json ) > 50000 ) { |
|
36 | - $json = json_encode( [ '@error' => [ 'toolong' => true ] ] ); |
|
35 | + if (strlen($json) > 50000) { |
|
36 | + $json = json_encode(['@error' => ['toolong' => true]]); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | return $json; |
@@ -44,28 +44,28 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @throws DBUnexpectedError |
46 | 46 | */ |
47 | - public function insertBatch( array $constraints ) { |
|
48 | - if ( !$constraints ) { |
|
47 | + public function insertBatch(array $constraints) { |
|
48 | + if (!$constraints) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | 52 | $accumulator = array_map( |
53 | - function ( Constraint $constraint ) { |
|
53 | + function(Constraint $constraint) { |
|
54 | 54 | return [ |
55 | 55 | 'constraint_guid' => $constraint->getConstraintId(), |
56 | 56 | 'pid' => $constraint->getPropertyId()->getNumericId(), |
57 | 57 | 'constraint_type_qid' => $constraint->getConstraintTypeItemId(), |
58 | - 'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() ), |
|
58 | + 'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters()), |
|
59 | 59 | ]; |
60 | 60 | }, |
61 | 61 | $constraints |
62 | 62 | ); |
63 | 63 | |
64 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_PRIMARY, [], $this->dbName ); |
|
64 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_PRIMARY, [], $this->dbName); |
|
65 | 65 | $dbw->newInsertQueryBuilder() |
66 | - ->insertInto( 'wbqc_constraints' ) |
|
67 | - ->rows( $accumulator ) |
|
68 | - ->caller( __METHOD__ ) |
|
66 | + ->insertInto('wbqc_constraints') |
|
67 | + ->rows($accumulator) |
|
68 | + ->caller(__METHOD__) |
|
69 | 69 | ->execute(); |
70 | 70 | } |
71 | 71 | |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @throws DBUnexpectedError |
78 | 78 | */ |
79 | - public function deleteForProperty( NumericPropertyId $propertyId ) { |
|
80 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_PRIMARY, [], $this->dbName ); |
|
79 | + public function deleteForProperty(NumericPropertyId $propertyId) { |
|
80 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_PRIMARY, [], $this->dbName); |
|
81 | 81 | $dbw->newDeleteQueryBuilder() |
82 | - ->deleteFrom( 'wbqc_constraints' ) |
|
83 | - ->where( [ |
|
82 | + ->deleteFrom('wbqc_constraints') |
|
83 | + ->where([ |
|
84 | 84 | 'pid' => $propertyId->getNumericId(), |
85 | - ] ) |
|
86 | - ->caller( __METHOD__ ) |
|
85 | + ]) |
|
86 | + ->caller(__METHOD__) |
|
87 | 87 | ->execute(); |
88 | 88 | } |
89 | 89 |
@@ -30,53 +30,53 @@ discard block |
||
30 | 30 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
31 | 31 | |
32 | 32 | return [ |
33 | - ConstraintsServices::EXPIRY_LOCK => static function ( MediaWikiServices $services ): ExpiryLock { |
|
34 | - return new ExpiryLock( $services->getObjectCacheFactory()->getInstance( CACHE_ANYTHING ) ); |
|
33 | + ConstraintsServices::EXPIRY_LOCK => static function(MediaWikiServices $services): ExpiryLock { |
|
34 | + return new ExpiryLock($services->getObjectCacheFactory()->getInstance(CACHE_ANYTHING)); |
|
35 | 35 | }, |
36 | 36 | |
37 | - ConstraintsServices::LOGGING_HELPER => static function ( MediaWikiServices $services ): LoggingHelper { |
|
37 | + ConstraintsServices::LOGGING_HELPER => static function(MediaWikiServices $services): LoggingHelper { |
|
38 | 38 | return new LoggingHelper( |
39 | 39 | $services->getStatsdDataFactory(), |
40 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
40 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
41 | 41 | $services->getMainConfig() |
42 | 42 | ); |
43 | 43 | }, |
44 | 44 | |
45 | - ConstraintsServices::CONSTRAINT_STORE => static function ( MediaWikiServices $services ): ConstraintRepositoryStore { |
|
46 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
47 | - $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE ); |
|
48 | - if ( $propertySource === null ) { |
|
49 | - throw new RuntimeException( 'Can\'t get a ConstraintStore for properties not stored in a database.' ); |
|
45 | + ConstraintsServices::CONSTRAINT_STORE => static function(MediaWikiServices $services): ConstraintRepositoryStore { |
|
46 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
47 | + $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE); |
|
48 | + if ($propertySource === null) { |
|
49 | + throw new RuntimeException('Can\'t get a ConstraintStore for properties not stored in a database.'); |
|
50 | 50 | } |
51 | 51 | |
52 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
53 | - if ( $propertySource->getSourceName() !== $localEntitySourceName ) { |
|
54 | - throw new RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' ); |
|
52 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
53 | + if ($propertySource->getSourceName() !== $localEntitySourceName) { |
|
54 | + throw new RuntimeException('Can\'t get a ConstraintStore for a non local entity source.'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | $dbName = $propertySource->getDatabaseName(); |
58 | 58 | return new ConstraintRepositoryStore( |
59 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
59 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
60 | 60 | $dbName |
61 | 61 | ); |
62 | 62 | }, |
63 | 63 | |
64 | - ConstraintsServices::CONSTRAINT_LOOKUP => static function ( MediaWikiServices $services ): ConstraintLookup { |
|
65 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
66 | - $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE ); |
|
67 | - if ( $propertySource === null ) { |
|
68 | - throw new RuntimeException( 'Can\'t get a ConstraintStore for properties not stored in a database.' ); |
|
64 | + ConstraintsServices::CONSTRAINT_LOOKUP => static function(MediaWikiServices $services): ConstraintLookup { |
|
65 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
66 | + $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE); |
|
67 | + if ($propertySource === null) { |
|
68 | + throw new RuntimeException('Can\'t get a ConstraintStore for properties not stored in a database.'); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $dbName = $propertySource->getDatabaseName(); |
72 | 72 | $rawLookup = new ConstraintRepositoryLookup( |
73 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
73 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
74 | 74 | $dbName |
75 | 75 | ); |
76 | - return new CachingConstraintLookup( $rawLookup ); |
|
76 | + return new CachingConstraintLookup($rawLookup); |
|
77 | 77 | }, |
78 | 78 | |
79 | - ConstraintsServices::CHECK_RESULT_SERIALIZER => static function ( MediaWikiServices $services ): CheckResultSerializer { |
|
79 | + ConstraintsServices::CHECK_RESULT_SERIALIZER => static function(MediaWikiServices $services): CheckResultSerializer { |
|
80 | 80 | return new CheckResultSerializer( |
81 | 81 | new ConstraintSerializer( |
82 | 82 | false // constraint parameters are not exposed |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | ); |
88 | 88 | }, |
89 | 89 | |
90 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function ( MediaWikiServices $services ): CheckResultDeserializer { |
|
91 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
92 | - $dataValueFactory = WikibaseRepo::getDataValueFactory( $services ); |
|
90 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function(MediaWikiServices $services): CheckResultDeserializer { |
|
91 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
92 | + $dataValueFactory = WikibaseRepo::getDataValueFactory($services); |
|
93 | 93 | |
94 | 94 | return new CheckResultDeserializer( |
95 | 95 | new ConstraintDeserializer(), |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | ); |
103 | 103 | }, |
104 | 104 | |
105 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function ( |
|
105 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function( |
|
106 | 106 | MediaWikiServices $services |
107 | 107 | ): ViolationMessageSerializer { |
108 | 108 | return new ViolationMessageSerializer(); |
109 | 109 | }, |
110 | 110 | |
111 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function ( |
|
111 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function( |
|
112 | 112 | MediaWikiServices $services |
113 | 113 | ): ViolationMessageDeserializer { |
114 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
115 | - $dataValueFactory = WikibaseRepo::getDataValueFactory( $services ); |
|
114 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
115 | + $dataValueFactory = WikibaseRepo::getDataValueFactory($services); |
|
116 | 116 | |
117 | 117 | return new ViolationMessageDeserializer( |
118 | 118 | $entityIdParser, |
@@ -120,39 +120,39 @@ discard block |
||
120 | 120 | ); |
121 | 121 | }, |
122 | 122 | |
123 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function ( |
|
123 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function( |
|
124 | 124 | MediaWikiServices $services |
125 | 125 | ): ConstraintParameterParser { |
126 | - $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory( $services ); |
|
127 | - $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
126 | + $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory($services); |
|
127 | + $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
128 | 128 | |
129 | 129 | return new ConstraintParameterParser( |
130 | 130 | $services->getMainConfig(), |
131 | 131 | $deserializerFactory, |
132 | - $entitySourceDefinitions->getDatabaseSourceForEntityType( 'item' )->getConceptBaseUri() |
|
132 | + $entitySourceDefinitions->getDatabaseSourceForEntityType('item')->getConceptBaseUri() |
|
133 | 133 | ); |
134 | 134 | }, |
135 | 135 | |
136 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => static function ( MediaWikiServices $services ): ConnectionCheckerHelper { |
|
136 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => static function(MediaWikiServices $services): ConnectionCheckerHelper { |
|
137 | 137 | return new ConnectionCheckerHelper(); |
138 | 138 | }, |
139 | 139 | |
140 | - ConstraintsServices::RANGE_CHECKER_HELPER => static function ( MediaWikiServices $services ): RangeCheckerHelper { |
|
140 | + ConstraintsServices::RANGE_CHECKER_HELPER => static function(MediaWikiServices $services): RangeCheckerHelper { |
|
141 | 141 | return new RangeCheckerHelper( |
142 | 142 | $services->getMainConfig(), |
143 | - WikibaseRepo::getUnitConverter( $services ) |
|
143 | + WikibaseRepo::getUnitConverter($services) |
|
144 | 144 | ); |
145 | 145 | }, |
146 | 146 | |
147 | - ConstraintsServices::SPARQL_HELPER => static function ( MediaWikiServices $services ): SparqlHelper { |
|
148 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
149 | - if ( $endpoint === '' ) { |
|
147 | + ConstraintsServices::SPARQL_HELPER => static function(MediaWikiServices $services): SparqlHelper { |
|
148 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
149 | + if ($endpoint === '') { |
|
150 | 150 | return new DummySparqlHelper(); |
151 | 151 | } |
152 | 152 | |
153 | - $rdfVocabulary = WikibaseRepo::getRdfVocabulary( $services ); |
|
154 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
155 | - $propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup( $services ); |
|
153 | + $rdfVocabulary = WikibaseRepo::getRdfVocabulary($services); |
|
154 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
155 | + $propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup($services); |
|
156 | 156 | |
157 | 157 | return new SparqlHelper( |
158 | 158 | $services->getMainConfig(), |
@@ -160,128 +160,128 @@ discard block |
||
160 | 160 | $entityIdParser, |
161 | 161 | $propertyDataTypeLookup, |
162 | 162 | $services->getMainWANObjectCache(), |
163 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
164 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
163 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
164 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
165 | 165 | $services->getStatsdDataFactory(), |
166 | - ConstraintsServices::getExpiryLock( $services ), |
|
167 | - ConstraintsServices::getLoggingHelper( $services ), |
|
168 | - WikiMap::getCurrentWikiId() . ' WikibaseQualityConstraints ' . $services->getHttpRequestFactory()->getUserAgent(), |
|
166 | + ConstraintsServices::getExpiryLock($services), |
|
167 | + ConstraintsServices::getLoggingHelper($services), |
|
168 | + WikiMap::getCurrentWikiId().' WikibaseQualityConstraints '.$services->getHttpRequestFactory()->getUserAgent(), |
|
169 | 169 | $services->getHttpRequestFactory() |
170 | 170 | ); |
171 | 171 | }, |
172 | 172 | |
173 | - ConstraintsServices::TYPE_CHECKER_HELPER => static function ( MediaWikiServices $services ): TypeCheckerHelper { |
|
173 | + ConstraintsServices::TYPE_CHECKER_HELPER => static function(MediaWikiServices $services): TypeCheckerHelper { |
|
174 | 174 | return new TypeCheckerHelper( |
175 | - WikibaseServices::getEntityLookup( $services ), |
|
175 | + WikibaseServices::getEntityLookup($services), |
|
176 | 176 | $services->getMainConfig(), |
177 | - ConstraintsServices::getSparqlHelper( $services ), |
|
178 | - $services->getStatsFactory()->withComponent( 'WikibaseQualityConstraints' ) |
|
177 | + ConstraintsServices::getSparqlHelper($services), |
|
178 | + $services->getStatsFactory()->withComponent('WikibaseQualityConstraints') |
|
179 | 179 | ); |
180 | 180 | }, |
181 | 181 | |
182 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function ( |
|
182 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function( |
|
183 | 183 | MediaWikiServices $services |
184 | 184 | ): DelegatingConstraintChecker { |
185 | - $statementGuidParser = WikibaseRepo::getStatementGuidParser( $services ); |
|
185 | + $statementGuidParser = WikibaseRepo::getStatementGuidParser($services); |
|
186 | 186 | |
187 | 187 | $config = $services->getMainConfig(); |
188 | 188 | $checkerMap = [ |
189 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
190 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
191 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
192 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
193 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
194 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
195 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
196 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
197 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
198 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
199 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
200 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
201 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
202 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
203 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
204 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
205 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
206 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
207 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
208 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
209 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
210 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
211 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
212 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
213 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
214 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
215 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
216 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
217 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
218 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
219 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
220 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
221 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
222 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
223 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
224 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
225 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
226 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
227 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
228 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
229 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
230 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
231 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
232 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
233 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
234 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
235 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
236 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
237 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
238 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
239 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
240 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
241 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
242 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
243 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
244 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
245 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
246 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
247 | - $config->get( 'WBQualityConstraintsLexemeLanguageConstraintId' ) |
|
248 | - => ConstraintCheckerServices::getLexemeLanguageChecker( $services ), |
|
249 | - $config->get( 'WBQualityConstraintsLabelInLanguageConstraintId' ) |
|
250 | - => ConstraintCheckerServices::getLabelInLanguageChecker( $services ), |
|
189 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
190 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
191 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
192 | + => ConstraintCheckerServices::getItemChecker($services), |
|
193 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
194 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
195 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
196 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
197 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
198 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
199 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
200 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
201 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
202 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
203 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
204 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
205 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
206 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
207 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
208 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
209 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
210 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
211 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
212 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
213 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
214 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
215 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
216 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
217 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
218 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
219 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
220 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
221 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
222 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
223 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
224 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
225 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
226 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
227 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
228 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
229 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
230 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
231 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
232 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
233 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
234 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
235 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
236 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
237 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
238 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
239 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
240 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
241 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
242 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
243 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
244 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
245 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
246 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
247 | + $config->get('WBQualityConstraintsLexemeLanguageConstraintId') |
|
248 | + => ConstraintCheckerServices::getLexemeLanguageChecker($services), |
|
249 | + $config->get('WBQualityConstraintsLabelInLanguageConstraintId') |
|
250 | + => ConstraintCheckerServices::getLabelInLanguageChecker($services), |
|
251 | 251 | ]; |
252 | 252 | |
253 | 253 | return new DelegatingConstraintChecker( |
254 | - WikibaseServices::getEntityLookup( $services ), |
|
254 | + WikibaseServices::getEntityLookup($services), |
|
255 | 255 | $checkerMap, |
256 | - ConstraintsServices::getConstraintLookup( $services ), |
|
257 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
256 | + ConstraintsServices::getConstraintLookup($services), |
|
257 | + ConstraintsServices::getConstraintParameterParser($services), |
|
258 | 258 | $statementGuidParser, |
259 | - ConstraintsServices::getLoggingHelper( $services ), |
|
260 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
261 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
262 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
259 | + ConstraintsServices::getLoggingHelper($services), |
|
260 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
261 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
262 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
263 | 263 | ); |
264 | 264 | }, |
265 | 265 | |
266 | - ConstraintsServices::RESULTS_SOURCE => static function ( MediaWikiServices $services ): ResultsSource { |
|
266 | + ConstraintsServices::RESULTS_SOURCE => static function(MediaWikiServices $services): ResultsSource { |
|
267 | 267 | $config = $services->getMainConfig(); |
268 | 268 | $resultsSource = new CheckingResultsSource( |
269 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
269 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
270 | 270 | ); |
271 | 271 | |
272 | 272 | $cacheCheckConstraintsResults = false; |
273 | 273 | |
274 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
274 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
275 | 275 | $cacheCheckConstraintsResults = true; |
276 | 276 | // check that we can use getLocalRepoWikiPageMetaDataAccessor() |
277 | 277 | // TODO we should always be able to cache constraint check results (T244726) |
278 | - $entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources(); |
|
279 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
278 | + $entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources(); |
|
279 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
280 | 280 | |
281 | - foreach ( $entitySources as $entitySource ) { |
|
282 | - if ( $entitySource->getSourceName() !== $localEntitySourceName ) { |
|
283 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning( |
|
284 | - 'Cannot cache constraint check results for non-local source: ' . |
|
281 | + foreach ($entitySources as $entitySource) { |
|
282 | + if ($entitySource->getSourceName() !== $localEntitySourceName) { |
|
283 | + LoggerFactory::getInstance('WikibaseQualityConstraints')->warning( |
|
284 | + 'Cannot cache constraint check results for non-local source: '. |
|
285 | 285 | $entitySource->getSourceName() |
286 | 286 | ); |
287 | 287 | $cacheCheckConstraintsResults = false; |
@@ -290,42 +290,42 @@ discard block |
||
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | - if ( $cacheCheckConstraintsResults ) { |
|
293 | + if ($cacheCheckConstraintsResults) { |
|
294 | 294 | $possiblyStaleConstraintTypes = [ |
295 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
296 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
297 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
298 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
295 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
296 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
297 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
298 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
299 | 299 | ]; |
300 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
300 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
301 | 301 | $wikiPageEntityMetaDataAccessor = WikibaseRepo::getLocalRepoWikiPageMetaDataAccessor( |
302 | 302 | $services ); |
303 | 303 | |
304 | 304 | $resultsSource = new CachingResultsSource( |
305 | 305 | $resultsSource, |
306 | 306 | ResultsCache::getDefaultInstance(), |
307 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
308 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
307 | + ConstraintsServices::getCheckResultSerializer($services), |
|
308 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
309 | 309 | $wikiPageEntityMetaDataAccessor, |
310 | 310 | $entityIdParser, |
311 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
311 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
312 | 312 | $possiblyStaleConstraintTypes, |
313 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
314 | - ConstraintsServices::getLoggingHelper( $services ) |
|
313 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
314 | + ConstraintsServices::getLoggingHelper($services) |
|
315 | 315 | ); |
316 | 316 | } |
317 | 317 | |
318 | 318 | return $resultsSource; |
319 | 319 | }, |
320 | 320 | |
321 | - ConstraintsServices::VIOLATION_MESSAGE_RENDERER_FACTORY => static function ( |
|
321 | + ConstraintsServices::VIOLATION_MESSAGE_RENDERER_FACTORY => static function( |
|
322 | 322 | MediaWikiServices $services |
323 | 323 | ): ViolationMessageRendererFactory { |
324 | 324 | return new ViolationMessageRendererFactory( |
325 | 325 | $services->getMainConfig(), |
326 | 326 | $services->getLanguageNameUtils(), |
327 | - WikibaseRepo::getEntityIdHtmlLinkFormatterFactory( $services ), |
|
328 | - WikibaseRepo::getValueFormatterFactory( $services ) |
|
327 | + WikibaseRepo::getEntityIdHtmlLinkFormatterFactory($services), |
|
328 | + WikibaseRepo::getValueFormatterFactory($services) |
|
329 | 329 | ); |
330 | 330 | }, |
331 | 331 | ]; |
@@ -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\ConstraintCheck\Checker; |
6 | 6 | |
@@ -64,18 +64,18 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs |
66 | 66 | */ |
67 | - public function checkConstraint( Context $context, Constraint $constraint ): CheckResult { |
|
68 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
69 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED ); |
|
67 | + public function checkConstraint(Context $context, Constraint $constraint): CheckResult { |
|
68 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
69 | + return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED); |
|
70 | 70 | } |
71 | 71 | |
72 | - if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) { |
|
72 | + if (!($this->sparqlHelper instanceof DummySparqlHelper)) { |
|
73 | 73 | |
74 | 74 | $separators = $this->constraintParameterParser->parseSeparatorsParameter( |
75 | 75 | $constraint->getConstraintParameters() |
76 | 76 | ); |
77 | 77 | |
78 | - if ( $context->getType() === 'statement' ) { |
|
78 | + if ($context->getType() === 'statement') { |
|
79 | 79 | $statement = $context->getSnakStatement(); |
80 | 80 | '@phan-var Statement $statement'; |
81 | 81 | $result = $this->sparqlHelper->findEntitiesWithSameStatement( |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | ); |
85 | 85 | } else { |
86 | 86 | $snak = $context->getSnak(); |
87 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
87 | + if (!$snak instanceof PropertyValueSnak) { |
|
88 | 88 | // nothing to check |
89 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE ); |
|
89 | + return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE); |
|
90 | 90 | } |
91 | 91 | $result = $this->sparqlHelper->findEntitiesWithSameQualifierOrReference( |
92 | 92 | $context->getEntity()->getId(), |
@@ -99,31 +99,31 @@ discard block |
||
99 | 99 | $otherEntities = $result->getArray(); |
100 | 100 | $metadata = $result->getMetadata(); |
101 | 101 | |
102 | - if ( $otherEntities === [] ) { |
|
102 | + if ($otherEntities === []) { |
|
103 | 103 | $status = CheckResult::STATUS_COMPLIANCE; |
104 | 104 | $message = null; |
105 | 105 | } else { |
106 | 106 | $status = CheckResult::STATUS_VIOLATION; |
107 | - $message = ( new ViolationMessage( 'wbqc-violation-message-unique-value' ) ) |
|
108 | - ->withEntityIdList( $otherEntities, Role::SUBJECT ); |
|
107 | + $message = (new ViolationMessage('wbqc-violation-message-unique-value')) |
|
108 | + ->withEntityIdList($otherEntities, Role::SUBJECT); |
|
109 | 109 | } |
110 | 110 | } else { |
111 | 111 | $status = CheckResult::STATUS_TODO; |
112 | - $message = ( new ViolationMessage( 'wbqc-violation-message-not-yet-implemented' ) ) |
|
113 | - ->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM ); |
|
112 | + $message = (new ViolationMessage('wbqc-violation-message-not-yet-implemented')) |
|
113 | + ->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM); |
|
114 | 114 | $metadata = Metadata::blank(); |
115 | 115 | } |
116 | 116 | |
117 | - return ( new CheckResult( $context, $constraint, $status, $message ) ) |
|
118 | - ->withMetadata( $metadata ); |
|
117 | + return (new CheckResult($context, $constraint, $status, $message)) |
|
118 | + ->withMetadata($metadata); |
|
119 | 119 | } |
120 | 120 | |
121 | - public function checkConstraintParameters( Constraint $constraint ): array { |
|
121 | + public function checkConstraintParameters(Constraint $constraint): array { |
|
122 | 122 | $constraintParameters = $constraint->getConstraintParameters(); |
123 | 123 | $exceptions = []; |
124 | 124 | try { |
125 | - $this->constraintParameterParser->parseSeparatorsParameter( $constraintParameters ); |
|
126 | - } catch ( ConstraintParameterException $e ) { |
|
125 | + $this->constraintParameterParser->parseSeparatorsParameter($constraintParameters); |
|
126 | + } catch (ConstraintParameterException $e) { |
|
127 | 127 | $exceptions[] = $e; |
128 | 128 | } |
129 | 129 | return $exceptions; |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Cache; |
6 | 6 |
@@ -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\ConstraintCheck\Helper; |
6 | 6 | |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | // no parent::__construct() call |
29 | 29 | } |
30 | 30 | |
31 | - public function hasType( string $id, array $classes ): CachedBool { |
|
32 | - throw new LogicException( 'methods of this class should never be called' ); |
|
31 | + public function hasType(string $id, array $classes): CachedBool { |
|
32 | + throw new LogicException('methods of this class should never be called'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function findEntitiesWithSameStatement( |
36 | 36 | Statement $statement, |
37 | 37 | array $separators |
38 | 38 | ): CachedEntityIds { |
39 | - throw new LogicException( 'methods of this class should never be called' ); |
|
39 | + throw new LogicException('methods of this class should never be called'); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | public function findEntitiesWithSameQualifierOrReference( |
@@ -45,15 +45,15 @@ discard block |
||
45 | 45 | string $type, |
46 | 46 | bool $ignoreDeprecatedStatements |
47 | 47 | ): CachedEntityIds { |
48 | - throw new LogicException( 'methods of this class should never be called' ); |
|
48 | + throw new LogicException('methods of this class should never be called'); |
|
49 | 49 | } |
50 | 50 | |
51 | - public function matchesRegularExpression( string $text, string $regex ): bool { |
|
52 | - throw new LogicException( 'methods of this class should never be called' ); |
|
51 | + public function matchesRegularExpression(string $text, string $regex): bool { |
|
52 | + throw new LogicException('methods of this class should never be called'); |
|
53 | 53 | } |
54 | 54 | |
55 | - public function runQuery( string $query, string $endpoint, bool $needsPrefixes = true ): CachedQueryResults { |
|
56 | - throw new LogicException( 'methods of this class should never be called' ); |
|
55 | + public function runQuery(string $query, string $endpoint, bool $needsPrefixes = true): CachedQueryResults { |
|
56 | + throw new LogicException('methods of this class should never be called'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | } |
@@ -15,12 +15,12 @@ |
||
15 | 15 | /** |
16 | 16 | * @param DatabaseUpdater $updater |
17 | 17 | */ |
18 | - public function onLoadExtensionSchemaUpdates( $updater ) { |
|
19 | - $dir = dirname( __DIR__ ) . '/sql/'; |
|
18 | + public function onLoadExtensionSchemaUpdates($updater) { |
|
19 | + $dir = dirname(__DIR__).'/sql/'; |
|
20 | 20 | |
21 | 21 | $updater->addExtensionTable( |
22 | 22 | 'wbqc_constraints', |
23 | - $dir . "/{$updater->getDB()->getType()}/tables-generated.sql" |
|
23 | + $dir."/{$updater->getDB()->getType()}/tables-generated.sql" |
|
24 | 24 | ); |
25 | 25 | } |
26 | 26 |
@@ -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\ConstraintCheck\Checker; |
6 | 6 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | private ConstraintParameterParser $constraintParameterParser; |
24 | 24 | |
25 | - public function __construct( ConstraintParameterParser $constraintParameterParser ) { |
|
25 | + public function __construct(ConstraintParameterParser $constraintParameterParser) { |
|
26 | 26 | $this->constraintParameterParser = $constraintParameterParser; |
27 | 27 | } |
28 | 28 | |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @throws ConstraintParameterException |
66 | 66 | */ |
67 | - public function checkConstraint( Context $context, Constraint $constraint ): CheckResult { |
|
68 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
69 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED ); |
|
67 | + public function checkConstraint(Context $context, Constraint $constraint): CheckResult { |
|
68 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
69 | + return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $constraintParameters = $constraint->getConstraintParameters(); |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | ); |
78 | 78 | |
79 | 79 | $status = CheckResult::STATUS_VIOLATION; |
80 | - $message = ( new ViolationMessage( 'wbqc-violation-message-label-lacking' ) ) |
|
81 | - ->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) |
|
82 | - ->withLanguages( $languages ); |
|
80 | + $message = (new ViolationMessage('wbqc-violation-message-label-lacking')) |
|
81 | + ->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE) |
|
82 | + ->withLanguages($languages); |
|
83 | 83 | |
84 | 84 | /** @var LabelsProvider $entity */ |
85 | 85 | $entity = $context->getEntity(); |
86 | 86 | '@phan-var LabelsProvider $entity'; |
87 | 87 | $labels = $entity->getLabels(); |
88 | 88 | |
89 | - if ( $labels->hasTermForLanguage( 'mul' ) ) { |
|
89 | + if ($labels->hasTermForLanguage('mul')) { |
|
90 | 90 | $message = null; |
91 | 91 | $status = CheckResult::STATUS_COMPLIANCE; |
92 | 92 | } else { |
93 | - foreach ( $languages as $language ) { |
|
94 | - if ( $labels->hasTermForLanguage( $language ) ) { |
|
93 | + foreach ($languages as $language) { |
|
94 | + if ($labels->hasTermForLanguage($language)) { |
|
95 | 95 | $message = null; |
96 | 96 | $status = CheckResult::STATUS_COMPLIANCE; |
97 | 97 | break; |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - return new CheckResult( $context, $constraint, $status, $message ); |
|
102 | + return new CheckResult($context, $constraint, $status, $message); |
|
103 | 103 | } |
104 | 104 | |
105 | - public function checkConstraintParameters( Constraint $constraint ): array { |
|
105 | + public function checkConstraintParameters(Constraint $constraint): array { |
|
106 | 106 | $constraintParameters = $constraint->getConstraintParameters(); |
107 | 107 | $exceptions = []; |
108 | 108 | try { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $constraintParameters, |
111 | 111 | $constraint->getConstraintTypeItemId() |
112 | 112 | ); |
113 | - } catch ( ConstraintParameterException $e ) { |
|
113 | + } catch (ConstraintParameterException $e) { |
|
114 | 114 | $exceptions[] = $e; |
115 | 115 | } |
116 | 116 | return $exceptions; |
@@ -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\Html; |
6 | 6 | |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @throws InvalidArgumentException |
35 | 35 | */ |
36 | - public function __construct( $content, bool $isSortable = false ) { |
|
37 | - Assert::parameterType( [ 'string', HtmlArmor::class ], $content, '$content' ); |
|
36 | + public function __construct($content, bool $isSortable = false) { |
|
37 | + Assert::parameterType(['string', HtmlArmor::class], $content, '$content'); |
|
38 | 38 | |
39 | 39 | $this->content = $content; |
40 | 40 | $this->isSortable = $isSortable; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return string HTML |
45 | 45 | */ |
46 | 46 | public function getContent(): string { |
47 | - return HtmlArmor::getHtml( $this->content ); |
|
47 | + return HtmlArmor::getHtml($this->content); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function getIsSortable(): bool { |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | * @return string HTML |
58 | 58 | */ |
59 | 59 | public function toHtml(): string { |
60 | - $attributes = [ 'role' => 'columnheader button' ]; |
|
60 | + $attributes = ['role' => 'columnheader button']; |
|
61 | 61 | |
62 | - if ( !$this->isSortable ) { |
|
62 | + if (!$this->isSortable) { |
|
63 | 63 | $attributes['class'] = 'unsortable'; |
64 | 64 | } |
65 | 65 | |
66 | - return Html::rawElement( 'th', $attributes, $this->getContent() ); |
|
66 | + return Html::rawElement('th', $attributes, $this->getContent()); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | } |
@@ -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\ConstraintCheck\Message; |
6 | 6 | |
@@ -21,26 +21,26 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class ViolationMessageSerializer implements Serializer { |
23 | 23 | |
24 | - private function abbreviateViolationMessageKey( string $fullMessageKey ): string { |
|
25 | - return substr( $fullMessageKey, strlen( ViolationMessage::MESSAGE_KEY_PREFIX ) ); |
|
24 | + private function abbreviateViolationMessageKey(string $fullMessageKey): string { |
|
25 | + return substr($fullMessageKey, strlen(ViolationMessage::MESSAGE_KEY_PREFIX)); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @param ViolationMessage $object |
30 | 30 | * @return array |
31 | 31 | */ |
32 | - public function serialize( $object ): array { |
|
32 | + public function serialize($object): array { |
|
33 | 33 | /** @var ViolationMessage $object */ |
34 | - Assert::parameterType( ViolationMessage::class, $object, '$object' ); |
|
34 | + Assert::parameterType(ViolationMessage::class, $object, '$object'); |
|
35 | 35 | |
36 | 36 | $arguments = $object->getArguments(); |
37 | 37 | $serializedArguments = []; |
38 | - foreach ( $arguments as $argument ) { |
|
39 | - $serializedArguments[] = $this->serializeArgument( $argument ); |
|
38 | + foreach ($arguments as $argument) { |
|
39 | + $serializedArguments[] = $this->serializeArgument($argument); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return [ |
43 | - 'k' => $this->abbreviateViolationMessageKey( $object->getMessageKey() ), |
|
43 | + 'k' => $this->abbreviateViolationMessageKey($object->getMessageKey()), |
|
44 | 44 | 'a' => $serializedArguments, |
45 | 45 | ]; |
46 | 46 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param array $argument element of ViolationMessage::getArguments() |
50 | 50 | * @return array [ 't' => ViolationMessage::TYPE_*, 'v' => serialized value, 'r' => $role ] |
51 | 51 | */ |
52 | - private function serializeArgument( array $argument ): array { |
|
52 | + private function serializeArgument(array $argument): array { |
|
53 | 53 | $methods = [ |
54 | 54 | ViolationMessage::TYPE_ENTITY_ID => 'serializeEntityId', |
55 | 55 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'serializeEntityIdList', |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | $value = $argument['value']; |
72 | 72 | $role = $argument['role']; |
73 | 73 | |
74 | - if ( array_key_exists( $type, $methods ) ) { |
|
74 | + if (array_key_exists($type, $methods)) { |
|
75 | 75 | $method = $methods[$type]; |
76 | - $serializedValue = $this->$method( $value ); |
|
76 | + $serializedValue = $this->$method($value); |
|
77 | 77 | } else { |
78 | 78 | throw new InvalidArgumentException( |
79 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
79 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $string any value that shall simply be serialized to itself |
94 | 94 | * @return string that same value, unchanged |
95 | 95 | */ |
96 | - private function serializeStringByIdentity( string $string ): string { |
|
96 | + private function serializeStringByIdentity(string $string): string { |
|
97 | 97 | return $string; |
98 | 98 | } |
99 | 99 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | * @param string[] $strings |
102 | 102 | * @return string[] |
103 | 103 | */ |
104 | - private function serializeStringListByIdentity( array $strings ): array { |
|
105 | - Assert::parameterElementType( 'string', $strings, '$strings' ); |
|
104 | + private function serializeStringListByIdentity(array $strings): array { |
|
105 | + Assert::parameterElementType('string', $strings, '$strings'); |
|
106 | 106 | return $strings; |
107 | 107 | } |
108 | 108 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param EntityId $entityId |
111 | 111 | * @return string entity ID serialization |
112 | 112 | */ |
113 | - private function serializeEntityId( EntityId $entityId ): string { |
|
113 | + private function serializeEntityId(EntityId $entityId): string { |
|
114 | 114 | return $entityId->getSerialization(); |
115 | 115 | } |
116 | 116 | |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * @param EntityId[] $entityIdList |
119 | 119 | * @return string[] entity ID serializations |
120 | 120 | */ |
121 | - private function serializeEntityIdList( array $entityIdList ): array { |
|
122 | - return array_map( [ $this, 'serializeEntityId' ], $entityIdList ); |
|
121 | + private function serializeEntityIdList(array $entityIdList): array { |
|
122 | + return array_map([$this, 'serializeEntityId'], $entityIdList); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | * @return string entity ID serialization, '::somevalue', or '::novalue' |
128 | 128 | * (according to EntityId::PATTERN, entity ID serializations can never begin with two colons) |
129 | 129 | */ |
130 | - private function serializeItemIdSnakValue( ItemIdSnakValue $value ): string { |
|
131 | - switch ( true ) { |
|
130 | + private function serializeItemIdSnakValue(ItemIdSnakValue $value): string { |
|
131 | + switch (true) { |
|
132 | 132 | case $value->isValue(): |
133 | - return $this->serializeEntityId( $value->getItemId() ); |
|
133 | + return $this->serializeEntityId($value->getItemId()); |
|
134 | 134 | case $value->isSomeValue(): |
135 | 135 | return '::somevalue'; |
136 | 136 | case $value->isNoValue(): |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | * @param ItemIdSnakValue[] $valueList |
149 | 149 | * @return string[] array of entity ID serializations, '::somevalue's or '::novalue's |
150 | 150 | */ |
151 | - private function serializeItemIdSnakValueList( array $valueList ): array { |
|
152 | - return array_map( [ $this, 'serializeItemIdSnakValue' ], $valueList ); |
|
151 | + private function serializeItemIdSnakValueList(array $valueList): array { |
|
152 | + return array_map([$this, 'serializeItemIdSnakValue'], $valueList); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
156 | 156 | * @param DataValue $dataValue |
157 | 157 | * @return array the data value in array form |
158 | 158 | */ |
159 | - private function serializeDataValue( DataValue $dataValue ): array { |
|
159 | + private function serializeDataValue(DataValue $dataValue): array { |
|
160 | 160 | return $dataValue->toArray(); |
161 | 161 | } |
162 | 162 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param string $contextType one of the Context::TYPE_* constants |
165 | 165 | * @return string the abbreviated context type |
166 | 166 | */ |
167 | - private function serializeContextType( string $contextType ): string { |
|
168 | - switch ( $contextType ) { |
|
167 | + private function serializeContextType(string $contextType): string { |
|
168 | + switch ($contextType) { |
|
169 | 169 | case Context::TYPE_STATEMENT: |
170 | 170 | return 's'; |
171 | 171 | case Context::TYPE_QUALIFIER: |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | default: |
176 | 176 | // @codeCoverageIgnoreStart |
177 | 177 | throw new LogicException( |
178 | - 'Unknown context type ' . $contextType |
|
178 | + 'Unknown context type '.$contextType |
|
179 | 179 | ); |
180 | 180 | // @codeCoverageIgnoreEnd |
181 | 181 | } |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | * @param string[] $contextTypeList Context::TYPE_* constants |
186 | 186 | * @return string[] abbreviated context types |
187 | 187 | */ |
188 | - private function serializeContextTypeList( array $contextTypeList ): array { |
|
189 | - return array_map( [ $this, 'serializeContextType' ], $contextTypeList ); |
|
188 | + private function serializeContextTypeList(array $contextTypeList): array { |
|
189 | + return array_map([$this, 'serializeContextType'], $contextTypeList); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
193 | 193 | * @param MultilingualTextValue $text |
194 | 194 | * @return mixed {@see MultilingualTextValue::getArrayValue} |
195 | 195 | */ |
196 | - private function serializeMultilingualText( MultilingualTextValue $text ) { |
|
196 | + private function serializeMultilingualText(MultilingualTextValue $text) { |
|
197 | 197 | return $text->getArrayValue(); |
198 | 198 | } |
199 | 199 |