[ticket/16955] Clean up composer classes and fix typos in exceptions

PHPBB3-16955
This commit is contained in:
Marc Alexander 2022-12-27 16:15:46 +01:00
parent 35228ffd62
commit 2aed7ff4e3
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
6 changed files with 36 additions and 23 deletions

View file

@ -29,7 +29,7 @@ class managed_with_clean_error_exception extends managed_with_error_exception
*/
public function __construct($prefix, $message = '', array $parameters = [], \Exception $previous = null, $code = 0)
{
parent::__construct($prefix . $message, $parameters, $previous, $code);
parent::__construct($prefix, $message, $parameters, $previous, $code);
}
}

View file

@ -29,7 +29,7 @@ class managed_with_enable_error_exception extends managed_with_error_exception
*/
public function __construct($prefix, $message = '', array $parameters = [], \Exception $previous = null, $code = 0)
{
parent::__construct($prefix . $message, $parameters, $previous, $code);
parent::__construct($prefix, $message, $parameters, $previous, $code);
}
}

View file

@ -29,7 +29,6 @@ class managed_with_error_exception extends runtime_exception
*/
public function __construct($prefix, $message = '', array $parameters = [], \Exception $previous = null, $code = 0)
{
parent::__construct($prefix . $message, $parameters, $previous, $code);
parent::__construct($prefix, $message, $parameters, $previous, $code);
}
}

View file

@ -29,7 +29,7 @@ use phpbb\filesystem\filesystem;
class extension_manager extends manager
{
/**
* @var manager
* @var ext_manager
*/
protected $extension_manager;
@ -102,7 +102,8 @@ class extension_manager extends manager
{
if ($this->enable_on_install)
{
$io->writeError([['ENABLING_EXTENSIONS', [], 1]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([['ENABLING_EXTENSIONS', [], 1]]);
foreach ($packages as $package => $version)
{
try
@ -111,11 +112,13 @@ class extension_manager extends manager
}
catch (\phpbb\exception\runtime_exception $e)
{
$io->writeError([[$e->getMessage(), $e->get_parameters(), 4]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([[$e->getMessage(), $e->get_parameters(), 4]]);
}
catch (\Exception $e)
{
$io->writeError([[$e->getMessage(), [], 4]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([[$e->getMessage(), [], 4]]);
}
}
}
@ -126,7 +129,8 @@ class extension_manager extends manager
*/
protected function pre_update(array $packages, IOInterface $io = null)
{
$io->writeError([['DISABLING_EXTENSIONS', [], 1]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([['DISABLING_EXTENSIONS', [], 1]]);
$this->enabled_extensions = [];
foreach ($packages as $package => $version)
{
@ -140,11 +144,13 @@ class extension_manager extends manager
}
catch (\phpbb\exception\runtime_exception $e)
{
$io->writeError([[$e->getMessage(), $e->get_parameters(), 4]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([[$e->getMessage(), $e->get_parameters(), 4]]);
}
catch (\Exception $e)
{
$io->writeError([[$e->getMessage(), [], 4]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([[$e->getMessage(), [], 4]]);
}
}
}
@ -154,7 +160,8 @@ class extension_manager extends manager
*/
protected function post_update(array $packages, IOInterface $io = null)
{
$io->writeError([['ENABLING_EXTENSIONS', [], 1]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([['ENABLING_EXTENSIONS', [], 1]]);
foreach ($this->enabled_extensions as $package)
{
try
@ -163,11 +170,13 @@ class extension_manager extends manager
}
catch (\phpbb\exception\runtime_exception $e)
{
$io->writeError([[$e->getMessage(), $e->get_parameters(), 4]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([[$e->getMessage(), $e->get_parameters(), 4]]);
}
catch (\Exception $e)
{
$io->writeError([[$e->getMessage(), [], 4]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([[$e->getMessage(), [], 4]]);
}
}
}
@ -195,7 +204,8 @@ class extension_manager extends manager
{
if ($this->purge_on_remove)
{
$io->writeError([['DISABLING_EXTENSIONS', [], 1]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([['DISABLING_EXTENSIONS', [], 1]]);
}
foreach ($packages as $package => $version)
@ -216,11 +226,13 @@ class extension_manager extends manager
}
catch (\phpbb\exception\runtime_exception $e)
{
$io->writeError([[$e->getMessage(), $e->get_parameters(), 4]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([[$e->getMessage(), $e->get_parameters(), 4]]);
}
catch (\Exception $e)
{
$io->writeError([[$e->getMessage(), [], 4]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([[$e->getMessage(), [], 4]]);
}
}
}
@ -244,7 +256,8 @@ class extension_manager extends manager
if ($this->extension_manager->is_enabled($package))
{
$enabled = true;
$io->writeError([['DISABLING_EXTENSIONS', [], 1]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([['DISABLING_EXTENSIONS', [], 1]]);
$this->extension_manager->disable($package);
}
@ -279,7 +292,8 @@ class extension_manager extends manager
{
try
{
$io->writeError([['ENABLING_EXTENSIONS', [], 1]], true);
/** @psalm-suppress InvalidArgument */
$io->writeError([['ENABLING_EXTENSIONS', [], 1]]);
$this->extension_manager->enable($package);
}
catch (\Exception $e)

View file

@ -147,11 +147,11 @@ class installer
* @param array $packages Packages to install.
* Each entry may be a name or an array associating a version constraint to a name
* @param array $whitelist White-listed packages (packages that can be installed/updated/removed)
* @param IOInterface|null $io IO object used for the output
* @param io\io_interface|null $io IO object used for the output
*
* @throws runtime_exception
*/
protected function do_install(array $packages, $whitelist, IOInterface $io = null)
protected function do_install(array $packages, $whitelist, io\io_interface $io = null)
{
if (!$io)
{

View file

@ -57,11 +57,11 @@ interface manager_interface
/**
* Tells whether or not a package is managed by Composer.
*
* @param string $packages Package name
* @param string $package Package name
*
* @return bool
*/
public function is_managed($packages);
public function is_managed($package);
/**
* Returns the list of managed packages for the current type