[ticket/16955] Fix phpdoc annotations and return types

PHPBB3-16955
This commit is contained in:
Ruben Calvo 2022-12-31 14:58:14 +01:00
parent 60aee47f50
commit 3e8fced5c8
No known key found for this signature in database
73 changed files with 251 additions and 205 deletions

View file

@ -99,7 +99,7 @@ class acp_language
/**
* Main handler for acp_language
*
* @param int $id Module ID
* @param string $id Module ID
* @param string $mode Module mode
*/
public function main($id, $mode)

View file

@ -55,7 +55,7 @@ class acp_storage
public $u_action;
/**
* @param string $id
* @param string $id
* @param string $mode
*/
public function main($id, $mode)

View file

@ -340,7 +340,7 @@ class mapped_diff extends diff
{
if (count($from_lines) != count($mapped_from_lines) || count($to_lines) != count($mapped_to_lines))
{
return false;
return;
}
parent::__construct($mapped_from_lines, $mapped_to_lines);
@ -760,11 +760,31 @@ class diff3 extends diff
*/
class diff3_op
{
/**
* @var array|mixed
*/
protected $orig;
/**
* @var array|mixed
*/
protected $final1;
/**
* @var array|mixed
*/
protected $final2;
/**
* @var false
*/
protected $_merged;
function __construct($orig = false, $final1 = false, $final2 = false)
{
$this->orig = $orig ? $orig : array();
$this->final1 = $final1 ? $final1 : array();
$this->final2 = $final2 ? $final2 : array();
$this->orig = $orig ?: array();
$this->final1 = $final1 ?: array();
$this->final2 = $final2 ?: array();
}
function merged()
@ -1059,8 +1079,6 @@ class diff3_op
return;
}
return;
}
}
@ -1074,7 +1092,7 @@ class diff3_op_copy extends diff3_op
{
function __construct($lines = false)
{
$this->orig = $lines ? $lines : array();
$this->orig = $lines ?: array();
$this->final1 = &$this->orig;
$this->final2 = &$this->orig;
}
@ -1098,6 +1116,21 @@ class diff3_op_copy extends diff3_op
*/
class diff3_block_builder
{
/**
* @var array
*/
protected $orig;
/**
* @var array
*/
protected $final1;
/**
* @var array
*/
protected $final2;
function __construct()
{
$this->_init();

View file

@ -1694,6 +1694,7 @@ function generate_board_url($without_script_path = false)
* @param string $url The url to redirect to
* @param bool $return If true, do not redirect but return the sanitized URL. Default is no return.
* @param bool $disable_cd_check If true, redirect() will redirect to an external domain. If false, the redirect point to the boards url if it does not match the current domain. Default is false.
* @return string|never
*/
function redirect($url, $return = false, $disable_cd_check = false)
{

View file

@ -2487,7 +2487,7 @@ function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_fr
* @param \phpbb\db\driver\driver_interface $db Database connection
* @param \phpbb\cache\driver\driver_interface $cache Cache driver
* @param \phpbb\auth\auth $auth Authentication object
* @return null
* @return void
*/
function phpbb_cache_moderators($db, $cache, $auth)
{

View file

@ -122,12 +122,12 @@ function tz_select($default = '', $truncate = false)
* must be carried through for the moderators table.
*
* @deprecated 3.1.0 (To be removed: 4.0.0)
* @return null
* @return void
*/
function cache_moderators()
{
global $db, $cache, $auth;
return phpbb_cache_moderators($db, $cache, $auth);
phpbb_cache_moderators($db, $cache, $auth);
}
/**
@ -249,7 +249,7 @@ function add_log()
* if it changes too frequently (true) to be
* efficiently cached.
*
* @return null
* @return void
*
* @deprecated 3.1.0 (To be removed: 4.0.0)
*/
@ -279,7 +279,7 @@ function set_config($config_name, $config_value, $is_dynamic = false, \phpbb\con
* if it changes too frequently (true) to be
* efficiently cached.
*
* @return null
* @return void
*
* @deprecated 3.1.0 (To be removed: 4.0.0)
*/
@ -336,7 +336,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, $
$static_request = $request;
if (empty($var_name))
{
return;
return null;
}
}
else if ($request === false)
@ -344,7 +344,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, $
$static_request = null;
if (empty($var_name))
{
return;
return null;
}
}
$tmp_request = $static_request;
@ -575,7 +575,7 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage
* Supported types are: MX (default), A, AAAA, NS, TXT, CNAME
* Other types may work or may not work
*
* @return mixed true if entry found,
* @return bool|null true if entry found,
* false if entry not found,
* null if this function is not supported by this environment
*
@ -615,7 +615,7 @@ function phpbb_inet_ntop($in_addr)
*
* @param string $address A human readable IPv4 or IPv6 address.
*
* @return mixed false if address is invalid,
* @return false|string false if address is invalid,
* in_addr representation of the given address otherwise (string)
*
* @deprecated 3.3.0-b2 (To be removed: 4.0.0)
@ -671,7 +671,7 @@ function phpbb_load_extensions_autoloaders($phpbb_root_path)
*
* @param array $param Parameter array, see $param_defaults array.
*
* @return null
* @return void
*
* @deprecated 3.2.10 (To be removed 4.0.0)
*/

View file

@ -144,8 +144,6 @@ function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key,
'sorts',
);
extract($phpbb_dispatcher->trigger_event('core.gen_sort_selects_after', compact($vars)));
return;
}
/**
@ -283,8 +281,6 @@ function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list
'S_JUMPBOX_ACTION' => $action,
'HIDDEN_FIELDS_FOR_JUMPBOX' => build_hidden_fields($url_parts['params']),
));
return;
}
/**
@ -441,6 +437,8 @@ function get_context($text, $words, $length = 400)
{
return str_replace($characters, $entities, ((utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text));
}
return '';
}
/**
@ -468,7 +466,7 @@ function phpbb_clean_search_string($search_string)
*
* @param string &$message Original message, passed by reference
* @param string $bbcode_uid BBCode UID
* @return null
* @return void
*/
function decode_message(&$message, $bbcode_uid = '')
{
@ -961,7 +959,6 @@ function make_clickable($text, $server_url = false, string $class = 'postlink')
if ($value == $static_class)
{
$element_exists = true;
return;
}
}
);

View file

@ -843,8 +843,6 @@ function generate_forum_nav(&$forum_data_ary)
$template->assign_block_vars_array('navlinks', $navlinks_parents);
$template->assign_block_vars('navlinks', $navlinks);
$template->assign_vars($forum_template_data);
return;
}
/**
@ -966,8 +964,6 @@ function get_moderators(&$forum_moderators, $forum_id = false)
}
}
$db->sql_freeresult($result);
return;
}
/**
@ -999,8 +995,6 @@ function gen_forum_auth_level($mode, $forum_id, $forum_status)
{
$template->assign_block_vars('rules', array('RULE' => $rule));
}
return;
}
/**
@ -1482,8 +1476,6 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id,
$s_watching['title_toggle'] = $user->lang[((!$is_watching) ? 'STOP' : 'START') . '_WATCHING_' . strtoupper($mode)];
$s_watching['is_watching'] = $is_watching;
}
return;
}
/**

View file

@ -79,6 +79,7 @@ abstract class base implements provider_interface
*/
public function login_link_has_necessary_data(array $login_link_data)
{
return null;
}
/**

View file

@ -424,6 +424,8 @@ class oauth extends base
{
return 'LOGIN_LINK_MISSING_DATA';
}
return null;
}
/**
@ -475,8 +477,6 @@ class oauth extends base
// Clear all tokens belonging to the user
$storage = new token_storage($this->db, $this->user, $this->oauth_token_table, $this->oauth_state_table);
$storage->clearAllTokens();
return;
}
/**
@ -617,7 +617,7 @@ class oauth extends base
* @param array $link_data The same variable given to
* {@see \phpbb\auth\provider\provider_interface::link_account}
* @param string $service_name The name of the service being used in linking.
* @return array|string|false Returns a language constant (string) if an error is encountered,
* @return string|false|never Returns a language constant (string) if an error is encountered,
* an array with error info or false on success.
*/
protected function link_account_auth_link(array $link_data, $service_name)
@ -661,7 +661,9 @@ class oauth extends base
}
else
{
return $this->set_redirect($service);
$this->set_redirect($service);
return false; // Not reached
}
}
@ -669,6 +671,7 @@ class oauth extends base
* Performs the query that inserts an account link
*
* @param array $data This array is passed to db->sql_build_array
* @return void
*/
protected function link_account_perform_link(array $data)
{
@ -852,6 +855,6 @@ class oauth extends base
redirect($service->getAuthorizationUri($parameters), false, true);
return [];
return []; // Never reached
}
}

