Add PHPStan configuration for Symfony4 tests

- Created a new phpstan.neon file in the Symfony4 tests directory.
- Configured paths and excluded Symfony3 directory.
- Added bootstrap files for autoloading.
- Set dynamic constant names and adjusted reporting settings.
- Established PHPStan level to 6 for stricter analysis.
This commit is contained in:
2026-02-09 23:14:09 +01:00
parent 58947ad589
commit 3bd8164d3d
169 changed files with 4964 additions and 3877 deletions

View File

@@ -204,7 +204,10 @@ class AdminEmpikActionLogController extends ModuleAdminController
*/
protected function contentOutput($content, $filename = 'error_report.csv')
{
ob_clean();
if (ob_get_level() > 0) {
ob_clean();
}
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Content-Length: ' . strlen($content));

View File

@@ -130,6 +130,7 @@ class AdminEmpikConnectionController extends ModuleAdminController
'name' => 'environment',
'label' => $this->l('Environment'),
'hint' => $this->l('Select environment'),
'desc' => $this->l('Use "testing" for development, switch to "production" when ready for real orders.'),
'options' => [
'query' => [
[
@@ -150,6 +151,7 @@ class AdminEmpikConnectionController extends ModuleAdminController
'type' => 'text',
'label' => $this->l('API key'),
'hint' => $this->l('API key'),
'desc' => $this->l('Generate API key in EmpikPlace panel (Marketplace > API settings). After entering key and testing connection, CRON URLs will be available in Help tab.'),
'name' => 'api_key',
],
[

View File

@@ -48,12 +48,13 @@ class AdminEmpikOffersController extends ModuleAdminController
$continue = !$this->exportOfferProcessor->isLastPage();
$this->ajaxDie(json_encode([
$this->ajaxRender(json_encode([
'success' => !$this->exportOfferProcessor->hasErrors(),
'errors' => $this->exportOfferProcessor->getErrors(),
'continue' => $continue,
'redirect' => $this->link->getAdminLink($this->controller_name, ['conf' => self::CONF_EXPORT_SUCCESS]),
]));
die();
}
public function initContent()
@@ -112,6 +113,7 @@ class AdminEmpikOffersController extends ModuleAdminController
'type' => 'switch',
'label' => $this->l('Sync Empik Marketplace offers automatically'),
'hint' => $this->l('Sync Empik Marketplace offers automatically'),
'desc' => $this->l('When enabled, prices and stock will be automatically synchronized with EmpikPlace via CRON.'),
'name' => 'sync_offers',
'is_bool' => true,
'values' => [
@@ -131,6 +133,7 @@ class AdminEmpikOffersController extends ModuleAdminController
'type' => 'switch',
'label' => $this->l('Sync logistic class'),
'hint' => $this->l('Enabling this option will update logistic class for all offers'),
'desc' => $this->l('When enabled, logistic class will be included in offer export.'),
'name' => 'sync_logistic_class',
'is_bool' => true,
'values' => [
@@ -150,6 +153,7 @@ class AdminEmpikOffersController extends ModuleAdminController
'type' => 'select',
'label' => $this->l('Offer identifier'),
'hint' => $this->l('Offer identifier'),
'desc' => $this->l('Product identifier sent to EmpikPlace. If products have EAN codes, we recommend using EAN.'),
'name' => 'offer_identifier',
'options' => [
'query' => [
@@ -170,6 +174,7 @@ class AdminEmpikOffersController extends ModuleAdminController
'type' => 'select',
'label' => $this->l('SKU type'),
'hint' => $this->l('SKU type'),
'desc' => $this->l('Field visible as offer SKU in EmpikPlace. Must match existing offers or delete old offers first.'),
'name' => 'sku_type',
'options' => [
'query' => [
@@ -194,6 +199,7 @@ class AdminEmpikOffersController extends ModuleAdminController
'type' => 'select',
'label' => $this->l('Leadtime to ship'),
'hint' => $this->l('Leadtime to ship'),
'desc' => $this->l('Business days to prepare and ship the order. Leave unset to use EmpikPlace default.'),
'name' => 'lead_time_to_ship',
'options' => [
'query' => $leadTimeToShip,
@@ -205,18 +211,22 @@ class AdminEmpikOffersController extends ModuleAdminController
'type' => 'text',
'label' => $this->l('Price ratio'),
'hint' => $this->l('Price ratio'),
'desc' => $this->l('Multiplier for offer prices. Value 1.0 = original price, 1.1 = +10%, 0.9 = -10%.'),
'name' => 'price_ratio',
],
[
'type' => 'text',
'label' => $this->l('Add to price'),
'hint' => $this->l('Add to price'),
'desc' => $this->l('Fixed amount added to all offer prices.'),
'name' => 'add_to_price',
'suffix' => Currency::getDefaultCurrency()->sign,
],
[
'type' => 'text',
'label' => $this->l('Reduce stock'),
'hint' => $this->l('Reduce stock'),
'desc' => $this->l('Safety stock buffer. E.g. value 3 means products with stock ≤3 will be sent as 0.'),
'name' => 'reduce_stock',
],
[
@@ -338,4 +348,4 @@ class AdminEmpikOffersController extends ModuleAdminController
{
return Translate::getModuleTranslation($this->module, $string, get_class($this), null, $addslashes);
}
}
}

View File

@@ -59,6 +59,7 @@ class AdminEmpikOrdersController extends ModuleAdminController
$autoAcceptOrders = Tools::getValue('auto_accept_orders');
$newOrderState = Tools::getValue('new_order_state');
$shippedOrderState = Tools::getValue('shipped_order_state');
$defaultVatRate = Tools::getValue('default_vat_rate');
if (!Validator::isBool($importOrders)) {
$this->errors[] = $this->l('Invalid Import orders field');
@@ -76,11 +77,16 @@ class AdminEmpikOrdersController extends ModuleAdminController
$this->errors[] = $this->l('Invalid Shipped order state field');
}
if (!Validator::isInt($defaultVatRate)) {
$this->errors[] = $this->l('Invalid Default VAT rate field');
}
if (empty($this->errors)) {
$result &= Configuration::updateValue(ConfigurationAdapter::CONF_IMPORT_ORDERS, (int)$importOrders);
$result &= Configuration::updateValue(ConfigurationAdapter::CONF_AUTO_ACCEPT_ORDERS, (int)$autoAcceptOrders);
$result &= Configuration::updateValue(ConfigurationAdapter::CONF_NEW_ORDER_STATE, (int)$newOrderState);
$result &= Configuration::updateValue(ConfigurationAdapter::CONF_SHIPPED_ORDER_STATE, (int)$shippedOrderState);
$result &= Configuration::updateValue(ConfigurationAdapter::CONF_DEFAULT_VAT_RATE, (int)$defaultVatRate);
}
}
@@ -125,6 +131,7 @@ class AdminEmpikOrdersController extends ModuleAdminController
'type' => 'switch',
'label' => $this->l('Import orders from Empik Marketplace'),
'hint' => $this->l('Import orders from Empik Marketplace'),
'desc' => $this->l('When enabled, orders with status "Shipment in progress" will be imported via CRON.'),
'name' => 'import_orders',
'is_bool' => true,
'values' => [
@@ -144,6 +151,7 @@ class AdminEmpikOrdersController extends ModuleAdminController
'type' => 'switch',
'label' => $this->l('Auto accept orders in Empik Marketplace'),
'hint' => $this->l('Auto accept orders in Empik Marketplace'),
'desc' => $this->l('Auto-accept orders with status "Pending acceptance" if products have positive stock.'),
'name' => 'auto_accept_orders',
'is_bool' => true,
'values' => [
@@ -163,6 +171,7 @@ class AdminEmpikOrdersController extends ModuleAdminController
'type' => 'select',
'label' => $this->l('New order state'),
'hint' => $this->l('New order state'),
'desc' => $this->l('Status assigned to newly imported orders. Choose one that indicates awaiting processing, e.g. "Payment accepted".'),
'name' => 'new_order_state',
'options' => [
'query' => $orderStates,
@@ -175,6 +184,7 @@ class AdminEmpikOrdersController extends ModuleAdminController
'type' => 'select',
'label' => $this->l('Shipped order state'),
'hint' => $this->l('Shipped order state'),
'desc' => $this->l('When order reaches this status, tracking number is sent and order marked as "Shipped" in EmpikPlace.'),
'name' => 'shipped_order_state',
'options' => [
'query' => $orderStates,
@@ -183,6 +193,24 @@ class AdminEmpikOrdersController extends ModuleAdminController
],
'class' => 'fixed-width-xxl',
],
[
'type' => 'select',
'label' => $this->l('Default VAT rate'),
'hint' => $this->l('Default VAT rate'),
'desc' => $this->l('Fallback VAT rate when product tax cannot be determined.'),
'name' => 'default_vat_rate',
'options' => [
'query' => [
['id' => '23', 'name' => '23%'],
['id' => '8', 'name' => '8%'],
['id' => '5', 'name' => '5%'],
['id' => '0', 'name' => '0%'],
],
'id' => 'id',
'name' => 'name'
],
'class' => 'fixed-width-xxl',
],
],
'buttons' => [],
'submit' => [
@@ -204,10 +232,11 @@ class AdminEmpikOrdersController extends ModuleAdminController
'id_language' => $this->context->language->id,
];
$helper->tpl_vars['fields_value']['import_orders'] = Tools::getValue('import_orders', (int)Configuration::get(ConfigurationAdapter::CONF_IMPORT_ORDERS));
$helper->tpl_vars['fields_value']['auto_accept_orders'] = Tools::getValue('auto_accept_orders', (int)Configuration::get(ConfigurationAdapter::CONF_AUTO_ACCEPT_ORDERS));
$helper->tpl_vars['fields_value']['new_order_state'] = Tools::getValue('new_order_state', (int)Configuration::get(ConfigurationAdapter::CONF_NEW_ORDER_STATE));
$helper->tpl_vars['fields_value']['shipped_order_state'] = Tools::getValue('shipped_order_state', (int)Configuration::get(ConfigurationAdapter::CONF_SHIPPED_ORDER_STATE));
$helper->tpl_vars['fields_value']['import_orders'] = (int)Tools::getValue('import_orders', Configuration::get(ConfigurationAdapter::CONF_IMPORT_ORDERS));
$helper->tpl_vars['fields_value']['auto_accept_orders'] = (int)Tools::getValue('auto_accept_orders', Configuration::get(ConfigurationAdapter::CONF_AUTO_ACCEPT_ORDERS));
$helper->tpl_vars['fields_value']['new_order_state'] = (int)Tools::getValue('new_order_state', Configuration::get(ConfigurationAdapter::CONF_NEW_ORDER_STATE));
$helper->tpl_vars['fields_value']['shipped_order_state'] = (int)Tools::getValue('shipped_order_state', Configuration::get(ConfigurationAdapter::CONF_SHIPPED_ORDER_STATE));
$helper->tpl_vars['fields_value']['default_vat_rate'] = (int)Tools::getValue('default_vat_rate', Configuration::get(ConfigurationAdapter::CONF_DEFAULT_VAT_RATE));
return $helper->generateForm([$formFields]);
}
@@ -248,6 +277,7 @@ class AdminEmpikOrdersController extends ModuleAdminController
[
'type' => 'html',
'label' => $this->l('Shipping mapping'),
'desc' => $this->l('Map EmpikPlace delivery methods to PrestaShop carriers. Only map methods you use.'),
'name' => 'html_data',
'html_content' => $this->context->smarty->fetch(
$this->module->getLocalPath().'/views/templates/admin/_partials/shipping_table.tpl'

View File

@@ -106,15 +106,18 @@ class AdminEmpikProductsController extends ModuleAdminController
'title' => $this->l('Category'),
'search' => false,
],
'active' => [
'title' => $this->l('Enabled'),
'active' => 'status',
'type' => 'bool',
'align' => 'center',
'class' => 'fixed-width-md',
'filter_key' => 'a!active',
],
'reference' => [
'title' => $this->l('Reference'),
'class' => 'fixed-width-md',
],
'price' => [
'title' => $this->l('Price (tax excl.)'),
'type' => 'price',
'class' => 'fixed-width-md',
],
'price_tax_incl' => [
'title' => $this->l('Price (tax incl.)'),
'type' => 'price',
@@ -259,12 +262,13 @@ class AdminEmpikProductsController extends ModuleAdminController
$continue = !$this->exportProductProcessor->isLastPage();
$this->ajaxDie(json_encode([
$this->ajaxRender(json_encode([
'success' => true,
'continue' => $continue,
'redirect' => $this->link->getAdminLink($this->controller_name, ['conf' => self::CONF_EXPORT_SUCCESS]),
'errors' => $this->errors,
]));
die();
}
public function initContent()
@@ -319,8 +323,6 @@ class AdminEmpikProductsController extends ModuleAdminController
$empikProduct = \EmpikProduct::getOrCreate($productId);
$empikProduct->product_export = 1;
$empikProduct->save();
Db::getInstance()->update('empik_product', ['product_export' => 1], 'id_product = ' . (int)$productId);
}
public function processDisableProduct()

View File

@@ -37,20 +37,6 @@ class AdminEmpikProductsPriceController extends ModuleAdminController
$this->bootstrap = true;
parent::__construct();
// 1.7.0
if (Tools::getIsset('changeDisplayOriginalPrice')) {
$idEmpikProduct = (int)Tools::getValue('id_empik_product');
$idProduct = Db::getInstance()->getValue('SELECT id_product FROM ' . _DB_PREFIX_ . 'empik_product
WHERE id_empik_product = ' . (int)$idEmpikProduct);
if ($idProduct > 0) {
\Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'empik_product
SET export_original_price = IF(export_original_price=1, 0, 1)
WHERE id_product = '.(int)$idProduct);
}
Tools::redirectAdmin($this->context->link->getAdminLink('AdminEmpikProductsPrice'));
}
$this->addRowAction('edit');
@@ -153,6 +139,32 @@ class AdminEmpikProductsPriceController extends ModuleAdminController
$this->addListActions();
}
private function getDefaultCurrencySign(): string
{
$currency = Currency::getDefaultCurrency();
if ($currency) {
return $currency->sign;
}
return '';
}
public function processChangeDisplayOriginalPrice()
{
$idEmpikProduct = (int)Tools::getValue('id_empik_product');
$idProduct = Db::getInstance()->getValue('SELECT id_product FROM ' . _DB_PREFIX_ . 'empik_product
WHERE id_empik_product = ' . (int)$idEmpikProduct);
if ($idProduct > 0) {
\Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'empik_product
SET export_original_price = IF(export_original_price=1, 0, 1)
WHERE id_product = '.(int)$idProduct);
}
Tools::redirectAdmin($this->context->link->getAdminLink('AdminEmpikProductsPrice'));
}
public function displayEmpikPriceColumn($val, $row)
{
$combinations = $this->combinationDataProvider->getCombinationsByProductId($row['id_product']);
@@ -161,6 +173,7 @@ class AdminEmpikProductsPriceController extends ModuleAdminController
'value' => $val,
'id_product' => $row['id_product'],
'combinations' => $combinations,
'currencySign' => $this->getDefaultCurrencySign(),
]);
return $this->module->display($this->module->name, 'views/templates/admin/list_action_edit_price.tpl');
@@ -174,6 +187,7 @@ class AdminEmpikProductsPriceController extends ModuleAdminController
'value' => $val,
'id_product' => $row['id_product'],
'combinations' => $combinations,
'currencySign' => $this->getDefaultCurrencySign(),
]);
return $this->module->display($this->module->name, 'views/templates/admin/list_action_edit_price_reduced.tpl');
@@ -186,7 +200,7 @@ class AdminEmpikProductsPriceController extends ModuleAdminController
$this->context->smarty->assign([
'displayOriginal' => (bool)$data[1],
'urlChange' => $this->link->getAdminLink($this->controller_name, ['changeDisplayOriginalPrice' => 1, 'id_empik_product' => $data[0]]),
'urlChange' => $this->link->getAdminLink($this->controller_name, ['action' => 'changeDisplayOriginalPrice', 'id_empik_product' => $data[0]]),
]);
return $this->module->display($this->module->name, 'views/templates/admin/list_action_original_price.tpl');
@@ -251,6 +265,8 @@ class AdminEmpikProductsPriceController extends ModuleAdminController
'name' => [
'type' => 'select',
'label' => $this->l('Logistic class'),
'hint' => $this->l('Logistic class'),
'desc' => $this->l('Determines shipping costs and delivery options on EmpikPlace.'),
'name' => 'logistic_class',
'options' => [
'query' => $this->getLogisticClassesOptions(),
@@ -262,6 +278,8 @@ class AdminEmpikProductsPriceController extends ModuleAdminController
[
'type' => 'select',
'label' => $this->l('Condition'),
'hint' => $this->l('Condition'),
'desc' => $this->l('Product condition displayed to customers on EmpikPlace.'),
'name' => 'condition',
'options' => [
'query' => $this->getConditionOptions(),
@@ -466,7 +484,7 @@ class AdminEmpikProductsPriceController extends ModuleAdminController
$this->productRepository->updateOfferPrice($productId, $productAttributeId, $price);
$this->ajaxDie(json_encode([
$this->ajaxRender(json_encode([
'success' => true,
'message' => $this->l('Price saved successfully!'),
'errors' => $this->errors,
@@ -481,7 +499,7 @@ class AdminEmpikProductsPriceController extends ModuleAdminController
$this->productRepository->updateOfferPriceReduced($productId, $productAttributeId, $price);
$this->ajaxDie(json_encode([
$this->ajaxRender(json_encode([
'success' => true,
'message' => $this->l('Price saved successfully!'),
'errors' => $this->errors,
@@ -521,4 +539,9 @@ class AdminEmpikProductsPriceController extends ModuleAdminController
$this->errors[] = $this->l('You must select at least one item');
}
}
protected function l($string, $class = null, $addslashes = false, $htmlentities = true)
{
return Translate::getModuleTranslation($this->module, $string, get_class($this), null, $addslashes);
}
}