@@ -37,198 +37,198 @@ |
||
37 | 37 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker; |
38 | 38 | |
39 | 39 | return [ |
40 | - ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => static function ( MediaWikiServices $services ) { |
|
40 | + ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => static function(MediaWikiServices $services) { |
|
41 | 41 | return new ConflictsWithChecker( |
42 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
43 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
42 | + ConstraintsServices::getConstraintParameterParser($services), |
|
43 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
44 | 44 | ); |
45 | 45 | }, |
46 | 46 | |
47 | - ConstraintCheckerServices::ITEM_CHECKER => static function ( MediaWikiServices $services ) { |
|
47 | + ConstraintCheckerServices::ITEM_CHECKER => static function(MediaWikiServices $services) { |
|
48 | 48 | return new ItemChecker( |
49 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
50 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
49 | + ConstraintsServices::getConstraintParameterParser($services), |
|
50 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
51 | 51 | ); |
52 | 52 | }, |
53 | 53 | |
54 | - ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => static function ( MediaWikiServices $services ) { |
|
54 | + ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => static 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 => static function ( MediaWikiServices $services ) { |
|
62 | + ConstraintCheckerServices::SYMMETRIC_CHECKER => static function(MediaWikiServices $services) { |
|
63 | 63 | return new SymmetricChecker( |
64 | - WikibaseServices::getEntityLookupWithoutCache( $services ), |
|
65 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
64 | + WikibaseServices::getEntityLookupWithoutCache($services), |
|
65 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
66 | 66 | ); |
67 | 67 | }, |
68 | 68 | |
69 | - ConstraintCheckerServices::INVERSE_CHECKER => static function ( MediaWikiServices $services ) { |
|
69 | + ConstraintCheckerServices::INVERSE_CHECKER => static 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 => static function ( MediaWikiServices $services ) { |
|
77 | + ConstraintCheckerServices::QUALIFIER_CHECKER => static function(MediaWikiServices $services) { |
|
78 | 78 | return new QualifierChecker(); |
79 | 79 | }, |
80 | 80 | |
81 | - ConstraintCheckerServices::QUALIFIERS_CHECKER => static function ( MediaWikiServices $services ) { |
|
81 | + ConstraintCheckerServices::QUALIFIERS_CHECKER => static 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 => static function ( MediaWikiServices $services ) { |
|
87 | + ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => static 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 => static function ( MediaWikiServices $services ) { |
|
93 | + ConstraintCheckerServices::RANGE_CHECKER => static 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 => static function ( MediaWikiServices $services ) { |
|
101 | + ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => static 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 => static function ( MediaWikiServices $services ) { |
|
109 | + ConstraintCheckerServices::TYPE_CHECKER => static function(MediaWikiServices $services) { |
|
110 | 110 | return new TypeChecker( |
111 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
112 | - ConstraintsServices::getTypeCheckerHelper( $services ), |
|
111 | + ConstraintsServices::getConstraintParameterParser($services), |
|
112 | + ConstraintsServices::getTypeCheckerHelper($services), |
|
113 | 113 | $services->getMainConfig() |
114 | 114 | ); |
115 | 115 | }, |
116 | 116 | |
117 | - ConstraintCheckerServices::VALUE_TYPE_CHECKER => static function ( MediaWikiServices $services ) { |
|
117 | + ConstraintCheckerServices::VALUE_TYPE_CHECKER => static function(MediaWikiServices $services) { |
|
118 | 118 | return new ValueTypeChecker( |
119 | - WikibaseServices::getEntityLookup( $services ), |
|
120 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
121 | - ConstraintsServices::getTypeCheckerHelper( $services ), |
|
119 | + WikibaseServices::getEntityLookup($services), |
|
120 | + ConstraintsServices::getConstraintParameterParser($services), |
|
121 | + ConstraintsServices::getTypeCheckerHelper($services), |
|
122 | 122 | $services->getMainConfig() |
123 | 123 | ); |
124 | 124 | }, |
125 | 125 | |
126 | - ConstraintCheckerServices::SINGLE_VALUE_CHECKER => static function ( MediaWikiServices $services ) { |
|
126 | + ConstraintCheckerServices::SINGLE_VALUE_CHECKER => static function(MediaWikiServices $services) { |
|
127 | 127 | return new SingleValueChecker( |
128 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
128 | + ConstraintsServices::getConstraintParameterParser($services) |
|
129 | 129 | ); |
130 | 130 | }, |
131 | 131 | |
132 | - ConstraintCheckerServices::MULTI_VALUE_CHECKER => static function ( MediaWikiServices $services ) { |
|
132 | + ConstraintCheckerServices::MULTI_VALUE_CHECKER => static function(MediaWikiServices $services) { |
|
133 | 133 | return new MultiValueChecker( |
134 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
134 | + ConstraintsServices::getConstraintParameterParser($services) |
|
135 | 135 | ); |
136 | 136 | }, |
137 | 137 | |
138 | - ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => static function ( MediaWikiServices $services ) { |
|
138 | + ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => static function(MediaWikiServices $services) { |
|
139 | 139 | // TODO return a different, dummy implementation if SPARQL is not available |
140 | 140 | return new UniqueValueChecker( |
141 | - ConstraintsServices::getSparqlHelper( $services ) |
|
141 | + ConstraintsServices::getSparqlHelper($services) |
|
142 | 142 | ); |
143 | 143 | }, |
144 | 144 | |
145 | - ConstraintCheckerServices::FORMAT_CHECKER => static function ( MediaWikiServices $services ) { |
|
145 | + ConstraintCheckerServices::FORMAT_CHECKER => static function(MediaWikiServices $services) { |
|
146 | 146 | // TODO return a different, dummy implementation if SPARQL is not available |
147 | 147 | return new FormatChecker( |
148 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
148 | + ConstraintsServices::getConstraintParameterParser($services), |
|
149 | 149 | $services->getMainConfig(), |
150 | - ConstraintsServices::getSparqlHelper( $services ), |
|
150 | + ConstraintsServices::getSparqlHelper($services), |
|
151 | 151 | $services->getShellboxClientFactory() |
152 | 152 | ); |
153 | 153 | }, |
154 | 154 | |
155 | - ConstraintCheckerServices::COMMONS_LINK_CHECKER => static function ( MediaWikiServices $services ) { |
|
155 | + ConstraintCheckerServices::COMMONS_LINK_CHECKER => static function(MediaWikiServices $services) { |
|
156 | 156 | $pageNameNormalizer = new MediaWikiPageNameNormalizer(); |
157 | 157 | return new CommonsLinkChecker( |
158 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
158 | + ConstraintsServices::getConstraintParameterParser($services), |
|
159 | 159 | $pageNameNormalizer |
160 | 160 | ); |
161 | 161 | }, |
162 | 162 | |
163 | - ConstraintCheckerServices::ONE_OF_CHECKER => static function ( MediaWikiServices $services ) { |
|
163 | + ConstraintCheckerServices::ONE_OF_CHECKER => static function(MediaWikiServices $services) { |
|
164 | 164 | return new OneOfChecker( |
165 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
165 | + ConstraintsServices::getConstraintParameterParser($services) |
|
166 | 166 | ); |
167 | 167 | }, |
168 | 168 | |
169 | - ConstraintCheckerServices::VALUE_ONLY_CHECKER => static function ( MediaWikiServices $services ) { |
|
169 | + ConstraintCheckerServices::VALUE_ONLY_CHECKER => static function(MediaWikiServices $services) { |
|
170 | 170 | return new ValueOnlyChecker(); |
171 | 171 | }, |
172 | 172 | |
173 | - ConstraintCheckerServices::REFERENCE_CHECKER => static function ( MediaWikiServices $services ) { |
|
173 | + ConstraintCheckerServices::REFERENCE_CHECKER => static function(MediaWikiServices $services) { |
|
174 | 174 | return new ReferenceChecker(); |
175 | 175 | }, |
176 | 176 | |
177 | - ConstraintCheckerServices::NO_BOUNDS_CHECKER => static function ( MediaWikiServices $services ) { |
|
177 | + ConstraintCheckerServices::NO_BOUNDS_CHECKER => static function(MediaWikiServices $services) { |
|
178 | 178 | return new NoBoundsChecker(); |
179 | 179 | }, |
180 | 180 | |
181 | - ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => static function ( MediaWikiServices $services ) { |
|
181 | + ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => static function(MediaWikiServices $services) { |
|
182 | 182 | return new AllowedUnitsChecker( |
183 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
184 | - WikibaseRepo::getUnitConverter( $services ) |
|
183 | + ConstraintsServices::getConstraintParameterParser($services), |
|
184 | + WikibaseRepo::getUnitConverter($services) |
|
185 | 185 | ); |
186 | 186 | }, |
187 | 187 | |
188 | - ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => static function ( MediaWikiServices $services ) { |
|
188 | + ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => static function(MediaWikiServices $services) { |
|
189 | 189 | return new SingleBestValueChecker( |
190 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
190 | + ConstraintsServices::getConstraintParameterParser($services) |
|
191 | 191 | ); |
192 | 192 | }, |
193 | 193 | |
194 | - ConstraintCheckerServices::ENTITY_TYPE_CHECKER => static function ( MediaWikiServices $services ) { |
|
194 | + ConstraintCheckerServices::ENTITY_TYPE_CHECKER => static function(MediaWikiServices $services) { |
|
195 | 195 | return new EntityTypeChecker( |
196 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
196 | + ConstraintsServices::getConstraintParameterParser($services) |
|
197 | 197 | ); |
198 | 198 | }, |
199 | 199 | |
200 | - ConstraintCheckerServices::NONE_OF_CHECKER => static function ( MediaWikiServices $services ) { |
|
200 | + ConstraintCheckerServices::NONE_OF_CHECKER => static function(MediaWikiServices $services) { |
|
201 | 201 | return new NoneOfChecker( |
202 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
202 | + ConstraintsServices::getConstraintParameterParser($services) |
|
203 | 203 | ); |
204 | 204 | }, |
205 | 205 | |
206 | - ConstraintCheckerServices::INTEGER_CHECKER => static function ( MediaWikiServices $services ) { |
|
206 | + ConstraintCheckerServices::INTEGER_CHECKER => static function(MediaWikiServices $services) { |
|
207 | 207 | return new IntegerChecker(); |
208 | 208 | }, |
209 | 209 | |
210 | - ConstraintCheckerServices::CITATION_NEEDED_CHECKER => static function ( MediaWikiServices $services ) { |
|
210 | + ConstraintCheckerServices::CITATION_NEEDED_CHECKER => static function(MediaWikiServices $services) { |
|
211 | 211 | return new CitationNeededChecker(); |
212 | 212 | }, |
213 | 213 | |
214 | - ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => static function ( MediaWikiServices $services ) { |
|
214 | + ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => static function(MediaWikiServices $services) { |
|
215 | 215 | return new PropertyScopeChecker( |
216 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
216 | + ConstraintsServices::getConstraintParameterParser($services) |
|
217 | 217 | ); |
218 | 218 | }, |
219 | 219 | |
220 | - ConstraintCheckerServices::CONTEMPORARY_CHECKER => static function ( MediaWikiServices $services ) { |
|
220 | + ConstraintCheckerServices::CONTEMPORARY_CHECKER => static function(MediaWikiServices $services) { |
|
221 | 221 | return new ContemporaryChecker( |
222 | - WikibaseServices::getEntityLookup( $services ), |
|
223 | - ConstraintsServices::getRangeCheckerHelper( $services ), |
|
222 | + WikibaseServices::getEntityLookup($services), |
|
223 | + ConstraintsServices::getRangeCheckerHelper($services), |
|
224 | 224 | $services->getMainConfig() |
225 | 225 | ); |
226 | 226 | }, |
227 | 227 | |
228 | - ConstraintCheckerServices::LEXEME_LANGUAGE_CHECKER => static function ( MediaWikiServices $services ) { |
|
228 | + ConstraintCheckerServices::LEXEME_LANGUAGE_CHECKER => static function(MediaWikiServices $services) { |
|
229 | 229 | return new LanguageChecker( |
230 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
231 | - WikibaseServices::getEntityLookup( $services ) |
|
230 | + ConstraintsServices::getConstraintParameterParser($services), |
|
231 | + WikibaseServices::getEntityLookup($services) |
|
232 | 232 | ); |
233 | 233 | }, |
234 | 234 | ]; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @throws ConstraintParameterException |
98 | 98 | * @return CheckResult |
99 | 99 | */ |
100 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
100 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
101 | 101 | $parameters = []; |
102 | 102 | $constraintParameters = $constraint->getConstraintParameters(); |
103 | 103 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $constraintParameters, |
107 | 107 | $constraintTypeItemId |
108 | 108 | ); |
109 | - $parameters['pattern'] = [ $format ]; |
|
109 | + $parameters['pattern'] = [$format]; |
|
110 | 110 | |
111 | 111 | $syntaxClarifications = $this->constraintParameterParser->parseSyntaxClarificationParameter( |
112 | 112 | $constraintParameters |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | |
115 | 115 | $snak = $context->getSnak(); |
116 | 116 | |
117 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
117 | + if (!$snak instanceof PropertyValueSnak) { |
|
118 | 118 | // nothing to check |
119 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE ); |
|
119 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | $dataValue = $snak->getDataValue(); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * error handling: |
126 | 126 | * type of $dataValue for properties with 'Format' constraint has to be 'string' or 'monolingualtext' |
127 | 127 | */ |
128 | - switch ( $dataValue->getType() ) { |
|
128 | + switch ($dataValue->getType()) { |
|
129 | 129 | case 'string': |
130 | 130 | $text = $dataValue->getValue(); |
131 | 131 | break; |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | $text = $dataValue->getText(); |
136 | 136 | break; |
137 | 137 | default: |
138 | - $message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-types-2' ) ) |
|
139 | - ->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM ) |
|
140 | - ->withDataValueType( 'string' ) |
|
141 | - ->withDataValueType( 'monolingualtext' ); |
|
142 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
138 | + $message = (new ViolationMessage('wbqc-violation-message-value-needed-of-types-2')) |
|
139 | + ->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM) |
|
140 | + ->withDataValueType('string') |
|
141 | + ->withDataValueType('monolingualtext'); |
|
142 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
143 | 143 | } |
144 | - $status = $this->runRegexCheck( $text, $format ); |
|
144 | + $status = $this->runRegexCheck($text, $format); |
|
145 | 145 | $message = $this->formatMessage( |
146 | 146 | $status, |
147 | 147 | $text, |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $syntaxClarifications, |
151 | 151 | $constraintTypeItemId |
152 | 152 | ); |
153 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
153 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | private function formatMessage( |
@@ -162,73 +162,73 @@ discard block |
||
162 | 162 | string $constraintTypeItemId |
163 | 163 | ): ?ViolationMessage { |
164 | 164 | $message = null; |
165 | - if ( $status === CheckResult::STATUS_VIOLATION ) { |
|
166 | - $message = ( new ViolationMessage( 'wbqc-violation-message-format-clarification' ) ) |
|
167 | - ->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY ) |
|
168 | - ->withDataValue( new StringValue( $text ), Role::OBJECT ) |
|
169 | - ->withInlineCode( $format, Role::CONSTRAINT_PARAMETER_VALUE ) |
|
170 | - ->withMultilingualText( $syntaxClarifications, Role::CONSTRAINT_PARAMETER_VALUE ); |
|
171 | - } elseif ( $status === CheckResult::STATUS_TODO ) { |
|
172 | - $message = ( new ViolationMessage( 'wbqc-violation-message-security-reason' ) ) |
|
173 | - ->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM ); |
|
165 | + if ($status === CheckResult::STATUS_VIOLATION) { |
|
166 | + $message = (new ViolationMessage('wbqc-violation-message-format-clarification')) |
|
167 | + ->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY) |
|
168 | + ->withDataValue(new StringValue($text), Role::OBJECT) |
|
169 | + ->withInlineCode($format, Role::CONSTRAINT_PARAMETER_VALUE) |
|
170 | + ->withMultilingualText($syntaxClarifications, Role::CONSTRAINT_PARAMETER_VALUE); |
|
171 | + } elseif ($status === CheckResult::STATUS_TODO) { |
|
172 | + $message = (new ViolationMessage('wbqc-violation-message-security-reason')) |
|
173 | + ->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | return $message; |
177 | 177 | } |
178 | 178 | |
179 | - private function runRegexCheck( string $text, string $format ): string { |
|
180 | - if ( !$this->config->get( 'WBQualityConstraintsCheckFormatConstraint' ) ) { |
|
179 | + private function runRegexCheck(string $text, string $format): string { |
|
180 | + if (!$this->config->get('WBQualityConstraintsCheckFormatConstraint')) { |
|
181 | 181 | return CheckResult::STATUS_TODO; |
182 | 182 | } |
183 | 183 | if ( |
184 | - $this->config->get( 'WBQualityConstraintsFormatCheckerShellboxRatio' ) > (float)wfRandom() |
|
184 | + $this->config->get('WBQualityConstraintsFormatCheckerShellboxRatio') > (float) wfRandom() |
|
185 | 185 | ) { |
186 | - return $this->runRegexCheckUsingShellbox( $text, $format ); |
|
186 | + return $this->runRegexCheckUsingShellbox($text, $format); |
|
187 | 187 | } |
188 | 188 | |
189 | - return $this->runRegexCheckUsingSparql( $text, $format ); |
|
189 | + return $this->runRegexCheckUsingSparql($text, $format); |
|
190 | 190 | } |
191 | 191 | |
192 | - private function runRegexCheckUsingShellbox( string $text, string $format ): string { |
|
193 | - if ( !$this->shellboxClientFactory->isEnabled() ) { |
|
192 | + private function runRegexCheckUsingShellbox(string $text, string $format): string { |
|
193 | + if (!$this->shellboxClientFactory->isEnabled()) { |
|
194 | 194 | return CheckResult::STATUS_TODO; |
195 | 195 | } |
196 | 196 | try { |
197 | - $pattern = '/^' . str_replace( '/', '\/', $format ) . '$/'; |
|
197 | + $pattern = '/^'.str_replace('/', '\/', $format).'$/'; |
|
198 | 198 | $shellboxResponse = $this->shellboxClientFactory->getClient( |
199 | - [ 'timeout' => $this->config->get( 'WBQualityConstraintsSparqlMaxMillis' ) / 1000 ] |
|
199 | + ['timeout' => $this->config->get('WBQualityConstraintsSparqlMaxMillis') / 1000] |
|
200 | 200 | )->call( |
201 | 201 | 'constraint-regex-checker', |
202 | 202 | 'preg_match', |
203 | - [ $pattern, $text ] |
|
203 | + [$pattern, $text] |
|
204 | 204 | ); |
205 | - } catch ( ShellboxError $exception ) { |
|
205 | + } catch (ShellboxError $exception) { |
|
206 | 206 | throw new ConstraintParameterException( |
207 | - ( new ViolationMessage( 'wbqc-violation-message-parameter-regex' ) ) |
|
208 | - ->withInlineCode( $pattern, Role::CONSTRAINT_PARAMETER_VALUE ) |
|
207 | + (new ViolationMessage('wbqc-violation-message-parameter-regex')) |
|
208 | + ->withInlineCode($pattern, Role::CONSTRAINT_PARAMETER_VALUE) |
|
209 | 209 | ); |
210 | 210 | } |
211 | 211 | |
212 | - if ( $shellboxResponse ) { |
|
212 | + if ($shellboxResponse) { |
|
213 | 213 | return CheckResult::STATUS_COMPLIANCE; |
214 | 214 | } else { |
215 | 215 | return CheckResult::STATUS_VIOLATION; |
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
219 | - private function runRegexCheckUsingSparql( string $text, string $format ): string { |
|
220 | - if ( $this->sparqlHelper instanceof DummySparqlHelper ) { |
|
219 | + private function runRegexCheckUsingSparql(string $text, string $format): string { |
|
220 | + if ($this->sparqlHelper instanceof DummySparqlHelper) { |
|
221 | 221 | return CheckResult::STATUS_TODO; |
222 | 222 | } |
223 | 223 | |
224 | - if ( $this->sparqlHelper->matchesRegularExpression( $text, $format ) ) { |
|
224 | + if ($this->sparqlHelper->matchesRegularExpression($text, $format)) { |
|
225 | 225 | return CheckResult::STATUS_COMPLIANCE; |
226 | 226 | } else { |
227 | 227 | return CheckResult::STATUS_VIOLATION; |
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
231 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
231 | + public function checkConstraintParameters(Constraint $constraint) { |
|
232 | 232 | $constraintParameters = $constraint->getConstraintParameters(); |
233 | 233 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
234 | 234 | $exceptions = []; |
@@ -237,14 +237,14 @@ discard block |
||
237 | 237 | $constraintParameters, |
238 | 238 | $constraintTypeItemId |
239 | 239 | ); |
240 | - } catch ( ConstraintParameterException $e ) { |
|
240 | + } catch (ConstraintParameterException $e) { |
|
241 | 241 | $exceptions[] = $e; |
242 | 242 | } |
243 | 243 | try { |
244 | 244 | $this->constraintParameterParser->parseSyntaxClarificationParameter( |
245 | 245 | $constraintParameters |
246 | 246 | ); |
247 | - } catch ( ConstraintParameterException $e ) { |
|
247 | + } catch (ConstraintParameterException $e) { |
|
248 | 248 | $exceptions[] = $e; |
249 | 249 | } |
250 | 250 | return $exceptions; |