@@ -32,14 +32,14 @@ discard block |
||
| 32 | 32 | return $ret; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public static function ofCachingMetadata( CachingMetadata $cachingMetadata ): self { |
|
| 35 | + public static function ofCachingMetadata(CachingMetadata $cachingMetadata): self { |
|
| 36 | 36 | $ret = new self; |
| 37 | 37 | $ret->cachingMetadata = $cachingMetadata; |
| 38 | 38 | $ret->dependencyMetadata = DependencyMetadata::blank(); |
| 39 | 39 | return $ret; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public static function ofDependencyMetadata( DependencyMetadata $dependencyMetadata ): self { |
|
| 42 | + public static function ofDependencyMetadata(DependencyMetadata $dependencyMetadata): self { |
|
| 43 | 43 | $ret = new self; |
| 44 | 44 | $ret->cachingMetadata = CachingMetadata::fresh(); |
| 45 | 45 | $ret->dependencyMetadata = $dependencyMetadata; |
@@ -50,17 +50,17 @@ discard block |
||
| 50 | 50 | * @param self[] $metadatas |
| 51 | 51 | * @return self |
| 52 | 52 | */ |
| 53 | - public static function merge( array $metadatas ) { |
|
| 54 | - Assert::parameterElementType( self::class, $metadatas, '$metadatas' ); |
|
| 53 | + public static function merge(array $metadatas) { |
|
| 54 | + Assert::parameterElementType(self::class, $metadatas, '$metadatas'); |
|
| 55 | 55 | $cachingMetadatas = []; |
| 56 | 56 | $dependencyMetadatas = []; |
| 57 | - foreach ( $metadatas as $metadata ) { |
|
| 57 | + foreach ($metadatas as $metadata) { |
|
| 58 | 58 | $cachingMetadatas[] = $metadata->cachingMetadata; |
| 59 | 59 | $dependencyMetadatas[] = $metadata->dependencyMetadata; |
| 60 | 60 | } |
| 61 | 61 | $ret = new self; |
| 62 | - $ret->cachingMetadata = CachingMetadata::merge( $cachingMetadatas ); |
|
| 63 | - $ret->dependencyMetadata = DependencyMetadata::merge( $dependencyMetadatas ); |
|
| 62 | + $ret->cachingMetadata = CachingMetadata::merge($cachingMetadatas); |
|
| 63 | + $ret->dependencyMetadata = DependencyMetadata::merge($dependencyMetadatas); |
|
| 64 | 64 | return $ret; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -43,95 +43,95 @@ |
||
| 43 | 43 | public const VIOLATION_MESSAGE_RENDERER_FACTORY = 'WBQC_ViolationMessageRendererFactory'; |
| 44 | 44 | |
| 45 | 45 | /** @return mixed */ |
| 46 | - private static function getService( ?MediaWikiServices $services, string $name ) { |
|
| 46 | + private static function getService(?MediaWikiServices $services, string $name) { |
|
| 47 | 47 | $services ??= MediaWikiServices::getInstance(); |
| 48 | - return $services->getService( $name ); |
|
| 48 | + return $services->getService($name); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public static function getLogger( ?MediaWikiServices $services = null ): LoggerInterface { |
|
| 52 | - return self::getService( $services, self::LOGGER ); |
|
| 51 | + public static function getLogger(?MediaWikiServices $services = null): LoggerInterface { |
|
| 52 | + return self::getService($services, self::LOGGER); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public static function getLoggingHelper( ?MediaWikiServices $services = null ): LoggingHelper { |
|
| 56 | - return self::getService( $services, self::LOGGING_HELPER ); |
|
| 55 | + public static function getLoggingHelper(?MediaWikiServices $services = null): LoggingHelper { |
|
| 56 | + return self::getService($services, self::LOGGING_HELPER); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public static function getConstraintStore( |
| 60 | 60 | ?MediaWikiServices $services = null |
| 61 | 61 | ): ConstraintStore { |
| 62 | - return self::getService( $services, self::CONSTRAINT_STORE ); |
|
| 62 | + return self::getService($services, self::CONSTRAINT_STORE); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public static function getConstraintLookup( ?MediaWikiServices $services = null ): ConstraintLookup { |
|
| 66 | - return self::getService( $services, self::CONSTRAINT_LOOKUP ); |
|
| 65 | + public static function getConstraintLookup(?MediaWikiServices $services = null): ConstraintLookup { |
|
| 66 | + return self::getService($services, self::CONSTRAINT_LOOKUP); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | public static function getCheckResultSerializer( |
| 70 | 70 | ?MediaWikiServices $services = null |
| 71 | 71 | ): CheckResultSerializer { |
| 72 | - return self::getService( $services, self::CHECK_RESULT_SERIALIZER ); |
|
| 72 | + return self::getService($services, self::CHECK_RESULT_SERIALIZER); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | public static function getCheckResultDeserializer( |
| 76 | 76 | ?MediaWikiServices $services = null |
| 77 | 77 | ): CheckResultDeserializer { |
| 78 | - return self::getService( $services, self::CHECK_RESULT_DESERIALIZER ); |
|
| 78 | + return self::getService($services, self::CHECK_RESULT_DESERIALIZER); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | public static function getViolationMessageSerializer( |
| 82 | 82 | ?MediaWikiServices $services = null |
| 83 | 83 | ): ViolationMessageSerializer { |
| 84 | - return self::getService( $services, self::VIOLATION_MESSAGE_SERIALIZER ); |
|
| 84 | + return self::getService($services, self::VIOLATION_MESSAGE_SERIALIZER); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public static function getViolationMessageDeserializer( |
| 88 | 88 | ?MediaWikiServices $services = null |
| 89 | 89 | ): ViolationMessageDeserializer { |
| 90 | - return self::getService( $services, self::VIOLATION_MESSAGE_DESERIALIZER ); |
|
| 90 | + return self::getService($services, self::VIOLATION_MESSAGE_DESERIALIZER); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | public static function getConstraintParameterParser( |
| 94 | 94 | ?MediaWikiServices $services = null |
| 95 | 95 | ): ConstraintParameterParser { |
| 96 | - return self::getService( $services, self::CONSTRAINT_PARAMETER_PARSER ); |
|
| 96 | + return self::getService($services, self::CONSTRAINT_PARAMETER_PARSER); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | public static function getConnectionCheckerHelper( |
| 100 | 100 | ?MediaWikiServices $services = null |
| 101 | 101 | ): ConnectionCheckerHelper { |
| 102 | - return self::getService( $services, self::CONNECTION_CHECKER_HELPER ); |
|
| 102 | + return self::getService($services, self::CONNECTION_CHECKER_HELPER); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - public static function getRangeCheckerHelper( ?MediaWikiServices $services = null ): RangeCheckerHelper { |
|
| 106 | - return self::getService( $services, self::RANGE_CHECKER_HELPER ); |
|
| 105 | + public static function getRangeCheckerHelper(?MediaWikiServices $services = null): RangeCheckerHelper { |
|
| 106 | + return self::getService($services, self::RANGE_CHECKER_HELPER); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - public static function getSparqlHelper( ?MediaWikiServices $services = null ): SparqlHelper { |
|
| 110 | - return self::getService( $services, self::SPARQL_HELPER ); |
|
| 109 | + public static function getSparqlHelper(?MediaWikiServices $services = null): SparqlHelper { |
|
| 110 | + return self::getService($services, self::SPARQL_HELPER); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public static function getTypeCheckerHelper( ?MediaWikiServices $services = null ): TypeCheckerHelper { |
|
| 114 | - return self::getService( $services, self::TYPE_CHECKER_HELPER ); |
|
| 113 | + public static function getTypeCheckerHelper(?MediaWikiServices $services = null): TypeCheckerHelper { |
|
| 114 | + return self::getService($services, self::TYPE_CHECKER_HELPER); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public static function getDelegatingConstraintChecker( |
| 118 | 118 | ?MediaWikiServices $services = null |
| 119 | 119 | ): DelegatingConstraintChecker { |
| 120 | - return self::getService( $services, self::DELEGATING_CONSTRAINT_CHECKER ); |
|
| 120 | + return self::getService($services, self::DELEGATING_CONSTRAINT_CHECKER); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public static function getResultsSource( ?MediaWikiServices $services = null ): ResultsSource { |
|
| 124 | - return self::getService( $services, self::RESULTS_SOURCE ); |
|
| 123 | + public static function getResultsSource(?MediaWikiServices $services = null): ResultsSource { |
|
| 124 | + return self::getService($services, self::RESULTS_SOURCE); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - public static function getExpiryLock( ?MediaWikiServices $services = null ): ExpiryLock { |
|
| 128 | - return self::getService( $services, self::EXPIRY_LOCK ); |
|
| 127 | + public static function getExpiryLock(?MediaWikiServices $services = null): ExpiryLock { |
|
| 128 | + return self::getService($services, self::EXPIRY_LOCK); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | public static function getViolationMessageRendererFactory( |
| 132 | 132 | ?MediaWikiServices $services = null |
| 133 | 133 | ): ViolationMessageRendererFactory { |
| 134 | - return self::getService( $services, self::VIOLATION_MESSAGE_RENDERER_FACTORY ); |
|
| 134 | + return self::getService($services, self::VIOLATION_MESSAGE_RENDERER_FACTORY); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | } |
@@ -24,16 +24,16 @@ discard block |
||
| 24 | 24 | * then using the main DBLoadBalancer service may be incorrect. |
| 25 | 25 | * @param string|false $dbName Database name ($domain for ILoadBalancer methods). |
| 26 | 26 | */ |
| 27 | - public function __construct( ILoadBalancer $lb, $dbName ) { |
|
| 27 | + public function __construct(ILoadBalancer $lb, $dbName) { |
|
| 28 | 28 | $this->lb = $lb; |
| 29 | 29 | $this->dbName = $dbName; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - private function encodeConstraintParameters( array $constraintParameters ): string { |
|
| 33 | - $json = json_encode( $constraintParameters, JSON_FORCE_OBJECT ); |
|
| 32 | + private function encodeConstraintParameters(array $constraintParameters): string { |
|
| 33 | + $json = json_encode($constraintParameters, JSON_FORCE_OBJECT); |
|
| 34 | 34 | |
| 35 | - if ( strlen( $json ) > 50000 ) { |
|
| 36 | - $json = json_encode( [ '@error' => [ 'toolong' => true ] ] ); |
|
| 35 | + if (strlen($json) > 50000) { |
|
| 36 | + $json = json_encode(['@error' => ['toolong' => true]]); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | return $json; |
@@ -44,28 +44,28 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @throws DBUnexpectedError |
| 46 | 46 | */ |
| 47 | - public function insertBatch( array $constraints ) { |
|
| 48 | - if ( !$constraints ) { |
|
| 47 | + public function insertBatch(array $constraints) { |
|
| 48 | + if (!$constraints) { |
|
| 49 | 49 | return; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $accumulator = array_map( |
| 53 | - function ( Constraint $constraint ) { |
|
| 53 | + function(Constraint $constraint) { |
|
| 54 | 54 | return [ |
| 55 | 55 | 'constraint_guid' => $constraint->getConstraintId(), |
| 56 | 56 | 'pid' => $constraint->getPropertyId()->getNumericId(), |
| 57 | 57 | 'constraint_type_qid' => $constraint->getConstraintTypeItemId(), |
| 58 | - 'constraint_parameters' => $this->encodeConstraintParameters( $constraint->getConstraintParameters() ), |
|
| 58 | + 'constraint_parameters' => $this->encodeConstraintParameters($constraint->getConstraintParameters()), |
|
| 59 | 59 | ]; |
| 60 | 60 | }, |
| 61 | 61 | $constraints |
| 62 | 62 | ); |
| 63 | 63 | |
| 64 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_PRIMARY, [], $this->dbName ); |
|
| 64 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_PRIMARY, [], $this->dbName); |
|
| 65 | 65 | $dbw->newInsertQueryBuilder() |
| 66 | - ->insertInto( 'wbqc_constraints' ) |
|
| 67 | - ->rows( $accumulator ) |
|
| 68 | - ->caller( __METHOD__ ) |
|
| 66 | + ->insertInto('wbqc_constraints') |
|
| 67 | + ->rows($accumulator) |
|
| 68 | + ->caller(__METHOD__) |
|
| 69 | 69 | ->execute(); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @throws DBUnexpectedError |
| 78 | 78 | */ |
| 79 | - public function deleteForProperty( NumericPropertyId $propertyId ) { |
|
| 80 | - $dbw = $this->lb->getConnection( ILoadBalancer::DB_PRIMARY, [], $this->dbName ); |
|
| 79 | + public function deleteForProperty(NumericPropertyId $propertyId) { |
|
| 80 | + $dbw = $this->lb->getConnection(ILoadBalancer::DB_PRIMARY, [], $this->dbName); |
|
| 81 | 81 | $dbw->newDeleteQueryBuilder() |
| 82 | - ->deleteFrom( 'wbqc_constraints' ) |
|
| 83 | - ->where( [ |
|
| 82 | + ->deleteFrom('wbqc_constraints') |
|
| 83 | + ->where([ |
|
| 84 | 84 | 'pid' => $propertyId->getNumericId(), |
| 85 | - ] ) |
|
| 86 | - ->caller( __METHOD__ ) |
|
| 85 | + ]) |
|
| 86 | + ->caller(__METHOD__) |
|
| 87 | 87 | ->execute(); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -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\Context; |
| 6 | 6 | |
@@ -61,6 +61,6 @@ discard block |
||
| 61 | 61 | * @param ?array $result |
| 62 | 62 | * @param array[] &$container |
| 63 | 63 | */ |
| 64 | - public function storeCheckResultInArray( ?array $result, array &$container ): void; |
|
| 64 | + public function storeCheckResultInArray(?array $result, array &$container): void; |
|
| 65 | 65 | |
| 66 | 66 | } |
@@ -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\Context; |
| 6 | 6 | |
@@ -60,29 +60,29 @@ discard block |
||
| 60 | 60 | return $this->snakHash; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - protected function &getMainArray( array &$container ): array { |
|
| 64 | - $statementArray = &$this->getStatementArray( $container ); |
|
| 63 | + protected function &getMainArray(array &$container): array { |
|
| 64 | + $statementArray = &$this->getStatementArray($container); |
|
| 65 | 65 | |
| 66 | - if ( !array_key_exists( 'qualifiers', $statementArray ) ) { |
|
| 66 | + if (!array_key_exists('qualifiers', $statementArray)) { |
|
| 67 | 67 | $statementArray['qualifiers'] = []; |
| 68 | 68 | } |
| 69 | 69 | $qualifiersArray = &$statementArray['qualifiers']; |
| 70 | 70 | |
| 71 | 71 | $snakPropertyId = $this->getSnakPropertyId(); |
| 72 | - if ( !array_key_exists( $snakPropertyId, $qualifiersArray ) ) { |
|
| 72 | + if (!array_key_exists($snakPropertyId, $qualifiersArray)) { |
|
| 73 | 73 | $qualifiersArray[$snakPropertyId] = []; |
| 74 | 74 | } |
| 75 | 75 | $propertyArray = &$qualifiersArray[$snakPropertyId]; |
| 76 | 76 | |
| 77 | 77 | $snakHash = $this->getSnakHash(); |
| 78 | - foreach ( $propertyArray as &$potentialQualifierArray ) { |
|
| 79 | - if ( $potentialQualifierArray['hash'] === $snakHash ) { |
|
| 78 | + foreach ($propertyArray as &$potentialQualifierArray) { |
|
| 79 | + if ($potentialQualifierArray['hash'] === $snakHash) { |
|
| 80 | 80 | $qualifierArray = &$potentialQualifierArray; |
| 81 | 81 | break; |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | - if ( !isset( $qualifierArray ) ) { |
|
| 85 | - $qualifierArray = [ 'hash' => $snakHash ]; |
|
| 84 | + if (!isset($qualifierArray)) { |
|
| 85 | + $qualifierArray = ['hash' => $snakHash]; |
|
| 86 | 86 | $propertyArray[] = &$qualifierArray; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -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\Context; |
| 6 | 6 | |
@@ -29,15 +29,15 @@ discard block |
||
| 29 | 29 | * @param array[] &$container |
| 30 | 30 | * @return array |
| 31 | 31 | */ |
| 32 | - protected function &getClaimsArray( array &$container ): array { |
|
| 32 | + protected function &getClaimsArray(array &$container): array { |
|
| 33 | 33 | $entityId = $this->getEntityId(); |
| 34 | 34 | |
| 35 | - if ( !array_key_exists( $entityId, $container ) ) { |
|
| 35 | + if (!array_key_exists($entityId, $container)) { |
|
| 36 | 36 | $container[$entityId] = []; |
| 37 | 37 | } |
| 38 | 38 | $entityContainer = &$container[$entityId]; |
| 39 | 39 | |
| 40 | - if ( !array_key_exists( 'claims', $entityContainer ) ) { |
|
| 40 | + if (!array_key_exists('claims', $entityContainer)) { |
|
| 41 | 41 | $entityContainer['claims'] = []; |
| 42 | 42 | } |
| 43 | 43 | $claimsArray = &$entityContainer['claims']; |
@@ -51,25 +51,25 @@ discard block |
||
| 51 | 51 | * @param array[] &$container |
| 52 | 52 | * @return array |
| 53 | 53 | */ |
| 54 | - protected function &getStatementArray( array &$container ): array { |
|
| 54 | + protected function &getStatementArray(array &$container): array { |
|
| 55 | 55 | $statementPropertyId = $this->getStatementPropertyId(); |
| 56 | 56 | $statementGuid = $this->getStatementGuid(); |
| 57 | 57 | |
| 58 | - $claimsContainer = &$this->getClaimsArray( $container ); |
|
| 58 | + $claimsContainer = &$this->getClaimsArray($container); |
|
| 59 | 59 | |
| 60 | - if ( !array_key_exists( $statementPropertyId, $claimsContainer ) ) { |
|
| 60 | + if (!array_key_exists($statementPropertyId, $claimsContainer)) { |
|
| 61 | 61 | $claimsContainer[$statementPropertyId] = []; |
| 62 | 62 | } |
| 63 | 63 | $propertyContainer = &$claimsContainer[$statementPropertyId]; |
| 64 | 64 | |
| 65 | - foreach ( $propertyContainer as &$statement ) { |
|
| 66 | - if ( $statement['id'] === $statementGuid ) { |
|
| 65 | + foreach ($propertyContainer as &$statement) { |
|
| 66 | + if ($statement['id'] === $statementGuid) { |
|
| 67 | 67 | $statementArray = &$statement; |
| 68 | 68 | break; |
| 69 | 69 | } |
| 70 | 70 | } |
| 71 | - if ( !isset( $statementArray ) ) { |
|
| 72 | - $statementArray = [ 'id' => $statementGuid ]; |
|
| 71 | + if (!isset($statementArray)) { |
|
| 72 | + $statementArray = ['id' => $statementGuid]; |
|
| 73 | 73 | $propertyContainer[] = &$statementArray; |
| 74 | 74 | } |
| 75 | 75 | |
@@ -84,19 +84,19 @@ discard block |
||
| 84 | 84 | * @param array[] &$container |
| 85 | 85 | * @return array |
| 86 | 86 | */ |
| 87 | - abstract protected function &getMainArray( array &$container ): array; |
|
| 87 | + abstract protected function &getMainArray(array &$container): array; |
|
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * @param ?array $result |
| 91 | 91 | * @param array[] &$container |
| 92 | 92 | */ |
| 93 | - public function storeCheckResultInArray( ?array $result, array &$container ): void { |
|
| 94 | - $mainArray = &$this->getMainArray( $container ); |
|
| 95 | - if ( !array_key_exists( 'results', $mainArray ) ) { |
|
| 93 | + public function storeCheckResultInArray(?array $result, array &$container): void { |
|
| 94 | + $mainArray = &$this->getMainArray($container); |
|
| 95 | + if (!array_key_exists('results', $mainArray)) { |
|
| 96 | 96 | $mainArray['results'] = []; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ( $result !== null ) { |
|
| 99 | + if ($result !== null) { |
|
| 100 | 100 | $mainArray['results'][] = $result; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -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\Context; |
| 6 | 6 | |
@@ -56,12 +56,12 @@ discard block |
||
| 56 | 56 | return $this->snakHash; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - protected function &getMainArray( array &$container ): array { |
|
| 60 | - $statementArray = &$this->getStatementArray( $container ); |
|
| 59 | + protected function &getMainArray(array &$container): array { |
|
| 60 | + $statementArray = &$this->getStatementArray($container); |
|
| 61 | 61 | |
| 62 | - if ( !array_key_exists( 'mainsnak', $statementArray ) ) { |
|
| 62 | + if (!array_key_exists('mainsnak', $statementArray)) { |
|
| 63 | 63 | $snakHash = $this->getSnakHash(); |
| 64 | - $statementArray['mainsnak'] = [ 'hash' => $snakHash ]; |
|
| 64 | + $statementArray['mainsnak'] = ['hash' => $snakHash]; |
|
| 65 | 65 | } |
| 66 | 66 | $mainsnakArray = &$statementArray['mainsnak']; |
| 67 | 67 | |
@@ -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\Context; |
| 6 | 6 | |
@@ -68,43 +68,43 @@ discard block |
||
| 68 | 68 | return $this->referenceHash; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - protected function &getMainArray( array &$container ): array { |
|
| 72 | - $statementArray = &$this->getStatementArray( $container ); |
|
| 71 | + protected function &getMainArray(array &$container): array { |
|
| 72 | + $statementArray = &$this->getStatementArray($container); |
|
| 73 | 73 | |
| 74 | - if ( !array_key_exists( 'references', $statementArray ) ) { |
|
| 74 | + if (!array_key_exists('references', $statementArray)) { |
|
| 75 | 75 | $statementArray['references'] = []; |
| 76 | 76 | } |
| 77 | 77 | $referencesArray = &$statementArray['references']; |
| 78 | 78 | |
| 79 | 79 | $referenceHash = $this->getReferenceHash(); |
| 80 | - foreach ( $referencesArray as &$potentialReferenceArray ) { |
|
| 81 | - if ( $potentialReferenceArray['hash'] === $referenceHash ) { |
|
| 80 | + foreach ($referencesArray as &$potentialReferenceArray) { |
|
| 81 | + if ($potentialReferenceArray['hash'] === $referenceHash) { |
|
| 82 | 82 | $referenceArray = &$potentialReferenceArray; |
| 83 | 83 | break; |
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | - if ( !isset( $referenceArray ) ) { |
|
| 87 | - $referenceArray = [ 'hash' => $referenceHash, 'snaks' => [] ]; |
|
| 86 | + if (!isset($referenceArray)) { |
|
| 87 | + $referenceArray = ['hash' => $referenceHash, 'snaks' => []]; |
|
| 88 | 88 | $referencesArray[] = &$referenceArray; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $snaksArray = &$referenceArray['snaks']; |
| 92 | 92 | |
| 93 | 93 | $snakPropertyId = $this->getSnakPropertyId(); |
| 94 | - if ( !array_key_exists( $snakPropertyId, $snaksArray ) ) { |
|
| 94 | + if (!array_key_exists($snakPropertyId, $snaksArray)) { |
|
| 95 | 95 | $snaksArray[$snakPropertyId] = []; |
| 96 | 96 | } |
| 97 | 97 | $propertyArray = &$snaksArray[$snakPropertyId]; |
| 98 | 98 | |
| 99 | 99 | $snakHash = $this->getSnakHash(); |
| 100 | - foreach ( $propertyArray as &$potentialSnakArray ) { |
|
| 101 | - if ( $potentialSnakArray['hash'] === $snakHash ) { |
|
| 100 | + foreach ($propertyArray as &$potentialSnakArray) { |
|
| 101 | + if ($potentialSnakArray['hash'] === $snakHash) { |
|
| 102 | 102 | $snakArray = &$potentialSnakArray; |
| 103 | 103 | break; |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | - if ( !isset( $snakArray ) ) { |
|
| 107 | - $snakArray = [ 'hash' => $snakHash ]; |
|
| 106 | + if (!isset($snakArray)) { |
|
| 107 | + $snakArray = ['hash' => $snakHash]; |
|
| 108 | 108 | $propertyArray[] = &$snakArray; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -31,58 +31,58 @@ discard block |
||
| 31 | 31 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Result\CheckResultSerializer; |
| 32 | 32 | |
| 33 | 33 | return [ |
| 34 | - ConstraintsServices::EXPIRY_LOCK => static function ( MediaWikiServices $services ): ExpiryLock { |
|
| 35 | - return new ExpiryLock( $services->getObjectCacheFactory()->getInstance( CACHE_ANYTHING ) ); |
|
| 34 | + ConstraintsServices::EXPIRY_LOCK => static function(MediaWikiServices $services): ExpiryLock { |
|
| 35 | + return new ExpiryLock($services->getObjectCacheFactory()->getInstance(CACHE_ANYTHING)); |
|
| 36 | 36 | }, |
| 37 | 37 | |
| 38 | - ConstraintsServices::LOGGER => static function ( MediaWikiServices $services ): LoggerInterface { |
|
| 39 | - return LoggerFactory::getInstance( 'WikibaseQualityConstraints' ); |
|
| 38 | + ConstraintsServices::LOGGER => static function(MediaWikiServices $services): LoggerInterface { |
|
| 39 | + return LoggerFactory::getInstance('WikibaseQualityConstraints'); |
|
| 40 | 40 | }, |
| 41 | 41 | |
| 42 | - ConstraintsServices::LOGGING_HELPER => static function ( MediaWikiServices $services ): LoggingHelper { |
|
| 42 | + ConstraintsServices::LOGGING_HELPER => static function(MediaWikiServices $services): LoggingHelper { |
|
| 43 | 43 | return new LoggingHelper( |
| 44 | - $services->getStatsFactory()->withComponent( 'WikibaseQualityConstraints' ), |
|
| 45 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
| 44 | + $services->getStatsFactory()->withComponent('WikibaseQualityConstraints'), |
|
| 45 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
| 46 | 46 | $services->getMainConfig() |
| 47 | 47 | ); |
| 48 | 48 | }, |
| 49 | 49 | |
| 50 | - ConstraintsServices::CONSTRAINT_STORE => static function ( MediaWikiServices $services ): ConstraintRepositoryStore { |
|
| 51 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
| 52 | - $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE ); |
|
| 53 | - if ( $propertySource === null ) { |
|
| 54 | - throw new RuntimeException( 'Can\'t get a ConstraintStore for properties not stored in a database.' ); |
|
| 50 | + ConstraintsServices::CONSTRAINT_STORE => static function(MediaWikiServices $services): ConstraintRepositoryStore { |
|
| 51 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
| 52 | + $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE); |
|
| 53 | + if ($propertySource === null) { |
|
| 54 | + throw new RuntimeException('Can\'t get a ConstraintStore for properties not stored in a database.'); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
| 58 | - if ( $propertySource->getSourceName() !== $localEntitySourceName ) { |
|
| 59 | - throw new RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' ); |
|
| 57 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
| 58 | + if ($propertySource->getSourceName() !== $localEntitySourceName) { |
|
| 59 | + throw new RuntimeException('Can\'t get a ConstraintStore for a non local entity source.'); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $dbName = $propertySource->getDatabaseName(); |
| 63 | 63 | return new ConstraintRepositoryStore( |
| 64 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
| 64 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
| 65 | 65 | $dbName |
| 66 | 66 | ); |
| 67 | 67 | }, |
| 68 | 68 | |
| 69 | - ConstraintsServices::CONSTRAINT_LOOKUP => static function ( MediaWikiServices $services ): ConstraintLookup { |
|
| 70 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
| 71 | - $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE ); |
|
| 72 | - if ( $propertySource === null ) { |
|
| 73 | - throw new RuntimeException( 'Can\'t get a ConstraintStore for properties not stored in a database.' ); |
|
| 69 | + ConstraintsServices::CONSTRAINT_LOOKUP => static function(MediaWikiServices $services): ConstraintLookup { |
|
| 70 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
| 71 | + $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE); |
|
| 72 | + if ($propertySource === null) { |
|
| 73 | + throw new RuntimeException('Can\'t get a ConstraintStore for properties not stored in a database.'); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | $dbName = $propertySource->getDatabaseName(); |
| 77 | 77 | $rawLookup = new ConstraintRepositoryLookup( |
| 78 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
| 78 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
| 79 | 79 | $dbName, |
| 80 | - ConstraintsServices::getLogger( $services ) |
|
| 80 | + ConstraintsServices::getLogger($services) |
|
| 81 | 81 | ); |
| 82 | - return new CachingConstraintLookup( $rawLookup ); |
|
| 82 | + return new CachingConstraintLookup($rawLookup); |
|
| 83 | 83 | }, |
| 84 | 84 | |
| 85 | - ConstraintsServices::CHECK_RESULT_SERIALIZER => static function ( MediaWikiServices $services ): CheckResultSerializer { |
|
| 85 | + ConstraintsServices::CHECK_RESULT_SERIALIZER => static function(MediaWikiServices $services): CheckResultSerializer { |
|
| 86 | 86 | return new CheckResultSerializer( |
| 87 | 87 | new ConstraintSerializer( |
| 88 | 88 | false // constraint parameters are not exposed |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | ); |
| 94 | 94 | }, |
| 95 | 95 | |
| 96 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function ( MediaWikiServices $services ): CheckResultDeserializer { |
|
| 97 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
| 98 | - $dataValueFactory = WikibaseRepo::getDataValueFactory( $services ); |
|
| 96 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function(MediaWikiServices $services): CheckResultDeserializer { |
|
| 97 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
| 98 | + $dataValueFactory = WikibaseRepo::getDataValueFactory($services); |
|
| 99 | 99 | |
| 100 | 100 | return new CheckResultDeserializer( |
| 101 | 101 | new ConstraintDeserializer(), |
@@ -108,17 +108,17 @@ discard block |
||
| 108 | 108 | ); |
| 109 | 109 | }, |
| 110 | 110 | |
| 111 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function ( |
|
| 111 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function( |
|
| 112 | 112 | MediaWikiServices $services |
| 113 | 113 | ): ViolationMessageSerializer { |
| 114 | 114 | return new ViolationMessageSerializer(); |
| 115 | 115 | }, |
| 116 | 116 | |
| 117 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function ( |
|
| 117 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function( |
|
| 118 | 118 | MediaWikiServices $services |
| 119 | 119 | ): ViolationMessageDeserializer { |
| 120 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
| 121 | - $dataValueFactory = WikibaseRepo::getDataValueFactory( $services ); |
|
| 120 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
| 121 | + $dataValueFactory = WikibaseRepo::getDataValueFactory($services); |
|
| 122 | 122 | |
| 123 | 123 | return new ViolationMessageDeserializer( |
| 124 | 124 | $entityIdParser, |
@@ -126,40 +126,40 @@ discard block |
||
| 126 | 126 | ); |
| 127 | 127 | }, |
| 128 | 128 | |
| 129 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function ( |
|
| 129 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function( |
|
| 130 | 130 | MediaWikiServices $services |
| 131 | 131 | ): ConstraintParameterParser { |
| 132 | - $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory( $services ); |
|
| 133 | - $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
| 132 | + $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory($services); |
|
| 133 | + $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
| 134 | 134 | |
| 135 | 135 | return new ConstraintParameterParser( |
| 136 | 136 | $services->getMainConfig(), |
| 137 | 137 | $deserializerFactory, |
| 138 | - $entitySourceDefinitions->getDatabaseSourceForEntityType( 'item' )->getConceptBaseUri() |
|
| 138 | + $entitySourceDefinitions->getDatabaseSourceForEntityType('item')->getConceptBaseUri() |
|
| 139 | 139 | ); |
| 140 | 140 | }, |
| 141 | 141 | |
| 142 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => static function ( MediaWikiServices $services ): ConnectionCheckerHelper { |
|
| 142 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => static function(MediaWikiServices $services): ConnectionCheckerHelper { |
|
| 143 | 143 | return new ConnectionCheckerHelper(); |
| 144 | 144 | }, |
| 145 | 145 | |
| 146 | - ConstraintsServices::RANGE_CHECKER_HELPER => static function ( MediaWikiServices $services ): RangeCheckerHelper { |
|
| 146 | + ConstraintsServices::RANGE_CHECKER_HELPER => static function(MediaWikiServices $services): RangeCheckerHelper { |
|
| 147 | 147 | return new RangeCheckerHelper( |
| 148 | 148 | $services->getMainConfig(), |
| 149 | - WikibaseRepo::getUnitConverter( $services ) |
|
| 149 | + WikibaseRepo::getUnitConverter($services) |
|
| 150 | 150 | ); |
| 151 | 151 | }, |
| 152 | 152 | |
| 153 | - ConstraintsServices::SPARQL_HELPER => static function ( MediaWikiServices $services ): SparqlHelper { |
|
| 154 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
| 155 | - if ( $endpoint === '' ) { |
|
| 153 | + ConstraintsServices::SPARQL_HELPER => static function(MediaWikiServices $services): SparqlHelper { |
|
| 154 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
| 155 | + if ($endpoint === '') { |
|
| 156 | 156 | return new DummySparqlHelper(); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $rdfVocabulary = WikibaseRepo::getRdfVocabulary( $services ); |
|
| 160 | - $valueSnakRdfBuilderFactory = WikibaseRepo::getValueSnakRdfBuilderFactory( $services ); |
|
| 161 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
| 162 | - $propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup( $services ); |
|
| 159 | + $rdfVocabulary = WikibaseRepo::getRdfVocabulary($services); |
|
| 160 | + $valueSnakRdfBuilderFactory = WikibaseRepo::getValueSnakRdfBuilderFactory($services); |
|
| 161 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
| 162 | + $propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup($services); |
|
| 163 | 163 | |
| 164 | 164 | return new SparqlHelper( |
| 165 | 165 | $services->getMainConfig(), |
@@ -168,128 +168,128 @@ discard block |
||
| 168 | 168 | $entityIdParser, |
| 169 | 169 | $propertyDataTypeLookup, |
| 170 | 170 | $services->getMainWANObjectCache(), |
| 171 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
| 172 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
| 173 | - $services->getStatsFactory()->withComponent( 'WikibaseQualityConstraints' ), |
|
| 174 | - ConstraintsServices::getExpiryLock( $services ), |
|
| 175 | - ConstraintsServices::getLoggingHelper( $services ), |
|
| 176 | - WikiMap::getCurrentWikiId() . ' WikibaseQualityConstraints ' . $services->getHttpRequestFactory()->getUserAgent(), |
|
| 171 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
| 172 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
| 173 | + $services->getStatsFactory()->withComponent('WikibaseQualityConstraints'), |
|
| 174 | + ConstraintsServices::getExpiryLock($services), |
|
| 175 | + ConstraintsServices::getLoggingHelper($services), |
|
| 176 | + WikiMap::getCurrentWikiId().' WikibaseQualityConstraints '.$services->getHttpRequestFactory()->getUserAgent(), |
|
| 177 | 177 | $services->getHttpRequestFactory() |
| 178 | 178 | ); |
| 179 | 179 | }, |
| 180 | 180 | |
| 181 | - ConstraintsServices::TYPE_CHECKER_HELPER => static function ( MediaWikiServices $services ): TypeCheckerHelper { |
|
| 181 | + ConstraintsServices::TYPE_CHECKER_HELPER => static function(MediaWikiServices $services): TypeCheckerHelper { |
|
| 182 | 182 | return new TypeCheckerHelper( |
| 183 | - WikibaseServices::getEntityLookup( $services ), |
|
| 183 | + WikibaseServices::getEntityLookup($services), |
|
| 184 | 184 | $services->getMainConfig(), |
| 185 | - ConstraintsServices::getSparqlHelper( $services ), |
|
| 186 | - $services->getStatsFactory()->withComponent( 'WikibaseQualityConstraints' ) |
|
| 185 | + ConstraintsServices::getSparqlHelper($services), |
|
| 186 | + $services->getStatsFactory()->withComponent('WikibaseQualityConstraints') |
|
| 187 | 187 | ); |
| 188 | 188 | }, |
| 189 | 189 | |
| 190 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function ( |
|
| 190 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function( |
|
| 191 | 191 | MediaWikiServices $services |
| 192 | 192 | ): DelegatingConstraintChecker { |
| 193 | - $statementGuidParser = WikibaseRepo::getStatementGuidParser( $services ); |
|
| 193 | + $statementGuidParser = WikibaseRepo::getStatementGuidParser($services); |
|
| 194 | 194 | |
| 195 | 195 | $config = $services->getMainConfig(); |
| 196 | 196 | $checkerMap = [ |
| 197 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
| 198 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
| 199 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
| 200 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
| 201 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
| 202 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
| 203 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
| 204 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
| 205 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
| 206 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
| 207 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
| 208 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
| 209 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
| 210 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
| 211 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
| 212 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
| 213 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
| 214 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
| 215 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
| 216 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
| 217 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
| 218 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
| 219 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
| 220 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
| 221 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
| 222 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
| 223 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
| 224 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
| 225 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
| 226 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
| 227 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
| 228 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
| 229 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
| 230 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
| 231 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
| 232 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
| 233 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
| 234 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
| 235 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
| 236 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
| 237 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
| 238 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
| 239 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
| 240 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
| 241 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
| 242 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
| 243 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
| 244 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
| 245 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
| 246 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
| 247 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
| 248 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
| 249 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
| 250 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
| 251 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
| 252 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
| 253 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
| 254 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
| 255 | - $config->get( 'WBQualityConstraintsLexemeLanguageConstraintId' ) |
|
| 256 | - => ConstraintCheckerServices::getLexemeLanguageChecker( $services ), |
|
| 257 | - $config->get( 'WBQualityConstraintsLabelInLanguageConstraintId' ) |
|
| 258 | - => ConstraintCheckerServices::getLabelInLanguageChecker( $services ), |
|
| 197 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
| 198 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
| 199 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
| 200 | + => ConstraintCheckerServices::getItemChecker($services), |
|
| 201 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
| 202 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
| 203 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
| 204 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
| 205 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
| 206 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
| 207 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
| 208 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
| 209 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
| 210 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
| 211 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
| 212 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
| 213 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
| 214 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
| 215 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
| 216 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
| 217 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
| 218 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
| 219 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
| 220 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
| 221 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
| 222 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
| 223 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
| 224 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
| 225 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
| 226 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
| 227 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
| 228 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
| 229 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
| 230 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
| 231 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
| 232 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
| 233 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
| 234 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
| 235 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
| 236 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
| 237 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
| 238 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
| 239 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
| 240 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
| 241 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
| 242 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
| 243 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
| 244 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
| 245 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
| 246 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
| 247 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
| 248 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
| 249 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
| 250 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
| 251 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
| 252 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
| 253 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
| 254 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
| 255 | + $config->get('WBQualityConstraintsLexemeLanguageConstraintId') |
|
| 256 | + => ConstraintCheckerServices::getLexemeLanguageChecker($services), |
|
| 257 | + $config->get('WBQualityConstraintsLabelInLanguageConstraintId') |
|
| 258 | + => ConstraintCheckerServices::getLabelInLanguageChecker($services), |
|
| 259 | 259 | ]; |
| 260 | 260 | |
| 261 | 261 | return new DelegatingConstraintChecker( |
| 262 | - WikibaseServices::getEntityLookup( $services ), |
|
| 262 | + WikibaseServices::getEntityLookup($services), |
|
| 263 | 263 | $checkerMap, |
| 264 | - ConstraintsServices::getConstraintLookup( $services ), |
|
| 265 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
| 264 | + ConstraintsServices::getConstraintLookup($services), |
|
| 265 | + ConstraintsServices::getConstraintParameterParser($services), |
|
| 266 | 266 | $statementGuidParser, |
| 267 | - ConstraintsServices::getLoggingHelper( $services ), |
|
| 268 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
| 269 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
| 270 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
| 267 | + ConstraintsServices::getLoggingHelper($services), |
|
| 268 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
| 269 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
| 270 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
| 271 | 271 | ); |
| 272 | 272 | }, |
| 273 | 273 | |
| 274 | - ConstraintsServices::RESULTS_SOURCE => static function ( MediaWikiServices $services ): ResultsSource { |
|
| 274 | + ConstraintsServices::RESULTS_SOURCE => static function(MediaWikiServices $services): ResultsSource { |
|
| 275 | 275 | $config = $services->getMainConfig(); |
| 276 | 276 | $resultsSource = new CheckingResultsSource( |
| 277 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
| 277 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
| 278 | 278 | ); |
| 279 | 279 | |
| 280 | 280 | $cacheCheckConstraintsResults = false; |
| 281 | 281 | |
| 282 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
| 282 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
| 283 | 283 | $cacheCheckConstraintsResults = true; |
| 284 | 284 | // check that we can use getLocalRepoWikiPageMetaDataAccessor() |
| 285 | 285 | // TODO we should always be able to cache constraint check results (T244726) |
| 286 | - $entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources(); |
|
| 287 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
| 286 | + $entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources(); |
|
| 287 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
| 288 | 288 | |
| 289 | - foreach ( $entitySources as $entitySource ) { |
|
| 290 | - if ( $entitySource->getSourceName() !== $localEntitySourceName ) { |
|
| 291 | - ConstraintsServices::getLogger( $services )->warning( |
|
| 292 | - 'Cannot cache constraint check results for non-local source: ' . |
|
| 289 | + foreach ($entitySources as $entitySource) { |
|
| 290 | + if ($entitySource->getSourceName() !== $localEntitySourceName) { |
|
| 291 | + ConstraintsServices::getLogger($services)->warning( |
|
| 292 | + 'Cannot cache constraint check results for non-local source: '. |
|
| 293 | 293 | $entitySource->getSourceName() |
| 294 | 294 | ); |
| 295 | 295 | $cacheCheckConstraintsResults = false; |
@@ -298,42 +298,42 @@ discard block |
||
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( $cacheCheckConstraintsResults ) { |
|
| 301 | + if ($cacheCheckConstraintsResults) { |
|
| 302 | 302 | $possiblyStaleConstraintTypes = [ |
| 303 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
| 304 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
| 305 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
| 306 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
| 303 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
| 304 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
| 305 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
| 306 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
| 307 | 307 | ]; |
| 308 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
| 308 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
| 309 | 309 | $wikiPageEntityMetaDataAccessor = WikibaseRepo::getLocalRepoWikiPageMetaDataAccessor( |
| 310 | 310 | $services ); |
| 311 | 311 | |
| 312 | 312 | $resultsSource = new CachingResultsSource( |
| 313 | 313 | $resultsSource, |
| 314 | 314 | ResultsCache::getDefaultInstance(), |
| 315 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
| 316 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
| 315 | + ConstraintsServices::getCheckResultSerializer($services), |
|
| 316 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
| 317 | 317 | $wikiPageEntityMetaDataAccessor, |
| 318 | 318 | $entityIdParser, |
| 319 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
| 319 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
| 320 | 320 | $possiblyStaleConstraintTypes, |
| 321 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
| 322 | - ConstraintsServices::getLoggingHelper( $services ) |
|
| 321 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
| 322 | + ConstraintsServices::getLoggingHelper($services) |
|
| 323 | 323 | ); |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | return $resultsSource; |
| 327 | 327 | }, |
| 328 | 328 | |
| 329 | - ConstraintsServices::VIOLATION_MESSAGE_RENDERER_FACTORY => static function ( |
|
| 329 | + ConstraintsServices::VIOLATION_MESSAGE_RENDERER_FACTORY => static function( |
|
| 330 | 330 | MediaWikiServices $services |
| 331 | 331 | ): ViolationMessageRendererFactory { |
| 332 | 332 | return new ViolationMessageRendererFactory( |
| 333 | 333 | $services->getMainConfig(), |
| 334 | 334 | $services->getLanguageNameUtils(), |
| 335 | - WikibaseRepo::getEntityIdHtmlLinkFormatterFactory( $services ), |
|
| 336 | - WikibaseRepo::getValueFormatterFactory( $services ) |
|
| 335 | + WikibaseRepo::getEntityIdHtmlLinkFormatterFactory($services), |
|
| 336 | + WikibaseRepo::getValueFormatterFactory($services) |
|
| 337 | 337 | ); |
| 338 | 338 | }, |
| 339 | 339 | ]; |