@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | public function __construct( |
92 | 92 | $messageKey |
93 | 93 | ) { |
94 | - if ( strpos( $messageKey, self::MESSAGE_KEY_PREFIX ) !== 0 ) { |
|
94 | + if (strpos($messageKey, self::MESSAGE_KEY_PREFIX) !== 0) { |
|
95 | 95 | throw new InvalidArgumentException( |
96 | - 'ViolationMessage key ⧼' . |
|
97 | - $messageKey . |
|
98 | - '⧽ should start with "' . |
|
99 | - self::MESSAGE_KEY_PREFIX . |
|
96 | + 'ViolationMessage key ⧼'. |
|
97 | + $messageKey. |
|
98 | + '⧽ should start with "'. |
|
99 | + self::MESSAGE_KEY_PREFIX. |
|
100 | 100 | '".' |
101 | 101 | ); |
102 | 102 | } |
103 | 103 | |
104 | - $this->messageKeySuffix = substr( $messageKey, strlen( self::MESSAGE_KEY_PREFIX ) ); |
|
104 | + $this->messageKeySuffix = substr($messageKey, strlen(self::MESSAGE_KEY_PREFIX)); |
|
105 | 105 | $this->arguments = []; |
106 | 106 | } |
107 | 107 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @return string |
111 | 111 | */ |
112 | 112 | public function getMessageKey() { |
113 | - return self::MESSAGE_KEY_PREFIX . $this->messageKeySuffix; |
|
113 | + return self::MESSAGE_KEY_PREFIX.$this->messageKeySuffix; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | * @param mixed $value the value, which should match the $type |
129 | 129 | * @return ViolationMessage |
130 | 130 | */ |
131 | - private function withArgument( $type, $role, $value ) { |
|
131 | + private function withArgument($type, $role, $value) { |
|
132 | 132 | $ret = clone $this; |
133 | - $ret->arguments[] = [ 'type' => $type, 'role' => $role, 'value' => $value ]; |
|
133 | + $ret->arguments[] = ['type' => $type, 'role' => $role, 'value' => $value]; |
|
134 | 134 | return $ret; |
135 | 135 | } |
136 | 136 | |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | * @param string|null $role one of the Role::* constants |
143 | 143 | * @return ViolationMessage |
144 | 144 | */ |
145 | - public function withEntityId( EntityId $entityId, $role = null ) { |
|
146 | - return $this->withArgument( self::TYPE_ENTITY_ID, $role, $entityId ); |
|
145 | + public function withEntityId(EntityId $entityId, $role = null) { |
|
146 | + return $this->withArgument(self::TYPE_ENTITY_ID, $role, $entityId); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @param string|null $role one of the Role::* constants |
161 | 161 | * @return ViolationMessage |
162 | 162 | */ |
163 | - public function withEntityIdList( array $entityIdList, $role = null ) { |
|
164 | - return $this->withArgument( self::TYPE_ENTITY_ID_LIST, $role, $entityIdList ); |
|
163 | + public function withEntityIdList(array $entityIdList, $role = null) { |
|
164 | + return $this->withArgument(self::TYPE_ENTITY_ID_LIST, $role, $entityIdList); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @param string|null $role one of the Role::* constants |
173 | 173 | * @return ViolationMessage |
174 | 174 | */ |
175 | - public function withItemIdSnakValue( ItemIdSnakValue $value, $role = null ) { |
|
176 | - return $this->withArgument( self::TYPE_ITEM_ID_SNAK_VALUE, $role, $value ); |
|
175 | + public function withItemIdSnakValue(ItemIdSnakValue $value, $role = null) { |
|
176 | + return $this->withArgument(self::TYPE_ITEM_ID_SNAK_VALUE, $role, $value); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | * @param string|null $role one of the Role::* constants |
191 | 191 | * @return ViolationMessage |
192 | 192 | */ |
193 | - public function withItemIdSnakValueList( array $valueList, $role = null ) { |
|
194 | - return $this->withArgument( self::TYPE_ITEM_ID_SNAK_VALUE_LIST, $role, $valueList ); |
|
193 | + public function withItemIdSnakValueList(array $valueList, $role = null) { |
|
194 | + return $this->withArgument(self::TYPE_ITEM_ID_SNAK_VALUE_LIST, $role, $valueList); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | * @param string|null $role one of the Role::* constants |
203 | 203 | * @return ViolationMessage |
204 | 204 | */ |
205 | - public function withDataValue( DataValue $dataValue, $role = null ) { |
|
206 | - return $this->withArgument( self::TYPE_DATA_VALUE, $role, $dataValue ); |
|
205 | + public function withDataValue(DataValue $dataValue, $role = null) { |
|
206 | + return $this->withArgument(self::TYPE_DATA_VALUE, $role, $dataValue); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | * @param string|null $role one of the Role::* constants |
219 | 219 | * @return ViolationMessage |
220 | 220 | */ |
221 | - public function withDataValueType( $dataValueType, $role = null ) { |
|
222 | - return $this->withArgument( self::TYPE_DATA_VALUE_TYPE, $role, $dataValueType ); |
|
221 | + public function withDataValueType($dataValueType, $role = null) { |
|
222 | + return $this->withArgument(self::TYPE_DATA_VALUE_TYPE, $role, $dataValueType); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @param string|null $role one of the Role::* constants |
231 | 231 | * @return ViolationMessage |
232 | 232 | */ |
233 | - public function withInlineCode( $code, $role = null ) { |
|
234 | - return $this->withArgument( self::TYPE_INLINE_CODE, $role, $code ); |
|
233 | + public function withInlineCode($code, $role = null) { |
|
234 | + return $this->withArgument(self::TYPE_INLINE_CODE, $role, $code); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | * @param string|null $role one of the Role::* constants |
243 | 243 | * @return ViolationMessage |
244 | 244 | */ |
245 | - public function withConstraintScope( $scope, $role = null ) { |
|
246 | - return $this->withArgument( self::TYPE_CONSTRAINT_SCOPE, $role, $scope ); |
|
245 | + public function withConstraintScope($scope, $role = null) { |
|
246 | + return $this->withArgument(self::TYPE_CONSTRAINT_SCOPE, $role, $scope); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | } |
@@ -65,31 +65,31 @@ discard block |
||
65 | 65 | * (temporarily, pre-rendered strings are allowed and returned without changes) |
66 | 66 | * @return string |
67 | 67 | */ |
68 | - public function render( $violationMessage ) { |
|
69 | - if ( is_string( $violationMessage ) ) { |
|
68 | + public function render($violationMessage) { |
|
69 | + if (is_string($violationMessage)) { |
|
70 | 70 | // TODO remove this once all checkers produce ViolationMessage objects |
71 | 71 | return $violationMessage; |
72 | 72 | } |
73 | 73 | |
74 | 74 | $messageKey = $violationMessage->getMessageKey(); |
75 | - $paramsLists = [ [] ]; |
|
76 | - foreach ( $violationMessage->getArguments() as $argument ) { |
|
77 | - $params = $this->renderArgument( $argument ); |
|
75 | + $paramsLists = [[]]; |
|
76 | + foreach ($violationMessage->getArguments() as $argument) { |
|
77 | + $params = $this->renderArgument($argument); |
|
78 | 78 | $paramsLists[] = $params; |
79 | 79 | } |
80 | - $allParams = call_user_func_array( 'array_merge', $paramsLists ); |
|
81 | - return ( new Message( $messageKey ) ) |
|
82 | - ->params( $allParams ) |
|
80 | + $allParams = call_user_func_array('array_merge', $paramsLists); |
|
81 | + return (new Message($messageKey)) |
|
82 | + ->params($allParams) |
|
83 | 83 | ->escaped(); |
84 | 84 | } |
85 | 85 | |
86 | - private function addRole( $value, $role ) { |
|
87 | - if ( $role === null ) { |
|
86 | + private function addRole($value, $role) { |
|
87 | + if ($role === null) { |
|
88 | 88 | return $value; |
89 | 89 | } |
90 | 90 | |
91 | - return '<span class="wbqc-role wbqc-role-' . htmlspecialchars( $role ) . '">' . |
|
92 | - $value . |
|
91 | + return '<span class="wbqc-role wbqc-role-'.htmlspecialchars($role).'">'. |
|
92 | + $value. |
|
93 | 93 | '</span>'; |
94 | 94 | } |
95 | 95 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param array $argument |
98 | 98 | * @return array params (for Message::params) |
99 | 99 | */ |
100 | - private function renderArgument( array $argument ) { |
|
100 | + private function renderArgument(array $argument) { |
|
101 | 101 | $methods = [ |
102 | 102 | ViolationMessage::TYPE_ENTITY_ID => 'renderEntityId', |
103 | 103 | ViolationMessage::TYPE_ENTITY_ID_LIST => 'renderEntityIdList', |
@@ -113,55 +113,55 @@ discard block |
||
113 | 113 | $value = $argument['value']; |
114 | 114 | $role = $argument['role']; |
115 | 115 | |
116 | - if ( array_key_exists( $type, $methods ) ) { |
|
116 | + if (array_key_exists($type, $methods)) { |
|
117 | 117 | $method = $methods[$type]; |
118 | - $params = $this->$method( $value, $role ); |
|
118 | + $params = $this->$method($value, $role); |
|
119 | 119 | } else { |
120 | 120 | throw new InvalidArgumentException( |
121 | - 'Unknown ViolationMessage argument type ' . $type . '!' |
|
121 | + 'Unknown ViolationMessage argument type '.$type.'!' |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 | |
125 | - if ( !array_key_exists( 0, $params ) ) { |
|
126 | - $params = [ $params ]; |
|
125 | + if (!array_key_exists(0, $params)) { |
|
126 | + $params = [$params]; |
|
127 | 127 | } |
128 | 128 | return $params; |
129 | 129 | } |
130 | 130 | |
131 | - private function renderList( array $list, $role, callable $render ) { |
|
132 | - if ( $list === [] ) { |
|
131 | + private function renderList(array $list, $role, callable $render) { |
|
132 | + if ($list === []) { |
|
133 | 133 | return [ |
134 | - Message::numParam( 0 ), |
|
135 | - Message::rawParam( '<ul></ul>' ), |
|
134 | + Message::numParam(0), |
|
135 | + Message::rawParam('<ul></ul>'), |
|
136 | 136 | ]; |
137 | 137 | } |
138 | 138 | |
139 | - if ( count( $list ) > $this->maxListLength ) { |
|
140 | - $list = array_slice( $list, 0, $this->maxListLength ); |
|
139 | + if (count($list) > $this->maxListLength) { |
|
140 | + $list = array_slice($list, 0, $this->maxListLength); |
|
141 | 141 | $truncated = true; |
142 | 142 | } |
143 | 143 | |
144 | 144 | $renderedParams = array_map( |
145 | 145 | $render, |
146 | 146 | $list, |
147 | - array_fill( 0, count( $list ), $role ) |
|
147 | + array_fill(0, count($list), $role) |
|
148 | 148 | ); |
149 | 149 | $renderedElements = array_map( |
150 | - function ( $param ) { |
|
150 | + function($param) { |
|
151 | 151 | return $param['raw']; |
152 | 152 | }, |
153 | 153 | $renderedParams |
154 | 154 | ); |
155 | - if ( isset( $truncated ) ) { |
|
156 | - $renderedElements[] = wfMessage( 'ellipsis' )->escaped(); |
|
155 | + if (isset($truncated)) { |
|
156 | + $renderedElements[] = wfMessage('ellipsis')->escaped(); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return array_merge( |
160 | 160 | [ |
161 | - Message::numParam( count( $list ) ), |
|
161 | + Message::numParam(count($list)), |
|
162 | 162 | Message::rawParam( |
163 | - '<ul><li>' . |
|
164 | - implode( '</li><li>', $renderedElements ) . |
|
163 | + '<ul><li>'. |
|
164 | + implode('</li><li>', $renderedElements). |
|
165 | 165 | '</li></ul>' |
166 | 166 | ), |
167 | 167 | ], |
@@ -169,35 +169,35 @@ discard block |
||
169 | 169 | ); |
170 | 170 | } |
171 | 171 | |
172 | - private function renderEntityId( EntityId $entityId, $role ) { |
|
173 | - return Message::rawParam( $this->addRole( |
|
174 | - $this->entityIdFormatter->formatEntityId( $entityId ), |
|
172 | + private function renderEntityId(EntityId $entityId, $role) { |
|
173 | + return Message::rawParam($this->addRole( |
|
174 | + $this->entityIdFormatter->formatEntityId($entityId), |
|
175 | 175 | $role |
176 | - ) ); |
|
176 | + )); |
|
177 | 177 | } |
178 | 178 | |
179 | - private function renderEntityIdList( array $entityIdList, $role ) { |
|
180 | - return $this->renderList( $entityIdList, $role, [ $this, 'renderEntityId' ] ); |
|
179 | + private function renderEntityIdList(array $entityIdList, $role) { |
|
180 | + return $this->renderList($entityIdList, $role, [$this, 'renderEntityId']); |
|
181 | 181 | } |
182 | 182 | |
183 | - private function renderItemIdSnakValue( ItemIdSnakValue $value, $role ) { |
|
184 | - switch ( true ) { |
|
183 | + private function renderItemIdSnakValue(ItemIdSnakValue $value, $role) { |
|
184 | + switch (true) { |
|
185 | 185 | case $value->isValue(): |
186 | - return $this->renderEntityId( $value->getItemId(), $role ); |
|
186 | + return $this->renderEntityId($value->getItemId(), $role); |
|
187 | 187 | case $value->isSomeValue(): |
188 | - return Message::rawParam( $this->addRole( |
|
189 | - '<span class="wikibase-snakview-variation-somevaluesnak">' . |
|
190 | - wfMessage( 'wikibase-snakview-snaktypeselector-somevalue' )->escaped() . |
|
188 | + return Message::rawParam($this->addRole( |
|
189 | + '<span class="wikibase-snakview-variation-somevaluesnak">'. |
|
190 | + wfMessage('wikibase-snakview-snaktypeselector-somevalue')->escaped(). |
|
191 | 191 | '</span>', |
192 | 192 | $role |
193 | - ) ); |
|
193 | + )); |
|
194 | 194 | case $value->isNoValue(): |
195 | - return Message::rawParam( $this->addRole( |
|
196 | - '<span class="wikibase-snakview-variation-novaluesnak">' . |
|
197 | - wfMessage( 'wikibase-snakview-snaktypeselector-novalue' )->escaped() . |
|
195 | + return Message::rawParam($this->addRole( |
|
196 | + '<span class="wikibase-snakview-variation-novaluesnak">'. |
|
197 | + wfMessage('wikibase-snakview-snaktypeselector-novalue')->escaped(). |
|
198 | 198 | '</span>', |
199 | 199 | $role |
200 | - ) ); |
|
200 | + )); |
|
201 | 201 | default: |
202 | 202 | // @codeCoverageIgnoreStart |
203 | 203 | throw new LogicException( |
@@ -207,47 +207,47 @@ discard block |
||
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
210 | - private function renderItemIdSnakValueList( array $valueList, $role ) { |
|
211 | - return $this->renderList( $valueList, $role, [ $this, 'renderItemIdSnakValue' ] ); |
|
210 | + private function renderItemIdSnakValueList(array $valueList, $role) { |
|
211 | + return $this->renderList($valueList, $role, [$this, 'renderItemIdSnakValue']); |
|
212 | 212 | } |
213 | 213 | |
214 | - private function renderDataValue( DataValue $dataValue, $role ) { |
|
215 | - return Message::rawParam( $this->addRole( |
|
216 | - $this->dataValueFormatter->format( $dataValue ), |
|
214 | + private function renderDataValue(DataValue $dataValue, $role) { |
|
215 | + return Message::rawParam($this->addRole( |
|
216 | + $this->dataValueFormatter->format($dataValue), |
|
217 | 217 | $role |
218 | - ) ); |
|
218 | + )); |
|
219 | 219 | } |
220 | 220 | |
221 | - private function renderDataValueType( $dataValueType, $role ) { |
|
221 | + private function renderDataValueType($dataValueType, $role) { |
|
222 | 222 | $messageKeys = [ |
223 | 223 | 'string' => 'datatypes-type-string', |
224 | 224 | 'monolingualtext' => 'datatypes-monolingualtext', |
225 | 225 | 'wikibase-entityid' => 'wbqc-dataValueType-wikibase-entityid', |
226 | 226 | ]; |
227 | 227 | |
228 | - if ( array_key_exists( $dataValueType, $messageKeys ) ) { |
|
229 | - return Message::rawParam( $this->addRole( |
|
230 | - wfMessage( $messageKeys[$dataValueType] )->escaped(), |
|
228 | + if (array_key_exists($dataValueType, $messageKeys)) { |
|
229 | + return Message::rawParam($this->addRole( |
|
230 | + wfMessage($messageKeys[$dataValueType])->escaped(), |
|
231 | 231 | $role |
232 | - ) ); |
|
232 | + )); |
|
233 | 233 | } else { |
234 | 234 | // @codeCoverageIgnoreStart |
235 | 235 | throw new LogicException( |
236 | - 'Unknown data value type ' . $dataValueType |
|
236 | + 'Unknown data value type '.$dataValueType |
|
237 | 237 | ); |
238 | 238 | // @codeCoverageIgnoreEnd |
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | - private function renderInlineCode( $code, $role ) { |
|
243 | - return Message::rawParam( $this->addRole( |
|
244 | - '<code>' . htmlspecialchars( $code ) . '</code>', |
|
242 | + private function renderInlineCode($code, $role) { |
|
243 | + return Message::rawParam($this->addRole( |
|
244 | + '<code>'.htmlspecialchars($code).'</code>', |
|
245 | 245 | $role |
246 | - ) ); |
|
246 | + )); |
|
247 | 247 | } |
248 | 248 | |
249 | - private function renderConstraintScope( $scope, $role ) { |
|
250 | - switch ( $scope ) { |
|
249 | + private function renderConstraintScope($scope, $role) { |
|
250 | + switch ($scope) { |
|
251 | 251 | case Context::TYPE_STATEMENT: |
252 | 252 | $itemId = $this->config->get( |
253 | 253 | 'WBQualityConstraintsConstraintCheckedOnMainValueId' |
@@ -267,10 +267,10 @@ discard block |
||
267 | 267 | // callers should never let this happen, but if it does happen, |
268 | 268 | // showing “unknown value” seems reasonable |
269 | 269 | // @codeCoverageIgnoreStart |
270 | - return $this->renderItemIdSnakValue( ItemIdSnakValue::someValue(), $role ); |
|
270 | + return $this->renderItemIdSnakValue(ItemIdSnakValue::someValue(), $role); |
|
271 | 271 | // @codeCoverageIgnoreEnd |
272 | 272 | } |
273 | - return $this->renderEntityId( new ItemId( $itemId ), $role ); |
|
273 | + return $this->renderEntityId(new ItemId($itemId), $role); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | } |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return self |
79 | 79 | */ |
80 | - public static function newFromGlobalState( ApiMain $main, $name, $prefix = '' ) { |
|
80 | + public static function newFromGlobalState(ApiMain $main, $name, $prefix = '') { |
|
81 | 81 | $repo = WikibaseRepo::getDefaultInstance(); |
82 | 82 | |
83 | 83 | $language = $repo->getUserLanguage(); |
84 | 84 | $formatterOptions = new FormatterOptions(); |
85 | - $formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
85 | + $formatterOptions->setOption(SnakFormatter::OPT_LANG, $language->getCode()); |
|
86 | 86 | $valueFormatterFactory = $repo->getValueFormatterFactory(); |
87 | - $valueFormatter = $valueFormatterFactory->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ); |
|
87 | + $valueFormatter = $valueFormatterFactory->getValueFormatter(SnakFormatter::FORMAT_HTML, $formatterOptions); |
|
88 | 88 | |
89 | 89 | $languageFallbackLabelDescriptionLookupFactory = $repo->getLanguageFallbackLabelDescriptionLookupFactory(); |
90 | - $labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup( $language ); |
|
90 | + $labelDescriptionLookup = $languageFallbackLabelDescriptionLookupFactory->newLabelDescriptionLookup($language); |
|
91 | 91 | $entityIdHtmlLinkFormatterFactory = $repo->getEntityIdHtmlLinkFormatterFactory(); |
92 | - $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup ); |
|
92 | + $entityIdHtmlLinkFormatter = $entityIdHtmlLinkFormatterFactory->getEntityIdFormatter($labelDescriptionLookup); |
|
93 | 93 | $entityIdLabelFormatterFactory = new EntityIdLabelFormatterFactory(); |
94 | - $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter( $labelDescriptionLookup ); |
|
94 | + $entityIdLabelFormatter = $entityIdLabelFormatterFactory->getEntityIdFormatter($labelDescriptionLookup); |
|
95 | 95 | $config = MediaWikiServices::getInstance()->getMainConfig(); |
96 | 96 | $titleParser = MediaWikiServices::getInstance()->getTitleParser(); |
97 | 97 | $unitConverter = $repo->getUnitConverter(); |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | $repo->getEntityTitleLookup(), |
125 | 125 | $entityIdLabelFormatter, |
126 | 126 | $constraintParameterRenderer, |
127 | - new ViolationMessageRenderer( $entityIdHtmlLinkFormatter, $valueFormatter, $config ), |
|
127 | + new ViolationMessageRenderer($entityIdHtmlLinkFormatter, $valueFormatter, $config), |
|
128 | 128 | $config |
129 | 129 | ); |
130 | - if ( $config->get( 'WBQualityConstraintsCacheCheckConstraintsResults' ) ) { |
|
130 | + if ($config->get('WBQualityConstraintsCacheCheckConstraintsResults')) { |
|
131 | 131 | $wikiPageEntityMetaDataAccessor = new WikiPageEntityMetaDataLookup( |
132 | 132 | $repo->getEntityNamespaceLookup() |
133 | 133 | ); |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | ResultsCache::getDefaultInstance(), |
139 | 139 | $wikiPageEntityMetaDataAccessor, |
140 | 140 | $entityIdParser, |
141 | - $config->get( 'WBQualityConstraintsCacheCheckConstraintsTTLSeconds' ), |
|
141 | + $config->get('WBQualityConstraintsCacheCheckConstraintsTTLSeconds'), |
|
142 | 142 | [ |
143 | - $config->get( 'WBQualityConstraintsCommonsLinkConstraintId' ), |
|
144 | - $config->get( 'WBQualityConstraintsTypeConstraintId' ), |
|
145 | - $config->get( 'WBQualityConstraintsValueTypeConstraintId' ), |
|
146 | - $config->get( 'WBQualityConstraintsDistinctValuesConstraintId' ), |
|
143 | + $config->get('WBQualityConstraintsCommonsLinkConstraintId'), |
|
144 | + $config->get('WBQualityConstraintsTypeConstraintId'), |
|
145 | + $config->get('WBQualityConstraintsValueTypeConstraintId'), |
|
146 | + $config->get('WBQualityConstraintsDistinctValuesConstraintId'), |
|
147 | 147 | ], |
148 | 148 | $dataFactory |
149 | 149 | ); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $prefix, |
156 | 156 | $repo->getEntityIdParser(), |
157 | 157 | $repo->getStatementGuidValidator(), |
158 | - $repo->getApiHelperFactory( RequestContext::getMain() ), |
|
158 | + $repo->getApiHelperFactory(RequestContext::getMain()), |
|
159 | 159 | $resultsBuilder, |
160 | 160 | $dataFactory |
161 | 161 | ); |
@@ -181,11 +181,11 @@ discard block |
||
181 | 181 | ResultsBuilder $resultsBuilder, |
182 | 182 | IBufferingStatsdDataFactory $dataFactory |
183 | 183 | ) { |
184 | - parent::__construct( $main, $name, $prefix ); |
|
184 | + parent::__construct($main, $name, $prefix); |
|
185 | 185 | $this->entityIdParser = $entityIdParser; |
186 | 186 | $this->statementGuidValidator = $statementGuidValidator; |
187 | - $this->resultBuilder = $apiHelperFactory->getResultBuilder( $this ); |
|
188 | - $this->errorReporter = $apiHelperFactory->getErrorReporter( $this ); |
|
187 | + $this->resultBuilder = $apiHelperFactory->getResultBuilder($this); |
|
188 | + $this->errorReporter = $apiHelperFactory->getErrorReporter($this); |
|
189 | 189 | $this->resultsBuilder = $resultsBuilder; |
190 | 190 | $this->dataFactory = $dataFactory; |
191 | 191 | } |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | |
201 | 201 | $params = $this->extractRequestParams(); |
202 | 202 | |
203 | - $this->validateParameters( $params ); |
|
204 | - $entityIds = $this->parseEntityIds( $params ); |
|
205 | - $claimIds = $this->parseClaimIds( $params ); |
|
203 | + $this->validateParameters($params); |
|
204 | + $entityIds = $this->parseEntityIds($params); |
|
205 | + $claimIds = $this->parseClaimIds($params); |
|
206 | 206 | $constraintIDs = $params[self::PARAM_CONSTRAINT_ID]; |
207 | 207 | $statuses = $params[self::PARAM_STATUS]; |
208 | 208 | |
@@ -217,13 +217,13 @@ discard block |
||
217 | 217 | )->getArray() |
218 | 218 | ); |
219 | 219 | // ensure that result contains the given entity IDs even if they have no statements |
220 | - foreach ( $entityIds as $entityId ) { |
|
220 | + foreach ($entityIds as $entityId) { |
|
221 | 221 | $this->getResult()->addArrayType( |
222 | - [ $this->getModuleName(), $entityId->getSerialization() ], |
|
222 | + [$this->getModuleName(), $entityId->getSerialization()], |
|
223 | 223 | 'assoc' |
224 | 224 | ); |
225 | 225 | } |
226 | - $this->resultBuilder->markSuccess( 1 ); |
|
226 | + $this->resultBuilder->markSuccess(1); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -231,24 +231,24 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return EntityId[] |
233 | 233 | */ |
234 | - private function parseEntityIds( array $params ) { |
|
234 | + private function parseEntityIds(array $params) { |
|
235 | 235 | $ids = $params[self::PARAM_ID]; |
236 | 236 | |
237 | - if ( $ids === null ) { |
|
237 | + if ($ids === null) { |
|
238 | 238 | return []; |
239 | - } elseif ( $ids === [] ) { |
|
239 | + } elseif ($ids === []) { |
|
240 | 240 | $this->errorReporter->dieError( |
241 | - 'If ' . self::PARAM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
241 | + 'If '.self::PARAM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
242 | 242 | } |
243 | 243 | |
244 | - return array_map( function ( $id ) { |
|
244 | + return array_map(function($id) { |
|
245 | 245 | try { |
246 | - return $this->entityIdParser->parse( $id ); |
|
247 | - } catch ( EntityIdParsingException $e ) { |
|
246 | + return $this->entityIdParser->parse($id); |
|
247 | + } catch (EntityIdParsingException $e) { |
|
248 | 248 | $this->errorReporter->dieError( |
249 | - "Invalid id: $id", 'invalid-entity-id', 0, [ self::PARAM_ID => $id ] ); |
|
249 | + "Invalid id: $id", 'invalid-entity-id', 0, [self::PARAM_ID => $id] ); |
|
250 | 250 | } |
251 | - }, $ids ); |
|
251 | + }, $ids); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -256,35 +256,35 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return string[] |
258 | 258 | */ |
259 | - private function parseClaimIds( array $params ) { |
|
259 | + private function parseClaimIds(array $params) { |
|
260 | 260 | $ids = $params[self::PARAM_CLAIM_ID]; |
261 | 261 | |
262 | - if ( $ids === null ) { |
|
262 | + if ($ids === null) { |
|
263 | 263 | return []; |
264 | - } elseif ( $ids === [] ) { |
|
264 | + } elseif ($ids === []) { |
|
265 | 265 | $this->errorReporter->dieError( |
266 | - 'If ' . self::PARAM_CLAIM_ID . ' is specified, it must be nonempty.', 'no-data' ); |
|
266 | + 'If '.self::PARAM_CLAIM_ID.' is specified, it must be nonempty.', 'no-data' ); |
|
267 | 267 | } |
268 | 268 | |
269 | - foreach ( $ids as $id ) { |
|
270 | - if ( !$this->statementGuidValidator->validate( $id ) ) { |
|
269 | + foreach ($ids as $id) { |
|
270 | + if (!$this->statementGuidValidator->validate($id)) { |
|
271 | 271 | $this->errorReporter->dieError( |
272 | - "Invalid claim id: $id", 'invalid-guid', 0, [ self::PARAM_CLAIM_ID => $id ] ); |
|
272 | + "Invalid claim id: $id", 'invalid-guid', 0, [self::PARAM_CLAIM_ID => $id] ); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
276 | 276 | return $ids; |
277 | 277 | } |
278 | 278 | |
279 | - private function validateParameters( array $params ) { |
|
280 | - if ( $params[self::PARAM_CONSTRAINT_ID] !== null |
|
281 | - && empty( $params[self::PARAM_CONSTRAINT_ID] ) |
|
279 | + private function validateParameters(array $params) { |
|
280 | + if ($params[self::PARAM_CONSTRAINT_ID] !== null |
|
281 | + && empty($params[self::PARAM_CONSTRAINT_ID]) |
|
282 | 282 | ) { |
283 | 283 | $paramConstraintId = self::PARAM_CONSTRAINT_ID; |
284 | 284 | $this->errorReporter->dieError( |
285 | 285 | "If $paramConstraintId is specified, it must be nonempty.", 'no-data' ); |
286 | 286 | } |
287 | - if ( $params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null ) { |
|
287 | + if ($params[self::PARAM_ID] === null && $params[self::PARAM_CLAIM_ID] === null) { |
|
288 | 288 | $paramId = self::PARAM_ID; |
289 | 289 | $paramClaimId = self::PARAM_CLAIM_ID; |
290 | 290 | $this->errorReporter->dieError( |