@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Checker; |
6 | 6 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | private ConstraintParameterParser $constraintParameterParser; |
24 | 24 | |
25 | - public function __construct( ConstraintParameterParser $constraintParameterParser ) { |
|
25 | + public function __construct(ConstraintParameterParser $constraintParameterParser) { |
|
26 | 26 | $this->constraintParameterParser = $constraintParameterParser; |
27 | 27 | } |
28 | 28 | |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @throws ConstraintParameterException |
66 | 66 | */ |
67 | - public function checkConstraint( Context $context, Constraint $constraint ): CheckResult { |
|
68 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
69 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_DEPRECATED ); |
|
67 | + public function checkConstraint(Context $context, Constraint $constraint): CheckResult { |
|
68 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
69 | + return new CheckResult($context, $constraint, CheckResult::STATUS_DEPRECATED); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $constraintParameters = $constraint->getConstraintParameters(); |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | ); |
78 | 78 | |
79 | 79 | $status = CheckResult::STATUS_VIOLATION; |
80 | - $message = ( new ViolationMessage( 'wbqc-violation-message-label-lacking' ) ) |
|
81 | - ->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) |
|
82 | - ->withLanguages( $languages ); |
|
80 | + $message = (new ViolationMessage('wbqc-violation-message-label-lacking')) |
|
81 | + ->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE) |
|
82 | + ->withLanguages($languages); |
|
83 | 83 | |
84 | 84 | /** @var LabelsProvider $entity */ |
85 | 85 | $entity = $context->getEntity(); |
86 | 86 | '@phan-var LabelsProvider $entity'; |
87 | 87 | $labels = $entity->getLabels(); |
88 | 88 | |
89 | - if ( $labels->hasTermForLanguage( 'mul' ) ) { |
|
89 | + if ($labels->hasTermForLanguage('mul')) { |
|
90 | 90 | $message = null; |
91 | 91 | $status = CheckResult::STATUS_COMPLIANCE; |
92 | 92 | } else { |
93 | - foreach ( $languages as $language ) { |
|
94 | - if ( $labels->hasTermForLanguage( $language ) ) { |
|
93 | + foreach ($languages as $language) { |
|
94 | + if ($labels->hasTermForLanguage($language)) { |
|
95 | 95 | $message = null; |
96 | 96 | $status = CheckResult::STATUS_COMPLIANCE; |
97 | 97 | break; |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - return new CheckResult( $context, $constraint, $status, $message ); |
|
102 | + return new CheckResult($context, $constraint, $status, $message); |
|
103 | 103 | } |
104 | 104 | |
105 | - public function checkConstraintParameters( Constraint $constraint ): array { |
|
105 | + public function checkConstraintParameters(Constraint $constraint): array { |
|
106 | 106 | $constraintParameters = $constraint->getConstraintParameters(); |
107 | 107 | $exceptions = []; |
108 | 108 | try { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $constraintParameters, |
111 | 111 | $constraint->getConstraintTypeItemId() |
112 | 112 | ); |
113 | - } catch ( ConstraintParameterException $e ) { |
|
113 | + } catch (ConstraintParameterException $e) { |
|
114 | 114 | $exceptions[] = $e; |
115 | 115 | } |
116 | 116 | return $exceptions; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\Html; |
6 | 6 | |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @throws InvalidArgumentException |
35 | 35 | */ |
36 | - public function __construct( $content, bool $isSortable = false ) { |
|
37 | - Assert::parameterType( [ 'string', HtmlArmor::class ], $content, '$content' ); |
|
36 | + public function __construct($content, bool $isSortable = false) { |
|
37 | + Assert::parameterType(['string', HtmlArmor::class], $content, '$content'); |
|
38 | 38 | |
39 | 39 | $this->content = $content; |
40 | 40 | $this->isSortable = $isSortable; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @return string HTML |
45 | 45 | */ |
46 | 46 | public function getContent(): string { |
47 | - return HtmlArmor::getHtml( $this->content ); |
|
47 | + return HtmlArmor::getHtml($this->content); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | public function getIsSortable(): bool { |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | * @return string HTML |
58 | 58 | */ |
59 | 59 | public function toHtml(): string { |
60 | - $attributes = [ 'role' => 'columnheader button' ]; |
|
60 | + $attributes = ['role' => 'columnheader button']; |
|
61 | 61 | |
62 | - if ( !$this->isSortable ) { |
|
62 | + if (!$this->isSortable) { |
|
63 | 63 | $attributes['class'] = 'unsortable'; |
64 | 64 | } |
65 | 65 | |
66 | - return Html::rawElement( 'th', $attributes, $this->getContent() ); |
|
66 | + return Html::rawElement('th', $attributes, $this->getContent()); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare( strict_types = 1 ); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | |
5 | 5 | namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Message; |
6 | 6 | |
@@ -21,26 +21,26 @@ discard block |
||
21 | 21 | */ |
22 | 22 | class ViolationMessageSerializer implements Serializer { |
23 | 23 | |
24 | - private function abbreviateViolationMessageKey( string $fullMessageKey ): string { |
|
25 | - return substr( $fullMessageKey, strlen( ViolationMessage::MESSAGE_KEY_PREFIX ) ); |
|
24 | + private function abbreviateViolationMessageKey(string $fullMessageKey): string { |
|
25 | + return substr($fullMessageKey, strlen(ViolationMessage::MESSAGE_KEY_PREFIX)); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @param ViolationMessage $object |
30 | 30 | * @return array |
31 | 31 | */ |
32 | - public function serialize( $object ): array { |
|
32 | + public function serialize($object): array { |
|
33 | 33 | /** @var ViolationMessage $object */ |
34 | - Assert::parameterType( ViolationMessage::class, $object, '$object' ); |
|
34 | + Assert::parameterType(ViolationMessage::class, $object, '$object'); |
|
35 | 35 | |
36 | 36 | $arguments = $object->getArguments(); |
37 | 37 | $serializedArguments = []; |
38 | - foreach ( $arguments as $argument ) { |
|
39 | - $serializedArguments[] = $this->serializeArgument( $argument ); |
|
38 | + foreach ($arguments as $argument) { |
|
39 | + $serializedArguments[] = $this->serializeArgument($argument); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | return [ |
43 | - 'k' => $this->abbreviateViolationMessageKey( $object->getMessageKey() ), |
|
43 | + 'k' => $this->abbreviateViolationMessageKey($object->getMessageKey()), |
|
44 | 44 | 'a' => $serializedArguments, |
45 | 45 | ]; |
46 | 46 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param array $argument element of ViolationMessage::getArguments() |
50 | 50 | * @return array [ 't' => ViolationMessage::TYPE_*, 'v' => serialized value, 'r' => $role ] |
51 | 51 | */ |
52 | - private function serializeArgument( array $argument ): array { |
|
52 | + private function serializeArgument(array $argument): array { |
|
53 | 53 | $methods = [ |
54 | 54 | ViolationMessage::TYPE_ENTITY_ID => 'serializeEntityId', |
55 | 55 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'serializeEntityIdList', |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | $value = $argument['value']; |
72 | 72 | $role = $argument['role']; |
73 | 73 | |
74 | - if ( array_key_exists( $type, $methods ) ) { |
|
74 | + if (array_key_exists($type, $methods)) { |
|
75 | 75 | $method = $methods[$type]; |
76 | - $serializedValue = $this->$method( $value ); |
|
76 | + $serializedValue = $this->$method($value); |
|
77 | 77 | } else { |
78 | 78 | throw new InvalidArgumentException( |
79 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
79 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $string any value that shall simply be serialized to itself |
94 | 94 | * @return string that same value, unchanged |
95 | 95 | */ |
96 | - private function serializeStringByIdentity( string $string ): string { |
|
96 | + private function serializeStringByIdentity(string $string): string { |
|
97 | 97 | return $string; |
98 | 98 | } |
99 | 99 | |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | * @param string[] $strings |
102 | 102 | * @return string[] |
103 | 103 | */ |
104 | - private function serializeStringListByIdentity( array $strings ): array { |
|
105 | - Assert::parameterElementType( 'string', $strings, '$strings' ); |
|
104 | + private function serializeStringListByIdentity(array $strings): array { |
|
105 | + Assert::parameterElementType('string', $strings, '$strings'); |
|
106 | 106 | return $strings; |
107 | 107 | } |
108 | 108 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param EntityId $entityId |
111 | 111 | * @return string entity ID serialization |
112 | 112 | */ |
113 | - private function serializeEntityId( EntityId $entityId ): string { |
|
113 | + private function serializeEntityId(EntityId $entityId): string { |
|
114 | 114 | return $entityId->getSerialization(); |
115 | 115 | } |
116 | 116 | |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * @param EntityId[] $entityIdList |
119 | 119 | * @return string[] entity ID serializations |
120 | 120 | */ |
121 | - private function serializeEntityIdList( array $entityIdList ): array { |
|
122 | - return array_map( [ $this, 'serializeEntityId' ], $entityIdList ); |
|
121 | + private function serializeEntityIdList(array $entityIdList): array { |
|
122 | + return array_map([$this, 'serializeEntityId'], $entityIdList); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | * @return string entity ID serialization, '::somevalue', or '::novalue' |
128 | 128 | * (according to EntityId::PATTERN, entity ID serializations can never begin with two colons) |
129 | 129 | */ |
130 | - private function serializeItemIdSnakValue( ItemIdSnakValue $value ): string { |
|
131 | - switch ( true ) { |
|
130 | + private function serializeItemIdSnakValue(ItemIdSnakValue $value): string { |
|
131 | + switch (true) { |
|
132 | 132 | case $value->isValue(): |
133 | - return $this->serializeEntityId( $value->getItemId() ); |
|
133 | + return $this->serializeEntityId($value->getItemId()); |
|
134 | 134 | case $value->isSomeValue(): |
135 | 135 | return '::somevalue'; |
136 | 136 | case $value->isNoValue(): |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | * @param ItemIdSnakValue[] $valueList |
149 | 149 | * @return string[] array of entity ID serializations, '::somevalue's or '::novalue's |
150 | 150 | */ |
151 | - private function serializeItemIdSnakValueList( array $valueList ): array { |
|
152 | - return array_map( [ $this, 'serializeItemIdSnakValue' ], $valueList ); |
|
151 | + private function serializeItemIdSnakValueList(array $valueList): array { |
|
152 | + return array_map([$this, 'serializeItemIdSnakValue'], $valueList); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
156 | 156 | * @param DataValue $dataValue |
157 | 157 | * @return array the data value in array form |
158 | 158 | */ |
159 | - private function serializeDataValue( DataValue $dataValue ): array { |
|
159 | + private function serializeDataValue(DataValue $dataValue): array { |
|
160 | 160 | return $dataValue->toArray(); |
161 | 161 | } |
162 | 162 | |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param string $contextType one of the Context::TYPE_* constants |
165 | 165 | * @return string the abbreviated context type |
166 | 166 | */ |
167 | - private function serializeContextType( string $contextType ): string { |
|
168 | - switch ( $contextType ) { |
|
167 | + private function serializeContextType(string $contextType): string { |
|
168 | + switch ($contextType) { |
|
169 | 169 | case Context::TYPE_STATEMENT: |
170 | 170 | return 's'; |
171 | 171 | case Context::TYPE_QUALIFIER: |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | default: |
176 | 176 | // @codeCoverageIgnoreStart |
177 | 177 | throw new LogicException( |
178 | - 'Unknown context type ' . $contextType |
|
178 | + 'Unknown context type '.$contextType |
|
179 | 179 | ); |
180 | 180 | // @codeCoverageIgnoreEnd |
181 | 181 | } |
@@ -185,15 +185,15 @@ discard block |
||
185 | 185 | * @param string[] $contextTypeList Context::TYPE_* constants |
186 | 186 | * @return string[] abbreviated context types |
187 | 187 | */ |
188 | - private function serializeContextTypeList( array $contextTypeList ): array { |
|
189 | - return array_map( [ $this, 'serializeContextType' ], $contextTypeList ); |
|
188 | + private function serializeContextTypeList(array $contextTypeList): array { |
|
189 | + return array_map([$this, 'serializeContextType'], $contextTypeList); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
193 | 193 | * @param MultilingualTextValue $text |
194 | 194 | * @return mixed {@see MultilingualTextValue::getArrayValue} |
195 | 195 | */ |
196 | - private function serializeMultilingualText( MultilingualTextValue $text ) { |
|
196 | + private function serializeMultilingualText(MultilingualTextValue $text) { |
|
197 | 197 | return $text->getArrayValue(); |
198 | 198 | } |
199 | 199 |
@@ -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 | |
@@ -11,16 +11,16 @@ discard block |
||
11 | 11 | use Wikibase\Repo\WikibaseRepo; |
12 | 12 | |
13 | 13 | return [ |
14 | - WikibaseServices::ENTITY_LOOKUP => static function ( MediaWikiServices $services ): EntityLookup { |
|
14 | + WikibaseServices::ENTITY_LOOKUP => static function(MediaWikiServices $services): EntityLookup { |
|
15 | 15 | return new ExceptionIgnoringEntityLookup( |
16 | - WikibaseRepo::getEntityLookup( $services ) |
|
16 | + WikibaseRepo::getEntityLookup($services) |
|
17 | 17 | ); |
18 | 18 | }, |
19 | 19 | |
20 | - WikibaseServices::ENTITY_LOOKUP_WITHOUT_CACHE => static function ( MediaWikiServices $services ): EntityLookup { |
|
20 | + WikibaseServices::ENTITY_LOOKUP_WITHOUT_CACHE => static function(MediaWikiServices $services): EntityLookup { |
|
21 | 21 | return new ExceptionIgnoringEntityLookup( |
22 | - WikibaseRepo::getStore( $services ) |
|
23 | - ->getEntityLookup( Store::LOOKUP_CACHING_RETRIEVE_ONLY ) |
|
22 | + WikibaseRepo::getStore($services) |
|
23 | + ->getEntityLookup(Store::LOOKUP_CACHING_RETRIEVE_ONLY) |
|
24 | 24 | ); |
25 | 25 | }, |
26 | 26 | ]; |
@@ -38,216 +38,216 @@ |
||
38 | 38 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker; |
39 | 39 | |
40 | 40 | return [ |
41 | - ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => static function ( MediaWikiServices $services ): ConflictsWithChecker { |
|
41 | + ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => static function(MediaWikiServices $services): ConflictsWithChecker { |
|
42 | 42 | return new ConflictsWithChecker( |
43 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
44 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
43 | + ConstraintsServices::getConstraintParameterParser($services), |
|
44 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
45 | 45 | ); |
46 | 46 | }, |
47 | 47 | |
48 | - ConstraintCheckerServices::ITEM_CHECKER => static function ( MediaWikiServices $services ): ItemChecker { |
|
48 | + ConstraintCheckerServices::ITEM_CHECKER => static function(MediaWikiServices $services): ItemChecker { |
|
49 | 49 | return new ItemChecker( |
50 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
51 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
50 | + ConstraintsServices::getConstraintParameterParser($services), |
|
51 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
52 | 52 | ); |
53 | 53 | }, |
54 | 54 | |
55 | - ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => static function ( |
|
55 | + ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => static function( |
|
56 | 56 | MediaWikiServices $services |
57 | 57 | ): TargetRequiredClaimChecker { |
58 | 58 | return new TargetRequiredClaimChecker( |
59 | - WikibaseServices::getEntityLookup( $services ), |
|
60 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
61 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
59 | + WikibaseServices::getEntityLookup($services), |
|
60 | + ConstraintsServices::getConstraintParameterParser($services), |
|
61 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
62 | 62 | ); |
63 | 63 | }, |
64 | 64 | |
65 | - ConstraintCheckerServices::SYMMETRIC_CHECKER => static function ( MediaWikiServices $services ): SymmetricChecker { |
|
65 | + ConstraintCheckerServices::SYMMETRIC_CHECKER => static function(MediaWikiServices $services): SymmetricChecker { |
|
66 | 66 | return new SymmetricChecker( |
67 | - WikibaseServices::getEntityLookupWithoutCache( $services ), |
|
68 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
67 | + WikibaseServices::getEntityLookupWithoutCache($services), |
|
68 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
69 | 69 | ); |
70 | 70 | }, |
71 | 71 | |
72 | - ConstraintCheckerServices::INVERSE_CHECKER => static function ( MediaWikiServices $services ): InverseChecker { |
|
72 | + ConstraintCheckerServices::INVERSE_CHECKER => static function(MediaWikiServices $services): InverseChecker { |
|
73 | 73 | return new InverseChecker( |
74 | - WikibaseServices::getEntityLookup( $services ), |
|
75 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
76 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
74 | + WikibaseServices::getEntityLookup($services), |
|
75 | + ConstraintsServices::getConstraintParameterParser($services), |
|
76 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
77 | 77 | ); |
78 | 78 | }, |
79 | 79 | |
80 | - ConstraintCheckerServices::QUALIFIER_CHECKER => static function ( MediaWikiServices $services ): QualifierChecker { |
|
80 | + ConstraintCheckerServices::QUALIFIER_CHECKER => static function(MediaWikiServices $services): QualifierChecker { |
|
81 | 81 | return new QualifierChecker(); |
82 | 82 | }, |
83 | 83 | |
84 | - ConstraintCheckerServices::QUALIFIERS_CHECKER => static function ( MediaWikiServices $services ): QualifiersChecker { |
|
84 | + ConstraintCheckerServices::QUALIFIERS_CHECKER => static function(MediaWikiServices $services): QualifiersChecker { |
|
85 | 85 | return new QualifiersChecker( |
86 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
86 | + ConstraintsServices::getConstraintParameterParser($services) |
|
87 | 87 | ); |
88 | 88 | }, |
89 | 89 | |
90 | - ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => static function ( |
|
90 | + ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => static function( |
|
91 | 91 | MediaWikiServices $services |
92 | 92 | ): MandatoryQualifiersChecker { |
93 | 93 | return new MandatoryQualifiersChecker( |
94 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
94 | + ConstraintsServices::getConstraintParameterParser($services) |
|
95 | 95 | ); |
96 | 96 | }, |
97 | 97 | |
98 | - ConstraintCheckerServices::RANGE_CHECKER => static function ( MediaWikiServices $services ): RangeChecker { |
|
98 | + ConstraintCheckerServices::RANGE_CHECKER => static function(MediaWikiServices $services): RangeChecker { |
|
99 | 99 | return new RangeChecker( |
100 | - WikibaseRepo::getPropertyDataTypeLookup( $services ), |
|
101 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
102 | - ConstraintsServices::getRangeCheckerHelper( $services ) |
|
100 | + WikibaseRepo::getPropertyDataTypeLookup($services), |
|
101 | + ConstraintsServices::getConstraintParameterParser($services), |
|
102 | + ConstraintsServices::getRangeCheckerHelper($services) |
|
103 | 103 | ); |
104 | 104 | }, |
105 | 105 | |
106 | - ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => static function ( |
|
106 | + ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => static function( |
|
107 | 107 | MediaWikiServices $services |
108 | 108 | ): DiffWithinRangeChecker { |
109 | 109 | return new DiffWithinRangeChecker( |
110 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
111 | - ConstraintsServices::getRangeCheckerHelper( $services ), |
|
110 | + ConstraintsServices::getConstraintParameterParser($services), |
|
111 | + ConstraintsServices::getRangeCheckerHelper($services), |
|
112 | 112 | $services->getMainConfig() |
113 | 113 | ); |
114 | 114 | }, |
115 | 115 | |
116 | - ConstraintCheckerServices::TYPE_CHECKER => static function ( MediaWikiServices $services ): TypeChecker { |
|
116 | + ConstraintCheckerServices::TYPE_CHECKER => static function(MediaWikiServices $services): TypeChecker { |
|
117 | 117 | return new TypeChecker( |
118 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
119 | - ConstraintsServices::getTypeCheckerHelper( $services ), |
|
118 | + ConstraintsServices::getConstraintParameterParser($services), |
|
119 | + ConstraintsServices::getTypeCheckerHelper($services), |
|
120 | 120 | $services->getMainConfig() |
121 | 121 | ); |
122 | 122 | }, |
123 | 123 | |
124 | - ConstraintCheckerServices::VALUE_TYPE_CHECKER => static function ( MediaWikiServices $services ): ValueTypeChecker { |
|
124 | + ConstraintCheckerServices::VALUE_TYPE_CHECKER => static function(MediaWikiServices $services): ValueTypeChecker { |
|
125 | 125 | return new ValueTypeChecker( |
126 | - WikibaseServices::getEntityLookup( $services ), |
|
127 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
128 | - ConstraintsServices::getTypeCheckerHelper( $services ), |
|
126 | + WikibaseServices::getEntityLookup($services), |
|
127 | + ConstraintsServices::getConstraintParameterParser($services), |
|
128 | + ConstraintsServices::getTypeCheckerHelper($services), |
|
129 | 129 | $services->getMainConfig() |
130 | 130 | ); |
131 | 131 | }, |
132 | 132 | |
133 | - ConstraintCheckerServices::SINGLE_VALUE_CHECKER => static function ( MediaWikiServices $services ): SingleValueChecker { |
|
133 | + ConstraintCheckerServices::SINGLE_VALUE_CHECKER => static function(MediaWikiServices $services): SingleValueChecker { |
|
134 | 134 | return new SingleValueChecker( |
135 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
135 | + ConstraintsServices::getConstraintParameterParser($services) |
|
136 | 136 | ); |
137 | 137 | }, |
138 | 138 | |
139 | - ConstraintCheckerServices::MULTI_VALUE_CHECKER => static function ( MediaWikiServices $services ): MultiValueChecker { |
|
139 | + ConstraintCheckerServices::MULTI_VALUE_CHECKER => static function(MediaWikiServices $services): MultiValueChecker { |
|
140 | 140 | return new MultiValueChecker( |
141 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
141 | + ConstraintsServices::getConstraintParameterParser($services) |
|
142 | 142 | ); |
143 | 143 | }, |
144 | 144 | |
145 | - ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => static function ( MediaWikiServices $services ): UniqueValueChecker { |
|
145 | + ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => static function(MediaWikiServices $services): UniqueValueChecker { |
|
146 | 146 | // TODO return a different, dummy implementation if SPARQL is not available |
147 | 147 | return new UniqueValueChecker( |
148 | - ConstraintsServices::getSparqlHelper( $services ), |
|
149 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
148 | + ConstraintsServices::getSparqlHelper($services), |
|
149 | + ConstraintsServices::getConstraintParameterParser($services) |
|
150 | 150 | ); |
151 | 151 | }, |
152 | 152 | |
153 | - ConstraintCheckerServices::FORMAT_CHECKER => static function ( MediaWikiServices $services ): FormatChecker { |
|
153 | + ConstraintCheckerServices::FORMAT_CHECKER => static function(MediaWikiServices $services): FormatChecker { |
|
154 | 154 | // TODO return a different, dummy implementation if SPARQL is not available |
155 | 155 | return new FormatChecker( |
156 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
156 | + ConstraintsServices::getConstraintParameterParser($services), |
|
157 | 157 | $services->getMainConfig(), |
158 | - ConstraintsServices::getSparqlHelper( $services ), |
|
158 | + ConstraintsServices::getSparqlHelper($services), |
|
159 | 159 | $services->getShellboxClientFactory() |
160 | 160 | ); |
161 | 161 | }, |
162 | 162 | |
163 | - ConstraintCheckerServices::COMMONS_LINK_CHECKER => static function ( MediaWikiServices $services ): CommonsLinkChecker { |
|
163 | + ConstraintCheckerServices::COMMONS_LINK_CHECKER => static function(MediaWikiServices $services): CommonsLinkChecker { |
|
164 | 164 | $pageNameNormalizer = new MediaWikiPageNameNormalizer(); |
165 | 165 | return new CommonsLinkChecker( |
166 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
166 | + ConstraintsServices::getConstraintParameterParser($services), |
|
167 | 167 | $pageNameNormalizer, |
168 | - WikibaseRepo::getPropertyDataTypeLookup( $services ) |
|
168 | + WikibaseRepo::getPropertyDataTypeLookup($services) |
|
169 | 169 | ); |
170 | 170 | }, |
171 | 171 | |
172 | - ConstraintCheckerServices::ONE_OF_CHECKER => static function ( MediaWikiServices $services ): OneOfChecker { |
|
172 | + ConstraintCheckerServices::ONE_OF_CHECKER => static function(MediaWikiServices $services): OneOfChecker { |
|
173 | 173 | return new OneOfChecker( |
174 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
174 | + ConstraintsServices::getConstraintParameterParser($services) |
|
175 | 175 | ); |
176 | 176 | }, |
177 | 177 | |
178 | - ConstraintCheckerServices::VALUE_ONLY_CHECKER => static function ( MediaWikiServices $services ): ValueOnlyChecker { |
|
178 | + ConstraintCheckerServices::VALUE_ONLY_CHECKER => static function(MediaWikiServices $services): ValueOnlyChecker { |
|
179 | 179 | return new ValueOnlyChecker(); |
180 | 180 | }, |
181 | 181 | |
182 | - ConstraintCheckerServices::REFERENCE_CHECKER => static function ( MediaWikiServices $services ): ReferenceChecker { |
|
182 | + ConstraintCheckerServices::REFERENCE_CHECKER => static function(MediaWikiServices $services): ReferenceChecker { |
|
183 | 183 | return new ReferenceChecker(); |
184 | 184 | }, |
185 | 185 | |
186 | - ConstraintCheckerServices::NO_BOUNDS_CHECKER => static function ( MediaWikiServices $services ): NoBoundsChecker { |
|
186 | + ConstraintCheckerServices::NO_BOUNDS_CHECKER => static function(MediaWikiServices $services): NoBoundsChecker { |
|
187 | 187 | return new NoBoundsChecker(); |
188 | 188 | }, |
189 | 189 | |
190 | - ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => static function ( MediaWikiServices $services ): AllowedUnitsChecker { |
|
190 | + ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => static function(MediaWikiServices $services): AllowedUnitsChecker { |
|
191 | 191 | return new AllowedUnitsChecker( |
192 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
193 | - WikibaseRepo::getUnitConverter( $services ) |
|
192 | + ConstraintsServices::getConstraintParameterParser($services), |
|
193 | + WikibaseRepo::getUnitConverter($services) |
|
194 | 194 | ); |
195 | 195 | }, |
196 | 196 | |
197 | - ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => static function ( |
|
197 | + ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => static function( |
|
198 | 198 | MediaWikiServices $services |
199 | 199 | ): SingleBestValueChecker { |
200 | 200 | return new SingleBestValueChecker( |
201 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
201 | + ConstraintsServices::getConstraintParameterParser($services) |
|
202 | 202 | ); |
203 | 203 | }, |
204 | 204 | |
205 | - ConstraintCheckerServices::ENTITY_TYPE_CHECKER => static function ( MediaWikiServices $services ): EntityTypeChecker { |
|
205 | + ConstraintCheckerServices::ENTITY_TYPE_CHECKER => static function(MediaWikiServices $services): EntityTypeChecker { |
|
206 | 206 | return new EntityTypeChecker( |
207 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
207 | + ConstraintsServices::getConstraintParameterParser($services) |
|
208 | 208 | ); |
209 | 209 | }, |
210 | 210 | |
211 | - ConstraintCheckerServices::NONE_OF_CHECKER => static function ( MediaWikiServices $services ): NoneOfChecker { |
|
211 | + ConstraintCheckerServices::NONE_OF_CHECKER => static function(MediaWikiServices $services): NoneOfChecker { |
|
212 | 212 | return new NoneOfChecker( |
213 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
213 | + ConstraintsServices::getConstraintParameterParser($services) |
|
214 | 214 | ); |
215 | 215 | }, |
216 | 216 | |
217 | - ConstraintCheckerServices::INTEGER_CHECKER => static function ( MediaWikiServices $services ): IntegerChecker { |
|
217 | + ConstraintCheckerServices::INTEGER_CHECKER => static function(MediaWikiServices $services): IntegerChecker { |
|
218 | 218 | return new IntegerChecker(); |
219 | 219 | }, |
220 | 220 | |
221 | - ConstraintCheckerServices::CITATION_NEEDED_CHECKER => static function ( MediaWikiServices $services ): CitationNeededChecker { |
|
221 | + ConstraintCheckerServices::CITATION_NEEDED_CHECKER => static function(MediaWikiServices $services): CitationNeededChecker { |
|
222 | 222 | return new CitationNeededChecker(); |
223 | 223 | }, |
224 | 224 | |
225 | - ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => static function ( MediaWikiServices $services ): PropertyScopeChecker { |
|
225 | + ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => static function(MediaWikiServices $services): PropertyScopeChecker { |
|
226 | 226 | return new PropertyScopeChecker( |
227 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
227 | + ConstraintsServices::getConstraintParameterParser($services) |
|
228 | 228 | ); |
229 | 229 | }, |
230 | 230 | |
231 | - ConstraintCheckerServices::CONTEMPORARY_CHECKER => static function ( MediaWikiServices $services ): ContemporaryChecker { |
|
231 | + ConstraintCheckerServices::CONTEMPORARY_CHECKER => static function(MediaWikiServices $services): ContemporaryChecker { |
|
232 | 232 | return new ContemporaryChecker( |
233 | - WikibaseServices::getEntityLookup( $services ), |
|
234 | - ConstraintsServices::getRangeCheckerHelper( $services ), |
|
233 | + WikibaseServices::getEntityLookup($services), |
|
234 | + ConstraintsServices::getRangeCheckerHelper($services), |
|
235 | 235 | $services->getMainConfig() |
236 | 236 | ); |
237 | 237 | }, |
238 | 238 | |
239 | - ConstraintCheckerServices::LEXEME_LANGUAGE_CHECKER => static function ( MediaWikiServices $services ): LanguageChecker { |
|
239 | + ConstraintCheckerServices::LEXEME_LANGUAGE_CHECKER => static function(MediaWikiServices $services): LanguageChecker { |
|
240 | 240 | return new LanguageChecker( |
241 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
242 | - WikibaseServices::getEntityLookup( $services ) |
|
241 | + ConstraintsServices::getConstraintParameterParser($services), |
|
242 | + WikibaseServices::getEntityLookup($services) |
|
243 | 243 | ); |
244 | 244 | }, |
245 | 245 | |
246 | - ConstraintCheckerServices::LABEL_IN_LANGUAGE_CHECKER => static function ( |
|
246 | + ConstraintCheckerServices::LABEL_IN_LANGUAGE_CHECKER => static function( |
|
247 | 247 | MediaWikiServices $services |
248 | 248 | ): LabelInLanguageChecker { |
249 | 249 | return new LabelInLanguageChecker( |
250 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
250 | + ConstraintsServices::getConstraintParameterParser($services) |
|
251 | 251 | ); |
252 | 252 | }, |
253 | 253 | ]; |
@@ -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\Result; |
6 | 6 | |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | string $status = self::STATUS_TODO, |
109 | 109 | ?ViolationMessage $message = null |
110 | 110 | ) { |
111 | - if ( $contextCursor instanceof Context ) { |
|
111 | + if ($contextCursor instanceof Context) { |
|
112 | 112 | $context = $contextCursor; |
113 | 113 | $this->contextCursor = $context->getCursor(); |
114 | 114 | $this->snakType = $context->getSnak()->getType(); |
115 | 115 | $mainSnak = $context->getSnak(); |
116 | - if ( $mainSnak instanceof PropertyValueSnak ) { |
|
116 | + if ($mainSnak instanceof PropertyValueSnak) { |
|
117 | 117 | $this->dataValue = $mainSnak->getDataValue(); |
118 | 118 | } else { |
119 | 119 | $this->dataValue = null; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $this->status = $status; |
128 | 128 | $this->message = $message; |
129 | 129 | $this->metadata = Metadata::blank(); |
130 | - $this->constraintClarification = new MultilingualTextValue( [] ); |
|
130 | + $this->constraintClarification = new MultilingualTextValue([]); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | public function getContextCursor(): ContextCursor { |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return $this->status; |
164 | 164 | } |
165 | 165 | |
166 | - public function setStatus( string $status ): void { |
|
166 | + public function setStatus(string $status): void { |
|
167 | 167 | $this->status = $status; |
168 | 168 | } |
169 | 169 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | return $this->message; |
172 | 172 | } |
173 | 173 | |
174 | - public function setMessage( ?ViolationMessage $message ) { |
|
174 | + public function setMessage(?ViolationMessage $message) { |
|
175 | 175 | $this->message = $message; |
176 | 176 | } |
177 | 177 | |
178 | - public function withMetadata( Metadata $metadata ): self { |
|
178 | + public function withMetadata(Metadata $metadata): self { |
|
179 | 179 | $this->metadata = $metadata; |
180 | 180 | return $this; |
181 | 181 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | return $this->constraintClarification; |
189 | 189 | } |
190 | 190 | |
191 | - public function setConstraintClarification( MultilingualTextValue $constraintClarification ) { |
|
191 | + public function setConstraintClarification(MultilingualTextValue $constraintClarification) { |
|
192 | 192 | $this->constraintClarification = $constraintClarification; |
193 | 193 | } |
194 | 194 |
@@ -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\Cache; |
6 | 6 | |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | * @param int $maxAge The maximum age of the cached value (in seconds). |
32 | 32 | * @return self Indication that a value is possibly outdated by up to this many seconds. |
33 | 33 | */ |
34 | - public static function ofMaximumAgeInSeconds( int $maxAge ): self { |
|
35 | - Assert::parameter( $maxAge > 0, '$maxAge', '$maxage > 0' ); |
|
34 | + public static function ofMaximumAgeInSeconds(int $maxAge): self { |
|
35 | + Assert::parameter($maxAge > 0, '$maxAge', '$maxage > 0'); |
|
36 | 36 | $ret = new self; |
37 | 37 | $ret->maxAge = $maxAge; |
38 | 38 | return $ret; |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | * @param self[] $metadatas |
43 | 43 | * @return self |
44 | 44 | */ |
45 | - public static function merge( array $metadatas ): self { |
|
46 | - Assert::parameterElementType( self::class, $metadatas, '$metadatas' ); |
|
45 | + public static function merge(array $metadatas): self { |
|
46 | + Assert::parameterElementType(self::class, $metadatas, '$metadatas'); |
|
47 | 47 | $ret = new self; |
48 | - foreach ( $metadatas as $metadata ) { |
|
49 | - $ret->maxAge = max( $ret->maxAge, $metadata->maxAge ); |
|
48 | + foreach ($metadatas as $metadata) { |
|
49 | + $ret->maxAge = max($ret->maxAge, $metadata->maxAge); |
|
50 | 50 | } |
51 | 51 | return $ret; |
52 | 52 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * For a fresh value, returns 0. |
65 | 65 | */ |
66 | 66 | public function getMaximumAgeInSeconds(): int { |
67 | - if ( is_int( $this->maxAge ) ) { |
|
67 | + if (is_int($this->maxAge)) { |
|
68 | 68 | return $this->maxAge; |
69 | 69 | } else { |
70 | 70 | return 0; |
@@ -79,8 +79,7 @@ discard block |
||
79 | 79 | return $this->isCached() ? |
80 | 80 | [ |
81 | 81 | 'maximumAgeInSeconds' => $this->maxAge, |
82 | - ] : |
|
83 | - null; |
|
82 | + ] : null; |
|
84 | 83 | } |
85 | 84 | |
86 | 85 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param EntityId $entityId An entity ID from which the value was derived. |
38 | 38 | * @return self Indication that a value was derived from the entity with the given ID. |
39 | 39 | */ |
40 | - public static function ofEntityId( EntityId $entityId ) { |
|
40 | + public static function ofEntityId(EntityId $entityId) { |
|
41 | 41 | $ret = new self; |
42 | 42 | $ret->entityIds[] = $entityId; |
43 | 43 | return $ret; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @return self Indication that a value will only remain valid |
50 | 50 | * as long as the given time value is in the future, not in the past. |
51 | 51 | */ |
52 | - public static function ofFutureTime( TimeValue $timeValue ) { |
|
52 | + public static function ofFutureTime(TimeValue $timeValue) { |
|
53 | 53 | $ret = new self; |
54 | 54 | $ret->timeValue = $timeValue; |
55 | 55 | return $ret; |
@@ -59,17 +59,17 @@ discard block |
||
59 | 59 | * @param self[] $metadatas |
60 | 60 | * @return self |
61 | 61 | */ |
62 | - public static function merge( array $metadatas ) { |
|
63 | - Assert::parameterElementType( self::class, $metadatas, '$metadatas' ); |
|
62 | + public static function merge(array $metadatas) { |
|
63 | + Assert::parameterElementType(self::class, $metadatas, '$metadatas'); |
|
64 | 64 | $ret = new self; |
65 | 65 | $entityIds = []; |
66 | - foreach ( $metadatas as $metadata ) { |
|
67 | - foreach ( $metadata->entityIds as $entityId ) { |
|
66 | + foreach ($metadatas as $metadata) { |
|
67 | + foreach ($metadata->entityIds as $entityId) { |
|
68 | 68 | $entityIds[$entityId->getSerialization()] = $entityId; |
69 | 69 | } |
70 | - $ret->timeValue = self::minTimeValue( $ret->timeValue, $metadata->timeValue ); |
|
70 | + $ret->timeValue = self::minTimeValue($ret->timeValue, $metadata->timeValue); |
|
71 | 71 | } |
72 | - $ret->entityIds = array_values( $entityIds ); |
|
72 | + $ret->entityIds = array_values($entityIds); |
|
73 | 73 | return $ret; |
74 | 74 | } |
75 | 75 | |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | * @param TimeValue|null $t2 |
79 | 79 | * @return TimeValue|null |
80 | 80 | */ |
81 | - private static function minTimeValue( ?TimeValue $t1, ?TimeValue $t2 ) { |
|
82 | - if ( $t1 === null ) { |
|
81 | + private static function minTimeValue(?TimeValue $t1, ?TimeValue $t2) { |
|
82 | + if ($t1 === null) { |
|
83 | 83 | return $t2; |
84 | 84 | } |
85 | - if ( $t2 === null ) { |
|
85 | + if ($t2 === null) { |
|
86 | 86 | return $t1; |
87 | 87 | } |
88 | - return ( new TimeValueComparer() )->getMinimum( $t1, $t2 ); |
|
88 | + return (new TimeValueComparer())->getMinimum($t1, $t2); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -21,12 +21,12 @@ |
||
21 | 21 | * @return false|int (from the preg_match documentation) returns 1 if the pattern |
22 | 22 | * matches given subject, 0 if it does not, or FALSE if an error occurred. |
23 | 23 | */ |
24 | - public static function runRegexCheck( string $regex, string $text ) { |
|
25 | - $pattern = '(^(?:' . $regex . ')$)u'; |
|
24 | + public static function runRegexCheck(string $regex, string $text) { |
|
25 | + $pattern = '(^(?:'.$regex.')$)u'; |
|
26 | 26 | |
27 | 27 | // `preg_match` emits an E_WARNING when the pattern is not valid regex. |
28 | 28 | // Silence this warning to avoid throwing a ShellboxError. |
29 | 29 | // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged |
30 | - return @preg_match( $pattern, $text ); |
|
30 | + return @preg_match($pattern, $text); |
|
31 | 31 | } |
32 | 32 | } |