@@ -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\Api; |
| 6 | 6 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | private BagOStuff $cache; |
| 23 | 23 | |
| 24 | - public function __construct( BagOStuff $cache ) { |
|
| 24 | + public function __construct(BagOStuff $cache) { |
|
| 25 | 25 | $this->cache = $cache; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @throws \Wikimedia\Assert\ParameterTypeException |
| 34 | 34 | */ |
| 35 | - private function makeKey( string $id ): string { |
|
| 36 | - if ( trim( $id ) === '' ) { |
|
| 37 | - throw new ParameterTypeException( '$id', 'non-empty string' ); |
|
| 35 | + private function makeKey(string $id): string { |
|
| 36 | + if (trim($id) === '') { |
|
| 37 | + throw new ParameterTypeException('$id', 'non-empty string'); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | return $this->cache->makeKey( |
@@ -52,15 +52,15 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @throws \Wikimedia\Assert\ParameterTypeException |
| 54 | 54 | */ |
| 55 | - public function lock( string $id, ConvertibleTimestamp $expiryTimestamp ): bool { |
|
| 55 | + public function lock(string $id, ConvertibleTimestamp $expiryTimestamp): bool { |
|
| 56 | 56 | |
| 57 | - $cacheId = $this->makeKey( $id ); |
|
| 57 | + $cacheId = $this->makeKey($id); |
|
| 58 | 58 | |
| 59 | - if ( !$this->isLockedInternal( $cacheId ) ) { |
|
| 59 | + if (!$this->isLockedInternal($cacheId)) { |
|
| 60 | 60 | return $this->cache->set( |
| 61 | 61 | $cacheId, |
| 62 | - $expiryTimestamp->getTimestamp( TS_UNIX ), |
|
| 63 | - (int)$expiryTimestamp->getTimestamp( TS_UNIX ) |
|
| 62 | + $expiryTimestamp->getTimestamp(TS_UNIX), |
|
| 63 | + (int) $expiryTimestamp->getTimestamp(TS_UNIX) |
|
| 64 | 64 | ); |
| 65 | 65 | } else { |
| 66 | 66 | return false; |
@@ -74,20 +74,20 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @throws \Wikimedia\Assert\ParameterTypeException |
| 76 | 76 | */ |
| 77 | - private function isLockedInternal( string $cacheId ): bool { |
|
| 78 | - $expiryTime = $this->cache->get( $cacheId ); |
|
| 79 | - if ( !$expiryTime ) { |
|
| 77 | + private function isLockedInternal(string $cacheId): bool { |
|
| 78 | + $expiryTime = $this->cache->get($cacheId); |
|
| 79 | + if (!$expiryTime) { |
|
| 80 | 80 | return false; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | try { |
| 84 | - $lockExpiryTimeStamp = new ConvertibleTimestamp( $expiryTime ); |
|
| 85 | - } catch ( TimestampException $exception ) { |
|
| 84 | + $lockExpiryTimeStamp = new ConvertibleTimestamp($expiryTime); |
|
| 85 | + } catch (TimestampException $exception) { |
|
| 86 | 86 | return false; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $now = new ConvertibleTimestamp(); |
| 90 | - if ( $now->timestamp < $lockExpiryTimeStamp->timestamp ) { |
|
| 90 | + if ($now->timestamp < $lockExpiryTimeStamp->timestamp) { |
|
| 91 | 91 | return true; |
| 92 | 92 | } else { |
| 93 | 93 | return false; |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @throws \Wikimedia\Assert\ParameterTypeException |
| 103 | 103 | */ |
| 104 | - public function isLocked( string $id ): bool { |
|
| 105 | - return $this->isLockedInternal( $this->makeKey( $id ) ); |
|
| 104 | + public function isLocked(string $id): bool { |
|
| 105 | + return $this->isLockedInternal($this->makeKey($id)); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | } |
@@ -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\Helper; |
| 6 | 6 | |
@@ -146,73 +146,73 @@ discard block |
||
| 146 | 146 | $this->defaultUserAgent = $defaultUserAgent; |
| 147 | 147 | $this->requestFactory = $requestFactory; |
| 148 | 148 | $this->entityPrefixes = []; |
| 149 | - foreach ( $rdfVocabulary->entityNamespaceNames as $namespaceName ) { |
|
| 150 | - $this->entityPrefixes[] = $rdfVocabulary->getNamespaceURI( $namespaceName ); |
|
| 149 | + foreach ($rdfVocabulary->entityNamespaceNames as $namespaceName) { |
|
| 150 | + $this->entityPrefixes[] = $rdfVocabulary->getNamespaceURI($namespaceName); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $this->primaryEndpoint = $config->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
| 154 | - $this->additionalEndpoints = $config->get( 'WBQualityConstraintsAdditionalSparqlEndpoints' ) ?: []; |
|
| 155 | - $this->maxQueryTimeMillis = $config->get( 'WBQualityConstraintsSparqlMaxMillis' ); |
|
| 156 | - $this->subclassOfId = $config->get( 'WBQualityConstraintsSubclassOfId' ); |
|
| 157 | - $this->cacheMapSize = $config->get( 'WBQualityConstraintsFormatCacheMapSize' ); |
|
| 153 | + $this->primaryEndpoint = $config->get('WBQualityConstraintsSparqlEndpoint'); |
|
| 154 | + $this->additionalEndpoints = $config->get('WBQualityConstraintsAdditionalSparqlEndpoints') ?: []; |
|
| 155 | + $this->maxQueryTimeMillis = $config->get('WBQualityConstraintsSparqlMaxMillis'); |
|
| 156 | + $this->subclassOfId = $config->get('WBQualityConstraintsSubclassOfId'); |
|
| 157 | + $this->cacheMapSize = $config->get('WBQualityConstraintsFormatCacheMapSize'); |
|
| 158 | 158 | $this->timeoutExceptionClasses = $config->get( |
| 159 | 159 | 'WBQualityConstraintsSparqlTimeoutExceptionClasses' |
| 160 | 160 | ); |
| 161 | 161 | $this->sparqlHasWikibaseSupport = $config->get( |
| 162 | 162 | 'WBQualityConstraintsSparqlHasWikibaseSupport' |
| 163 | 163 | ); |
| 164 | - $this->sparqlThrottlingFallbackDuration = (int)$config->get( |
|
| 164 | + $this->sparqlThrottlingFallbackDuration = (int) $config->get( |
|
| 165 | 165 | 'WBQualityConstraintsSparqlThrottlingFallbackDuration' |
| 166 | 166 | ); |
| 167 | 167 | |
| 168 | - $this->prefixes = $this->getQueryPrefixes( $rdfVocabulary ); |
|
| 168 | + $this->prefixes = $this->getQueryPrefixes($rdfVocabulary); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - private function getQueryPrefixes( RdfVocabulary $rdfVocabulary ): string { |
|
| 171 | + private function getQueryPrefixes(RdfVocabulary $rdfVocabulary): string { |
|
| 172 | 172 | // TODO: it would probably be smarter that RdfVocabulary exposed these prefixes somehow |
| 173 | 173 | $prefixes = ''; |
| 174 | - foreach ( $rdfVocabulary->entityNamespaceNames as $sourceName => $namespaceName ) { |
|
| 174 | + foreach ($rdfVocabulary->entityNamespaceNames as $sourceName => $namespaceName) { |
|
| 175 | 175 | $prefixes .= <<<END |
| 176 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
| 176 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
| 177 | 177 | END; |
| 178 | 178 | } |
| 179 | 179 | $prefixes .= <<<END |
| 180 | -PREFIX wds: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_STATEMENT )}> |
|
| 181 | -PREFIX wdv: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_VALUE )}>\n |
|
| 180 | +PREFIX wds: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_STATEMENT)}> |
|
| 181 | +PREFIX wdv: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_VALUE)}>\n |
|
| 182 | 182 | END; |
| 183 | 183 | |
| 184 | - foreach ( $rdfVocabulary->propertyNamespaceNames as $sourceName => $sourceNamespaces ) { |
|
| 184 | + foreach ($rdfVocabulary->propertyNamespaceNames as $sourceName => $sourceNamespaces) { |
|
| 185 | 185 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_DIRECT_CLAIM]; |
| 186 | 186 | $prefixes .= <<<END |
| 187 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
| 187 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
| 188 | 188 | END; |
| 189 | 189 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM]; |
| 190 | 190 | $prefixes .= <<<END |
| 191 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
| 191 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
| 192 | 192 | END; |
| 193 | 193 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM_STATEMENT]; |
| 194 | 194 | $prefixes .= <<<END |
| 195 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
| 195 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
| 196 | 196 | END; |
| 197 | 197 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_QUALIFIER]; |
| 198 | 198 | $prefixes .= <<<END |
| 199 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
| 199 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
| 200 | 200 | END; |
| 201 | 201 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_QUALIFIER_VALUE]; |
| 202 | 202 | $prefixes .= <<<END |
| 203 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
| 203 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
| 204 | 204 | END; |
| 205 | 205 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_REFERENCE]; |
| 206 | 206 | $prefixes .= <<<END |
| 207 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
| 207 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
| 208 | 208 | END; |
| 209 | 209 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_REFERENCE_VALUE]; |
| 210 | 210 | $prefixes .= <<<END |
| 211 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
| 211 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
| 212 | 212 | END; |
| 213 | 213 | } |
| 214 | 214 | $prefixes .= <<<END |
| 215 | -PREFIX wikibase: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_ONTOLOGY )}>\n |
|
| 215 | +PREFIX wikibase: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_ONTOLOGY)}>\n |
|
| 216 | 216 | END; |
| 217 | 217 | return $prefixes; |
| 218 | 218 | } |
@@ -224,21 +224,20 @@ discard block |
||
| 224 | 224 | * @return CachedBool |
| 225 | 225 | * @throws SparqlHelperException if the query times out or some other error occurs |
| 226 | 226 | */ |
| 227 | - public function hasType( string $id, array $classes ): CachedBool { |
|
| 227 | + public function hasType(string $id, array $classes): CachedBool { |
|
| 228 | 228 | // TODO hint:gearing is a workaround for T168973 and can hopefully be removed eventually |
| 229 | 229 | $gearingHint = $this->sparqlHasWikibaseSupport ? |
| 230 | - ' hint:Prior hint:gearing "forward".' : |
|
| 231 | - ''; |
|
| 230 | + ' hint:Prior hint:gearing "forward".' : ''; |
|
| 232 | 231 | |
| 233 | 232 | $metadatas = []; |
| 234 | 233 | |
| 235 | - foreach ( array_chunk( $classes, 20 ) as $classesChunk ) { |
|
| 236 | - $classesValues = implode( ' ', array_map( |
|
| 237 | - static function ( $class ) { |
|
| 238 | - return 'wd:' . $class; |
|
| 234 | + foreach (array_chunk($classes, 20) as $classesChunk) { |
|
| 235 | + $classesValues = implode(' ', array_map( |
|
| 236 | + static function($class) { |
|
| 237 | + return 'wd:'.$class; |
|
| 239 | 238 | }, |
| 240 | 239 | $classesChunk |
| 241 | - ) ); |
|
| 240 | + )); |
|
| 242 | 241 | |
| 243 | 242 | $query = <<<EOF |
| 244 | 243 | ASK { |
@@ -248,19 +247,19 @@ discard block |
||
| 248 | 247 | } |
| 249 | 248 | EOF; |
| 250 | 249 | |
| 251 | - $result = $this->runQuery( $query, $this->primaryEndpoint ); |
|
| 250 | + $result = $this->runQuery($query, $this->primaryEndpoint); |
|
| 252 | 251 | $metadatas[] = $result->getMetadata(); |
| 253 | - if ( $result->getArray()['boolean'] ) { |
|
| 252 | + if ($result->getArray()['boolean']) { |
|
| 254 | 253 | return new CachedBool( |
| 255 | 254 | true, |
| 256 | - Metadata::merge( $metadatas ) |
|
| 255 | + Metadata::merge($metadatas) |
|
| 257 | 256 | ); |
| 258 | 257 | } |
| 259 | 258 | } |
| 260 | 259 | |
| 261 | 260 | return new CachedBool( |
| 262 | 261 | false, |
| 263 | - Metadata::merge( $metadatas ) |
|
| 262 | + Metadata::merge($metadatas) |
|
| 264 | 263 | ); |
| 265 | 264 | } |
| 266 | 265 | |
@@ -268,7 +267,7 @@ discard block |
||
| 268 | 267 | * Helper function used by findEntitiesWithSameStatement to filter |
| 269 | 268 | * out entities with different qualifiers or no qualifier value. |
| 270 | 269 | */ |
| 271 | - private function nestedSeparatorFilter( PropertyId $separator ): string { |
|
| 270 | + private function nestedSeparatorFilter(PropertyId $separator): string { |
|
| 272 | 271 | $filter = <<<EOF |
| 273 | 272 | MINUS { |
| 274 | 273 | ?statement pq:$separator ?qualifier. |
@@ -305,14 +304,14 @@ discard block |
||
| 305 | 304 | * @return CachedEntityIds |
| 306 | 305 | * @throws SparqlHelperException if the query times out or some other error occurs |
| 307 | 306 | */ |
| 308 | - public function findEntitiesWithSameStatement( Statement $statement, array $separators ): CachedEntityIds { |
|
| 307 | + public function findEntitiesWithSameStatement(Statement $statement, array $separators): CachedEntityIds { |
|
| 309 | 308 | $pid = $statement->getPropertyId()->getSerialization(); |
| 310 | 309 | $guid = $statement->getGuid(); |
| 311 | 310 | '@phan-var string $guid'; // statement must have a non-null GUID |
| 312 | - $guidForRdf = str_replace( '$', '-', $guid ); |
|
| 311 | + $guidForRdf = str_replace('$', '-', $guid); |
|
| 313 | 312 | |
| 314 | - $separatorFilters = array_map( [ $this, 'nestedSeparatorFilter' ], $separators ); |
|
| 315 | - $finalSeparatorFilter = implode( "\n", $separatorFilters ); |
|
| 313 | + $separatorFilters = array_map([$this, 'nestedSeparatorFilter'], $separators); |
|
| 314 | + $finalSeparatorFilter = implode("\n", $separatorFilters); |
|
| 316 | 315 | |
| 317 | 316 | $query = <<<EOF |
| 318 | 317 | SELECT DISTINCT ?otherEntity WHERE { |
@@ -330,12 +329,12 @@ discard block |
||
| 330 | 329 | LIMIT 10 |
| 331 | 330 | EOF; |
| 332 | 331 | |
| 333 | - $results = [ $this->runQuery( $query, $this->primaryEndpoint ) ]; |
|
| 334 | - foreach ( $this->additionalEndpoints as $endpoint ) { |
|
| 335 | - $results[] = $this->runQuery( $query, $endpoint ); |
|
| 332 | + $results = [$this->runQuery($query, $this->primaryEndpoint)]; |
|
| 333 | + foreach ($this->additionalEndpoints as $endpoint) { |
|
| 334 | + $results[] = $this->runQuery($query, $endpoint); |
|
| 336 | 335 | } |
| 337 | 336 | |
| 338 | - return $this->getOtherEntities( $results ); |
|
| 337 | + return $this->getOtherEntities($results); |
|
| 339 | 338 | } |
| 340 | 339 | |
| 341 | 340 | /** |
@@ -360,16 +359,15 @@ discard block |
||
| 360 | 359 | $dataType = $this->propertyDataTypeLookup->getDataTypeIdForProperty( |
| 361 | 360 | $snak->getPropertyId() |
| 362 | 361 | ); |
| 363 | - [ $value, $isFullValue ] = $this->getRdfLiteral( $dataType, $dataValue ); |
|
| 364 | - if ( $isFullValue ) { |
|
| 362 | + [$value, $isFullValue] = $this->getRdfLiteral($dataType, $dataValue); |
|
| 363 | + if ($isFullValue) { |
|
| 365 | 364 | $prefix .= 'v'; |
| 366 | 365 | } |
| 367 | 366 | $path = $type === Context::TYPE_QUALIFIER ? |
| 368 | - "$prefix:$pid" : |
|
| 369 | - "prov:wasDerivedFrom/$prefix:$pid"; |
|
| 367 | + "$prefix:$pid" : "prov:wasDerivedFrom/$prefix:$pid"; |
|
| 370 | 368 | |
| 371 | 369 | $deprecatedFilter = ''; |
| 372 | - if ( $ignoreDeprecatedStatements ) { |
|
| 370 | + if ($ignoreDeprecatedStatements) { |
|
| 373 | 371 | $deprecatedFilter = <<< EOF |
| 374 | 372 | MINUS { ?otherStatement wikibase:rank wikibase:DeprecatedRank. } |
| 375 | 373 | EOF; |
@@ -389,19 +387,19 @@ discard block |
||
| 389 | 387 | LIMIT 10 |
| 390 | 388 | EOF; |
| 391 | 389 | |
| 392 | - $results = [ $this->runQuery( $query, $this->primaryEndpoint ) ]; |
|
| 393 | - foreach ( $this->additionalEndpoints as $endpoint ) { |
|
| 394 | - $results[] = $this->runQuery( $query, $endpoint ); |
|
| 390 | + $results = [$this->runQuery($query, $this->primaryEndpoint)]; |
|
| 391 | + foreach ($this->additionalEndpoints as $endpoint) { |
|
| 392 | + $results[] = $this->runQuery($query, $endpoint); |
|
| 395 | 393 | } |
| 396 | 394 | |
| 397 | - return $this->getOtherEntities( $results ); |
|
| 395 | + return $this->getOtherEntities($results); |
|
| 398 | 396 | } |
| 399 | 397 | |
| 400 | 398 | /** |
| 401 | 399 | * Return SPARQL code for a string literal with $text as content. |
| 402 | 400 | */ |
| 403 | - private function stringLiteral( string $text ): string { |
|
| 404 | - return '"' . strtr( $text, [ '"' => '\\"', '\\' => '\\\\' ] ) . '"'; |
|
| 401 | + private function stringLiteral(string $text): string { |
|
| 402 | + return '"'.strtr($text, ['"' => '\\"', '\\' => '\\\\']).'"'; |
|
| 405 | 403 | } |
| 406 | 404 | |
| 407 | 405 | /** |
@@ -411,26 +409,26 @@ discard block |
||
| 411 | 409 | * |
| 412 | 410 | * @return CachedEntityIds |
| 413 | 411 | */ |
| 414 | - private function getOtherEntities( array $results ): CachedEntityIds { |
|
| 412 | + private function getOtherEntities(array $results): CachedEntityIds { |
|
| 415 | 413 | $allResultBindings = []; |
| 416 | 414 | $metadatas = []; |
| 417 | 415 | |
| 418 | - foreach ( $results as $result ) { |
|
| 416 | + foreach ($results as $result) { |
|
| 419 | 417 | $metadatas[] = $result->getMetadata(); |
| 420 | - $allResultBindings = array_merge( $allResultBindings, $result->getArray()['results']['bindings'] ); |
|
| 418 | + $allResultBindings = array_merge($allResultBindings, $result->getArray()['results']['bindings']); |
|
| 421 | 419 | } |
| 422 | 420 | |
| 423 | 421 | $entityIds = array_map( |
| 424 | - function ( $resultBindings ) { |
|
| 422 | + function($resultBindings) { |
|
| 425 | 423 | $entityIRI = $resultBindings['otherEntity']['value']; |
| 426 | - foreach ( $this->entityPrefixes as $entityPrefix ) { |
|
| 427 | - $entityPrefixLength = strlen( $entityPrefix ); |
|
| 428 | - if ( substr( $entityIRI, 0, $entityPrefixLength ) === $entityPrefix ) { |
|
| 424 | + foreach ($this->entityPrefixes as $entityPrefix) { |
|
| 425 | + $entityPrefixLength = strlen($entityPrefix); |
|
| 426 | + if (substr($entityIRI, 0, $entityPrefixLength) === $entityPrefix) { |
|
| 429 | 427 | try { |
| 430 | 428 | return $this->entityIdParser->parse( |
| 431 | - substr( $entityIRI, $entityPrefixLength ) |
|
| 429 | + substr($entityIRI, $entityPrefixLength) |
|
| 432 | 430 | ); |
| 433 | - } catch ( EntityIdParsingException $e ) { |
|
| 431 | + } catch (EntityIdParsingException $e) { |
|
| 434 | 432 | // fall through |
| 435 | 433 | } |
| 436 | 434 | } |
@@ -444,8 +442,8 @@ discard block |
||
| 444 | 442 | ); |
| 445 | 443 | |
| 446 | 444 | return new CachedEntityIds( |
| 447 | - array_values( array_filter( array_unique( $entityIds ) ) ), |
|
| 448 | - Metadata::merge( $metadatas ) |
|
| 445 | + array_values(array_filter(array_unique($entityIds))), |
|
| 446 | + Metadata::merge($metadatas) |
|
| 449 | 447 | ); |
| 450 | 448 | } |
| 451 | 449 | |
@@ -456,50 +454,50 @@ discard block |
||
| 456 | 454 | * @return array the literal or IRI as a string in SPARQL syntax, |
| 457 | 455 | * and a boolean indicating whether it refers to a full value node or not |
| 458 | 456 | */ |
| 459 | - private function getRdfLiteral( string $dataType, DataValue $dataValue ): array { |
|
| 460 | - switch ( $dataType ) { |
|
| 457 | + private function getRdfLiteral(string $dataType, DataValue $dataValue): array { |
|
| 458 | + switch ($dataType) { |
|
| 461 | 459 | case 'string': |
| 462 | 460 | case 'external-id': |
| 463 | - return [ $this->stringLiteral( $dataValue->getValue() ), false ]; |
|
| 461 | + return [$this->stringLiteral($dataValue->getValue()), false]; |
|
| 464 | 462 | case 'commonsMedia': |
| 465 | - $url = $this->rdfVocabulary->getMediaFileURI( $dataValue->getValue() ); |
|
| 466 | - return [ '<' . $url . '>', false ]; |
|
| 463 | + $url = $this->rdfVocabulary->getMediaFileURI($dataValue->getValue()); |
|
| 464 | + return ['<'.$url.'>', false]; |
|
| 467 | 465 | case 'geo-shape': |
| 468 | - $url = $this->rdfVocabulary->getGeoShapeURI( $dataValue->getValue() ); |
|
| 469 | - return [ '<' . $url . '>', false ]; |
|
| 466 | + $url = $this->rdfVocabulary->getGeoShapeURI($dataValue->getValue()); |
|
| 467 | + return ['<'.$url.'>', false]; |
|
| 470 | 468 | case 'tabular-data': |
| 471 | - $url = $this->rdfVocabulary->getTabularDataURI( $dataValue->getValue() ); |
|
| 472 | - return [ '<' . $url . '>', false ]; |
|
| 469 | + $url = $this->rdfVocabulary->getTabularDataURI($dataValue->getValue()); |
|
| 470 | + return ['<'.$url.'>', false]; |
|
| 473 | 471 | case 'url': |
| 474 | 472 | $url = $dataValue->getValue(); |
| 475 | - if ( !preg_match( '/^[^<>"{}\\\\|^`\\x00-\\x20]*$/D', $url ) ) { |
|
| 473 | + if (!preg_match('/^[^<>"{}\\\\|^`\\x00-\\x20]*$/D', $url)) { |
|
| 476 | 474 | // not a valid URL for SPARQL (see SPARQL spec, production 139 IRIREF) |
| 477 | 475 | // such an URL should never reach us, so just throw |
| 478 | - throw new InvalidArgumentException( 'invalid URL: ' . $url ); |
|
| 476 | + throw new InvalidArgumentException('invalid URL: '.$url); |
|
| 479 | 477 | } |
| 480 | - return [ '<' . $url . '>', false ]; |
|
| 478 | + return ['<'.$url.'>', false]; |
|
| 481 | 479 | case 'wikibase-item': |
| 482 | 480 | case 'wikibase-property': |
| 483 | 481 | /** @var EntityIdValue $dataValue */ |
| 484 | 482 | '@phan-var EntityIdValue $dataValue'; |
| 485 | - return [ 'wd:' . $dataValue->getEntityId()->getSerialization(), false ]; |
|
| 483 | + return ['wd:'.$dataValue->getEntityId()->getSerialization(), false]; |
|
| 486 | 484 | case 'monolingualtext': |
| 487 | 485 | /** @var MonolingualTextValue $dataValue */ |
| 488 | 486 | '@phan-var MonolingualTextValue $dataValue'; |
| 489 | 487 | $lang = $dataValue->getLanguageCode(); |
| 490 | - if ( !preg_match( '/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/D', $lang ) ) { |
|
| 488 | + if (!preg_match('/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/D', $lang)) { |
|
| 491 | 489 | // not a valid language tag for SPARQL (see SPARQL spec, production 145 LANGTAG) |
| 492 | 490 | // such a language tag should never reach us, so just throw |
| 493 | - throw new InvalidArgumentException( 'invalid language tag: ' . $lang ); |
|
| 491 | + throw new InvalidArgumentException('invalid language tag: '.$lang); |
|
| 494 | 492 | } |
| 495 | - return [ $this->stringLiteral( $dataValue->getText() ) . '@' . $lang, false ]; |
|
| 493 | + return [$this->stringLiteral($dataValue->getText()).'@'.$lang, false]; |
|
| 496 | 494 | case 'globe-coordinate': |
| 497 | 495 | case 'quantity': |
| 498 | 496 | case 'time': |
| 499 | 497 | // @phan-suppress-next-line PhanUndeclaredMethod |
| 500 | - return [ 'wdv:' . $dataValue->getHash(), true ]; |
|
| 498 | + return ['wdv:'.$dataValue->getHash(), true]; |
|
| 501 | 499 | default: |
| 502 | - throw new InvalidArgumentException( 'unknown data type: ' . $dataType ); |
|
| 500 | + throw new InvalidArgumentException('unknown data type: '.$dataType); |
|
| 503 | 501 | } |
| 504 | 502 | } |
| 505 | 503 | // phpcs:enable |
@@ -508,43 +506,43 @@ discard block |
||
| 508 | 506 | * @throws SparqlHelperException if the query times out or some other error occurs |
| 509 | 507 | * @throws ConstraintParameterException if the $regex is invalid |
| 510 | 508 | */ |
| 511 | - public function matchesRegularExpression( string $text, string $regex ): bool { |
|
| 509 | + public function matchesRegularExpression(string $text, string $regex): bool { |
|
| 512 | 510 | // caching wrapper around matchesRegularExpressionWithSparql |
| 513 | 511 | |
| 514 | - $textHash = hash( 'sha256', $text ); |
|
| 512 | + $textHash = hash('sha256', $text); |
|
| 515 | 513 | $cacheKey = $this->cache->makeKey( |
| 516 | 514 | 'WikibaseQualityConstraints', // extension |
| 517 | 515 | 'regex', // action |
| 518 | 516 | 'WDQS-Java', // regex flavor |
| 519 | - hash( 'sha256', $regex ) |
|
| 517 | + hash('sha256', $regex) |
|
| 520 | 518 | ); |
| 521 | 519 | |
| 522 | 520 | $cacheMapArray = $this->cache->getWithSetCallback( |
| 523 | 521 | $cacheKey, |
| 524 | 522 | WANObjectCache::TTL_DAY, |
| 525 | - function ( $cacheMapArray ) use ( $text, $regex, $textHash ) { |
|
| 523 | + function($cacheMapArray) use ($text, $regex, $textHash) { |
|
| 526 | 524 | // Initialize the cache map if not set |
| 527 | - if ( $cacheMapArray === false ) { |
|
| 525 | + if ($cacheMapArray === false) { |
|
| 528 | 526 | $key = 'wikibase.quality.constraints.regex.cache.refresh.init'; |
| 529 | - $this->dataFactory->increment( $key ); |
|
| 527 | + $this->dataFactory->increment($key); |
|
| 530 | 528 | return []; |
| 531 | 529 | } |
| 532 | 530 | |
| 533 | 531 | $key = 'wikibase.quality.constraints.regex.cache.refresh'; |
| 534 | - $this->dataFactory->increment( $key ); |
|
| 535 | - $cacheMap = MapCacheLRU::newFromArray( $cacheMapArray, $this->cacheMapSize ); |
|
| 536 | - if ( $cacheMap->has( $textHash ) ) { |
|
| 532 | + $this->dataFactory->increment($key); |
|
| 533 | + $cacheMap = MapCacheLRU::newFromArray($cacheMapArray, $this->cacheMapSize); |
|
| 534 | + if ($cacheMap->has($textHash)) { |
|
| 537 | 535 | $key = 'wikibase.quality.constraints.regex.cache.refresh.hit'; |
| 538 | - $this->dataFactory->increment( $key ); |
|
| 539 | - $cacheMap->get( $textHash ); // ping cache |
|
| 536 | + $this->dataFactory->increment($key); |
|
| 537 | + $cacheMap->get($textHash); // ping cache |
|
| 540 | 538 | } else { |
| 541 | 539 | $key = 'wikibase.quality.constraints.regex.cache.refresh.miss'; |
| 542 | - $this->dataFactory->increment( $key ); |
|
| 540 | + $this->dataFactory->increment($key); |
|
| 543 | 541 | try { |
| 544 | - $matches = $this->matchesRegularExpressionWithSparql( $text, $regex ); |
|
| 545 | - } catch ( ConstraintParameterException $e ) { |
|
| 546 | - $matches = $this->serializeConstraintParameterException( $e ); |
|
| 547 | - } catch ( SparqlHelperException $e ) { |
|
| 542 | + $matches = $this->matchesRegularExpressionWithSparql($text, $regex); |
|
| 543 | + } catch (ConstraintParameterException $e) { |
|
| 544 | + $matches = $this->serializeConstraintParameterException($e); |
|
| 545 | + } catch (SparqlHelperException $e) { |
|
| 548 | 546 | // don’t cache this |
| 549 | 547 | return $cacheMap->toArray(); |
| 550 | 548 | } |
@@ -568,42 +566,42 @@ discard block |
||
| 568 | 566 | ] |
| 569 | 567 | ); |
| 570 | 568 | |
| 571 | - if ( isset( $cacheMapArray[$textHash] ) ) { |
|
| 569 | + if (isset($cacheMapArray[$textHash])) { |
|
| 572 | 570 | $key = 'wikibase.quality.constraints.regex.cache.hit'; |
| 573 | - $this->dataFactory->increment( $key ); |
|
| 571 | + $this->dataFactory->increment($key); |
|
| 574 | 572 | $matches = $cacheMapArray[$textHash]; |
| 575 | - if ( is_bool( $matches ) ) { |
|
| 573 | + if (is_bool($matches)) { |
|
| 576 | 574 | return $matches; |
| 577 | - } elseif ( is_array( $matches ) && |
|
| 578 | - $matches['type'] == ConstraintParameterException::class ) { |
|
| 579 | - throw $this->deserializeConstraintParameterException( $matches ); |
|
| 575 | + } elseif (is_array($matches) && |
|
| 576 | + $matches['type'] == ConstraintParameterException::class) { |
|
| 577 | + throw $this->deserializeConstraintParameterException($matches); |
|
| 580 | 578 | } else { |
| 581 | 579 | throw new UnexpectedValueException( |
| 582 | - 'Value of unknown type in object cache (' . |
|
| 583 | - 'cache key: ' . $cacheKey . ', ' . |
|
| 584 | - 'cache map key: ' . $textHash . ', ' . |
|
| 585 | - 'value type: ' . get_debug_type( $matches ) . ')' |
|
| 580 | + 'Value of unknown type in object cache ('. |
|
| 581 | + 'cache key: '.$cacheKey.', '. |
|
| 582 | + 'cache map key: '.$textHash.', '. |
|
| 583 | + 'value type: '.get_debug_type($matches).')' |
|
| 586 | 584 | ); |
| 587 | 585 | } |
| 588 | 586 | } else { |
| 589 | 587 | $key = 'wikibase.quality.constraints.regex.cache.miss'; |
| 590 | - $this->dataFactory->increment( $key ); |
|
| 591 | - return $this->matchesRegularExpressionWithSparql( $text, $regex ); |
|
| 588 | + $this->dataFactory->increment($key); |
|
| 589 | + return $this->matchesRegularExpressionWithSparql($text, $regex); |
|
| 592 | 590 | } |
| 593 | 591 | } |
| 594 | 592 | |
| 595 | - private function serializeConstraintParameterException( ConstraintParameterException $cpe ): array { |
|
| 593 | + private function serializeConstraintParameterException(ConstraintParameterException $cpe): array { |
|
| 596 | 594 | return [ |
| 597 | 595 | 'type' => ConstraintParameterException::class, |
| 598 | - 'violationMessage' => $this->violationMessageSerializer->serialize( $cpe->getViolationMessage() ), |
|
| 596 | + 'violationMessage' => $this->violationMessageSerializer->serialize($cpe->getViolationMessage()), |
|
| 599 | 597 | ]; |
| 600 | 598 | } |
| 601 | 599 | |
| 602 | - private function deserializeConstraintParameterException( array $serialization ): ConstraintParameterException { |
|
| 600 | + private function deserializeConstraintParameterException(array $serialization): ConstraintParameterException { |
|
| 603 | 601 | $message = $this->violationMessageDeserializer->deserialize( |
| 604 | 602 | $serialization['violationMessage'] |
| 605 | 603 | ); |
| 606 | - return new ConstraintParameterException( $message ); |
|
| 604 | + return new ConstraintParameterException($message); |
|
| 607 | 605 | } |
| 608 | 606 | |
| 609 | 607 | /** |
@@ -613,25 +611,25 @@ discard block |
||
| 613 | 611 | * @throws SparqlHelperException if the query times out or some other error occurs |
| 614 | 612 | * @throws ConstraintParameterException if the $regex is invalid |
| 615 | 613 | */ |
| 616 | - public function matchesRegularExpressionWithSparql( string $text, string $regex ): bool { |
|
| 617 | - $textStringLiteral = $this->stringLiteral( $text ); |
|
| 618 | - $regexStringLiteral = $this->stringLiteral( '^(?:' . $regex . ')$' ); |
|
| 614 | + public function matchesRegularExpressionWithSparql(string $text, string $regex): bool { |
|
| 615 | + $textStringLiteral = $this->stringLiteral($text); |
|
| 616 | + $regexStringLiteral = $this->stringLiteral('^(?:'.$regex.')$'); |
|
| 619 | 617 | |
| 620 | 618 | $query = <<<EOF |
| 621 | 619 | SELECT (REGEX($textStringLiteral, $regexStringLiteral) AS ?matches) {} |
| 622 | 620 | EOF; |
| 623 | 621 | |
| 624 | - $result = $this->runQuery( $query, $this->primaryEndpoint, false ); |
|
| 622 | + $result = $this->runQuery($query, $this->primaryEndpoint, false); |
|
| 625 | 623 | |
| 626 | 624 | $vars = $result->getArray()['results']['bindings'][0]; |
| 627 | - if ( array_key_exists( 'matches', $vars ) ) { |
|
| 625 | + if (array_key_exists('matches', $vars)) { |
|
| 628 | 626 | // true or false ⇒ regex okay, text matches or not |
| 629 | 627 | return $vars['matches']['value'] === 'true'; |
| 630 | 628 | } else { |
| 631 | 629 | // empty result: regex broken |
| 632 | 630 | throw new ConstraintParameterException( |
| 633 | - ( new ViolationMessage( 'wbqc-violation-message-parameter-regex' ) ) |
|
| 634 | - ->withInlineCode( $regex, Role::CONSTRAINT_PARAMETER_VALUE ) |
|
| 631 | + (new ViolationMessage('wbqc-violation-message-parameter-regex')) |
|
| 632 | + ->withInlineCode($regex, Role::CONSTRAINT_PARAMETER_VALUE) |
|
| 635 | 633 | ); |
| 636 | 634 | } |
| 637 | 635 | } |
@@ -639,14 +637,14 @@ discard block |
||
| 639 | 637 | /** |
| 640 | 638 | * Check whether the text content of an error response indicates a query timeout. |
| 641 | 639 | */ |
| 642 | - public function isTimeout( string $responseContent ): bool { |
|
| 643 | - $timeoutRegex = implode( '|', array_map( |
|
| 644 | - static function ( $fqn ) { |
|
| 645 | - return preg_quote( $fqn, '/' ); |
|
| 640 | + public function isTimeout(string $responseContent): bool { |
|
| 641 | + $timeoutRegex = implode('|', array_map( |
|
| 642 | + static function($fqn) { |
|
| 643 | + return preg_quote($fqn, '/'); |
|
| 646 | 644 | }, |
| 647 | 645 | $this->timeoutExceptionClasses |
| 648 | - ) ); |
|
| 649 | - return (bool)preg_match( '/' . $timeoutRegex . '/', $responseContent ); |
|
| 646 | + )); |
|
| 647 | + return (bool) preg_match('/'.$timeoutRegex.'/', $responseContent); |
|
| 650 | 648 | } |
| 651 | 649 | |
| 652 | 650 | /** |
@@ -658,17 +656,17 @@ discard block |
||
| 658 | 656 | * @return int|boolean the max-age (in seconds) |
| 659 | 657 | * or a plain boolean if no max-age can be determined |
| 660 | 658 | */ |
| 661 | - public function getCacheMaxAge( array $responseHeaders ) { |
|
| 659 | + public function getCacheMaxAge(array $responseHeaders) { |
|
| 662 | 660 | if ( |
| 663 | - array_key_exists( 'x-cache-status', $responseHeaders ) && |
|
| 664 | - preg_match( '/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0] ) |
|
| 661 | + array_key_exists('x-cache-status', $responseHeaders) && |
|
| 662 | + preg_match('/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0]) |
|
| 665 | 663 | ) { |
| 666 | 664 | $maxage = []; |
| 667 | 665 | if ( |
| 668 | - array_key_exists( 'cache-control', $responseHeaders ) && |
|
| 669 | - preg_match( '/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage ) |
|
| 666 | + array_key_exists('cache-control', $responseHeaders) && |
|
| 667 | + preg_match('/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage) |
|
| 670 | 668 | ) { |
| 671 | - return intval( $maxage[1] ); |
|
| 669 | + return intval($maxage[1]); |
|
| 672 | 670 | } else { |
| 673 | 671 | return true; |
| 674 | 672 | } |
@@ -689,34 +687,34 @@ discard block |
||
| 689 | 687 | * or SparlHelper::EMPTY_RETRY_AFTER if there is an empty Retry-After |
| 690 | 688 | * or SparlHelper::INVALID_RETRY_AFTER if there is something wrong with the format |
| 691 | 689 | */ |
| 692 | - public function getThrottling( MWHttpRequest $request ) { |
|
| 693 | - $retryAfterValue = $request->getResponseHeader( 'Retry-After' ); |
|
| 694 | - if ( $retryAfterValue === null ) { |
|
| 690 | + public function getThrottling(MWHttpRequest $request) { |
|
| 691 | + $retryAfterValue = $request->getResponseHeader('Retry-After'); |
|
| 692 | + if ($retryAfterValue === null) { |
|
| 695 | 693 | return self::NO_RETRY_AFTER; |
| 696 | 694 | } |
| 697 | 695 | |
| 698 | - $trimmedRetryAfterValue = trim( $retryAfterValue ); |
|
| 699 | - if ( $trimmedRetryAfterValue === '' ) { |
|
| 696 | + $trimmedRetryAfterValue = trim($retryAfterValue); |
|
| 697 | + if ($trimmedRetryAfterValue === '') { |
|
| 700 | 698 | return self::EMPTY_RETRY_AFTER; |
| 701 | 699 | } |
| 702 | 700 | |
| 703 | - if ( is_numeric( $trimmedRetryAfterValue ) ) { |
|
| 704 | - $delaySeconds = (int)$trimmedRetryAfterValue; |
|
| 705 | - if ( $delaySeconds >= 0 ) { |
|
| 706 | - return $this->getTimestampInFuture( new DateInterval( 'PT' . $delaySeconds . 'S' ) ); |
|
| 701 | + if (is_numeric($trimmedRetryAfterValue)) { |
|
| 702 | + $delaySeconds = (int) $trimmedRetryAfterValue; |
|
| 703 | + if ($delaySeconds >= 0) { |
|
| 704 | + return $this->getTimestampInFuture(new DateInterval('PT'.$delaySeconds.'S')); |
|
| 707 | 705 | } |
| 708 | 706 | } else { |
| 709 | - $return = strtotime( $trimmedRetryAfterValue ); |
|
| 710 | - if ( $return !== false ) { |
|
| 711 | - return new ConvertibleTimestamp( $return ); |
|
| 707 | + $return = strtotime($trimmedRetryAfterValue); |
|
| 708 | + if ($return !== false) { |
|
| 709 | + return new ConvertibleTimestamp($return); |
|
| 712 | 710 | } |
| 713 | 711 | } |
| 714 | 712 | return self::INVALID_RETRY_AFTER; |
| 715 | 713 | } |
| 716 | 714 | |
| 717 | - private function getTimestampInFuture( DateInterval $delta ) { |
|
| 715 | + private function getTimestampInFuture(DateInterval $delta) { |
|
| 718 | 716 | $now = new ConvertibleTimestamp(); |
| 719 | - return new ConvertibleTimestamp( $now->timestamp->add( $delta ) ); |
|
| 717 | + return new ConvertibleTimestamp($now->timestamp->add($delta)); |
|
| 720 | 718 | } |
| 721 | 719 | |
| 722 | 720 | /** |
@@ -731,64 +729,63 @@ discard block |
||
| 731 | 729 | * |
| 732 | 730 | * @throws SparqlHelperException if the query times out or some other error occurs |
| 733 | 731 | */ |
| 734 | - protected function runQuery( string $query, string $endpoint, bool $needsPrefixes = true ): CachedQueryResults { |
|
| 735 | - if ( $this->throttlingLock->isLocked( self::EXPIRY_LOCK_ID ) ) { |
|
| 736 | - $this->dataFactory->increment( 'wikibase.quality.constraints.sparql.throttling' ); |
|
| 732 | + protected function runQuery(string $query, string $endpoint, bool $needsPrefixes = true): CachedQueryResults { |
|
| 733 | + if ($this->throttlingLock->isLocked(self::EXPIRY_LOCK_ID)) { |
|
| 734 | + $this->dataFactory->increment('wikibase.quality.constraints.sparql.throttling'); |
|
| 737 | 735 | throw new TooManySparqlRequestsException(); |
| 738 | 736 | } |
| 739 | 737 | |
| 740 | - if ( $this->sparqlHasWikibaseSupport ) { |
|
| 738 | + if ($this->sparqlHasWikibaseSupport) { |
|
| 741 | 739 | $needsPrefixes = false; |
| 742 | 740 | } |
| 743 | 741 | |
| 744 | - if ( $needsPrefixes ) { |
|
| 745 | - $query = $this->prefixes . $query; |
|
| 742 | + if ($needsPrefixes) { |
|
| 743 | + $query = $this->prefixes.$query; |
|
| 746 | 744 | } |
| 747 | - $query = "#wbqc\n" . $query; |
|
| 745 | + $query = "#wbqc\n".$query; |
|
| 748 | 746 | |
| 749 | - $url = $endpoint . '?' . http_build_query( |
|
| 747 | + $url = $endpoint.'?'.http_build_query( |
|
| 750 | 748 | [ |
| 751 | 749 | 'query' => $query, |
| 752 | 750 | 'format' => 'json', |
| 753 | 751 | 'maxQueryTimeMillis' => $this->maxQueryTimeMillis, |
| 754 | 752 | ], |
| 755 | - '', ini_get( 'arg_separator.output' ), |
|
| 753 | + '', ini_get('arg_separator.output'), |
|
| 756 | 754 | // encode spaces with %20, not + |
| 757 | 755 | PHP_QUERY_RFC3986 |
| 758 | 756 | ); |
| 759 | 757 | |
| 760 | 758 | $options = [ |
| 761 | 759 | 'method' => 'GET', |
| 762 | - 'timeout' => (int)round( ( $this->maxQueryTimeMillis + 1000 ) / 1000 ), |
|
| 760 | + 'timeout' => (int) round(($this->maxQueryTimeMillis + 1000) / 1000), |
|
| 763 | 761 | 'connectTimeout' => 'default', |
| 764 | 762 | 'userAgent' => $this->defaultUserAgent, |
| 765 | 763 | ]; |
| 766 | - $request = $this->requestFactory->create( $url, $options, __METHOD__ ); |
|
| 767 | - $startTime = microtime( true ); |
|
| 764 | + $request = $this->requestFactory->create($url, $options, __METHOD__); |
|
| 765 | + $startTime = microtime(true); |
|
| 768 | 766 | $requestStatus = $request->execute(); |
| 769 | - $endTime = microtime( true ); |
|
| 767 | + $endTime = microtime(true); |
|
| 770 | 768 | $this->dataFactory->timing( |
| 771 | 769 | 'wikibase.quality.constraints.sparql.timing', |
| 772 | - ( $endTime - $startTime ) * 1000 |
|
| 770 | + ($endTime - $startTime) * 1000 |
|
| 773 | 771 | ); |
| 774 | 772 | |
| 775 | - $this->guardAgainstTooManyRequestsError( $request ); |
|
| 773 | + $this->guardAgainstTooManyRequestsError($request); |
|
| 776 | 774 | |
| 777 | - $maxAge = $this->getCacheMaxAge( $request->getResponseHeaders() ); |
|
| 778 | - if ( $maxAge ) { |
|
| 779 | - $this->dataFactory->increment( 'wikibase.quality.constraints.sparql.cached' ); |
|
| 775 | + $maxAge = $this->getCacheMaxAge($request->getResponseHeaders()); |
|
| 776 | + if ($maxAge) { |
|
| 777 | + $this->dataFactory->increment('wikibase.quality.constraints.sparql.cached'); |
|
| 780 | 778 | } |
| 781 | 779 | |
| 782 | - if ( $requestStatus->isOK() ) { |
|
| 780 | + if ($requestStatus->isOK()) { |
|
| 783 | 781 | $json = $request->getContent(); |
| 784 | - $jsonStatus = FormatJson::parse( $json, FormatJson::FORCE_ASSOC ); |
|
| 785 | - if ( $jsonStatus->isOK() ) { |
|
| 782 | + $jsonStatus = FormatJson::parse($json, FormatJson::FORCE_ASSOC); |
|
| 783 | + if ($jsonStatus->isOK()) { |
|
| 786 | 784 | return new CachedQueryResults( |
| 787 | 785 | $jsonStatus->getValue(), |
| 788 | 786 | Metadata::ofCachingMetadata( |
| 789 | 787 | $maxAge ? |
| 790 | - CachingMetadata::ofMaximumAgeInSeconds( $maxAge ) : |
|
| 791 | - CachingMetadata::fresh() |
|
| 788 | + CachingMetadata::ofMaximumAgeInSeconds($maxAge) : CachingMetadata::fresh() |
|
| 792 | 789 | ) |
| 793 | 790 | ); |
| 794 | 791 | } else { |
@@ -805,9 +802,9 @@ discard block |
||
| 805 | 802 | // fall through to general error handling |
| 806 | 803 | } |
| 807 | 804 | |
| 808 | - $this->dataFactory->increment( 'wikibase.quality.constraints.sparql.error' ); |
|
| 805 | + $this->dataFactory->increment('wikibase.quality.constraints.sparql.error'); |
|
| 809 | 806 | |
| 810 | - if ( $this->isTimeout( $request->getContent() ) ) { |
|
| 807 | + if ($this->isTimeout($request->getContent())) { |
|
| 811 | 808 | $this->dataFactory->increment( |
| 812 | 809 | 'wikibase.quality.constraints.sparql.error.timeout' |
| 813 | 810 | ); |
@@ -822,29 +819,29 @@ discard block |
||
| 822 | 819 | * @param MWHttpRequest $request |
| 823 | 820 | * @throws TooManySparqlRequestsException |
| 824 | 821 | */ |
| 825 | - private function guardAgainstTooManyRequestsError( MWHttpRequest $request ): void { |
|
| 826 | - if ( $request->getStatus() !== self::HTTP_TOO_MANY_REQUESTS ) { |
|
| 822 | + private function guardAgainstTooManyRequestsError(MWHttpRequest $request): void { |
|
| 823 | + if ($request->getStatus() !== self::HTTP_TOO_MANY_REQUESTS) { |
|
| 827 | 824 | return; |
| 828 | 825 | } |
| 829 | 826 | |
| 830 | 827 | $fallbackBlockDuration = $this->sparqlThrottlingFallbackDuration; |
| 831 | 828 | |
| 832 | - if ( $fallbackBlockDuration < 0 ) { |
|
| 833 | - throw new InvalidArgumentException( 'Fallback duration must be positive int but is: ' . |
|
| 834 | - $fallbackBlockDuration ); |
|
| 829 | + if ($fallbackBlockDuration < 0) { |
|
| 830 | + throw new InvalidArgumentException('Fallback duration must be positive int but is: '. |
|
| 831 | + $fallbackBlockDuration); |
|
| 835 | 832 | } |
| 836 | 833 | |
| 837 | - $this->dataFactory->increment( 'wikibase.quality.constraints.sparql.throttling' ); |
|
| 838 | - $throttlingUntil = $this->getThrottling( $request ); |
|
| 839 | - if ( !( $throttlingUntil instanceof ConvertibleTimestamp ) ) { |
|
| 840 | - $this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterInvalid( $request ); |
|
| 834 | + $this->dataFactory->increment('wikibase.quality.constraints.sparql.throttling'); |
|
| 835 | + $throttlingUntil = $this->getThrottling($request); |
|
| 836 | + if (!($throttlingUntil instanceof ConvertibleTimestamp)) { |
|
| 837 | + $this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterInvalid($request); |
|
| 841 | 838 | $this->throttlingLock->lock( |
| 842 | 839 | self::EXPIRY_LOCK_ID, |
| 843 | - $this->getTimestampInFuture( new DateInterval( 'PT' . $fallbackBlockDuration . 'S' ) ) |
|
| 840 | + $this->getTimestampInFuture(new DateInterval('PT'.$fallbackBlockDuration.'S')) |
|
| 844 | 841 | ); |
| 845 | 842 | } else { |
| 846 | - $this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterPresent( $throttlingUntil, $request ); |
|
| 847 | - $this->throttlingLock->lock( self::EXPIRY_LOCK_ID, $throttlingUntil ); |
|
| 843 | + $this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterPresent($throttlingUntil, $request); |
|
| 844 | + $this->throttlingLock->lock(self::EXPIRY_LOCK_ID, $throttlingUntil); |
|
| 848 | 845 | } |
| 849 | 846 | throw new TooManySparqlRequestsException(); |
| 850 | 847 | } |
@@ -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\Message; |
| 6 | 6 | |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | 'wbqc-violation-message-format-clarification' => 'wbqc-violation-message-format', |
| 29 | 29 | ]; |
| 30 | 30 | |
| 31 | - public function render( ViolationMessage $violationMessage ): string { |
|
| 32 | - if ( !array_key_exists( $violationMessage->getMessageKey(), self::ALTERNATIVE_MESSAGE_KEYS ) ) { |
|
| 33 | - return parent::render( $violationMessage ); |
|
| 31 | + public function render(ViolationMessage $violationMessage): string { |
|
| 32 | + if (!array_key_exists($violationMessage->getMessageKey(), self::ALTERNATIVE_MESSAGE_KEYS)) { |
|
| 33 | + return parent::render($violationMessage); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $arguments = $violationMessage->getArguments(); |
| 37 | - $multilingualTextArgument = array_pop( $arguments ); |
|
| 37 | + $multilingualTextArgument = array_pop($arguments); |
|
| 38 | 38 | $multilingualTextParams = $this->renderMultilingualText( |
| 39 | 39 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable TODO Ensure this is not an actual issue |
| 40 | 40 | $multilingualTextArgument['value'], |
@@ -42,22 +42,22 @@ discard block |
||
| 42 | 42 | $multilingualTextArgument['role'] |
| 43 | 43 | ); |
| 44 | 44 | |
| 45 | - $paramsLists = [ [] ]; |
|
| 46 | - foreach ( $arguments as $argument ) { |
|
| 47 | - $paramsLists[] = $this->renderArgument( $argument ); |
|
| 45 | + $paramsLists = [[]]; |
|
| 46 | + foreach ($arguments as $argument) { |
|
| 47 | + $paramsLists[] = $this->renderArgument($argument); |
|
| 48 | 48 | } |
| 49 | - $regularParams = call_user_func_array( 'array_merge', $paramsLists ); |
|
| 49 | + $regularParams = call_user_func_array('array_merge', $paramsLists); |
|
| 50 | 50 | |
| 51 | - if ( $multilingualTextParams === null ) { |
|
| 51 | + if ($multilingualTextParams === null) { |
|
| 52 | 52 | return $this->messageLocalizer |
| 53 | - ->msg( self::ALTERNATIVE_MESSAGE_KEYS[$violationMessage->getMessageKey()] ) |
|
| 54 | - ->params( $regularParams ) |
|
| 53 | + ->msg(self::ALTERNATIVE_MESSAGE_KEYS[$violationMessage->getMessageKey()]) |
|
| 54 | + ->params($regularParams) |
|
| 55 | 55 | ->escaped(); |
| 56 | 56 | } else { |
| 57 | 57 | return $this->messageLocalizer |
| 58 | - ->msg( $violationMessage->getMessageKey() ) |
|
| 59 | - ->params( $regularParams ) |
|
| 60 | - ->params( $multilingualTextParams ) |
|
| 58 | + ->msg($violationMessage->getMessageKey()) |
|
| 59 | + ->params($regularParams) |
|
| 60 | + ->params($multilingualTextParams) |
|
| 61 | 61 | ->escaped(); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | * @return MessageParam[]|null list of parameters as accepted by Message::params(), |
| 69 | 69 | * or null if the text is not available in the user’s language |
| 70 | 70 | */ |
| 71 | - protected function renderMultilingualText( MultilingualTextValue $text, ?string $role ): ?array { |
|
| 71 | + protected function renderMultilingualText(MultilingualTextValue $text, ?string $role): ?array { |
|
| 72 | 72 | $texts = $text->getTexts(); |
| 73 | - foreach ( $this->languageFallbackChain->getFetchLanguageCodes() as $languageCode ) { |
|
| 74 | - if ( array_key_exists( $languageCode, $texts ) ) { |
|
| 75 | - return [ Message::rawParam( $this->addRole( |
|
| 76 | - htmlspecialchars( $texts[$languageCode]->getText() ), |
|
| 73 | + foreach ($this->languageFallbackChain->getFetchLanguageCodes() as $languageCode) { |
|
| 74 | + if (array_key_exists($languageCode, $texts)) { |
|
| 75 | + return [Message::rawParam($this->addRole( |
|
| 76 | + htmlspecialchars($texts[$languageCode]->getText()), |
|
| 77 | 77 | $role |
| 78 | - ) ) ]; |
|
| 78 | + ))]; |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
@@ -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 | |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | $this->maxListLength = $maxListLength; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function render( ViolationMessage $violationMessage ): string { |
|
| 70 | + public function render(ViolationMessage $violationMessage): string { |
|
| 71 | 71 | $messageKey = $violationMessage->getMessageKey(); |
| 72 | - $paramsLists = [ [] ]; |
|
| 73 | - foreach ( $violationMessage->getArguments() as $argument ) { |
|
| 74 | - $params = $this->renderArgument( $argument ); |
|
| 72 | + $paramsLists = [[]]; |
|
| 73 | + foreach ($violationMessage->getArguments() as $argument) { |
|
| 74 | + $params = $this->renderArgument($argument); |
|
| 75 | 75 | $paramsLists[] = $params; |
| 76 | 76 | } |
| 77 | - $allParams = call_user_func_array( 'array_merge', $paramsLists ); |
|
| 77 | + $allParams = call_user_func_array('array_merge', $paramsLists); |
|
| 78 | 78 | return $this->messageLocalizer |
| 79 | - ->msg( $messageKey ) |
|
| 80 | - ->params( $allParams ) |
|
| 79 | + ->msg($messageKey) |
|
| 80 | + ->params($allParams) |
|
| 81 | 81 | ->escaped(); |
| 82 | 82 | } |
| 83 | 83 | |
@@ -86,13 +86,13 @@ discard block |
||
| 86 | 86 | * @param string|null $role one of the Role::* constants |
| 87 | 87 | * @return string HTML |
| 88 | 88 | */ |
| 89 | - protected function addRole( string $value, ?string $role ): string { |
|
| 90 | - if ( $role === null ) { |
|
| 89 | + protected function addRole(string $value, ?string $role): string { |
|
| 90 | + if ($role === null) { |
|
| 91 | 91 | return $value; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' . |
|
| 95 | - $value . |
|
| 94 | + return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'. |
|
| 95 | + $value. |
|
| 96 | 96 | '</span>'; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -100,15 +100,15 @@ discard block |
||
| 100 | 100 | * @param string $key message key |
| 101 | 101 | * @return string HTML |
| 102 | 102 | */ |
| 103 | - protected function msgEscaped( string $key ): string { |
|
| 104 | - return $this->messageLocalizer->msg( $key )->escaped(); |
|
| 103 | + protected function msgEscaped(string $key): string { |
|
| 104 | + return $this->messageLocalizer->msg($key)->escaped(); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * @param array $argument |
| 109 | 109 | * @return MessageParam[] params (for Message::params) |
| 110 | 110 | */ |
| 111 | - protected function renderArgument( array $argument ): array { |
|
| 111 | + protected function renderArgument(array $argument): array { |
|
| 112 | 112 | $methods = [ |
| 113 | 113 | ViolationMessage::TYPE_ENTITY_ID => 'renderEntityId', |
| 114 | 114 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'renderEntityIdList', |
@@ -129,12 +129,12 @@ discard block |
||
| 129 | 129 | $value = $argument['value']; |
| 130 | 130 | $role = $argument['role']; |
| 131 | 131 | |
| 132 | - if ( array_key_exists( $type, $methods ) ) { |
|
| 132 | + if (array_key_exists($type, $methods)) { |
|
| 133 | 133 | $method = $methods[$type]; |
| 134 | - $params = $this->$method( $value, $role ); |
|
| 134 | + $params = $this->$method($value, $role); |
|
| 135 | 135 | } else { |
| 136 | 136 | throw new InvalidArgumentException( |
| 137 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
| 137 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
| 138 | 138 | ); |
| 139 | 139 | } |
| 140 | 140 | |
@@ -148,36 +148,36 @@ discard block |
||
| 148 | 148 | * and return a single-element array with a raw message param (i. e. [ Message::rawParam( … ) ]) |
| 149 | 149 | * @return MessageParam[] list of parameters as accepted by Message::params() |
| 150 | 150 | */ |
| 151 | - private function renderList( array $list, ?string $role, callable $render ): array { |
|
| 152 | - if ( $list === [] ) { |
|
| 151 | + private function renderList(array $list, ?string $role, callable $render): array { |
|
| 152 | + if ($list === []) { |
|
| 153 | 153 | return [ |
| 154 | - Message::numParam( 0 ), |
|
| 155 | - Message::rawParam( '<ul></ul>' ), |
|
| 154 | + Message::numParam(0), |
|
| 155 | + Message::rawParam('<ul></ul>'), |
|
| 156 | 156 | ]; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ( count( $list ) > $this->maxListLength ) { |
|
| 160 | - $list = array_slice( $list, 0, $this->maxListLength ); |
|
| 159 | + if (count($list) > $this->maxListLength) { |
|
| 160 | + $list = array_slice($list, 0, $this->maxListLength); |
|
| 161 | 161 | $truncated = true; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $renderedParamsLists = array_map( |
| 165 | 165 | $render, |
| 166 | 166 | $list, |
| 167 | - array_fill( 0, count( $list ), $role ) |
|
| 167 | + array_fill(0, count($list), $role) |
|
| 168 | 168 | ); |
| 169 | - $renderedParams = array_column( $renderedParamsLists, 0 ); |
|
| 170 | - $renderedElements = array_map( fn ( MessageParam $msg ) => $msg->getValue(), $renderedParams ); |
|
| 171 | - if ( isset( $truncated ) ) { |
|
| 172 | - $renderedElements[] = $this->msgEscaped( 'ellipsis' ); |
|
| 169 | + $renderedParams = array_column($renderedParamsLists, 0); |
|
| 170 | + $renderedElements = array_map(fn (MessageParam $msg) => $msg->getValue(), $renderedParams); |
|
| 171 | + if (isset($truncated)) { |
|
| 172 | + $renderedElements[] = $this->msgEscaped('ellipsis'); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | return array_merge( |
| 176 | 176 | [ |
| 177 | - Message::numParam( count( $list ) ), |
|
| 177 | + Message::numParam(count($list)), |
|
| 178 | 178 | Message::rawParam( |
| 179 | - '<ul><li>' . |
|
| 180 | - implode( '</li><li>', $renderedElements ) . |
|
| 179 | + '<ul><li>'. |
|
| 180 | + implode('</li><li>', $renderedElements). |
|
| 181 | 181 | '</li></ul>' |
| 182 | 182 | ), |
| 183 | 183 | ], |
@@ -190,11 +190,11 @@ discard block |
||
| 190 | 190 | * @param string|null $role one of the Role::* constants |
| 191 | 191 | * @return MessageParam[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
| 192 | 192 | */ |
| 193 | - private function renderEntityId( EntityId $entityId, ?string $role ): array { |
|
| 194 | - return [ Message::rawParam( $this->addRole( |
|
| 195 | - $this->entityIdFormatter->formatEntityId( $entityId ), |
|
| 193 | + private function renderEntityId(EntityId $entityId, ?string $role): array { |
|
| 194 | + return [Message::rawParam($this->addRole( |
|
| 195 | + $this->entityIdFormatter->formatEntityId($entityId), |
|
| 196 | 196 | $role |
| 197 | - ) ) ]; |
|
| 197 | + ))]; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | * @param string|null $role one of the Role::* constants |
| 203 | 203 | * @return MessageParam[] list of parameters as accepted by Message::params() |
| 204 | 204 | */ |
| 205 | - private function renderEntityIdList( array $entityIdList, ?string $role ): array { |
|
| 206 | - return $this->renderList( $entityIdList, $role, [ $this, 'renderEntityId' ] ); |
|
| 205 | + private function renderEntityIdList(array $entityIdList, ?string $role): array { |
|
| 206 | + return $this->renderList($entityIdList, $role, [$this, 'renderEntityId']); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -211,24 +211,24 @@ discard block |
||
| 211 | 211 | * @param string|null $role one of the Role::* constants |
| 212 | 212 | * @return MessageParam[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
| 213 | 213 | */ |
| 214 | - private function renderItemIdSnakValue( ItemIdSnakValue $value, ?string $role ): array { |
|
| 215 | - switch ( true ) { |
|
| 214 | + private function renderItemIdSnakValue(ItemIdSnakValue $value, ?string $role): array { |
|
| 215 | + switch (true) { |
|
| 216 | 216 | case $value->isValue(): |
| 217 | - return $this->renderEntityId( $value->getItemId(), $role ); |
|
| 217 | + return $this->renderEntityId($value->getItemId(), $role); |
|
| 218 | 218 | case $value->isSomeValue(): |
| 219 | - return [ Message::rawParam( $this->addRole( |
|
| 220 | - '<span class="wikibase-snakview-variation-somevaluesnak">' . |
|
| 221 | - $this->msgEscaped( 'wikibase-snakview-snaktypeselector-somevalue' ) . |
|
| 219 | + return [Message::rawParam($this->addRole( |
|
| 220 | + '<span class="wikibase-snakview-variation-somevaluesnak">'. |
|
| 221 | + $this->msgEscaped('wikibase-snakview-snaktypeselector-somevalue'). |
|
| 222 | 222 | '</span>', |
| 223 | 223 | $role |
| 224 | - ) ) ]; |
|
| 224 | + ))]; |
|
| 225 | 225 | case $value->isNoValue(): |
| 226 | - return [ Message::rawParam( $this->addRole( |
|
| 227 | - '<span class="wikibase-snakview-variation-novaluesnak">' . |
|
| 228 | - $this->msgEscaped( 'wikibase-snakview-snaktypeselector-novalue' ) . |
|
| 226 | + return [Message::rawParam($this->addRole( |
|
| 227 | + '<span class="wikibase-snakview-variation-novaluesnak">'. |
|
| 228 | + $this->msgEscaped('wikibase-snakview-snaktypeselector-novalue'). |
|
| 229 | 229 | '</span>', |
| 230 | 230 | $role |
| 231 | - ) ) ]; |
|
| 231 | + ))]; |
|
| 232 | 232 | default: |
| 233 | 233 | // @codeCoverageIgnoreStart |
| 234 | 234 | throw new LogicException( |
@@ -243,8 +243,8 @@ discard block |
||
| 243 | 243 | * @param string|null $role one of the Role::* constants |
| 244 | 244 | * @return MessageParam[] list of parameters as accepted by Message::params() |
| 245 | 245 | */ |
| 246 | - private function renderItemIdSnakValueList( array $valueList, ?string $role ): array { |
|
| 247 | - return $this->renderList( $valueList, $role, [ $this, 'renderItemIdSnakValue' ] ); |
|
| 246 | + private function renderItemIdSnakValueList(array $valueList, ?string $role): array { |
|
| 247 | + return $this->renderList($valueList, $role, [$this, 'renderItemIdSnakValue']); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | /** |
@@ -252,11 +252,11 @@ discard block |
||
| 252 | 252 | * @param string|null $role one of the Role::* constants |
| 253 | 253 | * @return MessageParam[] list of parameters as accepted by Message::params() |
| 254 | 254 | */ |
| 255 | - private function renderDataValue( DataValue $dataValue, ?string $role ): array { |
|
| 256 | - return [ Message::rawParam( $this->addRole( |
|
| 257 | - $this->dataValueFormatter->format( $dataValue ), |
|
| 255 | + private function renderDataValue(DataValue $dataValue, ?string $role): array { |
|
| 256 | + return [Message::rawParam($this->addRole( |
|
| 257 | + $this->dataValueFormatter->format($dataValue), |
|
| 258 | 258 | $role |
| 259 | - ) ) ]; |
|
| 259 | + ))]; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * @param string|null $role one of the Role::* constants |
| 265 | 265 | * @return MessageParam[] list of parameters as accepted by Message::params() |
| 266 | 266 | */ |
| 267 | - private function renderDataValueType( string $dataValueType, ?string $role ): array { |
|
| 267 | + private function renderDataValueType(string $dataValueType, ?string $role): array { |
|
| 268 | 268 | $messageKeys = [ |
| 269 | 269 | 'string' => 'datatypes-type-string', |
| 270 | 270 | 'monolingualtext' => 'datatypes-type-monolingualtext', |
@@ -273,15 +273,15 @@ discard block |
||
| 273 | 273 | 'wikibase-entityid' => 'wbqc-dataValueType-wikibase-entityid', |
| 274 | 274 | ]; |
| 275 | 275 | |
| 276 | - if ( array_key_exists( $dataValueType, $messageKeys ) ) { |
|
| 277 | - return [ Message::rawParam( $this->addRole( |
|
| 278 | - $this->msgEscaped( $messageKeys[$dataValueType] ), |
|
| 276 | + if (array_key_exists($dataValueType, $messageKeys)) { |
|
| 277 | + return [Message::rawParam($this->addRole( |
|
| 278 | + $this->msgEscaped($messageKeys[$dataValueType]), |
|
| 279 | 279 | $role |
| 280 | - ) ) ]; |
|
| 280 | + ))]; |
|
| 281 | 281 | } else { |
| 282 | 282 | // @codeCoverageIgnoreStart |
| 283 | 283 | throw new LogicException( |
| 284 | - 'Unknown data value type ' . $dataValueType |
|
| 284 | + 'Unknown data value type '.$dataValueType |
|
| 285 | 285 | ); |
| 286 | 286 | // @codeCoverageIgnoreEnd |
| 287 | 287 | } |
@@ -292,11 +292,11 @@ discard block |
||
| 292 | 292 | * @param string|null $role one of the Role::* constants |
| 293 | 293 | * @return MessageParam[] list of parameters as accepted by Message::params() |
| 294 | 294 | */ |
| 295 | - private function renderInlineCode( string $code, ?string $role ): array { |
|
| 296 | - return [ Message::rawParam( $this->addRole( |
|
| 297 | - '<code>' . htmlspecialchars( $code ) . '</code>', |
|
| 295 | + private function renderInlineCode(string $code, ?string $role): array { |
|
| 296 | + return [Message::rawParam($this->addRole( |
|
| 297 | + '<code>'.htmlspecialchars($code).'</code>', |
|
| 298 | 298 | $role |
| 299 | - ) ) ]; |
|
| 299 | + ))]; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | /** |
@@ -304,8 +304,8 @@ discard block |
||
| 304 | 304 | * @param string|null $role one of the Role::* constants |
| 305 | 305 | * @return MessageParam[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
| 306 | 306 | */ |
| 307 | - private function renderConstraintScope( string $scope, ?string $role ): array { |
|
| 308 | - switch ( $scope ) { |
|
| 307 | + private function renderConstraintScope(string $scope, ?string $role): array { |
|
| 308 | + switch ($scope) { |
|
| 309 | 309 | case Context::TYPE_STATEMENT: |
| 310 | 310 | $itemId = $this->config->get( |
| 311 | 311 | 'WBQualityConstraintsConstraintCheckedOnMainValueId' |
@@ -325,10 +325,10 @@ discard block |
||
| 325 | 325 | // callers should never let this happen, but if it does happen, |
| 326 | 326 | // showing “unknown value” seems reasonable |
| 327 | 327 | // @codeCoverageIgnoreStart |
| 328 | - return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
| 328 | + return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
| 329 | 329 | // @codeCoverageIgnoreEnd |
| 330 | 330 | } |
| 331 | - return $this->renderEntityId( new ItemId( $itemId ), $role ); |
|
| 331 | + return $this->renderEntityId(new ItemId($itemId), $role); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | * @param string|null $role one of the Role::* constants |
| 337 | 337 | * @return MessageParam[] list of parameters as accepted by Message::params() |
| 338 | 338 | */ |
| 339 | - private function renderConstraintScopeList( array $scopeList, ?string $role ): array { |
|
| 340 | - return $this->renderList( $scopeList, $role, [ $this, 'renderConstraintScope' ] ); |
|
| 339 | + private function renderConstraintScopeList(array $scopeList, ?string $role): array { |
|
| 340 | + return $this->renderList($scopeList, $role, [$this, 'renderConstraintScope']); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | /** |
@@ -345,25 +345,25 @@ discard block |
||
| 345 | 345 | * @param string|null $role one of the Role::* constants |
| 346 | 346 | * @return MessageParam[] list of a single raw message param (i. e. [ Message::rawParam( … ) ]) |
| 347 | 347 | */ |
| 348 | - private function renderPropertyScope( string $scope, ?string $role ): array { |
|
| 349 | - switch ( $scope ) { |
|
| 348 | + private function renderPropertyScope(string $scope, ?string $role): array { |
|
| 349 | + switch ($scope) { |
|
| 350 | 350 | case Context::TYPE_STATEMENT: |
| 351 | - $itemId = $this->config->get( 'WBQualityConstraintsAsMainValueId' ); |
|
| 351 | + $itemId = $this->config->get('WBQualityConstraintsAsMainValueId'); |
|
| 352 | 352 | break; |
| 353 | 353 | case Context::TYPE_QUALIFIER: |
| 354 | - $itemId = $this->config->get( 'WBQualityConstraintsAsQualifiersId' ); |
|
| 354 | + $itemId = $this->config->get('WBQualityConstraintsAsQualifiersId'); |
|
| 355 | 355 | break; |
| 356 | 356 | case Context::TYPE_REFERENCE: |
| 357 | - $itemId = $this->config->get( 'WBQualityConstraintsAsReferencesId' ); |
|
| 357 | + $itemId = $this->config->get('WBQualityConstraintsAsReferencesId'); |
|
| 358 | 358 | break; |
| 359 | 359 | default: |
| 360 | 360 | // callers should never let this happen, but if it does happen, |
| 361 | 361 | // showing “unknown value” seems reasonable |
| 362 | 362 | // @codeCoverageIgnoreStart |
| 363 | - return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
| 363 | + return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
| 364 | 364 | // @codeCoverageIgnoreEnd |
| 365 | 365 | } |
| 366 | - return $this->renderEntityId( new ItemId( $itemId ), $role ); |
|
| 366 | + return $this->renderEntityId(new ItemId($itemId), $role); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | /** |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | * @param string|null $role one of the Role::* constants |
| 372 | 372 | * @return MessageParam[] list of parameters as accepted by Message::params() |
| 373 | 373 | */ |
| 374 | - private function renderPropertyScopeList( array $scopeList, ?string $role ): array { |
|
| 375 | - return $this->renderList( $scopeList, $role, [ $this, 'renderPropertyScope' ] ); |
|
| 374 | + private function renderPropertyScopeList(array $scopeList, ?string $role): array { |
|
| 375 | + return $this->renderList($scopeList, $role, [$this, 'renderPropertyScope']); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | /** |
@@ -380,14 +380,14 @@ discard block |
||
| 380 | 380 | * @param string|null $role one of the Role::* constants |
| 381 | 381 | * @return MessageParam[] list of parameters as accepted by Message::params() |
| 382 | 382 | */ |
| 383 | - private function renderLanguage( string $languageCode, ?string $role ): array { |
|
| 383 | + private function renderLanguage(string $languageCode, ?string $role): array { |
|
| 384 | 384 | return [ |
| 385 | 385 | // ::renderList (through ::renderLanguageList) requires 'raw' parameter |
| 386 | 386 | // so we effectively build Message::plaintextParam here |
| 387 | - Message::rawParam( htmlspecialchars( |
|
| 388 | - $this->languageNameUtils->getLanguageName( $languageCode, $this->userLanguageCode ) |
|
| 389 | - ) ), |
|
| 390 | - Message::plaintextParam( $languageCode ), |
|
| 387 | + Message::rawParam(htmlspecialchars( |
|
| 388 | + $this->languageNameUtils->getLanguageName($languageCode, $this->userLanguageCode) |
|
| 389 | + )), |
|
| 390 | + Message::plaintextParam($languageCode), |
|
| 391 | 391 | ]; |
| 392 | 392 | } |
| 393 | 393 | |
@@ -396,8 +396,8 @@ discard block |
||
| 396 | 396 | * @param string|null $role one of the Role::* constants |
| 397 | 397 | * @return MessageParam[] list of parameters as accepted by Message::params() |
| 398 | 398 | */ |
| 399 | - private function renderLanguageList( array $languageCodes, ?string $role ): array { |
|
| 400 | - return $this->renderList( $languageCodes, $role, [ $this, 'renderLanguage' ] ); |
|
| 399 | + private function renderLanguageList(array $languageCodes, ?string $role): array { |
|
| 400 | + return $this->renderList($languageCodes, $role, [$this, 'renderLanguage']); |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | } |