diff --git a/ps_emailsubscription.php b/ps_emailsubscription.php index 375734e..2b92863 100644 --- a/ps_emailsubscription.php +++ b/ps_emailsubscription.php @@ -952,21 +952,6 @@ public function hookActionFrontControllerSetMedia() $controller->registerJavascript('modules-psemailsubscription', 'modules/' . $this->name . '/views/js/ps_emailsubscription.js'); } - /** - * Returns the admin controller with a concrete type. Context::$controller is typed - * as the PHPStan-opaque LegacyControllerContext on PrestaShop 9.x, which prevents - * static resolution of legacy controller methods such as getLanguages(). - * - * @return AdminController - */ - private function getAdminController() - { - /** @var AdminController $controller */ - $controller = $this->context->controller; - - return $controller; - } - /** * Deletes duplicates email in newsletter table. * @@ -1153,7 +1138,7 @@ public function renderForm() $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = [ 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->getAdminController()->getLanguages(), + 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id, ]; @@ -1254,7 +1239,7 @@ public function renderExportForm() $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = [ 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->getAdminController()->getLanguages(), + 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id, ]; @@ -1293,7 +1278,7 @@ public function renderSearchForm() $helper->token = Tools::getAdminTokenLite('AdminModules'); $helper->tpl_vars = [ 'fields_value' => ['searched_email' => $this->_searched_email], - 'languages' => $this->getAdminController()->getLanguages(), + 'languages' => $this->context->controller->getLanguages(), 'id_language' => $this->context->language->id, ]; diff --git a/tests/php/phpstan/phpstan-9.0.3.neon b/tests/php/phpstan/phpstan-9.0.3.neon index efa856c..a976397 100644 --- a/tests/php/phpstan/phpstan-9.0.3.neon +++ b/tests/php/phpstan/phpstan-9.0.3.neon @@ -1,2 +1,8 @@ includes: - %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon + +parameters: + # PrestaShop 9 requires PHP 8.1 as a minimum. It has to be set explicitly because PHPStan + # otherwise infers the analysed PHP version from the composer platform declaration, and the + # resulting older syntax rules make it fail to parse the core classes the module relies on. + phpVersion: 80100 diff --git a/tests/php/phpstan/phpstan-9.1.5.neon b/tests/php/phpstan/phpstan-9.1.5.neon index efa856c..a976397 100644 --- a/tests/php/phpstan/phpstan-9.1.5.neon +++ b/tests/php/phpstan/phpstan-9.1.5.neon @@ -1,2 +1,8 @@ includes: - %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon + +parameters: + # PrestaShop 9 requires PHP 8.1 as a minimum. It has to be set explicitly because PHPStan + # otherwise infers the analysed PHP version from the composer platform declaration, and the + # resulting older syntax rules make it fail to parse the core classes the module relies on. + phpVersion: 80100 diff --git a/tests/php/phpstan/phpstan-9.2.x.neon b/tests/php/phpstan/phpstan-9.2.x.neon index efa856c..a976397 100644 --- a/tests/php/phpstan/phpstan-9.2.x.neon +++ b/tests/php/phpstan/phpstan-9.2.x.neon @@ -1,2 +1,8 @@ includes: - %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon + +parameters: + # PrestaShop 9 requires PHP 8.1 as a minimum. It has to be set explicitly because PHPStan + # otherwise infers the analysed PHP version from the composer platform declaration, and the + # resulting older syntax rules make it fail to parse the core classes the module relies on. + phpVersion: 80100 diff --git a/tests/php/phpstan/phpstan-develop.neon b/tests/php/phpstan/phpstan-develop.neon index efa856c..a976397 100644 --- a/tests/php/phpstan/phpstan-develop.neon +++ b/tests/php/phpstan/phpstan-develop.neon @@ -1,2 +1,8 @@ includes: - %currentWorkingDirectory%/tests/php/phpstan/phpstan.neon + +parameters: + # PrestaShop 9 requires PHP 8.1 as a minimum. It has to be set explicitly because PHPStan + # otherwise infers the analysed PHP version from the composer platform declaration, and the + # resulting older syntax rules make it fail to parse the core classes the module relies on. + phpVersion: 80100