@@ -19,26 +19,26 @@ discard block |
||
19 | 19 | */ |
20 | 20 | class ViolationMessageSerializer implements Serializer { |
21 | 21 | |
22 | - private function abbreviateViolationMessageKey( $fullMessageKey ) { |
|
23 | - return substr( $fullMessageKey, strlen( ViolationMessage::MESSAGE_KEY_PREFIX ) ); |
|
22 | + private function abbreviateViolationMessageKey($fullMessageKey) { |
|
23 | + return substr($fullMessageKey, strlen(ViolationMessage::MESSAGE_KEY_PREFIX)); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @param ViolationMessage $object |
28 | 28 | * @return array |
29 | 29 | */ |
30 | - public function serialize( $object ) { |
|
30 | + public function serialize($object) { |
|
31 | 31 | /** @var ViolationMessage $object */ |
32 | - Assert::parameterType( ViolationMessage::class, $object, '$object' ); |
|
32 | + Assert::parameterType(ViolationMessage::class, $object, '$object'); |
|
33 | 33 | |
34 | 34 | $arguments = $object->getArguments(); |
35 | 35 | $serializedArguments = []; |
36 | - foreach ( $arguments as $argument ) { |
|
37 | - $serializedArguments[] = $this->serializeArgument( $argument ); |
|
36 | + foreach ($arguments as $argument) { |
|
37 | + $serializedArguments[] = $this->serializeArgument($argument); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | return [ |
41 | - 'k' => $this->abbreviateViolationMessageKey( $object->getMessageKey() ), |
|
41 | + 'k' => $this->abbreviateViolationMessageKey($object->getMessageKey()), |
|
42 | 42 | 'a' => $serializedArguments, |
43 | 43 | ]; |
44 | 44 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param array $argument element of ViolationMessage::getArguments() |
48 | 48 | * @return array [ 't' => ViolationMessage::TYPE_*, 'v' => serialized value, 'r' => $role ] |
49 | 49 | */ |
50 | - private function serializeArgument( array $argument ) { |
|
50 | + private function serializeArgument(array $argument) { |
|
51 | 51 | $methods = [ |
52 | 52 | ViolationMessage::TYPE_ENTITY_ID => 'serializeEntityId', |
53 | 53 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'serializeEntityIdList', |
@@ -69,12 +69,12 @@ discard block |
||
69 | 69 | $value = $argument['value']; |
70 | 70 | $role = $argument['role']; |
71 | 71 | |
72 | - if ( array_key_exists( $type, $methods ) ) { |
|
72 | + if (array_key_exists($type, $methods)) { |
|
73 | 73 | $method = $methods[$type]; |
74 | - $serializedValue = $this->$method( $value ); |
|
74 | + $serializedValue = $this->$method($value); |
|
75 | 75 | } else { |
76 | 76 | throw new InvalidArgumentException( |
77 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
77 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
78 | 78 | ); |
79 | 79 | } |
80 | 80 | |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | * @param string $string any value that shall simply be serialized to itself |
92 | 92 | * @return string that same value, unchanged |
93 | 93 | */ |
94 | - private function serializeStringByIdentity( $string ) { |
|
95 | - Assert::parameterType( 'string', $string, '$string' ); |
|
94 | + private function serializeStringByIdentity($string) { |
|
95 | + Assert::parameterType('string', $string, '$string'); |
|
96 | 96 | return $string; |
97 | 97 | } |
98 | 98 | |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | * @param string[] $strings |
101 | 101 | * @return string[] |
102 | 102 | */ |
103 | - private function serializeStringListByIdentity( $strings ) { |
|
104 | - Assert::parameterElementType( 'string', $strings, '$strings' ); |
|
103 | + private function serializeStringListByIdentity($strings) { |
|
104 | + Assert::parameterElementType('string', $strings, '$strings'); |
|
105 | 105 | return $strings; |
106 | 106 | } |
107 | 107 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param EntityId $entityId |
110 | 110 | * @return string entity ID serialization |
111 | 111 | */ |
112 | - private function serializeEntityId( EntityId $entityId ) { |
|
112 | + private function serializeEntityId(EntityId $entityId) { |
|
113 | 113 | return $entityId->getSerialization(); |
114 | 114 | } |
115 | 115 | |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * @param EntityId[] $entityIdList |
118 | 118 | * @return string[] entity ID serializations |
119 | 119 | */ |
120 | - private function serializeEntityIdList( array $entityIdList ) { |
|
121 | - return array_map( [ $this, 'serializeEntityId' ], $entityIdList ); |
|
120 | + private function serializeEntityIdList(array $entityIdList) { |
|
121 | + return array_map([$this, 'serializeEntityId'], $entityIdList); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | * @return string entity ID serialization, '::somevalue', or '::novalue' |
127 | 127 | * (according to EntityId::PATTERN, entity ID serializations can never begin with two colons) |
128 | 128 | */ |
129 | - private function serializeItemIdSnakValue( ItemIdSnakValue $value ) { |
|
130 | - switch ( true ) { |
|
129 | + private function serializeItemIdSnakValue(ItemIdSnakValue $value) { |
|
130 | + switch (true) { |
|
131 | 131 | case $value->isValue(): |
132 | - return $this->serializeEntityId( $value->getItemId() ); |
|
132 | + return $this->serializeEntityId($value->getItemId()); |
|
133 | 133 | case $value->isSomeValue(): |
134 | 134 | return '::somevalue'; |
135 | 135 | case $value->isNoValue(): |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | * @param ItemIdSnakValue[] $valueList |
148 | 148 | * @return string[] array of entity ID serializations, '::somevalue's or '::novalue's |
149 | 149 | */ |
150 | - private function serializeItemIdSnakValueList( array $valueList ) { |
|
151 | - return array_map( [ $this, 'serializeItemIdSnakValue' ], $valueList ); |
|
150 | + private function serializeItemIdSnakValueList(array $valueList) { |
|
151 | + return array_map([$this, 'serializeItemIdSnakValue'], $valueList); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
155 | 155 | * @param DataValue $dataValue |
156 | 156 | * @return array the data value in array form |
157 | 157 | */ |
158 | - private function serializeDataValue( DataValue $dataValue ) { |
|
158 | + private function serializeDataValue(DataValue $dataValue) { |
|
159 | 159 | return $dataValue->toArray(); |
160 | 160 | } |
161 | 161 | |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | * @param string $contextType one of the Context::TYPE_* constants |
164 | 164 | * @return string the abbreviated context type |
165 | 165 | */ |
166 | - private function serializeContextType( $contextType ) { |
|
167 | - switch ( $contextType ) { |
|
166 | + private function serializeContextType($contextType) { |
|
167 | + switch ($contextType) { |
|
168 | 168 | case Context::TYPE_STATEMENT: |
169 | 169 | return 's'; |
170 | 170 | case Context::TYPE_QUALIFIER: |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | default: |
175 | 175 | // @codeCoverageIgnoreStart |
176 | 176 | throw new LogicException( |
177 | - 'Unknown context type ' . $contextType |
|
177 | + 'Unknown context type '.$contextType |
|
178 | 178 | ); |
179 | 179 | // @codeCoverageIgnoreEnd |
180 | 180 | } |
@@ -184,15 +184,15 @@ discard block |
||
184 | 184 | * @param string[] $contextTypeList Context::TYPE_* constants |
185 | 185 | * @return string[] abbreviated context types |
186 | 186 | */ |
187 | - private function serializeContextTypeList( array $contextTypeList ) { |
|
188 | - return array_map( [ $this, 'serializeContextType' ], $contextTypeList ); |
|
187 | + private function serializeContextTypeList(array $contextTypeList) { |
|
188 | + return array_map([$this, 'serializeContextType'], $contextTypeList); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | 192 | * @param MultilingualTextValue $text |
193 | 193 | * @return mixed {@see MultilingualTextValue::getArrayValue} |
194 | 194 | */ |
195 | - private function serializeMultilingualText( MultilingualTextValue $text ) { |
|
195 | + private function serializeMultilingualText(MultilingualTextValue $text) { |
|
196 | 196 | return $text->getArrayValue(); |
197 | 197 | } |
198 | 198 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | private $constraintParameterParser; |
24 | 24 | |
25 | - public function __construct( ConstraintParameterParser $constraintParameterParser ) { |
|
25 | + public function __construct(ConstraintParameterParser $constraintParameterParser) { |
|
26 | 26 | $this->constraintParameterParser = $constraintParameterParser; |
27 | 27 | } |
28 | 28 | |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | * @throws ConstraintParameterException |
69 | 69 | * @return CheckResult |
70 | 70 | */ |
71 | - public function checkConstraint( Context $context, Constraint $constraint ): CheckResult { |
|
72 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
73 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
71 | + public function checkConstraint(Context $context, Constraint $constraint): CheckResult { |
|
72 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
73 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $parameters = []; |
@@ -83,26 +83,26 @@ discard block |
||
83 | 83 | $parameters['language'] = $languages; |
84 | 84 | |
85 | 85 | $status = CheckResult::STATUS_VIOLATION; |
86 | - $message = ( new ViolationMessage( 'wbqc-violation-message-label-lacking' ) ) |
|
87 | - ->withEntityId( $context->getSnak()->getPropertyId(), Role::PREDICATE ) |
|
88 | - ->withLanguages( $languages ); |
|
86 | + $message = (new ViolationMessage('wbqc-violation-message-label-lacking')) |
|
87 | + ->withEntityId($context->getSnak()->getPropertyId(), Role::PREDICATE) |
|
88 | + ->withLanguages($languages); |
|
89 | 89 | |
90 | 90 | /** @var LabelsProvider $entity */ |
91 | 91 | $entity = $context->getEntity(); |
92 | 92 | '@phan-var LabelsProvider $entity'; |
93 | 93 | |
94 | - foreach ( $languages as $language ) { |
|
95 | - if ( $entity->getLabels()->hasTermForLanguage( $language ) ) { |
|
94 | + foreach ($languages as $language) { |
|
95 | + if ($entity->getLabels()->hasTermForLanguage($language)) { |
|
96 | 96 | $message = null; |
97 | 97 | $status = CheckResult::STATUS_COMPLIANCE; |
98 | 98 | break; |
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | - return new CheckResult( $context, $constraint, $parameters, $status, $message ); |
|
102 | + return new CheckResult($context, $constraint, $parameters, $status, $message); |
|
103 | 103 | } |
104 | 104 | |
105 | - public function checkConstraintParameters( Constraint $constraint ): array { |
|
105 | + public function checkConstraintParameters(Constraint $constraint): array { |
|
106 | 106 | $constraintParameters = $constraint->getConstraintParameters(); |
107 | 107 | $exceptions = []; |
108 | 108 | try { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | $constraintParameters, |
111 | 111 | $constraint->getConstraintTypeItemId() |
112 | 112 | ); |
113 | - } catch ( ConstraintParameterException $e ) { |
|
113 | + } catch (ConstraintParameterException $e) { |
|
114 | 114 | $exceptions[] = $e; |
115 | 115 | } |
116 | 116 | return $exceptions; |
@@ -72,7 +72,7 @@ |
||
72 | 72 | * @return never |
73 | 73 | */ |
74 | 74 | private function __construct() { |
75 | - throw new LogicException( 'This class should never be instantiated.' ); |
|
75 | + throw new LogicException('This class should never be instantiated.'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | } |
@@ -29,46 +29,46 @@ discard block |
||
29 | 29 | use WikiMap; |
30 | 30 | |
31 | 31 | return [ |
32 | - ConstraintsServices::EXPIRY_LOCK => static function ( MediaWikiServices $services ) { |
|
33 | - return new ExpiryLock( ObjectCache::getInstance( CACHE_ANYTHING ) ); |
|
32 | + ConstraintsServices::EXPIRY_LOCK => static function(MediaWikiServices $services) { |
|
33 | + return new ExpiryLock(ObjectCache::getInstance(CACHE_ANYTHING)); |
|
34 | 34 | }, |
35 | 35 | |
36 | - ConstraintsServices::LOGGING_HELPER => static function ( MediaWikiServices $services ) { |
|
36 | + ConstraintsServices::LOGGING_HELPER => static function(MediaWikiServices $services) { |
|
37 | 37 | return new LoggingHelper( |
38 | 38 | $services->getStatsdDataFactory(), |
39 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' ), |
|
39 | + LoggerFactory::getInstance('WikibaseQualityConstraints'), |
|
40 | 40 | $services->getMainConfig() |
41 | 41 | ); |
42 | 42 | }, |
43 | 43 | |
44 | - ConstraintsServices::CONSTRAINT_STORE => static function ( MediaWikiServices $services ) { |
|
45 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
46 | - $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE ); |
|
44 | + ConstraintsServices::CONSTRAINT_STORE => static function(MediaWikiServices $services) { |
|
45 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
46 | + $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE); |
|
47 | 47 | $dbName = $propertySource->getDatabaseName(); |
48 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
48 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
49 | 49 | |
50 | - if ( $propertySource->getSourceName() !== $localEntitySourceName ) { |
|
51 | - throw new \RuntimeException( 'Can\'t get a ConstraintStore for a non local entity source.' ); |
|
50 | + if ($propertySource->getSourceName() !== $localEntitySourceName) { |
|
51 | + throw new \RuntimeException('Can\'t get a ConstraintStore for a non local entity source.'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | return new ConstraintRepositoryStore( |
55 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
55 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
56 | 56 | $dbName |
57 | 57 | ); |
58 | 58 | }, |
59 | 59 | |
60 | - ConstraintsServices::CONSTRAINT_LOOKUP => static function ( MediaWikiServices $services ) { |
|
61 | - $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
62 | - $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType( Property::ENTITY_TYPE ); |
|
60 | + ConstraintsServices::CONSTRAINT_LOOKUP => static function(MediaWikiServices $services) { |
|
61 | + $sourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
62 | + $propertySource = $sourceDefinitions->getDatabaseSourceForEntityType(Property::ENTITY_TYPE); |
|
63 | 63 | $dbName = $propertySource->getDatabaseName(); |
64 | 64 | $rawLookup = new ConstraintRepositoryLookup( |
65 | - $services->getDBLoadBalancerFactory()->getMainLB( $dbName ), |
|
65 | + $services->getDBLoadBalancerFactory()->getMainLB($dbName), |
|
66 | 66 | $dbName |
67 | 67 | ); |
68 | - return new CachingConstraintLookup( $rawLookup ); |
|
68 | + return new CachingConstraintLookup($rawLookup); |
|
69 | 69 | }, |
70 | 70 | |
71 | - ConstraintsServices::CHECK_RESULT_SERIALIZER => static function ( MediaWikiServices $services ) { |
|
71 | + ConstraintsServices::CHECK_RESULT_SERIALIZER => static function(MediaWikiServices $services) { |
|
72 | 72 | return new CheckResultSerializer( |
73 | 73 | new ConstraintSerializer( |
74 | 74 | false // constraint parameters are not exposed |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | ); |
80 | 80 | }, |
81 | 81 | |
82 | - ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function ( MediaWikiServices $services ) { |
|
83 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
84 | - $dataValueFactory = WikibaseRepo::getDataValueFactory( $services ); |
|
82 | + ConstraintsServices::CHECK_RESULT_DESERIALIZER => static function(MediaWikiServices $services) { |
|
83 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
84 | + $dataValueFactory = WikibaseRepo::getDataValueFactory($services); |
|
85 | 85 | |
86 | 86 | return new CheckResultDeserializer( |
87 | 87 | new ConstraintDeserializer(), |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | ); |
95 | 95 | }, |
96 | 96 | |
97 | - ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function ( MediaWikiServices $services ) { |
|
97 | + ConstraintsServices::VIOLATION_MESSAGE_SERIALIZER => static function(MediaWikiServices $services) { |
|
98 | 98 | return new ViolationMessageSerializer(); |
99 | 99 | }, |
100 | 100 | |
101 | - ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function ( MediaWikiServices $services ) { |
|
102 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
103 | - $dataValueFactory = WikibaseRepo::getDataValueFactory( $services ); |
|
101 | + ConstraintsServices::VIOLATION_MESSAGE_DESERIALIZER => static function(MediaWikiServices $services) { |
|
102 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
103 | + $dataValueFactory = WikibaseRepo::getDataValueFactory($services); |
|
104 | 104 | |
105 | 105 | return new ViolationMessageDeserializer( |
106 | 106 | $entityIdParser, |
@@ -108,37 +108,37 @@ discard block |
||
108 | 108 | ); |
109 | 109 | }, |
110 | 110 | |
111 | - ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function ( MediaWikiServices $services ) { |
|
112 | - $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory( $services ); |
|
113 | - $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions( $services ); |
|
111 | + ConstraintsServices::CONSTRAINT_PARAMETER_PARSER => static function(MediaWikiServices $services) { |
|
112 | + $deserializerFactory = WikibaseRepo::getBaseDataModelDeserializerFactory($services); |
|
113 | + $entitySourceDefinitions = WikibaseRepo::getEntitySourceDefinitions($services); |
|
114 | 114 | |
115 | 115 | return new ConstraintParameterParser( |
116 | 116 | $services->getMainConfig(), |
117 | 117 | $deserializerFactory, |
118 | - $entitySourceDefinitions->getDatabaseSourceForEntityType( 'item' )->getConceptBaseUri() |
|
118 | + $entitySourceDefinitions->getDatabaseSourceForEntityType('item')->getConceptBaseUri() |
|
119 | 119 | ); |
120 | 120 | }, |
121 | 121 | |
122 | - ConstraintsServices::CONNECTION_CHECKER_HELPER => static function ( MediaWikiServices $services ) { |
|
122 | + ConstraintsServices::CONNECTION_CHECKER_HELPER => static function(MediaWikiServices $services) { |
|
123 | 123 | return new ConnectionCheckerHelper(); |
124 | 124 | }, |
125 | 125 | |
126 | - ConstraintsServices::RANGE_CHECKER_HELPER => static function ( MediaWikiServices $services ) { |
|
126 | + ConstraintsServices::RANGE_CHECKER_HELPER => static function(MediaWikiServices $services) { |
|
127 | 127 | return new RangeCheckerHelper( |
128 | 128 | $services->getMainConfig(), |
129 | - WikibaseRepo::getUnitConverter( $services ) |
|
129 | + WikibaseRepo::getUnitConverter($services) |
|
130 | 130 | ); |
131 | 131 | }, |
132 | 132 | |
133 | - ConstraintsServices::SPARQL_HELPER => static function ( MediaWikiServices $services ) { |
|
134 | - $endpoint = $services->getMainConfig()->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
135 | - if ( $endpoint === '' ) { |
|
133 | + ConstraintsServices::SPARQL_HELPER => static function(MediaWikiServices $services) { |
|
134 | + $endpoint = $services->getMainConfig()->get('WBQualityConstraintsSparqlEndpoint'); |
|
135 | + if ($endpoint === '') { |
|
136 | 136 | return new DummySparqlHelper(); |
137 | 137 | } |
138 | 138 | |
139 | - $rdfVocabulary = WikibaseRepo::getRdfVocabulary( $services ); |
|
140 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
141 | - $propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup( $services ); |
|
139 | + $rdfVocabulary = WikibaseRepo::getRdfVocabulary($services); |
|
140 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
141 | + $propertyDataTypeLookup = WikibaseRepo::getPropertyDataTypeLookup($services); |
|
142 | 142 | |
143 | 143 | return new SparqlHelper( |
144 | 144 | $services->getMainConfig(), |
@@ -146,126 +146,126 @@ discard block |
||
146 | 146 | $entityIdParser, |
147 | 147 | $propertyDataTypeLookup, |
148 | 148 | $services->getMainWANObjectCache(), |
149 | - ConstraintsServices::getViolationMessageSerializer( $services ), |
|
150 | - ConstraintsServices::getViolationMessageDeserializer( $services ), |
|
149 | + ConstraintsServices::getViolationMessageSerializer($services), |
|
150 | + ConstraintsServices::getViolationMessageDeserializer($services), |
|
151 | 151 | $services->getStatsdDataFactory(), |
152 | - ConstraintsServices::getExpiryLock( $services ), |
|
153 | - ConstraintsServices::getLoggingHelper( $services ), |
|
154 | - WikiMap::getCurrentWikiId() . ' WikibaseQualityConstraints ' . Http::userAgent(), |
|
152 | + ConstraintsServices::getExpiryLock($services), |
|
153 | + ConstraintsServices::getLoggingHelper($services), |
|
154 | + WikiMap::getCurrentWikiId().' WikibaseQualityConstraints '.Http::userAgent(), |
|
155 | 155 | $services->getHttpRequestFactory() |
156 | 156 | ); |
157 | 157 | }, |
158 | 158 | |
159 | - ConstraintsServices::TYPE_CHECKER_HELPER => static function ( MediaWikiServices $services ) { |
|
159 | + ConstraintsServices::TYPE_CHECKER_HELPER => static function(MediaWikiServices $services) { |
|
160 | 160 | return new TypeCheckerHelper( |
161 | - WikibaseServices::getEntityLookup( $services ), |
|
161 | + WikibaseServices::getEntityLookup($services), |
|
162 | 162 | $services->getMainConfig(), |
163 | - ConstraintsServices::getSparqlHelper( $services ), |
|
163 | + ConstraintsServices::getSparqlHelper($services), |
|
164 | 164 | $services->getStatsdDataFactory() |
165 | 165 | ); |
166 | 166 | }, |
167 | 167 | |
168 | - ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function ( MediaWikiServices $services ) { |
|
169 | - $statementGuidParser = WikibaseRepo::getStatementGuidParser( $services ); |
|
168 | + ConstraintsServices::DELEGATING_CONSTRAINT_CHECKER => static function(MediaWikiServices $services) { |
|
169 | + $statementGuidParser = WikibaseRepo::getStatementGuidParser($services); |
|
170 | 170 | |
171 | 171 | $config = $services->getMainConfig(); |
172 | 172 | $checkerMap = [ |
173 | - $config->get( 'WBQualityConstraintsConflictsWithConstraintId' ) |
|
174 | - => ConstraintCheckerServices::getConflictsWithChecker( $services ), |
|
175 | - $config->get( 'WBQualityConstraintsItemRequiresClaimConstraintId' ) |
|
176 | - => ConstraintCheckerServices::getItemChecker( $services ), |
|
177 | - $config->get( 'WBQualityConstraintsValueRequiresClaimConstraintId' ) |
|
178 | - => ConstraintCheckerServices::getTargetRequiredClaimChecker( $services ), |
|
179 | - $config->get( 'WBQualityConstraintsSymmetricConstraintId' ) |
|
180 | - => ConstraintCheckerServices::getSymmetricChecker( $services ), |
|
181 | - $config->get( 'WBQualityConstraintsInverseConstraintId' ) |
|
182 | - => ConstraintCheckerServices::getInverseChecker( $services ), |
|
183 | - $config->get( 'WBQualityConstraintsUsedAsQualifierConstraintId' ) |
|
184 | - => ConstraintCheckerServices::getQualifierChecker( $services ), |
|
185 | - $config->get( 'WBQualityConstraintsAllowedQualifiersConstraintId' ) |
|
186 | - => ConstraintCheckerServices::getQualifiersChecker( $services ), |
|
187 | - $config->get( 'WBQualityConstraintsMandatoryQualifierConstraintId' ) |
|
188 | - => ConstraintCheckerServices::getMandatoryQualifiersChecker( $services ), |
|
189 | - $config->get( 'WBQualityConstraintsRangeConstraintId' ) |
|
190 | - => ConstraintCheckerServices::getRangeChecker( $services ), |
|
191 | - $config->get( 'WBQualityConstraintsDifferenceWithinRangeConstraintId' ) |
|
192 | - => ConstraintCheckerServices::getDiffWithinRangeChecker( $services ), |
|
193 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ) |
|
194 | - => ConstraintCheckerServices::getTypeChecker( $services ), |
|
195 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ) |
|
196 | - => ConstraintCheckerServices::getValueTypeChecker( $services ), |
|
197 | - $config->get( 'WBQualityConstraintsSingleValueConstraintId' ) |
|
198 | - => ConstraintCheckerServices::getSingleValueChecker( $services ), |
|
199 | - $config->get( 'WBQualityConstraintsMultiValueConstraintId' ) |
|
200 | - => ConstraintCheckerServices::getMultiValueChecker( $services ), |
|
201 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ) |
|
202 | - => ConstraintCheckerServices::getUniqueValueChecker( $services ), |
|
203 | - $config->get( 'WBQualityConstraintsFormatConstraintId' ) |
|
204 | - => ConstraintCheckerServices::getFormatChecker( $services ), |
|
205 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ) |
|
206 | - => ConstraintCheckerServices::getCommonsLinkChecker( $services ), |
|
207 | - $config->get( 'WBQualityConstraintsOneOfConstraintId' ) |
|
208 | - => ConstraintCheckerServices::getOneOfChecker( $services ), |
|
209 | - $config->get( 'WBQualityConstraintsUsedForValuesOnlyConstraintId' ) |
|
210 | - => ConstraintCheckerServices::getValueOnlyChecker( $services ), |
|
211 | - $config->get( 'WBQualityConstraintsUsedAsReferenceConstraintId' ) |
|
212 | - => ConstraintCheckerServices::getReferenceChecker( $services ), |
|
213 | - $config->get( 'WBQualityConstraintsNoBoundsConstraintId' ) |
|
214 | - => ConstraintCheckerServices::getNoBoundsChecker( $services ), |
|
215 | - $config->get( 'WBQualityConstraintsAllowedUnitsConstraintId' ) |
|
216 | - => ConstraintCheckerServices::getAllowedUnitsChecker( $services ), |
|
217 | - $config->get( 'WBQualityConstraintsSingleBestValueConstraintId' ) |
|
218 | - => ConstraintCheckerServices::getSingleBestValueChecker( $services ), |
|
219 | - $config->get( 'WBQualityConstraintsAllowedEntityTypesConstraintId' ) |
|
220 | - => ConstraintCheckerServices::getEntityTypeChecker( $services ), |
|
221 | - $config->get( 'WBQualityConstraintsNoneOfConstraintId' ) |
|
222 | - => ConstraintCheckerServices::getNoneOfChecker( $services ), |
|
223 | - $config->get( 'WBQualityConstraintsIntegerConstraintId' ) |
|
224 | - => ConstraintCheckerServices::getIntegerChecker( $services ), |
|
225 | - $config->get( 'WBQualityConstraintsCitationNeededConstraintId' ) |
|
226 | - => ConstraintCheckerServices::getCitationNeededChecker( $services ), |
|
227 | - $config->get( 'WBQualityConstraintsPropertyScopeConstraintId' ) |
|
228 | - => ConstraintCheckerServices::getPropertyScopeChecker( $services ), |
|
229 | - $config->get( 'WBQualityConstraintsContemporaryConstraintId' ) |
|
230 | - => ConstraintCheckerServices::getContemporaryChecker( $services ), |
|
231 | - $config->get( 'WBQualityConstraintsLexemeLanguageConstraintId' ) |
|
232 | - => ConstraintCheckerServices::getLexemeLanguageChecker( $services ), |
|
233 | - $config->get( 'WBQualityConstraintsLabelInLanguageConstraintId' ) |
|
234 | - => ConstraintCheckerServices::getLabelInLanguageChecker( $services ), |
|
173 | + $config->get('WBQualityConstraintsConflictsWithConstraintId') |
|
174 | + => ConstraintCheckerServices::getConflictsWithChecker($services), |
|
175 | + $config->get('WBQualityConstraintsItemRequiresClaimConstraintId') |
|
176 | + => ConstraintCheckerServices::getItemChecker($services), |
|
177 | + $config->get('WBQualityConstraintsValueRequiresClaimConstraintId') |
|
178 | + => ConstraintCheckerServices::getTargetRequiredClaimChecker($services), |
|
179 | + $config->get('WBQualityConstraintsSymmetricConstraintId') |
|
180 | + => ConstraintCheckerServices::getSymmetricChecker($services), |
|
181 | + $config->get('WBQualityConstraintsInverseConstraintId') |
|
182 | + => ConstraintCheckerServices::getInverseChecker($services), |
|
183 | + $config->get('WBQualityConstraintsUsedAsQualifierConstraintId') |
|
184 | + => ConstraintCheckerServices::getQualifierChecker($services), |
|
185 | + $config->get('WBQualityConstraintsAllowedQualifiersConstraintId') |
|
186 | + => ConstraintCheckerServices::getQualifiersChecker($services), |
|
187 | + $config->get('WBQualityConstraintsMandatoryQualifierConstraintId') |
|
188 | + => ConstraintCheckerServices::getMandatoryQualifiersChecker($services), |
|
189 | + $config->get('WBQualityConstraintsRangeConstraintId') |
|
190 | + => ConstraintCheckerServices::getRangeChecker($services), |
|
191 | + $config->get('WBQualityConstraintsDifferenceWithinRangeConstraintId') |
|
192 | + => ConstraintCheckerServices::getDiffWithinRangeChecker($services), |
|
193 | + $config->get('WBQualityConstraintsTypeConstraintId') |
|
194 | + => ConstraintCheckerServices::getTypeChecker($services), |
|
195 | + $config->get('WBQualityConstraintsValueTypeConstraintId') |
|
196 | + => ConstraintCheckerServices::getValueTypeChecker($services), |
|
197 | + $config->get('WBQualityConstraintsSingleValueConstraintId') |
|
198 | + => ConstraintCheckerServices::getSingleValueChecker($services), |
|
199 | + $config->get('WBQualityConstraintsMultiValueConstraintId') |
|
200 | + => ConstraintCheckerServices::getMultiValueChecker($services), |
|
201 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId') |
|
202 | + => ConstraintCheckerServices::getUniqueValueChecker($services), |
|
203 | + $config->get('WBQualityConstraintsFormatConstraintId') |
|
204 | + => ConstraintCheckerServices::getFormatChecker($services), |
|
205 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId') |
|
206 | + => ConstraintCheckerServices::getCommonsLinkChecker($services), |
|
207 | + $config->get('WBQualityConstraintsOneOfConstraintId') |
|
208 | + => ConstraintCheckerServices::getOneOfChecker($services), |
|
209 | + $config->get('WBQualityConstraintsUsedForValuesOnlyConstraintId') |
|
210 | + => ConstraintCheckerServices::getValueOnlyChecker($services), |
|
211 | + $config->get('WBQualityConstraintsUsedAsReferenceConstraintId') |
|
212 | + => ConstraintCheckerServices::getReferenceChecker($services), |
|
213 | + $config->get('WBQualityConstraintsNoBoundsConstraintId') |
|
214 | + => ConstraintCheckerServices::getNoBoundsChecker($services), |
|
215 | + $config->get('WBQualityConstraintsAllowedUnitsConstraintId') |
|
216 | + => ConstraintCheckerServices::getAllowedUnitsChecker($services), |
|
217 | + $config->get('WBQualityConstraintsSingleBestValueConstraintId') |
|
218 | + => ConstraintCheckerServices::getSingleBestValueChecker($services), |
|
219 | + $config->get('WBQualityConstraintsAllowedEntityTypesConstraintId') |
|
220 | + => ConstraintCheckerServices::getEntityTypeChecker($services), |
|
221 | + $config->get('WBQualityConstraintsNoneOfConstraintId') |
|
222 | + => ConstraintCheckerServices::getNoneOfChecker($services), |
|
223 | + $config->get('WBQualityConstraintsIntegerConstraintId') |
|
224 | + => ConstraintCheckerServices::getIntegerChecker($services), |
|
225 | + $config->get('WBQualityConstraintsCitationNeededConstraintId') |
|
226 | + => ConstraintCheckerServices::getCitationNeededChecker($services), |
|
227 | + $config->get('WBQualityConstraintsPropertyScopeConstraintId') |
|
228 | + => ConstraintCheckerServices::getPropertyScopeChecker($services), |
|
229 | + $config->get('WBQualityConstraintsContemporaryConstraintId') |
|
230 | + => ConstraintCheckerServices::getContemporaryChecker($services), |
|
231 | + $config->get('WBQualityConstraintsLexemeLanguageConstraintId') |
|
232 | + => ConstraintCheckerServices::getLexemeLanguageChecker($services), |
|
233 | + $config->get('WBQualityConstraintsLabelInLanguageConstraintId') |
|
234 | + => ConstraintCheckerServices::getLabelInLanguageChecker($services), |
|
235 | 235 | ]; |
236 | 236 | |
237 | 237 | return new DelegatingConstraintChecker( |
238 | - WikibaseServices::getEntityLookup( $services ), |
|
238 | + WikibaseServices::getEntityLookup($services), |
|
239 | 239 | $checkerMap, |
240 | - ConstraintsServices::getConstraintLookup( $services ), |
|
241 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
240 | + ConstraintsServices::getConstraintLookup($services), |
|
241 | + ConstraintsServices::getConstraintParameterParser($services), |
|
242 | 242 | $statementGuidParser, |
243 | - ConstraintsServices::getLoggingHelper( $services ), |
|
244 | - $config->get( 'WBQualityConstraintsCheckQualifiers' ), |
|
245 | - $config->get( 'WBQualityConstraintsCheckReferences' ), |
|
246 | - $config->get( 'WBQualityConstraintsPropertiesWithViolatingQualifiers' ) |
|
243 | + ConstraintsServices::getLoggingHelper($services), |
|
244 | + $config->get('WBQualityConstraintsCheckQualifiers'), |
|
245 | + $config->get('WBQualityConstraintsCheckReferences'), |
|
246 | + $config->get('WBQualityConstraintsPropertiesWithViolatingQualifiers') |
|
247 | 247 | ); |
248 | 248 | }, |
249 | 249 | |
250 | - ConstraintsServices::RESULTS_SOURCE => static function ( MediaWikiServices $services ) { |
|
250 | + ConstraintsServices::RESULTS_SOURCE => static function(MediaWikiServices $services) { |
|
251 | 251 | $config = $services->getMainConfig(); |
252 | 252 | $resultsSource = new CheckingResultsSource( |
253 | - ConstraintsServices::getDelegatingConstraintChecker( $services ) |
|
253 | + ConstraintsServices::getDelegatingConstraintChecker($services) |
|
254 | 254 | ); |
255 | 255 | |
256 | 256 | $cacheCheckConstraintsResults = false; |
257 | 257 | |
258 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
258 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
259 | 259 | $cacheCheckConstraintsResults = true; |
260 | 260 | // check that we can use getLocalRepoWikiPageMetaDataAccessor() |
261 | 261 | // TODO we should always be able to cache constraint check results (T244726) |
262 | - $entitySources = WikibaseRepo::getEntitySourceDefinitions( $services )->getSources(); |
|
263 | - $localEntitySourceName = WikibaseRepo::getLocalEntitySource( $services )->getSourceName(); |
|
262 | + $entitySources = WikibaseRepo::getEntitySourceDefinitions($services)->getSources(); |
|
263 | + $localEntitySourceName = WikibaseRepo::getLocalEntitySource($services)->getSourceName(); |
|
264 | 264 | |
265 | - foreach ( $entitySources as $entitySource ) { |
|
266 | - if ( $entitySource->getSourceName() !== $localEntitySourceName ) { |
|
267 | - LoggerFactory::getInstance( 'WikibaseQualityConstraints' )->warning( |
|
268 | - 'Cannot cache constraint check results for non-local source: ' . |
|
265 | + foreach ($entitySources as $entitySource) { |
|
266 | + if ($entitySource->getSourceName() !== $localEntitySourceName) { |
|
267 | + LoggerFactory::getInstance('WikibaseQualityConstraints')->warning( |
|
268 | + 'Cannot cache constraint check results for non-local source: '. |
|
269 | 269 | $entitySource->getSourceName() |
270 | 270 | ); |
271 | 271 | $cacheCheckConstraintsResults = false; |
@@ -274,28 +274,28 @@ discard block |
||
274 | 274 | } |
275 | 275 | } |
276 | 276 | |
277 | - if ( $cacheCheckConstraintsResults ) { |
|
277 | + if ($cacheCheckConstraintsResults) { |
|
278 | 278 | $possiblyStaleConstraintTypes = [ |
279 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
280 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
281 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
282 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
279 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
280 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
281 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
282 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
283 | 283 | ]; |
284 | - $entityIdParser = WikibaseRepo::getEntityIdParser( $services ); |
|
284 | + $entityIdParser = WikibaseRepo::getEntityIdParser($services); |
|
285 | 285 | $wikiPageEntityMetaDataAccessor = WikibaseRepo::getLocalRepoWikiPageMetaDataAccessor( |
286 | 286 | $services ); |
287 | 287 | |
288 | 288 | $resultsSource = new CachingResultsSource( |
289 | 289 | $resultsSource, |
290 | 290 | ResultsCache::getDefaultInstance(), |
291 | - ConstraintsServices::getCheckResultSerializer( $services ), |
|
292 | - ConstraintsServices::getCheckResultDeserializer( $services ), |
|
291 | + ConstraintsServices::getCheckResultSerializer($services), |
|
292 | + ConstraintsServices::getCheckResultDeserializer($services), |
|
293 | 293 | $wikiPageEntityMetaDataAccessor, |
294 | 294 | $entityIdParser, |
295 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
295 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
296 | 296 | $possiblyStaleConstraintTypes, |
297 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds' ), |
|
298 | - ConstraintsServices::getLoggingHelper( $services ) |
|
297 | + $config->get('WBQualityConstraintsCacheCheckConstraintsMaximumRevisionIds'), |
|
298 | + ConstraintsServices::getLoggingHelper($services) |
|
299 | 299 | ); |
300 | 300 | } |
301 | 301 |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | use WikiMap; |
19 | 19 | |
20 | 20 | // @codeCoverageIgnoreStart |
21 | -$basePath = getenv( "MW_INSTALL_PATH" ) !== false |
|
22 | - ? getenv( "MW_INSTALL_PATH" ) : __DIR__ . "/../../.."; |
|
21 | +$basePath = getenv("MW_INSTALL_PATH") !== false |
|
22 | + ? getenv("MW_INSTALL_PATH") : __DIR__."/../../.."; |
|
23 | 23 | |
24 | -require_once $basePath . "/maintenance/Maintenance.php"; |
|
24 | +require_once $basePath."/maintenance/Maintenance.php"; |
|
25 | 25 | // @codeCoverageIgnoreEnd |
26 | 26 | |
27 | 27 | /** |
@@ -60,20 +60,20 @@ discard block |
||
60 | 60 | parent::__construct(); |
61 | 61 | |
62 | 62 | $this->addDescription( |
63 | - 'Import entities needed for constraint checks ' . |
|
63 | + 'Import entities needed for constraint checks '. |
|
64 | 64 | 'from Wikidata into the local repository.' |
65 | 65 | ); |
66 | 66 | $this->addOption( |
67 | 67 | 'config-format', |
68 | - 'The format in which the resulting configuration will be omitted: ' . |
|
69 | - '"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), ' . |
|
68 | + 'The format in which the resulting configuration will be omitted: '. |
|
69 | + '"globals" for directly settings global variables, suitable for inclusion in LocalSettings.php (default), '. |
|
70 | 70 | 'or "wgConf" for printing parts of arrays suitable for inclusion in $wgConf->settings.' |
71 | 71 | ); |
72 | 72 | $this->addOption( |
73 | 73 | 'dry-run', |
74 | 74 | 'Don’t actually import entities, just print which ones would be imported.' |
75 | 75 | ); |
76 | - $this->requireExtension( 'WikibaseQualityConstraints' ); |
|
76 | + $this->requireExtension('WikibaseQualityConstraints'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | */ |
82 | 82 | private function setupServices() { |
83 | 83 | $services = MediaWikiServices::getInstance(); |
84 | - $this->entitySerializer = WikibaseRepo::getAllTypesEntitySerializer( $services ); |
|
85 | - $this->entityDeserializer = WikibaseRepo::getInternalFormatEntityDeserializer( $services ); |
|
86 | - $this->entityStore = WikibaseRepo::getEntityStore( $services ); |
|
84 | + $this->entitySerializer = WikibaseRepo::getAllTypesEntitySerializer($services); |
|
85 | + $this->entityDeserializer = WikibaseRepo::getInternalFormatEntityDeserializer($services); |
|
86 | + $this->entityStore = WikibaseRepo::getEntityStore($services); |
|
87 | 87 | $this->httpRequestFactory = $services->getHttpRequestFactory(); |
88 | - if ( !$this->getOption( 'dry-run', false ) ) { |
|
89 | - $this->user = User::newSystemUser( 'WikibaseQualityConstraints importer' ); |
|
88 | + if (!$this->getOption('dry-run', false)) { |
|
89 | + $this->user = User::newSystemUser('WikibaseQualityConstraints importer'); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
@@ -95,21 +95,21 @@ discard block |
||
95 | 95 | |
96 | 96 | $configUpdates = []; |
97 | 97 | |
98 | - $extensionJsonFile = __DIR__ . '/../extension.json'; |
|
99 | - $extensionJsonText = file_get_contents( $extensionJsonFile ); |
|
100 | - $extensionJson = json_decode( $extensionJsonText, /* assoc = */ true ); |
|
98 | + $extensionJsonFile = __DIR__.'/../extension.json'; |
|
99 | + $extensionJsonText = file_get_contents($extensionJsonFile); |
|
100 | + $extensionJson = json_decode($extensionJsonText, /* assoc = */ true); |
|
101 | 101 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable |
102 | - $wikidataEntityIds = $this->getEntitiesToImport( $extensionJson['config'], $this->getConfig() ); |
|
102 | + $wikidataEntityIds = $this->getEntitiesToImport($extensionJson['config'], $this->getConfig()); |
|
103 | 103 | |
104 | - foreach ( $wikidataEntityIds as $key => $wikidataEntityId ) { |
|
105 | - $localEntityId = $this->importEntityFromWikidata( $wikidataEntityId ); |
|
104 | + foreach ($wikidataEntityIds as $key => $wikidataEntityId) { |
|
105 | + $localEntityId = $this->importEntityFromWikidata($wikidataEntityId); |
|
106 | 106 | $configUpdates[$key] = [ |
107 | 107 | 'wikidata' => $wikidataEntityId, |
108 | 108 | 'local' => $localEntityId, |
109 | 109 | ]; |
110 | 110 | } |
111 | 111 | |
112 | - $this->outputConfigUpdates( $configUpdates ); |
|
112 | + $this->outputConfigUpdates($configUpdates); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | * @param Config $wikiConfig |
118 | 118 | * @return string[] |
119 | 119 | */ |
120 | - private function getEntitiesToImport( array $extensionJsonConfig, Config $wikiConfig ) { |
|
120 | + private function getEntitiesToImport(array $extensionJsonConfig, Config $wikiConfig) { |
|
121 | 121 | $wikidataEntityIds = []; |
122 | 122 | |
123 | - foreach ( $extensionJsonConfig as $key => $value ) { |
|
124 | - if ( !preg_match( '/Id$/', $key ) ) { |
|
123 | + foreach ($extensionJsonConfig as $key => $value) { |
|
124 | + if (!preg_match('/Id$/', $key)) { |
|
125 | 125 | continue; |
126 | 126 | } |
127 | 127 | |
128 | 128 | $wikidataEntityId = $value['value']; |
129 | - $localEntityId = $wikiConfig->get( $key ); |
|
129 | + $localEntityId = $wikiConfig->get($key); |
|
130 | 130 | |
131 | - if ( $localEntityId === $wikidataEntityId ) { |
|
131 | + if ($localEntityId === $wikidataEntityId) { |
|
132 | 132 | $wikidataEntityIds[$key] = $wikidataEntityId; |
133 | 133 | } |
134 | 134 | } |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | * @param string $wikidataEntityId |
141 | 141 | * @return string local entity ID |
142 | 142 | */ |
143 | - private function importEntityFromWikidata( $wikidataEntityId ) { |
|
143 | + private function importEntityFromWikidata($wikidataEntityId) { |
|
144 | 144 | $wikidataEntityUrl = "https://www.wikidata.org/wiki/Special:EntityData/$wikidataEntityId.json"; |
145 | - $wikidataEntitiesJson = $this->httpRequestFactory->get( $wikidataEntityUrl, [], __METHOD__ ); |
|
146 | - return $this->importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ); |
|
145 | + $wikidataEntitiesJson = $this->httpRequestFactory->get($wikidataEntityUrl, [], __METHOD__); |
|
146 | + return $this->importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -151,24 +151,24 @@ discard block |
||
151 | 151 | * @param string $wikidataEntitiesJson |
152 | 152 | * @return string local entity ID |
153 | 153 | */ |
154 | - private function importEntityFromJson( $wikidataEntityId, $wikidataEntitiesJson ) { |
|
154 | + private function importEntityFromJson($wikidataEntityId, $wikidataEntitiesJson) { |
|
155 | 155 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable |
156 | - $wikidataEntityArray = json_decode( $wikidataEntitiesJson, true )['entities'][$wikidataEntityId]; |
|
157 | - $wikidataEntity = $this->entityDeserializer->deserialize( $wikidataEntityArray ); |
|
156 | + $wikidataEntityArray = json_decode($wikidataEntitiesJson, true)['entities'][$wikidataEntityId]; |
|
157 | + $wikidataEntity = $this->entityDeserializer->deserialize($wikidataEntityArray); |
|
158 | 158 | |
159 | - $wikidataEntity->setId( null ); |
|
159 | + $wikidataEntity->setId(null); |
|
160 | 160 | |
161 | - if ( $wikidataEntity instanceof StatementListProvider ) { |
|
161 | + if ($wikidataEntity instanceof StatementListProvider) { |
|
162 | 162 | $wikidataEntity->getStatements()->clear(); |
163 | 163 | } |
164 | 164 | |
165 | - if ( $wikidataEntity instanceof Item ) { |
|
166 | - $wikidataEntity->setSiteLinkList( new SiteLinkList() ); |
|
165 | + if ($wikidataEntity instanceof Item) { |
|
166 | + $wikidataEntity->setSiteLinkList(new SiteLinkList()); |
|
167 | 167 | } |
168 | 168 | |
169 | - if ( $this->getOption( 'dry-run', false ) ) { |
|
170 | - $wikidataEntityJson = json_encode( $this->entitySerializer->serialize( $wikidataEntity ) ); |
|
171 | - $this->output( $wikidataEntityJson . "\n" ); |
|
169 | + if ($this->getOption('dry-run', false)) { |
|
170 | + $wikidataEntityJson = json_encode($this->entitySerializer->serialize($wikidataEntity)); |
|
171 | + $this->output($wikidataEntityJson."\n"); |
|
172 | 172 | return "-$wikidataEntityId"; |
173 | 173 | } |
174 | 174 | |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | )->getEntity(); |
182 | 182 | |
183 | 183 | return $localEntity->getId()->getSerialization(); |
184 | - } catch ( StorageException $storageException ) { |
|
185 | - return $this->storageExceptionToEntityId( $storageException ); |
|
184 | + } catch (StorageException $storageException) { |
|
185 | + return $this->storageExceptionToEntityId($storageException); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - private function storageExceptionToEntityId( StorageException $storageException ) { |
|
189 | + private function storageExceptionToEntityId(StorageException $storageException) { |
|
190 | 190 | $message = $storageException->getMessage(); |
191 | 191 | // example messages: |
192 | 192 | // * Item [[Item:Q475|Q475]] already has label "as references" |
@@ -196,25 +196,25 @@ discard block |
||
196 | 196 | // * Property [[Property:P694|P694]] already has label "instance of" |
197 | 197 | // associated with language code en. |
198 | 198 | $pattern = '/[[|]([^][|]*)]] already has label .* associated with language code/'; |
199 | - if ( preg_match( $pattern, $message, $matches ) ) { |
|
199 | + if (preg_match($pattern, $message, $matches)) { |
|
200 | 200 | return $matches[1]; |
201 | 201 | } else { |
202 | 202 | throw $storageException; |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | - private function outputConfigUpdates( array $configUpdates ) { |
|
207 | - $configFormat = $this->getOption( 'config-format', 'globals' ); |
|
208 | - switch ( $configFormat ) { |
|
206 | + private function outputConfigUpdates(array $configUpdates) { |
|
207 | + $configFormat = $this->getOption('config-format', 'globals'); |
|
208 | + switch ($configFormat) { |
|
209 | 209 | case 'globals': |
210 | - $this->outputConfigUpdatesGlobals( $configUpdates ); |
|
210 | + $this->outputConfigUpdatesGlobals($configUpdates); |
|
211 | 211 | break; |
212 | 212 | case 'wgConf': |
213 | - $this->outputConfigUpdatesWgConf( $configUpdates ); |
|
213 | + $this->outputConfigUpdatesWgConf($configUpdates); |
|
214 | 214 | break; |
215 | 215 | default: |
216 | - $this->error( "Invalid config format \"$configFormat\", using \"globals\"" ); |
|
217 | - $this->outputConfigUpdatesGlobals( $configUpdates ); |
|
216 | + $this->error("Invalid config format \"$configFormat\", using \"globals\""); |
|
217 | + $this->outputConfigUpdatesGlobals($configUpdates); |
|
218 | 218 | break; |
219 | 219 | } |
220 | 220 | } |
@@ -222,22 +222,22 @@ discard block |
||
222 | 222 | /** |
223 | 223 | * @param array[] $configUpdates |
224 | 224 | */ |
225 | - private function outputConfigUpdatesGlobals( array $configUpdates ) { |
|
226 | - foreach ( $configUpdates as $key => $value ) { |
|
227 | - $localValueCode = var_export( $value['local'], true ); |
|
228 | - $this->output( "\$wg$key = $localValueCode;\n" ); |
|
225 | + private function outputConfigUpdatesGlobals(array $configUpdates) { |
|
226 | + foreach ($configUpdates as $key => $value) { |
|
227 | + $localValueCode = var_export($value['local'], true); |
|
228 | + $this->output("\$wg$key = $localValueCode;\n"); |
|
229 | 229 | } |
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
233 | 233 | * @param array[] $configUpdates |
234 | 234 | */ |
235 | - private function outputConfigUpdatesWgConf( array $configUpdates ) { |
|
236 | - $wikiIdCode = var_export( WikiMap::getCurrentWikiId(), true ); |
|
237 | - foreach ( $configUpdates as $key => $value ) { |
|
238 | - $keyCode = var_export( "wg$key", true ); |
|
239 | - $wikidataValueCode = var_export( $value['wikidata'], true ); |
|
240 | - $localValueCode = var_export( $value['local'], true ); |
|
235 | + private function outputConfigUpdatesWgConf(array $configUpdates) { |
|
236 | + $wikiIdCode = var_export(WikiMap::getCurrentWikiId(), true); |
|
237 | + foreach ($configUpdates as $key => $value) { |
|
238 | + $keyCode = var_export("wg$key", true); |
|
239 | + $wikidataValueCode = var_export($value['wikidata'], true); |
|
240 | + $localValueCode = var_export($value['local'], true); |
|
241 | 241 | $block = <<< EOF |
242 | 242 | $keyCode => [ |
243 | 243 | 'default' => $wikidataValueCode, |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | |
247 | 247 | |
248 | 248 | EOF; |
249 | - $this->output( $block ); |
|
249 | + $this->output($block); |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 |
@@ -200,73 +200,73 @@ discard block |
||
200 | 200 | $this->defaultUserAgent = $defaultUserAgent; |
201 | 201 | $this->requestFactory = $requestFactory; |
202 | 202 | $this->entityPrefixes = []; |
203 | - foreach ( $rdfVocabulary->entityNamespaceNames as $namespaceName ) { |
|
204 | - $this->entityPrefixes[] = $rdfVocabulary->getNamespaceURI( $namespaceName ); |
|
203 | + foreach ($rdfVocabulary->entityNamespaceNames as $namespaceName) { |
|
204 | + $this->entityPrefixes[] = $rdfVocabulary->getNamespaceURI($namespaceName); |
|
205 | 205 | } |
206 | 206 | |
207 | - $this->endpoint = $config->get( 'WBQualityConstraintsSparqlEndpoint' ); |
|
208 | - $this->maxQueryTimeMillis = $config->get( 'WBQualityConstraintsSparqlMaxMillis' ); |
|
209 | - $this->instanceOfId = $config->get( 'WBQualityConstraintsInstanceOfId' ); |
|
210 | - $this->subclassOfId = $config->get( 'WBQualityConstraintsSubclassOfId' ); |
|
211 | - $this->cacheMapSize = $config->get( 'WBQualityConstraintsFormatCacheMapSize' ); |
|
207 | + $this->endpoint = $config->get('WBQualityConstraintsSparqlEndpoint'); |
|
208 | + $this->maxQueryTimeMillis = $config->get('WBQualityConstraintsSparqlMaxMillis'); |
|
209 | + $this->instanceOfId = $config->get('WBQualityConstraintsInstanceOfId'); |
|
210 | + $this->subclassOfId = $config->get('WBQualityConstraintsSubclassOfId'); |
|
211 | + $this->cacheMapSize = $config->get('WBQualityConstraintsFormatCacheMapSize'); |
|
212 | 212 | $this->timeoutExceptionClasses = $config->get( |
213 | 213 | 'WBQualityConstraintsSparqlTimeoutExceptionClasses' |
214 | 214 | ); |
215 | 215 | $this->sparqlHasWikibaseSupport = $config->get( |
216 | 216 | 'WBQualityConstraintsSparqlHasWikibaseSupport' |
217 | 217 | ); |
218 | - $this->sparqlThrottlingFallbackDuration = (int)$config->get( |
|
218 | + $this->sparqlThrottlingFallbackDuration = (int) $config->get( |
|
219 | 219 | 'WBQualityConstraintsSparqlThrottlingFallbackDuration' |
220 | 220 | ); |
221 | 221 | |
222 | - $this->prefixes = $this->getQueryPrefixes( $rdfVocabulary ); |
|
222 | + $this->prefixes = $this->getQueryPrefixes($rdfVocabulary); |
|
223 | 223 | } |
224 | 224 | |
225 | - private function getQueryPrefixes( RdfVocabulary $rdfVocabulary ) { |
|
225 | + private function getQueryPrefixes(RdfVocabulary $rdfVocabulary) { |
|
226 | 226 | // TODO: it would probably be smarter that RdfVocubulary exposed these prefixes somehow |
227 | 227 | $prefixes = ''; |
228 | - foreach ( $rdfVocabulary->entityNamespaceNames as $sourceName => $namespaceName ) { |
|
228 | + foreach ($rdfVocabulary->entityNamespaceNames as $sourceName => $namespaceName) { |
|
229 | 229 | $prefixes .= <<<END |
230 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
230 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
231 | 231 | END; |
232 | 232 | } |
233 | 233 | $prefixes .= <<<END |
234 | -PREFIX wds: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_STATEMENT )}> |
|
235 | -PREFIX wdv: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_VALUE )}>\n |
|
234 | +PREFIX wds: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_STATEMENT)}> |
|
235 | +PREFIX wdv: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_VALUE)}>\n |
|
236 | 236 | END; |
237 | 237 | |
238 | - foreach ( $rdfVocabulary->propertyNamespaceNames as $sourceName => $sourceNamespaces ) { |
|
238 | + foreach ($rdfVocabulary->propertyNamespaceNames as $sourceName => $sourceNamespaces) { |
|
239 | 239 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_DIRECT_CLAIM]; |
240 | 240 | $prefixes .= <<<END |
241 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
241 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
242 | 242 | END; |
243 | 243 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM]; |
244 | 244 | $prefixes .= <<<END |
245 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
245 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
246 | 246 | END; |
247 | 247 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_CLAIM_STATEMENT]; |
248 | 248 | $prefixes .= <<<END |
249 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
249 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
250 | 250 | END; |
251 | 251 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_QUALIFIER]; |
252 | 252 | $prefixes .= <<<END |
253 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
253 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
254 | 254 | END; |
255 | 255 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_QUALIFIER_VALUE]; |
256 | 256 | $prefixes .= <<<END |
257 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
257 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
258 | 258 | END; |
259 | 259 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_REFERENCE]; |
260 | 260 | $prefixes .= <<<END |
261 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
261 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
262 | 262 | END; |
263 | 263 | $namespaceName = $sourceNamespaces[RdfVocabulary::NSP_REFERENCE_VALUE]; |
264 | 264 | $prefixes .= <<<END |
265 | -PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI( $namespaceName )}>\n |
|
265 | +PREFIX {$namespaceName}: <{$rdfVocabulary->getNamespaceURI($namespaceName)}>\n |
|
266 | 266 | END; |
267 | 267 | } |
268 | 268 | $prefixes .= <<<END |
269 | -PREFIX wikibase: <{$rdfVocabulary->getNamespaceURI( RdfVocabulary::NS_ONTOLOGY )}>\n |
|
269 | +PREFIX wikibase: <{$rdfVocabulary->getNamespaceURI(RdfVocabulary::NS_ONTOLOGY)}>\n |
|
270 | 270 | END; |
271 | 271 | return $prefixes; |
272 | 272 | } |
@@ -278,21 +278,20 @@ discard block |
||
278 | 278 | * @return CachedBool |
279 | 279 | * @throws SparqlHelperException if the query times out or some other error occurs |
280 | 280 | */ |
281 | - public function hasType( $id, array $classes ) { |
|
281 | + public function hasType($id, array $classes) { |
|
282 | 282 | // TODO hint:gearing is a workaround for T168973 and can hopefully be removed eventually |
283 | 283 | $gearingHint = $this->sparqlHasWikibaseSupport ? |
284 | - ' hint:Prior hint:gearing "forward".' : |
|
285 | - ''; |
|
284 | + ' hint:Prior hint:gearing "forward".' : ''; |
|
286 | 285 | |
287 | 286 | $metadatas = []; |
288 | 287 | |
289 | - foreach ( array_chunk( $classes, 20 ) as $classesChunk ) { |
|
290 | - $classesValues = implode( ' ', array_map( |
|
291 | - static function ( $class ) { |
|
292 | - return 'wd:' . $class; |
|
288 | + foreach (array_chunk($classes, 20) as $classesChunk) { |
|
289 | + $classesValues = implode(' ', array_map( |
|
290 | + static function($class) { |
|
291 | + return 'wd:'.$class; |
|
293 | 292 | }, |
294 | 293 | $classesChunk |
295 | - ) ); |
|
294 | + )); |
|
296 | 295 | |
297 | 296 | $query = <<<EOF |
298 | 297 | ASK { |
@@ -302,19 +301,19 @@ discard block |
||
302 | 301 | } |
303 | 302 | EOF; |
304 | 303 | |
305 | - $result = $this->runQuery( $query ); |
|
304 | + $result = $this->runQuery($query); |
|
306 | 305 | $metadatas[] = $result->getMetadata(); |
307 | - if ( $result->getArray()['boolean'] ) { |
|
306 | + if ($result->getArray()['boolean']) { |
|
308 | 307 | return new CachedBool( |
309 | 308 | true, |
310 | - Metadata::merge( $metadatas ) |
|
309 | + Metadata::merge($metadatas) |
|
311 | 310 | ); |
312 | 311 | } |
313 | 312 | } |
314 | 313 | |
315 | 314 | return new CachedBool( |
316 | 315 | false, |
317 | - Metadata::merge( $metadatas ) |
|
316 | + Metadata::merge($metadatas) |
|
318 | 317 | ); |
319 | 318 | } |
320 | 319 | |
@@ -325,7 +324,7 @@ discard block |
||
325 | 324 | * @param PropertyId $separator |
326 | 325 | * @return string |
327 | 326 | */ |
328 | - private function nestedSeparatorFilter( PropertyId $separator ) { |
|
327 | + private function nestedSeparatorFilter(PropertyId $separator) { |
|
329 | 328 | $filter = <<<EOF |
330 | 329 | MINUS { |
331 | 330 | ?statement pq:$separator ?qualifier. |
@@ -369,15 +368,15 @@ discard block |
||
369 | 368 | array $separators |
370 | 369 | ) { |
371 | 370 | $pid = $statement->getPropertyId()->serialize(); |
372 | - $guid = str_replace( '$', '-', $statement->getGuid() ); |
|
371 | + $guid = str_replace('$', '-', $statement->getGuid()); |
|
373 | 372 | |
374 | 373 | $deprecatedFilter = ''; |
375 | - if ( $ignoreDeprecatedStatements ) { |
|
374 | + if ($ignoreDeprecatedStatements) { |
|
376 | 375 | $deprecatedFilter = 'MINUS { ?otherStatement wikibase:rank wikibase:DeprecatedRank. }'; |
377 | 376 | } |
378 | 377 | |
379 | - $separatorFilters = array_map( [ $this, 'nestedSeparatorFilter' ], $separators ); |
|
380 | - $finalSeparatorFilter = implode( "\n", $separatorFilters ); |
|
378 | + $separatorFilters = array_map([$this, 'nestedSeparatorFilter'], $separators); |
|
379 | + $finalSeparatorFilter = implode("\n", $separatorFilters); |
|
381 | 380 | |
382 | 381 | $query = <<<EOF |
383 | 382 | SELECT DISTINCT ?otherEntity WHERE { |
@@ -395,9 +394,9 @@ discard block |
||
395 | 394 | LIMIT 10 |
396 | 395 | EOF; |
397 | 396 | |
398 | - $result = $this->runQuery( $query ); |
|
397 | + $result = $this->runQuery($query); |
|
399 | 398 | |
400 | - return $this->getOtherEntities( $result ); |
|
399 | + return $this->getOtherEntities($result); |
|
401 | 400 | } |
402 | 401 | |
403 | 402 | /** |
@@ -422,16 +421,15 @@ discard block |
||
422 | 421 | $dataType = $this->propertyDataTypeLookup->getDataTypeIdForProperty( |
423 | 422 | $snak->getPropertyId() |
424 | 423 | ); |
425 | - list( $value, $isFullValue ) = $this->getRdfLiteral( $dataType, $dataValue ); |
|
426 | - if ( $isFullValue ) { |
|
424 | + list($value, $isFullValue) = $this->getRdfLiteral($dataType, $dataValue); |
|
425 | + if ($isFullValue) { |
|
427 | 426 | $prefix .= 'v'; |
428 | 427 | } |
429 | 428 | $path = $type === Context::TYPE_QUALIFIER ? |
430 | - "$prefix:$pid" : |
|
431 | - "prov:wasDerivedFrom/$prefix:$pid"; |
|
429 | + "$prefix:$pid" : "prov:wasDerivedFrom/$prefix:$pid"; |
|
432 | 430 | |
433 | 431 | $deprecatedFilter = ''; |
434 | - if ( $ignoreDeprecatedStatements ) { |
|
432 | + if ($ignoreDeprecatedStatements) { |
|
435 | 433 | $deprecatedFilter = <<< EOF |
436 | 434 | MINUS { ?otherStatement wikibase:rank wikibase:DeprecatedRank. } |
437 | 435 | EOF; |
@@ -451,9 +449,9 @@ discard block |
||
451 | 449 | LIMIT 10 |
452 | 450 | EOF; |
453 | 451 | |
454 | - $result = $this->runQuery( $query ); |
|
452 | + $result = $this->runQuery($query); |
|
455 | 453 | |
456 | - return $this->getOtherEntities( $result ); |
|
454 | + return $this->getOtherEntities($result); |
|
457 | 455 | } |
458 | 456 | |
459 | 457 | /** |
@@ -463,8 +461,8 @@ discard block |
||
463 | 461 | * |
464 | 462 | * @return string |
465 | 463 | */ |
466 | - private function stringLiteral( $text ) { |
|
467 | - return '"' . strtr( $text, [ '"' => '\\"', '\\' => '\\\\' ] ) . '"'; |
|
464 | + private function stringLiteral($text) { |
|
465 | + return '"'.strtr($text, ['"' => '\\"', '\\' => '\\\\']).'"'; |
|
468 | 466 | } |
469 | 467 | |
470 | 468 | /** |
@@ -474,18 +472,18 @@ discard block |
||
474 | 472 | * |
475 | 473 | * @return CachedEntityIds |
476 | 474 | */ |
477 | - private function getOtherEntities( CachedQueryResults $results ) { |
|
478 | - return new CachedEntityIds( array_map( |
|
479 | - function ( $resultBindings ) { |
|
475 | + private function getOtherEntities(CachedQueryResults $results) { |
|
476 | + return new CachedEntityIds(array_map( |
|
477 | + function($resultBindings) { |
|
480 | 478 | $entityIRI = $resultBindings['otherEntity']['value']; |
481 | - foreach ( $this->entityPrefixes as $entityPrefix ) { |
|
482 | - $entityPrefixLength = strlen( $entityPrefix ); |
|
483 | - if ( substr( $entityIRI, 0, $entityPrefixLength ) === $entityPrefix ) { |
|
479 | + foreach ($this->entityPrefixes as $entityPrefix) { |
|
480 | + $entityPrefixLength = strlen($entityPrefix); |
|
481 | + if (substr($entityIRI, 0, $entityPrefixLength) === $entityPrefix) { |
|
484 | 482 | try { |
485 | 483 | return $this->entityIdParser->parse( |
486 | - substr( $entityIRI, $entityPrefixLength ) |
|
484 | + substr($entityIRI, $entityPrefixLength) |
|
487 | 485 | ); |
488 | - } catch ( EntityIdParsingException $e ) { |
|
486 | + } catch (EntityIdParsingException $e) { |
|
489 | 487 | // fall through |
490 | 488 | } |
491 | 489 | } |
@@ -496,7 +494,7 @@ discard block |
||
496 | 494 | return null; |
497 | 495 | }, |
498 | 496 | $results->getArray()['results']['bindings'] |
499 | - ), $results->getMetadata() ); |
|
497 | + ), $results->getMetadata()); |
|
500 | 498 | } |
501 | 499 | |
502 | 500 | // phpcs:disable Generic.Metrics.CyclomaticComplexity,Squiz.WhiteSpace.FunctionSpacing |
@@ -509,50 +507,50 @@ discard block |
||
509 | 507 | * @return array the literal or IRI as a string in SPARQL syntax, |
510 | 508 | * and a boolean indicating whether it refers to a full value node or not |
511 | 509 | */ |
512 | - private function getRdfLiteral( $dataType, DataValue $dataValue ) { |
|
513 | - switch ( $dataType ) { |
|
510 | + private function getRdfLiteral($dataType, DataValue $dataValue) { |
|
511 | + switch ($dataType) { |
|
514 | 512 | case 'string': |
515 | 513 | case 'external-id': |
516 | - return [ $this->stringLiteral( $dataValue->getValue() ), false ]; |
|
514 | + return [$this->stringLiteral($dataValue->getValue()), false]; |
|
517 | 515 | case 'commonsMedia': |
518 | - $url = $this->rdfVocabulary->getMediaFileURI( $dataValue->getValue() ); |
|
519 | - return [ '<' . $url . '>', false ]; |
|
516 | + $url = $this->rdfVocabulary->getMediaFileURI($dataValue->getValue()); |
|
517 | + return ['<'.$url.'>', false]; |
|
520 | 518 | case 'geo-shape': |
521 | - $url = $this->rdfVocabulary->getGeoShapeURI( $dataValue->getValue() ); |
|
522 | - return [ '<' . $url . '>', false ]; |
|
519 | + $url = $this->rdfVocabulary->getGeoShapeURI($dataValue->getValue()); |
|
520 | + return ['<'.$url.'>', false]; |
|
523 | 521 | case 'tabular-data': |
524 | - $url = $this->rdfVocabulary->getTabularDataURI( $dataValue->getValue() ); |
|
525 | - return [ '<' . $url . '>', false ]; |
|
522 | + $url = $this->rdfVocabulary->getTabularDataURI($dataValue->getValue()); |
|
523 | + return ['<'.$url.'>', false]; |
|
526 | 524 | case 'url': |
527 | 525 | $url = $dataValue->getValue(); |
528 | - if ( !preg_match( '/^[^<>"{}\\\\|^`\\x00-\\x20]*$/D', $url ) ) { |
|
526 | + if (!preg_match('/^[^<>"{}\\\\|^`\\x00-\\x20]*$/D', $url)) { |
|
529 | 527 | // not a valid URL for SPARQL (see SPARQL spec, production 139 IRIREF) |
530 | 528 | // such an URL should never reach us, so just throw |
531 | - throw new InvalidArgumentException( 'invalid URL: ' . $url ); |
|
529 | + throw new InvalidArgumentException('invalid URL: '.$url); |
|
532 | 530 | } |
533 | - return [ '<' . $url . '>', false ]; |
|
531 | + return ['<'.$url.'>', false]; |
|
534 | 532 | case 'wikibase-item': |
535 | 533 | case 'wikibase-property': |
536 | 534 | /** @var EntityIdValue $dataValue */ |
537 | 535 | '@phan-var EntityIdValue $dataValue'; |
538 | - return [ 'wd:' . $dataValue->getEntityId()->getSerialization(), false ]; |
|
536 | + return ['wd:'.$dataValue->getEntityId()->getSerialization(), false]; |
|
539 | 537 | case 'monolingualtext': |
540 | 538 | /** @var MonolingualTextValue $dataValue */ |
541 | 539 | '@phan-var MonolingualTextValue $dataValue'; |
542 | 540 | $lang = $dataValue->getLanguageCode(); |
543 | - if ( !preg_match( '/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/D', $lang ) ) { |
|
541 | + if (!preg_match('/^[a-zA-Z]+(-[a-zA-Z0-9]+)*$/D', $lang)) { |
|
544 | 542 | // not a valid language tag for SPARQL (see SPARQL spec, production 145 LANGTAG) |
545 | 543 | // such a language tag should never reach us, so just throw |
546 | - throw new InvalidArgumentException( 'invalid language tag: ' . $lang ); |
|
544 | + throw new InvalidArgumentException('invalid language tag: '.$lang); |
|
547 | 545 | } |
548 | - return [ $this->stringLiteral( $dataValue->getText() ) . '@' . $lang, false ]; |
|
546 | + return [$this->stringLiteral($dataValue->getText()).'@'.$lang, false]; |
|
549 | 547 | case 'globe-coordinate': |
550 | 548 | case 'quantity': |
551 | 549 | case 'time': |
552 | 550 | // @phan-suppress-next-line PhanUndeclaredMethod |
553 | - return [ 'wdv:' . $dataValue->getHash(), true ]; |
|
551 | + return ['wdv:'.$dataValue->getHash(), true]; |
|
554 | 552 | default: |
555 | - throw new InvalidArgumentException( 'unknown data type: ' . $dataType ); |
|
553 | + throw new InvalidArgumentException('unknown data type: '.$dataType); |
|
556 | 554 | } |
557 | 555 | } |
558 | 556 | // phpcs:enable |
@@ -565,43 +563,43 @@ discard block |
||
565 | 563 | * @throws SparqlHelperException if the query times out or some other error occurs |
566 | 564 | * @throws ConstraintParameterException if the $regex is invalid |
567 | 565 | */ |
568 | - public function matchesRegularExpression( $text, $regex ) { |
|
566 | + public function matchesRegularExpression($text, $regex) { |
|
569 | 567 | // caching wrapper around matchesRegularExpressionWithSparql |
570 | 568 | |
571 | - $textHash = hash( 'sha256', $text ); |
|
569 | + $textHash = hash('sha256', $text); |
|
572 | 570 | $cacheKey = $this->cache->makeKey( |
573 | 571 | 'WikibaseQualityConstraints', // extension |
574 | 572 | 'regex', // action |
575 | 573 | 'WDQS-Java', // regex flavor |
576 | - hash( 'sha256', $regex ) |
|
574 | + hash('sha256', $regex) |
|
577 | 575 | ); |
578 | 576 | |
579 | 577 | $cacheMapArray = $this->cache->getWithSetCallback( |
580 | 578 | $cacheKey, |
581 | 579 | WANObjectCache::TTL_DAY, |
582 | - function ( $cacheMapArray ) use ( $text, $regex, $textHash ) { |
|
580 | + function($cacheMapArray) use ($text, $regex, $textHash) { |
|
583 | 581 | // Initialize the cache map if not set |
584 | - if ( $cacheMapArray === false ) { |
|
582 | + if ($cacheMapArray === false) { |
|
585 | 583 | $key = 'wikibase.quality.constraints.regex.cache.refresh.init'; |
586 | - $this->dataFactory->increment( $key ); |
|
584 | + $this->dataFactory->increment($key); |
|
587 | 585 | return []; |
588 | 586 | } |
589 | 587 | |
590 | 588 | $key = 'wikibase.quality.constraints.regex.cache.refresh'; |
591 | - $this->dataFactory->increment( $key ); |
|
592 | - $cacheMap = MapCacheLRU::newFromArray( $cacheMapArray, $this->cacheMapSize ); |
|
593 | - if ( $cacheMap->has( $textHash ) ) { |
|
589 | + $this->dataFactory->increment($key); |
|
590 | + $cacheMap = MapCacheLRU::newFromArray($cacheMapArray, $this->cacheMapSize); |
|
591 | + if ($cacheMap->has($textHash)) { |
|
594 | 592 | $key = 'wikibase.quality.constraints.regex.cache.refresh.hit'; |
595 | - $this->dataFactory->increment( $key ); |
|
596 | - $cacheMap->get( $textHash ); // ping cache |
|
593 | + $this->dataFactory->increment($key); |
|
594 | + $cacheMap->get($textHash); // ping cache |
|
597 | 595 | } else { |
598 | 596 | $key = 'wikibase.quality.constraints.regex.cache.refresh.miss'; |
599 | - $this->dataFactory->increment( $key ); |
|
597 | + $this->dataFactory->increment($key); |
|
600 | 598 | try { |
601 | - $matches = $this->matchesRegularExpressionWithSparql( $text, $regex ); |
|
602 | - } catch ( ConstraintParameterException $e ) { |
|
603 | - $matches = $this->serializeConstraintParameterException( $e ); |
|
604 | - } catch ( SparqlHelperException $e ) { |
|
599 | + $matches = $this->matchesRegularExpressionWithSparql($text, $regex); |
|
600 | + } catch (ConstraintParameterException $e) { |
|
601 | + $matches = $this->serializeConstraintParameterException($e); |
|
602 | + } catch (SparqlHelperException $e) { |
|
605 | 603 | // don’t cache this |
606 | 604 | return $cacheMap->toArray(); |
607 | 605 | } |
@@ -625,42 +623,42 @@ discard block |
||
625 | 623 | ] |
626 | 624 | ); |
627 | 625 | |
628 | - if ( isset( $cacheMapArray[$textHash] ) ) { |
|
626 | + if (isset($cacheMapArray[$textHash])) { |
|
629 | 627 | $key = 'wikibase.quality.constraints.regex.cache.hit'; |
630 | - $this->dataFactory->increment( $key ); |
|
628 | + $this->dataFactory->increment($key); |
|
631 | 629 | $matches = $cacheMapArray[$textHash]; |
632 | - if ( is_bool( $matches ) ) { |
|
630 | + if (is_bool($matches)) { |
|
633 | 631 | return $matches; |
634 | - } elseif ( is_array( $matches ) && |
|
635 | - $matches['type'] == ConstraintParameterException::class ) { |
|
636 | - throw $this->deserializeConstraintParameterException( $matches ); |
|
632 | + } elseif (is_array($matches) && |
|
633 | + $matches['type'] == ConstraintParameterException::class) { |
|
634 | + throw $this->deserializeConstraintParameterException($matches); |
|
637 | 635 | } else { |
638 | 636 | throw new MWException( |
639 | - 'Value of unknown type in object cache (' . |
|
640 | - 'cache key: ' . $cacheKey . ', ' . |
|
641 | - 'cache map key: ' . $textHash . ', ' . |
|
642 | - 'value type: ' . gettype( $matches ) . ')' |
|
637 | + 'Value of unknown type in object cache ('. |
|
638 | + 'cache key: '.$cacheKey.', '. |
|
639 | + 'cache map key: '.$textHash.', '. |
|
640 | + 'value type: '.gettype($matches).')' |
|
643 | 641 | ); |
644 | 642 | } |
645 | 643 | } else { |
646 | 644 | $key = 'wikibase.quality.constraints.regex.cache.miss'; |
647 | - $this->dataFactory->increment( $key ); |
|
648 | - return $this->matchesRegularExpressionWithSparql( $text, $regex ); |
|
645 | + $this->dataFactory->increment($key); |
|
646 | + return $this->matchesRegularExpressionWithSparql($text, $regex); |
|
649 | 647 | } |
650 | 648 | } |
651 | 649 | |
652 | - private function serializeConstraintParameterException( ConstraintParameterException $cpe ) { |
|
650 | + private function serializeConstraintParameterException(ConstraintParameterException $cpe) { |
|
653 | 651 | return [ |
654 | 652 | 'type' => ConstraintParameterException::class, |
655 | - 'violationMessage' => $this->violationMessageSerializer->serialize( $cpe->getViolationMessage() ), |
|
653 | + 'violationMessage' => $this->violationMessageSerializer->serialize($cpe->getViolationMessage()), |
|
656 | 654 | ]; |
657 | 655 | } |
658 | 656 | |
659 | - private function deserializeConstraintParameterException( array $serialization ) { |
|
657 | + private function deserializeConstraintParameterException(array $serialization) { |
|
660 | 658 | $message = $this->violationMessageDeserializer->deserialize( |
661 | 659 | $serialization['violationMessage'] |
662 | 660 | ); |
663 | - return new ConstraintParameterException( $message ); |
|
661 | + return new ConstraintParameterException($message); |
|
664 | 662 | } |
665 | 663 | |
666 | 664 | /** |
@@ -674,25 +672,25 @@ discard block |
||
674 | 672 | * @throws SparqlHelperException if the query times out or some other error occurs |
675 | 673 | * @throws ConstraintParameterException if the $regex is invalid |
676 | 674 | */ |
677 | - public function matchesRegularExpressionWithSparql( $text, $regex ) { |
|
678 | - $textStringLiteral = $this->stringLiteral( $text ); |
|
679 | - $regexStringLiteral = $this->stringLiteral( '^(?:' . $regex . ')$' ); |
|
675 | + public function matchesRegularExpressionWithSparql($text, $regex) { |
|
676 | + $textStringLiteral = $this->stringLiteral($text); |
|
677 | + $regexStringLiteral = $this->stringLiteral('^(?:'.$regex.')$'); |
|
680 | 678 | |
681 | 679 | $query = <<<EOF |
682 | 680 | SELECT (REGEX($textStringLiteral, $regexStringLiteral) AS ?matches) {} |
683 | 681 | EOF; |
684 | 682 | |
685 | - $result = $this->runQuery( $query, false ); |
|
683 | + $result = $this->runQuery($query, false); |
|
686 | 684 | |
687 | 685 | $vars = $result->getArray()['results']['bindings'][0]; |
688 | - if ( array_key_exists( 'matches', $vars ) ) { |
|
686 | + if (array_key_exists('matches', $vars)) { |
|
689 | 687 | // true or false ⇒ regex okay, text matches or not |
690 | 688 | return $vars['matches']['value'] === 'true'; |
691 | 689 | } else { |
692 | 690 | // empty result: regex broken |
693 | 691 | throw new ConstraintParameterException( |
694 | - ( new ViolationMessage( 'wbqc-violation-message-parameter-regex' ) ) |
|
695 | - ->withInlineCode( $regex, Role::CONSTRAINT_PARAMETER_VALUE ) |
|
692 | + (new ViolationMessage('wbqc-violation-message-parameter-regex')) |
|
693 | + ->withInlineCode($regex, Role::CONSTRAINT_PARAMETER_VALUE) |
|
696 | 694 | ); |
697 | 695 | } |
698 | 696 | } |
@@ -704,14 +702,14 @@ discard block |
||
704 | 702 | * |
705 | 703 | * @return boolean |
706 | 704 | */ |
707 | - public function isTimeout( $responseContent ) { |
|
708 | - $timeoutRegex = implode( '|', array_map( |
|
709 | - static function ( $fqn ) { |
|
710 | - return preg_quote( $fqn, '/' ); |
|
705 | + public function isTimeout($responseContent) { |
|
706 | + $timeoutRegex = implode('|', array_map( |
|
707 | + static function($fqn) { |
|
708 | + return preg_quote($fqn, '/'); |
|
711 | 709 | }, |
712 | 710 | $this->timeoutExceptionClasses |
713 | - ) ); |
|
714 | - return (bool)preg_match( '/' . $timeoutRegex . '/', $responseContent ); |
|
711 | + )); |
|
712 | + return (bool) preg_match('/'.$timeoutRegex.'/', $responseContent); |
|
715 | 713 | } |
716 | 714 | |
717 | 715 | /** |
@@ -723,17 +721,17 @@ discard block |
||
723 | 721 | * @return int|boolean the max-age (in seconds) |
724 | 722 | * or a plain boolean if no max-age can be determined |
725 | 723 | */ |
726 | - public function getCacheMaxAge( $responseHeaders ) { |
|
724 | + public function getCacheMaxAge($responseHeaders) { |
|
727 | 725 | if ( |
728 | - array_key_exists( 'x-cache-status', $responseHeaders ) && |
|
729 | - preg_match( '/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0] ) |
|
726 | + array_key_exists('x-cache-status', $responseHeaders) && |
|
727 | + preg_match('/^hit(?:-.*)?$/', $responseHeaders['x-cache-status'][0]) |
|
730 | 728 | ) { |
731 | 729 | $maxage = []; |
732 | 730 | if ( |
733 | - array_key_exists( 'cache-control', $responseHeaders ) && |
|
734 | - preg_match( '/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage ) |
|
731 | + array_key_exists('cache-control', $responseHeaders) && |
|
732 | + preg_match('/\bmax-age=(\d+)\b/', $responseHeaders['cache-control'][0], $maxage) |
|
735 | 733 | ) { |
736 | - return intval( $maxage[1] ); |
|
734 | + return intval($maxage[1]); |
|
737 | 735 | } else { |
738 | 736 | return true; |
739 | 737 | } |
@@ -754,34 +752,34 @@ discard block |
||
754 | 752 | * or SparlHelper::EMPTY_RETRY_AFTER if there is an empty Retry-After |
755 | 753 | * or SparlHelper::INVALID_RETRY_AFTER if there is something wrong with the format |
756 | 754 | */ |
757 | - public function getThrottling( MWHttpRequest $request ) { |
|
758 | - $retryAfterValue = $request->getResponseHeader( 'Retry-After' ); |
|
759 | - if ( $retryAfterValue === null ) { |
|
755 | + public function getThrottling(MWHttpRequest $request) { |
|
756 | + $retryAfterValue = $request->getResponseHeader('Retry-After'); |
|
757 | + if ($retryAfterValue === null) { |
|
760 | 758 | return self::NO_RETRY_AFTER; |
761 | 759 | } |
762 | 760 | |
763 | - $trimmedRetryAfterValue = trim( $retryAfterValue ); |
|
764 | - if ( empty( $trimmedRetryAfterValue ) ) { |
|
761 | + $trimmedRetryAfterValue = trim($retryAfterValue); |
|
762 | + if (empty($trimmedRetryAfterValue)) { |
|
765 | 763 | return self::EMPTY_RETRY_AFTER; |
766 | 764 | } |
767 | 765 | |
768 | - if ( is_numeric( $trimmedRetryAfterValue ) ) { |
|
769 | - $delaySeconds = (int)$trimmedRetryAfterValue; |
|
770 | - if ( $delaySeconds >= 0 ) { |
|
771 | - return $this->getTimestampInFuture( new DateInterval( 'PT' . $delaySeconds . 'S' ) ); |
|
766 | + if (is_numeric($trimmedRetryAfterValue)) { |
|
767 | + $delaySeconds = (int) $trimmedRetryAfterValue; |
|
768 | + if ($delaySeconds >= 0) { |
|
769 | + return $this->getTimestampInFuture(new DateInterval('PT'.$delaySeconds.'S')); |
|
772 | 770 | } |
773 | 771 | } else { |
774 | - $return = strtotime( $trimmedRetryAfterValue ); |
|
775 | - if ( !empty( $return ) ) { |
|
776 | - return new ConvertibleTimestamp( $return ); |
|
772 | + $return = strtotime($trimmedRetryAfterValue); |
|
773 | + if (!empty($return)) { |
|
774 | + return new ConvertibleTimestamp($return); |
|
777 | 775 | } |
778 | 776 | } |
779 | 777 | return self::INVALID_RETRY_AFTER; |
780 | 778 | } |
781 | 779 | |
782 | - private function getTimestampInFuture( DateInterval $delta ) { |
|
780 | + private function getTimestampInFuture(DateInterval $delta) { |
|
783 | 781 | $now = new ConvertibleTimestamp(); |
784 | - return new ConvertibleTimestamp( $now->timestamp->add( $delta ) ); |
|
782 | + return new ConvertibleTimestamp($now->timestamp->add($delta)); |
|
785 | 783 | } |
786 | 784 | |
787 | 785 | /** |
@@ -795,65 +793,64 @@ discard block |
||
795 | 793 | * |
796 | 794 | * @throws SparqlHelperException if the query times out or some other error occurs |
797 | 795 | */ |
798 | - public function runQuery( $query, $needsPrefixes = true ) { |
|
796 | + public function runQuery($query, $needsPrefixes = true) { |
|
799 | 797 | |
800 | - if ( $this->throttlingLock->isLocked( self::EXPIRY_LOCK_ID ) ) { |
|
801 | - $this->dataFactory->increment( 'wikibase.quality.constraints.sparql.throttling' ); |
|
798 | + if ($this->throttlingLock->isLocked(self::EXPIRY_LOCK_ID)) { |
|
799 | + $this->dataFactory->increment('wikibase.quality.constraints.sparql.throttling'); |
|
802 | 800 | throw new TooManySparqlRequestsException(); |
803 | 801 | } |
804 | 802 | |
805 | - if ( $this->sparqlHasWikibaseSupport ) { |
|
803 | + if ($this->sparqlHasWikibaseSupport) { |
|
806 | 804 | $needsPrefixes = false; |
807 | 805 | } |
808 | 806 | |
809 | - if ( $needsPrefixes ) { |
|
810 | - $query = $this->prefixes . $query; |
|
807 | + if ($needsPrefixes) { |
|
808 | + $query = $this->prefixes.$query; |
|
811 | 809 | } |
812 | - $query = "#wbqc\n" . $query; |
|
810 | + $query = "#wbqc\n".$query; |
|
813 | 811 | |
814 | - $url = $this->endpoint . '?' . http_build_query( |
|
812 | + $url = $this->endpoint.'?'.http_build_query( |
|
815 | 813 | [ |
816 | 814 | 'query' => $query, |
817 | 815 | 'format' => 'json', |
818 | 816 | 'maxQueryTimeMillis' => $this->maxQueryTimeMillis, |
819 | 817 | ], |
820 | - null, ini_get( 'arg_separator.output' ), |
|
818 | + null, ini_get('arg_separator.output'), |
|
821 | 819 | // encode spaces with %20, not + |
822 | 820 | PHP_QUERY_RFC3986 |
823 | 821 | ); |
824 | 822 | |
825 | 823 | $options = [ |
826 | 824 | 'method' => 'GET', |
827 | - 'timeout' => (int)round( ( $this->maxQueryTimeMillis + 1000 ) / 1000 ), |
|
825 | + 'timeout' => (int) round(($this->maxQueryTimeMillis + 1000) / 1000), |
|
828 | 826 | 'connectTimeout' => 'default', |
829 | 827 | 'userAgent' => $this->defaultUserAgent, |
830 | 828 | ]; |
831 | - $request = $this->requestFactory->create( $url, $options, __METHOD__ ); |
|
832 | - $startTime = microtime( true ); |
|
829 | + $request = $this->requestFactory->create($url, $options, __METHOD__); |
|
830 | + $startTime = microtime(true); |
|
833 | 831 | $requestStatus = $request->execute(); |
834 | - $endTime = microtime( true ); |
|
832 | + $endTime = microtime(true); |
|
835 | 833 | $this->dataFactory->timing( |
836 | 834 | 'wikibase.quality.constraints.sparql.timing', |
837 | - ( $endTime - $startTime ) * 1000 |
|
835 | + ($endTime - $startTime) * 1000 |
|
838 | 836 | ); |
839 | 837 | |
840 | - $this->guardAgainstTooManyRequestsError( $request ); |
|
838 | + $this->guardAgainstTooManyRequestsError($request); |
|
841 | 839 | |
842 | - $maxAge = $this->getCacheMaxAge( $request->getResponseHeaders() ); |
|
843 | - if ( $maxAge ) { |
|
844 | - $this->dataFactory->increment( 'wikibase.quality.constraints.sparql.cached' ); |
|
840 | + $maxAge = $this->getCacheMaxAge($request->getResponseHeaders()); |
|
841 | + if ($maxAge) { |
|
842 | + $this->dataFactory->increment('wikibase.quality.constraints.sparql.cached'); |
|
845 | 843 | } |
846 | 844 | |
847 | - if ( $requestStatus->isOK() ) { |
|
845 | + if ($requestStatus->isOK()) { |
|
848 | 846 | $json = $request->getContent(); |
849 | - $jsonStatus = FormatJson::parse( $json, FormatJson::FORCE_ASSOC ); |
|
850 | - if ( $jsonStatus->isOK() ) { |
|
847 | + $jsonStatus = FormatJson::parse($json, FormatJson::FORCE_ASSOC); |
|
848 | + if ($jsonStatus->isOK()) { |
|
851 | 849 | return new CachedQueryResults( |
852 | 850 | $jsonStatus->getValue(), |
853 | 851 | Metadata::ofCachingMetadata( |
854 | 852 | $maxAge ? |
855 | - CachingMetadata::ofMaximumAgeInSeconds( $maxAge ) : |
|
856 | - CachingMetadata::fresh() |
|
853 | + CachingMetadata::ofMaximumAgeInSeconds($maxAge) : CachingMetadata::fresh() |
|
857 | 854 | ) |
858 | 855 | ); |
859 | 856 | } else { |
@@ -870,9 +867,9 @@ discard block |
||
870 | 867 | // fall through to general error handling |
871 | 868 | } |
872 | 869 | |
873 | - $this->dataFactory->increment( 'wikibase.quality.constraints.sparql.error' ); |
|
870 | + $this->dataFactory->increment('wikibase.quality.constraints.sparql.error'); |
|
874 | 871 | |
875 | - if ( $this->isTimeout( $request->getContent() ) ) { |
|
872 | + if ($this->isTimeout($request->getContent())) { |
|
876 | 873 | $this->dataFactory->increment( |
877 | 874 | 'wikibase.quality.constraints.sparql.error.timeout' |
878 | 875 | ); |
@@ -887,29 +884,29 @@ discard block |
||
887 | 884 | * @param MWHttpRequest $request |
888 | 885 | * @throws TooManySparqlRequestsException |
889 | 886 | */ |
890 | - private function guardAgainstTooManyRequestsError( MWHttpRequest $request ): void { |
|
891 | - if ( $request->getStatus() !== self::HTTP_TOO_MANY_REQUESTS ) { |
|
887 | + private function guardAgainstTooManyRequestsError(MWHttpRequest $request): void { |
|
888 | + if ($request->getStatus() !== self::HTTP_TOO_MANY_REQUESTS) { |
|
892 | 889 | return; |
893 | 890 | } |
894 | 891 | |
895 | 892 | $fallbackBlockDuration = $this->sparqlThrottlingFallbackDuration; |
896 | 893 | |
897 | - if ( $fallbackBlockDuration < 0 ) { |
|
898 | - throw new InvalidArgumentException( 'Fallback duration must be positive int but is: ' . |
|
899 | - $fallbackBlockDuration ); |
|
894 | + if ($fallbackBlockDuration < 0) { |
|
895 | + throw new InvalidArgumentException('Fallback duration must be positive int but is: '. |
|
896 | + $fallbackBlockDuration); |
|
900 | 897 | } |
901 | 898 | |
902 | - $this->dataFactory->increment( 'wikibase.quality.constraints.sparql.throttling' ); |
|
903 | - $throttlingUntil = $this->getThrottling( $request ); |
|
904 | - if ( !( $throttlingUntil instanceof ConvertibleTimestamp ) ) { |
|
905 | - $this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterInvalid( $request ); |
|
899 | + $this->dataFactory->increment('wikibase.quality.constraints.sparql.throttling'); |
|
900 | + $throttlingUntil = $this->getThrottling($request); |
|
901 | + if (!($throttlingUntil instanceof ConvertibleTimestamp)) { |
|
902 | + $this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterInvalid($request); |
|
906 | 903 | $this->throttlingLock->lock( |
907 | 904 | self::EXPIRY_LOCK_ID, |
908 | - $this->getTimestampInFuture( new DateInterval( 'PT' . $fallbackBlockDuration . 'S' ) ) |
|
905 | + $this->getTimestampInFuture(new DateInterval('PT'.$fallbackBlockDuration.'S')) |
|
909 | 906 | ); |
910 | 907 | } else { |
911 | - $this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterPresent( $throttlingUntil, $request ); |
|
912 | - $this->throttlingLock->lock( self::EXPIRY_LOCK_ID, $throttlingUntil ); |
|
908 | + $this->loggingHelper->logSparqlHelperTooManyRequestsRetryAfterPresent($throttlingUntil, $request); |
|
909 | + $this->throttlingLock->lock(self::EXPIRY_LOCK_ID, $throttlingUntil); |
|
913 | 910 | } |
914 | 911 | throw new TooManySparqlRequestsException(); |
915 | 912 | } |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | // no parent::__construct() call |
24 | 24 | } |
25 | 25 | |
26 | - public function hasType( $id, array $classes ) { |
|
27 | - throw new LogicException( 'methods of this class should never be called' ); |
|
26 | + public function hasType($id, array $classes) { |
|
27 | + throw new LogicException('methods of this class should never be called'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function findEntitiesWithSameStatement( |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $ignoreDeprecatedStatements, |
33 | 33 | array $separators |
34 | 34 | ) { |
35 | - throw new LogicException( 'methods of this class should never be called' ); |
|
35 | + throw new LogicException('methods of this class should never be called'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | public function findEntitiesWithSameQualifierOrReference( |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | $type, |
42 | 42 | $ignoreDeprecatedStatements |
43 | 43 | ) { |
44 | - throw new LogicException( 'methods of this class should never be called' ); |
|
44 | + throw new LogicException('methods of this class should never be called'); |
|
45 | 45 | } |
46 | 46 | |
47 | - public function matchesRegularExpression( $text, $regex ) { |
|
48 | - throw new LogicException( 'methods of this class should never be called' ); |
|
47 | + public function matchesRegularExpression($text, $regex) { |
|
48 | + throw new LogicException('methods of this class should never be called'); |
|
49 | 49 | } |
50 | 50 | |
51 | - public function runQuery( $query, $needsPrefixes = true ) { |
|
52 | - throw new LogicException( 'methods of this class should never be called' ); |
|
51 | + public function runQuery($query, $needsPrefixes = true) { |
|
52 | + throw new LogicException('methods of this class should never be called'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | } |
@@ -76,20 +76,20 @@ discard block |
||
76 | 76 | * @throws SparqlHelperException if the checker uses SPARQL and the query times out or some other error occurs |
77 | 77 | * @return CheckResult |
78 | 78 | */ |
79 | - public function checkConstraint( Context $context, Constraint $constraint ) { |
|
80 | - if ( $context->getSnakRank() === Statement::RANK_DEPRECATED ) { |
|
81 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_DEPRECATED ); |
|
79 | + public function checkConstraint(Context $context, Constraint $constraint) { |
|
80 | + if ($context->getSnakRank() === Statement::RANK_DEPRECATED) { |
|
81 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_DEPRECATED); |
|
82 | 82 | } |
83 | 83 | $parameters = []; |
84 | 84 | |
85 | - if ( !( $this->sparqlHelper instanceof DummySparqlHelper ) ) { |
|
85 | + if (!($this->sparqlHelper instanceof DummySparqlHelper)) { |
|
86 | 86 | |
87 | 87 | $separators = $this->constraintParameterParser->parseSeparatorsParameter( |
88 | 88 | $constraint->getConstraintParameters() |
89 | 89 | ); |
90 | 90 | $parameters['separator'] = $separators; |
91 | 91 | |
92 | - if ( $context->getType() === 'statement' ) { |
|
92 | + if ($context->getType() === 'statement') { |
|
93 | 93 | $result = $this->sparqlHelper->findEntitiesWithSameStatement( |
94 | 94 | $context->getSnakStatement(), |
95 | 95 | true, // ignore deprecated statements |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | ); |
98 | 98 | } else { |
99 | 99 | $snak = $context->getSnak(); |
100 | - if ( !$snak instanceof PropertyValueSnak ) { |
|
100 | + if (!$snak instanceof PropertyValueSnak) { |
|
101 | 101 | // nothing to check |
102 | - return new CheckResult( $context, $constraint, [], CheckResult::STATUS_COMPLIANCE ); |
|
102 | + return new CheckResult($context, $constraint, [], CheckResult::STATUS_COMPLIANCE); |
|
103 | 103 | } |
104 | 104 | $result = $this->sparqlHelper->findEntitiesWithSameQualifierOrReference( |
105 | 105 | $context->getEntity()->getId(), |
@@ -112,32 +112,32 @@ discard block |
||
112 | 112 | $otherEntities = $result->getArray(); |
113 | 113 | $metadata = $result->getMetadata(); |
114 | 114 | |
115 | - if ( $otherEntities === [] ) { |
|
115 | + if ($otherEntities === []) { |
|
116 | 116 | $status = CheckResult::STATUS_COMPLIANCE; |
117 | 117 | $message = null; |
118 | 118 | } else { |
119 | - $otherEntities = array_values( array_filter( $otherEntities ) ); // remove nulls |
|
119 | + $otherEntities = array_values(array_filter($otherEntities)); // remove nulls |
|
120 | 120 | $status = CheckResult::STATUS_VIOLATION; |
121 | - $message = ( new ViolationMessage( 'wbqc-violation-message-unique-value' ) ) |
|
122 | - ->withEntityIdList( $otherEntities, Role::SUBJECT ); |
|
121 | + $message = (new ViolationMessage('wbqc-violation-message-unique-value')) |
|
122 | + ->withEntityIdList($otherEntities, Role::SUBJECT); |
|
123 | 123 | } |
124 | 124 | } else { |
125 | 125 | $status = CheckResult::STATUS_TODO; |
126 | - $message = ( new ViolationMessage( 'wbqc-violation-message-not-yet-implemented' ) ) |
|
127 | - ->withEntityId( new ItemId( $constraint->getConstraintTypeItemId() ), Role::CONSTRAINT_TYPE_ITEM ); |
|
126 | + $message = (new ViolationMessage('wbqc-violation-message-not-yet-implemented')) |
|
127 | + ->withEntityId(new ItemId($constraint->getConstraintTypeItemId()), Role::CONSTRAINT_TYPE_ITEM); |
|
128 | 128 | $metadata = Metadata::blank(); |
129 | 129 | } |
130 | 130 | |
131 | - return ( new CheckResult( $context, $constraint, $parameters, $status, $message ) ) |
|
132 | - ->withMetadata( $metadata ); |
|
131 | + return (new CheckResult($context, $constraint, $parameters, $status, $message)) |
|
132 | + ->withMetadata($metadata); |
|
133 | 133 | } |
134 | 134 | |
135 | - public function checkConstraintParameters( Constraint $constraint ) { |
|
135 | + public function checkConstraintParameters(Constraint $constraint) { |
|
136 | 136 | $constraintParameters = $constraint->getConstraintParameters(); |
137 | 137 | $exceptions = []; |
138 | 138 | try { |
139 | - $this->constraintParameterParser->parseSeparatorsParameter( $constraintParameters ); |
|
140 | - } catch ( ConstraintParameterException $e ) { |
|
139 | + $this->constraintParameterParser->parseSeparatorsParameter($constraintParameters); |
|
140 | + } catch (ConstraintParameterException $e) { |
|
141 | 141 | $exceptions[] = $e; |
142 | 142 | } |
143 | 143 | return $exceptions; |
@@ -38,206 +38,206 @@ |
||
38 | 38 | use WikibaseQuality\ConstraintReport\ConstraintCheck\Checker\ValueTypeChecker; |
39 | 39 | |
40 | 40 | return [ |
41 | - ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => static function ( MediaWikiServices $services ) { |
|
41 | + ConstraintCheckerServices::CONFLICTS_WITH_CHECKER => static function(MediaWikiServices $services) { |
|
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 ) { |
|
48 | + ConstraintCheckerServices::ITEM_CHECKER => static function(MediaWikiServices $services) { |
|
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 ( MediaWikiServices $services ) { |
|
55 | + ConstraintCheckerServices::TARGET_REQUIRED_CLAIM_CHECKER => static function(MediaWikiServices $services) { |
|
56 | 56 | return new TargetRequiredClaimChecker( |
57 | - WikibaseServices::getEntityLookup( $services ), |
|
58 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
59 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
57 | + WikibaseServices::getEntityLookup($services), |
|
58 | + ConstraintsServices::getConstraintParameterParser($services), |
|
59 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
60 | 60 | ); |
61 | 61 | }, |
62 | 62 | |
63 | - ConstraintCheckerServices::SYMMETRIC_CHECKER => static function ( MediaWikiServices $services ) { |
|
63 | + ConstraintCheckerServices::SYMMETRIC_CHECKER => static function(MediaWikiServices $services) { |
|
64 | 64 | return new SymmetricChecker( |
65 | - WikibaseServices::getEntityLookupWithoutCache( $services ), |
|
66 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
65 | + WikibaseServices::getEntityLookupWithoutCache($services), |
|
66 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
67 | 67 | ); |
68 | 68 | }, |
69 | 69 | |
70 | - ConstraintCheckerServices::INVERSE_CHECKER => static function ( MediaWikiServices $services ) { |
|
70 | + ConstraintCheckerServices::INVERSE_CHECKER => static function(MediaWikiServices $services) { |
|
71 | 71 | return new InverseChecker( |
72 | - WikibaseServices::getEntityLookup( $services ), |
|
73 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
74 | - ConstraintsServices::getConnectionCheckerHelper( $services ) |
|
72 | + WikibaseServices::getEntityLookup($services), |
|
73 | + ConstraintsServices::getConstraintParameterParser($services), |
|
74 | + ConstraintsServices::getConnectionCheckerHelper($services) |
|
75 | 75 | ); |
76 | 76 | }, |
77 | 77 | |
78 | - ConstraintCheckerServices::QUALIFIER_CHECKER => static function ( MediaWikiServices $services ) { |
|
78 | + ConstraintCheckerServices::QUALIFIER_CHECKER => static function(MediaWikiServices $services) { |
|
79 | 79 | return new QualifierChecker(); |
80 | 80 | }, |
81 | 81 | |
82 | - ConstraintCheckerServices::QUALIFIERS_CHECKER => static function ( MediaWikiServices $services ) { |
|
82 | + ConstraintCheckerServices::QUALIFIERS_CHECKER => static function(MediaWikiServices $services) { |
|
83 | 83 | return new QualifiersChecker( |
84 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
84 | + ConstraintsServices::getConstraintParameterParser($services) |
|
85 | 85 | ); |
86 | 86 | }, |
87 | 87 | |
88 | - ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => static function ( MediaWikiServices $services ) { |
|
88 | + ConstraintCheckerServices::MANDATORY_QUALIFIERS_CHECKER => static function(MediaWikiServices $services) { |
|
89 | 89 | return new MandatoryQualifiersChecker( |
90 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
90 | + ConstraintsServices::getConstraintParameterParser($services) |
|
91 | 91 | ); |
92 | 92 | }, |
93 | 93 | |
94 | - ConstraintCheckerServices::RANGE_CHECKER => static function ( MediaWikiServices $services ) { |
|
94 | + ConstraintCheckerServices::RANGE_CHECKER => static function(MediaWikiServices $services) { |
|
95 | 95 | return new RangeChecker( |
96 | - WikibaseServices::getPropertyDataTypeLookup( $services ), |
|
97 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
98 | - ConstraintsServices::getRangeCheckerHelper( $services ) |
|
96 | + WikibaseServices::getPropertyDataTypeLookup($services), |
|
97 | + ConstraintsServices::getConstraintParameterParser($services), |
|
98 | + ConstraintsServices::getRangeCheckerHelper($services) |
|
99 | 99 | ); |
100 | 100 | }, |
101 | 101 | |
102 | - ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => static function ( MediaWikiServices $services ) { |
|
102 | + ConstraintCheckerServices::DIFF_WITHIN_RANGE_CHECKER => static function(MediaWikiServices $services) { |
|
103 | 103 | return new DiffWithinRangeChecker( |
104 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
105 | - ConstraintsServices::getRangeCheckerHelper( $services ), |
|
104 | + ConstraintsServices::getConstraintParameterParser($services), |
|
105 | + ConstraintsServices::getRangeCheckerHelper($services), |
|
106 | 106 | $services->getMainConfig() |
107 | 107 | ); |
108 | 108 | }, |
109 | 109 | |
110 | - ConstraintCheckerServices::TYPE_CHECKER => static function ( MediaWikiServices $services ) { |
|
110 | + ConstraintCheckerServices::TYPE_CHECKER => static function(MediaWikiServices $services) { |
|
111 | 111 | return new TypeChecker( |
112 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
113 | - ConstraintsServices::getTypeCheckerHelper( $services ), |
|
112 | + ConstraintsServices::getConstraintParameterParser($services), |
|
113 | + ConstraintsServices::getTypeCheckerHelper($services), |
|
114 | 114 | $services->getMainConfig() |
115 | 115 | ); |
116 | 116 | }, |
117 | 117 | |
118 | - ConstraintCheckerServices::VALUE_TYPE_CHECKER => static function ( MediaWikiServices $services ) { |
|
118 | + ConstraintCheckerServices::VALUE_TYPE_CHECKER => static function(MediaWikiServices $services) { |
|
119 | 119 | return new ValueTypeChecker( |
120 | - WikibaseServices::getEntityLookup( $services ), |
|
121 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
122 | - ConstraintsServices::getTypeCheckerHelper( $services ), |
|
120 | + WikibaseServices::getEntityLookup($services), |
|
121 | + ConstraintsServices::getConstraintParameterParser($services), |
|
122 | + ConstraintsServices::getTypeCheckerHelper($services), |
|
123 | 123 | $services->getMainConfig() |
124 | 124 | ); |
125 | 125 | }, |
126 | 126 | |
127 | - ConstraintCheckerServices::SINGLE_VALUE_CHECKER => static function ( MediaWikiServices $services ) { |
|
127 | + ConstraintCheckerServices::SINGLE_VALUE_CHECKER => static function(MediaWikiServices $services) { |
|
128 | 128 | return new SingleValueChecker( |
129 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
129 | + ConstraintsServices::getConstraintParameterParser($services) |
|
130 | 130 | ); |
131 | 131 | }, |
132 | 132 | |
133 | - ConstraintCheckerServices::MULTI_VALUE_CHECKER => static function ( MediaWikiServices $services ) { |
|
133 | + ConstraintCheckerServices::MULTI_VALUE_CHECKER => static function(MediaWikiServices $services) { |
|
134 | 134 | return new MultiValueChecker( |
135 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
135 | + ConstraintsServices::getConstraintParameterParser($services) |
|
136 | 136 | ); |
137 | 137 | }, |
138 | 138 | |
139 | - ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => static function ( MediaWikiServices $services ) { |
|
139 | + ConstraintCheckerServices::UNIQUE_VALUE_CHECKER => static function(MediaWikiServices $services) { |
|
140 | 140 | // TODO return a different, dummy implementation if SPARQL is not available |
141 | 141 | return new UniqueValueChecker( |
142 | - ConstraintsServices::getSparqlHelper( $services ), |
|
143 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
142 | + ConstraintsServices::getSparqlHelper($services), |
|
143 | + ConstraintsServices::getConstraintParameterParser($services) |
|
144 | 144 | ); |
145 | 145 | }, |
146 | 146 | |
147 | - ConstraintCheckerServices::FORMAT_CHECKER => static function ( MediaWikiServices $services ) { |
|
147 | + ConstraintCheckerServices::FORMAT_CHECKER => static function(MediaWikiServices $services) { |
|
148 | 148 | // TODO return a different, dummy implementation if SPARQL is not available |
149 | 149 | return new FormatChecker( |
150 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
150 | + ConstraintsServices::getConstraintParameterParser($services), |
|
151 | 151 | $services->getMainConfig(), |
152 | - ConstraintsServices::getSparqlHelper( $services ), |
|
152 | + ConstraintsServices::getSparqlHelper($services), |
|
153 | 153 | $services->getShellboxClientFactory() |
154 | 154 | ); |
155 | 155 | }, |
156 | 156 | |
157 | - ConstraintCheckerServices::COMMONS_LINK_CHECKER => static function ( MediaWikiServices $services ) { |
|
157 | + ConstraintCheckerServices::COMMONS_LINK_CHECKER => static function(MediaWikiServices $services) { |
|
158 | 158 | $pageNameNormalizer = new MediaWikiPageNameNormalizer(); |
159 | 159 | return new CommonsLinkChecker( |
160 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
160 | + ConstraintsServices::getConstraintParameterParser($services), |
|
161 | 161 | $pageNameNormalizer, |
162 | - WikibaseRepo::getPropertyDataTypeLookup( $services ) |
|
162 | + WikibaseRepo::getPropertyDataTypeLookup($services) |
|
163 | 163 | ); |
164 | 164 | }, |
165 | 165 | |
166 | - ConstraintCheckerServices::ONE_OF_CHECKER => static function ( MediaWikiServices $services ) { |
|
166 | + ConstraintCheckerServices::ONE_OF_CHECKER => static function(MediaWikiServices $services) { |
|
167 | 167 | return new OneOfChecker( |
168 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
168 | + ConstraintsServices::getConstraintParameterParser($services) |
|
169 | 169 | ); |
170 | 170 | }, |
171 | 171 | |
172 | - ConstraintCheckerServices::VALUE_ONLY_CHECKER => static function ( MediaWikiServices $services ) { |
|
172 | + ConstraintCheckerServices::VALUE_ONLY_CHECKER => static function(MediaWikiServices $services) { |
|
173 | 173 | return new ValueOnlyChecker(); |
174 | 174 | }, |
175 | 175 | |
176 | - ConstraintCheckerServices::REFERENCE_CHECKER => static function ( MediaWikiServices $services ) { |
|
176 | + ConstraintCheckerServices::REFERENCE_CHECKER => static function(MediaWikiServices $services) { |
|
177 | 177 | return new ReferenceChecker(); |
178 | 178 | }, |
179 | 179 | |
180 | - ConstraintCheckerServices::NO_BOUNDS_CHECKER => static function ( MediaWikiServices $services ) { |
|
180 | + ConstraintCheckerServices::NO_BOUNDS_CHECKER => static function(MediaWikiServices $services) { |
|
181 | 181 | return new NoBoundsChecker(); |
182 | 182 | }, |
183 | 183 | |
184 | - ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => static function ( MediaWikiServices $services ) { |
|
184 | + ConstraintCheckerServices::ALLOWED_UNITS_CHECKER => static function(MediaWikiServices $services) { |
|
185 | 185 | return new AllowedUnitsChecker( |
186 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
187 | - WikibaseRepo::getUnitConverter( $services ) |
|
186 | + ConstraintsServices::getConstraintParameterParser($services), |
|
187 | + WikibaseRepo::getUnitConverter($services) |
|
188 | 188 | ); |
189 | 189 | }, |
190 | 190 | |
191 | - ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => static function ( MediaWikiServices $services ) { |
|
191 | + ConstraintCheckerServices::SINGLE_BEST_VALUE_CHECKER => static function(MediaWikiServices $services) { |
|
192 | 192 | return new SingleBestValueChecker( |
193 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
193 | + ConstraintsServices::getConstraintParameterParser($services) |
|
194 | 194 | ); |
195 | 195 | }, |
196 | 196 | |
197 | - ConstraintCheckerServices::ENTITY_TYPE_CHECKER => static function ( MediaWikiServices $services ) { |
|
197 | + ConstraintCheckerServices::ENTITY_TYPE_CHECKER => static function(MediaWikiServices $services) { |
|
198 | 198 | return new EntityTypeChecker( |
199 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
199 | + ConstraintsServices::getConstraintParameterParser($services) |
|
200 | 200 | ); |
201 | 201 | }, |
202 | 202 | |
203 | - ConstraintCheckerServices::NONE_OF_CHECKER => static function ( MediaWikiServices $services ) { |
|
203 | + ConstraintCheckerServices::NONE_OF_CHECKER => static function(MediaWikiServices $services) { |
|
204 | 204 | return new NoneOfChecker( |
205 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
205 | + ConstraintsServices::getConstraintParameterParser($services) |
|
206 | 206 | ); |
207 | 207 | }, |
208 | 208 | |
209 | - ConstraintCheckerServices::INTEGER_CHECKER => static function ( MediaWikiServices $services ) { |
|
209 | + ConstraintCheckerServices::INTEGER_CHECKER => static function(MediaWikiServices $services) { |
|
210 | 210 | return new IntegerChecker(); |
211 | 211 | }, |
212 | 212 | |
213 | - ConstraintCheckerServices::CITATION_NEEDED_CHECKER => static function ( MediaWikiServices $services ) { |
|
213 | + ConstraintCheckerServices::CITATION_NEEDED_CHECKER => static function(MediaWikiServices $services) { |
|
214 | 214 | return new CitationNeededChecker(); |
215 | 215 | }, |
216 | 216 | |
217 | - ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => static function ( MediaWikiServices $services ) { |
|
217 | + ConstraintCheckerServices::PROPERTY_SCOPE_CHECKER => static function(MediaWikiServices $services) { |
|
218 | 218 | return new PropertyScopeChecker( |
219 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
219 | + ConstraintsServices::getConstraintParameterParser($services) |
|
220 | 220 | ); |
221 | 221 | }, |
222 | 222 | |
223 | - ConstraintCheckerServices::CONTEMPORARY_CHECKER => static function ( MediaWikiServices $services ) { |
|
223 | + ConstraintCheckerServices::CONTEMPORARY_CHECKER => static function(MediaWikiServices $services) { |
|
224 | 224 | return new ContemporaryChecker( |
225 | - WikibaseServices::getEntityLookup( $services ), |
|
226 | - ConstraintsServices::getRangeCheckerHelper( $services ), |
|
225 | + WikibaseServices::getEntityLookup($services), |
|
226 | + ConstraintsServices::getRangeCheckerHelper($services), |
|
227 | 227 | $services->getMainConfig() |
228 | 228 | ); |
229 | 229 | }, |
230 | 230 | |
231 | - ConstraintCheckerServices::LEXEME_LANGUAGE_CHECKER => static function ( MediaWikiServices $services ) { |
|
231 | + ConstraintCheckerServices::LEXEME_LANGUAGE_CHECKER => static function(MediaWikiServices $services) { |
|
232 | 232 | return new LanguageChecker( |
233 | - ConstraintsServices::getConstraintParameterParser( $services ), |
|
234 | - WikibaseServices::getEntityLookup( $services ) |
|
233 | + ConstraintsServices::getConstraintParameterParser($services), |
|
234 | + WikibaseServices::getEntityLookup($services) |
|
235 | 235 | ); |
236 | 236 | }, |
237 | 237 | |
238 | - ConstraintCheckerServices::LABEL_IN_LANGUAGE_CHECKER => static function ( MediaWikiServices $services ) { |
|
238 | + ConstraintCheckerServices::LABEL_IN_LANGUAGE_CHECKER => static function(MediaWikiServices $services) { |
|
239 | 239 | return new LabelInLanguageChecker( |
240 | - ConstraintsServices::getConstraintParameterParser( $services ) |
|
240 | + ConstraintsServices::getConstraintParameterParser($services) |
|
241 | 241 | ); |
242 | 242 | }, |
243 | 243 | ]; |