@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs |
89 | 89 | * @return CheckResult |
90 | 90 | */ |
91 | - public function checkConstraint( Context $context, Constraint $constraint ): CheckResult { |
|
92 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
93 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED ); |
|
91 | + public function checkConstraint(Context $context, Constraint $constraint): CheckResult { |
|
92 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
93 | + return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $constraintParameters = $constraint->getConstraintParameters(); |
@@ -106,18 +106,18 @@ discard block |
||
106 | 106 | $constraintTypeItemId |
107 | 107 | ); |
108 | 108 | $relationIds = []; |
109 | - if ( $relation === 'instance' || $relation === 'instanceOrSubclass' ) { |
|
110 | - $relationIds[] = $this->config->get( 'WBQualityConstraintsInstanceOfId' ); |
|
109 | + if ($relation === 'instance' || $relation === 'instanceOrSubclass') { |
|
110 | + $relationIds[] = $this->config->get('WBQualityConstraintsInstanceOfId'); |
|
111 | 111 | } |
112 | - if ( $relation === 'subclass' || $relation === 'instanceOrSubclass' ) { |
|
113 | - $relationIds[] = $this->config->get( 'WBQualityConstraintsSubclassOfId' ); |
|
112 | + if ($relation === 'subclass' || $relation === 'instanceOrSubclass') { |
|
113 | + $relationIds[] = $this->config->get('WBQualityConstraintsSubclassOfId'); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | $snak = $context->getSnak(); |
117 | 117 | |
118 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
118 | + if (!$snak instanceof PropertyValueSnak) { |
|
119 | 119 | // nothing to check |
120 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_COMPLIANCE ); |
|
120 | + return new CheckResult($context, $constraint, CheckResult::STATUS_COMPLIANCE); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | $dataValue = $snak->getDataValue(); |
@@ -126,23 +126,23 @@ discard block |
||
126 | 126 | * error handling: |
127 | 127 | * type of $dataValue for properties with 'Value type' constraint has to be 'wikibase-entityid' |
128 | 128 | */ |
129 | - if ( !$dataValue instanceof EntityIdValue ) { |
|
130 | - $message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-type' ) ) |
|
131 | - ->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM ) |
|
132 | - ->withDataValueType( 'wikibase-entityid' ); |
|
133 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message ); |
|
129 | + if (!$dataValue instanceof EntityIdValue) { |
|
130 | + $message = (new ViolationMessage('wbqc-violation-message-value-needed-of-type')) |
|
131 | + ->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM) |
|
132 | + ->withDataValueType('wikibase-entityid'); |
|
133 | + return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | try { |
137 | - $item = $this->entityLookup->getEntity( $dataValue->getEntityId() ); |
|
138 | - } catch ( UnresolvedEntityRedirectException $e ) { |
|
137 | + $item = $this->entityLookup->getEntity($dataValue->getEntityId()); |
|
138 | + } catch (UnresolvedEntityRedirectException $e) { |
|
139 | 139 | // Edge case (double redirect): Pretend the entity doesn't exist |
140 | 140 | $item = null; |
141 | 141 | } |
142 | 142 | |
143 | - if ( !( $item instanceof StatementListProvidingEntity ) ) { |
|
144 | - $message = new ViolationMessage( 'wbqc-violation-message-value-entity-must-exist' ); |
|
145 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message ); |
|
143 | + if (!($item instanceof StatementListProvidingEntity)) { |
|
144 | + $message = new ViolationMessage('wbqc-violation-message-value-entity-must-exist'); |
|
145 | + return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $statements = $item->getStatements(); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | $classes |
154 | 154 | ); |
155 | 155 | |
156 | - if ( $result->getBool() ) { |
|
156 | + if ($result->getBool()) { |
|
157 | 157 | $message = null; |
158 | 158 | $status = CheckResult::STATUS_COMPLIANCE; |
159 | 159 | } else { |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | $status = CheckResult::STATUS_VIOLATION; |
168 | 168 | } |
169 | 169 | |
170 | - return ( new CheckResult( $context, $constraint, $status, $message ) ) |
|
171 | - ->withMetadata( $result->getMetadata() ); |
|
170 | + return (new CheckResult($context, $constraint, $status, $message)) |
|
171 | + ->withMetadata($result->getMetadata()); |
|
172 | 172 | } |
173 | 173 | |
174 | - public function checkConstraintParameters( Constraint $constraint ): array { |
|
174 | + public function checkConstraintParameters(Constraint $constraint): array { |
|
175 | 175 | $constraintParameters = $constraint->getConstraintParameters(); |
176 | 176 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
177 | 177 | $exceptions = []; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $constraintParameters, |
181 | 181 | $constraintTypeItemId |
182 | 182 | ); |
183 | - } catch ( ConstraintParameterException $e ) { |
|
183 | + } catch (ConstraintParameterException $e) { |
|
184 | 184 | $exceptions[] = $e; |
185 | 185 | } |
186 | 186 | try { |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $constraintParameters, |
189 | 189 | $constraintTypeItemId |
190 | 190 | ); |
191 | - } catch ( ConstraintParameterException $e ) { |
|
191 | + } catch (ConstraintParameterException $e) { |
|
192 | 192 | $exceptions[] = $e; |
193 | 193 | } |
194 | 194 | return $exceptions; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param string|false $dbName Database name ($domain for ILoadBalancer methods). |
30 | 30 | * @param LoggerInterface|null $logger |
31 | 31 | */ |
32 | - public function __construct( ILoadBalancer $lb, $dbName, ?LoggerInterface $logger = null ) { |
|
32 | + public function __construct(ILoadBalancer $lb, $dbName, ?LoggerInterface $logger = null) { |
|
33 | 33 | $this->lb = $lb; |
34 | 34 | $this->dbName = $dbName; |
35 | 35 | $this->logger = $logger ?? new NullLogger(); |
@@ -40,22 +40,22 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return Constraint[] |
42 | 42 | */ |
43 | - public function queryConstraintsForProperty( NumericPropertyId $propertyId ) { |
|
44 | - $dbr = $this->lb->getConnection( ILoadBalancer::DB_REPLICA, [], $this->dbName ); |
|
43 | + public function queryConstraintsForProperty(NumericPropertyId $propertyId) { |
|
44 | + $dbr = $this->lb->getConnection(ILoadBalancer::DB_REPLICA, [], $this->dbName); |
|
45 | 45 | |
46 | 46 | $results = $dbr->newSelectQueryBuilder() |
47 | - ->select( [ |
|
47 | + ->select([ |
|
48 | 48 | 'constraint_type_qid', |
49 | 49 | 'constraint_parameters', |
50 | 50 | 'constraint_guid', |
51 | 51 | 'pid', |
52 | - ] ) |
|
53 | - ->from( 'wbqc_constraints' ) |
|
54 | - ->where( [ 'pid' => $propertyId->getNumericId() ] ) |
|
55 | - ->caller( __METHOD__ ) |
|
52 | + ]) |
|
53 | + ->from('wbqc_constraints') |
|
54 | + ->where(['pid' => $propertyId->getNumericId()]) |
|
55 | + ->caller(__METHOD__) |
|
56 | 56 | ->fetchResultSet(); |
57 | 57 | |
58 | - return $this->convertToConstraints( $results ); |
|
58 | + return $this->convertToConstraints($results); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -63,25 +63,25 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return Constraint[] |
65 | 65 | */ |
66 | - private function convertToConstraints( IResultWrapper $results ) { |
|
66 | + private function convertToConstraints(IResultWrapper $results) { |
|
67 | 67 | $constraints = []; |
68 | - foreach ( $results as $result ) { |
|
68 | + foreach ($results as $result) { |
|
69 | 69 | $constraintTypeItemId = $result->constraint_type_qid; |
70 | - $constraintParameters = json_decode( $result->constraint_parameters, true ); |
|
70 | + $constraintParameters = json_decode($result->constraint_parameters, true); |
|
71 | 71 | |
72 | - if ( $constraintParameters === null ) { |
|
72 | + if ($constraintParameters === null) { |
|
73 | 73 | // T171295 |
74 | - $this->logger->warning( 'Constraint {constraintId} has invalid constraint parameters.', [ |
|
74 | + $this->logger->warning('Constraint {constraintId} has invalid constraint parameters.', [ |
|
75 | 75 | 'method' => __METHOD__, |
76 | 76 | 'constraintId' => $result->constraint_guid, |
77 | 77 | 'constraintParameters' => $result->constraint_parameters, |
78 | - ] ); |
|
79 | - $constraintParameters = [ '@error' => [ /* unknown */ ] ]; |
|
78 | + ]); |
|
79 | + $constraintParameters = ['@error' => [/* unknown */]]; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | $constraints[] = new Constraint( |
83 | 83 | $result->constraint_guid, |
84 | - NumericPropertyId::newFromNumber( $result->pid ), |
|
84 | + NumericPropertyId::newFromNumber($result->pid), |
|
85 | 85 | $constraintTypeItemId, |
86 | 86 | $constraintParameters |
87 | 87 | ); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport; |
6 | 6 | |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | public const ENTITY_LOOKUP_WITHOUT_CACHE = 'WBQC_EntityLookupWithoutCache'; |
27 | 27 | |
28 | 28 | /** @return mixed */ |
29 | - private static function getService( ?MediaWikiServices $services, string $name ) { |
|
29 | + private static function getService(?MediaWikiServices $services, string $name) { |
|
30 | 30 | $services ??= MediaWikiServices::getInstance(); |
31 | - return $services->getService( $name ); |
|
31 | + return $services->getService($name); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * this lookup ignores exceptions (such as unresolved redirects, T93273), |
39 | 39 | * as it is more convenient to treat them all as missing entities in WBQC. |
40 | 40 | */ |
41 | - public static function getEntityLookup( ?MediaWikiServices $services = null ): EntityLookup { |
|
42 | - return self::getService( $services, self::ENTITY_LOOKUP ); |
|
41 | + public static function getEntityLookup(?MediaWikiServices $services = null): EntityLookup { |
|
42 | + return self::getService($services, self::ENTITY_LOOKUP); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * were exceeding the request memory limit when they were all added to the cache (T227450). |
50 | 50 | * Also, like {@link self::getEntityLookup()}, this lookup ignores exceptions. |
51 | 51 | */ |
52 | - public static function getEntityLookupWithoutCache( ?MediaWikiServices $services = null ): EntityLookup { |
|
53 | - return self::getService( $services, self::ENTITY_LOOKUP_WITHOUT_CACHE ); |
|
52 | + public static function getEntityLookupWithoutCache(?MediaWikiServices $services = null): EntityLookup { |
|
53 | + return self::getService($services, self::ENTITY_LOOKUP_WITHOUT_CACHE); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | } |
@@ -45,257 +45,257 @@ |
||
45 | 45 | public const LABEL_IN_LANGUAGE_CHECKER = 'WBQC_LabelInLanguageChecker'; |
46 | 46 | |
47 | 47 | /** @return mixed */ |
48 | - private static function getService( ?MediaWikiServices $services, string $name ) { |
|
48 | + private static function getService(?MediaWikiServices $services, string $name) { |
|
49 | 49 | $services ??= MediaWikiServices::getInstance(); |
50 | - return $services->getService( $name ); |
|
50 | + return $services->getService($name); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @param MediaWikiServices|null $services |
55 | 55 | * @return ConstraintChecker |
56 | 56 | */ |
57 | - public static function getConflictsWithChecker( ?MediaWikiServices $services = null ) { |
|
58 | - return self::getService( $services, self::CONFLICTS_WITH_CHECKER ); |
|
57 | + public static function getConflictsWithChecker(?MediaWikiServices $services = null) { |
|
58 | + return self::getService($services, self::CONFLICTS_WITH_CHECKER); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @param MediaWikiServices|null $services |
63 | 63 | * @return ConstraintChecker |
64 | 64 | */ |
65 | - public static function getItemChecker( ?MediaWikiServices $services = null ) { |
|
66 | - return self::getService( $services, self::ITEM_CHECKER ); |
|
65 | + public static function getItemChecker(?MediaWikiServices $services = null) { |
|
66 | + return self::getService($services, self::ITEM_CHECKER); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
70 | 70 | * @param MediaWikiServices|null $services |
71 | 71 | * @return ConstraintChecker |
72 | 72 | */ |
73 | - public static function getTargetRequiredClaimChecker( ?MediaWikiServices $services = null ) { |
|
74 | - return self::getService( $services, self::TARGET_REQUIRED_CLAIM_CHECKER ); |
|
73 | + public static function getTargetRequiredClaimChecker(?MediaWikiServices $services = null) { |
|
74 | + return self::getService($services, self::TARGET_REQUIRED_CLAIM_CHECKER); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @param MediaWikiServices|null $services |
79 | 79 | * @return ConstraintChecker |
80 | 80 | */ |
81 | - public static function getSymmetricChecker( ?MediaWikiServices $services = null ) { |
|
82 | - return self::getService( $services, self::SYMMETRIC_CHECKER ); |
|
81 | + public static function getSymmetricChecker(?MediaWikiServices $services = null) { |
|
82 | + return self::getService($services, self::SYMMETRIC_CHECKER); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
86 | 86 | * @param MediaWikiServices|null $services |
87 | 87 | * @return ConstraintChecker |
88 | 88 | */ |
89 | - public static function getInverseChecker( ?MediaWikiServices $services = null ) { |
|
90 | - return self::getService( $services, self::INVERSE_CHECKER ); |
|
89 | + public static function getInverseChecker(?MediaWikiServices $services = null) { |
|
90 | + return self::getService($services, self::INVERSE_CHECKER); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * @param MediaWikiServices|null $services |
95 | 95 | * @return ConstraintChecker |
96 | 96 | */ |
97 | - public static function getQualifierChecker( ?MediaWikiServices $services = null ) { |
|
98 | - return self::getService( $services, self::QUALIFIER_CHECKER ); |
|
97 | + public static function getQualifierChecker(?MediaWikiServices $services = null) { |
|
98 | + return self::getService($services, self::QUALIFIER_CHECKER); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
102 | 102 | * @param MediaWikiServices|null $services |
103 | 103 | * @return ConstraintChecker |
104 | 104 | */ |
105 | - public static function getQualifiersChecker( ?MediaWikiServices $services = null ) { |
|
106 | - return self::getService( $services, self::QUALIFIERS_CHECKER ); |
|
105 | + public static function getQualifiersChecker(?MediaWikiServices $services = null) { |
|
106 | + return self::getService($services, self::QUALIFIERS_CHECKER); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @param MediaWikiServices|null $services |
111 | 111 | * @return ConstraintChecker |
112 | 112 | */ |
113 | - public static function getMandatoryQualifiersChecker( ?MediaWikiServices $services = null ) { |
|
114 | - return self::getService( $services, self::MANDATORY_QUALIFIERS_CHECKER ); |
|
113 | + public static function getMandatoryQualifiersChecker(?MediaWikiServices $services = null) { |
|
114 | + return self::getService($services, self::MANDATORY_QUALIFIERS_CHECKER); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | 118 | * @param MediaWikiServices|null $services |
119 | 119 | * @return ConstraintChecker |
120 | 120 | */ |
121 | - public static function getRangeChecker( ?MediaWikiServices $services = null ) { |
|
122 | - return self::getService( $services, self::RANGE_CHECKER ); |
|
121 | + public static function getRangeChecker(?MediaWikiServices $services = null) { |
|
122 | + return self::getService($services, self::RANGE_CHECKER); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | 126 | * @param MediaWikiServices|null $services |
127 | 127 | * @return ConstraintChecker |
128 | 128 | */ |
129 | - public static function getDiffWithinRangeChecker( ?MediaWikiServices $services = null ) { |
|
130 | - return self::getService( $services, self::DIFF_WITHIN_RANGE_CHECKER ); |
|
129 | + public static function getDiffWithinRangeChecker(?MediaWikiServices $services = null) { |
|
130 | + return self::getService($services, self::DIFF_WITHIN_RANGE_CHECKER); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
134 | 134 | * @param MediaWikiServices|null $services |
135 | 135 | * @return ConstraintChecker |
136 | 136 | */ |
137 | - public static function getTypeChecker( ?MediaWikiServices $services = null ) { |
|
138 | - return self::getService( $services, self::TYPE_CHECKER ); |
|
137 | + public static function getTypeChecker(?MediaWikiServices $services = null) { |
|
138 | + return self::getService($services, self::TYPE_CHECKER); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
142 | 142 | * @param MediaWikiServices|null $services |
143 | 143 | * @return ConstraintChecker |
144 | 144 | */ |
145 | - public static function getValueTypeChecker( ?MediaWikiServices $services = null ) { |
|
146 | - return self::getService( $services, self::VALUE_TYPE_CHECKER ); |
|
145 | + public static function getValueTypeChecker(?MediaWikiServices $services = null) { |
|
146 | + return self::getService($services, self::VALUE_TYPE_CHECKER); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
150 | 150 | * @param MediaWikiServices|null $services |
151 | 151 | * @return ConstraintChecker |
152 | 152 | */ |
153 | - public static function getSingleValueChecker( ?MediaWikiServices $services = null ) { |
|
154 | - return self::getService( $services, self::SINGLE_VALUE_CHECKER ); |
|
153 | + public static function getSingleValueChecker(?MediaWikiServices $services = null) { |
|
154 | + return self::getService($services, self::SINGLE_VALUE_CHECKER); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
158 | 158 | * @param MediaWikiServices|null $services |
159 | 159 | * @return ConstraintChecker |
160 | 160 | */ |
161 | - public static function getMultiValueChecker( ?MediaWikiServices $services = null ) { |
|
162 | - return self::getService( $services, self::MULTI_VALUE_CHECKER ); |
|
161 | + public static function getMultiValueChecker(?MediaWikiServices $services = null) { |
|
162 | + return self::getService($services, self::MULTI_VALUE_CHECKER); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | 166 | * @param MediaWikiServices|null $services |
167 | 167 | * @return ConstraintChecker |
168 | 168 | */ |
169 | - public static function getUniqueValueChecker( ?MediaWikiServices $services = null ) { |
|
170 | - return self::getService( $services, self::UNIQUE_VALUE_CHECKER ); |
|
169 | + public static function getUniqueValueChecker(?MediaWikiServices $services = null) { |
|
170 | + return self::getService($services, self::UNIQUE_VALUE_CHECKER); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
174 | 174 | * @param MediaWikiServices|null $services |
175 | 175 | * @return ConstraintChecker |
176 | 176 | */ |
177 | - public static function getFormatChecker( ?MediaWikiServices $services = null ) { |
|
178 | - return self::getService( $services, self::FORMAT_CHECKER ); |
|
177 | + public static function getFormatChecker(?MediaWikiServices $services = null) { |
|
178 | + return self::getService($services, self::FORMAT_CHECKER); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
182 | 182 | * @param MediaWikiServices|null $services |
183 | 183 | * @return ConstraintChecker |
184 | 184 | */ |
185 | - public static function getCommonsLinkChecker( ?MediaWikiServices $services = null ) { |
|
186 | - return self::getService( $services, self::COMMONS_LINK_CHECKER ); |
|
185 | + public static function getCommonsLinkChecker(?MediaWikiServices $services = null) { |
|
186 | + return self::getService($services, self::COMMONS_LINK_CHECKER); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
190 | 190 | * @param MediaWikiServices|null $services |
191 | 191 | * @return ConstraintChecker |
192 | 192 | */ |
193 | - public static function getOneOfChecker( ?MediaWikiServices $services = null ) { |
|
194 | - return self::getService( $services, self::ONE_OF_CHECKER ); |
|
193 | + public static function getOneOfChecker(?MediaWikiServices $services = null) { |
|
194 | + return self::getService($services, self::ONE_OF_CHECKER); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
198 | 198 | * @param MediaWikiServices|null $services |
199 | 199 | * @return ConstraintChecker |
200 | 200 | */ |
201 | - public static function getValueOnlyChecker( ?MediaWikiServices $services = null ) { |
|
202 | - return self::getService( $services, self::VALUE_ONLY_CHECKER ); |
|
201 | + public static function getValueOnlyChecker(?MediaWikiServices $services = null) { |
|
202 | + return self::getService($services, self::VALUE_ONLY_CHECKER); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
206 | 206 | * @param MediaWikiServices|null $services |
207 | 207 | * @return ConstraintChecker |
208 | 208 | */ |
209 | - public static function getReferenceChecker( ?MediaWikiServices $services = null ) { |
|
210 | - return self::getService( $services, self::REFERENCE_CHECKER ); |
|
209 | + public static function getReferenceChecker(?MediaWikiServices $services = null) { |
|
210 | + return self::getService($services, self::REFERENCE_CHECKER); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
214 | 214 | * @param MediaWikiServices|null $services |
215 | 215 | * @return ConstraintChecker |
216 | 216 | */ |
217 | - public static function getNoBoundsChecker( ?MediaWikiServices $services = null ) { |
|
218 | - return self::getService( $services, self::NO_BOUNDS_CHECKER ); |
|
217 | + public static function getNoBoundsChecker(?MediaWikiServices $services = null) { |
|
218 | + return self::getService($services, self::NO_BOUNDS_CHECKER); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
222 | 222 | * @param MediaWikiServices|null $services |
223 | 223 | * @return ConstraintChecker |
224 | 224 | */ |
225 | - public static function getAllowedUnitsChecker( ?MediaWikiServices $services = null ) { |
|
226 | - return self::getService( $services, self::ALLOWED_UNITS_CHECKER ); |
|
225 | + public static function getAllowedUnitsChecker(?MediaWikiServices $services = null) { |
|
226 | + return self::getService($services, self::ALLOWED_UNITS_CHECKER); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
230 | 230 | * @param MediaWikiServices|null $services |
231 | 231 | * @return ConstraintChecker |
232 | 232 | */ |
233 | - public static function getSingleBestValueChecker( ?MediaWikiServices $services = null ) { |
|
234 | - return self::getService( $services, self::SINGLE_BEST_VALUE_CHECKER ); |
|
233 | + public static function getSingleBestValueChecker(?MediaWikiServices $services = null) { |
|
234 | + return self::getService($services, self::SINGLE_BEST_VALUE_CHECKER); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
238 | 238 | * @param MediaWikiServices|null $services |
239 | 239 | * @return ConstraintChecker |
240 | 240 | */ |
241 | - public static function getEntityTypeChecker( ?MediaWikiServices $services = null ) { |
|
242 | - return self::getService( $services, self::ENTITY_TYPE_CHECKER ); |
|
241 | + public static function getEntityTypeChecker(?MediaWikiServices $services = null) { |
|
242 | + return self::getService($services, self::ENTITY_TYPE_CHECKER); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | /** |
246 | 246 | * @param MediaWikiServices|null $services |
247 | 247 | * @return ConstraintChecker |
248 | 248 | */ |
249 | - public static function getNoneOfChecker( ?MediaWikiServices $services = null ) { |
|
250 | - return self::getService( $services, self::NONE_OF_CHECKER ); |
|
249 | + public static function getNoneOfChecker(?MediaWikiServices $services = null) { |
|
250 | + return self::getService($services, self::NONE_OF_CHECKER); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
254 | 254 | * @param MediaWikiServices|null $services |
255 | 255 | * @return ConstraintChecker |
256 | 256 | */ |
257 | - public static function getIntegerChecker( ?MediaWikiServices $services = null ) { |
|
258 | - return self::getService( $services, self::INTEGER_CHECKER ); |
|
257 | + public static function getIntegerChecker(?MediaWikiServices $services = null) { |
|
258 | + return self::getService($services, self::INTEGER_CHECKER); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
262 | 262 | * @param MediaWikiServices|null $services |
263 | 263 | * @return ConstraintChecker |
264 | 264 | */ |
265 | - public static function getCitationNeededChecker( ?MediaWikiServices $services = null ) { |
|
266 | - return self::getService( $services, self::CITATION_NEEDED_CHECKER ); |
|
265 | + public static function getCitationNeededChecker(?MediaWikiServices $services = null) { |
|
266 | + return self::getService($services, self::CITATION_NEEDED_CHECKER); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
270 | 270 | * @param MediaWikiServices|null $services |
271 | 271 | * @return ConstraintChecker |
272 | 272 | */ |
273 | - public static function getPropertyScopeChecker( ?MediaWikiServices $services = null ) { |
|
274 | - return self::getService( $services, self::PROPERTY_SCOPE_CHECKER ); |
|
273 | + public static function getPropertyScopeChecker(?MediaWikiServices $services = null) { |
|
274 | + return self::getService($services, self::PROPERTY_SCOPE_CHECKER); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
278 | 278 | * @param MediaWikiServices|null $services |
279 | 279 | * @return ConstraintChecker |
280 | 280 | */ |
281 | - public static function getContemporaryChecker( ?MediaWikiServices $services = null ) { |
|
282 | - return self::getService( $services, self::CONTEMPORARY_CHECKER ); |
|
281 | + public static function getContemporaryChecker(?MediaWikiServices $services = null) { |
|
282 | + return self::getService($services, self::CONTEMPORARY_CHECKER); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
286 | 286 | * @param MediaWikiServices|null $services |
287 | 287 | * @return LanguageChecker |
288 | 288 | */ |
289 | - public static function getLexemeLanguageChecker( ?MediaWikiServices $services = null ) { |
|
290 | - return self::getService( $services, self::LEXEME_LANGUAGE_CHECKER ); |
|
289 | + public static function getLexemeLanguageChecker(?MediaWikiServices $services = null) { |
|
290 | + return self::getService($services, self::LEXEME_LANGUAGE_CHECKER); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
294 | 294 | * @param MediaWikiServices|null $services |
295 | 295 | * @return LabelInLanguageChecker |
296 | 296 | */ |
297 | - public static function getLabelInLanguageChecker( ?MediaWikiServices $services = null ) { |
|
298 | - return self::getService( $services, self::LABEL_IN_LANGUAGE_CHECKER ); |
|
297 | + public static function getLabelInLanguageChecker(?MediaWikiServices $services = null) { |
|
298 | + return self::getService($services, self::LABEL_IN_LANGUAGE_CHECKER); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @return string |
29 | 29 | */ |
30 | 30 | public function getTime() { |
31 | - return gmdate( '+Y-m-d\TH:i:s\Z' ); |
|
31 | + return gmdate('+Y-m-d\TH:i:s\Z'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** @inheritDoc */ |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | |
44 | 44 | /** @inheritDoc */ |
45 | 45 | public function getArrayValue() { |
46 | - throw new LogicException( 'NowValue should never be serialized' ); |
|
46 | + throw new LogicException('NowValue should never be serialized'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** @inheritDoc */ |
50 | - public function equals( $value ) { |
|
51 | - return get_class( $value ) === self::class; |
|
50 | + public function equals($value) { |
|
51 | + return get_class($value) === self::class; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | } |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | return $ret; |
33 | 33 | } |
34 | 34 | |
35 | - public static function ofCachingMetadata( CachingMetadata $cachingMetadata ): self { |
|
35 | + public static function ofCachingMetadata(CachingMetadata $cachingMetadata): self { |
|
36 | 36 | $ret = new self; |
37 | 37 | $ret->cachingMetadata = $cachingMetadata; |
38 | 38 | $ret->dependencyMetadata = DependencyMetadata::blank(); |
39 | 39 | return $ret; |
40 | 40 | } |
41 | 41 | |
42 | - public static function ofDependencyMetadata( DependencyMetadata $dependencyMetadata ): self { |
|
42 | + public static function ofDependencyMetadata(DependencyMetadata $dependencyMetadata): self { |
|
43 | 43 | $ret = new self; |
44 | 44 | $ret->cachingMetadata = CachingMetadata::fresh(); |
45 | 45 | $ret->dependencyMetadata = $dependencyMetadata; |
@@ -50,17 +50,17 @@ discard block |
||
50 | 50 | * @param self[] $metadatas |
51 | 51 | * @return self |
52 | 52 | */ |
53 | - public static function merge( array $metadatas ) { |
|
54 | - Assert::parameterElementType( self::class, $metadatas, '$metadatas' ); |
|
53 | + public static function merge(array $metadatas) { |
|
54 | + Assert::parameterElementType(self::class, $metadatas, '$metadatas'); |
|
55 | 55 | $cachingMetadatas = []; |
56 | 56 | $dependencyMetadatas = []; |
57 | - foreach ( $metadatas as $metadata ) { |
|
57 | + foreach ($metadatas as $metadata) { |
|
58 | 58 | $cachingMetadatas[] = $metadata->cachingMetadata; |
59 | 59 | $dependencyMetadatas[] = $metadata->dependencyMetadata; |
60 | 60 | } |
61 | 61 | $ret = new self; |
62 | - $ret->cachingMetadata = CachingMetadata::merge( $cachingMetadatas ); |
|
63 | - $ret->dependencyMetadata = DependencyMetadata::merge( $dependencyMetadatas ); |
|
62 | + $ret->cachingMetadata = CachingMetadata::merge($cachingMetadatas); |
|
63 | + $ret->dependencyMetadata = DependencyMetadata::merge($dependencyMetadatas); |
|
64 | 64 | return $ret; |
65 | 65 | } |
66 | 66 |
@@ -43,95 +43,95 @@ |
||
43 | 43 | public const VIOLATION_MESSAGE_RENDERER_FACTORY = 'WBQC_ViolationMessageRendererFactory'; |
44 | 44 | |
45 | 45 | /** @return mixed */ |
46 | - private static function getService( ?MediaWikiServices $services, string $name ) { |
|
46 | + private static function getService(?MediaWikiServices $services, string $name) { |
|
47 | 47 | $services ??= MediaWikiServices::getInstance(); |
48 | - return $services->getService( $name ); |
|
48 | + return $services->getService($name); |
|
49 | 49 | } |
50 | 50 | |
51 | - public static function getLogger( ?MediaWikiServices $services = null ): LoggerInterface { |
|
52 | - return self::getService( $services, self::LOGGER ); |
|
51 | + public static function getLogger(?MediaWikiServices $services = null): LoggerInterface { |
|
52 | + return self::getService($services, self::LOGGER); |
|
53 | 53 | } |
54 | 54 | |
55 | - public static function getLoggingHelper( ?MediaWikiServices $services = null ): LoggingHelper { |
|
56 | - return self::getService( $services, self::LOGGING_HELPER ); |
|
55 | + public static function getLoggingHelper(?MediaWikiServices $services = null): LoggingHelper { |
|
56 | + return self::getService($services, self::LOGGING_HELPER); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | public static function getConstraintStore( |
60 | 60 | ?MediaWikiServices $services = null |
61 | 61 | ): ConstraintStore { |
62 | - return self::getService( $services, self::CONSTRAINT_STORE ); |
|
62 | + return self::getService($services, self::CONSTRAINT_STORE); |
|
63 | 63 | } |
64 | 64 | |
65 | - public static function getConstraintLookup( ?MediaWikiServices $services = null ): ConstraintLookup { |
|
66 | - return self::getService( $services, self::CONSTRAINT_LOOKUP ); |
|
65 | + public static function getConstraintLookup(?MediaWikiServices $services = null): ConstraintLookup { |
|
66 | + return self::getService($services, self::CONSTRAINT_LOOKUP); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | public static function getCheckResultSerializer( |
70 | 70 | ?MediaWikiServices $services = null |
71 | 71 | ): CheckResultSerializer { |
72 | - return self::getService( $services, self::CHECK_RESULT_SERIALIZER ); |
|
72 | + return self::getService($services, self::CHECK_RESULT_SERIALIZER); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | public static function getCheckResultDeserializer( |
76 | 76 | ?MediaWikiServices $services = null |
77 | 77 | ): CheckResultDeserializer { |
78 | - return self::getService( $services, self::CHECK_RESULT_DESERIALIZER ); |
|
78 | + return self::getService($services, self::CHECK_RESULT_DESERIALIZER); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | public static function getViolationMessageSerializer( |
82 | 82 | ?MediaWikiServices $services = null |
83 | 83 | ): ViolationMessageSerializer { |
84 | - return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER ); |
|
84 | + return self::getService($services, self::VIOLATION_MESSAGE_SERIALIZER); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | public static function getViolationMessageDeserializer( |
88 | 88 | ?MediaWikiServices $services = null |
89 | 89 | ): ViolationMessageDeserializer { |
90 | - return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER ); |
|
90 | + return self::getService($services, self::VIOLATION_MESSAGE_DESERIALIZER); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | public static function getConstraintParameterParser( |
94 | 94 | ?MediaWikiServices $services = null |
95 | 95 | ): ConstraintParameterParser { |
96 | - return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER ); |
|
96 | + return self::getService($services, self::CONSTRAINT_PARAMETER_PARSER); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | public static function getConnectionCheckerHelper( |
100 | 100 | ?MediaWikiServices $services = null |
101 | 101 | ): ConnectionCheckerHelper { |
102 | - return self::getService( $services, self::CONNECTION_CHECKER_HELPER ); |
|
102 | + return self::getService($services, self::CONNECTION_CHECKER_HELPER); |
|
103 | 103 | } |
104 | 104 | |
105 | - public static function getRangeCheckerHelper( ?MediaWikiServices $services = null ): RangeCheckerHelper { |
|
106 | - return self::getService( $services, self::RANGE_CHECKER_HELPER ); |
|
105 | + public static function getRangeCheckerHelper(?MediaWikiServices $services = null): RangeCheckerHelper { |
|
106 | + return self::getService($services, self::RANGE_CHECKER_HELPER); |
|
107 | 107 | } |
108 | 108 | |
109 | - public static function getSparqlHelper( ?MediaWikiServices $services = null ): SparqlHelper { |
|
110 | - return self::getService( $services, self::SPARQL_HELPER ); |
|
109 | + public static function getSparqlHelper(?MediaWikiServices $services = null): SparqlHelper { |
|
110 | + return self::getService($services, self::SPARQL_HELPER); |
|
111 | 111 | } |
112 | 112 | |
113 | - public static function getTypeCheckerHelper( ?MediaWikiServices $services = null ): TypeCheckerHelper { |
|
114 | - return self::getService( $services, self::TYPE_CHECKER_HELPER ); |
|
113 | + public static function getTypeCheckerHelper(?MediaWikiServices $services = null): TypeCheckerHelper { |
|
114 | + return self::getService($services, self::TYPE_CHECKER_HELPER); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | public static function getDelegatingConstraintChecker( |
118 | 118 | ?MediaWikiServices $services = null |
119 | 119 | ): DelegatingConstraintChecker { |
120 | - return self::getService( $services, self::DELEGATING_CONSTRAINT_CHECKER ); |
|
120 | + return self::getService($services, self::DELEGATING_CONSTRAINT_CHECKER); |
|
121 | 121 | } |
122 | 122 | |
123 | - public static function getResultsSource( ?MediaWikiServices $services = null ): ResultsSource { |
|
124 | - return self::getService( $services, self::RESULTS_SOURCE ); |
|
123 | + public static function getResultsSource(?MediaWikiServices $services = null): ResultsSource { |
|
124 | + return self::getService($services, self::RESULTS_SOURCE); |
|
125 | 125 | } |
126 | 126 | |
127 | - public static function getExpiryLock( ?MediaWikiServices $services = null ): ExpiryLock { |
|
128 | - return self::getService( $services, self::EXPIRY_LOCK ); |
|
127 | + public static function getExpiryLock(?MediaWikiServices $services = null): ExpiryLock { |
|
128 | + return self::getService($services, self::EXPIRY_LOCK); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | public static function getViolationMessageRendererFactory( |
132 | 132 | ?MediaWikiServices $services = null |
133 | 133 | ): ViolationMessageRendererFactory { |
134 | - return self::getService( $services, self::VIOLATION_MESSAGE_RENDERER_FACTORY ); |
|
134 | + return self::getService($services, self::VIOLATION_MESSAGE_RENDERER_FACTORY); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | } |
@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | * then using the main DBLoadBalancer service may be incorrect. |
25 | 25 | * @param string|false $dbName Database name ($domain for ILoadBalancer methods). |
26 | 26 | */ |
27 | - public function __construct( ILoadBalancer $lb, $dbName ) { |
|
27 | + public function __construct(ILoadBalancer $lb, $dbName) { |
|
28 | 28 | $this->lb = $lb; |
29 | 29 | $this->dbName = $dbName; |
30 | 30 | } |
31 | 31 | |
32 | - private function encodeConstraintParameters( array $constraintParameters ): string { |
|
33 | - $json = json_encode( $constraintParameters, JSON_FORCE_OBJECT ); |
|
32 | + private function encodeConstraintParameters(array $constraintParameters): string { |
|
33 | + $json = json_encode($constraintParameters, JSON_FORCE_OBJECT); |
|
34 | 34 | |
35 | - if ( strlen( $json ) > 50000 ) { |
|
36 | - $json = json_encode( [ '@error' => [ 'toolong' => true ] ] ); |
|
35 | + if (strlen($json) > 50000) { |
|
36 | + $json = json_encode(['@error' => ['toolong' => true]]); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | return $json; |
@@ -44,28 +44,28 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @throws DBUnexpectedError |
46 | 46 | */ |
47 | - public function insertBatch( array $constraints ) { |
|
48 | - if ( !$constraints ) { |
|
47 | + public function insertBatch(array $constraints) { |
|
48 | + if (!$constraints) { |
|
49 | 49 | return; |
50 | 50 | } |
51 | 51 | |
52 | 52 | $accumulator = array_map( |
53 | - function ( Constraint $constraint ) { |
|
53 | + function(Constraint $constraint) { |
|
54 | 54 | return [ |
55 | 55 | 'constraint_guid' => $constraint->getConstraintId(), |
56 | 56 | 'pid' => $constraint->getPropertyId()->getNumericId(), |
57 | 57 | 'constraint_type_qid' => $constraint->getConstraintTypeItemId(), |
58 | - 'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() ), |
|
58 | + 'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters()), |
|
59 | 59 | ]; |
60 | 60 | }, |
61 | 61 | $constraints |
62 | 62 | ); |
63 | 63 | |
64 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_PRIMARY, [], $this->dbName ); |
|
64 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_PRIMARY, [], $this->dbName); |
|
65 | 65 | $dbw->newInsertQueryBuilder() |
66 | - ->insertInto( 'wbqc_constraints' ) |
|
67 | - ->rows( $accumulator ) |
|
68 | - ->caller( __METHOD__ ) |
|
66 | + ->insertInto('wbqc_constraints') |
|
67 | + ->rows($accumulator) |
|
68 | + ->caller(__METHOD__) |
|
69 | 69 | ->execute(); |
70 | 70 | } |
71 | 71 | |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @throws DBUnexpectedError |
78 | 78 | */ |
79 | - public function deleteForProperty( NumericPropertyId $propertyId ) { |
|
80 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_PRIMARY, [], $this->dbName ); |
|
79 | + public function deleteForProperty(NumericPropertyId $propertyId) { |
|
80 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_PRIMARY, [], $this->dbName); |
|
81 | 81 | $dbw->newDeleteQueryBuilder() |
82 | - ->deleteFrom( 'wbqc_constraints' ) |
|
83 | - ->where( [ |
|
82 | + ->deleteFrom('wbqc_constraints') |
|
83 | + ->where([ |
|
84 | 84 | 'pid' => $propertyId->getNumericId(), |
85 | - ] ) |
|
86 | - ->caller( __METHOD__ ) |
|
85 | + ]) |
|
86 | + ->caller(__METHOD__) |
|
87 | 87 | ->execute(); |
88 | 88 | } |
89 | 89 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Context; |
6 | 6 | |
@@ -61,6 +61,6 @@ discard block |
||
61 | 61 | * @param ?array $result |
62 | 62 | * @param array[] &$container |
63 | 63 | */ |
64 | - public function storeCheckResultInArray( ?array $result, array &$container ): void; |
|
64 | + public function storeCheckResultInArray(?array $result, array &$container): void; |
|
65 | 65 | |
66 | 66 | } |