@@ -82,22 +82,22 @@ discard block |
||
82 | 82 | * @return array first element is the namespace number (default namespace for TitleParser), |
83 | 83 | * second element is a string to prepend to the title before giving it to the TitleParser |
84 | 84 | */ |
85 | - private function getCommonsNamespace( $namespace ) { |
|
85 | + private function getCommonsNamespace($namespace) { |
|
86 | 86 | // for namespace numbers see mediawiki-config repo, wmf-config/InitialiseSettings.php, |
87 | 87 | // 'wgExtraNamespaces' key, 'commonswiki' subkey |
88 | - switch ( $namespace ) { |
|
88 | + switch ($namespace) { |
|
89 | 89 | case '': |
90 | - return [ NS_MAIN, '' ]; |
|
90 | + return [NS_MAIN, '']; |
|
91 | 91 | case 'Creator': |
92 | - return [ 100, '' ]; |
|
92 | + return [100, '']; |
|
93 | 93 | case 'TimedText': |
94 | - return [ 102, '' ]; |
|
94 | + return [102, '']; |
|
95 | 95 | case 'Sequence': |
96 | - return [ 104, '' ]; |
|
96 | + return [104, '']; |
|
97 | 97 | case 'Institution': |
98 | - return [ 106, '' ]; |
|
98 | + return [106, '']; |
|
99 | 99 | default: |
100 | - return [ NS_MAIN, $namespace . ':' ]; |
|
100 | + return [NS_MAIN, $namespace.':']; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
@@ -110,17 +110,17 @@ discard block |
||
110 | 110 | * @throws ConstraintParameterException |
111 | 111 | * @return CheckResult |
112 | 112 | */ |
113 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
113 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
114 | 114 | $parameters = []; |
115 | 115 | $constraintParameters = $constraint->getConstraintParameters(); |
116 | - $namespace = $this->constraintParameterParser->parseNamespaceParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
117 | - $parameters['namespace'] = [ $namespace ]; |
|
116 | + $namespace = $this->constraintParameterParser->parseNamespaceParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
117 | + $parameters['namespace'] = [$namespace]; |
|
118 | 118 | |
119 | 119 | $snak = $context->getSnak(); |
120 | 120 | |
121 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
121 | + if (!$snak instanceof PropertyValueSnak) { |
|
122 | 122 | // nothing to check |
123 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, '' ); |
|
123 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_COMPLIANCE, ''); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | $dataValue = $snak->getDataValue(); |
@@ -130,49 +130,49 @@ discard block |
||
130 | 130 | * type of $dataValue for properties with 'Commons link' constraint has to be 'string' |
131 | 131 | * parameter $namespace can be null, works for commons galleries |
132 | 132 | */ |
133 | - if ( $dataValue->getType() !== 'string' ) { |
|
134 | - $message = wfMessage( "wbqc-violation-message-value-needed-of-type" ) |
|
133 | + if ($dataValue->getType() !== 'string') { |
|
134 | + $message = wfMessage("wbqc-violation-message-value-needed-of-type") |
|
135 | 135 | ->rawParams( |
136 | - $this->constraintParameterRenderer->formatItemId( $constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM ), |
|
137 | - wfMessage( 'datatypes-type-string' )->escaped() |
|
136 | + $this->constraintParameterRenderer->formatItemId($constraint->getConstraintTypeItemId(), Role::CONSTRAINT_TYPE_ITEM), |
|
137 | + wfMessage('datatypes-type-string')->escaped() |
|
138 | 138 | ) |
139 | 139 | ->escaped(); |
140 | - return new CheckResult( $context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message ); |
|
140 | + return new CheckResult($context, $constraint, $parameters, CheckResult::STATUS_VIOLATION, $message); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | $commonsLink = $dataValue->getValue(); |
144 | 144 | |
145 | 145 | try { |
146 | - if ( !$this->commonsLinkIsWellFormed( $commonsLink ) ) { |
|
147 | - throw new MalformedTitleException( 'wbqc-violation-message-commons-link-not-well-formed', $commonsLink ); // caught below |
|
146 | + if (!$this->commonsLinkIsWellFormed($commonsLink)) { |
|
147 | + throw new MalformedTitleException('wbqc-violation-message-commons-link-not-well-formed', $commonsLink); // caught below |
|
148 | 148 | } |
149 | - list( $defaultNamespace, $prefix ) = $this->getCommonsNamespace( $namespace ); |
|
150 | - $title = $this->titleParser->parseTitle( $prefix . $commonsLink, $defaultNamespace ); |
|
151 | - if ( $this->pageExists( $title ) ) { |
|
149 | + list($defaultNamespace, $prefix) = $this->getCommonsNamespace($namespace); |
|
150 | + $title = $this->titleParser->parseTitle($prefix.$commonsLink, $defaultNamespace); |
|
151 | + if ($this->pageExists($title)) { |
|
152 | 152 | $message = ''; |
153 | 153 | $status = CheckResult::STATUS_COMPLIANCE; |
154 | 154 | } else { |
155 | - if ( $this->valueIncludesNamespace( $commonsLink, $namespace ) ) { |
|
156 | - throw new MalformedTitleException( 'wbqc-violation-message-commons-link-not-well-formed', $commonsLink ); // caught below |
|
155 | + if ($this->valueIncludesNamespace($commonsLink, $namespace)) { |
|
156 | + throw new MalformedTitleException('wbqc-violation-message-commons-link-not-well-formed', $commonsLink); // caught below |
|
157 | 157 | } else { |
158 | - $message = wfMessage( "wbqc-violation-message-commons-link-no-existent" )->escaped(); |
|
158 | + $message = wfMessage("wbqc-violation-message-commons-link-no-existent")->escaped(); |
|
159 | 159 | $status = CheckResult::STATUS_VIOLATION; |
160 | 160 | } |
161 | 161 | } |
162 | - } catch ( MalformedTitleException $e ) { |
|
163 | - $message = wfMessage( "wbqc-violation-message-commons-link-not-well-formed" )->escaped(); |
|
162 | + } catch (MalformedTitleException $e) { |
|
163 | + $message = wfMessage("wbqc-violation-message-commons-link-not-well-formed")->escaped(); |
|
164 | 164 | $status = CheckResult::STATUS_VIOLATION; |
165 | 165 | } |
166 | 166 | |
167 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
167 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
168 | 168 | } |
169 | 169 | |
170 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
170 | + public function checkConstraintParameters(Constraint $constraint) { |
|
171 | 171 | $constraintParameters = $constraint->getConstraintParameters(); |
172 | 172 | $exceptions = []; |
173 | 173 | try { |
174 | - $this->constraintParameterParser->parseNamespaceParameter( $constraintParameters, $constraint->getConstraintTypeItemId() ); |
|
175 | - } catch ( ConstraintParameterException $e ) { |
|
174 | + $this->constraintParameterParser->parseNamespaceParameter($constraintParameters, $constraint->getConstraintTypeItemId()); |
|
175 | + } catch (ConstraintParameterException $e) { |
|
176 | 176 | $exceptions[] = $e; |
177 | 177 | } |
178 | 178 | return $exceptions; |
@@ -183,19 +183,19 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return bool |
185 | 185 | */ |
186 | - private function pageExists( TitleValue $title ) { |
|
186 | + private function pageExists(TitleValue $title) { |
|
187 | 187 | $commonsWikiId = 'commonswiki'; |
188 | - if ( defined( 'MW_PHPUNIT_TEST' ) ) { |
|
188 | + if (defined('MW_PHPUNIT_TEST')) { |
|
189 | 189 | $commonsWikiId = false; |
190 | 190 | } |
191 | 191 | |
192 | - $dbLoadBalancer = wfGetLB( $commonsWikiId ); |
|
192 | + $dbLoadBalancer = wfGetLB($commonsWikiId); |
|
193 | 193 | $dbConnection = $dbLoadBalancer->getConnection( |
194 | 194 | DB_REPLICA, false, $commonsWikiId ); |
195 | - $row = $dbConnection->selectRow( 'page', '*', [ |
|
195 | + $row = $dbConnection->selectRow('page', '*', [ |
|
196 | 196 | 'page_title' => $title->getDBkey(), |
197 | 197 | 'page_namespace' => $title->getNamespace() |
198 | - ] ); |
|
198 | + ]); |
|
199 | 199 | |
200 | 200 | return $row !== false; |
201 | 201 | } |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return bool |
207 | 207 | */ |
208 | - private function commonsLinkIsWellFormed( $commonsLink ) { |
|
209 | - $toReplace = [ "_", "%20" ]; |
|
210 | - $compareString = trim( str_replace( $toReplace, '', $commonsLink ) ); |
|
208 | + private function commonsLinkIsWellFormed($commonsLink) { |
|
209 | + $toReplace = ["_", "%20"]; |
|
210 | + $compareString = trim(str_replace($toReplace, '', $commonsLink)); |
|
211 | 211 | return $commonsLink === $compareString; |
212 | 212 | } |
213 | 213 | |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @return bool |
222 | 222 | */ |
223 | - private function valueIncludesNamespace( $value, $namespace ) { |
|
223 | + private function valueIncludesNamespace($value, $namespace) { |
|
224 | 224 | return $namespace !== '' && |
225 | - strncasecmp( $value, $namespace . ':', strlen( $namespace ) + 1 ) === 0; |
|
225 | + strncasecmp($value, $namespace.':', strlen($namespace) + 1) === 0; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | protected $snak; |
25 | 25 | |
26 | - public function __construct( EntityDocument $entity, Snak $snak ) { |
|
26 | + public function __construct(EntityDocument $entity, Snak $snak) { |
|
27 | 27 | $this->entity = $entity; |
28 | 28 | $this->snak = $snak; |
29 | 29 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | Statement $statement, |
24 | 24 | Snak $snak |
25 | 25 | ) { |
26 | - parent::__construct( $entity, $snak ); |
|
26 | + parent::__construct($entity, $snak); |
|
27 | 27 | $this->statement = $statement; |
28 | 28 | } |
29 | 29 | |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | |
34 | 34 | public function getSnakGroup() { |
35 | 35 | $snaks = $this->statement->getQualifiers(); |
36 | - return array_values( $snaks->getArrayCopy() ); |
|
36 | + return array_values($snaks->getArrayCopy()); |
|
37 | 37 | } |
38 | 38 | |
39 | - protected function &getMainArray( array &$container ) { |
|
39 | + protected function &getMainArray(array &$container) { |
|
40 | 40 | $statementArray = &$this->getStatementArray( |
41 | 41 | $container, |
42 | 42 | $this->entity->getId()->getSerialization(), |
@@ -44,25 +44,25 @@ discard block |
||
44 | 44 | $this->statement->getGuid() |
45 | 45 | ); |
46 | 46 | |
47 | - if ( !array_key_exists( 'qualifiers', $statementArray ) ) { |
|
47 | + if (!array_key_exists('qualifiers', $statementArray)) { |
|
48 | 48 | $statementArray['qualifiers'] = []; |
49 | 49 | } |
50 | 50 | $qualifiersArray = &$statementArray['qualifiers']; |
51 | 51 | |
52 | 52 | $propertyId = $this->getSnak()->getPropertyId()->getSerialization(); |
53 | - if ( !array_key_exists( $propertyId, $qualifiersArray ) ) { |
|
53 | + if (!array_key_exists($propertyId, $qualifiersArray)) { |
|
54 | 54 | $qualifiersArray[$propertyId] = []; |
55 | 55 | } |
56 | 56 | $propertyArray = &$qualifiersArray[$propertyId]; |
57 | 57 | |
58 | - foreach ( $propertyArray as &$potentialQualifierArray ) { |
|
59 | - if ( $potentialQualifierArray['hash'] === $this->getSnak()->getHash() ) { |
|
58 | + foreach ($propertyArray as &$potentialQualifierArray) { |
|
59 | + if ($potentialQualifierArray['hash'] === $this->getSnak()->getHash()) { |
|
60 | 60 | $qualifierArray = &$potentialQualifierArray; |
61 | 61 | break; |
62 | 62 | } |
63 | 63 | } |
64 | - if ( !isset( $qualifierArray ) ) { |
|
65 | - $qualifierArray = [ 'hash' => $this->getSnak()->getHash() ]; |
|
64 | + if (!isset($qualifierArray)) { |
|
65 | + $qualifierArray = ['hash' => $this->getSnak()->getHash()]; |
|
66 | 66 | $propertyArray[] = &$qualifierArray; |
67 | 67 | } |
68 | 68 |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | Reference $reference, |
31 | 31 | Snak $snak |
32 | 32 | ) { |
33 | - parent::__construct( $entity, $snak ); |
|
33 | + parent::__construct($entity, $snak); |
|
34 | 34 | $this->statement = $statement; |
35 | 35 | $this->reference = $reference; |
36 | 36 | } |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | |
42 | 42 | public function getSnakGroup() { |
43 | 43 | $snaks = $this->reference->getSnaks(); |
44 | - return array_values( $snaks->getArrayCopy() ); |
|
44 | + return array_values($snaks->getArrayCopy()); |
|
45 | 45 | } |
46 | 46 | |
47 | - protected function &getMainArray( array &$container ) { |
|
47 | + protected function &getMainArray(array &$container) { |
|
48 | 48 | $statementArray = &$this->getStatementArray( |
49 | 49 | $container, |
50 | 50 | $this->entity->getId()->getSerialization(), |
@@ -52,38 +52,38 @@ discard block |
||
52 | 52 | $this->statement->getGuid() |
53 | 53 | ); |
54 | 54 | |
55 | - if ( !array_key_exists( 'references', $statementArray ) ) { |
|
55 | + if (!array_key_exists('references', $statementArray)) { |
|
56 | 56 | $statementArray['references'] = []; |
57 | 57 | } |
58 | 58 | $referencesArray = &$statementArray['references']; |
59 | 59 | |
60 | - foreach ( $referencesArray as &$potentialReferenceArray ) { |
|
61 | - if ( $potentialReferenceArray['hash'] === $this->reference->getHash() ) { |
|
60 | + foreach ($referencesArray as &$potentialReferenceArray) { |
|
61 | + if ($potentialReferenceArray['hash'] === $this->reference->getHash()) { |
|
62 | 62 | $referenceArray = &$potentialReferenceArray; |
63 | 63 | break; |
64 | 64 | } |
65 | 65 | } |
66 | - if ( !isset( $referenceArray ) ) { |
|
67 | - $referenceArray = [ 'hash' => $this->reference->getHash(), 'snaks' => [] ]; |
|
66 | + if (!isset($referenceArray)) { |
|
67 | + $referenceArray = ['hash' => $this->reference->getHash(), 'snaks' => []]; |
|
68 | 68 | $referencesArray[] = &$referenceArray; |
69 | 69 | } |
70 | 70 | |
71 | 71 | $snaksArray = &$referenceArray['snaks']; |
72 | 72 | |
73 | 73 | $propertyId = $this->getSnak()->getPropertyId()->getSerialization(); |
74 | - if ( !array_key_exists( $propertyId, $snaksArray ) ) { |
|
74 | + if (!array_key_exists($propertyId, $snaksArray)) { |
|
75 | 75 | $snaksArray[$propertyId] = []; |
76 | 76 | } |
77 | 77 | $propertyArray = &$snaksArray[$propertyId]; |
78 | 78 | |
79 | - foreach ( $propertyArray as &$potentialSnakArray ) { |
|
80 | - if ( $potentialSnakArray['hash'] === $this->getSnak()->getHash() ) { |
|
79 | + foreach ($propertyArray as &$potentialSnakArray) { |
|
80 | + if ($potentialSnakArray['hash'] === $this->getSnak()->getHash()) { |
|
81 | 81 | $snakArray = &$potentialSnakArray; |
82 | 82 | break; |
83 | 83 | } |
84 | 84 | } |
85 | - if ( !isset( $snakArray ) ) { |
|
86 | - $snakArray = [ 'hash' => $this->getSnak()->getHash() ]; |
|
85 | + if (!isset($snakArray)) { |
|
86 | + $snakArray = ['hash' => $this->getSnak()->getHash()]; |
|
87 | 87 | $propertyArray[] = &$snakArray; |
88 | 88 | } |
89 | 89 |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | */ |
21 | 21 | private $statement; |
22 | 22 | |
23 | - public function __construct( EntityDocument $entity, Statement $statement ) { |
|
24 | - Assert::parameterType( StatementListProvider::class, $entity, '$entity' ); |
|
25 | - parent::__construct( $entity, $statement->getMainSnak() ); |
|
23 | + public function __construct(EntityDocument $entity, Statement $statement) { |
|
24 | + Assert::parameterType(StatementListProvider::class, $entity, '$entity'); |
|
25 | + parent::__construct($entity, $statement->getMainSnak()); |
|
26 | 26 | |
27 | 27 | $this->statement = $statement; |
28 | 28 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | /** @var StatementList $statements */ |
44 | 44 | $statements = $this->entity->getStatements(); |
45 | 45 | return $statements |
46 | - ->getByRank( [ Statement::RANK_NORMAL, Statement::RANK_PREFERRED ] ) |
|
46 | + ->getByRank([Statement::RANK_NORMAL, Statement::RANK_PREFERRED]) |
|
47 | 47 | ->getMainSnaks(); |
48 | 48 | } |
49 | 49 | |
50 | - protected function &getMainArray( array &$container ) { |
|
50 | + protected function &getMainArray(array &$container) { |
|
51 | 51 | $statementArray = &$this->getStatementArray( |
52 | 52 | $container, |
53 | 53 | $this->entity->getId()->getSerialization(), |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | $this->statement->getGuid() |
56 | 56 | ); |
57 | 57 | |
58 | - if ( !array_key_exists( 'mainsnak', $statementArray ) ) { |
|
59 | - $statementArray['mainsnak'] = [ 'hash' => $this->statement->getMainSnak()->getHash() ]; |
|
58 | + if (!array_key_exists('mainsnak', $statementArray)) { |
|
59 | + $statementArray['mainsnak'] = ['hash' => $this->statement->getMainSnak()->getHash()]; |
|
60 | 60 | } |
61 | 61 | $mainsnakArray = &$statementArray['mainsnak']; |
62 | 62 |
@@ -20,13 +20,13 @@ |
||
20 | 20 | * @param PropertyId $propertyId |
21 | 21 | * @return int |
22 | 22 | */ |
23 | - public function getPropertyCount( array $snaks, PropertyId $propertyId ) { |
|
24 | - return count( array_filter( |
|
23 | + public function getPropertyCount(array $snaks, PropertyId $propertyId) { |
|
24 | + return count(array_filter( |
|
25 | 25 | $snaks, |
26 | - function ( Snak $snak ) use ( $propertyId ) { |
|
27 | - return $snak->getPropertyId()->equals( $propertyId ); |
|
26 | + function(Snak $snak) use ($propertyId) { |
|
27 | + return $snak->getPropertyId()->equals($propertyId); |
|
28 | 28 | } |
29 | - ) ); |
|
29 | + )); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | } |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return CheckResult |
56 | 56 | */ |
57 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
58 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
59 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
57 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
58 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
59 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $propertyId = $context->getSnak()->getPropertyId(); |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | $propertyId |
69 | 69 | ); |
70 | 70 | |
71 | - if ( $propertyCount <= 1 ) { |
|
72 | - $message = wfMessage( "wbqc-violation-message-multi-value" )->escaped(); |
|
71 | + if ($propertyCount <= 1) { |
|
72 | + $message = wfMessage("wbqc-violation-message-multi-value")->escaped(); |
|
73 | 73 | $status = CheckResult::STATUS_VIOLATION; |
74 | 74 | } else { |
75 | 75 | $message = ''; |
76 | 76 | $status = CheckResult::STATUS_COMPLIANCE; |
77 | 77 | } |
78 | 78 | |
79 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
79 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
80 | 80 | } |
81 | 81 | |
82 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
82 | + public function checkConstraintParameters(Constraint $constraint) { |
|
83 | 83 | // no parameters |
84 | 84 | return []; |
85 | 85 | } |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return CheckResult |
56 | 56 | */ |
57 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
58 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
59 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
57 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
58 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
59 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $propertyId = $context->getSnak()->getPropertyId(); |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | $propertyId |
69 | 69 | ); |
70 | 70 | |
71 | - if ( $propertyCount > 1 ) { |
|
72 | - $message = wfMessage( "wbqc-violation-message-single-value" )->escaped(); |
|
71 | + if ($propertyCount > 1) { |
|
72 | + $message = wfMessage("wbqc-violation-message-single-value")->escaped(); |
|
73 | 73 | $status = CheckResult::STATUS_VIOLATION; |
74 | 74 | } else { |
75 | 75 | $message = ''; |
76 | 76 | $status = CheckResult::STATUS_COMPLIANCE; |
77 | 77 | } |
78 | 78 | |
79 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
79 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
80 | 80 | } |
81 | 81 | |
82 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
82 | + public function checkConstraintParameters(Constraint $constraint) { |
|
83 | 83 | // no parameters |
84 | 84 | return []; |
85 | 85 | } |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool |
32 | 32 | */ |
33 | - public static function onCreateSchema( DatabaseUpdater $updater ) { |
|
34 | - $updater->addExtensionTable( 'wbqc_constraints', __DIR__ . '/../sql/create_wbqc_constraints.sql' ); |
|
33 | + public static function onCreateSchema(DatabaseUpdater $updater) { |
|
34 | + $updater->addExtensionTable('wbqc_constraints', __DIR__.'/../sql/create_wbqc_constraints.sql'); |
|
35 | 35 | return true; |
36 | 36 | } |
37 | 37 | |
38 | - public static function onWikibaseChange( Change $change ) { |
|
38 | + public static function onWikibaseChange(Change $change) { |
|
39 | 39 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
40 | - if ( $config->get( 'WBQualityConstraintsEnableConstraintsImportFromStatements' ) && |
|
41 | - self::isConstraintStatementsChange( $config, $change ) |
|
40 | + if ($config->get('WBQualityConstraintsEnableConstraintsImportFromStatements') && |
|
41 | + self::isConstraintStatementsChange($config, $change) |
|
42 | 42 | ) { |
43 | 43 | /** @var EntityChange $change */ |
44 | 44 | $title = Title::newMainPage(); |
45 | - $params = [ 'propertyId' => $change->getEntityId()->getSerialization() ]; |
|
45 | + $params = ['propertyId' => $change->getEntityId()->getSerialization()]; |
|
46 | 46 | JobQueueGroup::singleton()->push( |
47 | - new JobSpecification( 'constraintsTableUpdate', $params, [], $title ) |
|
47 | + new JobSpecification('constraintsTableUpdate', $params, [], $title) |
|
48 | 48 | ); |
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
52 | - public static function isConstraintStatementsChange( Config $config, Change $change ) { |
|
53 | - if ( !( $change instanceof EntityChange ) || |
|
52 | + public static function isConstraintStatementsChange(Config $config, Change $change) { |
|
53 | + if (!($change instanceof EntityChange) || |
|
54 | 54 | $change->getAction() !== EntityChange::UPDATE || |
55 | - !( $change->getEntityId() instanceof PropertyId ) |
|
55 | + !($change->getEntityId() instanceof PropertyId) |
|
56 | 56 | ) { |
57 | 57 | return false; |
58 | 58 | } |
59 | 59 | |
60 | 60 | $info = $change->getInfo(); |
61 | 61 | |
62 | - if ( !array_key_exists( 'compactDiff', $info ) ) { |
|
62 | + if (!array_key_exists('compactDiff', $info)) { |
|
63 | 63 | // the non-compact diff ($info['diff']) does not contain statement diffs (T110996), |
64 | 64 | // so we only know that the change *might* affect the constraint statements |
65 | 65 | return true; |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | /** @var EntityDiffChangedAspects $aspects */ |
69 | 69 | $aspects = $info['compactDiff']; |
70 | 70 | |
71 | - $propertyConstraintId = $config->get( 'WBQualityConstraintsPropertyConstraintId' ); |
|
72 | - return in_array( $propertyConstraintId, $aspects->getStatementChanges() ); |
|
71 | + $propertyConstraintId = $config->get('WBQualityConstraintsPropertyConstraintId'); |
|
72 | + return in_array($propertyConstraintId, $aspects->getStatementChanges()); |
|
73 | 73 | } |
74 | 74 | |
75 | - public static function onArticlePurge( WikiPage $wikiPage ) { |
|
75 | + public static function onArticlePurge(WikiPage $wikiPage) { |
|
76 | 76 | $repo = WikibaseRepo::getDefaultInstance(); |
77 | 77 | |
78 | 78 | $entityContentFactory = $repo->getEntityContentFactory(); |
79 | - if ( $entityContentFactory->isEntityContentModel( $wikiPage->getContentModel() ) ) { |
|
80 | - $entityId = $entityContentFactory->getEntityIdForTitle( $wikiPage->getTitle() ); |
|
79 | + if ($entityContentFactory->isEntityContentModel($wikiPage->getContentModel())) { |
|
80 | + $entityId = $entityContentFactory->getEntityIdForTitle($wikiPage->getTitle()); |
|
81 | 81 | $resultsCache = ResultsCache::getDefaultInstance(); |
82 | - $resultsCache->delete( $entityId ); |
|
82 | + $resultsCache->delete($entityId); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -88,18 +88,18 @@ discard block |
||
88 | 88 | * @param int $timestamp UTC timestamp (seconds since the Epoch) |
89 | 89 | * @return bool |
90 | 90 | */ |
91 | - public static function isGadgetEnabledForUserName( $userName, $timestamp ) { |
|
91 | + public static function isGadgetEnabledForUserName($userName, $timestamp) { |
|
92 | 92 | $initial = $userName[0]; |
93 | 93 | |
94 | - if ( $initial === 'Z' ) { |
|
94 | + if ($initial === 'Z') { |
|
95 | 95 | $firstWeek = 0; |
96 | - } elseif ( $initial >= 'W' && $initial < 'Z' ) { |
|
96 | + } elseif ($initial >= 'W' && $initial < 'Z') { |
|
97 | 97 | $firstWeek = 1; |
98 | - } elseif ( $initial >= 'T' && $initial < 'W' ) { |
|
98 | + } elseif ($initial >= 'T' && $initial < 'W') { |
|
99 | 99 | $firstWeek = 2; |
100 | - } elseif ( $initial >= 'N' && $initial < 'T' ) { |
|
100 | + } elseif ($initial >= 'N' && $initial < 'T') { |
|
101 | 101 | $firstWeek = 3; |
102 | - } elseif ( $initial >= 'E' && $initial < 'N' ) { |
|
102 | + } elseif ($initial >= 'E' && $initial < 'N') { |
|
103 | 103 | $firstWeek = 4; |
104 | 104 | } else { |
105 | 105 | $firstWeek = 5; |
@@ -117,27 +117,27 @@ discard block |
||
117 | 117 | return $timestamp >= $threshold; |
118 | 118 | } |
119 | 119 | |
120 | - public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) { |
|
120 | + public static function onBeforePageDisplay(OutputPage &$out, Skin &$skin) { |
|
121 | 121 | $repo = WikibaseRepo::getDefaultInstance(); |
122 | 122 | |
123 | 123 | $lookup = $repo->getEntityNamespaceLookup(); |
124 | 124 | $title = $out->getTitle(); |
125 | - if ( $title === null ) { |
|
125 | + if ($title === null) { |
|
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | - if ( !$lookup->isEntityNamespace( $title->getNamespace() ) ) { |
|
129 | + if (!$lookup->isEntityNamespace($title->getNamespace())) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | - if ( !$out->getUser()->isLoggedIn() ) { |
|
132 | + if (!$out->getUser()->isLoggedIn()) { |
|
133 | 133 | return; |
134 | 134 | } |
135 | - if ( !$out->getJsConfigVars()['wbIsEditView'] ) { |
|
135 | + if (!$out->getJsConfigVars()['wbIsEditView']) { |
|
136 | 136 | return; |
137 | 137 | } |
138 | 138 | |
139 | - if ( self::isGadgetEnabledForUserName( $out->getUser()->getName(), time() ) ) { |
|
140 | - $out->addModules( 'wikibase.quality.constraints.gadget' ); |
|
139 | + if (self::isGadgetEnabledForUserName($out->getUser()->getName(), time())) { |
|
140 | + $out->addModules('wikibase.quality.constraints.gadget'); |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 |