mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/16955] Clean up installer classes for psalm
PHPBB3-16955
This commit is contained in:
parent
d9c179f9ef
commit
40e8a737c3
22 changed files with 54 additions and 42 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -99,6 +99,7 @@ class install
|
|||
* @return Response|StreamedResponse
|
||||
*
|
||||
* @throws http_exception When phpBB is already installed
|
||||
* @psalm-suppress InvalidNullableReturnType
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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',
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 : '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -179,6 +179,7 @@ class installer
|
|||
|
||||
try
|
||||
{
|
||||
/** @psalm-suppress InvalidTemplateParam */
|
||||
$iterator = $this->installer_modules->getIterator();
|
||||
|
||||
if ($module_index < $iterator->count())
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Add table
Reference in a new issue