From 57c8400904b74569c843cd898fe6c39552f91e6b Mon Sep 17 00:00:00 2001 From: Nikita Kiselev Date: Tue, 23 Dec 2025 20:04:39 +0300 Subject: [PATCH] fix: correct cli.php path for phar --- .../bastion/Handlers/SettingsHandler.php | 2 +- .../console/Commands/ScheduleListCommand.php | 2 +- .../framework/Container/Container.php | 7 ++++++- .../framework/Scheduler/SchedulerService.php | 2 +- .../oc_telegram_shop/framework/Support/helpers.php | 13 ++++++------- .../upload/oc_telegram_shop/phpstan.neon | 5 ++++- .../oc_telegram_shop/stubs/phpstan-bootstrap.php | 11 +++++++++++ 7 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 module/oc_telegram_shop/upload/oc_telegram_shop/stubs/phpstan-bootstrap.php diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/bastion/Handlers/SettingsHandler.php b/module/oc_telegram_shop/upload/oc_telegram_shop/bastion/Handlers/SettingsHandler.php index 838984a..1b9f1f8 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/bastion/Handlers/SettingsHandler.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/bastion/Handlers/SettingsHandler.php @@ -79,7 +79,7 @@ class SettingsHandler $data['forms'] = []; // Add CRON system details (read-only) - $data['cron']['cli_path'] = dirname(DIR_SYSTEM) . '/cli.php'; + $data['cron']['cli_path'] = BP_REAL_BASE_PATH . '/cli.php'; $data['cron']['last_run'] = $this->getLastCronRunDate(); $forms = $this->builder->newQuery() diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/console/Commands/ScheduleListCommand.php b/module/oc_telegram_shop/upload/oc_telegram_shop/console/Commands/ScheduleListCommand.php index c02b5db..26f1e45 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/console/Commands/ScheduleListCommand.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/console/Commands/ScheduleListCommand.php @@ -30,7 +30,7 @@ class ScheduleListCommand extends TeleCartCommand $registry = new ScheduleJobRegistry($this->container); // Load schedule config - $configFile = BP_BASE_PATH . '/configs/schedule.php'; + $configFile = BP_PHAR_BASE_PATH . '/configs/schedule.php'; if (file_exists($configFile)) { $scheduler = $registry; // Variable name used in config file require $configFile; diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Container/Container.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Container/Container.php index eb2b25a..1f0847c 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Container/Container.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Container/Container.php @@ -17,7 +17,12 @@ use Symfony\Component\HttpFoundation\Response; // phpcs:disable PSR1.Files.SideEffects if (! defined('BP_BASE_PATH')) { $phar = Phar::running(false); - define('BP_BASE_PATH', $phar ? "phar://$phar" : dirname(__DIR__) . '/..'); + $realBasePath = $phar ? dirname($phar) : dirname(__DIR__) . '/..'; + $pharBasePath = $phar ? "phar://$phar" : $realBasePath; + + define('BP_REAL_BASE_PATH', $realBasePath); + define('BP_PHAR_BASE_PATH', $pharBasePath); + define('BP_BASE_PATH', $pharBasePath); } // phpcs:enable PSR1.Files.SideEffects diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Scheduler/SchedulerService.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Scheduler/SchedulerService.php index f899c33..36e1a08 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Scheduler/SchedulerService.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Scheduler/SchedulerService.php @@ -67,7 +67,7 @@ class SchedulerService // Only load config file if registry was not injected (for production use) if (! $this->registry) { - $configFile = BP_BASE_PATH . '/configs/schedule.php'; + $configFile = BP_PHAR_BASE_PATH . '/configs/schedule.php'; if (file_exists($configFile)) { require $configFile; } else { diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Support/helpers.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Support/helpers.php index 49a5914..066571c 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Support/helpers.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Support/helpers.php @@ -3,7 +3,6 @@ use Openguru\OpenCartFramework\Application; use Openguru\OpenCartFramework\Config\Settings; use Openguru\OpenCartFramework\Support\Utils; -use Openguru\OpenCartFramework\TeleCartPulse\TeleCartPulseService; if (! function_exists('table')) { function db_table(string $name): string @@ -34,28 +33,28 @@ if (! function_exists('column')) { if (! function_exists('configs_path')) { function configs_path(string $path = ''): string { - return BP_BASE_PATH . '/configs/' . $path; + return BP_PHAR_BASE_PATH . '/configs/' . $path; } } if (! function_exists('resources_path')) { function resources_path(string $path = ''): string { - return BP_BASE_PATH . '/resources/' . $path; + return BP_PHAR_BASE_PATH . '/resources/' . $path; } } if (! function_exists('database_path')) { function database_path(string $path = ''): string { - return BP_BASE_PATH . '/database/' . $path; + return BP_PHAR_BASE_PATH . '/database/' . $path; } } if (! function_exists('base_path')) { function base_path(string $path = ''): string { - return BP_BASE_PATH . '/' . $path; + return BP_PHAR_BASE_PATH . '/' . $path; } } @@ -111,7 +110,7 @@ if (! function_exists('module_version')) { return $version; } - $versionFile = BP_BASE_PATH . '/version.txt'; + $versionFile = BP_PHAR_BASE_PATH . '/version.txt'; if (is_readable($versionFile)) { $raw = trim((string) file_get_contents($versionFile)); if ($raw !== '') { @@ -119,7 +118,7 @@ if (! function_exists('module_version')) { } } - $composerFile = BP_BASE_PATH . '/composer.json'; + $composerFile = BP_PHAR_BASE_PATH . '/composer.json'; if (is_readable($composerFile)) { $composer = json_decode((string) file_get_contents($composerFile), true); if (is_array($composer) && ! empty($composer['version'])) { diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/phpstan.neon b/module/oc_telegram_shop/upload/oc_telegram_shop/phpstan.neon index 4579bbf..e576619 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/phpstan.neon +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/phpstan.neon @@ -9,4 +9,7 @@ parameters: scanDirectories: - stubs - inferPrivatePropertyTypeFromConstructor: true \ No newline at end of file + inferPrivatePropertyTypeFromConstructor: true + + bootstrapFiles: + - stubs/phpstan-bootstrap.php \ No newline at end of file diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/stubs/phpstan-bootstrap.php b/module/oc_telegram_shop/upload/oc_telegram_shop/stubs/phpstan-bootstrap.php new file mode 100644 index 0000000..d06cdb3 --- /dev/null +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/stubs/phpstan-bootstrap.php @@ -0,0 +1,11 @@ +