diff --git a/phpBB/phpbb/install/console/command/install/config/show.php b/phpBB/phpbb/install/console/command/install/config/show.php index b6c11956fe..58ad7397da 100644 --- a/phpBB/phpbb/install/console/command/install/config/show.php +++ b/phpBB/phpbb/install/console/command/install/config/show.php @@ -73,7 +73,7 @@ class show extends \phpbb\console\command\command * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * - * @return null + * @return int 0 if everything went fine, or a non-zero exit code */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -90,7 +90,7 @@ class show extends \phpbb\console\command\command { $iohandler->add_error_message(array('MISSING_FILE', $config_file)); - return; + return 1; } try @@ -101,7 +101,7 @@ class show extends \phpbb\console\command\command { $iohandler->add_error_message('INVALID_YAML_FILE'); - return; + return 1; } $processor = new Processor(); @@ -115,9 +115,11 @@ class show extends \phpbb\console\command\command { $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); - return; + return 1; } $style->block(Yaml::dump(array('installer' => $config), 10, 4, true, false)); + + return 0; } } diff --git a/phpBB/phpbb/install/console/command/install/config/validate.php b/phpBB/phpbb/install/console/command/install/config/validate.php index b48a1acbd4..0b8a28beaa 100644 --- a/phpBB/phpbb/install/console/command/install/config/validate.php +++ b/phpBB/phpbb/install/console/command/install/config/validate.php @@ -73,7 +73,7 @@ class validate extends \phpbb\console\command\command * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * - * @return null + * @return int 0 if everything went fine, or a non-zero exit code */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/phpBB/phpbb/install/console/command/install/install.php b/phpBB/phpbb/install/console/command/install/install.php index 980586cb0e..e50eeeb5bc 100644 --- a/phpBB/phpbb/install/console/command/install/install.php +++ b/phpBB/phpbb/install/console/command/install/install.php @@ -92,7 +92,7 @@ class install extends \phpbb\console\command\command * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * - * @return null + * @return int 0 if everything went fine, or a non-zero exit code */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/phpBB/phpbb/install/console/command/update/config/show.php b/phpBB/phpbb/install/console/command/update/config/show.php index e462763b5d..138c5cae28 100644 --- a/phpBB/phpbb/install/console/command/update/config/show.php +++ b/phpBB/phpbb/install/console/command/update/config/show.php @@ -73,7 +73,7 @@ class show extends \phpbb\console\command\command * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * - * @return null + * @return int 0 if everything went fine, or a non-zero exit code */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -90,7 +90,7 @@ class show extends \phpbb\console\command\command { $iohandler->add_error_message(array('MISSING_FILE', $config_file)); - return; + return 1; } try @@ -101,7 +101,7 @@ class show extends \phpbb\console\command\command { $iohandler->add_error_message('INVALID_YAML_FILE'); - return; + return 1; } $processor = new Processor(); @@ -115,9 +115,11 @@ class show extends \phpbb\console\command\command { $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage()); - return; + return 1; } $style->block(Yaml::dump(array('updater' => $config), 10, 4, true, false)); + + return 0; } } diff --git a/phpBB/phpbb/install/console/command/update/config/validate.php b/phpBB/phpbb/install/console/command/update/config/validate.php index 18de5eab46..8a0d963ac2 100644 --- a/phpBB/phpbb/install/console/command/update/config/validate.php +++ b/phpBB/phpbb/install/console/command/update/config/validate.php @@ -73,7 +73,7 @@ class validate extends \phpbb\console\command\command * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * - * @return null + * @return int 0 if everything went fine, or a non-zero exit code */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/phpBB/phpbb/install/controller/install.php b/phpBB/phpbb/install/controller/install.php index 92506872a3..47acc2953f 100644 --- a/phpBB/phpbb/install/controller/install.php +++ b/phpBB/phpbb/install/controller/install.php @@ -99,6 +99,7 @@ class install * @return Response|StreamedResponse * * @throws http_exception When phpBB is already installed + * @psalm-suppress InvalidNullableReturnType */ public function handle() { diff --git a/phpBB/phpbb/install/database_task.php b/phpBB/phpbb/install/database_task.php index 81864773c5..758e511c1a 100644 --- a/phpBB/phpbb/install/database_task.php +++ b/phpBB/phpbb/install/database_task.php @@ -93,9 +93,9 @@ abstract class database_task extends task_base * * @param string $sql The SQL. * - * @return DriverStmt|Statement The prepared statement object. + * @return Statement|null The prepared statement object or null if preparing failed */ - protected function create_prepared_stmt(string $sql) + protected function create_prepared_stmt(string $sql): ?Statement { try { @@ -153,13 +153,13 @@ abstract class database_task extends task_base /** * Returns the last insert ID. * - * @return string|null The last insert ID. + * @return int|null The last insert ID. */ - protected function get_last_insert_id() : ?string + protected function get_last_insert_id() : ?int { try { - return $this->conn->lastInsertId(); + return (int) $this->conn->lastInsertId(); } catch (Exception $e) { diff --git a/phpBB/phpbb/install/event/kernel_exception_subscriber.php b/phpBB/phpbb/install/event/kernel_exception_subscriber.php index dd0d15c72e..79a5bbc8b9 100644 --- a/phpBB/phpbb/install/event/kernel_exception_subscriber.php +++ b/phpBB/phpbb/install/event/kernel_exception_subscriber.php @@ -113,14 +113,12 @@ class kernel_exception_subscriber implements EventSubscriberInterface } /** - * Returns an array of events the object is subscribed to - * - * @return array Array of events the object is subscribed to + * {@inheritDoc} */ public static function getSubscribedEvents() { - return array( + return [ KernelEvents::EXCEPTION => 'on_kernel_exception', - ); + ]; } } diff --git a/phpBB/phpbb/install/helper/container_factory.php b/phpBB/phpbb/install/helper/container_factory.php index e689e44cde..b5869b67d0 100644 --- a/phpBB/phpbb/install/helper/container_factory.php +++ b/phpBB/phpbb/install/helper/container_factory.php @@ -75,7 +75,7 @@ class container_factory * * @param null|string $service_name Name of the service to return * - * @return \Symfony\Component\DependencyInjection\ContainerInterface|Object phpBB's dependency injection container + * @return \Symfony\Component\DependencyInjection\ContainerInterface|object|null phpBB's dependency injection container * or the service specified in $service_name * * @throws cannot_build_container_exception When container cannot be built @@ -91,7 +91,7 @@ class container_factory $this->build_container(); } - return ($service_name === null) ? $this->container : $this->container->get($service_name); + return $service_name === null ? $this->container : $this->container->get($service_name); } /** diff --git a/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php b/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php index c1044a3a1f..6e4fc2a845 100644 --- a/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php +++ b/phpBB/phpbb/install/helper/file_updater/compression_file_updater.php @@ -21,7 +21,7 @@ use phpbb\install\helper\update_helper; class compression_file_updater implements file_updater_interface { /** - * @var \compress|null + * @var \compress_zip|\compress_tar|null */ protected $compress; @@ -86,7 +86,10 @@ class compression_file_updater implements file_updater_interface */ public function close() { - $this->compress->close(); + if ($this->compress !== null) + { + $this->compress->close(); + } } /** diff --git a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php index c235b8557a..06695f5057 100644 --- a/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/ajax_iohandler.php @@ -82,7 +82,7 @@ class ajax_iohandler extends iohandler_base protected $redirect_url; /** - * @var resource + * @var resource|closed-resource */ protected $file_lock_pointer; @@ -235,7 +235,9 @@ class ajax_iohandler extends iohandler_base 'form_install' => 'installer_form.html', )); - return $this->template->assign_display('form_install'); + $compiled_template = $this->template->assign_display('form_install'); + + return is_string($compiled_template) ? $compiled_template : ''; } /** diff --git a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php index 9553b11d34..5485fb3bfc 100644 --- a/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php +++ b/phpBB/phpbb/install/helper/iohandler/cli_iohandler.php @@ -188,11 +188,11 @@ class cli_iohandler extends iohandler_base /** * {@inheritdoc */ - public function add_success_message($error_title, $error_description = false) + public function add_success_message($success_title, $success_description = false) { $this->io->newLine(); - $message = $this->translate_message($error_title, $error_description); + $message = $this->translate_message($success_title, $success_description); $message_string = $message['title'] . (!empty($message['description']) ? "\n" . $message['description'] : ''); $this->io->success($message_string); diff --git a/phpBB/phpbb/install/helper/iohandler/factory.php b/phpBB/phpbb/install/helper/iohandler/factory.php index 5ea1b93398..56503efdbd 100644 --- a/phpBB/phpbb/install/helper/iohandler/factory.php +++ b/phpBB/phpbb/install/helper/iohandler/factory.php @@ -52,7 +52,7 @@ class factory /** * Factory getter for iohandler * - * @return \phpbb\install\helper\iohandler\iohandler_interface + * @return \phpbb\install\helper\iohandler\iohandler_interface|null * * @throws iohandler_not_implemented_exception * When the specified iohandler_interface does not exists @@ -63,17 +63,16 @@ class factory { case 'ajax': return $this->container->get('installer.helper.iohandler_ajax'); - break; + case 'nojs': // @todo replace this return $this->container->get('installer.helper.iohandler_ajax'); - break; + case 'cli': return $this->container->get('installer.helper.iohandler_cli'); - break; + default: throw new iohandler_not_implemented_exception(); - break; } } } diff --git a/phpBB/phpbb/install/helper/update_helper.php b/phpBB/phpbb/install/helper/update_helper.php index a00731d317..41a9bca206 100644 --- a/phpBB/phpbb/install/helper/update_helper.php +++ b/phpBB/phpbb/install/helper/update_helper.php @@ -89,6 +89,7 @@ class update_helper * @param string $version_number2 * @param string|null $operator * @return int|bool The returned value is identical to the PHP build-in function version_compare() + * @psalm-suppress InvalidNullableReturnType, NullableReturnStatement */ public function phpbb_version_compare($version_number1, $version_number2, $operator = null) { diff --git a/phpBB/phpbb/install/installer.php b/phpBB/phpbb/install/installer.php index 08906d7830..26c1c8a0f6 100644 --- a/phpBB/phpbb/install/installer.php +++ b/phpBB/phpbb/install/installer.php @@ -179,6 +179,7 @@ class installer try { + /** @psalm-suppress InvalidTemplateParam */ $iterator = $this->installer_modules->getIterator(); if ($module_index < $iterator->count()) diff --git a/phpBB/phpbb/install/module/install_data/task/add_languages.php b/phpBB/phpbb/install/module/install_data/task/add_languages.php index e8722d8987..3e56d3f69e 100644 --- a/phpBB/phpbb/install/module/install_data/task/add_languages.php +++ b/phpBB/phpbb/install/module/install_data/task/add_languages.php @@ -102,7 +102,7 @@ class add_languages extends database_task ]); $installed_languages = $this->config->get('installed_languages', []); - array_push($installed_languages, (int) $this->get_last_insert_id()); + $installed_languages[] = (int) $this->get_last_insert_id(); $this->config->set('installed_languages', $installed_languages); } diff --git a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php index 5f915c56f3..019553053f 100644 --- a/phpBB/phpbb/install/module/install_finish/task/install_extensions.php +++ b/phpBB/phpbb/install/module/install_finish/task/install_extensions.php @@ -42,7 +42,7 @@ class install_extensions extends database_task protected $iohandler; /** - * @var db + * @var \phpbb\config\config */ protected $config; @@ -106,9 +106,9 @@ class install_extensions extends database_task // Make sure asset version exists in config. Otherwise we might try to // insert the assets_version setting into the database and cause a // duplicate entry error. - if (!isset($this->config['assets_version'])) + if (!$this->config->offsetExists('assets_version')) { - $this->config['assets_version'] = 0; + $this->config->offsetSet('assets_version', 0); } parent::__construct( diff --git a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_files.php b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_files.php index b6dea1ca30..24581dda4c 100644 --- a/phpBB/phpbb/install/module/obtain_data/task/obtain_update_files.php +++ b/phpBB/phpbb/install/module/obtain_data/task/obtain_update_files.php @@ -75,6 +75,7 @@ class obtain_update_files extends task_base // The file should be checked in the requirements, so we assume that it exists $update_info_file = $this->phpbb_root_path . 'install/update/index.' . $this->php_ext; include($update_info_file); + /** @var array $update_info */ $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info; // If the file is invalid, abort mission diff --git a/phpBB/phpbb/install/module/requirements/task/check_update.php b/phpBB/phpbb/install/module/requirements/task/check_update.php index c15e6eafe2..2bd1841b3d 100644 --- a/phpBB/phpbb/install/module/requirements/task/check_update.php +++ b/phpBB/phpbb/install/module/requirements/task/check_update.php @@ -137,6 +137,7 @@ class check_update extends task_base // Recover version numbers $update_info = array(); @include($this->phpbb_root_path . 'install/update/index.' . $this->php_ext); + /** @var array|false $info */ $info = (empty($update_info) || !is_array($update_info)) ? false : $update_info; $update_version = false; diff --git a/phpBB/phpbb/install/module/update_database/task/update_extensions.php b/phpBB/phpbb/install/module/update_database/task/update_extensions.php index 4fe065fcb2..e47d23d052 100644 --- a/phpBB/phpbb/install/module/update_database/task/update_extensions.php +++ b/phpBB/phpbb/install/module/update_database/task/update_extensions.php @@ -45,7 +45,7 @@ class update_extensions extends task_base protected $update_helper; /** - * @var \phpbb\config\db + * @var \phpbb\config\config */ protected $config; @@ -111,9 +111,9 @@ class update_extensions extends task_base // Make sure asset version exists in config. Otherwise we might try to // insert the assets_version setting into the database and cause a // duplicate entry error. - if (!isset($this->config['assets_version'])) + if (!$this->config->offsetExists('assets_version')) { - $this->config['assets_version'] = 0; + $this->config->offsetSet('assets_version', 0); } parent::__construct(true); diff --git a/phpBB/phpbb/install/module/update_filesystem/task/update_files.php b/phpBB/phpbb/install/module/update_filesystem/task/update_files.php index b3325b93ce..49f76a5048 100644 --- a/phpBB/phpbb/install/module/update_filesystem/task/update_files.php +++ b/phpBB/phpbb/install/module/update_filesystem/task/update_files.php @@ -224,7 +224,7 @@ class update_files extends task_base } $file_updater_method = $this->installer_config->get('file_update_method', ''); - if ($file_updater_method === 'compression' || $file_updater_method === 'ftp') + if ($file_updater_method === 'compression' || $file_updater_method === 'ftp' && method_exists($this->file_updater, 'close')) { $this->file_updater->close(); } diff --git a/phpBB/phpbb/install/module_base.php b/phpBB/phpbb/install/module_base.php index 4464a89716..85ac4506c7 100644 --- a/phpBB/phpbb/install/module_base.php +++ b/phpBB/phpbb/install/module_base.php @@ -106,6 +106,7 @@ abstract class module_base implements module_interface { // Recover install progress $task_index = $this->recover_progress(); + /** @psalm-suppress InvalidTemplateParam */ $iterator = $this->task_collection->getIterator(); if ($task_index < $iterator->count())