Skip to content

Commit 4e653f4

Browse files
committed
[ticket/17281] Update psalm config and fix issues
PHPBB3-17281
1 parent 3533171 commit 4e653f4

40 files changed

+103
-80
lines changed

attachment/upload.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public function upload($form_name, $forum_id, $local = false, $local_storage = '
219219
$this->storage->delete($thumbnail_file);
220220
}
221221

222+
/** @psalm-suppress NoValue */
222223
$this->file_data['error'] = array_merge($this->file_data['error'], $this->file->error);
223224
$this->file_data['post_attach'] = false;
224225

avatar/manager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function get_enabled_drivers()
190190
* @param array $row User data or group data
191191
* @param string $prefix Prefix of data keys (e.g. user), should not include the trailing underscore
192192
*
193-
* @return array User or group data with keys that have been
193+
* @return array{string, string} User or group data with keys that have been
194194
* stripped from the preceding "user_" or "group_"
195195
* Also the group id is prefixed with g, when the prefix group is removed.
196196
*/
@@ -202,7 +202,7 @@ public static function clean_row($row, $prefix = '')
202202
return self::$default_row;
203203
}
204204

205-
$output = array();
205+
$output = [];
206206
foreach ($row as $key => $value)
207207
{
208208
$key = preg_replace("#^(?:{$prefix}_)#", '', $key);

captcha/non_gd.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function execute($code, $seed)
7878

7979
for ($j = 0; $j < $code_len; $j++)
8080
{
81+
/** @psalm-suppress InvalidArrayOffset */
8182
$image .= $this->randomise(substr($hold_chars[$code[$j]][$i - $offset_y - 1], 1), $char_widths[$j]);
8283
}
8384

config/config.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable
2727
/**
2828
* Creates a configuration container with a default set of values
2929
*
30-
* @param array<string,string> $config The configuration data.
30+
* @param array<string,int|string> $config The configuration data.
3131
*/
3232
public function __construct(array $config)
3333
{
@@ -74,22 +74,22 @@ public function offsetGet($key)
7474
* The configuration change will not persist. It will be lost
7575
* after the request.
7676
*
77-
* @param string $key The configuration option's name.
78-
* @param string $value The temporary value.
77+
* @param string $offset The configuration option's name.
78+
* @param int|string $value The temporary value.
7979
*/
8080
#[\ReturnTypeWillChange]
81-
public function offsetSet($key, $value)
81+
public function offsetSet($offset, $value)
8282
{
83-
$this->config[$key] = $value;
83+
$this->config[$offset] = $value;
8484
}
8585

8686
/**
8787
* Called when deleting a configuration value directly, triggers an error.
8888
*
89-
* @param string $key The configuration option's name.
89+
* @param string $offset The configuration option's name.
9090
*/
9191
#[\ReturnTypeWillChange]
92-
public function offsetUnset($key)
92+
public function offsetUnset($offset): never
9393
{
9494
trigger_error('Config values have to be deleted explicitly with the \phpbb\config\config::delete($key) method.', E_USER_ERROR);
9595
}
@@ -121,7 +121,7 @@ public function delete($key, $use_cache = true)
121121
* Sets a configuration option's value
122122
*
123123
* @param string $key The configuration option's name
124-
* @param string $value New configuration value
124+
* @param int|string $value New configuration value
125125
* @param bool $use_cache Whether this variable should be cached or if it
126126
* changes too frequently to be efficiently cached.
127127
*/
@@ -135,8 +135,8 @@ public function set($key, $value, $use_cache = true)
135135
* current configuration value or the configuration value does not exist yet.
136136
*
137137
* @param string $key The configuration option's name
138-
* @param string $old_value Current configuration value
139-
* @param string $new_value New configuration value
138+
* @param int|string $old_value Current configuration value
139+
* @param int|string $new_value New configuration value
140140
* @param bool $use_cache Whether this variable should be cached or if it
141141
* changes too frequently to be efficiently cached.
142142
* @return bool True if the value was changed, false otherwise.
@@ -157,7 +157,7 @@ public function set_atomic($key, $old_value, $new_value, $use_cache = true)
157157
* only after set_atomic has been called.
158158
*
159159
* @param string $key The configuration option's name
160-
* @param string $new_value New configuration value
160+
* @param int|string $new_value New configuration value
161161
* @throws \phpbb\exception\http_exception when config value is set and not equal to new_value.
162162
* @return bool True if the value was changed, false otherwise.
163163
*/

config/db.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ public function delete($key, $use_cache = true)
127127
/**
128128
* Sets a configuration option's value
129129
*
130-
* @param string $key The configuration option's name
131-
* @param string $value New configuration value
132-
* @param bool $use_cache Whether this variable should be cached or if it
133-
* changes too frequently to be efficiently cached.
130+
* @param string $key The configuration option's name
131+
* @param int|string $value New configuration value
132+
* @param bool $use_cache Whether this variable should be cached or if it
133+
* changes too frequently to be efficiently cached.
134134
*/
135135
public function set($key, $value, $use_cache = true)
136136
{
@@ -141,13 +141,13 @@ public function set($key, $value, $use_cache = true)
141141
* Sets a configuration option's value only if the old_value matches the
142142
* current configuration value or the configuration value does not exist yet.
143143
*
144-
* @param string $key The configuration option's name
145-
* @param mixed $old_value Current configuration value or false to ignore
146-
* the old value
147-
* @param string $new_value New configuration value
148-
* @param bool $use_cache Whether this variable should be cached or if it
149-
* changes too frequently to be efficiently cached
150-
* @return bool True if the value was changed, false otherwise
144+
* @param string $key The configuration option's name
145+
* @param false|int|string $old_value Current configuration value or false to ignore
146+
* the old value
147+
* @param int|string $new_value New configuration value
148+
* @param bool $use_cache Whether this variable should be cached or if it
149+
* changes too frequently to be efficiently cached
150+
* @return bool True if the value was changed, false otherwise
151151
*/
152152
public function set_atomic($key, $old_value, $new_value, $use_cache = true)
153153
{

cron/manager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function __construct(ContainerInterface $phpbb_container, helper $routing
8686
* Loads tasks given by name, wraps them
8787
* and puts them into $this->tasks.
8888
*
89-
* @param array|\Traversable $tasks Array of instances of \phpbb\cron\task\task
89+
* @param array|\ArrayObject $tasks Array of instances of \phpbb\cron\task\task
9090
*/
9191
public function load_tasks($tasks)
9292
{
@@ -106,6 +106,7 @@ public function load_tasks_from_container()
106106
{
107107
$this->is_initialised_from_container = true;
108108

109+
/** @var array|\phpbb\di\service_collection $tasks */
109110
$tasks = $this->phpbb_container->get('cron.task_collection');
110111

111112
$this->load_tasks($tasks);

cron/task/core/tidy_plupload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function run()
105105
));
106106
}
107107

108-
$this->config->set('plupload_last_gc', time(), true);
108+
$this->config->set('plupload_last_gc', time());
109109
}
110110

111111
/**

db/doctrine/type_converter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public static function convert(string $type, string $dbms): array
7474
* @param string $type Legacy type name.
7575
* @param int $length Type length.
7676
*
77-
* @return array{string, array} Pair of type name and options.
77+
* @return array{string, array{string, ...}} Pair of type name and options.
7878
*/
7979
private static function mapWithLength(string $type, int $length): array
8080
{

db/driver/mssql_odbc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function sql_last_inserted_id()
279279
{
280280
$id = odbc_result($result_id, 1);
281281
odbc_free_result($result_id);
282-
return $id;
282+
return $id ? (int) $id : false;
283283
}
284284
odbc_free_result($result_id);
285285
}

db/migration/exception.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct()
4444
*
4545
* @return string
4646
*/
47-
public function __toString()
47+
public function __toString(): string
4848
{
4949
return $this->message . ': ' . var_export($this->parameters, true);
5050
}

0 commit comments

Comments
 (0)