[ticket/17281] Update psalm config and fix issues

PHPBB3-17281
This commit is contained in:
Marc Alexander 2023-12-30 17:41:12 +01:00
parent c6c299eea4
commit 661a8a6117
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
42 changed files with 107 additions and 80 deletions

View file

@ -554,6 +554,8 @@ function strip_bbcode(&$text, $uid = '')
/** /**
* For display of custom parsed text on user-facing pages * For display of custom parsed text on user-facing pages
* Expects $text to be the value directly from the database (stored value) * Expects $text to be the value directly from the database (stored value)
*
* @return string Generated text
*/ */
function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text = true) function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text = true)
{ {

View file

@ -219,6 +219,7 @@ class upload
$this->storage->delete($thumbnail_file); $this->storage->delete($thumbnail_file);
} }
/** @psalm-suppress NoValue */
$this->file_data['error'] = array_merge($this->file_data['error'], $this->file->error); $this->file_data['error'] = array_merge($this->file_data['error'], $this->file->error);
$this->file_data['post_attach'] = false; $this->file_data['post_attach'] = false;

View file

@ -190,7 +190,7 @@ class manager
* @param array $row User data or group data * @param array $row User data or group data
* @param string $prefix Prefix of data keys (e.g. user), should not include the trailing underscore * @param string $prefix Prefix of data keys (e.g. user), should not include the trailing underscore
* *
* @return array User or group data with keys that have been * @return array{string, string} User or group data with keys that have been
* stripped from the preceding "user_" or "group_" * stripped from the preceding "user_" or "group_"
* Also the group id is prefixed with g, when the prefix group is removed. * Also the group id is prefixed with g, when the prefix group is removed.
*/ */
@ -202,7 +202,7 @@ class manager
return self::$default_row; return self::$default_row;
} }
$output = array(); $output = [];
foreach ($row as $key => $value) foreach ($row as $key => $value)
{ {
$key = preg_replace("#^(?:{$prefix}_)#", '', $key); $key = preg_replace("#^(?:{$prefix}_)#", '', $key);

View file

@ -78,6 +78,7 @@ class non_gd
for ($j = 0; $j < $code_len; $j++) for ($j = 0; $j < $code_len; $j++)
{ {
/** @psalm-suppress InvalidArrayOffset */
$image .= $this->randomise(substr($hold_chars[$code[$j]][$i - $offset_y - 1], 1), $char_widths[$j]); $image .= $this->randomise(substr($hold_chars[$code[$j]][$i - $offset_y - 1], 1), $char_widths[$j]);
} }

View file

@ -27,7 +27,7 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable
/** /**
* Creates a configuration container with a default set of values * Creates a configuration container with a default set of values
* *
* @param array<string,string> $config The configuration data. * @param array<string,int|string> $config The configuration data.
*/ */
public function __construct(array $config) public function __construct(array $config)
{ {
@ -74,22 +74,22 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable
* The configuration change will not persist. It will be lost * The configuration change will not persist. It will be lost
* after the request. * after the request.
* *
* @param string $key The configuration option's name. * @param string $offset The configuration option's name.
* @param string $value The temporary value. * @param int|string $value The temporary value.
*/ */
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
public function offsetSet($key, $value) public function offsetSet($offset, $value)
{ {
$this->config[$key] = $value; $this->config[$offset] = $value;
} }
/** /**
* Called when deleting a configuration value directly, triggers an error. * Called when deleting a configuration value directly, triggers an error.
* *
* @param string $key The configuration option's name. * @param string $offset The configuration option's name.
*/ */
#[\ReturnTypeWillChange] #[\ReturnTypeWillChange]
public function offsetUnset($key) public function offsetUnset($offset): never
{ {
trigger_error('Config values have to be deleted explicitly with the \phpbb\config\config::delete($key) method.', E_USER_ERROR); trigger_error('Config values have to be deleted explicitly with the \phpbb\config\config::delete($key) method.', E_USER_ERROR);
} }
@ -121,7 +121,7 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable
* Sets a configuration option's value * Sets a configuration option's value
* *
* @param string $key The configuration option's name * @param string $key The configuration option's name
* @param string $value New configuration value * @param int|string $value New configuration value
* @param bool $use_cache Whether this variable should be cached or if it * @param bool $use_cache Whether this variable should be cached or if it
* changes too frequently to be efficiently cached. * changes too frequently to be efficiently cached.
*/ */
@ -135,8 +135,8 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable
* current configuration value or the configuration value does not exist yet. * current configuration value or the configuration value does not exist yet.
* *
* @param string $key The configuration option's name * @param string $key The configuration option's name
* @param string $old_value Current configuration value * @param int|string $old_value Current configuration value
* @param string $new_value New configuration value * @param int|string $new_value New configuration value
* @param bool $use_cache Whether this variable should be cached or if it * @param bool $use_cache Whether this variable should be cached or if it
* changes too frequently to be efficiently cached. * changes too frequently to be efficiently cached.
* @return bool True if the value was changed, false otherwise. * @return bool True if the value was changed, false otherwise.
@ -157,7 +157,7 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable
* only after set_atomic has been called. * only after set_atomic has been called.
* *
* @param string $key The configuration option's name * @param string $key The configuration option's name
* @param string $new_value New configuration value * @param int|string $new_value New configuration value
* @throws \phpbb\exception\http_exception when config value is set and not equal to new_value. * @throws \phpbb\exception\http_exception when config value is set and not equal to new_value.
* @return bool True if the value was changed, false otherwise. * @return bool True if the value was changed, false otherwise.
*/ */

View file

@ -128,7 +128,7 @@ class db extends config
* Sets a configuration option's value * Sets a configuration option's value
* *
* @param string $key The configuration option's name * @param string $key The configuration option's name
* @param string $value New configuration value * @param int|string $value New configuration value
* @param bool $use_cache Whether this variable should be cached or if it * @param bool $use_cache Whether this variable should be cached or if it
* changes too frequently to be efficiently cached. * changes too frequently to be efficiently cached.
*/ */
@ -142,9 +142,9 @@ class db extends config
* current configuration value or the configuration value does not exist yet. * current configuration value or the configuration value does not exist yet.
* *
* @param string $key The configuration option's name * @param string $key The configuration option's name
* @param mixed $old_value Current configuration value or false to ignore * @param false|int|string $old_value Current configuration value or false to ignore
* the old value * the old value
* @param string $new_value New configuration value * @param int|string $new_value New configuration value
* @param bool $use_cache Whether this variable should be cached or if it * @param bool $use_cache Whether this variable should be cached or if it
* changes too frequently to be efficiently cached * changes too frequently to be efficiently cached
* @return bool True if the value was changed, false otherwise * @return bool True if the value was changed, false otherwise

View file

@ -86,7 +86,7 @@ class manager
* Loads tasks given by name, wraps them * Loads tasks given by name, wraps them
* and puts them into $this->tasks. * and puts them into $this->tasks.
* *
* @param array|\Traversable $tasks Array of instances of \phpbb\cron\task\task * @param array|\ArrayObject $tasks Array of instances of \phpbb\cron\task\task
*/ */
public function load_tasks($tasks) public function load_tasks($tasks)
{ {
@ -106,6 +106,7 @@ class manager
{ {
$this->is_initialised_from_container = true; $this->is_initialised_from_container = true;
/** @var array|\phpbb\di\service_collection $tasks */
$tasks = $this->phpbb_container->get('cron.task_collection'); $tasks = $this->phpbb_container->get('cron.task_collection');
$this->load_tasks($tasks); $this->load_tasks($tasks);

View file

@ -105,7 +105,7 @@ class tidy_plupload extends \phpbb\cron\task\base
)); ));
} }
$this->config->set('plupload_last_gc', time(), true); $this->config->set('plupload_last_gc', time());
} }
/** /**

View file

@ -74,7 +74,7 @@ class type_converter
* @param string $type Legacy type name. * @param string $type Legacy type name.
* @param int $length Type length. * @param int $length Type length.
* *
* @return array{string, array} Pair of type name and options. * @return array{string, array{string, ...}} Pair of type name and options.
*/ */
private static function mapWithLength(string $type, int $length): array private static function mapWithLength(string $type, int $length): array
{ {

View file

@ -279,7 +279,7 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
{ {
$id = odbc_result($result_id, 1); $id = odbc_result($result_id, 1);
odbc_free_result($result_id); odbc_free_result($result_id);
return $id; return $id ? (int) $id : false;
} }
odbc_free_result($result_id); odbc_free_result($result_id);
} }

