diff --git a/module/oc_telegram_shop/upload/catalog/controller/extension/tgshop/handle.php b/module/oc_telegram_shop/upload/catalog/controller/extension/tgshop/handle.php index 0f09e5b..7ba3677 100755 --- a/module/oc_telegram_shop/upload/catalog/controller/extension/tgshop/handle.php +++ b/module/oc_telegram_shop/upload/catalog/controller/extension/tgshop/handle.php @@ -8,6 +8,7 @@ use Cart\Currency; use Cart\Tax; use Openguru\OpenCartFramework\ImageTool\ImageTool; use Openguru\OpenCartFramework\ImageTool\ImageToolInterface; +use Openguru\OpenCartFramework\Logger\OpenCartLogAdapter; $sysLibPath = rtrim(DIR_SYSTEM, '/') . '/library/oc_telegram_shop'; $basePath = rtrim(DIR_APPLICATION, '/') . '/..'; @@ -26,6 +27,9 @@ class Controllerextensiontgshophandle extends Controller { public function index(): void { + $this->load->model('checkout/order'); + $this->session->data['language'] = $this->config->get('config_language'); + $app = ApplicationFactory::create([ 'app_enabled' => filter_var($this->config->get('module_tgshop_status'), FILTER_VALIDATE_BOOLEAN), 'oc_config_tax' => $this->config->get('config_tax'), @@ -69,40 +73,22 @@ class Controllerextensiontgshophandle extends Controller 'cache_products_main' => 60 * 10, ]); - $app->bind(Url::class, function () { - return $this->url; - }); - - $app->bind(Currency::class, function () { - return $this->currency; - }); - - $app->bind(Tax::class, function () { - return $this->tax; - }); - $app->bind(OcModelCatalogProductAdapter::class, function () { $this->load->model('catalog/product'); return new OcModelCatalogProductAdapter($this->model_catalog_product); }); - $app->bind(ImageToolInterface::class, function () { - return new ImageTool(DIR_IMAGE, HTTPS_SERVER); - }); + $app->bind(Url::class, fn () => $this->url); + $app->bind(Currency::class, fn () => $this->currency); + $app->bind(Tax::class, fn () => $this->tax); + $app->bind(ImageToolInterface::class, fn () => new ImageTool(DIR_IMAGE, HTTPS_SERVER)); + $app->bind(Cart::class, fn () => $this->cart); + $app->bind(OcRegistryDecorator::class, fn () => new OcRegistryDecorator($this->registry)); + $app->singleton(Log::class, fn () => $this->log); - $app->bind(Cart::class, function () { - return $this->cart; - }); - - $app->bind(OcRegistryDecorator::class, function () { - return new OcRegistryDecorator($this->registry); - }); - - $this->load->model('checkout/order'); - - $this->session->data['language'] = $this->config->get('config_language'); - - $app->bootAndHandleRequest(); + $app + ->withLogger(fn () => new OpenCartLogAdapter($this->log, 'TeleCart')) + ->bootAndHandleRequest(); } function extractPureJs($input) diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/composer.json b/module/oc_telegram_shop/upload/oc_telegram_shop/composer.json index afe9a5f..3adcc90 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/composer.json +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/composer.json @@ -3,7 +3,8 @@ "autoload": { "psr-4": { "Openguru\\OpenCartFramework\\": "framework/", - "App\\": "src/" + "App\\": "src/", + "Tests\\": "tests/" }, "files": [ "framework/Support/helpers.php" @@ -21,13 +22,13 @@ "psr/container": "^2.0", "ext-json": "*", "intervention/image": "^2.7", - "rakit/validation": "^1.4", "vlucas/phpdotenv": "^5.6", "guzzlehttp/guzzle": "^7.9", "symfony/cache": "^5.4" }, "require-dev": { "roave/security-advisories": "dev-latest", - "phpstan/phpstan": "^2.1" + "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^9.6" } } diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/composer.lock b/module/oc_telegram_shop/upload/oc_telegram_shop/composer.lock index a704d07..e849aff 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/composer.lock +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "119f24aafb5ae0828f70c3c57fa07234", + "content-hash": "7800f8b8834540a6bcbca3336bef7949", "packages": [ { "name": "graham-campbell/result-type", @@ -864,52 +864,6 @@ }, "time": "2021-05-03T11:20:27+00:00" }, - { - "name": "rakit/validation", - "version": "v1.4.0", - "source": { - "type": "git", - "url": "https://github.com/rakit/validation.git", - "reference": "ff003a35cdf5030a5f2482299f4c93f344a35b29" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/rakit/validation/zipball/ff003a35cdf5030a5f2482299f4c93f344a35b29", - "reference": "ff003a35cdf5030a5f2482299f4c93f344a35b29", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "php": ">=7.0" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^6.5", - "squizlabs/php_codesniffer": "^3" - }, - "type": "library", - "autoload": { - "psr-4": { - "Rakit\\Validation\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Muhammad Syifa", - "email": "emsifa@gmail.com" - } - ], - "description": "PHP Laravel like standalone validation library", - "support": { - "issues": "https://github.com/rakit/validation/issues", - "source": "https://github.com/rakit/validation/tree/v1.4.0" - }, - "time": "2020-08-27T05:07:01+00:00" - }, { "name": "ralouphie/getallheaders", "version": "3.0.3", @@ -1733,6 +1687,312 @@ } ], "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", + "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^9 || ^11", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.16 || ^1", + "phpstan/phpstan": "^1.4", + "phpstan/phpstan-phpunit": "^1", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "vimeo/psalm": "^4.30 || ^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2022-12-30T00:15:36+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.13.4", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "reference": "07d290f0c47959fd5eed98c95ee5602db07e0b6a", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3 <3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.4" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2025-08-01T08:46:24+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v5.6.1", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2", + "reference": "f103601b29efebd7ff4a1ca7b3eeea9e3336a2a2", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "php": ">=7.4" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v5.6.1" + }, + "time": "2025-08-13T20:13:15+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "54750ef60c58e43759730615a392c31c80e23176" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, { "name": "phpstan/phpstan", "version": "2.1.22", @@ -1791,6 +2051,436 @@ ], "time": "2025-08-04T19:17:37+00:00" }, + { + "name": "phpunit/php-code-coverage", + "version": "9.2.32", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5", + "reference": "85402a822d1ecf1db1096959413d35e1c37cf1a5", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.19.1 || ^5.1.0", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-text-template": "^2.0.4", + "sebastian/code-unit-reverse-lookup": "^2.0.3", + "sebastian/complexity": "^2.0.3", + "sebastian/environment": "^5.1.5", + "sebastian/lines-of-code": "^1.0.4", + "sebastian/version": "^3.0.2", + "theseer/tokenizer": "^1.2.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.6" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "9.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.32" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-08-22T04:23:01+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-12-02T12:48:52+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.6.24", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "ea49afa29aeea25ea7bf9de9fdd7cab163cc0701" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ea49afa29aeea25ea7bf9de9fdd7cab163cc0701", + "reference": "ea49afa29aeea25ea7bf9de9fdd7cab163cc0701", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.5.0 || ^2", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.13.4", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", + "php": ">=7.3", + "phpunit/php-code-coverage": "^9.2.32", + "phpunit/php-file-iterator": "^3.0.6", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", + "sebastian/comparator": "^4.0.9", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.8", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", + "sebastian/version": "^3.0.2" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.6-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.24" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2025-08-10T08:32:42+00:00" + }, { "name": "roave/security-advisories", "version": "dev-latest", @@ -2745,6 +3435,1055 @@ } ], "time": "2025-07-09T19:05:36+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:27:43+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:30:19+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "67a2df3a62639eab2cc5906065e9805d4fd5dfc5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/67a2df3a62639eab2cc5906065e9805d4fd5dfc5", + "reference": "67a2df3a62639eab2cc5906065e9805d4fd5dfc5", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.9" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/comparator", + "type": "tidelift" + } + ], + "time": "2025-08-10T06:51:50+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:19:30+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:30:58+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:03:51+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:33:00+00:00" + }, + { + "name": "sebastian/global-state", + "version": "5.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "b6781316bdcd28260904e7cc18ec983d0d2ef4f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/b6781316bdcd28260904e7cc18ec983d0d2ef4f6", + "reference": "b6781316bdcd28260904e7cc18ec983d0d2ef4f6", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/global-state", + "type": "tidelift" + } + ], + "time": "2025-08-10T07:10:35+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:20:34+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:12:34+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:14:26+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "539c6691e0623af6dc6f9c20384c120f963465a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/539c6691e0623af6dc6f9c20384c120f963465a0", + "reference": "539c6691e0623af6dc6f9c20384c120f963465a0", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://liberapay.com/sebastianbergmann", + "type": "liberapay" + }, + { + "url": "https://thanks.dev/u/gh/sebastianbergmann", + "type": "thanks_dev" + }, + { + "url": "https://tidelift.com/funding/github/packagist/sebastian/recursion-context", + "type": "tidelift" + } + ], + "time": "2025-08-10T06:57:39+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "3.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-14T16:00:52+00:00" + }, + { + "name": "sebastian/type", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:13:03+00:00" + }, + { + "name": "sebastian/version", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:36:25+00:00" } ], "aliases": [], diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Application.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Application.php index 479d408..5ecbeb3 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Application.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Application.php @@ -2,6 +2,7 @@ namespace Openguru\OpenCartFramework; +use Closure; use Dotenv\Dotenv; use InvalidArgumentException; use Openguru\OpenCartFramework\Config\Settings; @@ -9,6 +10,7 @@ use Openguru\OpenCartFramework\Container\Container; use Openguru\OpenCartFramework\Http\JsonResponse; use Openguru\OpenCartFramework\Http\Request; use Openguru\OpenCartFramework\Logger\Logger; +use Openguru\OpenCartFramework\Logger\LoggerInterface; use Openguru\OpenCartFramework\Router\Router; use Openguru\OpenCartFramework\Support\ExecutionTimeProfiler; @@ -18,6 +20,16 @@ class Application extends Container private static array $events = []; private array $serviceProviders = []; private array $middlewareStack = []; + private LoggerInterface $logger; + + public function __construct(array $config) + { + parent::__construct($config); + + // Fallback logger + $path = rtrim($this->getConfigValue('logs.path'), '/') . '/oc_telegram_shop.log'; + $this->logger = new Logger($path); + } /** * @var ExecutionTimeProfiler @@ -42,10 +54,7 @@ class Application extends Container return $container; }); - $this->singleton(Logger::class, function (Container $container) { - $path = $container->getConfigValue('logs.path') . '/oc_telegram_shop.log'; - return new Logger($path, Logger::LEVEL_INFO); - }); + $this->singleton(LoggerInterface::class, fn () => $this->logger); $this->singleton(Settings::class, function (Container $container) { return new Settings($container->getConfigValue()); @@ -55,7 +64,7 @@ class Application extends Container $dotenv->load(); $errorHandler = new ErrorHandler( - $this->get(Logger::class), + $this->get(LoggerInterface::class), $this, ); @@ -89,17 +98,17 @@ class Application extends Container [$controller, $method] = $action; - if (!class_exists($controller) || !method_exists($controller, $method)) { + if (! class_exists($controller) || ! method_exists($controller, $method)) { throw new InvalidArgumentException('Invalid action: ' . $controller . '->' . $method); } $this->profiler->addCheckpoint('Handle Middlewares.'); - $next = fn($req) => $this->call($controller, $method); + $next = fn ($req) => $this->call($controller, $method); foreach (array_reverse($this->middlewareStack) as $class) { $instance = $this->get($class); - $next = static fn($req) => $instance->handle($req, $next); + $next = static fn ($req) => $instance->handle($req, $next); } $response = $next($request); @@ -130,4 +139,11 @@ class Application extends Container return $this; } + + public function withLogger(Closure $closure): Application + { + $this->logger = $closure(); + + return $this; + } } diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/ErrorHandler.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/ErrorHandler.php index 14590b0..43ca9f3 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/ErrorHandler.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/ErrorHandler.php @@ -7,7 +7,7 @@ use Openguru\OpenCartFramework\Contracts\ExceptionHandlerInterface; use Openguru\OpenCartFramework\Exceptions\NonLoggableExceptionInterface; use Openguru\OpenCartFramework\Http\JsonResponse; use Openguru\OpenCartFramework\Http\Response; -use Openguru\OpenCartFramework\Logger\Logger; +use Openguru\OpenCartFramework\Logger\LoggerInterface; use Throwable; /** @@ -15,10 +15,10 @@ use Throwable; */ class ErrorHandler { - private $logger; + private LoggerInterface $logger; private Application $app; - public function __construct(Logger $logger, Application $application) + public function __construct(LoggerInterface $logger, Application $application) { $this->logger = $logger; $this->app = $application; diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Logger/Logger.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Logger/Logger.php index 3ea05d4..34c1634 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Logger/Logger.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Logger/Logger.php @@ -4,24 +4,20 @@ namespace Openguru\OpenCartFramework\Logger; use Throwable; -class Logger +class Logger implements LoggerInterface { private $logFile; private $logLevel; private $maxFileSize; // Максимальный размер файла в байтах - public const LEVEL_INFO = 1; - public const LEVEL_WARNING = 2; - public const LEVEL_ERROR = 3; - - public function __construct($logFile, $logLevel = self::LEVEL_INFO, $maxFileSize = 1048576) + public function __construct($logFile, $logLevel = LoggerInterface::LEVEL_INFO, $maxFileSize = 1048576) { $this->logFile = $logFile; $this->logLevel = $logLevel; $this->maxFileSize = $maxFileSize; } - public function log($message, $level = self::LEVEL_INFO) + public function log($message, $level = LoggerInterface::LEVEL_INFO) { if ($level < $this->logLevel) { return; // Не логируем, если уровень ниже установленного @@ -39,11 +35,11 @@ class Logger private function getLevelString($level): string { switch ($level) { - case self::LEVEL_INFO: + case LoggerInterface::LEVEL_INFO: return 'INFO'; - case self::LEVEL_WARNING: + case LoggerInterface::LEVEL_WARNING: return 'WARNING'; - case self::LEVEL_ERROR: + case LoggerInterface::LEVEL_ERROR: return 'ERROR'; default: return 'UNKNOWN'; @@ -52,17 +48,17 @@ class Logger public function info(string $message): void { - $this->log($message, self::LEVEL_INFO); + $this->log($message, LoggerInterface::LEVEL_INFO); } public function warning(string $message): void { - $this->log($message, self::LEVEL_WARNING); + $this->log($message, LoggerInterface::LEVEL_WARNING); } public function error(string $message): void { - $this->log($message, self::LEVEL_ERROR); + $this->log($message, LoggerInterface::LEVEL_ERROR); } private function rotateLogs(): void diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Logger/LoggerInterface.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Logger/LoggerInterface.php new file mode 100644 index 0000000..6d20ce1 --- /dev/null +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Logger/LoggerInterface.php @@ -0,0 +1,22 @@ +ocLogger = $ocLogger; + $this->namespace = $namespace; + } + + public function log($message, $level = self::LEVEL_INFO): void + { + $this->ocLogger->write( + sprintf( + "[%s] [%s] %s\n", + $this->namespace, + $this->getLevelString($level), + $message + ) + ); + } + + public function info(string $message): void + { + $this->log($message); + } + + public function warning(string $message): void + { + $this->log($message, self::LEVEL_WARNING); + } + + public function error(string $message): void + { + $this->log($message, self::LEVEL_ERROR); + } + + public function logException(Throwable $exception): void + { + $this->error( + sprintf( + "Fatal error %s in %s on line %d\n%s", + $exception->getMessage(), + $exception->getFile(), + $exception->getLine(), + $exception->getTraceAsString() + ) + ); + } + + private function getLevelString($level): string + { + switch ($level) { + case LoggerInterface::LEVEL_INFO: + return 'INFO'; + case LoggerInterface::LEVEL_WARNING: + return 'WARNING'; + case LoggerInterface::LEVEL_ERROR: + return 'ERROR'; + default: + return 'UNKNOWN'; + } + } +} diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Telegram/TelegramService.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Telegram/TelegramService.php index 4aab4e4..306b6d0 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Telegram/TelegramService.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Telegram/TelegramService.php @@ -3,17 +3,14 @@ namespace Openguru\OpenCartFramework\Telegram; use GuzzleHttp\Client; -use Openguru\OpenCartFramework\Logger\Logger; class TelegramService { - private Logger $logger; private Client $client; private ?string $botToken; - public function __construct(Logger $logger, ?string $botToken = null) + public function __construct(?string $botToken = null) { - $this->logger = $logger; $this->botToken = $botToken; $this->client = $this->createGuzzleClient("https://api.telegram.org/bot{$botToken}/"); } diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Telegram/TelegramServiceProvider.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Telegram/TelegramServiceProvider.php index 2cfcd2e..07395c2 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Telegram/TelegramServiceProvider.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Telegram/TelegramServiceProvider.php @@ -4,7 +4,6 @@ namespace Openguru\OpenCartFramework\Telegram; use Openguru\OpenCartFramework\Application; use Openguru\OpenCartFramework\Container\ServiceProvider; -use Openguru\OpenCartFramework\Logger\Logger; class TelegramServiceProvider extends ServiceProvider { @@ -12,10 +11,7 @@ class TelegramServiceProvider extends ServiceProvider { $this->container->singleton(TelegramService::class, function (Application $app) { $botToken = $app->getConfigValue('telegram.bot_token'); - return new TelegramService( - $app->get(Logger::class), - $botToken, - ); + return new TelegramService($botToken); }); $this->container->singleton(SignatureValidator::class, function (Application $app) { diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/ErrorBag.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/ErrorBag.php new file mode 100644 index 0000000..521ec85 --- /dev/null +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/ErrorBag.php @@ -0,0 +1,43 @@ +errors = $errors; + } + + public function count(): int + { + return count($this->errors); + } + + public function put(string $field, string $message): void + { + $this->errors[$field][] = $message; + } + + public function first(): array + { + foreach ($this->errors as $error) { + return $error; + } + } + + public function firstOfAll(): array + { + $result = []; + + foreach ($this->errors as $field => $errors) { + if (count($errors) > 0) { + $result[$field] = $errors[0]; + } + } + + return $result; + } +} diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/ValidationRuleNotFoundException.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/ValidationRuleNotFoundException.php new file mode 100644 index 0000000..7f50836 --- /dev/null +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/ValidationRuleNotFoundException.php @@ -0,0 +1,9 @@ +validateRequired($value) === false) { + $fail(':field is required'); + } + } +} diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/ValidationRules/ValidationRuleInterface.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/ValidationRules/ValidationRuleInterface.php new file mode 100644 index 0000000..4e6758c --- /dev/null +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/ValidationRules/ValidationRuleInterface.php @@ -0,0 +1,10 @@ +validationRules = $validationRules; + $this->customMessages = $customMessages; + } + + public function make(array $input, array $rules, array $fieldNames = []): Validator { $this->input = $input; $this->rules = $rules; + $this->errors = new ErrorBag(); + $this->fieldNames = $fieldNames; + + return $this; } - public function validate(): bool + /** + * @throws ValidationRuleNotFoundException + */ + private function validate(): void { - foreach ($this->rules as $name => $rule) { - $components = explode('|', $rule); + foreach ($this->rules as $field => $rule) { + $parts = $this->extractParts($rule); + + foreach ($parts as $part) { + $validationRule = $this->resolveRuleClass($part); + + $validationRule->validate($field, $this->input, function ($message) use ($part, $field) { + $this->errors->put($field, $this->formatMessage($message, $part, $field)); + }); + } + } + } + + /** + * @throws ValidationRuleNotFoundException + */ + public function fails(): bool + { + $this->validate(); + + return $this->errors->count() > 0; + } + + private function extractParts($rule): array + { + return explode('|', $rule); + } + + /** + * @throws ValidationRuleNotFoundException + */ + private function resolveRuleClass($part): ValidationRuleInterface + { + $lazyClass = $this->validationRules[$part] ?? null; + + if ($lazyClass === null) { + throw new ValidationRuleNotFoundException('Unknown rule "' . $part); } - return true; + return $lazyClass(); + } + + public function getErrors(): ErrorBag + { + return $this->errors; + } + + private function formatMessage(string $message, string $rule, string $field): string + { + $message = $this->customMessages[$rule] ?? $message; + $field = $this->fieldNames[$field] ?? $field; + + return str_replace(':field', $field, $message); } } diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/ValidatorInterface.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/ValidatorInterface.php new file mode 100644 index 0000000..a507276 --- /dev/null +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/ValidatorInterface.php @@ -0,0 +1,15 @@ + fn () => $this->container->get(Required::class), + 'email' => fn () => $this->container->get(Email::class), + ]; + } + + public function register(): void + { + $this->container->bind(ValidatorInterface::class, function () { + $langCode = $this->container->getConfigValue('', 'ru'); + $translationsFile = __DIR__ . "/translations/$langCode.php"; + + if (! file_exists($translationsFile)) { + $translationsFile = __DIR__ . "/lang/en.php"; + } + + return new Validator($this->rules(), require $translationsFile); + }); + } +} diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/translations/ru.php b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/translations/ru.php new file mode 100644 index 0000000..245fb8a --- /dev/null +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/framework/Validator/translations/ru.php @@ -0,0 +1,6 @@ + ':field обязательно для заполнения.', + 'email' => 'Неверный e-mail.', +]; diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/src/ApplicationFactory.php b/module/oc_telegram_shop/upload/oc_telegram_shop/src/ApplicationFactory.php index 5ca0c5b..b94ef4f 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/src/ApplicationFactory.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/src/ApplicationFactory.php @@ -10,6 +10,7 @@ use Openguru\OpenCartFramework\Router\RouteServiceProvider; use Openguru\OpenCartFramework\Support\Arr; use Openguru\OpenCartFramework\Telegram\TelegramServiceProvider; use Openguru\OpenCartFramework\Telegram\TelegramValidateInitDataMiddleware; +use Openguru\OpenCartFramework\Validator\ValidatorServiceProvider; class ApplicationFactory { @@ -24,6 +25,7 @@ class ApplicationFactory RouteServiceProvider::class, AppServiceProvider::class, TelegramServiceProvider::class, + ValidatorServiceProvider::class, ]) ->withMiddlewares([ TelegramValidateInitDataMiddleware::class, diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/src/Decorators/OcRegistryDecorator.php b/module/oc_telegram_shop/upload/oc_telegram_shop/src/Decorators/OcRegistryDecorator.php index a467fa4..9311843 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/src/Decorators/OcRegistryDecorator.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/src/Decorators/OcRegistryDecorator.php @@ -3,12 +3,18 @@ namespace App\Decorators; use Cart\Cart; +use Cart\Currency; +use Config; use Loader; use Registry; +use Session; /** * @property Loader $load * @property Cart $cart + * @property Session $session + * @property Currency $currency + * @property Config $config * @property \ModelCatalogProduct $model_catalog_product */ class OcRegistryDecorator diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/src/Exceptions/OrderValidationFailedException.php b/module/oc_telegram_shop/upload/oc_telegram_shop/src/Exceptions/OrderValidationFailedException.php index 1180cd0..7e303c3 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/src/Exceptions/OrderValidationFailedException.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/src/Exceptions/OrderValidationFailedException.php @@ -2,7 +2,7 @@ namespace App\Exceptions; -use Rakit\Validation\ErrorBag; +use Openguru\OpenCartFramework\Validator\ErrorBag; use RuntimeException; use Throwable; diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/src/Handlers/ProductsHandler.php b/module/oc_telegram_shop/upload/oc_telegram_shop/src/Handlers/ProductsHandler.php index f84ed30..cec8dad 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/src/Handlers/ProductsHandler.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/src/Handlers/ProductsHandler.php @@ -9,16 +9,16 @@ use Exception; use Openguru\OpenCartFramework\Config\Settings; use Openguru\OpenCartFramework\Http\JsonResponse; use Openguru\OpenCartFramework\Http\Request; -use Openguru\OpenCartFramework\Logger\Logger; +use Openguru\OpenCartFramework\Logger\LoggerInterface; use RuntimeException; class ProductsHandler { private Settings $settings; private ProductsService $productsService; - private Logger $logger; + private LoggerInterface $logger; - public function __construct(Settings $settings, ProductsService $productsService, Logger $logger) + public function __construct(Settings $settings, ProductsService $productsService, LoggerInterface $logger) { $this->settings = $settings; $this->productsService = $productsService; diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/src/Services/OrderCreateService.php b/module/oc_telegram_shop/upload/oc_telegram_shop/src/Services/OrderCreateService.php index d49827f..554bac9 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/src/Services/OrderCreateService.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/src/Services/OrderCreateService.php @@ -1,16 +1,19 @@ database = $database; $this->cartService = $cartService; @@ -36,11 +41,16 @@ class OrderCreateService $this->settings = $settings; $this->telegramService = $telegramService; $this->logger = $logger; + $this->validator = $validator; } public function create(array $data, array $meta = []): void { - $this->validate($data); + try { + $this->validate($data); + } catch (ValidationRuleNotFoundException $e) { + throw new RuntimeException($e->getMessage()); + } $now = date('Y-m-d H:i:s'); $storeId = $this->settings->get('oc_store_id'); @@ -170,23 +180,22 @@ class OrderCreateService $this->sendNotifications($orderData, $data['tgData']); } + /** + * @throws ValidationRuleNotFoundException + */ private function validate(array $data): void { - $validator = new Validator(); - - $validation = $validator->make($data, [ - 'firstName' => 'required', - 'lastName' => 'required', - 'email' => 'required|email', - 'phone' => 'required', - 'address' => 'required', - 'comment' => 'required', + $v = $this->validator->make($data, $this->makeValidationRulesFromSettings(), [ + 'firstName' => 'Имя', + 'lastName' => 'Фамилия', + 'email' => 'E-mail', + 'phone' => 'Номер телефона', + 'address' => 'Адрес доставки', + 'comment' => 'Комментарий', ]); - $validation->validate(); - - if ($validation->fails()) { - throw new OrderValidationFailedException($validation->errors()); + if ($v->fails()) { + throw new OrderValidationFailedException($v->getErrors()); } } @@ -232,4 +241,16 @@ class OrderCreateService } } } + + private function makeValidationRulesFromSettings(): array + { + return [ + 'firstName' => 'required', + 'lastName' => 'required', + 'email' => 'required|email', + 'phone' => 'required', + 'address' => 'required', + 'comment' => 'required', + ]; + } } \ No newline at end of file diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/src/config.php b/module/oc_telegram_shop/upload/oc_telegram_shop/src/config.php index a8fce00..fd958fb 100755 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/src/config.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/src/config.php @@ -1,7 +1,6 @@ 'UTC', 'lang' => 'en-gb', diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/tests/TestCase.php b/module/oc_telegram_shop/upload/oc_telegram_shop/tests/TestCase.php new file mode 100644 index 0000000..4d9c6dd --- /dev/null +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/tests/TestCase.php @@ -0,0 +1,19 @@ +app = new Application($config); + } +} diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/tests/Validator/ErrorBagTest.php b/module/oc_telegram_shop/upload/oc_telegram_shop/tests/Validator/ErrorBagTest.php new file mode 100644 index 0000000..de57183 --- /dev/null +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/tests/Validator/ErrorBagTest.php @@ -0,0 +1,24 @@ + ['one', 'two'], + 'bar' => ['three', 'four'], + ]); + + $expected = [ + 'foo' => 'one', + 'bar' => 'three', + ]; + + $this->assertEquals($expected, $errorBag->firstOfAll()); + } +} diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/tests/Validator/ValidatorTest.php b/module/oc_telegram_shop/upload/oc_telegram_shop/tests/Validator/ValidatorTest.php new file mode 100644 index 0000000..136b5b8 --- /dev/null +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/tests/Validator/ValidatorTest.php @@ -0,0 +1,145 @@ +assertFalse($validator->make([], [])->fails()); + } + + /** + * @covers Validator::fails() + */ + public function testThrowExceptionIfRuleNotFound(): void + { + $validator = new Validator(); + $v = $validator->make([], [ + 'field' => 'not_exists_rule', + ]); + + $this->expectException(ValidationRuleNotFoundException::class); + + $v->fails(); + } + + public function testRequiredForNonExistentField(): void + { + $validator = new Validator([ + 'required' => fn () => new Required(), + ]); + + $v = $validator->make(['xyz' => 'abc'], ['foo' => 'required']); + + $this->assertTrue($v->fails()); + $this->assertEquals(1, $v->getErrors()->count()); + $this->assertEquals(['foo is required'], $v->getErrors()->first()); + } + + public function testRequiredForEmptyField(): void + { + $validator = new Validator([ + 'required' => fn () => new Required(), + ]); + + $v = $validator->make(['foo' => ''], ['foo' => 'required']); + + $this->assertTrue($v->fails()); + $this->assertEquals(1, $v->getErrors()->count()); + $this->assertEquals(['foo is required'], $v->getErrors()->first()); + } + + public function testRequiredForFalseValue(): void + { + $validator = new Validator([ + 'required' => fn () => new Required(), + ]); + + $v = $validator->make(['foo' => false], ['foo' => 'required']); + + $this->assertFalse($v->fails()); + } + + public function testRequiredForNullValue(): void + { + $validator = new Validator([ + 'required' => fn () => new Required(), + ]); + + $v = $validator->make(['foo' => null], ['foo' => 'required']); + + $this->assertTrue($v->fails()); + $this->assertEquals(1, $v->getErrors()->count()); + $this->assertEquals(['foo is required'], $v->getErrors()->first()); + } + + public function testRequiredForZero(): void + { + $validator = new Validator([ + 'required' => fn () => new Required(), + ]); + + $v = $validator->make(['foo' => 0], ['foo' => 'required']); + + $this->assertFalse($v->fails()); + } + + public function testRequiredForZeroString(): void + { + $validator = new Validator([ + 'required' => fn () => new Required(), + ]); + + $v = $validator->make(['foo' => "0"], ['foo' => 'required']); + + $this->assertFalse($v->fails()); + } + + public function testCustomValidationMessages(): void + { + $customMessages = [ + 'required' => ':field is very required', + ]; + + $validator = new Validator([ + 'required' => fn () => new Required(), + ], $customMessages); + + $v = $validator->make(['foo' => ''], ['foo' => 'required']); + + $this->assertTrue($v->fails()); + $this->assertEquals(1, $v->getErrors()->count()); + $this->assertEquals(['foo is very required'], $v->getErrors()->first()); + } + + public function testCustomFieldNames(): void + { + $validator = new Validator([ + 'required' => fn () => new Required(), + ]); + + $v = $validator->make(['foo' => ''], [ + 'foo' => 'required' + ], [ + 'foo' => 'My Field' + ]); + + $this->assertTrue($v->fails()); + $this->assertEquals(1, $v->getErrors()->count()); + $this->assertEquals(['My Field is required'], $v->getErrors()->first()); + } +}