improve code for PHP 8

This commit is contained in:
2024-03-04 13:57:10 +01:00
committed by Daniel Seifert
parent 220f8a1c7c
commit b77642666b
9 changed files with 126 additions and 124 deletions

View File

@ -18,20 +18,21 @@ namespace D3\DataWizard\Application\Controller\Admin;
use D3\DataWizard\Application\Model\Configuration;
use D3\DataWizard\Application\Model\Exceptions\DataWizardException;
use D3\DataWizard\Application\Model\Exceptions\DebugException;
use D3\DataWizard\Application\Model\Exceptions\InputUnvalidException;
use D3\DataWizard\Application\Model\Exceptions\TaskException;
use D3\ModCfg\Application\Model\d3database;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception as DBALException;
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Registry;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class d3ActionWizard extends AdminDetailsController
{
protected $_sThisTemplate = 'd3ActionWizard.tpl';
/** @var Configuration */
protected $configuration;
protected Configuration $configuration;
public function __construct()
{
@ -55,23 +56,28 @@ class d3ActionWizard extends AdminDetailsController
}
/**
* @throws DatabaseConnectionException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function runTask()
public function runTask(): void
{
try {
$this->execute();
} catch (DataWizardException|DBALException|DatabaseErrorException $e) {
} catch (DataWizardException|DBALException $e) {
Registry::getLogger()->error($e->getMessage());
Registry::getUtilsView()->addErrorToDisplay($e);
}
}
/**
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws ContainerExceptionInterface
* @throws DBALException
* @throws DebugException
* @throws InputUnvalidException
* @throws NotFoundExceptionInterface
* @throws TaskException
*/
protected function execute()
protected function execute(): void
{
$id = Registry::getRequest()->getRequestEscapedParameter('taskid');
$action = $this->configuration->getActionById($id);
@ -79,10 +85,12 @@ class d3ActionWizard extends AdminDetailsController
[ $queryString, $parameters ] = $action->getQuery();
if ($this->d3GetConfig()->getConfigParam('d3datawizard_debug')) {
throw oxNew(
/** @var DebugException $debug */
$debug = oxNew(
DebugException::class,
d3database::getInstance()->getPreparedStatementQuery($queryString, $parameters)
);
throw $debug;
}
$action->run();
@ -96,12 +104,12 @@ class d3ActionWizard extends AdminDetailsController
return Registry::getConfig();
}
public function getUserMessages()
public function getUserMessages(): ?string
{
return null;
}
public function getHelpURL()
public function getHelpURL(): ?string
{
return null;
}

View File

@ -19,24 +19,25 @@ use D3\DataWizard\Application\Model\Configuration;
use D3\DataWizard\Application\Model\Exceptions\DataWizardException;
use D3\DataWizard\Application\Model\Exceptions\DebugException;
use D3\DataWizard\Application\Model\Exceptions\NoSuitableRendererException;
use D3\DataWizard\Application\Model\Exceptions\TaskException;
use D3\ModCfg\Application\Model\d3database;
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Exception as DBALException;
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
use OxidEsales\Eshop\Core\Config;
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
use OxidEsales\Eshop\Core\Exception\StandardException;
use OxidEsales\Eshop\Core\Registry;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class d3ExportWizard extends AdminDetailsController
{
protected $_sThisTemplate = 'd3ExportWizard.tpl';
/** @var Configuration */
protected $configuration;
protected Configuration $configuration;
public function __construct()
{
@ -61,12 +62,15 @@ class d3ExportWizard extends AdminDetailsController
}
/**
* @throws ContainerExceptionInterface
* @throws DatabaseConnectionException
* @throws Exception
* @throws NotFoundExceptionInterface
* @throws StandardException
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
*/
public function runTask()
public function runTask(): void
{
try {
$this->execute();
@ -80,13 +84,15 @@ class d3ExportWizard extends AdminDetailsController
* @throws DBALException
* @throws DatabaseConnectionException
* @throws DatabaseErrorException
* @throws StandardException
* @throws NoSuitableRendererException
* @throws TaskException
* @throws StandardException
* @throws Exception
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws d3ShopCompatibilityAdapterException
* @throws d3_cfg_mod_exception
*/
protected function execute()
protected function execute(): void
{
$id = Registry::getRequest()->getRequestEscapedParameter('taskid');
$export = $this->configuration->getExportById($id);
@ -111,12 +117,12 @@ class d3ExportWizard extends AdminDetailsController
return Registry::getConfig();
}
public function getUserMessages()
public function getUserMessages(): ?string
{
return null;
}
public function getHelpURL()
public function getHelpURL(): ?string
{
return null;
}