View file

@ -44,7 +44,7 @@ class exception extends \Exception
* *
* @return string * @return string
*/ */
public function __toString() public function __toString(): string
{ {
return $this->message . ': ' . var_export($this->parameters, true); return $this->message . ': ' . var_export($this->parameters, true);
} }

View file

@ -103,6 +103,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
foreach ($parent_sqls as $parent_sql) foreach ($parent_sqls as $parent_sql)
{ {
/** @psalm-suppress NoValue */
$sql = 'SELECT module_id $sql = 'SELECT module_id
FROM ' . $this->modules_table . " FROM ' . $this->modules_table . "
WHERE module_class = '" . $this->db->sql_escape($class) . "' WHERE module_class = '" . $this->db->sql_escape($class) . "'

View file

@ -587,7 +587,7 @@ class container_builder
$this->config_php_file->get('dbname'), $this->config_php_file->get('dbname'),
$this->config_php_file->get('dbport'), $this->config_php_file->get('dbport'),
false, false,
defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false
); );
} }
$this->container->set('dbal.conn.driver', $this->dbal_connection); $this->container->set('dbal.conn.driver', $this->dbal_connection);

View file

@ -28,6 +28,7 @@ class container_configuration implements ConfigurationInterface
{ {
$treeBuilder = new TreeBuilder('core'); $treeBuilder = new TreeBuilder('core');
$rootNode = $treeBuilder->getRootNode(); $rootNode = $treeBuilder->getRootNode();
/** @psalm-suppress UndefinedMethod */
$rootNode $rootNode
->children() ->children()
->booleanNode('require_dev_dependencies')->defaultValue(false)->end() ->booleanNode('require_dev_dependencies')->defaultValue(false)->end()

View file

@ -17,6 +17,8 @@ namespace phpbb\event;
* This filter ignores directories and files starting with a dot. * This filter ignores directories and files starting with a dot.
* It also skips some directories that do not contain events anyway, * It also skips some directories that do not contain events anyway,
* such as e.g. files/, store/ and vendor/ * such as e.g. files/, store/ and vendor/
*
* @psalm-suppress MissingTemplateParam
*/ */
class recursive_event_filter_iterator extends \RecursiveFilterIterator class recursive_event_filter_iterator extends \RecursiveFilterIterator
{ {

View file

@ -23,6 +23,8 @@ namespace phpbb\extension;
* *
* Items could be anything, for example template paths or cron task names. * Items could be anything, for example template paths or cron task names.
* Derived classes completely define what the items are. * Derived classes completely define what the items are.
*
* @psalm-suppress MissingTemplateParam
*/ */
abstract class provider implements \IteratorAggregate abstract class provider implements \IteratorAggregate
{ {
@ -60,7 +62,7 @@ abstract class provider implements \IteratorAggregate
* *
* @return \ArrayIterator An iterator for the array of template paths * @return \ArrayIterator An iterator for the array of template paths
*/ */
public function getIterator() public function getIterator(): \ArrayIterator
{ {
if ($this->items === null) if ($this->items === null)
{ {

View file

@ -119,7 +119,7 @@ class topics_active extends topic_base
FROM ' . FORUMS_TABLE . ' FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . ' WHERE forum_type = ' . FORUM_POST . '
AND ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '= 0') . ' AND ' . $this->db->sql_bit_and('forum_options', FORUM_OPTION_FEED_EXCLUDE, '= 0') . '
AND ' . $this->db->sql_bit_and('forum_flags', round(log(FORUM_FLAG_ACTIVE_TOPICS, 2)), '<> 0'); AND ' . $this->db->sql_bit_and('forum_flags', (int) round(log(FORUM_FLAG_ACTIVE_TOPICS, 2)), '<> 0');
$result = $this->db->sql_query($sql); $result = $this->db->sql_query($sql);
$forum_ids = array(); $forum_ids = array();

View file

@ -632,7 +632,7 @@ class filesystem implements filesystem_interface
else if (function_exists('debug_backtrace')) else if (function_exists('debug_backtrace'))
{ {
$call_stack = debug_backtrace(0); $call_stack = debug_backtrace(0);
$this->working_directory = str_replace(DIRECTORY_SEPARATOR, '/', dirname($call_stack[count($call_stack) - 1]['file'])); $this->working_directory = str_replace(DIRECTORY_SEPARATOR, '/', dirname($call_stack[max(0, count($call_stack) - 1)]['file']));
} }
else else
{ {
@ -686,6 +686,8 @@ class filesystem implements filesystem_interface
return false; return false;
} }
$resolved_path = (string) $resolved_path;
if (!@file_exists($resolved_path) || (!@is_dir($resolved_path . '/') && !is_file($resolved_path))) if (!@file_exists($resolved_path) || (!@is_dir($resolved_path . '/') && !is_file($resolved_path)))
{ {
return false; return false;

View file

@ -97,7 +97,7 @@ class helper
else if (function_exists('debug_backtrace')) else if (function_exists('debug_backtrace'))
{ {
$call_stack = debug_backtrace(0); $call_stack = debug_backtrace(0);
$working_directory = str_replace(DIRECTORY_SEPARATOR, '/', dirname($call_stack[count($call_stack) - 1]['file'])); $working_directory = str_replace(DIRECTORY_SEPARATOR, '/', dirname($call_stack[max(0, count($call_stack) - 1)]['file']));
} }
else else
{ {
@ -156,7 +156,7 @@ class helper
} }
// Return OS specific directory separators // Return OS specific directory separators
$resolved = str_replace('/', DIRECTORY_SEPARATOR, $resolved_path); $resolved = str_replace('/', DIRECTORY_SEPARATOR, (string) $resolved_path);
// Check for DIRECTORY_SEPARATOR at the end (and remove it!) // Check for DIRECTORY_SEPARATOR at the end (and remove it!)
if (substr($resolved, -1) === DIRECTORY_SEPARATOR) if (substr($resolved, -1) === DIRECTORY_SEPARATOR)

View file

@ -19,6 +19,8 @@ namespace phpbb\finder;
* This filter ignores directories starting with a dot. * This filter ignores directories starting with a dot.
* When searching for php classes and template files of extensions * When searching for php classes and template files of extensions
* we don't need to look inside these directories. * we don't need to look inside these directories.
*
* @psalm-suppress MissingTemplateParam
*/ */
class recursive_dot_prefix_filter_iterator extends \RecursiveFilterIterator class recursive_dot_prefix_filter_iterator extends \RecursiveFilterIterator
{ {

View file

@ -15,6 +15,9 @@ declare(strict_types=1);
namespace phpbb\finder; namespace phpbb\finder;
/**
* @psalm-suppress MissingTemplateParam
*/
class recursive_path_iterator extends \RecursiveIteratorIterator class recursive_path_iterator extends \RecursiveIteratorIterator
{ {
/** /**

View file

@ -341,11 +341,11 @@ class installer
/** /**
* Recover install progress * Recover install progress
* *
* @return string Index of the next installer module to execute * @return int Index of the next installer module to execute
*/ */
protected function recover_progress() protected function recover_progress(): int
{ {
$progress_array = $this->install_config->get_progress_data(); $progress_array = $this->install_config->get_progress_data();
return $progress_array['last_task_module_index']; return (int) $progress_array['last_task_module_index'];
} }
} }

View file

@ -28,6 +28,7 @@ class installer_configuration implements ConfigurationInterface
{ {
$treeBuilder = new TreeBuilder('installer'); $treeBuilder = new TreeBuilder('installer');
$rootNode = $treeBuilder->getRootNode(); $rootNode = $treeBuilder->getRootNode();
/** @psalm-suppress UndefinedMethod */
$rootNode $rootNode
->children() ->children()
->arrayNode('admin') ->arrayNode('admin')

View file

@ -149,7 +149,7 @@ class create_schema_file extends \phpbb\install\task_base
$tables = []; $tables = [];
foreach ($tables_data['parameters'] as $parameter => $table) foreach ($tables_data['parameters'] as $parameter => $table)
{ {
$tables[str_replace('tables.', '', $parameter)] = str_replace('%core.table_prefix%', $table_prefix, $table); $tables[str_replace('tables.', '', (string) $parameter)] = str_replace('%core.table_prefix%', $table_prefix, $table);
} }
$schema_generator = new \phpbb\db\migration\schema_generator( $schema_generator = new \phpbb\db\migration\schema_generator(

View file

@ -186,12 +186,12 @@ abstract class module_base implements module_interface
/** /**
* Returns the next task's name * Returns the next task's name
* *
* @return string Index of the array element of the next task * @return int Index of the array element of the next task
*/ */
protected function recover_progress() protected function recover_progress(): int
{ {
$progress_array = $this->install_config->get_progress_data(); $progress_array = $this->install_config->get_progress_data();
return $progress_array['last_task_index']; return (int) $progress_array['last_task_index'];
} }
/** /**

View file

@ -28,6 +28,7 @@ class updater_configuration implements ConfigurationInterface
{ {
$treeBuilder = new TreeBuilder('updater'); $treeBuilder = new TreeBuilder('updater');
$rootNode = $treeBuilder->getRootNode(); $rootNode = $treeBuilder->getRootNode();
/** @psalm-suppress UndefinedMethod */
$rootNode $rootNode
->addDefaultsIfNotSet() ->addDefaultsIfNotSet()
->children() ->children()

View file

@ -223,7 +223,7 @@ class manager
* Mark notifications read or unread for a given method * Mark notifications read or unread for a given method
* *
* @param string $method_name * @param string $method_name
* @param int|array $notification_id Notification id or array of notification ids. * @param array $notification_id Notification id or array of notification ids.
* @param bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False) * @param bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False)
* @param bool $mark_read Define if the notification as to be set to True or False. (Default: True) * @param bool $mark_read Define if the notification as to be set to True or False. (Default: True)
*/ */

View file

@ -91,7 +91,7 @@ interface method_interface
/** /**
* Mark notifications read or unread * Mark notifications read or unread
* *
* @param bool|string $notification_type_id Type identifier of item types. False to mark read for all item types * @param bool|string|array $notification_type_id Type identifier of item types. False to mark read for all item types
* @param bool|int|array $item_id Item id or array of item ids. False to mark read for all item ids * @param bool|int|array $item_id Item id or array of item ids. False to mark read for all item ids
* @param bool|int|array $user_id User id or array of user ids. False to mark read for all user ids * @param bool|int|array $user_id User id or array of user ids. False to mark read for all user ids
* @param bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False) * @param bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False)
@ -113,7 +113,7 @@ interface method_interface
/** /**
* Mark notifications read or unread * Mark notifications read or unread
* *
* @param int $notification_id Notification id of notification ids. * @param array|int $notification_id Notification id or array of notification ids.
* @param bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False) * @param bool|int $time Time at which to mark all notifications prior to as read. False to mark all as read. (Default: False)
* @param bool $mark_read Define if the notification as to be set to True or False. (Default: True) * @param bool $mark_read Define if the notification as to be set to True or False. (Default: True)
*/ */
@ -122,7 +122,7 @@ interface method_interface
/** /**
* Delete a notification * Delete a notification
* *
* @param string $notification_type_id Type identifier of item types * @param int $notification_type_id Type identifier of item types
* @param int|array $item_id Identifier within the type (or array of ids) * @param int|array $item_id Identifier within the type (or array of ids)
* @param mixed $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified (Default: false; not checked) * @param mixed $parent_id Parent identifier within the type (or array of ids), used in combination with item_id if specified (Default: false; not checked)
* @param mixed $user_id User id (Default: false; not checked) * @param mixed $user_id User id (Default: false; not checked)
@ -143,7 +143,7 @@ interface method_interface
* This should be called when an extension which has notification types * This should be called when an extension which has notification types
* is purged so that all those notifications are removed * is purged so that all those notifications are removed
* *
* @param string $notification_type_id Type identifier of the subscription * @param int $notification_type_id Type identifier of the subscription
*/ */
public function purge_notifications($notification_type_id); public function purge_notifications($notification_type_id);
} }

View file

@ -49,7 +49,7 @@ class pagination
* @param string|array $base_url is url prepended to all links generated within the function * @param string|array $base_url is url prepended to all links generated within the function
* If you use page numbers inside your controller route, base_url should contains a placeholder (%d) * If you use page numbers inside your controller route, base_url should contains a placeholder (%d)
* for the page. Also be sure to specify the pagination path information into the start_name argument * for the page. Also be sure to specify the pagination path information into the start_name argument
* @param string $on_page is the page for which we want to generate the link * @param int $on_page is the page for which we want to generate the link
* @param string $start_name is the name of the parameter containing the first item of the given page (example: start=20) * @param string $start_name is the name of the parameter containing the first item of the given page (example: start=20)
* If you use page numbers inside your controller route, start name should be the string * If you use page numbers inside your controller route, start name should be the string
* that should be removed for the first page (example: /page/%d) * that should be removed for the first page (example: /page/%d)
@ -72,7 +72,7 @@ class pagination
* @var string|array base_url is url prepended to all links generated within the function * @var string|array base_url is url prepended to all links generated within the function
* If you use page numbers inside your controller route, base_url should contains a placeholder (%d) * If you use page numbers inside your controller route, base_url should contains a placeholder (%d)
* for the page. Also be sure to specify the pagination path information into the start_name argument * for the page. Also be sure to specify the pagination path information into the start_name argument
* @var string on_page is the page for which we want to generate the link * @var int on_page is the page for which we want to generate the link
* @var string start_name is the name of the parameter containing the first item of the given page (example: start=20) * @var string start_name is the name of the parameter containing the first item of the given page (example: start=20)
* If you use page numbers inside your controller route, start name should be the string * If you use page numbers inside your controller route, start name should be the string
* that should be removed for the first page (example: /page/%d) * that should be removed for the first page (example: /page/%d)

View file

@ -102,8 +102,8 @@ class helper
if ($dss_seeded !== true && ($this->config['rand_seed_last_update'] < time() - rand(1,10))) if ($dss_seeded !== true && ($this->config['rand_seed_last_update'] < time() - rand(1,10)))
{ {
$this->config->set('rand_seed_last_update', time(), true); $this->config->set('rand_seed_last_update', time());
$this->config->set('rand_seed', $this->config['rand_seed'], true); $this->config->set('rand_seed', $this->config['rand_seed']);
$dss_seeded = true; $dss_seeded = true;
} }

View file

@ -221,11 +221,11 @@ class plupload
* appropriate for use in configuring plupload with * appropriate for use in configuring plupload with
* *
* @param \phpbb\cache\service $cache Cache service object * @param \phpbb\cache\service $cache Cache service object
* @param string $forum_id The forum identifier * @param int $forum_id The forum identifier
* *
* @return string * @return string
*/ */
public function generate_filter_string(\phpbb\cache\service $cache, $forum_id) public function generate_filter_string(\phpbb\cache\service $cache, int $forum_id)
{ {
$groups = []; $groups = [];
$filters = []; $filters = [];

View file

@ -250,7 +250,7 @@ class report
/** /**
* Assigns template variables * Assigns template variables
* *
* @param int $mode * @param string $mode
* @param int $id * @param int $id
* @param int $reason_id * @param int $reason_id
* @param string $report_text * @param string $report_text

View file

@ -16,6 +16,7 @@ namespace phpbb\request;
/** /**
* Replacement for a superglobal (like $_GET or $_POST) which calls * Replacement for a superglobal (like $_GET or $_POST) which calls
* trigger_error on all operations but isset, overloads the [] operator with SPL. * trigger_error on all operations but isset, overloads the [] operator with SPL.
* @psalm-suppress MissingTemplateParam
*/ */
class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAggregate class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAggregate
{ {
@ -25,23 +26,23 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
private $name; private $name;
/** /**
* @var string (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE) Super global constant. * @var int (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE) Super global constant.
*/ */
private $super_global; private $super_global;
/** /**
* @var \phpbb\request\request_interface The request class instance holding the actual request data. * @var request_interface The request class instance holding the actual request data.
*/ */
private $request; private $request;
/** /**
* Constructor generates an error message fitting the super global to be used within the other functions. * Constructor generates an error message fitting the super global to be used within the other functions.
* *
* @param \phpbb\request\request_interface $request A request class instance holding the real super global data. * @param request_interface $request A request class instance holding the real super global data.
* @param string $name Name of the super global this is a replacement for - e.g. '_GET'. * @param string $name Name of the super global this is a replacement for - e.g. '_GET'.
* @param string $super_global The variable's super global constant (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE). * @param int $super_global The variable's super global constant (\phpbb\request\request_interface::POST|GET|REQUEST|COOKIE).
*/ */
public function __construct(\phpbb\request\request_interface $request, $name, $super_global) public function __construct(request_interface $request, string $name, int $super_global)
{ {
$this->request = $request; $this->request = $request;
$this->name = $name; $this->name = $name;
@ -82,7 +83,7 @@ class deactivated_super_global implements \ArrayAccess, \Countable, \IteratorAgg
/**#@+ /**#@+
* Part of the \ArrayAccess implementation, will always result in a FATAL error. * Part of the \ArrayAccess implementation, will always result in a FATAL error.
*/ */
public function offsetGet($offset): mixed public function offsetGet($offset): void
{ {
$this->error(); $this->error();
} }

View file

@ -25,7 +25,11 @@ class file_locator extends FileLocator
foreach ($paths as $path) foreach ($paths as $path)
{ {
$absolute_paths[] = filesystem_helper::realpath($path); $path = filesystem_helper::realpath($path);
if ($path !== false)
{
$absolute_paths[] = $path;
}
} }
parent::__construct($absolute_paths); parent::__construct($absolute_paths);

View file

@ -1718,7 +1718,7 @@ class fulltext_native extends base implements search_backend_interface
/** /**
* Clean up the string, remove HTML tags, remove BBCodes * Clean up the string, remove HTML tags, remove BBCodes
*/ */
$word = strtok($this->cleanup(preg_replace($match, ' ', strip_tags($text)), -1), ' '); $word = strtok($this->cleanup(preg_replace($match, ' ', strip_tags($text)), '-1'), ' ');
while (strlen($word)) while (strlen($word))
{ {

View file

@ -61,12 +61,12 @@ class session
$script_name = str_replace(array('\\', '//'), '/', $script_name); $script_name = str_replace(array('\\', '//'), '/', $script_name);
// Now, remove the sid and let us get a clean query string... // Now, remove the sid and let us get a clean query string...
$use_args = array(); $use_args = [];
// Since some browser do not encode correctly we need to do this with some "special" characters... // Since some browser do not encode correctly we need to do this with some "special" characters...
// " -> %22, ' => %27, < -> %3C, > -> %3E // " -> %22, ' => %27, < -> %3C, > -> %3E
$find = array('"', "'", '<', '>', '&quot;', '&lt;', '&gt;'); $find = ['"', "'", '<', '>', '&quot;', '&lt;', '&gt;'];
$replace = array('%22', '%27', '%3C', '%3E', '%22', '%3C', '%3E'); $replace = ['%22', '%27', '%3C', '%3E', '%22', '%3C', '%3E'];
foreach ($args as $argument) foreach ($args as $argument)
{ {
@ -75,7 +75,7 @@ class session
continue; continue;
} }
$use_args[] = str_replace($find, $replace, $argument); $use_args[] = (string) str_replace($find, $replace, $argument);
} }
unset($args); unset($args);
@ -530,7 +530,7 @@ class session
{ {
if ($row['bot_agent'] && preg_match('#' . str_replace('\*', '.*?', preg_quote($row['bot_agent'], '#')) . '#i', $this->browser)) if ($row['bot_agent'] && preg_match('#' . str_replace('\*', '.*?', preg_quote($row['bot_agent'], '#')) . '#i', $this->browser))
{ {
$bot = $row['user_id']; $bot = (int) $row['user_id'];
} }
// If ip is supplied, we will make sure the ip is matching too... // If ip is supplied, we will make sure the ip is matching too...

View file

@ -60,10 +60,10 @@ class context
* Value can be a string, an integer or a boolean. * Value can be a string, an integer or a boolean.
* *
* @param string $varname Variable name * @param string $varname Variable name
* @param string $varval Value to assign to variable * @param bool|int|string $varval Value to assign to variable
* @return true * @return true
*/ */
public function assign_var($varname, $varval) public function assign_var(string $varname, bool|int|string $varval)
{ {
$this->rootref[$varname] = $varval; $this->rootref[$varname] = $varval;

View file

@ -103,10 +103,10 @@ interface template
* Value can be a string, an integer or a boolean. * Value can be a string, an integer or a boolean.
* *
* @param string $varname Variable name * @param string $varname Variable name
* @param string $varval Value to assign to variable * @param bool|int|string $varval Value to assign to variable
* @return \phpbb\template\template $this * @return \phpbb\template\template $this
*/ */
public function assign_var($varname, $varval); public function assign_var(string $varname, bool|int|string $varval);
/** /**
* Append text to the string value stored in a key. * Append text to the string value stored in a key.

View file

@ -58,7 +58,7 @@ class icon extends AbstractExtension
* *
* @param environment $environment Twig environment object * @param environment $environment Twig environment object
* @param string $type Icon type (font|iconify|png|svg) * @param string $type Icon type (font|iconify|png|svg)
* @param string $icon Icon name (eg. "bold") * @param array|string $icon Icon name (eg. "bold")
* @param string $title Icon title * @param string $title Icon title
* @param bool $hidden Hide the icon title from view * @param bool $hidden Hide the icon title from view
* @param string $classes Additional classes (eg. "fa-fw") * @param string $classes Additional classes (eg. "fa-fw")

View file

@ -441,7 +441,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface
$sql = 'UPDATE ' . $this->table_name . ' $sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ', SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ',
' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ', ' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ',
' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_parent_id . ' = ' . $current_parent_id, $new_parent_id, $this->column_parent_id) . ', ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_parent_id . ' = ' . $current_parent_id, (string) $new_parent_id, $this->column_parent_id) . ',
' . $this->column_item_parents . " = '' ' . $this->column_item_parents . " = ''
WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . ' WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . '
' . $this->get_sql_where('AND'); ' . $this->get_sql_where('AND');
@ -539,7 +539,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface
$sql = 'UPDATE ' . $this->table_name . ' $sql = 'UPDATE ' . $this->table_name . '
SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ', SET ' . $this->column_left_id . ' = ' . $this->column_left_id . $diff . ',
' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ', ' . $this->column_right_id . ' = ' . $this->column_right_id . $diff . ',
' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_item_id . ' = ' . $item_id, $new_parent_id, $this->column_parent_id) . ', ' . $this->column_parent_id . ' = ' . $this->db->sql_case($this->column_item_id . ' = ' . $item_id, (string) $new_parent_id, $this->column_parent_id) . ',
' . $this->column_item_parents . " = '' ' . $this->column_item_parents . " = ''
WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . ' WHERE " . $this->db->sql_in_set($this->column_item_id, $move_items) . '
' . $this->get_sql_where('AND'); ' . $this->get_sql_where('AND');
@ -720,12 +720,12 @@ abstract class nestedset implements \phpbb\tree\tree_interface
if ($set_subset_zero) if ($set_subset_zero)
{ {
$set_left_id = $this->db->sql_case($sql_subset_items, 0, $set_left_id); $set_left_id = $this->db->sql_case($sql_subset_items, '0', $set_left_id);
$set_right_id = $this->db->sql_case($sql_subset_items, 0, $set_right_id); $set_right_id = $this->db->sql_case($sql_subset_items, '0', $set_right_id);
} }
$sql = 'UPDATE ' . $this->table_name . ' $sql = 'UPDATE ' . $this->table_name . '
SET ' . (($set_subset_zero) ? $this->column_parent_id . ' = ' . $this->db->sql_case($sql_subset_items, 0, $this->column_parent_id) . ',' : '') . ' SET ' . (($set_subset_zero) ? $this->column_parent_id . ' = ' . $this->db->sql_case($sql_subset_items, '0', $this->column_parent_id) . ',' : '') . '
' . $this->column_left_id . ' = ' . $set_left_id . ', ' . $this->column_left_id . ' = ' . $set_left_id . ',
' . $this->column_right_id . ' = ' . $set_right_id . ' ' . $this->column_right_id . ' = ' . $set_right_id . '
' . ((!$set_subset_zero) ? ' WHERE ' . $sql_not_subset_items . ' ' . $this->get_sql_where('AND') : $this->get_sql_where('WHERE')); ' . ((!$set_subset_zero) ? ' WHERE ' . $sql_not_subset_items . ' ' . $this->get_sql_where('AND') : $this->get_sql_where('WHERE'));

View file

@ -765,11 +765,11 @@ class user extends \phpbb\session
/** /**
* Get option bit field from user options. * Get option bit field from user options.
* *
* @param int $key option key, as defined in $keyoptions property. * @param string $key option key, as defined in $keyoptions property.
* @param int|false $data bit field value to use, or false to use $this->data['user_options'] * @param int|false $data bit field value to use, or false to use $this->data['user_options']
* @return bool true if the option is set in the bit field, false otherwise * @return bool true if the option is set in the bit field, false otherwise
*/ */
function optionget($key, $data = false) function optionget(string $key, $data = false)
{ {
$var = ($data !== false) ? $data : $this->data['user_options']; $var = ($data !== false) ? $data : $this->data['user_options'];
return phpbb_optionget($this->keyoptions[$key], $var); return phpbb_optionget($this->keyoptions[$key], $var);

View file

@ -20,6 +20,8 @@
<referencedClass name="UnitEnum" /> <referencedClass name="UnitEnum" />
</errorLevel> </errorLevel>
</UndefinedDocblockClass> </UndefinedDocblockClass>
<UnsupportedPropertyReferenceUsage errorLevel="suppress" />
<MissingTemplateParam errorLevel="suppress" />
</issueHandlers> </issueHandlers>
<stubs> <stubs>