@@ -79,19 +79,19 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return self |
81 | 81 | */ |
82 | - public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) { |
|
82 | + public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') { |
|
83 | 83 | $repo = WikibaseRepo::getDefaultInstance(); |
84 | 84 | |
85 | 85 | $language = $repo->getUserLanguage(); |
86 | 86 | $formatterOptions = new FormatterOptions(); |
87 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
87 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
88 | 88 | $valueFormatterFactory = $repo->getValueFormatterFactory(); |
89 | - $valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
89 | + $valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
90 | 90 | |
91 | 91 | $entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory(); |
92 | - $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $language ); |
|
92 | + $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($language); |
|
93 | 93 | $entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory(); |
94 | - $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $language ); |
|
94 | + $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($language); |
|
95 | 95 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
96 | 96 | $dataFactory = MediaWikiServices::getInstance()->getStatsdDataFactory(); |
97 | 97 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $prefix, |
114 | 114 | $repo->getEntityIdParser(), |
115 | 115 | $repo->getStatementGuidValidator(), |
116 | - $repo->getApiHelperFactory( RequestContext::getMain() ), |
|
116 | + $repo->getApiHelperFactory(RequestContext::getMain()), |
|
117 | 117 | $resultsSource, |
118 | 118 | $checkResultsRenderer, |
119 | 119 | $dataFactory |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | CheckResultsRenderer $checkResultsRenderer, |
143 | 143 | IBufferingStatsdDataFactory $dataFactory |
144 | 144 | ) { |
145 | - parent::__construct( $main, $name, $prefix ); |
|
145 | + parent::__construct($main, $name, $prefix); |
|
146 | 146 | $this->entityIdParser = $entityIdParser; |
147 | 147 | $this->statementGuidValidator = $statementGuidValidator; |
148 | - $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); |
|
149 | - $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
148 | + $this->resultBuilder = $apiHelperFactory->getResultBuilder($this); |
|
149 | + $this->errorReporter = $apiHelperFactory->getErrorReporter($this); |
|
150 | 150 | $this->resultsSource = $resultsSource; |
151 | 151 | $this->checkResultsRenderer = $checkResultsRenderer; |
152 | 152 | $this->dataFactory = $dataFactory; |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | |
163 | 163 | $params = $this->extractRequestParams(); |
164 | 164 | |
165 | - $this->validateParameters( $params ); |
|
166 | - $entityIds = $this->parseEntityIds( $params ); |
|
167 | - $claimIds = $this->parseClaimIds( $params ); |
|
165 | + $this->validateParameters($params); |
|
166 | + $entityIds = $this->parseEntityIds($params); |
|
167 | + $claimIds = $this->parseClaimIds($params); |
|
168 | 168 | $constraintIDs = $params[self::PARAM_CONSTRAINT_ID]; |
169 | 169 | $statuses = $params[self::PARAM_STATUS]; |
170 | 170 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | ) |
181 | 181 | )->getArray() |
182 | 182 | ); |
183 | - $this->resultBuilder->markSuccess( 1 ); |
|
183 | + $this->resultBuilder->markSuccess(1); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -188,24 +188,24 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @return EntityId[] |
190 | 190 | */ |
191 | - private function parseEntityIds( array $params ) { |
|
191 | + private function parseEntityIds(array $params) { |
|
192 | 192 | $ids = $params[self::PARAM_ID]; |
193 | 193 | |
194 | - if ( $ids === null ) { |
|
194 | + if ($ids === null) { |
|
195 | 195 | return []; |
196 | - } elseif ( $ids === [] ) { |
|
196 | + } elseif ($ids === []) { |
|
197 | 197 | $this->errorReporter->dieError( |
198 | - 'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
198 | + 'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
199 | 199 | } |
200 | 200 | |
201 | - return array_map( function ( $id ) { |
|
201 | + return array_map(function($id) { |
|
202 | 202 | try { |
203 | - return $this->entityIdParser->parse( $id ); |
|
204 | - } catch ( EntityIdParsingException $e ) { |
|
203 | + return $this->entityIdParser->parse($id); |
|
204 | + } catch (EntityIdParsingException $e) { |
|
205 | 205 | $this->errorReporter->dieError( |
206 | - "Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] ); |
|
206 | + "Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] ); |
|
207 | 207 | } |
208 | - }, $ids ); |
|
208 | + }, $ids); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -213,35 +213,35 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @return string[] |
215 | 215 | */ |
216 | - private function parseClaimIds( array $params ) { |
|
216 | + private function parseClaimIds(array $params) { |
|
217 | 217 | $ids = $params[self::PARAM_CLAIM_ID]; |
218 | 218 | |
219 | - if ( $ids === null ) { |
|
219 | + if ($ids === null) { |
|
220 | 220 | return []; |
221 | - } elseif ( $ids === [] ) { |
|
221 | + } elseif ($ids === []) { |
|
222 | 222 | $this->errorReporter->dieError( |
223 | - 'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
223 | + 'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
224 | 224 | } |
225 | 225 | |
226 | - foreach ( $ids as $id ) { |
|
227 | - if ( !$this->statementGuidValidator->validate( $id ) ) { |
|
226 | + foreach ($ids as $id) { |
|
227 | + if (!$this->statementGuidValidator->validate($id)) { |
|
228 | 228 | $this->errorReporter->dieError( |
229 | - "Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] ); |
|
229 | + "Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] ); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | 233 | return $ids; |
234 | 234 | } |
235 | 235 | |
236 | - private function validateParameters( array $params ) { |
|
237 | - if ( $params[self::PARAM_CONSTRAINT_ID] !== null |
|
238 | - && empty( $params[self::PARAM_CONSTRAINT_ID] ) |
|
236 | + private function validateParameters(array $params) { |
|
237 | + if ($params[self::PARAM_CONSTRAINT_ID] !== null |
|
238 | + && empty($params[self::PARAM_CONSTRAINT_ID]) |
|
239 | 239 | ) { |
240 | 240 | $paramConstraintId = self::PARAM_CONSTRAINT_ID; |
241 | 241 | $this->errorReporter->dieError( |
242 | 242 | "If $paramConstraintId is specified, it must be nonempty.", 'no-data' ); |
243 | 243 | } |
244 | - if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) { |
|
244 | + if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) { |
|
245 | 245 | $paramId = self::PARAM_ID; |
246 | 246 | $paramClaimId = self::PARAM_CLAIM_ID; |
247 | 247 | $this->errorReporter->dieError( |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | ], |
282 | 282 | ApiBase::PARAM_ISMULTI => true, |
283 | 283 | ApiBase::PARAM_ALL => true, |
284 | - ApiBase::PARAM_DFLT => implode( '|', [ |
|
284 | + ApiBase::PARAM_DFLT => implode('|', [ |
|
285 | 285 | CheckResult::STATUS_VIOLATION, |
286 | 286 | CheckResult::STATUS_WARNING, |
287 | 287 | CheckResult::STATUS_BAD_PARAMETERS, |
288 | - ] ), |
|
288 | + ]), |
|
289 | 289 | ApiBase::PARAM_HELP_MSG_PER_VALUE => [], |
290 | 290 | ], |
291 | 291 | ]; |
@@ -35,124 +35,124 @@ discard block |
||
35 | 35 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker; |
36 | 36 | |
37 | 37 | return [ |
38 | - ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => function( MediaWikiServices $services ) { |
|
38 | + ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => function(MediaWikiServices $services) { |
|
39 | 39 | return new ConflictsWithChecker( |
40 | - WikibaseServices::getEntityLookup( $services ), |
|
41 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
42 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
40 | + WikibaseServices::getEntityLookup($services), |
|
41 | + ConstraintsServices::getConstraintParameterParser($services), |
|
42 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
43 | 43 | ); |
44 | 44 | }, |
45 | 45 | |
46 | - ConstraintCheckerServices::ITEM_CHECKER => function( MediaWikiServices $services ) { |
|
46 | + ConstraintCheckerServices::ITEM_CHECKER => function(MediaWikiServices $services) { |
|
47 | 47 | return new ItemChecker( |
48 | - WikibaseServices::getEntityLookup( $services ), |
|
49 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
50 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
48 | + WikibaseServices::getEntityLookup($services), |
|
49 | + ConstraintsServices::getConstraintParameterParser($services), |
|
50 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
51 | 51 | ); |
52 | 52 | }, |
53 | 53 | |
54 | - ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => function( MediaWikiServices $services ) { |
|
54 | + ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => function(MediaWikiServices $services) { |
|
55 | 55 | return new TargetRequiredClaimChecker( |
56 | - WikibaseServices::getEntityLookup( $services ), |
|
57 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
58 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
56 | + WikibaseServices::getEntityLookup($services), |
|
57 | + ConstraintsServices::getConstraintParameterParser($services), |
|
58 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
59 | 59 | ); |
60 | 60 | }, |
61 | 61 | |
62 | - ConstraintCheckerServices::SYMMETRIC_CHECKER => function( MediaWikiServices $services ) { |
|
62 | + ConstraintCheckerServices::SYMMETRIC_CHECKER => function(MediaWikiServices $services) { |
|
63 | 63 | return new SymmetricChecker( |
64 | - WikibaseServices::getEntityLookup( $services ), |
|
65 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
64 | + WikibaseServices::getEntityLookup($services), |
|
65 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
66 | 66 | ); |
67 | 67 | }, |
68 | 68 | |
69 | - ConstraintCheckerServices::INVERSE_CHECKER => function( MediaWikiServices $services ) { |
|
69 | + ConstraintCheckerServices::INVERSE_CHECKER => function(MediaWikiServices $services) { |
|
70 | 70 | return new InverseChecker( |
71 | - WikibaseServices::getEntityLookup( $services ), |
|
72 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
73 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
71 | + WikibaseServices::getEntityLookup($services), |
|
72 | + ConstraintsServices::getConstraintParameterParser($services), |
|
73 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
74 | 74 | ); |
75 | 75 | }, |
76 | 76 | |
77 | - ConstraintCheckerServices::QUALIFIER_CHECKER => function( MediaWikiServices $services ) { |
|
77 | + ConstraintCheckerServices::QUALIFIER_CHECKER => function(MediaWikiServices $services) { |
|
78 | 78 | return new QualifierChecker(); |
79 | 79 | }, |
80 | 80 | |
81 | - ConstraintCheckerServices::QUALIFIERS_CHECKER => function( MediaWikiServices $services ) { |
|
81 | + ConstraintCheckerServices::QUALIFIERS_CHECKER => function(MediaWikiServices $services) { |
|
82 | 82 | return new QualifiersChecker( |
83 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
83 | + ConstraintsServices::getConstraintParameterParser($services) |
|
84 | 84 | ); |
85 | 85 | }, |
86 | 86 | |
87 | - ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => function( MediaWikiServices $services ) { |
|
87 | + ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => function(MediaWikiServices $services) { |
|
88 | 88 | return new MandatoryQualifiersChecker( |
89 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
89 | + ConstraintsServices::getConstraintParameterParser($services) |
|
90 | 90 | ); |
91 | 91 | }, |
92 | 92 | |
93 | - ConstraintCheckerServices::RANGE_CHECKER => function( MediaWikiServices $services ) { |
|
93 | + ConstraintCheckerServices::RANGE_CHECKER => function(MediaWikiServices $services) { |
|
94 | 94 | return new RangeChecker( |
95 | - WikibaseServices::getPropertyDataTypeLookup( $services ), |
|
96 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
97 | - ConstraintsServices::getRangeCheckerHelper( $services ) |
|
95 | + WikibaseServices::getPropertyDataTypeLookup($services), |
|
96 | + ConstraintsServices::getConstraintParameterParser($services), |
|
97 | + ConstraintsServices::getRangeCheckerHelper($services) |
|
98 | 98 | ); |
99 | 99 | }, |
100 | 100 | |
101 | - ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => function( MediaWikiServices $services ) { |
|
101 | + ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => function(MediaWikiServices $services) { |
|
102 | 102 | return new DiffWithinRangeChecker( |
103 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
104 | - ConstraintsServices::getRangeCheckerHelper( $services ), |
|
103 | + ConstraintsServices::getConstraintParameterParser($services), |
|
104 | + ConstraintsServices::getRangeCheckerHelper($services), |
|
105 | 105 | $services->getMainConfig() |
106 | 106 | ); |
107 | 107 | }, |
108 | 108 | |
109 | - ConstraintCheckerServices::TYPE_CHECKER => function( MediaWikiServices $services ) { |
|
109 | + ConstraintCheckerServices::TYPE_CHECKER => function(MediaWikiServices $services) { |
|
110 | 110 | return new TypeChecker( |
111 | - WikibaseServices::getEntityLookup( $services ), |
|
112 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
113 | - ConstraintsServices::getTypeCheckerHelper( $services ), |
|
111 | + WikibaseServices::getEntityLookup($services), |
|
112 | + ConstraintsServices::getConstraintParameterParser($services), |
|
113 | + ConstraintsServices::getTypeCheckerHelper($services), |
|
114 | 114 | $services->getMainConfig() |
115 | 115 | ); |
116 | 116 | }, |
117 | 117 | |
118 | - ConstraintCheckerServices::VALUE_TYPE_CHECKER => function( MediaWikiServices $services ) { |
|
118 | + ConstraintCheckerServices::VALUE_TYPE_CHECKER => function(MediaWikiServices $services) { |
|
119 | 119 | return new ValueTypeChecker( |
120 | - WikibaseServices::getEntityLookup( $services ), |
|
121 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
122 | - ConstraintsServices::getTypeCheckerHelper( $services ), |
|
120 | + WikibaseServices::getEntityLookup($services), |
|
121 | + ConstraintsServices::getConstraintParameterParser($services), |
|
122 | + ConstraintsServices::getTypeCheckerHelper($services), |
|
123 | 123 | $services->getMainConfig() |
124 | 124 | ); |
125 | 125 | }, |
126 | 126 | |
127 | - ConstraintCheckerServices::SINGLE_VALUE_CHECKER => function( MediaWikiServices $services ) { |
|
127 | + ConstraintCheckerServices::SINGLE_VALUE_CHECKER => function(MediaWikiServices $services) { |
|
128 | 128 | return new SingleValueChecker( |
129 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
129 | + ConstraintsServices::getConstraintParameterParser($services) |
|
130 | 130 | ); |
131 | 131 | }, |
132 | 132 | |
133 | - ConstraintCheckerServices::MULTI_VALUE_CHECKER => function( MediaWikiServices $services ) { |
|
133 | + ConstraintCheckerServices::MULTI_VALUE_CHECKER => function(MediaWikiServices $services) { |
|
134 | 134 | return new MultiValueChecker( |
135 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
135 | + ConstraintsServices::getConstraintParameterParser($services) |
|
136 | 136 | ); |
137 | 137 | }, |
138 | 138 | |
139 | - ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => function( MediaWikiServices $services ) { |
|
139 | + ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => function(MediaWikiServices $services) { |
|
140 | 140 | // TODO return a different, dummy implementation if SPARQL is not available |
141 | 141 | return new UniqueValueChecker( |
142 | - ConstraintsServices::getSparqlHelper( $services ) |
|
142 | + ConstraintsServices::getSparqlHelper($services) |
|
143 | 143 | ); |
144 | 144 | }, |
145 | 145 | |
146 | - ConstraintCheckerServices::FORMAT_CHECKER => function( MediaWikiServices $services ) { |
|
146 | + ConstraintCheckerServices::FORMAT_CHECKER => function(MediaWikiServices $services) { |
|
147 | 147 | // TODO return a different, dummy implementation if SPARQL is not available |
148 | 148 | return new FormatChecker( |
149 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
149 | + ConstraintsServices::getConstraintParameterParser($services), |
|
150 | 150 | $services->getMainConfig(), |
151 | - ConstraintsServices::getSparqlHelper( $services ) |
|
151 | + ConstraintsServices::getSparqlHelper($services) |
|
152 | 152 | ); |
153 | 153 | }, |
154 | 154 | |
155 | - ConstraintCheckerServices::COMMONS_LINK_CHECKER => function( MediaWikiServices $services ) { |
|
155 | + ConstraintCheckerServices::COMMONS_LINK_CHECKER => function(MediaWikiServices $services) { |
|
156 | 156 | // TODO return different implementations for: |
157 | 157 | // - Wikimedia production ('commonswiki' database available) |
158 | 158 | // - InstantCommons wikis |
@@ -160,76 +160,76 @@ discard block |
||
160 | 160 | // - … |
161 | 161 | // ? (see also T169538) |
162 | 162 | return new CommonsLinkChecker( |
163 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
163 | + ConstraintsServices::getConstraintParameterParser($services), |
|
164 | 164 | $services->getTitleParser() |
165 | 165 | ); |
166 | 166 | }, |
167 | 167 | |
168 | - ConstraintCheckerServices::ONE_OF_CHECKER => function( MediaWikiServices $services ) { |
|
168 | + ConstraintCheckerServices::ONE_OF_CHECKER => function(MediaWikiServices $services) { |
|
169 | 169 | return new OneOfChecker( |
170 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
170 | + ConstraintsServices::getConstraintParameterParser($services) |
|
171 | 171 | ); |
172 | 172 | }, |
173 | 173 | |
174 | - ConstraintCheckerServices::VALUE_ONLY_CHECKER => function( MediaWikiServices $services ) { |
|
174 | + ConstraintCheckerServices::VALUE_ONLY_CHECKER => function(MediaWikiServices $services) { |
|
175 | 175 | return new ValueOnlyChecker(); |
176 | 176 | }, |
177 | 177 | |
178 | - ConstraintCheckerServices::REFERENCE_CHECKER => function( MediaWikiServices $services ) { |
|
178 | + ConstraintCheckerServices::REFERENCE_CHECKER => function(MediaWikiServices $services) { |
|
179 | 179 | return new ReferenceChecker(); |
180 | 180 | }, |
181 | 181 | |
182 | - ConstraintCheckerServices::NO_BOUNDS_CHECKER => function( MediaWikiServices $services ) { |
|
182 | + ConstraintCheckerServices::NO_BOUNDS_CHECKER => function(MediaWikiServices $services) { |
|
183 | 183 | return new NoBoundsChecker(); |
184 | 184 | }, |
185 | 185 | |
186 | - ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => function( MediaWikiServices $services ) { |
|
186 | + ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => function(MediaWikiServices $services) { |
|
187 | 187 | // TODO in the future, get UnitConverter from $services? |
188 | 188 | $repo = WikibaseRepo::getDefaultInstance(); |
189 | 189 | $unitConverter = $repo->getUnitConverter(); |
190 | 190 | |
191 | 191 | return new AllowedUnitsChecker( |
192 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
192 | + ConstraintsServices::getConstraintParameterParser($services), |
|
193 | 193 | $unitConverter |
194 | 194 | ); |
195 | 195 | }, |
196 | 196 | |
197 | - ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => function( MediaWikiServices $services ) { |
|
197 | + ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => function(MediaWikiServices $services) { |
|
198 | 198 | return new SingleBestValueChecker( |
199 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
199 | + ConstraintsServices::getConstraintParameterParser($services) |
|
200 | 200 | ); |
201 | 201 | }, |
202 | 202 | |
203 | - ConstraintCheckerServices::ENTITY_TYPE_CHECKER => function( MediaWikiServices $services ) { |
|
203 | + ConstraintCheckerServices::ENTITY_TYPE_CHECKER => function(MediaWikiServices $services) { |
|
204 | 204 | return new EntityTypeChecker( |
205 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
205 | + ConstraintsServices::getConstraintParameterParser($services) |
|
206 | 206 | ); |
207 | 207 | }, |
208 | 208 | |
209 | - ConstraintCheckerServices::NONE_OF_CHECKER => function( MediaWikiServices $services ) { |
|
209 | + ConstraintCheckerServices::NONE_OF_CHECKER => function(MediaWikiServices $services) { |
|
210 | 210 | return new NoneOfChecker( |
211 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
211 | + ConstraintsServices::getConstraintParameterParser($services) |
|
212 | 212 | ); |
213 | 213 | }, |
214 | 214 | |
215 | - ConstraintCheckerServices::INTEGER_CHECKER => function( MediaWikiServices $services ) { |
|
215 | + ConstraintCheckerServices::INTEGER_CHECKER => function(MediaWikiServices $services) { |
|
216 | 216 | return new IntegerChecker(); |
217 | 217 | }, |
218 | 218 | |
219 | - ConstraintCheckerServices::CITATION_NEEDED_CHECKER => function( MediaWikiServices $services ) { |
|
219 | + ConstraintCheckerServices::CITATION_NEEDED_CHECKER => function(MediaWikiServices $services) { |
|
220 | 220 | return new CitationNeededChecker(); |
221 | 221 | }, |
222 | 222 | |
223 | - ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => function( MediaWikiServices $services ) { |
|
223 | + ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => function(MediaWikiServices $services) { |
|
224 | 224 | return new PropertyScopeChecker( |
225 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
225 | + ConstraintsServices::getConstraintParameterParser($services) |
|
226 | 226 | ); |
227 | 227 | }, |
228 | 228 | |
229 | - ConstraintCheckerServices::CONTEMPORARY_CHECKER => function( MediaWikiServices $services ) { |
|
229 | + ConstraintCheckerServices::CONTEMPORARY_CHECKER => function(MediaWikiServices $services) { |
|
230 | 230 | return new ContemporaryChecker( |
231 | - WikibaseServices::getEntityLookup( $services ), |
|
232 | - ConstraintsServices::getRangeCheckerHelper( $services ), |
|
231 | + WikibaseServices::getEntityLookup($services), |
|
232 | + ConstraintsServices::getRangeCheckerHelper($services), |
|
233 | 233 | $services->getMainConfig() |
234 | 234 | ); |
235 | 235 | }, |
@@ -40,10 +40,10 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @throws InvalidArgumentException |
42 | 42 | */ |
43 | - public function __construct( $content, $isSortable = false, $isRawContent = false ) { |
|
44 | - Assert::parameterType( 'string', $content, '$content' ); |
|
45 | - Assert::parameterType( 'boolean', $isSortable, '$isSortable' ); |
|
46 | - Assert::parameterType( 'boolean', $isRawContent, '$isRawContent' ); |
|
43 | + public function __construct($content, $isSortable = false, $isRawContent = false) { |
|
44 | + Assert::parameterType('string', $content, '$content'); |
|
45 | + Assert::parameterType('boolean', $isSortable, '$isSortable'); |
|
46 | + Assert::parameterType('boolean', $isRawContent, '$isRawContent'); |
|
47 | 47 | |
48 | 48 | $this->content = $content; |
49 | 49 | $this->isSortable = $isSortable; |
@@ -70,18 +70,18 @@ discard block |
||
70 | 70 | * @return string HTML |
71 | 71 | */ |
72 | 72 | public function toHtml() { |
73 | - $attributes = [ 'role' => 'columnheader button' ]; |
|
73 | + $attributes = ['role' => 'columnheader button']; |
|
74 | 74 | |
75 | - if ( !$this->isSortable ) { |
|
75 | + if (!$this->isSortable) { |
|
76 | 76 | $attributes['class'] = 'unsortable'; |
77 | 77 | } |
78 | 78 | |
79 | 79 | $content = $this->content; |
80 | - if ( !$this->isRawContent ) { |
|
81 | - $content = htmlspecialchars( $this->content ); |
|
80 | + if (!$this->isRawContent) { |
|
81 | + $content = htmlspecialchars($this->content); |
|
82 | 82 | } |
83 | 83 | |
84 | - return Html::rawElement( 'th', $attributes, $content ); |
|
84 | + return Html::rawElement('th', $attributes, $content); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | } |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @throws InvalidArgumentException |
40 | 40 | */ |
41 | - public function __construct( $content, array $attributes = [], $isRawContent = false ) { |
|
42 | - Assert::parameterType( 'string', $content, '$content' ); |
|
43 | - Assert::parameterType( 'boolean', $isRawContent, '$isRawContent' ); |
|
41 | + public function __construct($content, array $attributes = [], $isRawContent = false) { |
|
42 | + Assert::parameterType('string', $content, '$content'); |
|
43 | + Assert::parameterType('boolean', $isRawContent, '$isRawContent'); |
|
44 | 44 | |
45 | 45 | $this->content = $content; |
46 | 46 | $this->attributes = $attributes; |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | * @return string HTML |
66 | 66 | */ |
67 | 67 | public function toHtml() { |
68 | - if ( $this->isRawContent ) { |
|
69 | - return Html::rawElement( 'td', $this->getAttributes(), $this->content ); |
|
68 | + if ($this->isRawContent) { |
|
69 | + return Html::rawElement('td', $this->getAttributes(), $this->content); |
|
70 | 70 | } else { |
71 | - return Html::element( 'td', $this->getAttributes(), $this->content ); |
|
71 | + return Html::element('td', $this->getAttributes(), $this->content); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @param array $headers |
34 | 34 | */ |
35 | - public function __construct( array $headers ) { |
|
36 | - foreach ( $headers as $header ) { |
|
37 | - $this->addHeader( $header ); |
|
35 | + public function __construct(array $headers) { |
|
36 | + foreach ($headers as $header) { |
|
37 | + $this->addHeader($header); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
@@ -43,16 +43,16 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @throws InvalidArgumentException |
45 | 45 | */ |
46 | - private function addHeader( $header ) { |
|
47 | - Assert::parameterType( 'string|' . HtmlTableHeaderBuilder::class, $header, '$header' ); |
|
46 | + private function addHeader($header) { |
|
47 | + Assert::parameterType('string|'.HtmlTableHeaderBuilder::class, $header, '$header'); |
|
48 | 48 | |
49 | - if ( is_string( $header ) ) { |
|
50 | - $header = new HtmlTableHeaderBuilder( $header ); |
|
49 | + if (is_string($header)) { |
|
50 | + $header = new HtmlTableHeaderBuilder($header); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $this->headers[] = $header; |
54 | 54 | |
55 | - if ( $header->getIsSortable() ) { |
|
55 | + if ($header->getIsSortable()) { |
|
56 | 56 | $this->isSortable = true; |
57 | 57 | } |
58 | 58 | } |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @throws InvalidArgumentException |
87 | 87 | */ |
88 | - public function appendRow( array $cells ) { |
|
89 | - foreach ( $cells as $key => $cell ) { |
|
90 | - if ( is_string( $cell ) ) { |
|
91 | - $cells[$key] = new HtmlTableCellBuilder( $cell ); |
|
92 | - } elseif ( !( $cell instanceof HtmlTableCellBuilder ) ) { |
|
93 | - throw new InvalidArgumentException( '$cells must be array of HtmlTableCell objects.' ); |
|
88 | + public function appendRow(array $cells) { |
|
89 | + foreach ($cells as $key => $cell) { |
|
90 | + if (is_string($cell)) { |
|
91 | + $cells[$key] = new HtmlTableCellBuilder($cell); |
|
92 | + } elseif (!($cell instanceof HtmlTableCellBuilder)) { |
|
93 | + throw new InvalidArgumentException('$cells must be array of HtmlTableCell objects.'); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @throws InvalidArgumentException |
106 | 106 | */ |
107 | - public function appendRows( array $rows ) { |
|
108 | - foreach ( $rows as $cells ) { |
|
109 | - if ( !is_array( $cells ) ) { |
|
110 | - throw new InvalidArgumentException( '$rows must be array of arrays of HtmlTableCell objects.' ); |
|
107 | + public function appendRows(array $rows) { |
|
108 | + foreach ($rows as $cells) { |
|
109 | + if (!is_array($cells)) { |
|
110 | + throw new InvalidArgumentException('$rows must be array of arrays of HtmlTableCell objects.'); |
|
111 | 111 | } |
112 | 112 | |
113 | - $this->appendRow( $cells ); |
|
113 | + $this->appendRow($cells); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | |
@@ -122,34 +122,34 @@ discard block |
||
122 | 122 | public function toHtml() { |
123 | 123 | // Open table |
124 | 124 | $tableClasses = 'wikitable'; |
125 | - if ( $this->isSortable ) { |
|
125 | + if ($this->isSortable) { |
|
126 | 126 | $tableClasses .= ' sortable jquery-tablesort'; |
127 | 127 | } |
128 | - $html = Html::openElement( 'table', [ 'class' => $tableClasses ] ); |
|
128 | + $html = Html::openElement('table', ['class' => $tableClasses]); |
|
129 | 129 | |
130 | 130 | // Write headers |
131 | - $html .= Html::openElement( 'tr' ); |
|
132 | - foreach ( $this->headers as $header ) { |
|
131 | + $html .= Html::openElement('tr'); |
|
132 | + foreach ($this->headers as $header) { |
|
133 | 133 | $html .= $header->toHtml(); |
134 | 134 | } |
135 | - $html .= Html::closeElement( 'tr' ); |
|
135 | + $html .= Html::closeElement('tr'); |
|
136 | 136 | |
137 | 137 | // Write rows |
138 | - foreach ( $this->rows as $row ) { |
|
139 | - $html .= Html::openElement( 'tr' ); |
|
138 | + foreach ($this->rows as $row) { |
|
139 | + $html .= Html::openElement('tr'); |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * @var HtmlTableCellBuilder $cell |
143 | 143 | */ |
144 | - foreach ( $row as $cell ) { |
|
144 | + foreach ($row as $cell) { |
|
145 | 145 | $html .= $cell->toHtml(); |
146 | 146 | } |
147 | 147 | |
148 | - $html .= Html::closeElement( 'tr' ); |
|
148 | + $html .= Html::closeElement('tr'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // Close table |
152 | - $html .= Html::closeElement( 'table' ); |
|
152 | + $html .= Html::closeElement('table'); |
|
153 | 153 | |
154 | 154 | return $html; |
155 | 155 | } |
@@ -31,25 +31,25 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * @param DatabaseUpdater $updater |
33 | 33 | */ |
34 | - public static function onCreateSchema( DatabaseUpdater $updater ) { |
|
34 | + public static function onCreateSchema(DatabaseUpdater $updater) { |
|
35 | 35 | $updater->addExtensionTable( |
36 | 36 | 'wbqc_constraints', |
37 | - __DIR__ . '/../sql/create_wbqc_constraints.sql' |
|
37 | + __DIR__.'/../sql/create_wbqc_constraints.sql' |
|
38 | 38 | ); |
39 | 39 | $updater->addExtensionField( |
40 | 40 | 'wbqc_constraints', |
41 | 41 | 'constraint_id', |
42 | - __DIR__ . '/../sql/patch-wbqc_constraints-constraint_id.sql' |
|
42 | + __DIR__.'/../sql/patch-wbqc_constraints-constraint_id.sql' |
|
43 | 43 | ); |
44 | 44 | $updater->addExtensionIndex( |
45 | 45 | 'wbqc_constraints', |
46 | 46 | 'wbqc_constraints_guid_uniq', |
47 | - __DIR__ . '/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
47 | + __DIR__.'/../sql/patch-wbqc_constraints-wbqc_constraints_guid_uniq.sql' |
|
48 | 48 | ); |
49 | 49 | } |
50 | 50 | |
51 | - public static function onWikibaseChange( Change $change ) { |
|
52 | - if ( !( $change instanceof EntityChange ) ) { |
|
51 | + public static function onWikibaseChange(Change $change) { |
|
52 | + if (!($change instanceof EntityChange)) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
@@ -58,44 +58,44 @@ discard block |
||
58 | 58 | |
59 | 59 | // If jobs are enabled and the results would be stored in some way run a job. |
60 | 60 | if ( |
61 | - $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobs' ) && |
|
62 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) && |
|
61 | + $config->get('WBQualityConstraintsEnableConstraintsCheckJobs') && |
|
62 | + $config->get('WBQualityConstraintsCacheCheckConstraintsResults') && |
|
63 | 63 | self::isSelectedForJobRunBasedOnPercentage() |
64 | 64 | ) { |
65 | - $params = [ 'entityId' => $change->getEntityId()->getSerialization() ]; |
|
65 | + $params = ['entityId' => $change->getEntityId()->getSerialization()]; |
|
66 | 66 | JobQueueGroup::singleton()->push( |
67 | - new JobSpecification( CheckConstraintsJob::COMMAND, $params ) |
|
67 | + new JobSpecification(CheckConstraintsJob::COMMAND, $params) |
|
68 | 68 | ); |
69 | 69 | } |
70 | 70 | |
71 | - if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
72 | - self::isConstraintStatementsChange( $config, $change ) |
|
71 | + if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
72 | + self::isConstraintStatementsChange($config, $change) |
|
73 | 73 | ) { |
74 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
74 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
75 | 75 | JobQueueGroup::singleton()->push( |
76 | - new JobSpecification( 'constraintsTableUpdate', $params ) |
|
76 | + new JobSpecification('constraintsTableUpdate', $params) |
|
77 | 77 | ); |
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
81 | 81 | private static function isSelectedForJobRunBasedOnPercentage() { |
82 | 82 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
83 | - $percentage = $config->get( 'WBQualityConstraintsEnableConstraintsCheckJobsRatio' ); |
|
83 | + $percentage = $config->get('WBQualityConstraintsEnableConstraintsCheckJobsRatio'); |
|
84 | 84 | |
85 | - return mt_rand( 1, 100 ) <= $percentage; |
|
85 | + return mt_rand(1, 100) <= $percentage; |
|
86 | 86 | } |
87 | 87 | |
88 | - public static function isConstraintStatementsChange( Config $config, Change $change ) { |
|
89 | - if ( !( $change instanceof EntityChange ) || |
|
88 | + public static function isConstraintStatementsChange(Config $config, Change $change) { |
|
89 | + if (!($change instanceof EntityChange) || |
|
90 | 90 | $change->getAction() !== EntityChange::UPDATE || |
91 | - !( $change->getEntityId() instanceof PropertyId ) |
|
91 | + !($change->getEntityId() instanceof PropertyId) |
|
92 | 92 | ) { |
93 | 93 | return false; |
94 | 94 | } |
95 | 95 | |
96 | 96 | $info = $change->getInfo(); |
97 | 97 | |
98 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
98 | + if (!array_key_exists('compactDiff', $info)) { |
|
99 | 99 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
100 | 100 | // so we only know that the change *might* affect the constraint statements |
101 | 101 | return true; |
@@ -104,46 +104,46 @@ discard block |
||
104 | 104 | /** @var EntityDiffChangedAspects $aspects */ |
105 | 105 | $aspects = $info['compactDiff']; |
106 | 106 | |
107 | - $propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
108 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
107 | + $propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
108 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
109 | 109 | } |
110 | 110 | |
111 | - public static function onArticlePurge( WikiPage $wikiPage ) { |
|
111 | + public static function onArticlePurge(WikiPage $wikiPage) { |
|
112 | 112 | $repo = WikibaseRepo::getDefaultInstance(); |
113 | 113 | |
114 | 114 | $entityContentFactory = $repo->getEntityContentFactory(); |
115 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
116 | - $entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
117 | - if ( $entityId !== null ) { |
|
115 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
116 | + $entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle()); |
|
117 | + if ($entityId !== null) { |
|
118 | 118 | $resultsCache = ResultsCache::getDefaultInstance(); |
119 | - $resultsCache->delete( $entityId ); |
|
119 | + $resultsCache->delete($entityId); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | - public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { |
|
124 | + public static function onBeforePageDisplay(OutputPage $out, Skin $skin) { |
|
125 | 125 | $repo = WikibaseRepo::getDefaultInstance(); |
126 | 126 | |
127 | 127 | $lookup = $repo->getEntityNamespaceLookup(); |
128 | 128 | $title = $out->getTitle(); |
129 | - if ( $title === null ) { |
|
129 | + if ($title === null) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | - if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) { |
|
133 | + if (!$lookup->isEntityNamespace($title->getNamespace())) { |
|
134 | 134 | return; |
135 | 135 | } |
136 | - if ( empty( $out->getJsConfigVars()['wbIsEditView'] ) ) { |
|
136 | + if (empty($out->getJsConfigVars()['wbIsEditView'])) { |
|
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
140 | - $out->addModules( 'wikibase.quality.constraints.suggestions' ); |
|
140 | + $out->addModules('wikibase.quality.constraints.suggestions'); |
|
141 | 141 | |
142 | - if ( !$out->getUser()->isLoggedIn() ) { |
|
142 | + if (!$out->getUser()->isLoggedIn()) { |
|
143 | 143 | return; |
144 | 144 | } |
145 | 145 | |
146 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
146 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | * @param User $user |
153 | 153 | * @param array[] &$prefs |
154 | 154 | */ |
155 | - public static function onGetBetaFeaturePreferences( User $user, array &$prefs ) { |
|
155 | + public static function onGetBetaFeaturePreferences(User $user, array &$prefs) { |
|
156 | 156 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
157 | - $extensionAssetsPath = $config->get( 'ExtensionAssetsPath' ); |
|
158 | - if ( $config->get( 'WBQualityConstraintsSuggestionsBetaFeature' ) ) { |
|
157 | + $extensionAssetsPath = $config->get('ExtensionAssetsPath'); |
|
158 | + if ($config->get('WBQualityConstraintsSuggestionsBetaFeature')) { |
|
159 | 159 | $prefs['constraint-suggestions'] = [ |
160 | 160 | 'label-message' => 'wbqc-beta-feature-label-message', |
161 | 161 | 'desc-message' => 'wbqc-beta-feature-description-message', |
@@ -179,20 +179,20 @@ discard block |
||
179 | 179 | * @param array &$vars |
180 | 180 | * @param OutputPage $out |
181 | 181 | */ |
182 | - public static function addVariables( &$vars, OutputPage $out ) { |
|
182 | + public static function addVariables(&$vars, OutputPage $out) { |
|
183 | 183 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
184 | 184 | |
185 | - $vars['wbQualityConstraintsPropertyConstraintId'] = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
186 | - $vars['wbQualityConstraintsOneOfConstraintId'] = $config->get( 'WBQualityConstraintsOneOfConstraintId' ); |
|
187 | - $vars['wbQualityConstraintsAllowedQualifierConstraintId'] = $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ); |
|
188 | - $vars['wbQualityConstraintsPropertyId'] = $config->get( 'WBQualityConstraintsPropertyId' ); |
|
189 | - $vars['wbQualityConstraintsQualifierOfPropertyConstraintId'] = $config->get( 'WBQualityConstraintsQualifierOfPropertyConstraintId' ); |
|
185 | + $vars['wbQualityConstraintsPropertyConstraintId'] = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
186 | + $vars['wbQualityConstraintsOneOfConstraintId'] = $config->get('WBQualityConstraintsOneOfConstraintId'); |
|
187 | + $vars['wbQualityConstraintsAllowedQualifierConstraintId'] = $config->get('WBQualityConstraintsAllowedQualifiersConstraintId'); |
|
188 | + $vars['wbQualityConstraintsPropertyId'] = $config->get('WBQualityConstraintsPropertyId'); |
|
189 | + $vars['wbQualityConstraintsQualifierOfPropertyConstraintId'] = $config->get('WBQualityConstraintsQualifierOfPropertyConstraintId'); |
|
190 | 190 | |
191 | 191 | $vars['wbQualityConstraintsSuggestionsGloballyEnabled'] = false; |
192 | 192 | |
193 | - if ( $config->get( 'WBQualityConstraintsSuggestionsBetaFeature' ) && |
|
194 | - ExtensionRegistry::getInstance()->isLoaded( 'BetaFeatures' ) && |
|
195 | - BetaFeatures::isFeatureEnabled( $out->getUser(), 'constraint-suggestions' ) |
|
193 | + if ($config->get('WBQualityConstraintsSuggestionsBetaFeature') && |
|
194 | + ExtensionRegistry::getInstance()->isLoaded('BetaFeatures') && |
|
195 | + BetaFeatures::isFeatureEnabled($out->getUser(), 'constraint-suggestions') |
|
196 | 196 | ) { |
197 | 197 | $vars['wbQualityConstraintsSuggestionsGloballyEnabled'] = true; |
198 | 198 | } |
@@ -42,25 +42,25 @@ discard block |
||
42 | 42 | * @param Title $title |
43 | 43 | * @param string[] $params should contain 'entityId' => 'Q1234' |
44 | 44 | */ |
45 | - public function __construct( Title $title, array $params ) { |
|
46 | - parent::__construct( self::COMMAND, $title, $params ); |
|
45 | + public function __construct(Title $title, array $params) { |
|
46 | + parent::__construct(self::COMMAND, $title, $params); |
|
47 | 47 | $this->removeDuplicates = true; |
48 | 48 | |
49 | - Assert::parameterType( 'string', $params['entityId'], '$params[\'entityId\']' ); |
|
49 | + Assert::parameterType('string', $params['entityId'], '$params[\'entityId\']'); |
|
50 | 50 | $this->entityId = $params['entityId']; |
51 | 51 | |
52 | - $resultSource = ConstraintsServices::getResultsSource( MediaWikiServices::getInstance() ); |
|
52 | + $resultSource = ConstraintsServices::getResultsSource(MediaWikiServices::getInstance()); |
|
53 | 53 | // This job should only ever be used when caching result sources are used. |
54 | - $this->setResultsSource( $resultSource ); |
|
54 | + $this->setResultsSource($resultSource); |
|
55 | 55 | |
56 | - $this->setEntityIdParser( WikibaseRepo::getDefaultInstance()->getEntityIdParser() ); |
|
56 | + $this->setEntityIdParser(WikibaseRepo::getDefaultInstance()->getEntityIdParser()); |
|
57 | 57 | } |
58 | 58 | |
59 | - public function setResultsSource( CachingResultsSource $resultsSource ) { |
|
59 | + public function setResultsSource(CachingResultsSource $resultsSource) { |
|
60 | 60 | $this->resultsSource = $resultsSource; |
61 | 61 | } |
62 | 62 | |
63 | - public function setEntityIdParser( EntityIdParser $parser ) { |
|
63 | + public function setEntityIdParser(EntityIdParser $parser) { |
|
64 | 64 | $this->entityIdParser = $parser; |
65 | 65 | } |
66 | 66 | |
@@ -71,19 +71,19 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function run() { |
73 | 73 | try { |
74 | - $entityId = $this->entityIdParser->parse( $this->entityId ); |
|
75 | - } catch ( EntityIdParsingException $e ) { |
|
74 | + $entityId = $this->entityIdParser->parse($this->entityId); |
|
75 | + } catch (EntityIdParsingException $e) { |
|
76 | 76 | return false; |
77 | 77 | } |
78 | 78 | |
79 | - $this->checkConstraints( $entityId ); |
|
79 | + $this->checkConstraints($entityId); |
|
80 | 80 | |
81 | 81 | return true; |
82 | 82 | } |
83 | 83 | |
84 | - private function checkConstraints( EntityId $entityId ) { |
|
84 | + private function checkConstraints(EntityId $entityId) { |
|
85 | 85 | $this->resultsSource->getResults( |
86 | - [ $entityId ], |
|
86 | + [$entityId], |
|
87 | 87 | [], |
88 | 88 | null, |
89 | 89 | [] |
@@ -76,6 +76,7 @@ |
||
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @param string the converted $cacheId |
79 | + * @param string $cacheId |
|
79 | 80 | * |
80 | 81 | * @return boolean representing if the Lock is Locked |
81 | 82 | * |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @param BagOStuff $cache |
28 | 28 | */ |
29 | - public function __construct( BagOStuff $cache ) { |
|
29 | + public function __construct(BagOStuff $cache) { |
|
30 | 30 | $this->cache = $cache; |
31 | 31 | } |
32 | 32 | |
@@ -37,17 +37,17 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @throws \Wikimedia\Assert\ParameterTypeException |
39 | 39 | */ |
40 | - private function makeKey( $id ) { |
|
41 | - if ( empty( trim( $id ) ) ) { |
|
42 | - throw new ParameterTypeException( '$id', 'non-empty string' ); |
|
40 | + private function makeKey($id) { |
|
41 | + if (empty(trim($id))) { |
|
42 | + throw new ParameterTypeException('$id', 'non-empty string'); |
|
43 | 43 | } |
44 | 44 | |
45 | - Assert::parameterType( 'string', $id, '$id' ); |
|
45 | + Assert::parameterType('string', $id, '$id'); |
|
46 | 46 | |
47 | 47 | return $this->cache->makeKey( |
48 | 48 | 'WikibaseQualityConstraints', |
49 | 49 | 'ExpiryLock', |
50 | - (string)$id |
|
50 | + (string) $id |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @throws \Wikimedia\Assert\ParameterTypeException |
61 | 61 | */ |
62 | - public function lock( $id, ConvertibleTimestamp $expiryTimestamp ) { |
|
62 | + public function lock($id, ConvertibleTimestamp $expiryTimestamp) { |
|
63 | 63 | |
64 | - $cacheId = $this->makeKey( $id ); |
|
64 | + $cacheId = $this->makeKey($id); |
|
65 | 65 | |
66 | - if ( !$this->isLockedInternal( $cacheId ) ) { |
|
66 | + if (!$this->isLockedInternal($cacheId)) { |
|
67 | 67 | return $this->cache->set( |
68 | 68 | $cacheId, |
69 | 69 | $expiryTimestamp->getTimestamp(), |
@@ -81,20 +81,20 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @throws \Wikimedia\Assert\ParameterTypeException |
83 | 83 | */ |
84 | - private function isLockedInternal( $cacheId ) { |
|
85 | - $expiryTime = $this->cache->get( $cacheId ); |
|
86 | - if ( !$expiryTime ) { |
|
84 | + private function isLockedInternal($cacheId) { |
|
85 | + $expiryTime = $this->cache->get($cacheId); |
|
86 | + if (!$expiryTime) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | |
90 | 90 | try { |
91 | - $lockExpiryTimeStamp = new ConvertibleTimestamp( $expiryTime ); |
|
92 | - } catch ( TimestampException $exception ) { |
|
91 | + $lockExpiryTimeStamp = new ConvertibleTimestamp($expiryTime); |
|
92 | + } catch (TimestampException $exception) { |
|
93 | 93 | return false; |
94 | 94 | } |
95 | 95 | |
96 | 96 | $now = new ConvertibleTimestamp(); |
97 | - if ( $now->timestamp < $lockExpiryTimeStamp->timestamp ) { |
|
97 | + if ($now->timestamp < $lockExpiryTimeStamp->timestamp) { |
|
98 | 98 | return true; |
99 | 99 | } else { |
100 | 100 | return false; |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @throws \Wikimedia\Assert\ParameterTypeException |
110 | 110 | */ |
111 | - public function isLocked( $id ) { |
|
112 | - return $this->isLockedInternal( $this->makeKey( $id ) ); |
|
111 | + public function isLocked($id) { |
|
112 | + return $this->isLockedInternal($this->makeKey($id)); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | } |
@@ -29,28 +29,28 @@ discard block |
||
29 | 29 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
30 | 30 | |
31 | 31 | return [ |
32 | - ConstraintsServices::EXPIRY_LOCK => function( MediaWikiServices $services ) { |
|
33 | - return new ExpiryLock( ObjectCache::getInstance( CACHE_ANYTHING ) ); |
|
32 | + ConstraintsServices::EXPIRY_LOCK => function(MediaWikiServices $services) { |
|
33 | + return new ExpiryLock(ObjectCache::getInstance(CACHE_ANYTHING)); |
|
34 | 34 | }, |
35 | 35 | |
36 | - ConstraintsServices::LOGGING_HELPER => function( MediaWikiServices $services ) { |
|
36 | + ConstraintsServices::LOGGING_HELPER => function(MediaWikiServices $services) { |
|
37 | 37 | return new LoggingHelper( |
38 | 38 | $services->getStatsdDataFactory(), |
39 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
39 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
40 | 40 | $services->getMainConfig() |
41 | 41 | ); |
42 | 42 | }, |
43 | 43 | |
44 | - ConstraintsServices::CONSTRAINT_REPOSITORY => function( MediaWikiServices $services ) { |
|
44 | + ConstraintsServices::CONSTRAINT_REPOSITORY => function(MediaWikiServices $services) { |
|
45 | 45 | return new ConstraintRepository(); |
46 | 46 | }, |
47 | 47 | |
48 | - ConstraintsServices::CONSTRAINT_LOOKUP => function( MediaWikiServices $services ) { |
|
49 | - $constraintRepository = ConstraintsServices::getConstraintRepository( $services ); |
|
50 | - return new CachingConstraintLookup( $constraintRepository ); |
|
48 | + ConstraintsServices::CONSTRAINT_LOOKUP => function(MediaWikiServices $services) { |
|
49 | + $constraintRepository = ConstraintsServices::getConstraintRepository($services); |
|
50 | + return new CachingConstraintLookup($constraintRepository); |
|
51 | 51 | }, |
52 | 52 | |
53 | - ConstraintsServices::CHECK_RESULT_SERIALIZER => function( MediaWikiServices $services ) { |
|
53 | + ConstraintsServices::CHECK_RESULT_SERIALIZER => function(MediaWikiServices $services) { |
|
54 | 54 | return new CheckResultSerializer( |
55 | 55 | new ConstraintSerializer( |
56 | 56 | false // constraint parameters are not exposed |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | ); |
62 | 62 | }, |
63 | 63 | |
64 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => function( MediaWikiServices $services ) { |
|
64 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => function(MediaWikiServices $services) { |
|
65 | 65 | // TODO in the future, get EntityIdParser and DataValueFactory from $services? |
66 | 66 | $repo = WikibaseRepo::getDefaultInstance(); |
67 | 67 | $entityIdParser = $repo->getEntityIdParser(); |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | ); |
79 | 79 | }, |
80 | 80 | |
81 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function( MediaWikiServices $services ) { |
|
81 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => function(MediaWikiServices $services) { |
|
82 | 82 | return new ViolationMessageSerializer(); |
83 | 83 | }, |
84 | 84 | |
85 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function( MediaWikiServices $services ) { |
|
85 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => function(MediaWikiServices $services) { |
|
86 | 86 | // TODO in the future, get EntityIdParser and DataValueFactory from $services? |
87 | 87 | $repo = WikibaseRepo::getDefaultInstance(); |
88 | 88 | $entityIdParser = $repo->getEntityIdParser(); |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | ); |
95 | 95 | }, |
96 | 96 | |
97 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function( MediaWikiServices $services ) { |
|
97 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => function(MediaWikiServices $services) { |
|
98 | 98 | // TODO in the future, get DeserializerFactory and concept base URIs from $services? |
99 | 99 | $repo = WikibaseRepo::getDefaultInstance(); |
100 | 100 | $deserializerFactory = $repo->getBaseDataModelDeserializerFactory(); |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | ); |
108 | 108 | }, |
109 | 109 | |
110 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
110 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
111 | 111 | return new ConnectionCheckerHelper(); |
112 | 112 | }, |
113 | 113 | |
114 | - ConstraintsServices::RANGE_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
114 | + ConstraintsServices::RANGE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
115 | 115 | // TODO in the future, get UnitConverter from $services? |
116 | 116 | $repo = WikibaseRepo::getDefaultInstance(); |
117 | 117 | $unitConverter = $repo->getUnitConverter(); |
@@ -122,9 +122,9 @@ discard block |
||
122 | 122 | ); |
123 | 123 | }, |
124 | 124 | |
125 | - ConstraintsServices::SPARQL_HELPER => function( MediaWikiServices $services ) { |
|
126 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
127 | - if ( $endpoint === '' ) { |
|
125 | + ConstraintsServices::SPARQL_HELPER => function(MediaWikiServices $services) { |
|
126 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
127 | + if ($endpoint === '') { |
|
128 | 128 | return new DummySparqlHelper(); |
129 | 129 | } |
130 | 130 | |
@@ -140,115 +140,115 @@ discard block |
||
140 | 140 | $entityIdParser, |
141 | 141 | $propertyDataTypeLookup, |
142 | 142 | $services->getMainWANObjectCache(), |
143 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
144 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
143 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
144 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
145 | 145 | $services->getStatsdDataFactory(), |
146 | - wfWikiID() . ' WikibaseQualityConstraints ' . Http::userAgent(), |
|
146 | + wfWikiID().' WikibaseQualityConstraints '.Http::userAgent(), |
|
147 | 147 | $services->getHttpRequestFactory() |
148 | 148 | ); |
149 | 149 | }, |
150 | 150 | |
151 | - ConstraintsServices::TYPE_CHECKER_HELPER => function( MediaWikiServices $services ) { |
|
151 | + ConstraintsServices::TYPE_CHECKER_HELPER => function(MediaWikiServices $services) { |
|
152 | 152 | return new TypeCheckerHelper( |
153 | - WikibaseServices::getEntityLookup( $services ), |
|
153 | + WikibaseServices::getEntityLookup($services), |
|
154 | 154 | $services->getMainConfig(), |
155 | - ConstraintsServices::getSparqlHelper( $services ), |
|
155 | + ConstraintsServices::getSparqlHelper($services), |
|
156 | 156 | $services->getStatsdDataFactory() |
157 | 157 | ); |
158 | 158 | }, |
159 | 159 | |
160 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function( MediaWikiServices $services ) { |
|
160 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => function(MediaWikiServices $services) { |
|
161 | 161 | // TODO in the future, get StatementGuidParser from $services? |
162 | 162 | $repo = WikibaseRepo::getDefaultInstance(); |
163 | 163 | $statementGuidParser = $repo->getStatementGuidParser(); |
164 | 164 | |
165 | 165 | $config = $services->getMainConfig(); |
166 | 166 | $checkerMap = [ |
167 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
168 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
169 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
170 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
171 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
172 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
173 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
174 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
175 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
176 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
177 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
178 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
179 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
180 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
181 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
182 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
183 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
184 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
185 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
186 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
187 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
188 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
189 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
190 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
191 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
192 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
193 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
194 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
195 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
196 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
197 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
198 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
199 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
200 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
201 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
202 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
203 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
204 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
205 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
206 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
207 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
208 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
209 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
210 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
211 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
212 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
213 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
214 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
215 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
216 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
217 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
218 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
219 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
220 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
221 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
222 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
223 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
224 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
167 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
168 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
169 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
170 | + => ConstraintCheckerServices::getItemChecker($services), |
|
171 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
172 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
173 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
174 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
175 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
176 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
177 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
178 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
179 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
180 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
181 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
182 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
183 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
184 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
185 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
186 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
187 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
188 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
189 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
190 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
191 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
192 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
193 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
194 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
195 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
196 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
197 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
198 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
199 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
200 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
201 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
202 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
203 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
204 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
205 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
206 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
207 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
208 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
209 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
210 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
211 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
212 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
213 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
214 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
215 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
216 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
217 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
218 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
219 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
220 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
221 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
222 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
223 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
224 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
225 | 225 | ]; |
226 | 226 | |
227 | 227 | return new DelegatingConstraintChecker( |
228 | - WikibaseServices::getEntityLookup( $services ), |
|
228 | + WikibaseServices::getEntityLookup($services), |
|
229 | 229 | $checkerMap, |
230 | - ConstraintsServices::getConstraintLookup( $services ), |
|
231 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
230 | + ConstraintsServices::getConstraintLookup($services), |
|
231 | + ConstraintsServices::getConstraintParameterParser($services), |
|
232 | 232 | $statementGuidParser, |
233 | - ConstraintsServices::getLoggingHelper( $services ), |
|
234 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
235 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
236 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
233 | + ConstraintsServices::getLoggingHelper($services), |
|
234 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
235 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
236 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
237 | 237 | ); |
238 | 238 | }, |
239 | 239 | |
240 | - ConstraintsServices::RESULTS_SOURCE => function( MediaWikiServices $services ) { |
|
240 | + ConstraintsServices::RESULTS_SOURCE => function(MediaWikiServices $services) { |
|
241 | 241 | $config = $services->getMainConfig(); |
242 | 242 | $resultsSource = new CheckingResultsSource( |
243 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
243 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
244 | 244 | ); |
245 | 245 | |
246 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
246 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
247 | 247 | $possiblyStaleConstraintTypes = [ |
248 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
249 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
250 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
251 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
248 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
249 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
250 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
251 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
252 | 252 | ]; |
253 | 253 | // TODO in the future, get EntityIdParser and WikiPageEntityMetaDataAccessor from $services? |
254 | 254 | $repo = WikibaseRepo::getDefaultInstance(); |
@@ -260,21 +260,21 @@ discard block |
||
260 | 260 | $entityNamespaceLookup, |
261 | 261 | $services->getSlotRoleStore() |
262 | 262 | ), |
263 | - $repo->getSettings()->getSetting( 'changesDatabase' ), |
|
263 | + $repo->getSettings()->getSetting('changesDatabase'), |
|
264 | 264 | '' // Empty string here means this only works for the local repo |
265 | 265 | ); |
266 | 266 | |
267 | 267 | $resultsSource = new CachingResultsSource( |
268 | 268 | $resultsSource, |
269 | 269 | ResultsCache::getDefaultInstance(), |
270 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
271 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
270 | + ConstraintsServices::getCheckResultSerializer($services), |
|
271 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
272 | 272 | $wikiPageEntityMetaDataAccessor, |
273 | 273 | $entityIdParser, |
274 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
274 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
275 | 275 | $possiblyStaleConstraintTypes, |
276 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
277 | - ConstraintsServices::getLoggingHelper( $services ) |
|
276 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
277 | + ConstraintsServices::getLoggingHelper($services) |
|
278 | 278 | ); |
279 | 279 | } |
280 | 280 |