View file

@ -151,7 +151,7 @@ interface provider_interface
*
* @param array $login_link_data Any data needed to link a phpBB account to
* an external account.
* @return string|void Returns a string with a language constant if there
* @return string|null Returns a string with a language constant if there
* is data missing or void if there is no error.
*/
public function login_link_has_necessary_data(array $login_link_data);

View file

@ -311,7 +311,7 @@ class manager
* avatar data
* @param string $table Database table from which the avatar should be deleted
* @param string $prefix Prefix of user data columns in database
* @return null
* @return void
*/
public function handle_avatar_delete(\phpbb\db\driver\driver_interface $db, \phpbb\user $user, $avatar_data, $table, $prefix)
{

View file

@ -1037,7 +1037,8 @@ class qa
{
return true;
}
return false;
}
return false;
}
}

View file

@ -150,6 +150,7 @@ class installer
* @param io\io_interface|null $io IO object used for the output
*
* @throws runtime_exception
* @throws JsonValidationException
*/
protected function do_install(array $packages, $whitelist, io\io_interface $io = null)
{
@ -501,6 +502,7 @@ class installer
*
* @param array $packages Packages to update.
* Each entry may be a name or an array associating a version constraint to a name
* @throws JsonValidationException
*/
protected function generate_ext_json_file(array $packages)
{

View file

@ -106,7 +106,7 @@ class config implements \ArrayAccess, \IteratorAggregate, \Countable
* @param String $key The configuration option's name
* @param bool $use_cache Whether this variable should be cached or if it
* changes too frequently to be efficiently cached
* @return null
* @return void
*/
public function delete($key, $use_cache = true)
{

View file

@ -72,7 +72,7 @@ class prune_shadow_topics extends \phpbb\cron\task\base implements \phpbb\cron\t
/**
* Runs this cron task.
*
* @return null
* @return void
*/
public function run()
{
@ -135,7 +135,7 @@ class prune_shadow_topics extends \phpbb\cron\task\base implements \phpbb\cron\t
*
* @param \phpbb\request\request_interface $request Request object.
*
* @return null
* @return void
*/
public function parse_parameters(\phpbb\request\request_interface $request)
{

View file

@ -1246,7 +1246,7 @@ abstract class driver implements driver_interface
$this->html_hold .= '<tr>';
$class = 'row1';
foreach (array_values($row) as $val)
foreach ($row as $val)
{
$class = ($class == 'row1') ? 'row2' : 'row1';
$this->html_hold .= '<td class="' . $class . '">' . (($val) ? $val : '&nbsp;') . '</td>';

View file

@ -365,7 +365,7 @@ interface driver_interface
*
* @param mixed $query_id Already executed query result,
* if false, the last query will be used.
* @return null
* @return void
*/
public function sql_freeresult($query_id = false);

View file

@ -780,8 +780,6 @@ class oracle extends \phpbb\db\driver\driver
$success = @oci_execute($result, OCI_DEFAULT);
if ($success)
{
array();
while ($row = oci_fetch_array($result, OCI_ASSOC + OCI_RETURN_NULLS))
{
// Take the time spent on parsing rows into account

View file

@ -20,7 +20,7 @@ class mssql_extractor extends base_extractor
/**
* Writes closing line(s) to database backup
*
* @return null
* @return void
* @throws extractor_not_initialized_exception when calling this function before init_extractor()
*/
public function write_end()
@ -310,7 +310,7 @@ class mssql_extractor extends base_extractor
* Extracts data from database table (for ODBC driver)
*
* @param string $table_name name of the database table
* @return null
* @return void
* @throws extractor_not_initialized_exception when calling this function before init_extractor()
*/
protected function write_data_odbc($table_name)

View file

@ -323,7 +323,7 @@ class postgres_extractor extends base_extractor
/**
* Writes closing line(s) to database backup
*
* @return null
* @return void
* @throws extractor_not_initialized_exception when calling this function before init_extractor()
*/
public function write_end()

View file

@ -135,7 +135,7 @@ class sqlite3_extractor extends base_extractor
/**
* Writes closing line(s) to database backup
*
* @return null
* @return void
* @throws extractor_not_initialized_exception when calling this function before init_extractor()
*/
public function write_end()

View file

@ -161,5 +161,7 @@ class config implements \phpbb\db\migration\tool\tool_interface
{
return call_user_func_array(array(&$this, $call), $arguments);
}
return null;
}
}

View file

@ -126,5 +126,7 @@ class config_text implements \phpbb\db\migration\tool\tool_interface
{
return call_user_func_array(array(&$this, $call), $arguments);
}
return null;
}
}

View file

@ -339,7 +339,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
* Use false to ignore the parent check and check class wide.
* @param int|string $module The module id|module_langname
* specify that here
* @return null
* @return void
* @throws \phpbb\db\migration\exception
*/
public function remove($class, $parent = 0, $module = '')
@ -350,7 +350,8 @@ class module implements \phpbb\db\migration\tool\tool_interface
if (isset($module['module_langname']))
{
// Manual Method
return $this->remove($class, $parent, $module['module_langname']);
$this->remove($class, $parent, $module['module_langname']);
return;
}
// Failed.
@ -443,6 +444,8 @@ class module implements \phpbb\db\migration\tool\tool_interface
{
return call_user_func_array(array(&$this, $call), $arguments);
}
return null;
}
/**
@ -470,7 +473,7 @@ class module implements \phpbb\db\migration\tool\tool_interface
* key - module_id
* value - module_langname
*
* @return null
* @return void
*/
protected function get_categories_list()
{

View file

@ -411,7 +411,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
* @param string $type The type (role|group)
* @param bool $has_permission True if you want to give them permission,
* false if you want to deny them permission
* @return null
* @return void
* @throws \phpbb\db\migration\exception
*/
public function permission_set($name, $auth_option, $type = 'role', $has_permission = true)
@ -506,7 +506,8 @@ class permission implements \phpbb\db\migration\tool\tool_interface
if (count($auth_option))
{
return $this->permission_set($role_name, $auth_option, 'role', $has_permission);
$this->permission_set($role_name, $auth_option, 'role', $has_permission);
return;
}
}
@ -570,7 +571,7 @@ class permission implements \phpbb\db\migration\tool\tool_interface
* @param string|array $auth_option The auth_option or array of
* auth_options you would like to set
* @param string $type The type (role|group)
* @return null
* @return void
* @throws \phpbb\db\migration\exception
*/
public function permission_unset($name, $auth_option, $type = 'role')
@ -643,7 +644,8 @@ class permission implements \phpbb\db\migration\tool\tool_interface
throw new \phpbb\db\migration\exception('ROLE_ASSIGNED_NOT_EXIST', $name, $role_id);
}
return $this->permission_unset($role_name, $auth_option, 'role');
$this->permission_unset($role_name, $auth_option, 'role');
return;
}
$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '

View file

@ -15,6 +15,7 @@ namespace phpbb\db;
use phpbb\config\config;
use phpbb\db\driver\driver_interface;
use phpbb\db\migration\exception;
use phpbb\db\migration\helper;
use phpbb\db\output_handler\migrator_output_handler_interface;
use phpbb\db\output_handler\null_migrator_output_handler;
@ -157,7 +158,7 @@ class migrator
/**
* Loads all migrations and their application state from the database.
*
* @return null
* @return void
*/
public function load_migration_state()
{
@ -203,7 +204,7 @@ class migrator
* Sets the list of available migration class names to the given array.
*
* @param array $class_names An array of migration class names
* @return null
* @return void
*/
public function set_migrations($class_names)
{
@ -256,7 +257,7 @@ class migrator
* The update step can either be a schema or a (partial) data update. To
* check if update() needs to be called again use the finished() method.
*
* @return null
* @return void
*/
public function update()
{
@ -329,7 +330,7 @@ class migrator
*
* @param string $name The class name of the migration
* @return bool Whether any update step was successfully run
* @throws \phpbb\db\migration\exception
* @throws exception
*/
protected function try_apply($name)
{
@ -365,7 +366,7 @@ class migrator
$missing = $this->unfulfillable($depend);
if ($missing !== false)
{
throw new \phpbb\db\migration\exception('MIGRATION_NOT_FULFILLABLE', $name, $missing);
throw new exception('MIGRATION_NOT_FULFILLABLE', $name, $missing);
}
if (!isset($this->migration_state[$depend]) ||
@ -480,7 +481,7 @@ class migrator
$this->output_handler->write(array('MIGRATION_DATA_IN_PROGRESS', $name, $elapsed_time), migrator_output_handler_interface::VERBOSITY_VERY_VERBOSE);
}
}
catch (\phpbb\db\migration\exception $e)
catch (exception $e)
{
// Reset data state and revert the schema changes
$state['migration_data_state'] = '';
@ -653,7 +654,7 @@ class migrator
* @param bool $revert true to revert a data step
* @return bool|array migration state. True if completed, serialized array if not finished
* @psalm-return bool|array{result: mixed, step: int}
* @throws \phpbb\db\migration\exception
* @throws exception
*/
protected function process_data_step($steps, $state, $revert = false)
{
@ -693,7 +694,7 @@ class migrator
);
}
}
catch (\phpbb\db\migration\exception $e)
catch (exception $e)
{
// We should try rolling back here
foreach ($steps as $reverse_step_identifier => $reverse_step)
@ -715,15 +716,16 @@ class migrator
}
/**
* Run a single step
*
* An exception should be thrown if an error occurs
*
* @param mixed $step Data step from migration
* @param mixed $last_result Result to pass to the callable (only for 'custom' method)
* @param bool $reverse False to install, True to attempt uninstallation by reversing the call
* @return null
*/
* Run a single step
*
* An exception should be thrown if an error occurs
*
* @param mixed $step Data step from migration
* @param mixed $last_result Result to pass to the callable (only for 'custom' method)
* @param bool $reverse False to install, True to attempt uninstallation by reversing the call
* @return mixed
* @throws exception
*/
protected function run_step($step, $last_result = 0, $reverse = false)
{
$callable_and_parameters = $this->get_callable_from_step($step, $last_result, $reverse);
@ -747,7 +749,7 @@ class migrator
* @param bool $reverse False to install, True to attempt uninstallation by reversing the call
* @return array|false Array with parameters for call_user_func_array(), 0 is the callable, 1 is parameters;
* false if no callable can be created from data setp
* @throws \phpbb\db\migration\exception
* @throws exception
*/
protected function get_callable_from_step(array $step, $last_result = 0, $reverse = false)
{
@ -769,12 +771,12 @@ class migrator
case 'if':
if (!isset($parameters[0]))
{
throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_MISSING_CONDITION', $step);
throw new exception('MIGRATION_INVALID_DATA_MISSING_CONDITION', $step);
}
if (!isset($parameters[1]))
{
throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_MISSING_STEP', $step);
throw new exception('MIGRATION_INVALID_DATA_MISSING_STEP', $step);
}
if ($reverse)
@ -799,7 +801,7 @@ class migrator
case 'custom':
if (!is_callable($parameters[0]))
{
throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_CUSTOM_NOT_CALLABLE', $step);
throw new exception('MIGRATION_INVALID_DATA_CUSTOM_NOT_CALLABLE', $step);
}
if ($reverse)
@ -818,17 +820,17 @@ class migrator
default:
if (!$method)
{
throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_UNKNOWN_TYPE', $step);
throw new exception('MIGRATION_INVALID_DATA_UNKNOWN_TYPE', $step);
}
if (!isset($this->tools[$class]))
{
throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_UNDEFINED_TOOL', $step);
throw new exception('MIGRATION_INVALID_DATA_UNDEFINED_TOOL', $step);
}
if (!method_exists(get_class($this->tools[$class]), $method))
{
throw new \phpbb\db\migration\exception('MIGRATION_INVALID_DATA_UNDEFINED_METHOD', $step);
throw new exception('MIGRATION_INVALID_DATA_UNDEFINED_METHOD', $step);
}
// Attempt to reverse operations
@ -855,7 +857,7 @@ class migrator
*
* @param string $name Name of the migration
* @param array $state
* @return null
* @return void
*/
protected function set_migration_state($name, $state)
{
@ -993,7 +995,7 @@ class migrator
* THIS WILL THROW ERRORS IF MIGRATIONS ALREADY EXIST IN THE TABLE, DO NOT CALL MORE THAN ONCE!
*
* @param array $migrations Array of migrations (names) to add to the migrations table
* @return null
* @return void
*/
public function populate_migrations($migrations)
{
@ -1016,7 +1018,7 @@ class migrator
/**
* Creates the migrations table if it does not exist.
* @return null
* @return void
*/
public function create_migrations_table()
{

View file

@ -143,6 +143,7 @@ class container_builder
* Build and return a new Container respecting the current configuration
*
* @return \phpbb_cache_container|ContainerBuilder
* @throws \Exception
*/
public function get_container()
{

View file

@ -429,7 +429,7 @@ class md_exporter
* Validates a template event name
*
* @param $event_name
* @return null
* @return void
* @throws \LogicException
*/
public function validate_event_name($event_name)

View file

@ -84,7 +84,7 @@ class php_exporter
*
* @param string $name Name of the current event (used for error messages)
* @param int $line Line where the current event is placed in
* @return null
* @return void
*/
public function set_current_event($name, $line)
{
@ -96,7 +96,7 @@ class php_exporter
* Set the content of this file
*
* @param array $content Array with the lines of the file
* @return null
* @return void
*/
public function set_content($content)
{
@ -790,7 +790,7 @@ class php_exporter
*
* @param array $vars_array Variables found in the array line
* @param array $vars_docblock Variables found in the doc block
* @return null
* @return void
* @throws \LogicException
*/
public function validate_vars_docblock_array($vars_array, $vars_docblock)

View file

@ -254,7 +254,7 @@ class manager
* so never call this in a script that has a max_execution time.
*
* @param string $name The extension's name
* @return null
* @return void
*/
public function enable($name)
{
@ -302,7 +302,7 @@ class manager
* while so never call this in a script that has a max_execution time.
*
* @param string $name The extension's name
* @return null
* @return void
*/
public function disable($name)
{
@ -357,7 +357,7 @@ class manager
* so never call this in a script that has a max_execution time.
*
* @param string $name The extension's name
* @return null
* @return void
*/
public function purge($name)
{

View file

@ -30,7 +30,7 @@ class file_downloader
* @param int $port Port to connect to; default: 80
* @param int $timeout Connection timeout in seconds; default: 6
*
* @return mixed File data as string if file can be read and there is no
* @return false|string File data as string if file can be read and there is no
* timeout, false if there were errors or the connection timed out
*
* @throws \phpbb\exception\runtime_exception If data can't be retrieved and no error

View file

@ -110,12 +110,13 @@ class legend implements \phpbb\groupposition\groupposition_interface
}
/**
* Deletes a group by setting the field to self::GROUP_DISABLED and closing the gap in the list.
*
* @param int $group_id group_id of the group to be deleted
* @param bool $skip_group Skip setting the value for this group, to save the query, when you need to update it anyway.
* @return bool True if the group was deleted successfully
*/
* Deletes a group by setting the field to self::GROUP_DISABLED and closing the gap in the list.
*
* @param int $group_id group_id of the group to be deleted
* @param bool $skip_group Skip setting the value for this group, to save the query, when you need to update it anyway.
* @return bool True if the group was deleted successfully
* @throws exception
*/
public function delete_group($group_id, $skip_group = false)
{
$current_value = $this->get_group_value($group_id);

View file

@ -96,7 +96,7 @@ class show extends \phpbb\console\command\command
try
{
$config = Yaml::parse(file_get_contents($config_file), true, false);
$config = Yaml::parse(file_get_contents($config_file), true);
}
catch (ParseException $e)
{
@ -119,7 +119,7 @@ class show extends \phpbb\console\command\command
return Command::FAILURE;
}
$style->block(Yaml::dump(array('installer' => $config), 10, 4, true, false));
$style->block(Yaml::dump(array('installer' => $config), 10, 4, true));
return Command::SUCCESS;
}

View file

@ -96,7 +96,7 @@ class validate extends \phpbb\console\command\command
try
{
$config = Yaml::parse(file_get_contents($config_file), true, false);
$config = Yaml::parse(file_get_contents($config_file), true);
}
catch (ParseException $e)
{

View file

@ -16,6 +16,7 @@ namespace phpbb\install\console\command\install;
use phpbb\install\exception\installer_exception;
use phpbb\install\helper\install_helper;
use phpbb\install\helper\iohandler\cli_iohandler;
use phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception;
use phpbb\install\helper\iohandler\factory;
use phpbb\install\installer;
use phpbb\install\installer_configuration;
@ -90,10 +91,11 @@ class install extends \phpbb\console\command\command
*
* Install the board
*
* @param InputInterface $input An InputInterface instance
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return int 0 if everything went fine, or a non-zero exit code
* @throws iohandler_not_implemented_exception
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
@ -124,7 +126,7 @@ class install extends \phpbb\console\command\command
try
{
$config = Yaml::parse(file_get_contents($config_file), true, false);
$config = Yaml::parse(file_get_contents($config_file), true);
}
catch (ParseException $e)
{

View file

@ -96,7 +96,7 @@ class show extends \phpbb\console\command\command
try
{
$config = Yaml::parse(file_get_contents($config_file), true, false);
$config = Yaml::parse(file_get_contents($config_file), true);
}
catch (ParseException $e)
{
@ -119,7 +119,7 @@ class show extends \phpbb\console\command\command
return Command::FAILURE;
}
$style->block(Yaml::dump(array('updater' => $config), 10, 4, true, false));
$style->block(Yaml::dump(array('updater' => $config), 10, 4, true));
return Command::SUCCESS;
}

View file

@ -96,7 +96,7 @@ class validate extends \phpbb\console\command\command
try
{
$config = Yaml::parse(file_get_contents($config_file), true, false);
$config = Yaml::parse(file_get_contents($config_file), true);
}
catch (ParseException $e)
{

View file

@ -124,7 +124,7 @@ class update extends \phpbb\console\command\command
try
{
$config = Yaml::parse(file_get_contents($config_file), true, false);
$config = Yaml::parse(file_get_contents($config_file), true);
}
catch (ParseException $e)
{

View file

@ -99,6 +99,7 @@ class install
* @return Response|StreamedResponse
*
* @throws http_exception When phpBB is already installed
* @throws \phpbb\install\helper\iohandler\exception\iohandler_not_implemented_exception
* @psalm-suppress InvalidNullableReturnType
*/
public function handle()

View file

@ -94,9 +94,9 @@ class ajax_iohandler extends iohandler_base
* @param \phpbb\request\request_interface $request HTTP request interface
* @param \phpbb\template\template $template Template engine
* @param router $router Router
* @param string $root_path Path to phpBB's root
* @param string $root_path Path to phpBB's root
*/
public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, $root_path)
public function __construct(path_helper $path_helper, \phpbb\request\request_interface $request, \phpbb\template\template $template, router $router, string $root_path)
{
$this->path_helper = $path_helper;
$this->request = $request;

View file

@ -129,7 +129,7 @@ class log implements \phpbb\log\log_interface
* in get_logs()
*
* @param bool $is_in_admin Are we called from within the acp?
* @return null
* @return void
*/
public function set_is_admin($is_in_admin)
{
@ -150,7 +150,7 @@ class log implements \phpbb\log\log_interface
* Set table name
*
* @param string $log_table Can overwrite the table to use for the logs
* @return null
* @return void
*/
public function set_log_table($log_table)
{

View file

@ -65,7 +65,7 @@ class message
* Set the subject of the email
*
* @param string $subject
* @return null
* @return void
*/
public function set_subject($subject)
{
@ -76,7 +76,7 @@ class message
* Set the body of the email text
*
* @param string $body
* @return null
* @return void
*/
public function set_body($body)
{
@ -87,7 +87,7 @@ class message
* Set the name of the email template to use
*
* @param string $template
* @return null
* @return void
*/
public function set_template($template)
{
@ -98,7 +98,7 @@ class message
* Set the array with the "template" data for the email
*
* @param array $template_vars
* @return null
* @return void
*/
public function set_template_vars($template_vars)
{
@ -109,7 +109,7 @@ class message
* Add a recipient from \phpbb\user
*
* @param array $user
* @return null
* @return void
*/
public function add_recipient_from_user_row(array $user)
{
@ -132,7 +132,7 @@ class message
* @param int $recipient_notify_type Used notification methods (Jabber, Email, ...)
* @param string $recipient_username User Name (used for AntiAbuse header)
* @param string $recipient_jabber
* @return null
* @return void
*/
public function add_recipient($recipient_name, $recipient_address, $recipient_lang, $recipient_notify_type = NOTIFY_EMAIL, $recipient_username = '', $recipient_jabber = '')
{
@ -151,7 +151,7 @@ class message
* Set the senders data from \phpbb\user object
*
* @param \phpbb\user $user
* @return null
* @return void
*/
public function set_sender_from_user($user)
{
@ -178,7 +178,7 @@ class message
* @param int $sender_id User ID
* @param string $sender_username User Name (used for AntiAbuse header)
* @param string $sender_jabber
* @return null
* @return void
*/
public function set_sender($sender_ip, $sender_name, $sender_address, $sender_lang = '', $sender_id = 0, $sender_username = '', $sender_jabber = '')
{
@ -195,7 +195,7 @@ class message
* Which notification type should be used? Jabber, Email, ...?
*
* @param int $sender_notify_type
* @return null
* @return void
*/
public function set_sender_notify_type($sender_notify_type)
{
@ -205,7 +205,7 @@ class message
/**
* Ok, now the same email if CC specified, but without exposing the user's email address
*
* @return null
* @return void
*/
public function cc_sender()
{

View file

@ -117,7 +117,7 @@ class email extends \phpbb\notification\method\messenger_base
$insert_buffer->flush();
return $this->notify_using_messenger(NOTIFY_EMAIL);
$this->notify_using_messenger(NOTIFY_EMAIL);
}
/**

View file

@ -29,8 +29,10 @@ class admin_activate_user extends \phpbb\notification\type\base
}
/**
* {@inheritdoc}
*/
* Language key used to output the text
*
* @var string
*/
protected $language_key = 'NOTIFICATION_ADMIN_ACTIVATE_USER';
/**

View file

@ -128,9 +128,7 @@ class approve_post extends \phpbb\notification\type\post
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -127,9 +127,7 @@ class approve_topic extends \phpbb\notification\type\topic
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -129,7 +129,7 @@ abstract class base implements \phpbb\notification\type\type_interface
*/
public function __get($name)
{
return (!isset($this->data[$name])) ? null : $this->data[$name];
return $this->data[$name] ?? null;
}
@ -139,13 +139,24 @@ abstract class base implements \phpbb\notification\type\type_interface
* @param mixed $name
* @param mixed $value
*
* @return null
* @return void
*/
public function __set($name, $value)
{
$this->data[$name] = $value;
}
/**
* Magic method check if a variable is defined and is not null
*
* @param mixed $name
*
* @return bool
*/
public function __isset($name)
{
return isset($this->data[$name]);
}
/**
* Magic method to get a string of this notification
@ -394,7 +405,6 @@ abstract class base implements \phpbb\notification\type\type_interface
*/
public function load_special($data, $notifications)
{
return;
}
/**
@ -407,6 +417,14 @@ abstract class base implements \phpbb\notification\type\type_interface
return true;
}
/**
* {@inheritdoc}
*/
public function get_email_template()
{
return false;
}
/**
* Pre create insert array function (fall back)
*

View file

@ -57,13 +57,14 @@ class bookmark extends \phpbb\notification\type\post
}
/**
* Find the users who want to receive notifications
*
* @param array $type_data Data from submit_post
* @param array $options Options for finding users for notification
*
* @return array
*/
* Find the users who want to receive notifications
*
* @param array $type_data Data from submit_post
* @param array $options Options for finding users for notification
*
* @return array
* @throws \Exception
*/
public function find_users_for_notification($type_data, $options = array())
{
$options = array_merge(array(
@ -117,9 +118,7 @@ class bookmark extends \phpbb\notification\type\post
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -148,9 +148,7 @@ class disapprove_post extends \phpbb\notification\type\approve_post
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -148,9 +148,7 @@ class disapprove_topic extends \phpbb\notification\type\approve_topic
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -104,9 +104,7 @@ class forum extends \phpbb\notification\type\post
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -145,9 +145,7 @@ class pm extends \phpbb\notification\type\base
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -238,9 +238,7 @@ class post extends \phpbb\notification\type\base
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -152,9 +152,7 @@ class post_in_queue extends \phpbb\notification\type\post
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -149,9 +149,7 @@ class quote extends \phpbb\notification\type\post
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -125,9 +125,7 @@ class report_pm extends \phpbb\notification\type\pm
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -84,9 +84,7 @@ class report_pm_closed extends \phpbb\notification\type\pm
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -91,9 +91,7 @@ class report_post extends \phpbb\notification\type\post_in_queue
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -91,9 +91,7 @@ class report_post_closed extends \phpbb\notification\type\post
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -191,9 +191,7 @@ class topic extends \phpbb\notification\type\base
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -144,9 +144,7 @@ class topic_in_queue extends \phpbb\notification\type\topic
}
/**
* Get email template
*
* @return string|bool
* {@inheritdoc}
*/
public function get_email_template()
{

View file

@ -100,7 +100,7 @@ class plupload
// and handle the file as usual
if ($chunks_expected < 2)
{
return;
return null;
}
$file_name = $this->request->variable('name', '');
@ -150,7 +150,7 @@ class plupload
* @param int $forum_id The ID of the forum
* @param int $max_files Maximum number of files allowed. 0 for unlimited.
*
* @return null
* @return void
*/
public function configure(\phpbb\cache\service $cache, \phpbb\template\template $template, $s_action, $forum_id, $max_files)
{
@ -200,7 +200,7 @@ class plupload
* @param int $code The error code
* @param string $msg The translation string of the message to be sent
*
* @return null
* @return void
*/
public function emit_error($code, $msg)
{
@ -331,7 +331,7 @@ class plupload
* @param int $chunk Chunk number
* @param string $file_path File path
*
* @return null
* @return void
*/
protected function integrate_uploaded_file($form_name, $chunk, $file_path)
{
@ -378,7 +378,7 @@ class plupload
/**
* Creates the temporary directory if it does not already exist.
*
* @return null
* @return void
*/
protected function prepare_temporary_directory()
{
@ -396,7 +396,7 @@ class plupload
/**
* Sets the default directories for uploads
*
* @return null
* @return void
*/
protected function set_default_directories()
{
@ -410,7 +410,7 @@ class plupload
* @param string $upload_directory Upload directory
* @param string $temporary_directory Temporary directory
*
* @return null
* @return void
*/
public function set_upload_directories($upload_directory, $temporary_directory)
{

View file

@ -179,7 +179,6 @@ abstract class type_base implements type_interface
*/
public function display_options(&$template_vars, &$field_data)
{
return;
}
/**

View file

@ -258,7 +258,7 @@ class report
* @param array $error
* @param string $s_hidden_fields
* @param mixed $captcha
* @return null
* @return void
*/
protected function assign_template_data($mode, $id, $reason_id, $report_text, $user_notify, $error = array(), $s_hidden_fields = '', $captcha = false)
{

View file

@ -1068,8 +1068,6 @@ class session
* @since 3.1.6-RC1
*/
$phpbb_dispatcher->trigger_event('core.session_gc_after');
return;
}
/**
@ -1143,7 +1141,7 @@ class session
if (defined('IN_CHECK_BAN') || defined('SKIP_CHECK_BAN'))
{
return;
return false;
}
$banned = false;

View file

@ -289,7 +289,7 @@ class attachment extends controller
*/
protected function filenameFallback($filename)
{
$filename = preg_replace(['/[^\x20-\x7e]/', '/%/', '/\//', '/\\\/'], '', $filename);
$filename = preg_replace(['/[^\x20-\x7e]/', '/%/', '/\//', '/\\\\/'], '', $filename);
return (!empty($filename)) ?: 'File';
}

View file

@ -21,9 +21,8 @@ class defineparser extends \Twig\TokenParser\AbstractTokenParser
*
* @param \Twig\Token $token A Twig\Token instance
*
* @return \Twig\Node\Node A Twig\Node instance
* @throws \Twig\Error\SyntaxError
* @return \phpbb\template\twig\node\definenode
* @return \Twig\Node\Node A Twig\Node instance
*/
public function parse(\Twig\Token $token)
{

View file

@ -148,7 +148,7 @@ class renderer implements \phpbb\textformatter\renderer_interface
*
* @param \phpbb\config\config $config
* @param \phpbb\path_helper $path_helper
* @return null
* @return void
*/
public function configure_smilies_path(\phpbb\config\config $config, \phpbb\path_helper $path_helper)
{

View file

@ -40,8 +40,11 @@ abstract class base implements reparser_interface
abstract protected function get_records_by_range($min_id, $max_id);
/**
* {@inheritdoc}
*/
* Save record
*
* @param array $record
* @return void
*/
abstract protected function save_record(array $record);
/**

View file

@ -470,14 +470,18 @@ class user extends \phpbb\session
* @param $number int|float The number we want to get the plural case for. Float numbers are floored.
* @param $force_rule mixed False to use the plural rule of the language package
* or an integer to force a certain plural rule
* @return int|bool The plural-case we need to use for the number plural-rule combination, false if $force_rule
* @return int|false The plural-case we need to use for the number plural-rule combination, false if $force_rule
* was invalid.
*
* @deprecated: 3.2.0-dev (To be removed: 4.0.0)
*/
function get_plural_form($number, $force_rule = false)
{
return $this->language->get_plural_form($number, $force_rule);
try {
return $this->language->get_plural_form($number, $force_rule);
} catch (\phpbb\language\exception\invalid_plural_rule_exception $e) {
return false;
}
}
/**

View file

@ -110,7 +110,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
'autoescape' => false,
)
);
$this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)));
$this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $lang)));
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
$this->template->set_custom_style('tests', $this->template_path);
}

View file

@ -15,6 +15,16 @@ require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php';
class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
{
/**
* @var phpbb_mock_cache
*/
private $cache;
/**
* @var phpbb_mock_event_dispatcher
*/
private $dispatcher;
protected function setUp(): void
{
$this->cache = new phpbb_mock_cache;