@@ -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\ConstraintCheck\Cache; |
| 6 | 6 | |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | * @param int $maxAge The maximum age of the cached value (in seconds). |
| 32 | 32 | * @return self Indication that a value is possibly outdated by up to this many seconds. |
| 33 | 33 | */ |
| 34 | - public static function ofMaximumAgeInSeconds( int $maxAge ): self { |
|
| 35 | - Assert::parameter( $maxAge > 0, '$maxAge', '$maxage > 0' ); |
|
| 34 | + public static function ofMaximumAgeInSeconds(int $maxAge): self { |
|
| 35 | + Assert::parameter($maxAge > 0, '$maxAge', '$maxage > 0'); |
|
| 36 | 36 | $ret = new self; |
| 37 | 37 | $ret->maxAge = $maxAge; |
| 38 | 38 | return $ret; |
@@ -43,9 +43,9 @@ discard block |
||
| 43 | 43 | * @param array|null $array As returned by toArray. |
| 44 | 44 | * @return self |
| 45 | 45 | */ |
| 46 | - public static function ofArray( array $array = null ): self { |
|
| 46 | + public static function ofArray(array $array = null): self { |
|
| 47 | 47 | $ret = new self; |
| 48 | - if ( $array !== null ) { |
|
| 48 | + if ($array !== null) { |
|
| 49 | 49 | $ret->maxAge = $array['maximumAgeInSeconds']; |
| 50 | 50 | } |
| 51 | 51 | return $ret; |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | * @param self[] $metadatas |
| 56 | 56 | * @return self |
| 57 | 57 | */ |
| 58 | - public static function merge( array $metadatas ): self { |
|
| 59 | - Assert::parameterElementType( self::class, $metadatas, '$metadatas' ); |
|
| 58 | + public static function merge(array $metadatas): self { |
|
| 59 | + Assert::parameterElementType(self::class, $metadatas, '$metadatas'); |
|
| 60 | 60 | $ret = new self; |
| 61 | - foreach ( $metadatas as $metadata ) { |
|
| 62 | - $ret->maxAge = max( $ret->maxAge, $metadata->maxAge ); |
|
| 61 | + foreach ($metadatas as $metadata) { |
|
| 62 | + $ret->maxAge = max($ret->maxAge, $metadata->maxAge); |
|
| 63 | 63 | } |
| 64 | 64 | return $ret; |
| 65 | 65 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * For a fresh value, returns 0. |
| 78 | 78 | */ |
| 79 | 79 | public function getMaximumAgeInSeconds(): int { |
| 80 | - if ( is_int( $this->maxAge ) ) { |
|
| 80 | + if (is_int($this->maxAge)) { |
|
| 81 | 81 | return $this->maxAge; |
| 82 | 82 | } else { |
| 83 | 83 | return 0; |
@@ -92,8 +92,7 @@ discard block |
||
| 92 | 92 | return $this->isCached() ? |
| 93 | 93 | [ |
| 94 | 94 | 'maximumAgeInSeconds' => $this->maxAge, |
| 95 | - ] : |
|
| 96 | - null; |
|
| 95 | + ] : null; |
|
| 97 | 96 | } |
| 98 | 97 | |
| 99 | 98 | } |
@@ -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 | |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | public const ENTITY_LOOKUP = 'WBQC_EntityLookup'; |
| 26 | 26 | public const ENTITY_LOOKUP_WITHOUT_CACHE = 'WBQC_EntityLookupWithoutCache'; |
| 27 | 27 | |
| 28 | - private static function getService( ?MediaWikiServices $services, $name ) { |
|
| 28 | + private static function getService(?MediaWikiServices $services, $name) { |
|
| 29 | 29 | $services ??= MediaWikiServices::getInstance(); |
| 30 | - return $services->getService( $name ); |
|
| 30 | + return $services->getService($name); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | * this lookup ignores exceptions (such as unresolved redirects, T93273), |
| 38 | 38 | * as it is more convenient to treat them all as missing entities in WBQC. |
| 39 | 39 | */ |
| 40 | - public static function getEntityLookup( MediaWikiServices $services = null ): EntityLookup { |
|
| 41 | - return self::getService( $services, self::ENTITY_LOOKUP ); |
|
| 40 | + public static function getEntityLookup(MediaWikiServices $services = null): EntityLookup { |
|
| 41 | + return self::getService($services, self::ENTITY_LOOKUP); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | * were exceeding the request memory limit when they were all added to the cache (T227450). |
| 49 | 49 | * Also, like {@link self::getEntityLookup()}, this lookup ignores exceptions. |
| 50 | 50 | */ |
| 51 | - public static function getEntityLookupWithoutCache( MediaWikiServices $services = null ): EntityLookup { |
|
| 52 | - return self::getService( $services, self::ENTITY_LOOKUP_WITHOUT_CACHE ); |
|
| 51 | + public static function getEntityLookupWithoutCache(MediaWikiServices $services = null): EntityLookup { |
|
| 52 | + return self::getService($services, self::ENTITY_LOOKUP_WITHOUT_CACHE); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | } |
@@ -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\Specials; |
| 6 | 6 | |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | Config $config, |
| 92 | 92 | IBufferingStatsdDataFactory $dataFactory |
| 93 | 93 | ) { |
| 94 | - parent::__construct( 'ConstraintReport' ); |
|
| 94 | + parent::__construct('ConstraintReport'); |
|
| 95 | 95 | |
| 96 | 96 | $this->entityLookup = $entityLookup; |
| 97 | 97 | $this->entityTitleLookup = $entityTitleLookup; |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | $this->violationMessageRenderer = $violationMessageRendererFactory->getViolationMessageRenderer( |
| 113 | 113 | $language, |
| 114 | - $languageFallbackChainFactory->newFromLanguage( $language ), |
|
| 114 | + $languageFallbackChainFactory->newFromLanguage($language), |
|
| 115 | 115 | $this->getContext() |
| 116 | 116 | ); |
| 117 | 117 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @inheritDoc |
| 146 | 146 | */ |
| 147 | 147 | public function getDescription() { |
| 148 | - return $this->msg( 'wbqc-constraintreport' ); |
|
| 148 | + return $this->msg('wbqc-constraintreport'); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
@@ -157,43 +157,43 @@ discard block |
||
| 157 | 157 | * @throws EntityIdParsingException |
| 158 | 158 | * @throws UnexpectedValueException |
| 159 | 159 | */ |
| 160 | - public function execute( $subPage ) { |
|
| 160 | + public function execute($subPage) { |
|
| 161 | 161 | $out = $this->getOutput(); |
| 162 | 162 | |
| 163 | - $postRequest = $this->getContext()->getRequest()->getVal( 'entityid' ); |
|
| 164 | - if ( $postRequest ) { |
|
| 165 | - $out->redirect( $this->getPageTitle( strtoupper( $postRequest ) )->getLocalURL() ); |
|
| 163 | + $postRequest = $this->getContext()->getRequest()->getVal('entityid'); |
|
| 164 | + if ($postRequest) { |
|
| 165 | + $out->redirect($this->getPageTitle(strtoupper($postRequest))->getLocalURL()); |
|
| 166 | 166 | return; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | $out->enableOOUI(); |
| 170 | - $out->addModules( $this->getModules() ); |
|
| 170 | + $out->addModules($this->getModules()); |
|
| 171 | 171 | |
| 172 | 172 | $this->setHeaders(); |
| 173 | 173 | |
| 174 | - $out->addHTML( $this->getExplanationText() ); |
|
| 174 | + $out->addHTML($this->getExplanationText()); |
|
| 175 | 175 | $this->buildEntityIdForm(); |
| 176 | 176 | |
| 177 | - if ( !$subPage ) { |
|
| 177 | + if (!$subPage) { |
|
| 178 | 178 | return; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - if ( !is_string( $subPage ) ) { |
|
| 182 | - throw new InvalidArgumentException( '$subPage must be string.' ); |
|
| 181 | + if (!is_string($subPage)) { |
|
| 182 | + throw new InvalidArgumentException('$subPage must be string.'); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | try { |
| 186 | - $entityId = $this->entityIdParser->parse( $subPage ); |
|
| 187 | - } catch ( EntityIdParsingException $e ) { |
|
| 186 | + $entityId = $this->entityIdParser->parse($subPage); |
|
| 187 | + } catch (EntityIdParsingException $e) { |
|
| 188 | 188 | $out->addHTML( |
| 189 | - $this->buildNotice( 'wbqc-constraintreport-invalid-entity-id', true ) |
|
| 189 | + $this->buildNotice('wbqc-constraintreport-invalid-entity-id', true) |
|
| 190 | 190 | ); |
| 191 | 191 | return; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if ( !$this->entityLookup->hasEntity( $entityId ) ) { |
|
| 194 | + if (!$this->entityLookup->hasEntity($entityId)) { |
|
| 195 | 195 | $out->addHTML( |
| 196 | - $this->buildNotice( 'wbqc-constraintreport-not-existent-entity', true ) |
|
| 196 | + $this->buildNotice('wbqc-constraintreport-not-existent-entity', true) |
|
| 197 | 197 | ); |
| 198 | 198 | return; |
| 199 | 199 | } |
@@ -201,18 +201,18 @@ discard block |
||
| 201 | 201 | $this->dataFactory->increment( |
| 202 | 202 | 'wikibase.quality.constraints.specials.specialConstraintReport.executeCheck' |
| 203 | 203 | ); |
| 204 | - $results = $this->constraintChecker->checkAgainstConstraintsOnEntityId( $entityId ); |
|
| 204 | + $results = $this->constraintChecker->checkAgainstConstraintsOnEntityId($entityId); |
|
| 205 | 205 | |
| 206 | - if ( $results !== [] ) { |
|
| 206 | + if ($results !== []) { |
|
| 207 | 207 | $out->addHTML( |
| 208 | - $this->buildResultHeader( $entityId ) |
|
| 209 | - . $this->buildSummary( $results ) |
|
| 210 | - . $this->buildResultTable( $entityId, $results ) |
|
| 208 | + $this->buildResultHeader($entityId) |
|
| 209 | + . $this->buildSummary($results) |
|
| 210 | + . $this->buildResultTable($entityId, $results) |
|
| 211 | 211 | ); |
| 212 | 212 | } else { |
| 213 | 213 | $out->addHTML( |
| 214 | - $this->buildResultHeader( $entityId ) |
|
| 215 | - . $this->buildNotice( 'wbqc-constraintreport-empty-result' ) |
|
| 214 | + $this->buildResultHeader($entityId) |
|
| 215 | + . $this->buildNotice('wbqc-constraintreport-empty-result') |
|
| 216 | 216 | ); |
| 217 | 217 | } |
| 218 | 218 | } |
@@ -228,16 +228,16 @@ discard block |
||
| 228 | 228 | 'name' => 'entityid', |
| 229 | 229 | 'label-message' => 'wbqc-constraintreport-form-entityid-label', |
| 230 | 230 | 'cssclass' => 'wbqc-constraintreport-form-entity-id', |
| 231 | - 'placeholder' => $this->msg( 'wbqc-constraintreport-form-entityid-placeholder' )->escaped(), |
|
| 231 | + 'placeholder' => $this->msg('wbqc-constraintreport-form-entityid-placeholder')->escaped(), |
|
| 232 | 232 | 'required' => true, |
| 233 | 233 | ], |
| 234 | 234 | ]; |
| 235 | - $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form' ); |
|
| 236 | - $htmlForm->setSubmitText( $this->msg( 'wbqc-constraintreport-form-submit-label' )->escaped() ); |
|
| 237 | - $htmlForm->setSubmitCallback( static function () { |
|
| 235 | + $htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext(), 'wbqc-constraintreport-form'); |
|
| 236 | + $htmlForm->setSubmitText($this->msg('wbqc-constraintreport-form-submit-label')->escaped()); |
|
| 237 | + $htmlForm->setSubmitCallback(static function() { |
|
| 238 | 238 | return false; |
| 239 | 239 | } ); |
| 240 | - $htmlForm->setMethod( 'post' ); |
|
| 240 | + $htmlForm->setMethod('post'); |
|
| 241 | 241 | $htmlForm->show(); |
| 242 | 242 | } |
| 243 | 243 | |
@@ -251,9 +251,9 @@ discard block |
||
| 251 | 251 | * |
| 252 | 252 | * @return string HTML |
| 253 | 253 | */ |
| 254 | - private function buildNotice( string $messageKey, bool $error = false ): string { |
|
| 254 | + private function buildNotice(string $messageKey, bool $error = false): string { |
|
| 255 | 255 | $cssClasses = 'wbqc-constraintreport-notice'; |
| 256 | - if ( $error ) { |
|
| 256 | + if ($error) { |
|
| 257 | 257 | $cssClasses .= ' wbqc-constraintreport-notice-error'; |
| 258 | 258 | } |
| 259 | 259 | |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | [ |
| 263 | 263 | 'class' => $cssClasses, |
| 264 | 264 | ], |
| 265 | - $this->msg( $messageKey )->escaped() |
|
| 265 | + $this->msg($messageKey)->escaped() |
|
| 266 | 266 | ); |
| 267 | 267 | } |
| 268 | 268 | |
@@ -272,16 +272,16 @@ discard block |
||
| 272 | 272 | private function getExplanationText(): string { |
| 273 | 273 | return Html::rawElement( |
| 274 | 274 | 'div', |
| 275 | - [ 'class' => 'wbqc-explanation' ], |
|
| 275 | + ['class' => 'wbqc-explanation'], |
|
| 276 | 276 | Html::rawElement( |
| 277 | 277 | 'p', |
| 278 | 278 | [], |
| 279 | - $this->msg( 'wbqc-constraintreport-explanation-part-one' )->escaped() |
|
| 279 | + $this->msg('wbqc-constraintreport-explanation-part-one')->escaped() |
|
| 280 | 280 | ) |
| 281 | 281 | . Html::rawElement( |
| 282 | 282 | 'p', |
| 283 | 283 | [], |
| 284 | - $this->msg( 'wbqc-constraintreport-explanation-part-two' )->escaped() |
|
| 284 | + $this->msg('wbqc-constraintreport-explanation-part-two')->escaped() |
|
| 285 | 285 | ) |
| 286 | 286 | ); |
| 287 | 287 | } |
@@ -292,31 +292,31 @@ discard block |
||
| 292 | 292 | * |
| 293 | 293 | * @return string HTML |
| 294 | 294 | */ |
| 295 | - private function buildResultTable( EntityId $entityId, array $results ): string { |
|
| 295 | + private function buildResultTable(EntityId $entityId, array $results): string { |
|
| 296 | 296 | // Set table headers |
| 297 | 297 | $table = new HtmlTableBuilder( |
| 298 | 298 | [ |
| 299 | 299 | new HtmlTableHeaderBuilder( |
| 300 | - $this->msg( 'wbqc-constraintreport-result-table-header-status' )->text(), |
|
| 300 | + $this->msg('wbqc-constraintreport-result-table-header-status')->text(), |
|
| 301 | 301 | true |
| 302 | 302 | ), |
| 303 | 303 | new HtmlTableHeaderBuilder( |
| 304 | - $this->msg( 'wbqc-constraintreport-result-table-header-property' )->text(), |
|
| 304 | + $this->msg('wbqc-constraintreport-result-table-header-property')->text(), |
|
| 305 | 305 | true |
| 306 | 306 | ), |
| 307 | 307 | new HtmlTableHeaderBuilder( |
| 308 | - $this->msg( 'wbqc-constraintreport-result-table-header-message' )->text(), |
|
| 308 | + $this->msg('wbqc-constraintreport-result-table-header-message')->text(), |
|
| 309 | 309 | true |
| 310 | 310 | ), |
| 311 | 311 | new HtmlTableHeaderBuilder( |
| 312 | - $this->msg( 'wbqc-constraintreport-result-table-header-constraint' )->text(), |
|
| 312 | + $this->msg('wbqc-constraintreport-result-table-header-constraint')->text(), |
|
| 313 | 313 | true |
| 314 | 314 | ), |
| 315 | 315 | ] |
| 316 | 316 | ); |
| 317 | 317 | |
| 318 | - foreach ( $results as $result ) { |
|
| 319 | - $table = $this->appendToResultTable( $table, $entityId, $result ); |
|
| 318 | + foreach ($results as $result) { |
|
| 319 | + $table = $this->appendToResultTable($table, $entityId, $result); |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | return $table->toHtml(); |
@@ -328,35 +328,35 @@ discard block |
||
| 328 | 328 | CheckResult $result |
| 329 | 329 | ): HtmlTableBuilder { |
| 330 | 330 | $message = $result->getMessage(); |
| 331 | - if ( $message === null ) { |
|
| 331 | + if ($message === null) { |
|
| 332 | 332 | // no row for this result |
| 333 | 333 | return $table; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | // Status column |
| 337 | - $statusColumn = $this->formatStatus( $result->getStatus() ); |
|
| 337 | + $statusColumn = $this->formatStatus($result->getStatus()); |
|
| 338 | 338 | |
| 339 | 339 | // Property column |
| 340 | - $propertyId = new NumericPropertyId( $result->getContextCursor()->getSnakPropertyId() ); |
|
| 340 | + $propertyId = new NumericPropertyId($result->getContextCursor()->getSnakPropertyId()); |
|
| 341 | 341 | $propertyColumn = $this->getClaimLink( |
| 342 | 342 | $entityId, |
| 343 | 343 | $propertyId, |
| 344 | - $this->entityIdLabelFormatter->formatEntityId( $propertyId ) |
|
| 344 | + $this->entityIdLabelFormatter->formatEntityId($propertyId) |
|
| 345 | 345 | ); |
| 346 | 346 | |
| 347 | 347 | // Message column |
| 348 | - $messageColumn = $this->violationMessageRenderer->render( $message ); |
|
| 348 | + $messageColumn = $this->violationMessageRenderer->render($message); |
|
| 349 | 349 | |
| 350 | 350 | // Constraint column |
| 351 | 351 | $constraintTypeItemId = $result->getConstraint()->getConstraintTypeItemId(); |
| 352 | 352 | try { |
| 353 | - $constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId( new ItemId( $constraintTypeItemId ) ); |
|
| 354 | - } catch ( InvalidArgumentException $e ) { |
|
| 355 | - $constraintTypeLabel = htmlspecialchars( $constraintTypeItemId ); |
|
| 353 | + $constraintTypeLabel = $this->entityIdLabelFormatter->formatEntityId(new ItemId($constraintTypeItemId)); |
|
| 354 | + } catch (InvalidArgumentException $e) { |
|
| 355 | + $constraintTypeLabel = htmlspecialchars($constraintTypeItemId); |
|
| 356 | 356 | } |
| 357 | 357 | $constraintColumn = $this->getClaimLink( |
| 358 | 358 | $propertyId, |
| 359 | - new NumericPropertyId( $this->config->get( 'WBQualityConstraintsPropertyConstraintId' ) ), |
|
| 359 | + new NumericPropertyId($this->config->get('WBQualityConstraintsPropertyConstraintId')), |
|
| 360 | 360 | $constraintTypeLabel |
| 361 | 361 | ); |
| 362 | 362 | |
@@ -364,16 +364,16 @@ discard block |
||
| 364 | 364 | $table->appendRow( |
| 365 | 365 | [ |
| 366 | 366 | new HtmlTableCellBuilder( |
| 367 | - new HtmlArmor( $statusColumn ) |
|
| 367 | + new HtmlArmor($statusColumn) |
|
| 368 | 368 | ), |
| 369 | 369 | new HtmlTableCellBuilder( |
| 370 | - new HtmlArmor( $propertyColumn ) |
|
| 370 | + new HtmlArmor($propertyColumn) |
|
| 371 | 371 | ), |
| 372 | 372 | new HtmlTableCellBuilder( |
| 373 | - new HtmlArmor( $messageColumn ) |
|
| 373 | + new HtmlArmor($messageColumn) |
|
| 374 | 374 | ), |
| 375 | 375 | new HtmlTableCellBuilder( |
| 376 | - new HtmlArmor( $constraintColumn ) |
|
| 376 | + new HtmlArmor($constraintColumn) |
|
| 377 | 377 | ), |
| 378 | 378 | ] |
| 379 | 379 | ); |
@@ -388,15 +388,15 @@ discard block |
||
| 388 | 388 | * |
| 389 | 389 | * @return string HTML |
| 390 | 390 | */ |
| 391 | - protected function buildResultHeader( EntityId $entityId ): string { |
|
| 392 | - $entityLink = sprintf( '%s (%s)', |
|
| 393 | - $this->entityIdLinkFormatter->formatEntityId( $entityId ), |
|
| 394 | - htmlspecialchars( $entityId->getSerialization() ) ); |
|
| 391 | + protected function buildResultHeader(EntityId $entityId): string { |
|
| 392 | + $entityLink = sprintf('%s (%s)', |
|
| 393 | + $this->entityIdLinkFormatter->formatEntityId($entityId), |
|
| 394 | + htmlspecialchars($entityId->getSerialization())); |
|
| 395 | 395 | |
| 396 | 396 | return Html::rawElement( |
| 397 | 397 | 'h3', |
| 398 | 398 | [], |
| 399 | - sprintf( '%s %s', $this->msg( 'wbqc-constraintreport-result-headline' )->escaped(), $entityLink ) |
|
| 399 | + sprintf('%s %s', $this->msg('wbqc-constraintreport-result-headline')->escaped(), $entityLink) |
|
| 400 | 400 | ); |
| 401 | 401 | } |
| 402 | 402 | |
@@ -407,24 +407,24 @@ discard block |
||
| 407 | 407 | * |
| 408 | 408 | * @return string HTML |
| 409 | 409 | */ |
| 410 | - protected function buildSummary( array $results ): string { |
|
| 410 | + protected function buildSummary(array $results): string { |
|
| 411 | 411 | $statuses = []; |
| 412 | - foreach ( $results as $result ) { |
|
| 413 | - $status = strtolower( $result->getStatus() ); |
|
| 414 | - $statuses[$status] = isset( $statuses[$status] ) ? $statuses[$status] + 1 : 1; |
|
| 412 | + foreach ($results as $result) { |
|
| 413 | + $status = strtolower($result->getStatus()); |
|
| 414 | + $statuses[$status] = isset($statuses[$status]) ? $statuses[$status] + 1 : 1; |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | $statusElements = []; |
| 418 | - foreach ( $statuses as $status => $count ) { |
|
| 419 | - if ( $count > 0 ) { |
|
| 418 | + foreach ($statuses as $status => $count) { |
|
| 419 | + if ($count > 0) { |
|
| 420 | 420 | $statusElements[] = |
| 421 | - $this->formatStatus( $status ) |
|
| 421 | + $this->formatStatus($status) |
|
| 422 | 422 | . ': ' |
| 423 | 423 | . $count; |
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - return Html::rawElement( 'p', [], implode( ', ', $statusElements ) ); |
|
| 427 | + return Html::rawElement('p', [], implode(', ', $statusElements)); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | /** |
@@ -436,8 +436,8 @@ discard block |
||
| 436 | 436 | * |
| 437 | 437 | * @return string HTML |
| 438 | 438 | */ |
| 439 | - private function formatStatus( string $status ): string { |
|
| 440 | - $messageName = "wbqc-constraintreport-status-" . strtolower( $status ); |
|
| 439 | + private function formatStatus(string $status): string { |
|
| 440 | + $messageName = "wbqc-constraintreport-status-".strtolower($status); |
|
| 441 | 441 | $statusIcons = [ |
| 442 | 442 | CheckResult::STATUS_SUGGESTION => [ |
| 443 | 443 | 'icon' => 'suggestion-constraint-violation', |
@@ -454,25 +454,25 @@ discard block |
||
| 454 | 454 | ], |
| 455 | 455 | ]; |
| 456 | 456 | |
| 457 | - if ( array_key_exists( $status, $statusIcons ) ) { |
|
| 458 | - $iconWidget = new IconWidget( $statusIcons[$status] ); |
|
| 459 | - $iconHtml = $iconWidget->toString() . ' '; |
|
| 457 | + if (array_key_exists($status, $statusIcons)) { |
|
| 458 | + $iconWidget = new IconWidget($statusIcons[$status]); |
|
| 459 | + $iconHtml = $iconWidget->toString().' '; |
|
| 460 | 460 | } else { |
| 461 | 461 | $iconHtml = ''; |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - $labelWidget = new LabelWidget( [ |
|
| 465 | - 'label' => $this->msg( $messageName )->text(), |
|
| 466 | - ] ); |
|
| 464 | + $labelWidget = new LabelWidget([ |
|
| 465 | + 'label' => $this->msg($messageName)->text(), |
|
| 466 | + ]); |
|
| 467 | 467 | $labelHtml = $labelWidget->toString(); |
| 468 | 468 | |
| 469 | 469 | $formattedStatus = |
| 470 | 470 | Html::rawElement( |
| 471 | 471 | 'span', |
| 472 | 472 | [ |
| 473 | - 'class' => 'wbqc-status wbqc-status-' . $status, |
|
| 473 | + 'class' => 'wbqc-status wbqc-status-'.$status, |
|
| 474 | 474 | ], |
| 475 | - $iconHtml . $labelHtml |
|
| 475 | + $iconHtml.$labelHtml |
|
| 476 | 476 | ); |
| 477 | 477 | |
| 478 | 478 | return $formattedStatus; |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | return Html::rawElement( |
| 496 | 496 | 'a', |
| 497 | 497 | [ |
| 498 | - 'href' => $this->getClaimUrl( $entityId, $propertyId ), |
|
| 498 | + 'href' => $this->getClaimUrl($entityId, $propertyId), |
|
| 499 | 499 | 'target' => '_blank', |
| 500 | 500 | ], |
| 501 | 501 | $text |
@@ -509,8 +509,8 @@ discard block |
||
| 509 | 509 | EntityId $entityId, |
| 510 | 510 | NumericPropertyId $propertyId |
| 511 | 511 | ): string { |
| 512 | - $title = $this->entityTitleLookup->getTitleForId( $entityId ); |
|
| 513 | - $entityUrl = sprintf( '%s#%s', $title->getLocalURL(), $propertyId->getSerialization() ); |
|
| 512 | + $title = $this->entityTitleLookup->getTitleForId($entityId); |
|
| 513 | + $entityUrl = sprintf('%s#%s', $title->getLocalURL(), $propertyId->getSerialization()); |
|
| 514 | 514 | |
| 515 | 515 | return $entityUrl; |
| 516 | 516 | } |
@@ -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 | |