@@ -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 |
@@ -40,91 +40,91 @@ |
||
40 | 40 | public const EXPIRY_LOCK = 'WBQC_ExpiryLock'; |
41 | 41 | public const VIOLATION_MESSAGE_RENDERER_FACTORY = 'WBQC_ViolationMessageRendererFactory'; |
42 | 42 | |
43 | - private static function getService( ?MediaWikiServices $services, $name ) { |
|
43 | + private static function getService(?MediaWikiServices $services, $name) { |
|
44 | 44 | $services ??= MediaWikiServices::getInstance(); |
45 | - return $services->getService( $name ); |
|
45 | + return $services->getService($name); |
|
46 | 46 | } |
47 | 47 | |
48 | - public static function getLoggingHelper( ?MediaWikiServices $services = null ): LoggingHelper { |
|
49 | - return self::getService( $services, self::LOGGING_HELPER ); |
|
48 | + public static function getLoggingHelper(?MediaWikiServices $services = null): LoggingHelper { |
|
49 | + return self::getService($services, self::LOGGING_HELPER); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | public static function getConstraintStore( |
53 | 53 | ?MediaWikiServices $services = null |
54 | 54 | ): ConstraintStore { |
55 | - return self::getService( $services, self::CONSTRAINT_STORE ); |
|
55 | + return self::getService($services, self::CONSTRAINT_STORE); |
|
56 | 56 | } |
57 | 57 | |
58 | - public static function getConstraintLookup( ?MediaWikiServices $services = null ): ConstraintLookup { |
|
59 | - return self::getService( $services, self::CONSTRAINT_LOOKUP ); |
|
58 | + public static function getConstraintLookup(?MediaWikiServices $services = null): ConstraintLookup { |
|
59 | + return self::getService($services, self::CONSTRAINT_LOOKUP); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | public static function getCheckResultSerializer( |
63 | 63 | ?MediaWikiServices $services = null |
64 | 64 | ): CheckResultSerializer { |
65 | - return self::getService( $services, self::CHECK_RESULT_SERIALIZER ); |
|
65 | + return self::getService($services, self::CHECK_RESULT_SERIALIZER); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | public static function getCheckResultDeserializer( |
69 | 69 | ?MediaWikiServices $services = null |
70 | 70 | ): CheckResultDeserializer { |
71 | - return self::getService( $services, self::CHECK_RESULT_DESERIALIZER ); |
|
71 | + return self::getService($services, self::CHECK_RESULT_DESERIALIZER); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public static function getViolationMessageSerializer( |
75 | 75 | ?MediaWikiServices $services = null |
76 | 76 | ): ViolationMessageSerializer { |
77 | - return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER ); |
|
77 | + return self::getService($services, self::VIOLATION_MESSAGE_SERIALIZER); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | public static function getViolationMessageDeserializer( |
81 | 81 | ?MediaWikiServices $services = null |
82 | 82 | ): ViolationMessageDeserializer { |
83 | - return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER ); |
|
83 | + return self::getService($services, self::VIOLATION_MESSAGE_DESERIALIZER); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | public static function getConstraintParameterParser( |
87 | 87 | ?MediaWikiServices $services = null |
88 | 88 | ): ConstraintParameterParser { |
89 | - return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER ); |
|
89 | + return self::getService($services, self::CONSTRAINT_PARAMETER_PARSER); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | public static function getConnectionCheckerHelper( |
93 | 93 | ?MediaWikiServices $services = null |
94 | 94 | ): ConnectionCheckerHelper { |
95 | - return self::getService( $services, self::CONNECTION_CHECKER_HELPER ); |
|
95 | + return self::getService($services, self::CONNECTION_CHECKER_HELPER); |
|
96 | 96 | } |
97 | 97 | |
98 | - public static function getRangeCheckerHelper( ?MediaWikiServices $services = null ): RangeCheckerHelper { |
|
99 | - return self::getService( $services, self::RANGE_CHECKER_HELPER ); |
|
98 | + public static function getRangeCheckerHelper(?MediaWikiServices $services = null): RangeCheckerHelper { |
|
99 | + return self::getService($services, self::RANGE_CHECKER_HELPER); |
|
100 | 100 | } |
101 | 101 | |
102 | - public static function getSparqlHelper( ?MediaWikiServices $services = null ): SparqlHelper { |
|
103 | - return self::getService( $services, self::SPARQL_HELPER ); |
|
102 | + public static function getSparqlHelper(?MediaWikiServices $services = null): SparqlHelper { |
|
103 | + return self::getService($services, self::SPARQL_HELPER); |
|
104 | 104 | } |
105 | 105 | |
106 | - public static function getTypeCheckerHelper( ?MediaWikiServices $services = null ): TypeCheckerHelper { |
|
107 | - return self::getService( $services, self::TYPE_CHECKER_HELPER ); |
|
106 | + public static function getTypeCheckerHelper(?MediaWikiServices $services = null): TypeCheckerHelper { |
|
107 | + return self::getService($services, self::TYPE_CHECKER_HELPER); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | public static function getDelegatingConstraintChecker( |
111 | 111 | ?MediaWikiServices $services = null |
112 | 112 | ): DelegatingConstraintChecker { |
113 | - return self::getService( $services, self::DELEGATING_CONSTRAINT_CHECKER ); |
|
113 | + return self::getService($services, self::DELEGATING_CONSTRAINT_CHECKER); |
|
114 | 114 | } |
115 | 115 | |
116 | - public static function getResultsSource( ?MediaWikiServices $services = null ): ResultsSource { |
|
117 | - return self::getService( $services, self::RESULTS_SOURCE ); |
|
116 | + public static function getResultsSource(?MediaWikiServices $services = null): ResultsSource { |
|
117 | + return self::getService($services, self::RESULTS_SOURCE); |
|
118 | 118 | } |
119 | 119 | |
120 | - public static function getExpiryLock( ?MediaWikiServices $services = null ): ExpiryLock { |
|
121 | - return self::getService( $services, self::EXPIRY_LOCK ); |
|
120 | + public static function getExpiryLock(?MediaWikiServices $services = null): ExpiryLock { |
|
121 | + return self::getService($services, self::EXPIRY_LOCK); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | public static function getViolationMessageRendererFactory( |
125 | 125 | ?MediaWikiServices $services = null |
126 | 126 | ): ViolationMessageRendererFactory { |
127 | - return self::getService( $services, self::VIOLATION_MESSAGE_RENDERER_FACTORY ); |
|
127 | + return self::getService($services, self::VIOLATION_MESSAGE_RENDERER_FACTORY); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | } |
@@ -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 | /** |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->config = $config; |
54 | 54 | $this->timeParser = new IsoTimestampParser(); |
55 | 55 | $this->timeCalculator = new TimeValueCalculator(); |
56 | - $this->timeValueComparer = new TimeValueComparer( $this->timeCalculator ); |
|
56 | + $this->timeValueComparer = new TimeValueComparer($this->timeCalculator); |
|
57 | 57 | $this->unitConverter = $unitConverter; |
58 | 58 | } |
59 | 59 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * @param UnboundedQuantityValue $value |
62 | 62 | * @return UnboundedQuantityValue $value converted to standard units if possible, otherwise unchanged $value. |
63 | 63 | */ |
64 | - private function standardize( UnboundedQuantityValue $value ) { |
|
65 | - if ( $this->unitConverter !== null ) { |
|
66 | - $standard = $this->unitConverter->toStandardUnits( $value ); |
|
67 | - if ( $standard !== null ) { |
|
64 | + private function standardize(UnboundedQuantityValue $value) { |
|
65 | + if ($this->unitConverter !== null) { |
|
66 | + $standard = $this->unitConverter->toStandardUnits($value); |
|
67 | + if ($standard !== null) { |
|
68 | 68 | return $standard; |
69 | 69 | } else { |
70 | 70 | return $value; |
@@ -86,33 +86,33 @@ discard block |
||
86 | 86 | * when $lhs is respectively less than, equal to, or greater than $rhs. |
87 | 87 | * (In other words, just like the “spaceship” operator <=>.) |
88 | 88 | */ |
89 | - public function getComparison( ?DataValue $lhs, ?DataValue $rhs ) { |
|
90 | - if ( $lhs === null || $rhs === null ) { |
|
89 | + public function getComparison(?DataValue $lhs, ?DataValue $rhs) { |
|
90 | + if ($lhs === null || $rhs === null) { |
|
91 | 91 | return 0; |
92 | 92 | } |
93 | 93 | |
94 | - if ( $lhs->getType() !== $rhs->getType() ) { |
|
95 | - throw new InvalidArgumentException( 'Different data value types' ); |
|
94 | + if ($lhs->getType() !== $rhs->getType()) { |
|
95 | + throw new InvalidArgumentException('Different data value types'); |
|
96 | 96 | } |
97 | 97 | |
98 | - switch ( $lhs->getType() ) { |
|
98 | + switch ($lhs->getType()) { |
|
99 | 99 | case 'time': |
100 | 100 | /** @var TimeValue $lhs */ |
101 | 101 | /** @var TimeValue $rhs */ |
102 | 102 | '@phan-var TimeValue $lhs'; |
103 | 103 | '@phan-var TimeValue $rhs'; |
104 | - return $this->timeValueComparer->getComparison( $lhs, $rhs ); |
|
104 | + return $this->timeValueComparer->getComparison($lhs, $rhs); |
|
105 | 105 | case 'quantity': |
106 | 106 | /** @var QuantityValue|UnboundedQuantityValue $lhs */ |
107 | 107 | /** @var QuantityValue|UnboundedQuantityValue $rhs */ |
108 | 108 | '@phan-var QuantityValue|UnboundedQuantityValue $lhs'; |
109 | 109 | '@phan-var QuantityValue|UnboundedQuantityValue $rhs'; |
110 | - $lhsStandard = $this->standardize( $lhs ); |
|
111 | - $rhsStandard = $this->standardize( $rhs ); |
|
112 | - return $lhsStandard->getAmount()->compare( $rhsStandard->getAmount() ); |
|
110 | + $lhsStandard = $this->standardize($lhs); |
|
111 | + $rhsStandard = $this->standardize($rhs); |
|
112 | + return $lhsStandard->getAmount()->compare($rhsStandard->getAmount()); |
|
113 | 113 | } |
114 | 114 | |
115 | - throw new InvalidArgumentException( 'Unsupported data value type' ); |
|
115 | + throw new InvalidArgumentException('Unsupported data value type'); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | /** |
@@ -127,71 +127,71 @@ discard block |
||
127 | 127 | * @throws InvalidArgumentException if the values do not both have the same, supported data value type |
128 | 128 | * @return UnboundedQuantityValue |
129 | 129 | */ |
130 | - public function getDifference( DataValue $minuend, DataValue $subtrahend ) { |
|
131 | - if ( $minuend->getType() === 'time' && $subtrahend->getType() === 'time' ) { |
|
132 | - $minuendSeconds = $this->timeCalculator->getTimestamp( $minuend ); |
|
133 | - $subtrahendSeconds = $this->timeCalculator->getTimestamp( $subtrahend ); |
|
130 | + public function getDifference(DataValue $minuend, DataValue $subtrahend) { |
|
131 | + if ($minuend->getType() === 'time' && $subtrahend->getType() === 'time') { |
|
132 | + $minuendSeconds = $this->timeCalculator->getTimestamp($minuend); |
|
133 | + $subtrahendSeconds = $this->timeCalculator->getTimestamp($subtrahend); |
|
134 | 134 | return UnboundedQuantityValue::newFromNumber( |
135 | 135 | $minuendSeconds - $subtrahendSeconds, |
136 | - $this->config->get( 'WBQualityConstraintsSecondUnit' ) |
|
136 | + $this->config->get('WBQualityConstraintsSecondUnit') |
|
137 | 137 | ); |
138 | 138 | } |
139 | - if ( $minuend->getType() === 'quantity' && $subtrahend->getType() === 'quantity' ) { |
|
140 | - $minuendStandard = $this->standardize( $minuend ); |
|
141 | - $subtrahendStandard = $this->standardize( $subtrahend ); |
|
139 | + if ($minuend->getType() === 'quantity' && $subtrahend->getType() === 'quantity') { |
|
140 | + $minuendStandard = $this->standardize($minuend); |
|
141 | + $subtrahendStandard = $this->standardize($subtrahend); |
|
142 | 142 | $minuendValue = $minuendStandard->getAmount()->getValueFloat(); |
143 | 143 | $subtrahendValue = $subtrahendStandard->getAmount()->getValueFloat(); |
144 | 144 | $diff = $minuendValue - $subtrahendValue; |
145 | 145 | // we don’t check whether both quantities have the same standard unit – |
146 | 146 | // that’s the job of a different constraint type, Units (T164372) |
147 | - return UnboundedQuantityValue::newFromNumber( $diff, $minuendStandard->getUnit() ); |
|
147 | + return UnboundedQuantityValue::newFromNumber($diff, $minuendStandard->getUnit()); |
|
148 | 148 | } |
149 | 149 | |
150 | - throw new InvalidArgumentException( 'Unsupported or different data value types' ); |
|
150 | + throw new InvalidArgumentException('Unsupported or different data value types'); |
|
151 | 151 | } |
152 | 152 | |
153 | - public function getDifferenceInYears( TimeValue $minuend, TimeValue $subtrahend ) { |
|
154 | - if ( !preg_match( '/^([-+]\d{1,16})-(.*)$/', $minuend->getTime(), $minuendMatches ) || |
|
155 | - !preg_match( '/^([-+]\d{1,16})-(.*)$/', $subtrahend->getTime(), $subtrahendMatches ) |
|
153 | + public function getDifferenceInYears(TimeValue $minuend, TimeValue $subtrahend) { |
|
154 | + if (!preg_match('/^([-+]\d{1,16})-(.*)$/', $minuend->getTime(), $minuendMatches) || |
|
155 | + !preg_match('/^([-+]\d{1,16})-(.*)$/', $subtrahend->getTime(), $subtrahendMatches) |
|
156 | 156 | ) { |
157 | - throw new InvalidArgumentException( 'TimeValue::getTime() did not match expected format' ); |
|
157 | + throw new InvalidArgumentException('TimeValue::getTime() did not match expected format'); |
|
158 | 158 | } |
159 | - $minuendYear = (float)$minuendMatches[1]; |
|
160 | - $subtrahendYear = (float)$subtrahendMatches[1]; |
|
159 | + $minuendYear = (float) $minuendMatches[1]; |
|
160 | + $subtrahendYear = (float) $subtrahendMatches[1]; |
|
161 | 161 | $minuendRest = $minuendMatches[2]; |
162 | 162 | $subtrahendRest = $subtrahendMatches[2]; |
163 | 163 | |
164 | 164 | // calculate difference of years |
165 | 165 | $diff = $minuendYear - $subtrahendYear; |
166 | - if ( $minuendYear > 0.0 && $subtrahendYear < 0.0 ) { |
|
166 | + if ($minuendYear > 0.0 && $subtrahendYear < 0.0) { |
|
167 | 167 | $diff -= 1.0; // there is no year 0, remove it from difference |
168 | - } elseif ( $minuendYear < 0.0 && $subtrahendYear > 0.0 ) { |
|
168 | + } elseif ($minuendYear < 0.0 && $subtrahendYear > 0.0) { |
|
169 | 169 | $diff -= -1.0; // there is no year 0, remove it from negative difference |
170 | 170 | } |
171 | 171 | |
172 | 172 | // adjust for date within year by parsing the month-day part within the same year |
173 | - $minuendDateValue = $this->timeParser->parse( '+0000000000001970-' . $minuendRest ); |
|
174 | - $subtrahendDateValue = $this->timeParser->parse( '+0000000000001970-' . $subtrahendRest ); |
|
175 | - $minuendDateSeconds = $this->timeCalculator->getTimestamp( $minuendDateValue ); |
|
176 | - $subtrahendDateSeconds = $this->timeCalculator->getTimestamp( $subtrahendDateValue ); |
|
177 | - if ( $minuendDateSeconds < $subtrahendDateSeconds ) { |
|
173 | + $minuendDateValue = $this->timeParser->parse('+0000000000001970-'.$minuendRest); |
|
174 | + $subtrahendDateValue = $this->timeParser->parse('+0000000000001970-'.$subtrahendRest); |
|
175 | + $minuendDateSeconds = $this->timeCalculator->getTimestamp($minuendDateValue); |
|
176 | + $subtrahendDateSeconds = $this->timeCalculator->getTimestamp($subtrahendDateValue); |
|
177 | + if ($minuendDateSeconds < $subtrahendDateSeconds) { |
|
178 | 178 | // difference in the last year is actually less than one full year |
179 | 179 | // e. g. 1975-03-01 - 1974-09-01 is just six months |
180 | 180 | // (we don’t need sub-year precision in the difference, adjusting by 0.5 is enough) |
181 | 181 | $diff -= 0.5; |
182 | - } elseif ( $minuendDateSeconds > $subtrahendDateSeconds ) { |
|
182 | + } elseif ($minuendDateSeconds > $subtrahendDateSeconds) { |
|
183 | 183 | // difference in the last year is actually more than one full year |
184 | 184 | // e. g. 1975-09-01 - 1974-03-01 is 18 months |
185 | 185 | // (we don’t need sub-year precision in the difference, adjusting by 0.5 is enough) |
186 | 186 | $diff += 0.5; |
187 | 187 | } |
188 | 188 | |
189 | - $unit = $this->config->get( 'WBQualityConstraintsYearUnit' ); |
|
190 | - return UnboundedQuantityValue::newFromNumber( $diff, $unit ); |
|
189 | + $unit = $this->config->get('WBQualityConstraintsYearUnit'); |
|
190 | + return UnboundedQuantityValue::newFromNumber($diff, $unit); |
|
191 | 191 | } |
192 | 192 | |
193 | - public function isFutureTime( TimeValue $timeValue ) { |
|
194 | - return $this->timeValueComparer->isFutureTime( $timeValue ); |
|
193 | + public function isFutureTime(TimeValue $timeValue) { |
|
194 | + return $this->timeValueComparer->isFutureTime($timeValue); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |
@@ -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\Specials; |
6 | 6 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | Config $config, |
92 | 92 | IBufferingStatsdDataFactory $dataFactory |
93 | 93 | ) { |
94 | - parent::__construct( 'ConstraintReport' ); |
|
94 | + parent::__construct('ConstraintReport'); |
|
95 | 95 | |
96 | 96 | $this->entityLookup = $entityLookup; |
97 | 97 | $this->entityTitleLookup = $entityTitleLookup; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | |
112 | 112 | $this->violationMessageRenderer = $violationMessageRendererFactory->getViolationMessageRenderer( |
113 | 113 | $language, |
114 | - $languageFallbackChainFactory->newFromLanguage( $language ), |
|
114 | + $languageFallbackChainFactory->newFromLanguage($language), |
|
115 | 115 | $this->getContext() |
116 | 116 | ); |
117 | 117 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @inheritDoc |
146 | 146 | */ |
147 | 147 | public function getDescription() { |
148 | - return $this->msg( 'wbqc-constraintreport' ); |
|
148 | + return $this->msg('wbqc-constraintreport'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -157,56 +157,56 @@ discard block |
||
157 | 157 | * @throws EntityIdParsingException |
158 | 158 | * @throws UnexpectedValueException |
159 | 159 | */ |
160 | - public function execute( $subPage ) { |
|
160 | + public function execute($subPage) { |
|
161 | 161 | $out = $this->getOutput(); |
162 | 162 | |
163 | - $postRequest = $this->getContext()->getRequest()->getVal( 'entityid' ); |
|
164 | - if ( $postRequest ) { |
|
163 | + $postRequest = $this->getContext()->getRequest()->getVal('entityid'); |
|
164 | + if ($postRequest) { |
|
165 | 165 | try { |
166 | - $entityId = $this->entityIdParser->parse( $postRequest ); |
|
167 | - $out->redirect( $this->getPageTitle( $entityId->getSerialization() )->getLocalURL() ); |
|
166 | + $entityId = $this->entityIdParser->parse($postRequest); |
|
167 | + $out->redirect($this->getPageTitle($entityId->getSerialization())->getLocalURL()); |
|
168 | 168 | return; |
169 | - } catch ( EntityIdParsingException $e ) { |
|
169 | + } catch (EntityIdParsingException $e) { |
|
170 | 170 | // fall through, error is shown later |
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
174 | 174 | $out->enableOOUI(); |
175 | - $out->addModules( $this->getModules() ); |
|
175 | + $out->addModules($this->getModules()); |
|
176 | 176 | |
177 | 177 | $this->setHeaders(); |
178 | 178 | |
179 | - $out->addHTML( $this->getExplanationText() ); |
|
179 | + $out->addHTML($this->getExplanationText()); |
|
180 | 180 | $this->buildEntityIdForm(); |
181 | 181 | |
182 | - if ( $postRequest ) { |
|
182 | + if ($postRequest) { |
|
183 | 183 | // must be an invalid entity ID (otherwise we would have redirected and returned above) |
184 | 184 | $out->addHTML( |
185 | - $this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true ) |
|
185 | + $this->buildNotice('wbqc-constraintreport-invalid-entity-id', true) |
|
186 | 186 | ); |
187 | 187 | return; |
188 | 188 | } |
189 | 189 | |
190 | - if ( !$subPage ) { |
|
190 | + if (!$subPage) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
194 | - if ( !is_string( $subPage ) ) { |
|
195 | - throw new InvalidArgumentException( '$subPage must be string.' ); |
|
194 | + if (!is_string($subPage)) { |
|
195 | + throw new InvalidArgumentException('$subPage must be string.'); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | try { |
199 | - $entityId = $this->entityIdParser->parse( $subPage ); |
|
200 | - } catch ( EntityIdParsingException $e ) { |
|
199 | + $entityId = $this->entityIdParser->parse($subPage); |
|
200 | + } catch (EntityIdParsingException $e) { |
|
201 | 201 | $out->addHTML( |
202 | - $this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true ) |
|
202 | + $this->buildNotice('wbqc-constraintreport-invalid-entity-id', true) |
|
203 | 203 | ); |
204 | 204 | return; |
205 | 205 | } |
206 | 206 | |
207 | - if ( !$this->entityLookup->hasEntity( $entityId ) ) { |
|
207 | + if (!$this->entityLookup->hasEntity($entityId)) { |
|
208 | 208 | $out->addHTML( |
209 | - $this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true ) |
|
209 | + $this->buildNotice('wbqc-constraintreport-not-existent-entity', true) |
|
210 | 210 | ); |
211 | 211 | return; |
212 | 212 | } |
@@ -214,18 +214,18 @@ discard block |
||
214 | 214 | $this->dataFactory->increment( |
215 | 215 | 'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck' |
216 | 216 | ); |
217 | - $results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId ); |
|
217 | + $results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId); |
|
218 | 218 | |
219 | - if ( $results !== [] ) { |
|
219 | + if ($results !== []) { |
|
220 | 220 | $out->addHTML( |
221 | - $this->buildResultHeader( $entityId ) |
|
222 | - . $this->buildSummary( $results ) |
|
223 | - . $this->buildResultTable( $entityId, $results ) |
|
221 | + $this->buildResultHeader($entityId) |
|
222 | + . $this->buildSummary($results) |
|
223 | + . $this->buildResultTable($entityId, $results) |
|
224 | 224 | ); |
225 | 225 | } else { |
226 | 226 | $out->addHTML( |
227 | - $this->buildResultHeader( $entityId ) |
|
228 | - . $this->buildNotice( 'wbqc-constraintreport-empty-result' ) |
|
227 | + $this->buildResultHeader($entityId) |
|
228 | + . $this->buildNotice('wbqc-constraintreport-empty-result') |
|
229 | 229 | ); |
230 | 230 | } |
231 | 231 | } |
@@ -241,16 +241,16 @@ discard block |
||
241 | 241 | 'name' => 'entityid', |
242 | 242 | 'label-message' => 'wbqc-constraintreport-form-entityid-label', |
243 | 243 | 'cssclass' => 'wbqc-constraintreport-form-entity-id', |
244 | - 'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped(), |
|
244 | + 'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped(), |
|
245 | 245 | 'required' => true, |
246 | 246 | ], |
247 | 247 | ]; |
248 | - $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' ); |
|
249 | - $htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() ); |
|
250 | - $htmlForm->setSubmitCallback( static function () { |
|
248 | + $htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form'); |
|
249 | + $htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped()); |
|
250 | + $htmlForm->setSubmitCallback(static function() { |
|
251 | 251 | return false; |
252 | 252 | } ); |
253 | - $htmlForm->setMethod( 'post' ); |
|
253 | + $htmlForm->setMethod('post'); |
|
254 | 254 | $htmlForm->show(); |
255 | 255 | } |
256 | 256 | |
@@ -264,9 +264,9 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @return string HTML |
266 | 266 | */ |
267 | - private function buildNotice( string $messageKey, bool $error = false ): string { |
|
267 | + private function buildNotice(string $messageKey, bool $error = false): string { |
|
268 | 268 | $cssClasses = 'wbqc-constraintreport-notice'; |
269 | - if ( $error ) { |
|
269 | + if ($error) { |
|
270 | 270 | $cssClasses .= ' wbqc-constraintreport-notice-error'; |
271 | 271 | } |
272 | 272 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | [ |
276 | 276 | 'class' => $cssClasses, |
277 | 277 | ], |
278 | - $this->msg( $messageKey )->escaped() |
|
278 | + $this->msg($messageKey)->escaped() |
|
279 | 279 | ); |
280 | 280 | } |
281 | 281 | |
@@ -285,16 +285,16 @@ discard block |
||
285 | 285 | private function getExplanationText(): string { |
286 | 286 | return Html::rawElement( |
287 | 287 | 'div', |
288 | - [ 'class' => 'wbqc-explanation' ], |
|
288 | + ['class' => 'wbqc-explanation'], |
|
289 | 289 | Html::rawElement( |
290 | 290 | 'p', |
291 | 291 | [], |
292 | - $this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped() |
|
292 | + $this->msg('wbqc-constraintreport-explanation-part-one')->escaped() |
|
293 | 293 | ) |
294 | 294 | . Html::rawElement( |
295 | 295 | 'p', |
296 | 296 | [], |
297 | - $this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped() |
|
297 | + $this->msg('wbqc-constraintreport-explanation-part-two')->escaped() |
|
298 | 298 | ) |
299 | 299 | ); |
300 | 300 | } |
@@ -305,31 +305,31 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @return string HTML |
307 | 307 | */ |
308 | - private function buildResultTable( EntityId $entityId, array $results ): string { |
|
308 | + private function buildResultTable(EntityId $entityId, array $results): string { |
|
309 | 309 | // Set table headers |
310 | 310 | $table = new HtmlTableBuilder( |
311 | 311 | [ |
312 | 312 | new HtmlTableHeaderBuilder( |
313 | - $this->msg( 'wbqc-constraintreport-result-table-header-status' )->text(), |
|
313 | + $this->msg('wbqc-constraintreport-result-table-header-status')->text(), |
|
314 | 314 | true |
315 | 315 | ), |
316 | 316 | new HtmlTableHeaderBuilder( |
317 | - $this->msg( 'wbqc-constraintreport-result-table-header-property' )->text(), |
|
317 | + $this->msg('wbqc-constraintreport-result-table-header-property')->text(), |
|
318 | 318 | true |
319 | 319 | ), |
320 | 320 | new HtmlTableHeaderBuilder( |
321 | - $this->msg( 'wbqc-constraintreport-result-table-header-message' )->text(), |
|
321 | + $this->msg('wbqc-constraintreport-result-table-header-message')->text(), |
|
322 | 322 | true |
323 | 323 | ), |
324 | 324 | new HtmlTableHeaderBuilder( |
325 | - $this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->text(), |
|
325 | + $this->msg('wbqc-constraintreport-result-table-header-constraint')->text(), |
|
326 | 326 | true |
327 | 327 | ), |
328 | 328 | ] |
329 | 329 | ); |
330 | 330 | |
331 | - foreach ( $results as $result ) { |
|
332 | - $table = $this->appendToResultTable( $table, $entityId, $result ); |
|
331 | + foreach ($results as $result) { |
|
332 | + $table = $this->appendToResultTable($table, $entityId, $result); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | return $table->toHtml(); |
@@ -341,35 +341,35 @@ discard block |
||
341 | 341 | CheckResult $result |
342 | 342 | ): HtmlTableBuilder { |
343 | 343 | $message = $result->getMessage(); |
344 | - if ( $message === null ) { |
|
344 | + if ($message === null) { |
|
345 | 345 | // no row for this result |
346 | 346 | return $table; |
347 | 347 | } |
348 | 348 | |
349 | 349 | // Status column |
350 | - $statusColumn = $this->formatStatus( $result->getStatus() ); |
|
350 | + $statusColumn = $this->formatStatus($result->getStatus()); |
|
351 | 351 | |
352 | 352 | // Property column |
353 | - $propertyId = new NumericPropertyId( $result->getContextCursor()->getSnakPropertyId() ); |
|
353 | + $propertyId = new NumericPropertyId($result->getContextCursor()->getSnakPropertyId()); |
|
354 | 354 | $propertyColumn = $this->getClaimLink( |
355 | 355 | $entityId, |
356 | 356 | $propertyId, |
357 | - $this->entityIdLabelFormatter->formatEntityId( $propertyId ) |
|
357 | + $this->entityIdLabelFormatter->formatEntityId($propertyId) |
|
358 | 358 | ); |
359 | 359 | |
360 | 360 | // Message column |
361 | - $messageColumn = $this->violationMessageRenderer->render( $message ); |
|
361 | + $messageColumn = $this->violationMessageRenderer->render($message); |
|
362 | 362 | |
363 | 363 | // Constraint column |
364 | 364 | $constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId(); |
365 | 365 | try { |
366 | - $constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) ); |
|
367 | - } catch ( InvalidArgumentException $e ) { |
|
368 | - $constraintTypeLabel = htmlspecialchars( $constraintTypeItemId ); |
|
366 | + $constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId)); |
|
367 | + } catch (InvalidArgumentException $e) { |
|
368 | + $constraintTypeLabel = htmlspecialchars($constraintTypeItemId); |
|
369 | 369 | } |
370 | 370 | $constraintColumn = $this->getClaimLink( |
371 | 371 | $propertyId, |
372 | - new NumericPropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ), |
|
372 | + new NumericPropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')), |
|
373 | 373 | $constraintTypeLabel |
374 | 374 | ); |
375 | 375 | |
@@ -377,16 +377,16 @@ discard block |
||
377 | 377 | $table->appendRow( |
378 | 378 | [ |
379 | 379 | new HtmlTableCellBuilder( |
380 | - new HtmlArmor( $statusColumn ) |
|
380 | + new HtmlArmor($statusColumn) |
|
381 | 381 | ), |
382 | 382 | new HtmlTableCellBuilder( |
383 | - new HtmlArmor( $propertyColumn ) |
|
383 | + new HtmlArmor($propertyColumn) |
|
384 | 384 | ), |
385 | 385 | new HtmlTableCellBuilder( |
386 | - new HtmlArmor( $messageColumn ) |
|
386 | + new HtmlArmor($messageColumn) |
|
387 | 387 | ), |
388 | 388 | new HtmlTableCellBuilder( |
389 | - new HtmlArmor( $constraintColumn ) |
|
389 | + new HtmlArmor($constraintColumn) |
|
390 | 390 | ), |
391 | 391 | ] |
392 | 392 | ); |
@@ -401,15 +401,15 @@ discard block |
||
401 | 401 | * |
402 | 402 | * @return string HTML |
403 | 403 | */ |
404 | - protected function buildResultHeader( EntityId $entityId ): string { |
|
405 | - $entityLink = sprintf( '%s (%s)', |
|
406 | - $this->entityIdLinkFormatter->formatEntityId( $entityId ), |
|
407 | - htmlspecialchars( $entityId->getSerialization() ) ); |
|
404 | + protected function buildResultHeader(EntityId $entityId): string { |
|
405 | + $entityLink = sprintf('%s (%s)', |
|
406 | + $this->entityIdLinkFormatter->formatEntityId($entityId), |
|
407 | + htmlspecialchars($entityId->getSerialization())); |
|
408 | 408 | |
409 | 409 | return Html::rawElement( |
410 | 410 | 'h3', |
411 | 411 | [], |
412 | - sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink ) |
|
412 | + sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink) |
|
413 | 413 | ); |
414 | 414 | } |
415 | 415 | |
@@ -420,24 +420,24 @@ discard block |
||
420 | 420 | * |
421 | 421 | * @return string HTML |
422 | 422 | */ |
423 | - protected function buildSummary( array $results ): string { |
|
423 | + protected function buildSummary(array $results): string { |
|
424 | 424 | $statuses = []; |
425 | - foreach ( $results as $result ) { |
|
426 | - $status = strtolower( $result->getStatus() ); |
|
427 | - $statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1; |
|
425 | + foreach ($results as $result) { |
|
426 | + $status = strtolower($result->getStatus()); |
|
427 | + $statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1; |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | $statusElements = []; |
431 | - foreach ( $statuses as $status => $count ) { |
|
432 | - if ( $count > 0 ) { |
|
431 | + foreach ($statuses as $status => $count) { |
|
432 | + if ($count > 0) { |
|
433 | 433 | $statusElements[] = |
434 | - $this->formatStatus( $status ) |
|
434 | + $this->formatStatus($status) |
|
435 | 435 | . ': ' |
436 | 436 | . $count; |
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
440 | - return Html::rawElement( 'p', [], implode( ', ', $statusElements ) ); |
|
440 | + return Html::rawElement('p', [], implode(', ', $statusElements)); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | * |
450 | 450 | * @return string HTML |
451 | 451 | */ |
452 | - private function formatStatus( string $status ): string { |
|
453 | - $messageName = "wbqc-constraintreport-status-" . strtolower( $status ); |
|
452 | + private function formatStatus(string $status): string { |
|
453 | + $messageName = "wbqc-constraintreport-status-".strtolower($status); |
|
454 | 454 | $statusIcons = [ |
455 | 455 | CheckResult::STATUS_SUGGESTION => [ |
456 | 456 | 'icon' => 'suggestion-constraint-violation', |
@@ -467,25 +467,25 @@ discard block |
||
467 | 467 | ], |
468 | 468 | ]; |
469 | 469 | |
470 | - if ( array_key_exists( $status, $statusIcons ) ) { |
|
471 | - $iconWidget = new IconWidget( $statusIcons[$status] ); |
|
472 | - $iconHtml = $iconWidget->toString() . ' '; |
|
470 | + if (array_key_exists($status, $statusIcons)) { |
|
471 | + $iconWidget = new IconWidget($statusIcons[$status]); |
|
472 | + $iconHtml = $iconWidget->toString().' '; |
|
473 | 473 | } else { |
474 | 474 | $iconHtml = ''; |
475 | 475 | } |
476 | 476 | |
477 | - $labelWidget = new LabelWidget( [ |
|
478 | - 'label' => $this->msg( $messageName )->text(), |
|
479 | - ] ); |
|
477 | + $labelWidget = new LabelWidget([ |
|
478 | + 'label' => $this->msg($messageName)->text(), |
|
479 | + ]); |
|
480 | 480 | $labelHtml = $labelWidget->toString(); |
481 | 481 | |
482 | 482 | $formattedStatus = |
483 | 483 | Html::rawElement( |
484 | 484 | 'span', |
485 | 485 | [ |
486 | - 'class' => 'wbqc-status wbqc-status-' . $status, |
|
486 | + 'class' => 'wbqc-status wbqc-status-'.$status, |
|
487 | 487 | ], |
488 | - $iconHtml . $labelHtml |
|
488 | + $iconHtml.$labelHtml |
|
489 | 489 | ); |
490 | 490 | |
491 | 491 | return $formattedStatus; |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | return Html::rawElement( |
509 | 509 | 'a', |
510 | 510 | [ |
511 | - 'href' => $this->getClaimUrl( $entityId, $propertyId ), |
|
511 | + 'href' => $this->getClaimUrl($entityId, $propertyId), |
|
512 | 512 | 'target' => '_blank', |
513 | 513 | ], |
514 | 514 | $text |
@@ -522,8 +522,8 @@ discard block |
||
522 | 522 | EntityId $entityId, |
523 | 523 | NumericPropertyId $propertyId |
524 | 524 | ): string { |
525 | - $title = $this->entityTitleLookup->getTitleForId( $entityId ); |
|
526 | - $entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() ); |
|
525 | + $title = $this->entityTitleLookup->getTitleForId($entityId); |
|
526 | + $entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization()); |
|
527 | 527 | |
528 | 528 | return $entityUrl; |
529 | 529 | } |
@@ -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 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $this->sparqlHelper = $sparqlHelper; |
68 | 68 | $this->shellboxClientFactory = $shellboxClientFactory; |
69 | 69 | $this->knownGoodPatternsAsKeys = array_fill_keys( |
70 | - $this->config->get( 'WBQualityConstraintsFormatCheckerKnownGoodRegexPatterns' ), |
|
70 | + $this->config->get('WBQualityConstraintsFormatCheckerKnownGoodRegexPatterns'), |
|
71 | 71 | null |
72 | 72 | ); |
73 | 73 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @throws ConstraintParameterException |
101 | 101 | * @return CheckResult |
102 | 102 | */ |
103 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
103 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
104 | 104 | $constraintParameters = $constraint->getConstraintParameters(); |
105 | 105 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
106 | 106 | |
@@ -115,9 +115,9 @@ discard block |
||
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,7 +126,7 @@ discard block |
||
126 | 126 | * error handling: |
127 | 127 | * type of $dataValue for properties with 'Format' constraint has to be 'string' or 'monolingualtext' |
128 | 128 | */ |
129 | - switch ( $dataValue->getType() ) { |
|
129 | + switch ($dataValue->getType()) { |
|
130 | 130 | case 'string': |
131 | 131 | $text = $dataValue->getValue(); |
132 | 132 | break; |
@@ -136,13 +136,13 @@ discard block |
||
136 | 136 | $text = $dataValue->getText(); |
137 | 137 | break; |
138 | 138 | default: |
139 | - $message = ( new ViolationMessage( 'wbqc-violation-message-value-needed-of-types-2' ) ) |
|
140 | - ->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM ) |
|
141 | - ->withDataValueType( 'string' ) |
|
142 | - ->withDataValueType( 'monolingualtext' ); |
|
143 | - return new CheckResult( $context, $constraint, CheckResult::STATUS_VIOLATION, $message ); |
|
139 | + $message = (new ViolationMessage('wbqc-violation-message-value-needed-of-types-2')) |
|
140 | + ->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM) |
|
141 | + ->withDataValueType('string') |
|
142 | + ->withDataValueType('monolingualtext'); |
|
143 | + return new CheckResult($context, $constraint, CheckResult::STATUS_VIOLATION, $message); |
|
144 | 144 | } |
145 | - $status = $this->runRegexCheck( $text, $format ); |
|
145 | + $status = $this->runRegexCheck($text, $format); |
|
146 | 146 | $message = $this->formatMessage( |
147 | 147 | $status, |
148 | 148 | $text, |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $syntaxClarifications, |
152 | 152 | $constraintTypeItemId |
153 | 153 | ); |
154 | - return new CheckResult( $context, $constraint, $status, $message ); |
|
154 | + return new CheckResult($context, $constraint, $status, $message); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | private function formatMessage( |
@@ -163,42 +163,42 @@ discard block |
||
163 | 163 | string $constraintTypeItemId |
164 | 164 | ): ?ViolationMessage { |
165 | 165 | $message = null; |
166 | - if ( $status === CheckResult::STATUS_VIOLATION ) { |
|
167 | - $message = ( new ViolationMessage( 'wbqc-violation-message-format-clarification' ) ) |
|
168 | - ->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY ) |
|
169 | - ->withDataValue( new StringValue( $text ), Role::OBJECT ) |
|
170 | - ->withInlineCode( $format, Role::CONSTRAINT_PARAMETER_VALUE ) |
|
171 | - ->withMultilingualText( $syntaxClarifications, Role::CONSTRAINT_PARAMETER_VALUE ); |
|
172 | - } elseif ( $status === CheckResult::STATUS_TODO ) { |
|
173 | - $message = ( new ViolationMessage( 'wbqc-violation-message-security-reason' ) ) |
|
174 | - ->withEntityId( new ItemId( $constraintTypeItemId ), Role::CONSTRAINT_TYPE_ITEM ); |
|
166 | + if ($status === CheckResult::STATUS_VIOLATION) { |
|
167 | + $message = (new ViolationMessage('wbqc-violation-message-format-clarification')) |
|
168 | + ->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY) |
|
169 | + ->withDataValue(new StringValue($text), Role::OBJECT) |
|
170 | + ->withInlineCode($format, Role::CONSTRAINT_PARAMETER_VALUE) |
|
171 | + ->withMultilingualText($syntaxClarifications, Role::CONSTRAINT_PARAMETER_VALUE); |
|
172 | + } elseif ($status === CheckResult::STATUS_TODO) { |
|
173 | + $message = (new ViolationMessage('wbqc-violation-message-security-reason')) |
|
174 | + ->withEntityId(new ItemId($constraintTypeItemId), Role::CONSTRAINT_TYPE_ITEM); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | return $message; |
178 | 178 | } |
179 | 179 | |
180 | - private function runRegexCheck( string $text, string $format ): string { |
|
181 | - if ( !$this->config->get( 'WBQualityConstraintsCheckFormatConstraint' ) ) { |
|
180 | + private function runRegexCheck(string $text, string $format): string { |
|
181 | + if (!$this->config->get('WBQualityConstraintsCheckFormatConstraint')) { |
|
182 | 182 | return CheckResult::STATUS_TODO; |
183 | 183 | } |
184 | - if ( \array_key_exists( $format, $this->knownGoodPatternsAsKeys ) ) { |
|
185 | - $checkResult = FormatCheckerHelper::runRegexCheck( $format, $text ); |
|
184 | + if (\array_key_exists($format, $this->knownGoodPatternsAsKeys)) { |
|
185 | + $checkResult = FormatCheckerHelper::runRegexCheck($format, $text); |
|
186 | 186 | } elseif ( |
187 | - $this->config->get( 'WBQualityConstraintsFormatCheckerShellboxRatio' ) > (float)wfRandom() |
|
187 | + $this->config->get('WBQualityConstraintsFormatCheckerShellboxRatio') > (float) wfRandom() |
|
188 | 188 | ) { |
189 | - $checkResult = $this->runRegexCheckUsingShellbox( $text, $format ); |
|
189 | + $checkResult = $this->runRegexCheckUsingShellbox($text, $format); |
|
190 | 190 | } else { |
191 | - return $this->runRegexCheckUsingSparql( $text, $format ); |
|
191 | + return $this->runRegexCheckUsingSparql($text, $format); |
|
192 | 192 | } |
193 | 193 | |
194 | - if ( $checkResult === 1 ) { |
|
194 | + if ($checkResult === 1) { |
|
195 | 195 | return CheckResult::STATUS_COMPLIANCE; |
196 | - } elseif ( $checkResult === 0 ) { |
|
196 | + } elseif ($checkResult === 0) { |
|
197 | 197 | return CheckResult::STATUS_VIOLATION; |
198 | - } elseif ( $checkResult === false ) { |
|
198 | + } elseif ($checkResult === false) { |
|
199 | 199 | throw new ConstraintParameterException( |
200 | - ( new ViolationMessage( 'wbqc-violation-message-parameter-regex' ) ) |
|
201 | - ->withInlineCode( $format, Role::CONSTRAINT_PARAMETER_VALUE ) |
|
200 | + (new ViolationMessage('wbqc-violation-message-parameter-regex')) |
|
201 | + ->withInlineCode($format, Role::CONSTRAINT_PARAMETER_VALUE) |
|
202 | 202 | ); |
203 | 203 | } else { |
204 | 204 | return $checkResult; |
@@ -212,35 +212,35 @@ discard block |
||
212 | 212 | * - FALSE if $format is invalid regex |
213 | 213 | * - CheckResult::STATUS_TODO if Shellbox is not enabled |
214 | 214 | */ |
215 | - private function runRegexCheckUsingShellbox( string $text, string $format ) { |
|
216 | - if ( !$this->shellboxClientFactory->isEnabled( 'constraint-regex-checker' ) ) { |
|
215 | + private function runRegexCheckUsingShellbox(string $text, string $format) { |
|
216 | + if (!$this->shellboxClientFactory->isEnabled('constraint-regex-checker')) { |
|
217 | 217 | return CheckResult::STATUS_TODO; |
218 | 218 | } |
219 | 219 | |
220 | - return $this->shellboxClientFactory->getClient( [ |
|
221 | - 'timeout' => $this->config->get( 'WBQualityConstraintsSparqlMaxMillis' ) / 1000, |
|
220 | + return $this->shellboxClientFactory->getClient([ |
|
221 | + 'timeout' => $this->config->get('WBQualityConstraintsSparqlMaxMillis') / 1000, |
|
222 | 222 | 'service' => 'constraint-regex-checker', |
223 | - ] )->call( |
|
223 | + ])->call( |
|
224 | 224 | 'constraint-regex-checker', |
225 | - [ FormatCheckerHelper::class, 'runRegexCheck' ], |
|
226 | - [ $format, $text ], |
|
227 | - [ 'classes' => [ FormatCheckerHelper::class ] ], |
|
225 | + [FormatCheckerHelper::class, 'runRegexCheck'], |
|
226 | + [$format, $text], |
|
227 | + ['classes' => [FormatCheckerHelper::class]], |
|
228 | 228 | ); |
229 | 229 | } |
230 | 230 | |
231 | - private function runRegexCheckUsingSparql( string $text, string $format ): string { |
|
232 | - if ( $this->sparqlHelper instanceof DummySparqlHelper ) { |
|
231 | + private function runRegexCheckUsingSparql(string $text, string $format): string { |
|
232 | + if ($this->sparqlHelper instanceof DummySparqlHelper) { |
|
233 | 233 | return CheckResult::STATUS_TODO; |
234 | 234 | } |
235 | 235 | |
236 | - if ( $this->sparqlHelper->matchesRegularExpression( $text, $format ) ) { |
|
236 | + if ($this->sparqlHelper->matchesRegularExpression($text, $format)) { |
|
237 | 237 | return CheckResult::STATUS_COMPLIANCE; |
238 | 238 | } else { |
239 | 239 | return CheckResult::STATUS_VIOLATION; |
240 | 240 | } |
241 | 241 | } |
242 | 242 | |
243 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
243 | + public function checkConstraintParameters(Constraint $constraint) { |
|
244 | 244 | $constraintParameters = $constraint->getConstraintParameters(); |
245 | 245 | $constraintTypeItemId = $constraint->getConstraintTypeItemId(); |
246 | 246 | $exceptions = []; |
@@ -249,14 +249,14 @@ discard block |
||
249 | 249 | $constraintParameters, |
250 | 250 | $constraintTypeItemId |
251 | 251 | ); |
252 | - } catch ( ConstraintParameterException $e ) { |
|
252 | + } catch (ConstraintParameterException $e) { |
|
253 | 253 | $exceptions[] = $e; |
254 | 254 | } |
255 | 255 | try { |
256 | 256 | $this->constraintParameterParser->parseSyntaxClarificationParameter( |
257 | 257 | $constraintParameters |
258 | 258 | ); |
259 | - } catch ( ConstraintParameterException $e ) { |
|
259 | + } catch (ConstraintParameterException $e) { |
|
260 | 260 | $exceptions[] = $e; |
261 | 261 | } |
262 | 262 | return $exceptions; |
@@ -81,26 +81,26 @@ discard block |
||
81 | 81 | * @return bool |
82 | 82 | * @throws OverflowException if $entitiesChecked exceeds the configured limit |
83 | 83 | */ |
84 | - private function isSubclassOf( EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0 ) { |
|
85 | - $maxEntities = $this->config->get( 'WBQualityConstraintsTypeCheckMaxEntities' ); |
|
84 | + private function isSubclassOf(EntityId $comparativeClass, array $classesToCheck, &$entitiesChecked = 0) { |
|
85 | + $maxEntities = $this->config->get('WBQualityConstraintsTypeCheckMaxEntities'); |
|
86 | 86 | if ( ++$entitiesChecked > $maxEntities ) { |
87 | - throw new OverflowException( 'Too many entities to check' ); |
|
87 | + throw new OverflowException('Too many entities to check'); |
|
88 | 88 | } |
89 | 89 | |
90 | - $item = $this->entityLookup->getEntity( $comparativeClass ); |
|
91 | - if ( !( $item instanceof StatementListProvider ) ) { |
|
90 | + $item = $this->entityLookup->getEntity($comparativeClass); |
|
91 | + if (!($item instanceof StatementListProvider)) { |
|
92 | 92 | return false; // lookup failed, probably because item doesn't exist |
93 | 93 | } |
94 | 94 | |
95 | - $subclassId = $this->config->get( 'WBQualityConstraintsSubclassOfId' ); |
|
95 | + $subclassId = $this->config->get('WBQualityConstraintsSubclassOfId'); |
|
96 | 96 | $statements = $item->getStatements() |
97 | - ->getByPropertyId( new NumericPropertyId( $subclassId ) ) |
|
97 | + ->getByPropertyId(new NumericPropertyId($subclassId)) |
|
98 | 98 | ->getBestStatements(); |
99 | 99 | /** @var Statement $statement */ |
100 | - foreach ( $statements as $statement ) { |
|
100 | + foreach ($statements as $statement) { |
|
101 | 101 | $mainSnak = $statement->getMainSnak(); |
102 | 102 | |
103 | - if ( !$this->hasCorrectType( $mainSnak ) ) { |
|
103 | + if (!$this->hasCorrectType($mainSnak)) { |
|
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | /** @var PropertyValueSnak $mainSnak */ |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | '@phan-var EntityIdValue $dataValue'; |
111 | 111 | $comparativeClass = $dataValue->getEntityId(); |
112 | 112 | |
113 | - if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) { |
|
113 | + if (in_array($comparativeClass->getSerialization(), $classesToCheck)) { |
|
114 | 114 | return true; |
115 | 115 | } |
116 | 116 | |
117 | - if ( $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ) ) { |
|
117 | + if ($this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked)) { |
|
118 | 118 | return true; |
119 | 119 | } |
120 | 120 | } |
@@ -135,40 +135,40 @@ discard block |
||
135 | 135 | * @return CachedBool |
136 | 136 | * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs |
137 | 137 | */ |
138 | - public function isSubclassOfWithSparqlFallback( EntityId $comparativeClass, array $classesToCheck ) { |
|
139 | - $timing = $this->statsFactory->getTiming( 'isSubclassOf_duration_seconds' ) |
|
140 | - ->setLabel( 'result', 'success' ) |
|
141 | - ->setLabel( 'TypeCheckerImplementation', 'php' ) |
|
142 | - ->copyToStatsdAt( 'wikibase.quality.constraints.type.php.success.timing' ); |
|
138 | + public function isSubclassOfWithSparqlFallback(EntityId $comparativeClass, array $classesToCheck) { |
|
139 | + $timing = $this->statsFactory->getTiming('isSubclassOf_duration_seconds') |
|
140 | + ->setLabel('result', 'success') |
|
141 | + ->setLabel('TypeCheckerImplementation', 'php') |
|
142 | + ->copyToStatsdAt('wikibase.quality.constraints.type.php.success.timing'); |
|
143 | 143 | $timing->start(); |
144 | 144 | |
145 | 145 | try { |
146 | 146 | $entitiesChecked = 0; |
147 | - $isSubclass = $this->isSubclassOf( $comparativeClass, $classesToCheck, $entitiesChecked ); |
|
147 | + $isSubclass = $this->isSubclassOf($comparativeClass, $classesToCheck, $entitiesChecked); |
|
148 | 148 | $timing->stop(); |
149 | 149 | |
150 | 150 | // not really a timing, but works like one (we want percentiles etc.) |
151 | 151 | // TODO: probably a good candidate for T348796 |
152 | - $this->statsFactory->getTiming( 'isSubclassOf_entities_total' ) |
|
153 | - ->setLabel( 'TypeCheckerImplementation', 'php' ) |
|
154 | - ->setLabel( 'result', 'success' ) |
|
155 | - ->copyToStatsdAt( 'wikibase.quality.constraints.type.php.success.entities' ) |
|
156 | - ->observe( $entitiesChecked ); |
|
157 | - |
|
158 | - return new CachedBool( $isSubclass, Metadata::blank() ); |
|
159 | - } catch ( OverflowException $e ) { |
|
160 | - $timing->setLabel( 'result', 'overflow' ) |
|
161 | - ->copyToStatsdAt( 'wikibase.quality.constraints.type.php.overflow.timing' ) |
|
152 | + $this->statsFactory->getTiming('isSubclassOf_entities_total') |
|
153 | + ->setLabel('TypeCheckerImplementation', 'php') |
|
154 | + ->setLabel('result', 'success') |
|
155 | + ->copyToStatsdAt('wikibase.quality.constraints.type.php.success.entities') |
|
156 | + ->observe($entitiesChecked); |
|
157 | + |
|
158 | + return new CachedBool($isSubclass, Metadata::blank()); |
|
159 | + } catch (OverflowException $e) { |
|
160 | + $timing->setLabel('result', 'overflow') |
|
161 | + ->copyToStatsdAt('wikibase.quality.constraints.type.php.overflow.timing') |
|
162 | 162 | ->stop(); |
163 | 163 | |
164 | - if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) { |
|
165 | - $this->statsFactory->getCounter( 'sparql_typeFallback_total' ) |
|
166 | - ->copyToStatsdAt( 'wikibase.quality.constraints.sparql.typeFallback' ) |
|
164 | + if (!($this->sparqlHelper instanceof DummySparqlHelper)) { |
|
165 | + $this->statsFactory->getCounter('sparql_typeFallback_total') |
|
166 | + ->copyToStatsdAt('wikibase.quality.constraints.sparql.typeFallback') |
|
167 | 167 | ->increment(); |
168 | 168 | |
169 | - $timing->setLabel( 'TypeCheckerImplementation', 'sparql' ) |
|
170 | - ->setLabel( 'result', 'success' ) |
|
171 | - ->copyToStatsdAt( 'wikibase.quality.constraints.type.sparql.success.timing' ) |
|
169 | + $timing->setLabel('TypeCheckerImplementation', 'sparql') |
|
170 | + ->setLabel('result', 'success') |
|
171 | + ->copyToStatsdAt('wikibase.quality.constraints.type.sparql.success.timing') |
|
172 | 172 | ->start(); |
173 | 173 | |
174 | 174 | $hasType = $this->sparqlHelper->hasType( |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | return $hasType; |
182 | 182 | } else { |
183 | - return new CachedBool( false, Metadata::blank() ); |
|
183 | + return new CachedBool(false, Metadata::blank()); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | } |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | * @return CachedBool |
199 | 199 | * @throws SparqlHelperException if SPARQL is used and the query times out or some other error occurs |
200 | 200 | */ |
201 | - public function hasClassInRelation( StatementList $statements, array $relationIds, array $classesToCheck ) { |
|
201 | + public function hasClassInRelation(StatementList $statements, array $relationIds, array $classesToCheck) { |
|
202 | 202 | $metadatas = []; |
203 | 203 | |
204 | - foreach ( $this->getBestStatementsByPropertyIds( $statements, $relationIds ) as $statement ) { |
|
204 | + foreach ($this->getBestStatementsByPropertyIds($statements, $relationIds) as $statement) { |
|
205 | 205 | $mainSnak = $statement->getMainSnak(); |
206 | 206 | |
207 | - if ( !$this->hasCorrectType( $mainSnak ) ) { |
|
207 | + if (!$this->hasCorrectType($mainSnak)) { |
|
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | /** @var PropertyValueSnak $mainSnak */ |
@@ -214,24 +214,24 @@ discard block |
||
214 | 214 | '@phan-var EntityIdValue $dataValue'; |
215 | 215 | $comparativeClass = $dataValue->getEntityId(); |
216 | 216 | |
217 | - if ( in_array( $comparativeClass->getSerialization(), $classesToCheck ) ) { |
|
217 | + if (in_array($comparativeClass->getSerialization(), $classesToCheck)) { |
|
218 | 218 | // discard $metadatas, we know this is fresh |
219 | - return new CachedBool( true, Metadata::blank() ); |
|
219 | + return new CachedBool(true, Metadata::blank()); |
|
220 | 220 | } |
221 | 221 | |
222 | - $result = $this->isSubclassOfWithSparqlFallback( $comparativeClass, $classesToCheck ); |
|
222 | + $result = $this->isSubclassOfWithSparqlFallback($comparativeClass, $classesToCheck); |
|
223 | 223 | $metadatas[] = $result->getMetadata(); |
224 | - if ( $result->getBool() ) { |
|
224 | + if ($result->getBool()) { |
|
225 | 225 | return new CachedBool( |
226 | 226 | true, |
227 | - Metadata::merge( $metadatas ) |
|
227 | + Metadata::merge($metadatas) |
|
228 | 228 | ); |
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | 232 | return new CachedBool( |
233 | 233 | false, |
234 | - Metadata::merge( $metadatas ) |
|
234 | + Metadata::merge($metadatas) |
|
235 | 235 | ); |
236 | 236 | } |
237 | 237 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @return bool |
241 | 241 | * @phan-assert PropertyValueSnak $mainSnak |
242 | 242 | */ |
243 | - private function hasCorrectType( Snak $mainSnak ) { |
|
243 | + private function hasCorrectType(Snak $mainSnak) { |
|
244 | 244 | return $mainSnak instanceof PropertyValueSnak |
245 | 245 | && $mainSnak->getDataValue()->getType() === 'wikibase-entityid'; |
246 | 246 | } |
@@ -257,15 +257,15 @@ discard block |
||
257 | 257 | ) { |
258 | 258 | $statementArrays = []; |
259 | 259 | |
260 | - foreach ( $propertyIdSerializations as $propertyIdSerialization ) { |
|
261 | - $propertyId = new NumericPropertyId( $propertyIdSerialization ); |
|
260 | + foreach ($propertyIdSerializations as $propertyIdSerialization) { |
|
261 | + $propertyId = new NumericPropertyId($propertyIdSerialization); |
|
262 | 262 | $statementArrays[] = $statements |
263 | - ->getByPropertyId( $propertyId ) |
|
263 | + ->getByPropertyId($propertyId) |
|
264 | 264 | ->getBestStatements() |
265 | 265 | ->toArray(); |
266 | 266 | } |
267 | 267 | |
268 | - return array_merge( ...$statementArrays ); |
|
268 | + return array_merge(...$statementArrays); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -285,8 +285,8 @@ discard block |
||
285 | 285 | $relation |
286 | 286 | ) { |
287 | 287 | $classes = array_map( |
288 | - static function ( $itemIdSerialization ) { |
|
289 | - return new ItemId( $itemIdSerialization ); |
|
288 | + static function($itemIdSerialization) { |
|
289 | + return new ItemId($itemIdSerialization); |
|
290 | 290 | }, |
291 | 291 | $classes |
292 | 292 | ); |
@@ -298,10 +298,10 @@ discard block |
||
298 | 298 | // wbqc-violation-message-valueType-instance |
299 | 299 | // wbqc-violation-message-valueType-subclass |
300 | 300 | // wbqc-violation-message-valueType-instanceOrSubclass |
301 | - return ( new ViolationMessage( 'wbqc-violation-message-' . $checker . '-' . $relation ) ) |
|
302 | - ->withEntityId( $propertyId, Role::CONSTRAINT_PROPERTY ) |
|
303 | - ->withEntityId( $entityId, Role::SUBJECT ) |
|
304 | - ->withEntityIdList( $classes, Role::OBJECT ); |
|
301 | + return (new ViolationMessage('wbqc-violation-message-'.$checker.'-'.$relation)) |
|
302 | + ->withEntityId($propertyId, Role::CONSTRAINT_PROPERTY) |
|
303 | + ->withEntityId($entityId, Role::SUBJECT) |
|
304 | + ->withEntityIdList($classes, Role::OBJECT); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | } |