From c3f3f69eac96387a31ca28d1a30a0309f2e5458d Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Tue, 17 Sep 2024 10:43:35 +0200 Subject: [PATCH 1/9] Add scoper and remove mozart files --- .github/workflows/release.yml | 5 +- composer.json | 18 +- composer.lock | 395 +++++++------ lib/README.md | 5 - .../Container/ContainerConfigurator.php | 157 ----- .../Container/PackageProxyContainer.php | 101 ---- .../Container/ReadOnlyContainer.php | 142 ----- .../Modularity/Module/ExecutableModule.php | 21 - .../Modularity/Module/ExtendingModule.php | 24 - .../Modularity/Module/FactoryModule.php | 18 - .../Inpsyde/Modularity/Module/Module.php | 20 - .../Module/ModuleClassNameIdTrait.php | 23 - .../Modularity/Module/ServiceModule.php | 21 - lib/packages/Inpsyde/Modularity/Package.php | 555 ------------------ .../Modularity/Properties/BaseProperties.php | 217 ------- .../Properties/LibraryProperties.php | 209 ------- .../Properties/PluginProperties.php | 163 ----- .../Modularity/Properties/Properties.php | 139 ----- .../Modularity/Properties/ThemeProperties.php | 131 ----- .../Container/ContainerExceptionInterface.php | 13 - .../Psr/Container/ContainerInterface.php | 37 -- .../Container/NotFoundExceptionInterface.php | 13 - scoper.inc.php | 75 +++ 23 files changed, 309 insertions(+), 2193 deletions(-) delete mode 100644 lib/README.md delete mode 100644 lib/packages/Inpsyde/Modularity/Container/ContainerConfigurator.php delete mode 100644 lib/packages/Inpsyde/Modularity/Container/PackageProxyContainer.php delete mode 100644 lib/packages/Inpsyde/Modularity/Container/ReadOnlyContainer.php delete mode 100644 lib/packages/Inpsyde/Modularity/Module/ExecutableModule.php delete mode 100644 lib/packages/Inpsyde/Modularity/Module/ExtendingModule.php delete mode 100644 lib/packages/Inpsyde/Modularity/Module/FactoryModule.php delete mode 100644 lib/packages/Inpsyde/Modularity/Module/Module.php delete mode 100644 lib/packages/Inpsyde/Modularity/Module/ModuleClassNameIdTrait.php delete mode 100644 lib/packages/Inpsyde/Modularity/Module/ServiceModule.php delete mode 100644 lib/packages/Inpsyde/Modularity/Package.php delete mode 100644 lib/packages/Inpsyde/Modularity/Properties/BaseProperties.php delete mode 100644 lib/packages/Inpsyde/Modularity/Properties/LibraryProperties.php delete mode 100644 lib/packages/Inpsyde/Modularity/Properties/PluginProperties.php delete mode 100644 lib/packages/Inpsyde/Modularity/Properties/Properties.php delete mode 100644 lib/packages/Inpsyde/Modularity/Properties/ThemeProperties.php delete mode 100644 lib/packages/Psr/Container/ContainerExceptionInterface.php delete mode 100644 lib/packages/Psr/Container/ContainerInterface.php delete mode 100644 lib/packages/Psr/Container/NotFoundExceptionInterface.php create mode 100644 scoper.inc.php diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a80d5667..8303fa58 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,11 +7,10 @@ on: required: true jobs: create_archive: - uses: inpsyde/reusable-workflows/.github/workflows/build-plugin-archive.yml@task/build-plugin-archive-without-dep-dependencies + uses: inpsyde/reusable-workflows/.github/workflows/build-plugin-archive.yml@main with: PLUGIN_VERSION: ${{ inputs.PACKAGE_VERSION }} PHP_VERSION: 7.2 PLUGIN_MAIN_FILE: mollie-payments-for-woocommerce.php ARCHIVE_NAME: mollie-payments-for-woocommerce - POST_SCRIPT: | - mv dist/WooCommerce dist/mollie-payments-for-woocommerce + PLUGIN_FOLDER_NAME: mollie-payments-for-woocommerce diff --git a/composer.json b/composer.json index 0fbd7da9..452e5498 100644 --- a/composer.json +++ b/composer.json @@ -20,11 +20,11 @@ "ext-intl": "*", "ext-json": "*", "mollie/mollie-api-php": "^v2.40", + "inpsyde/modularity": "^1.3.0", + "psr/container": "1.0.0", "psr/log":"^1.1.4" }, "require-dev": { - "inpsyde/modularity": "^1.3.0", - "psr/container": "1.0.0", "phpunit/phpunit": "^8", "brain/monkey": "^2.3", "ptrofimov/xpmock": "^1", @@ -39,8 +39,7 @@ "autoload": { "psr-4": { "Mollie\\WooCommerce\\": "src/", - "Inpsyde\\EnvironmentChecker\\": "pluginEnvironmentChecker", - "Mollie\\WooCommerce\\Vendor\\": "lib/packages/" + "Inpsyde\\EnvironmentChecker\\": "pluginEnvironmentChecker" } }, "autoload-dev": { @@ -78,17 +77,6 @@ "pre-commit": [ "vendor/bin/phpcbf" ] - }, - "mozart": { - "dep_namespace": "Mollie\\WooCommerce\\Vendor\\", - "dep_directory": "/lib/packages/", - "classmap_directory": "/lib/classes/", - "classmap_prefix": "MOL_", - "packages": [ - "psr/container", - "inpsyde/modularity" - ], - "delete_vendor_directories": true } }, "config": { diff --git a/composer.lock b/composer.lock index e9c88ffc..3d08ff82 100644 --- a/composer.lock +++ b/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": "99dd93462bdd098a3d12154b8e71b543", + "content-hash": "b958dd474a49238a79209ae9ea95c361", "packages": [ { "name": "composer/ca-bundle", @@ -175,32 +175,169 @@ "time": "2024-07-17T08:02:14+00:00" }, { - "name": "psr/log", - "version": "1.1.4", + "name": "symfony/deprecation-contracts", + "version": "v2.5.3", "source": { "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "80d075412b557d41002320b96a096ca65aa2c98d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", + "reference": "80d075412b557d41002320b96a096ca65aa2c98d", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" } + ], + "time": "2023-01-24T14:02:46+00:00" + }, + { + "name": "symfony/finder", + "version": "v5.4.43", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "ae25a9145a900764158d439653d5630191155ca0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/ae25a9145a900764158d439653d5630191155ca0", + "reference": "ae25a9145a900764158d439653d5630191155ca0", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php80": "^1.16" }, + "type": "library", "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v5.4.43" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-08-13T14:03:51+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.30.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "77fa7995ac1b21ab60769b7323d600a991a90433" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433", + "reference": "77fa7995ac1b21ab60769b7323d600a991a90433", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -208,21 +345,44 @@ ], "authors": [ { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", "keywords": [ - "log", - "psr", - "psr-3" + "compatibility", + "polyfill", + "portable", + "shim" ], "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0" }, - "time": "2021-05-03T11:20:27+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-05-31T15:07:36+00:00" } ], "packages-dev": [ @@ -2712,6 +2872,56 @@ }, "time": "2017-02-14T16:28:37+00:00" }, + { + "name": "psr/log", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "time": "2021-05-03T11:20:27+00:00" + }, { "name": "ptrofimov/xpmock", "version": "1.1.5", @@ -3704,73 +3914,6 @@ ], "time": "2024-07-26T12:21:55+00:00" }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.5.3", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "80d075412b557d41002320b96a096ca65aa2c98d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", - "reference": "80d075412b557d41002320b96a096ca65aa2c98d", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-01-24T14:02:46+00:00" - }, { "name": "symfony/polyfill-ctype", "version": "v1.30.0", @@ -4165,86 +4308,6 @@ ], "time": "2024-05-31T15:07:36+00:00" }, - { - "name": "symfony/polyfill-php80", - "version": "v1.30.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "77fa7995ac1b21ab60769b7323d600a991a90433" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433", - "reference": "77fa7995ac1b21ab60769b7323d600a991a90433", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-05-31T15:07:36+00:00" - }, { "name": "symfony/service-contracts", "version": "v2.2.0", diff --git a/lib/README.md b/lib/README.md deleted file mode 100644 index e25dc217..00000000 --- a/lib/README.md +++ /dev/null @@ -1,5 +0,0 @@ -The packages that are likely to cause conflicts with other plugins (by loading multiple incompatible versions). -Their namespaces are isolated by [Mozart](https://github.com/coenjacobs/mozart). - -Currently, the packages are simply added in the repo to avoid making the build process more complex. -We need to isolate only PSR-11 containers and Inpsyde modularity packages, which are not supposed to change often. diff --git a/lib/packages/Inpsyde/Modularity/Container/ContainerConfigurator.php b/lib/packages/Inpsyde/Modularity/Container/ContainerConfigurator.php deleted file mode 100644 index c7722af4..00000000 --- a/lib/packages/Inpsyde/Modularity/Container/ContainerConfigurator.php +++ /dev/null @@ -1,157 +0,0 @@ - - */ - private $services = []; - - /** - * @var array - */ - private $factoryIds = []; - - /** - * @var array> - */ - private $extensions = []; - - /** - * @var ContainerInterface[] - */ - private $containers = []; - - /** - * @var null|ContainerInterface - */ - private $compiledContainer; - - /** - * ContainerConfigurator constructor. - * - * @param ContainerInterface[] $containers - */ - public function __construct(array $containers = []) - { - array_map([$this, 'addContainer'], $containers); - } - - /** - * Allowing to add child containers. - * - * @param ContainerInterface $container - */ - public function addContainer(ContainerInterface $container): void - { - $this->containers[] = $container; - } - - /** - * @param string $id - * @param callable(ContainerInterface $container):mixed $factory - */ - public function addFactory(string $id, callable $factory): void - { - $this->addService($id, $factory); - // We're using a hash table to detect later - // via isset() if a Service as a Factory. - $this->factoryIds[$id] = true; - } - - /** - * @param string $id - * @param callable(ContainerInterface $container):mixed $service - * - * @return void - */ - public function addService(string $id, callable $service): void - { - if ($this->hasService($id)) { - /* - * We are being intentionally permissive here, - * allowing a simple workflow for *intentional* overrides - * while accepting the (small?) risk of *accidental* overrides - * that could be hard to notice and debug. - */ - - /* - * Clear a factory flag in case it was a factory. - * If needs be, it will get re-added after this function completes. - */ - unset($this->factoryIds[$id]); - } - - $this->services[$id] = $service; - } - - /** - * @param string $id - * - * @return bool - */ - public function hasService(string $id): bool - { - if (array_key_exists($id, $this->services)) { - return true; - } - - foreach ($this->containers as $container) { - if ($container->has($id)) { - return true; - } - } - - return false; - } - - /** - * @param string $id - * @param callable(mixed $service, ContainerInterface $container):mixed $extender - * - * @return void - */ - public function addExtension(string $id, callable $extender): void - { - if (!isset($this->extensions[$id])) { - $this->extensions[$id] = []; - } - - $this->extensions[$id][] = $extender; - } - - /** - * @param string $id - * - * @return bool - */ - public function hasExtension(string $id): bool - { - return isset($this->extensions[$id]); - } - - /** - * Returns a read only version of this Container. - * - * @return ContainerInterface - */ - public function createReadOnlyContainer(): ContainerInterface - { - if (!$this->compiledContainer) { - $this->compiledContainer = new ReadOnlyContainer( - $this->services, - $this->factoryIds, - $this->extensions, - $this->containers - ); - } - - return $this->compiledContainer; - } -} diff --git a/lib/packages/Inpsyde/Modularity/Container/PackageProxyContainer.php b/lib/packages/Inpsyde/Modularity/Container/PackageProxyContainer.php deleted file mode 100644 index 143b030d..00000000 --- a/lib/packages/Inpsyde/Modularity/Container/PackageProxyContainer.php +++ /dev/null @@ -1,101 +0,0 @@ -package = $package; - } - - /** - * @param string $id - * @return mixed - * - * @throws \Exception - */ - public function get($id) - { - assert(is_string($id)); - $this->assertPackageBooted($id); - - return $this->container->get($id); - } - - /** - * @param string $id - * @return bool - * - * @throws \Exception - */ - public function has($id) - { - assert(is_string($id)); - - return $this->tryContainer() && $this->container->has($id); - } - - /** - * @return bool - * - * @throws \Exception - * @psalm-assert-if-true ContainerInterface $this->container - */ - private function tryContainer(): bool - { - if ($this->container) { - return true; - } - - if ($this->package->statusIs(Package::STATUS_BOOTED)) { - $this->container = $this->package->container(); - } - - return (bool)$this->container; - } - - /** - * @param string $id - * @return void - * - * @throws \Exception - * - * @psalm-assert ContainerInterface $this->container - */ - private function assertPackageBooted(string $id): void - { - if ($this->tryContainer()) { - return; - } - - $name = $this->package->name(); - $status = $this->package->statusIs(Package::STATUS_FAILED) - ? 'failed booting' - : 'is not booted yet'; - - throw new class ("Error retrieving service {$id} because package {$name} {$status}.") - extends \Exception - implements ContainerExceptionInterface { - }; - } -} diff --git a/lib/packages/Inpsyde/Modularity/Container/ReadOnlyContainer.php b/lib/packages/Inpsyde/Modularity/Container/ReadOnlyContainer.php deleted file mode 100644 index ee082fa0..00000000 --- a/lib/packages/Inpsyde/Modularity/Container/ReadOnlyContainer.php +++ /dev/null @@ -1,142 +0,0 @@ - - */ - private $services; - - /** - * @var array - */ - private $factoryIds; - - /** - * @var array> - */ - private $extensions; - - /** - * Resolved factories. - * - * @var array - */ - private $resolvedServices = []; - - /** - * @var ContainerInterface[] - */ - private $containers; - - /** - * ReadOnlyContainer constructor. - * - * @param array $services - * @param array $factoryIds - * @param array> $extensions - * @param ContainerInterface[] $containers - */ - public function __construct( - array $services, - array $factoryIds, - array $extensions, - array $containers - ) { - $this->services = $services; - $this->factoryIds = $factoryIds; - $this->extensions = $extensions; - $this->containers = $containers; - } - - /** - * @param string $id - * - * @return mixed - */ - public function get($id) - { - assert(is_string($id)); - - if (array_key_exists($id, $this->resolvedServices)) { - return $this->resolvedServices[$id]; - } - - if (array_key_exists($id, $this->services)) { - $service = $this->services[$id]($this); - $resolved = $this->resolveExtensions($id, $service); - - if (!isset($this->factoryIds[$id])) { - $this->resolvedServices[$id] = $resolved; - unset($this->services[$id]); - } - - return $resolved; - } - - foreach ($this->containers as $container) { - if ($container->has($id)) { - $service = $container->get($id); - - return $this->resolveExtensions($id, $service); - } - } - - throw new class ("Service with ID {$id} not found.") - extends \Exception - implements NotFoundExceptionInterface { - }; - } - - /** - * @param string $id - * - * @return bool - */ - public function has($id) - { - assert(is_string($id)); - - if (array_key_exists($id, $this->services)) { - return true; - } - - if (array_key_exists($id, $this->resolvedServices)) { - return true; - } - - foreach ($this->containers as $container) { - if ($container->has($id)) { - return true; - } - } - - return false; - } - - /** - * @param string $id - * @param mixed $service - * - * @return mixed - */ - private function resolveExtensions(string $id, $service) - { - if (!isset($this->extensions[$id])) { - return $service; - } - - foreach ($this->extensions[$id] as $extender) { - $service = $extender($service, $this); - } - - return $service; - } -} diff --git a/lib/packages/Inpsyde/Modularity/Module/ExecutableModule.php b/lib/packages/Inpsyde/Modularity/Module/ExecutableModule.php deleted file mode 100644 index ea59bbbf..00000000 --- a/lib/packages/Inpsyde/Modularity/Module/ExecutableModule.php +++ /dev/null @@ -1,21 +0,0 @@ - - */ - public function extensions(): array; -} diff --git a/lib/packages/Inpsyde/Modularity/Module/FactoryModule.php b/lib/packages/Inpsyde/Modularity/Module/FactoryModule.php deleted file mode 100644 index 5990547f..00000000 --- a/lib/packages/Inpsyde/Modularity/Module/FactoryModule.php +++ /dev/null @@ -1,18 +0,0 @@ - - */ - public function factories(): array; -} diff --git a/lib/packages/Inpsyde/Modularity/Module/Module.php b/lib/packages/Inpsyde/Modularity/Module/Module.php deleted file mode 100644 index 7ab5afa7..00000000 --- a/lib/packages/Inpsyde/Modularity/Module/Module.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ - public function services(): array; -} diff --git a/lib/packages/Inpsyde/Modularity/Package.php b/lib/packages/Inpsyde/Modularity/Package.php deleted file mode 100644 index 72b24d7e..00000000 --- a/lib/packages/Inpsyde/Modularity/Package.php +++ /dev/null @@ -1,555 +0,0 @@ - - * $package = Package::new(); - * $package->boot(); - * - * $container = $package->container(); - * $container->has(Package::PROPERTIES); - * $container->get(Package::PROPERTIES); - * - * - * @var string - */ - public const PROPERTIES = 'properties'; - - /** - * Custom action to be used to add Modules to the package. - * It might also be used to access package properties. - * - * @example - * - * $package = Package::new(); - * - * add_action( - * $package->hookName(Package::ACTION_INIT), - * $callback - * ); - * - */ - public const ACTION_INIT = 'init'; - - /** - * Custom action which is triggered after the application - * is booted to access container and properties. - * - * @example - * - * $package = Package::new(); - * - * add_action( - * $package->hookName(Package::ACTION_READY), - * $callback - * ); - * - */ - public const ACTION_READY = 'ready'; - - /** - * Custom action which is triggered when application failed to boot. - * - * @example - * - * $package = Package::new(); - * - * add_action( - * $package->hookName(Package::ACTION_FAILED_BOOT), - * $callback - * ); - * - */ - public const ACTION_FAILED_BOOT = 'failed-boot'; - - /** - * Custom action which is triggered when a package is connected. - */ - public const ACTION_PACKAGE_CONNECTED = 'package-connected'; - - /** - * Custom action which is triggered when a package cannot be connected. - */ - public const ACTION_FAILED_CONNECTION = 'failed-connection'; - - /** - * Module states can be used to get information about your module. - * - * @example - * - * $package = Package::new(); - * $package->moduleIs(SomeModule::class, Package::MODULE_ADDED); // false - * $package->boot(new SomeModule()); - * $package->moduleIs(SomeModule::class, Package::MODULE_ADDED); // true - * - */ - public const MODULE_ADDED = 'added'; - public const MODULE_NOT_ADDED = 'not-added'; - public const MODULE_REGISTERED = 'registered'; - public const MODULE_REGISTERED_FACTORIES = 'registered-factories'; - public const MODULE_EXTENDED = 'extended'; - public const MODULE_EXECUTED = 'executed'; - public const MODULE_EXECUTION_FAILED = 'executed-failed'; - public const MODULES_ALL = '*'; - - /** - * Custom states for the class. - * - * @example - * - * $package = Package::new(); - * $package->statusIs(Package::IDLE); // true - * $package->boot(); - * $package->statusIs(Package::BOOTED); // true - * - */ - public const STATUS_IDLE = 2; - public const STATUS_INITIALIZED = 4; - public const STATUS_BOOTED = 8; - public const STATUS_FAILED = -8; - - /** - * Current state of the application. - * - * @see Package::STATUS_* - * - * @var int - */ - private $status = self::STATUS_IDLE; - - /** - * Contains the progress of all modules. - * - * @see Package::moduleProgress() - * - * @var array> - */ - private $moduleStatus = [self::MODULES_ALL => []]; - - /** - * Hashmap of where keys are names of connected packages, and values are boolean, true - * if connection was successful. - * - * @see Package::connect() - * - * @var array - */ - private $connectedPackages = []; - - /** - * @var list - */ - private $executables = []; - - /** - * @var Properties - */ - private $properties; - - /** - * @var ContainerConfigurator - */ - private $containerConfigurator; - - /** - * @param Properties $properties - * @param ContainerInterface[] $containers - * - * @return Package - */ - public static function new(Properties $properties, ContainerInterface ...$containers): Package - { - return new self($properties, ...$containers); - } - - /** - * @param Properties $properties - * @param ContainerInterface[] $containers - */ - private function __construct(Properties $properties, ContainerInterface ...$containers) - { - $this->properties = $properties; - - $this->containerConfigurator = new ContainerConfigurator($containers); - $this->containerConfigurator->addService( - self::PROPERTIES, - static function () use ($properties) { - return $properties; - } - ); - } - - /** - * @param Module $module - * - * @return static - * @throws \Exception - */ - public function addModule(Module $module): Package - { - $this->assertStatus(self::STATUS_IDLE, 'access Container'); - - $registeredServices = $this->addModuleServices($module, self::MODULE_REGISTERED); - $registeredFactories = $this->addModuleServices($module, self::MODULE_REGISTERED_FACTORIES); - $extended = $this->addModuleServices($module, self::MODULE_EXTENDED); - $isExecutable = $module instanceof ExecutableModule; - - // ExecutableModules are collected and executed on Package::boot() - // when the Container is being compiled. - if ($isExecutable) { - /** @var ExecutableModule $module */ - $this->executables[] = $module; - } - - $added = $registeredServices || $registeredFactories || $extended || $isExecutable; - $status = $added ? self::MODULE_ADDED : self::MODULE_NOT_ADDED; - $this->moduleProgress($module->id(), $status); - - return $this; - } - - /** - * @param Package $package - * @return bool - * @throws \Exception - */ - public function connect(Package $package): bool - { - if (($package === $this)) { - return false; - } - - $packageName = $package->name(); - $errorData = ['package' => $packageName, 'status' => $this->status]; - - // Don't connect, if already connected - if (array_key_exists($packageName, $this->connectedPackages)) { - do_action( - $this->hookName(self::ACTION_FAILED_CONNECTION), - $packageName, - new \WP_Error('already_connected', 'already connected', $errorData) - ); - - return false; - } - - // Don't connect, if already booted or boot failed - if (in_array($this->status, [self::STATUS_BOOTED, self::STATUS_FAILED], true)) { - $this->connectedPackages[$packageName] = false; - do_action( - $this->hookName(self::ACTION_FAILED_CONNECTION), - $packageName, - new \WP_Error('no_connect_status', 'no connect status', $errorData) - ); - - return false; - } - - $this->connectedPackages[$packageName] = true; - - // We put connected package's properties in this package's container, so that in modules - // "run" method we can access them if we need to. - $this->containerConfigurator->addService( - sprintf('%s.%s', $package->name(), self::PROPERTIES), - static function () use ($package): Properties { - return $package->properties(); - } - ); - - // If the other package is booted, we can obtain a container, otherwise - // we build a proxy container - $container = $package->statusIs(self::STATUS_BOOTED) - ? $package->container() - : new PackageProxyContainer($package); - - $this->containerConfigurator->addContainer($container); - - do_action( - $this->hookName(self::ACTION_PACKAGE_CONNECTED), - $packageName, - $this->status, - $container instanceof PackageProxyContainer - ); - - return true; - } - - /** - * @param Module ...$defaultModules - * - * @return bool - * - * @throws \Throwable - */ - public function boot(Module ...$defaultModules): bool - { - try { - // don't allow to boot the application multiple times. - $this->assertStatus(self::STATUS_IDLE, 'execute boot'); - - // Add default Modules to the Application. - array_map([$this, 'addModule'], $defaultModules); - - do_action( - $this->hookName(self::ACTION_INIT), - $this - ); - // we want to lock adding new Modules and Containers now - // to process everything and be able to compile the container. - $this->progress(self::STATUS_INITIALIZED); - - if (count($this->executables) > 0) { - $this->doExecute(); - } - - do_action( - $this->hookName(self::ACTION_READY), - $this - ); - } catch (\Throwable $throwable) { - $this->progress(self::STATUS_FAILED); - do_action($this->hookName(self::ACTION_FAILED_BOOT), $throwable); - - if ($this->properties->isDebug()) { - throw $throwable; - } - - return false; - } - - $this->progress(self::STATUS_BOOTED); - - return true; - } - - /** - * @param Module $module - * @param string $status - * @return bool - */ - private function addModuleServices(Module $module, string $status): bool - { - $services = null; - $addCallback = null; - switch ($status) { - case self::MODULE_REGISTERED: - $services = $module instanceof ServiceModule ? $module->services() : null; - $addCallback = [$this->containerConfigurator, 'addService']; - break; - case self::MODULE_REGISTERED_FACTORIES: - $services = $module instanceof FactoryModule ? $module->factories() : null; - $addCallback = [$this->containerConfigurator, 'addFactory']; - break; - case self::MODULE_EXTENDED: - $services = $module instanceof ExtendingModule ? $module->extensions() : null; - $addCallback = [$this->containerConfigurator, 'addExtension']; - break; - } - - if (!$services) { - return false; - } - - $ids = []; - array_walk( - $services, - static function (callable $service, string $id) use ($addCallback, &$ids) { - /** @var callable(string, callable) $addCallback */ - $addCallback($id, $service); - /** @var list $ids */ - $ids[] = $id; - } - ); - /** @var list $ids */ - $this->moduleProgress($module->id(), $status, $ids); - - return true; - } - - /** - * @return void - * - * @throws \Throwable - */ - private function doExecute(): void - { - foreach ($this->executables as $executable) { - $success = $executable->run($this->container()); - $this->moduleProgress( - $executable->id(), - $success - ? self::MODULE_EXECUTED - : self::MODULE_EXECUTION_FAILED - ); - } - } - - /** - * @param string $moduleId - * @param string $type - * @param list|null $serviceIds - * - * @return void - */ - private function moduleProgress(string $moduleId, string $type, ?array $serviceIds = null) - { - isset($this->moduleStatus[$type]) or $this->moduleStatus[$type] = []; - $this->moduleStatus[$type][] = $moduleId; - - if (!$serviceIds || !$this->properties->isDebug()) { - $this->moduleStatus[self::MODULES_ALL][] = "{$moduleId} {$type}"; - - return; - } - - $description = sprintf('%s %s (%s)', $moduleId, $type, implode(', ', $serviceIds)); - $this->moduleStatus[self::MODULES_ALL][] = $description; - } - - /** - * @return array> - */ - public function modulesStatus(): array - { - return $this->moduleStatus; - } - - /** - * @return array - */ - public function connectedPackages(): array - { - return $this->connectedPackages; - } - - /** - * @param string $packageName - * @return bool - */ - public function isPackageConnected(string $packageName): bool - { - return $this->connectedPackages[$packageName] ?? false; - } - - /** - * @param string $moduleId - * @param string $status - * - * @return bool - */ - public function moduleIs(string $moduleId, string $status): bool - { - return in_array($moduleId, $this->moduleStatus[$status] ?? [], true); - } - - /** - * Return the filter name to be used to extend modules of the plugin. - * - * If the plugin is single file `my-plugin.php` in plugins folder the filter name will be: - * `inpsyde.modularity.my-plugin`. - * - * If the plugin is in a sub-folder e.g. `my-plugin/index.php` the filter name will be: - * `inpsyde.modularity.my-plugin` anyway, so the file name is not relevant. - * - * @param string $suffix - * - * @return string - * @see Package::name() - * - */ - public function hookName(string $suffix = ''): string - { - $filter = self::HOOK_PREFIX . $this->properties->baseName(); - - if ($suffix) { - $filter .= '.' . $suffix; - } - - return $filter; - } - - /** - * @return Properties - */ - public function properties(): Properties - { - return $this->properties; - } - - /** - * @return ContainerInterface - * - * @throws \Exception - */ - public function container(): ContainerInterface - { - $this->assertStatus(self::STATUS_INITIALIZED, 'access Container', '>='); - - return $this->containerConfigurator->createReadOnlyContainer(); - } - - /** - * @return string - */ - public function name(): string - { - return $this->properties->baseName(); - } - - /** - * @param int $status - */ - private function progress(int $status): void - { - $this->status = $status; - } - - /** - * @param int $status - * - * @return bool - */ - public function statusIs(int $status): bool - { - return $this->status === $status; - } - - /** - * @param int $status - * @param string $action - * @param string $operator - * - * @throws \Exception - * @psalm-suppress ArgumentTypeCoercion - */ - private function assertStatus(int $status, string $action, string $operator = '=='): void - { - if (!version_compare((string) $this->status, (string) $status, $operator)) { - throw new \Exception(sprintf("Can't %s at this point of application.", $action)); - } - } -} diff --git a/lib/packages/Inpsyde/Modularity/Properties/BaseProperties.php b/lib/packages/Inpsyde/Modularity/Properties/BaseProperties.php deleted file mode 100644 index 11f4be1d..00000000 --- a/lib/packages/Inpsyde/Modularity/Properties/BaseProperties.php +++ /dev/null @@ -1,217 +0,0 @@ -sanitizeBaseName($baseName); - $basePath = (string) trailingslashit($basePath); - if ($baseUrl) { - $baseUrl = (string) trailingslashit($baseUrl); - } - - $this->baseName = $baseName; - $this->basePath = $basePath; - $this->baseUrl = $baseUrl; - $this->properties = array_replace(Properties::DEFAULT_PROPERTIES, $properties); - } - - /** - * @param string $name - * - * @return string - */ - protected function sanitizeBaseName(string $name): string - { - substr_count($name, '/') and $name = dirname($name); - - return strtolower(pathinfo($name, PATHINFO_FILENAME)); - } - - /** - * @return string - */ - public function baseName(): string - { - return $this->baseName; - } - - /** - * @return string - */ - public function basePath(): string - { - return $this->basePath; - } - - /** - * @return string|null - */ - public function baseUrl(): ?string - { - return $this->baseUrl; - } - - /** - * @return string - */ - public function author(): string - { - return (string) $this->get(self::PROP_AUTHOR); - } - - /** - * @return string - */ - public function authorUri(): string - { - return (string) $this->get(self::PROP_AUTHOR_URI); - } - - /** - * @return string - */ - public function description(): string - { - return (string) $this->get(self::PROP_DESCRIPTION); - } - - /** - * @return string - */ - public function textDomain(): string - { - return (string) $this->get(self::PROP_TEXTDOMAIN); - } - - /** - * @return string - */ - public function domainPath(): string - { - return (string) $this->get(self::PROP_DOMAIN_PATH); - } - - /** - * @return string - */ - public function name(): string - { - return (string) $this->get(self::PROP_NAME); - } - - /** - * @return string - */ - public function uri(): string - { - return (string) $this->get(self::PROP_URI); - } - - /** - * @return string - */ - public function version(): string - { - return (string) $this->get(self::PROP_VERSION); - } - - /** - * @return string|null - */ - public function requiresWp(): ?string - { - $value = $this->get(self::PROP_REQUIRES_WP); - - return $value && is_string($value) ? $value : null; - } - - /** - * @return string|null - */ - public function requiresPhp(): ?string - { - $value = $this->get(self::PROP_REQUIRES_PHP); - - return $value && is_string($value) ? $value : null; - } - - /** - * @return array - */ - public function tags(): array - { - return (array) $this->get(self::PROP_TAGS); - } - - /** - * @param string $key - * @param null $default - * @return mixed - */ - public function get(string $key, $default = null) - { - return $this->properties[$key] ?? $default; - } - - /** - * @param string $key - * @return bool - */ - public function has(string $key): bool - { - return isset($this->properties[$key]); - } - - /** - * @return bool - * @see Properties::isDebug() - */ - public function isDebug(): bool - { - if ($this->isDebug === null) { - $this->isDebug = defined('WP_DEBUG') && WP_DEBUG; - } - - return $this->isDebug; - } -} diff --git a/lib/packages/Inpsyde/Modularity/Properties/LibraryProperties.php b/lib/packages/Inpsyde/Modularity/Properties/LibraryProperties.php deleted file mode 100644 index 16e10451..00000000 --- a/lib/packages/Inpsyde/Modularity/Properties/LibraryProperties.php +++ /dev/null @@ -1,209 +0,0 @@ - 0) { - $properties[self::PROP_AUTHOR] = implode(', ', $names); - } - - // Custom settings which can be stored in composer.json "extra.modularity" - $extra = $composerJsonData['extra']['modularity'] ?? []; - foreach (self::EXTRA_KEYS as $key) { - $properties[$key] = $extra[$key] ?? ''; - } - - // PHP requirement in composer.json "require" or "require-dev" - $properties[self::PROP_REQUIRES_PHP] = self::extractPhpVersion($composerJsonData); - - // composer.json might have "version" in root - $version = $composerJsonData['version'] ?? null; - if ($version && is_string($version)) { - $properties[self::PROP_VERSION] = $version; - } - - [$baseName, $name] = static::buildNames($composerJsonData); - $basePath = dirname($composerJsonFile); - if (empty($properties[self::PROP_NAME])) { - $properties[self::PROP_NAME] = $name; - } - - return new self( - $baseName, - $basePath, - $baseUrl, - $properties - ); - } - - /** - * @param array $composerJsonData - * - * @return array{string, string} - */ - private static function buildNames(array $composerJsonData): array - { - $composerName = (string) ($composerJsonData['name'] ?? ''); - $packageNamePieces = explode('/', $composerName, 2); - $basename = implode('-', $packageNamePieces); - // "inpsyde/foo-bar-baz" => "Inpsyde Foo Bar Baz" - $name = mb_convert_case( - str_replace(['-', '_', '.'], ' ', implode(' ', $packageNamePieces)), - MB_CASE_TITLE - ); - - return [$basename, $name]; - } - - /** - * Check PHP version in require, require-dev. - * - * Attempt to parse requirements to find the _minimum_ accepted version (consistent with WP). - * Composer requirements are parsed in a way that, for example: - * `>=7.2` returns `7.2` - * `^7.3` returns `7.3` - * `5.6 || >= 7.1` returns `5.6` - * `>= 7.1 < 8` returns `7.1` - * - * @param array $composerData - * @param string $key - * - * @return string|null - */ - private static function extractPhpVersion(array $composerData, string $key = 'require'): ?string - { - $nextKey = ($key === 'require') - ? 'require-dev' - : null; - $base = (array) ($composerData[$key] ?? []); - $requirement = $base['php'] ?? null; - $version = ($requirement && is_string($requirement)) - ? trim($requirement) - : null; - if (!$version) { - return $nextKey - ? static::extractPhpVersion($composerData, $nextKey) - : null; - } - - static $matcher; - $matcher or $matcher = static function (string $version): ?string { - $version = trim($version); - if (!$version) { - return null; - } - - // versions range like `>= 7.2.4 < 8` - if (preg_match('{>=?([\s0-9\.]+)<}', $version, $matches)) { - return trim($matches[1], " \t\n\r\0\x0B."); - } - - // aliases like `dev-src#abcde as 7.4` - if (preg_match('{as\s*([\s0-9\.]+)}', $version, $matches)) { - return trim($matches[1], " \t\n\r\0\x0B."); - } - - // Basic requirements like 7.2, >=7.2, ^7.2, ~7.2 - if (preg_match('{^(?:[>=\s~\^]+)?([0-9\.]+)}', $version, $matches)) { - return trim($matches[1], " \t\n\r\0\x0B."); - } - - return null; - }; - - // support for simpler requirements like `7.3`, `>=7.4` or alternative like `5.6 || >=7` - - $alternatives = explode('||', $version); - $found = null; - foreach ($alternatives as $alternative) { - /** @var callable(string):?string $matcher */ - $itemFound = $matcher($alternative); - if ($itemFound && (!$found || version_compare($itemFound, $found, '<'))) { - $found = $itemFound; - } - } - - if ($found) { - return $found; - } - - return $nextKey - ? static::extractPhpVersion($composerData, $nextKey) - : null; - } - - /** - * @param string $url - * - * @return static - * - * @throws \Exception - */ - public function withBaseUrl(string $url): LibraryProperties - { - if ($this->baseUrl !== null) { - throw new \Exception(sprintf('%s::$baseUrl property is not overridable.', __CLASS__)); - } - - $this->baseUrl = trailingslashit($url); - - return $this; - } -} diff --git a/lib/packages/Inpsyde/Modularity/Properties/PluginProperties.php b/lib/packages/Inpsyde/Modularity/Properties/PluginProperties.php deleted file mode 100644 index 3c4a7d97..00000000 --- a/lib/packages/Inpsyde/Modularity/Properties/PluginProperties.php +++ /dev/null @@ -1,163 +0,0 @@ - 'Author', - self::PROP_AUTHOR_URI => 'AuthorURI', - self::PROP_DESCRIPTION => 'Description', - self::PROP_DOMAIN_PATH => 'DomainPath', - self::PROP_NAME => 'Name', - self::PROP_TEXTDOMAIN => 'TextDomain', - self::PROP_URI => 'PluginURI', - self::PROP_VERSION => 'Version', - self::PROP_REQUIRES_WP => 'RequiresWP', - self::PROP_REQUIRES_PHP => 'RequiresPHP', - - // additional headers - self::PROP_NETWORK => 'Network', - ]; - - /** - * @var string - */ - private $pluginFile; - - /** - * @var bool|null - */ - protected $isMu; - - /** - * @var bool|null - */ - protected $isActive; - - /** - * @var bool|null - */ - protected $isNetworkActive; - - /** - * @param string $pluginMainFile - * - * @return PluginProperties - */ - public static function new(string $pluginMainFile): PluginProperties - { - return new self($pluginMainFile); - } - - /** - * PluginProperties constructor. - * - * @param string $pluginMainFile - */ - protected function __construct(string $pluginMainFile) - { - if (!function_exists('get_plugin_data')) { - require_once ABSPATH . 'wp-admin/includes/plugin.php'; - } - - $pluginData = get_plugin_data($pluginMainFile); - $properties = Properties::DEFAULT_PROPERTIES; - - // Map pluginData to internal structure. - foreach (self::HEADERS as $key => $pluginDataKey) { - $properties[$key] = $pluginData[$pluginDataKey] ?? ''; - unset($pluginData[$pluginDataKey]); - } - $properties = array_merge($properties, $pluginData); - - $this->pluginFile = $pluginMainFile; - - $baseName = plugin_basename($pluginMainFile); - $basePath = plugin_dir_path($pluginMainFile); - $baseUrl = plugins_url('/', $pluginMainFile); - - parent::__construct( - $baseName, - $basePath, - $baseUrl, - $properties - ); - } - - /** - * @return bool - * - * @psalm-suppress PossiblyFalseArgument - */ - public function network(): bool - { - return (bool) $this->get(self::PROP_NETWORK, false); - } - - /** - * @return bool - */ - public function isActive(): bool - { - if ($this->isActive === null) { - if (!function_exists('is_plugin_active')) { - require_once ABSPATH . 'wp-admin/includes/plugin.php'; - } - $this->isActive = is_plugin_active($this->pluginFile); - } - - return $this->isActive; - } - - /** - * @return bool - */ - public function isNetworkActive(): bool - { - if ($this->isNetworkActive === null) { - if (!function_exists('is_plugin_active_for_network')) { - require_once ABSPATH . 'wp-admin/includes/plugin.php'; - } - $this->isNetworkActive = is_plugin_active_for_network($this->pluginFile); - } - - return $this->isNetworkActive; - } - - /** - * @return bool - */ - public function isMuPlugin(): bool - { - if ($this->isMu === null) { - /** - * @psalm-suppress UndefinedConstant - * @psalm-suppress MixedArgument - */ - $muPluginDir = wp_normalize_path(WPMU_PLUGIN_DIR); - $this->isMu = strpos($this->pluginFile, $muPluginDir) === 0; - } - - return $this->isMu; - } -} diff --git a/lib/packages/Inpsyde/Modularity/Properties/Properties.php b/lib/packages/Inpsyde/Modularity/Properties/Properties.php deleted file mode 100644 index 995c316c..00000000 --- a/lib/packages/Inpsyde/Modularity/Properties/Properties.php +++ /dev/null @@ -1,139 +0,0 @@ - '', - self::PROP_AUTHOR_URI => '', - self::PROP_DESCRIPTION => '', - self::PROP_DOMAIN_PATH => '', - self::PROP_NAME => '', - self::PROP_TEXTDOMAIN => '', - self::PROP_URI => '', - self::PROP_VERSION => '', - self::PROP_REQUIRES_WP => null, - self::PROP_REQUIRES_PHP => null, - self::PROP_TAGS => [], - ]; - - /** - * @param string $key - * @param null $default - * - * @return mixed - */ - public function get(string $key, $default = null); - - /** - * @param string $key - * - * @return bool - */ - public function has(string $key): bool; - - /** - * @return bool - */ - public function isDebug(): bool; - - /** - * @return string - */ - public function baseName(): string; - - /** - * @return string - */ - public function basePath(): string; - - /** - * @return string|null - */ - public function baseUrl(): ?string; - - /** - * @return string - */ - public function author(): string; - - /** - * @return string - */ - public function authorUri(): string; - - /** - * @return string - */ - public function description(): string; - - /** - * @return string - */ - public function textDomain(): string; - - /** - * @return string - */ - public function domainPath(): string; - - /** - * The name of the plugin, theme or library. - * - * @return string - */ - public function name(): string; - - /** - * The home page of the plugin, theme or library. - * @return string - */ - public function uri(): string; - - /** - * @return string - */ - public function version(): string; - - /** - * Optional. Specify the minimum required WordPress version. - * - * @return string|null - */ - public function requiresWp(): ?string; - - /** - * Optional. Specify the minimum required PHP version. - * - * @return string - */ - public function requiresPhp(): ?string; - - /** - * Optional. Currently, only available for Theme and Library. - * Plugins do not have support for "tags"/"keywords" in header. - * - * @link https://developer.wordpress.org/reference/classes/wp_theme/#properties - * @link https://getcomposer.org/doc/04-schema.md#keywords - * - * @return array - */ - public function tags(): array; -} diff --git a/lib/packages/Inpsyde/Modularity/Properties/ThemeProperties.php b/lib/packages/Inpsyde/Modularity/Properties/ThemeProperties.php deleted file mode 100644 index 3535c391..00000000 --- a/lib/packages/Inpsyde/Modularity/Properties/ThemeProperties.php +++ /dev/null @@ -1,131 +0,0 @@ - 'Author', - self::PROP_AUTHOR_URI => 'Author URI', - self::PROP_DESCRIPTION => 'Description', - self::PROP_DOMAIN_PATH => 'Domain Path', - self::PROP_NAME => 'Theme Name', - self::PROP_TEXTDOMAIN => 'Text Domain', - self::PROP_URI => 'Theme URI', - self::PROP_VERSION => 'Version', - self::PROP_REQUIRES_WP => 'Requires at least', - self::PROP_REQUIRES_PHP => 'Requires PHP', - - // additional headers - self::PROP_STATUS => 'Status', - self::PROP_TAGS => 'Tags', - self::PROP_TEMPLATE => 'Template', - ]; - - /** - * @param string $themeDirectory - * - * @return ThemeProperties - */ - public static function new(string $themeDirectory): ThemeProperties - { - return new self($themeDirectory); - } - - /** - * ThemeProperties constructor. - * - * @param string $themeDirectory - */ - protected function __construct(string $themeDirectory) - { - if (!function_exists('wp_get_theme')) { - require_once ABSPATH . 'wp-includes/theme.php'; - } - - $theme = wp_get_theme($themeDirectory); - $properties = Properties::DEFAULT_PROPERTIES; - - foreach (self::HEADERS as $key => $themeKey) { - /** @psalm-suppress DocblockTypeContradiction */ - $properties[$key] = $theme->get($themeKey) ?? ''; - } - - $baseName = $theme->get_stylesheet(); - $basePath = $theme->get_template_directory(); - $baseUrl = (string) trailingslashit($theme->get_stylesheet_directory_uri()); - - parent::__construct( - $baseName, - $basePath, - $baseUrl, - $properties - ); - } - - /** - * If the theme is published. - * - * @return string - */ - public function status(): string - { - return (string) $this->get(self::PROP_STATUS); - } - - public function template(): string - { - return (string) $this->get(self::PROP_TEMPLATE); - } - - /** - * @return bool - */ - public function isChildTheme(): bool - { - return (bool) $this->template(); - } - - /** - * @return bool - */ - public function isCurrentTheme(): bool - { - return get_stylesheet() === $this->baseName(); - } - - /** - * @return ThemeProperties|null - */ - public function parentThemeProperties(): ?ThemeProperties - { - $template = $this->template(); - if (!$template) { - return null; - } - - $parent = wp_get_theme($template, get_theme_root($template)); - - return static::new($parent->get_template_directory()); - } -} diff --git a/lib/packages/Psr/Container/ContainerExceptionInterface.php b/lib/packages/Psr/Container/ContainerExceptionInterface.php deleted file mode 100644 index 0cc7d5e8..00000000 --- a/lib/packages/Psr/Container/ContainerExceptionInterface.php +++ /dev/null @@ -1,13 +0,0 @@ -files() + ->ignoreVCS(true) + ->ignoreDotFiles(false) # We need to keep .distignore around + ->exclude([ + '.github', + '.ddev', + '.idea', + 'modules.local', + 'tests', + ]) + ->in('.'), +]; + +return [ + 'prefix' => 'Syde\\Vendor', // string|null + 'finders' => $finders, // list + 'patchers' => [], // list + 'exclude-files' => [ + 'vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php' + ], // list + 'exclude-namespaces' => [ + 'Composer', + 'Automattic', + '^WooCommerce', + 'Inpsyde\Assets', + ], // list + 'exclude-constants' => array_merge($wp_constants, [ + 'WC_VERSION', + ]), // list + 'exclude-classes' => array_merge($wp_classes, [ + 'WooCommerce', + '/^WC_/', + ]), // list + 'exclude-functions' => array_merge($wp_functions, [ + '/^wc/', + ]), // list + + 'expose-global-constants' => false, // bool + 'expose-global-classes' => false, // bool + 'expose-global-functions' => false, // bool + + 'expose-namespaces' => [], // list + 'expose-constants' => [], // list + 'expose-classes' => [], // list + 'expose-functions' => [], // list +]; From e6094744d3721051ea3ac60576971345759f119f Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 19 Sep 2024 09:24:15 +0200 Subject: [PATCH 2/9] Update composer lock --- composer.lock | 739 +++++++++++++++++++++++--------------------------- 1 file changed, 338 insertions(+), 401 deletions(-) diff --git a/composer.lock b/composer.lock index 3d08ff82..6e5ec773 100644 --- a/composer.lock +++ b/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": "b958dd474a49238a79209ae9ea95c361", + "content-hash": "2544dbd439fe830543743298a0d463cb", "packages": [ { "name": "composer/ca-bundle", @@ -82,18 +82,91 @@ ], "time": "2024-07-08T15:28:20+00:00" }, + { + "name": "inpsyde/modularity", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/inpsyde/modularity.git", + "reference": "3bbff6197aabbc4df25b5f386f521bedc71aff2e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/inpsyde/modularity/zipball/3bbff6197aabbc4df25b5f386f521bedc71aff2e", + "reference": "3bbff6197aabbc4df25b5f386f521bedc71aff2e", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=7.2", + "psr/container": "~1.0" + }, + "require-dev": { + "brain/monkey": "^2.6.1", + "inpsyde/php-coding-standards": "^1", + "johnpbloch/wordpress-core": ">=5.8", + "mikey179/vfsstream": "^v1.6.10", + "php-stubs/wordpress-stubs": ">=5.8@stable", + "phpunit/phpunit": "^8.5.21", + "vimeo/psalm": "^4.13.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Inpsyde\\Modularity\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "Inpsyde GmbH", + "email": "hello@inpsyde.com", + "homepage": "https://inpsyde.com/", + "role": "Company" + }, + { + "name": "Christian Leucht", + "email": "c.leucht@inpsyde.com", + "role": "Developer" + }, + { + "name": "Pablo Kauffman", + "email": "p.kauffman@inpsyde.com", + "role": "Developer" + }, + { + "name": "Giuseppe Mazzapica", + "email": "g.mazzapica@inpsyde.com", + "role": "Developer" + } + ], + "description": "Modular PSR-11 implementation for WordPress plugins, themes or libraries.", + "support": { + "issues": "https://github.com/inpsyde/modularity/issues", + "source": "https://github.com/inpsyde/modularity/tree/1.5.1" + }, + "time": "2022-03-09T13:59:27+00:00" + }, { "name": "mollie/mollie-api-php", - "version": "v2.71.0", + "version": "v2.72.0", "source": { "type": "git", "url": "https://github.com/mollie/mollie-api-php.git", - "reference": "dff324f0621ff134fbefffa42ee511833a58578f" + "reference": "cdfb298ff61737a077554c001e936e6134e7ed8e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/dff324f0621ff134fbefffa42ee511833a58578f", - "reference": "dff324f0621ff134fbefffa42ee511833a58578f", + "url": "https://api.github.com/repos/mollie/mollie-api-php/zipball/cdfb298ff61737a077554c001e936e6134e7ed8e", + "reference": "cdfb298ff61737a077554c001e936e6134e7ed8e", "shasum": "" }, "require": { @@ -170,104 +243,37 @@ ], "support": { "issues": "https://github.com/mollie/mollie-api-php/issues", - "source": "https://github.com/mollie/mollie-api-php/tree/v2.71.0" + "source": "https://github.com/mollie/mollie-api-php/tree/v2.72.0" }, - "time": "2024-07-17T08:02:14+00:00" + "time": "2024-09-11T15:06:31+00:00" }, { - "name": "symfony/deprecation-contracts", - "version": "v2.5.3", + "name": "psr/container", + "version": "1.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "80d075412b557d41002320b96a096ca65aa2c98d" + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", - "reference": "80d075412b557d41002320b96a096ca65aa2c98d", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=5.3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" + "dev-master": "1.0.x-dev" } - ], - "time": "2023-01-24T14:02:46+00:00" - }, - { - "name": "symfony/finder", - "version": "v5.4.43", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "ae25a9145a900764158d439653d5630191155ca0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ae25a9145a900764158d439653d5630191155ca0", - "reference": "ae25a9145a900764158d439653d5630191155ca0", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php80": "^1.16" }, - "type": "library", "autoload": { "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Psr\\Container\\": "src/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -275,69 +281,52 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" } ], - "description": "Finds files and directories via an intuitive fluent interface", - "homepage": "https://symfony.com", + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.43" + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/master" }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-08-13T14:03:51+00:00" + "time": "2017-02-14T16:28:37+00:00" }, { - "name": "symfony/polyfill-php80", - "version": "v1.30.0", + "name": "psr/log", + "version": "1.1.4", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "77fa7995ac1b21ab60769b7323d600a991a90433" + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/77fa7995ac1b21ab60769b7323d600a991a90433", - "reference": "77fa7995ac1b21ab60769b7323d600a991a90433", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=5.3.0" }, "type": "library", "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "branch-alias": { + "dev-master": "1.1.x-dev" } }, "autoload": { - "files": [ - "bootstrap.php" - ], "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] + "Psr\\Log\\": "Psr/Log/" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -345,44 +334,21 @@ ], "authors": [ { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" } ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" + "log", + "psr", + "psr-3" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.30.0" + "source": "https://github.com/php-fig/log/tree/1.1.4" }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2021-05-03T11:20:27+00:00" } ], "packages-dev": [ @@ -838,26 +804,26 @@ }, { "name": "composer/pcre", - "version": "2.2.0", + "version": "2.3.1", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "0e455b78ac53637929b29d5ab5bf3c978329c1eb" + "reference": "26859a860a7f140fc08422c3cc14ad9c2a287d79" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/0e455b78ac53637929b29d5ab5bf3c978329c1eb", - "reference": "0e455b78ac53637929b29d5ab5bf3c978329c1eb", + "url": "https://api.github.com/repos/composer/pcre/zipball/26859a860a7f140fc08422c3cc14ad9c2a287d79", + "reference": "26859a860a7f140fc08422c3cc14ad9c2a287d79", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "conflict": { - "phpstan/phpstan": "<1.11.8" + "phpstan/phpstan": "<1.11.10" }, "require-dev": { - "phpstan/phpstan": "^1.11.8", + "phpstan/phpstan": "^1.11.10", "phpstan/phpstan-strict-rules": "^1.1", "phpunit/phpunit": "^8 || ^9" }, @@ -897,7 +863,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/2.2.0" + "source": "https://github.com/composer/pcre/tree/2.3.1" }, "funding": [ { @@ -913,7 +879,7 @@ "type": "tidelift" } ], - "time": "2024-07-25T09:28:32+00:00" + "time": "2024-08-27T12:02:26+00:00" }, { "name": "composer/semver", @@ -1516,79 +1482,6 @@ }, "time": "2024-03-07T12:11:10+00:00" }, - { - "name": "inpsyde/modularity", - "version": "1.5.1", - "source": { - "type": "git", - "url": "https://github.com/inpsyde/modularity.git", - "reference": "3bbff6197aabbc4df25b5f386f521bedc71aff2e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/inpsyde/modularity/zipball/3bbff6197aabbc4df25b5f386f521bedc71aff2e", - "reference": "3bbff6197aabbc4df25b5f386f521bedc71aff2e", - "shasum": "" - }, - "require": { - "ext-json": "*", - "php": ">=7.2", - "psr/container": "~1.0" - }, - "require-dev": { - "brain/monkey": "^2.6.1", - "inpsyde/php-coding-standards": "^1", - "johnpbloch/wordpress-core": ">=5.8", - "mikey179/vfsstream": "^v1.6.10", - "php-stubs/wordpress-stubs": ">=5.8@stable", - "phpunit/phpunit": "^8.5.21", - "vimeo/psalm": "^4.13.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Inpsyde\\Modularity\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0-or-later" - ], - "authors": [ - { - "name": "Inpsyde GmbH", - "email": "hello@inpsyde.com", - "homepage": "https://inpsyde.com/", - "role": "Company" - }, - { - "name": "Christian Leucht", - "email": "c.leucht@inpsyde.com", - "role": "Developer" - }, - { - "name": "Pablo Kauffman", - "email": "p.kauffman@inpsyde.com", - "role": "Developer" - }, - { - "name": "Giuseppe Mazzapica", - "email": "g.mazzapica@inpsyde.com", - "role": "Developer" - } - ], - "description": "Modular PSR-11 implementation for WordPress plugins, themes or libraries.", - "support": { - "issues": "https://github.com/inpsyde/modularity/issues", - "source": "https://github.com/inpsyde/modularity/tree/1.5.1" - }, - "time": "2022-03-09T13:59:27+00:00" - }, { "name": "inpsyde/php-coding-standards", "version": "1.0.0", @@ -1835,16 +1728,16 @@ }, { "name": "netresearch/jsonmapper", - "version": "v4.4.1", + "version": "v4.5.0", "source": { "type": "git", "url": "https://github.com/cweiske/jsonmapper.git", - "reference": "132c75c7dd83e45353ebb9c6c9f591952995bbf0" + "reference": "8e76efb98ee8b6afc54687045e1b8dba55ac76e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/132c75c7dd83e45353ebb9c6c9f591952995bbf0", - "reference": "132c75c7dd83e45353ebb9c6c9f591952995bbf0", + "url": "https://api.github.com/repos/cweiske/jsonmapper/zipball/8e76efb98ee8b6afc54687045e1b8dba55ac76e5", + "reference": "8e76efb98ee8b6afc54687045e1b8dba55ac76e5", "shasum": "" }, "require": { @@ -1880,22 +1773,22 @@ "support": { "email": "cweiske@cweiske.de", "issues": "https://github.com/cweiske/jsonmapper/issues", - "source": "https://github.com/cweiske/jsonmapper/tree/v4.4.1" + "source": "https://github.com/cweiske/jsonmapper/tree/v4.5.0" }, - "time": "2024-01-31T06:18:54+00:00" + "time": "2024-09-08T10:13:13+00:00" }, { "name": "nikic/php-parser", - "version": "v4.19.1", + "version": "v4.19.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b" + "reference": "0ed4c8949a32986043e977dbe14776c14d644c45" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4e1b88d21c69391150ace211e9eaf05810858d0b", - "reference": "4e1b88d21c69391150ace211e9eaf05810858d0b", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ed4c8949a32986043e977dbe14776c14d644c45", + "reference": "0ed4c8949a32986043e977dbe14776c14d644c45", "shasum": "" }, "require": { @@ -1936,9 +1829,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.1" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.2" }, - "time": "2024-03-17T08:10:35+00:00" + "time": "2024-09-17T19:36:00+00:00" }, { "name": "openlss/lib-array2xml", @@ -2819,109 +2712,6 @@ ], "time": "2024-07-10T11:43:00+00:00" }, - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/master" - }, - "time": "2017-02-14T16:28:37+00:00" - }, - { - "name": "psr/log", - "version": "1.1.4", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" - }, - "time": "2021-05-03T11:20:27+00:00" - }, { "name": "ptrofimov/xpmock", "version": "1.1.5", @@ -3817,16 +3607,16 @@ }, { "name": "symfony/console", - "version": "v5.4.42", + "version": "v5.4.43", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "cef62396a0477e94fc52e87a17c6e5c32e226b7f" + "reference": "e86f8554de667c16dde8aeb89a3990cfde924df9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/cef62396a0477e94fc52e87a17c6e5c32e226b7f", - "reference": "cef62396a0477e94fc52e87a17c6e5c32e226b7f", + "url": "https://api.github.com/repos/symfony/console/zipball/e86f8554de667c16dde8aeb89a3990cfde924df9", + "reference": "e86f8554de667c16dde8aeb89a3990cfde924df9", "shasum": "" }, "require": { @@ -3896,7 +3686,74 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v5.4.42" + "source": "https://github.com/symfony/console/tree/v5.4.43" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-08-13T16:31:56+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.5.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "80d075412b557d41002320b96a096ca65aa2c98d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d", + "reference": "80d075412b557d41002320b96a096ca65aa2c98d", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3" }, "funding": [ { @@ -3912,24 +3769,24 @@ "type": "tidelift" } ], - "time": "2024-07-26T12:21:55+00:00" + "time": "2023-01-24T14:02:46+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "0424dff1c58f028c451efff2045f5d92410bd540" + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/0424dff1c58f028c451efff2045f5d92410bd540", - "reference": "0424dff1c58f028c451efff2045f5d92410bd540", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638", + "reference": "a3cc8b044a6ea513310cbd48ef7333b384945638", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-ctype": "*" @@ -3975,7 +3832,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" }, "funding": [ { @@ -3991,24 +3848,24 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a" + "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/64647a7c30b2283f5d49b874d84a18fc22054b7a", - "reference": "64647a7c30b2283f5d49b874d84a18fc22054b7a", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", + "reference": "b9123926e3b7bc2f98c02ad54f6a4b02b91a8abe", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "suggest": { "ext-intl": "For best performance" @@ -4053,7 +3910,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.31.0" }, "funding": [ { @@ -4069,24 +3926,24 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb" + "reference": "3833d7255cc303546435cb650316bff708a1c75c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/a95281b0be0d9ab48050ebd988b967875cdb9fdb", - "reference": "a95281b0be0d9ab48050ebd988b967875cdb9fdb", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c", + "reference": "3833d7255cc303546435cb650316bff708a1c75c", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "suggest": { "ext-intl": "For best performance" @@ -4134,7 +3991,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0" }, "funding": [ { @@ -4150,24 +4007,24 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c" + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fd22ab50000ef01661e2a31d850ebaa297f8e03c", - "reference": "fd22ab50000ef01661e2a31d850ebaa297f8e03c", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "provide": { "ext-mbstring": "*" @@ -4214,7 +4071,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" }, "funding": [ { @@ -4230,24 +4087,24 @@ "type": "tidelift" } ], - "time": "2024-06-19T12:30:46+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/polyfill-php73", - "version": "v1.30.0", + "version": "v1.31.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1" + "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/ec444d3f3f6505bb28d11afa41e75faadebc10a1", - "reference": "ec444d3f3f6505bb28d11afa41e75faadebc10a1", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb", + "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=7.2" }, "type": "library", "extra": { @@ -4290,7 +4147,87 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.30.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" }, "funding": [ { @@ -4306,7 +4243,7 @@ "type": "tidelift" } ], - "time": "2024-05-31T15:07:36+00:00" + "time": "2024-09-09T11:45:10+00:00" }, { "name": "symfony/service-contracts", @@ -4389,16 +4326,16 @@ }, { "name": "symfony/string", - "version": "v5.4.42", + "version": "v5.4.43", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "909cec913edea162a3b2836788228ad45fcab337" + "reference": "8be1d484951ff5ca995eaf8edcbcb8b9a5888450" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/909cec913edea162a3b2836788228ad45fcab337", - "reference": "909cec913edea162a3b2836788228ad45fcab337", + "url": "https://api.github.com/repos/symfony/string/zipball/8be1d484951ff5ca995eaf8edcbcb8b9a5888450", + "reference": "8be1d484951ff5ca995eaf8edcbcb8b9a5888450", "shasum": "" }, "require": { @@ -4455,7 +4392,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v5.4.42" + "source": "https://github.com/symfony/string/tree/v5.4.43" }, "funding": [ { @@ -4471,7 +4408,7 @@ "type": "tidelift" } ], - "time": "2024-07-20T18:38:32+00:00" + "time": "2024-08-01T10:24:28+00:00" }, { "name": "theseer/tokenizer", From e2e2fbdda50e2d14e382faec4c18ca13f6e3447a Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 19 Sep 2024 09:34:08 +0200 Subject: [PATCH 3/9] Install php-scoper-wordpress-excludes --- composer.json | 3 ++- composer.lock | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 452e5498..c4d8b7ef 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "mollie/mollie-api-php": "^v2.40", "inpsyde/modularity": "^1.3.0", "psr/container": "1.0.0", - "psr/log":"^1.1.4" + "psr/log":"^1.1.4", + "sniccowp/php-scoper-wordpress-excludes": "^6.6" }, "require-dev": { "phpunit/phpunit": "^8", diff --git a/composer.lock b/composer.lock index 6e5ec773..f0ef1660 100644 --- a/composer.lock +++ b/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": "2544dbd439fe830543743298a0d463cb", + "content-hash": "eddbfc3311d3d6f88a9db7bb4bf9f629", "packages": [ { "name": "composer/ca-bundle", @@ -349,6 +349,53 @@ "source": "https://github.com/php-fig/log/tree/1.1.4" }, "time": "2021-05-03T11:20:27+00:00" + }, + { + "name": "sniccowp/php-scoper-wordpress-excludes", + "version": "6.6.0", + "source": { + "type": "git", + "url": "https://github.com/snicco/php-scoper-wordpress-excludes.git", + "reference": "56cce0bed93ec18e04519de987f7bf78af5385c3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/snicco/php-scoper-wordpress-excludes/zipball/56cce0bed93ec18e04519de987f7bf78af5385c3", + "reference": "56cce0bed93ec18e04519de987f7bf78af5385c3", + "shasum": "" + }, + "require-dev": { + "php": "^7.4", + "php-stubs/wordpress-globals": "0.2.0", + "php-stubs/wordpress-stubs": "6.6.0", + "sniccowp/php-scoper-excludes": "dev-master" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Calvin Alkan", + "email": "calvin@snicco.de" + }, + { + "name": "Marlon Alkan", + "email": "marlon@snicco.de" + } + ], + "description": "A list of all WordPress core classes, functions and constants. Meant to be used with the PHP-Scoper exclusion functionality.", + "keywords": [ + "php-scoper", + "scoping WordPress", + "wordpress" + ], + "support": { + "issues": "https://github.com/snicco/php-scoper-wordpress-excludes/issues", + "source": "https://github.com/snicco/php-scoper-wordpress-excludes/tree/6.6.0" + }, + "time": "2024-08-24T00:01:07+00:00" } ], "packages-dev": [ From 7424e875fa4c141a3e19993182f06600045fc7f4 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 19 Sep 2024 11:22:13 +0200 Subject: [PATCH 4/9] Remove hardcoded namespaces --- mollie-payments-for-woocommerce.php | 4 ++-- src/Activation/ActivationModule.php | 6 +++--- src/Assets/AssetsModule.php | 6 +++--- src/Gateway/GatewayModule.php | 13 +++++++------ src/Gateway/Voucher/VoucherModule.php | 8 ++++---- src/Log/LogModule.php | 6 +++--- src/MerchantCapture/Capture/Type/ManualCapture.php | 2 +- .../Capture/Type/StateChangeCapture.php | 2 +- src/MerchantCapture/MerchantCaptureModule.php | 8 ++++---- src/Notice/NoticeModule.php | 4 ++-- src/Payment/PaymentModule.php | 8 ++++---- src/SDK/SDKModule.php | 8 ++++---- src/Settings/SettingsModule.php | 8 ++++---- src/Shared/SharedModule.php | 8 ++++---- src/Subscription/SubscriptionModule.php | 6 +++--- src/Uninstall/UninstallModule.php | 4 ++-- uninstall.php | 4 ++-- 17 files changed, 53 insertions(+), 52 deletions(-) diff --git a/mollie-payments-for-woocommerce.php b/mollie-payments-for-woocommerce.php index 0a6bf7d8..001d6a64 100644 --- a/mollie-payments-for-woocommerce.php +++ b/mollie-payments-for-woocommerce.php @@ -21,8 +21,8 @@ namespace Mollie\WooCommerce; use Mollie\WooCommerce\MerchantCapture\MerchantCaptureModule; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Package; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Properties\PluginProperties; +use Inpsyde\Modularity\Package; +use Inpsyde\Modularity\Properties\PluginProperties; use Mollie\WooCommerce\Activation\ActivationModule; use Mollie\WooCommerce\Activation\ConstraintsChecker; use Mollie\WooCommerce\Assets\AssetsModule; diff --git a/src/Activation/ActivationModule.php b/src/Activation/ActivationModule.php index ec70f8c7..ef82ea30 100644 --- a/src/Activation/ActivationModule.php +++ b/src/Activation/ActivationModule.php @@ -7,11 +7,11 @@ namespace Mollie\WooCommerce\Activation; use Automattic\WooCommerce\Utilities\FeaturesUtil; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ExecutableModule; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; use Mollie\WooCommerce\Notice\AdminNotice; use Mollie\WooCommerce\Shared\SharedDataDictionary; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Psr\Container\ContainerInterface; class ActivationModule implements ExecutableModule { diff --git a/src/Assets/AssetsModule.php b/src/Assets/AssetsModule.php index 9cb2e361..eeb8cd88 100644 --- a/src/Assets/AssetsModule.php +++ b/src/Assets/AssetsModule.php @@ -7,15 +7,15 @@ namespace Mollie\WooCommerce\Assets; use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ExecutableModule; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; use Mollie\Api\Exceptions\ApiException; use Mollie\WooCommerce\Buttons\ApplePayButton\DataToAppleButtonScripts; use Mollie\WooCommerce\Buttons\PayPalButton\DataToPayPal; use Mollie\WooCommerce\Components\AcceptedLocaleValuesDictionary; use Mollie\WooCommerce\Settings\Settings; use Mollie\WooCommerce\Shared\Data; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Psr\Container\ContainerInterface; class AssetsModule implements ExecutableModule { diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index 0004ef09..403ff616 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -9,9 +9,9 @@ use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController; use Automattic\WooCommerce\StoreApi\Exceptions\RouteException; use DateTime; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule; +use Inpsyde\Modularity\Module\ExecutableModule; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ServiceModule; use Mollie\WooCommerce\BlockService\CheckoutBlockService; use Mollie\WooCommerce\Buttons\ApplePayButton\AppleAjaxRequests; use Mollie\WooCommerce\Buttons\ApplePayButton\ApplePayDirectHandler; @@ -41,7 +41,7 @@ use Mollie\WooCommerce\Subscription\MollieSepaRecurringGateway; use Mollie\WooCommerce\Subscription\MollieSubscriptionGateway; use Mollie\WooCommerce\PaymentMethods\Constants; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface as Logger; use WP_Post; @@ -701,8 +701,9 @@ public function buildPaymentMethod( Surcharge $surchargeService, array $apiMethod ): PaymentMethodI { - - $paymentMethodClassName = 'Mollie\\WooCommerce\\PaymentMethods\\' . ucfirst($id); + $scopedPrefix = array_shift(explode('\\', __NAMESPACE__)); + $transformedId = ucfirst($id); + $paymentMethodClassName = $scopedPrefix . '\\Mollie\\WooCommerce\\PaymentMethods\\' . $transformedId; $paymentMethod = new $paymentMethodClassName( $iconFactory, $settingsHelper, diff --git a/src/Gateway/Voucher/VoucherModule.php b/src/Gateway/Voucher/VoucherModule.php index 87002ed5..4e1eb1f8 100644 --- a/src/Gateway/Voucher/VoucherModule.php +++ b/src/Gateway/Voucher/VoucherModule.php @@ -22,11 +22,11 @@ namespace Mollie\WooCommerce\Gateway\Voucher; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule; +use Inpsyde\Modularity\Module\ExecutableModule; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ServiceModule; use Mollie\WooCommerce\PaymentMethods\Voucher; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Psr\Container\ContainerInterface; class VoucherModule implements ExecutableModule, ServiceModule { diff --git a/src/Log/LogModule.php b/src/Log/LogModule.php index 4483f692..8159f5da 100644 --- a/src/Log/LogModule.php +++ b/src/Log/LogModule.php @@ -6,9 +6,9 @@ namespace Mollie\WooCommerce\Log; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ServiceModule; +use Psr\Container\ContainerInterface; use Psr\Log\AbstractLogger; use Psr\Log\LoggerInterface as Logger; use Psr\Log\NullLogger; diff --git a/src/MerchantCapture/Capture/Type/ManualCapture.php b/src/MerchantCapture/Capture/Type/ManualCapture.php index 81a782e9..2bdefdc5 100644 --- a/src/MerchantCapture/Capture/Type/ManualCapture.php +++ b/src/MerchantCapture/Capture/Type/ManualCapture.php @@ -5,7 +5,7 @@ namespace Mollie\WooCommerce\MerchantCapture\Capture\Type; use Mollie\WooCommerce\MerchantCapture\Capture\Action\CapturePayment; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Psr\Container\ContainerInterface; class ManualCapture { diff --git a/src/MerchantCapture/Capture/Type/StateChangeCapture.php b/src/MerchantCapture/Capture/Type/StateChangeCapture.php index 1bafca2d..d50fdc22 100644 --- a/src/MerchantCapture/Capture/Type/StateChangeCapture.php +++ b/src/MerchantCapture/Capture/Type/StateChangeCapture.php @@ -7,7 +7,7 @@ use Mollie\WooCommerce\MerchantCapture\Capture\Action\CapturePayment; use Mollie\WooCommerce\MerchantCapture\Capture\Action\VoidPayment; use Mollie\WooCommerce\Shared\SharedDataDictionary; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Psr\Container\ContainerInterface; class StateChangeCapture { diff --git a/src/MerchantCapture/MerchantCaptureModule.php b/src/MerchantCapture/MerchantCaptureModule.php index 0bdca1df..52fcb80f 100644 --- a/src/MerchantCapture/MerchantCaptureModule.php +++ b/src/MerchantCapture/MerchantCaptureModule.php @@ -14,10 +14,10 @@ use Mollie\WooCommerce\SDK\Api; use Mollie\WooCommerce\Settings\Settings; use Mollie\WooCommerce\Shared\SharedDataDictionary; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Inpsyde\Modularity\Module\ExecutableModule; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ServiceModule; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface as Logger; use WC_Order; diff --git a/src/Notice/NoticeModule.php b/src/Notice/NoticeModule.php index e2cb7cc5..49861917 100644 --- a/src/Notice/NoticeModule.php +++ b/src/Notice/NoticeModule.php @@ -6,8 +6,8 @@ namespace Mollie\WooCommerce\Notice; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ServiceModule; class NoticeModule implements ServiceModule { diff --git a/src/Payment/PaymentModule.php b/src/Payment/PaymentModule.php index 31c721da..91367be2 100644 --- a/src/Payment/PaymentModule.php +++ b/src/Payment/PaymentModule.php @@ -6,9 +6,9 @@ namespace Mollie\WooCommerce\Payment; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule; +use Inpsyde\Modularity\Module\ExecutableModule; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ServiceModule; use Mollie\Api\Exceptions\ApiException; use Mollie\Api\Resources\Refund; use Mollie\WooCommerce\Gateway\MolliePaymentGateway; @@ -18,7 +18,7 @@ use Mollie\WooCommerce\Settings\Settings; use Mollie\WooCommerce\Shared\Data; use Mollie\WooCommerce\Shared\SharedDataDictionary; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface as Logger; use Psr\Log\LogLevel; use RuntimeException; diff --git a/src/SDK/SDKModule.php b/src/SDK/SDKModule.php index 4544b664..7ade0a00 100644 --- a/src/SDK/SDKModule.php +++ b/src/SDK/SDKModule.php @@ -6,15 +6,15 @@ namespace Mollie\WooCommerce\SDK; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule; +use Inpsyde\Modularity\Module\ExecutableModule; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ServiceModule; use Mollie\Api\Resources\Refund; use Mollie\WooCommerce\Gateway\AbstractGateway; use Mollie\WooCommerce\Notice\AdminNotice; use Mollie\WooCommerce\Plugin; use Mollie\WooCommerce\SDK\HttpResponse; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Psr\Container\ContainerInterface; class SDKModule implements ExecutableModule, ServiceModule { diff --git a/src/Settings/SettingsModule.php b/src/Settings/SettingsModule.php index 9dffc59c..5cac11b5 100644 --- a/src/Settings/SettingsModule.php +++ b/src/Settings/SettingsModule.php @@ -6,16 +6,16 @@ namespace Mollie\WooCommerce\Settings; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule; +use Inpsyde\Modularity\Module\ExecutableModule; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ServiceModule; use Mollie\WooCommerce\Notice\AdminNotice; use Mollie\WooCommerce\SDK\Api; use Mollie\WooCommerce\Settings\Page\MollieSettingsPage; use Mollie\WooCommerce\Shared\Data; use Mollie\WooCommerce\Shared\Status; use Mollie\WooCommerce\Uninstall\CleanDb; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface as Logger; class SettingsModule implements ServiceModule, ExecutableModule diff --git a/src/Shared/SharedModule.php b/src/Shared/SharedModule.php index 8298c565..40f62690 100644 --- a/src/Shared/SharedModule.php +++ b/src/Shared/SharedModule.php @@ -6,12 +6,12 @@ namespace Mollie\WooCommerce\Shared; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Package; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ServiceModule; +use Inpsyde\Modularity\Package; use Mollie\Api\CompatibilityChecker; use Mollie\WooCommerce\SDK\Api; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface as Logger; class SharedModule implements ServiceModule diff --git a/src/Subscription/SubscriptionModule.php b/src/Subscription/SubscriptionModule.php index 71511e28..a6ca51ff 100644 --- a/src/Subscription/SubscriptionModule.php +++ b/src/Subscription/SubscriptionModule.php @@ -7,13 +7,13 @@ namespace Mollie\WooCommerce\Subscription; use DateTime; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ExecutableModule; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; use Mollie\WooCommerce\Gateway\MolliePaymentGateway; use Mollie\WooCommerce\Settings\Settings; use Mollie\WooCommerce\Shared\Data; use Mollie\WooCommerce\Shared\SharedDataDictionary; -use Mollie\WooCommerce\Vendor\Psr\Container\ContainerInterface; +use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface as Logger; use Psr\Log\LogLevel; diff --git a/src/Uninstall/UninstallModule.php b/src/Uninstall/UninstallModule.php index d5b34309..0cf437cd 100644 --- a/src/Uninstall/UninstallModule.php +++ b/src/Uninstall/UninstallModule.php @@ -6,8 +6,8 @@ namespace Mollie\WooCommerce\Uninstall; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule; +use Inpsyde\Modularity\Module\ModuleClassNameIdTrait; +use Inpsyde\Modularity\Module\ServiceModule; use Mollie\WooCommerce\Shared\SharedDataDictionary; class UninstallModule implements ServiceModule diff --git a/uninstall.php b/uninstall.php index 4874afb8..c4f9a4e4 100644 --- a/uninstall.php +++ b/uninstall.php @@ -4,8 +4,8 @@ namespace Mollie\WooCommerce; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Package; -use Mollie\WooCommerce\Vendor\Inpsyde\Modularity\Properties\PluginProperties; +use Inpsyde\Modularity\Package; +use Inpsyde\Modularity\Properties\PluginProperties; use Mollie\WooCommerce\Uninstall\CleanDb; use Mollie\WooCommerce\Uninstall\UninstallModule; use Throwable; From 5123ba833c3d8e130ed9e19b46c31c2fa63d8280 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 19 Sep 2024 11:22:33 +0200 Subject: [PATCH 5/9] Add patcher & remove functions from scoper --- scoper.inc.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/scoper.inc.php b/scoper.inc.php index a96c6f54..60ad1478 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -43,9 +43,27 @@ return [ 'prefix' => 'Syde\\Vendor', // string|null 'finders' => $finders, // list - 'patchers' => [], // list + 'patchers' => [ + static function (string $filePath, string $prefix, string $content): string { + // + // PHP-Parser patch conditions for file targets + // + if ($filePath === 'src/Gateway/GatewayModule.php') { + return preg_replace( + "%\$class = 'Mollie\\\\WooCommerce\\\\PaymentMethod\\\\' . \$transformedId;%", + '$class = \'' . $prefix . '\\\\Humbug\\\\Format\\\\Type\\\\\' . $type;', + $content + ); + } + + return $content; + }, + ], // list 'exclude-files' => [ - 'vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php' + 'vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php', + 'inc/functions.php', + 'inc/utils.php', + 'inc/woocommerce.php' ], // list 'exclude-namespaces' => [ 'Composer', @@ -55,6 +73,9 @@ ], // list 'exclude-constants' => array_merge($wp_constants, [ 'WC_VERSION', + 'M4W_FILE', + 'M4W_PLUGIN_DIR', + 'M4W_PLUGIN_URL' ]), // list 'exclude-classes' => array_merge($wp_classes, [ 'WooCommerce', From 77000bb609ac9ae8b63fe4630733c0ddccf46394 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 19 Sep 2024 11:31:22 +0200 Subject: [PATCH 6/9] Fix typo --- scoper.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scoper.inc.php b/scoper.inc.php index 60ad1478..1f3a06f0 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -51,7 +51,7 @@ static function (string $filePath, string $prefix, string $content): string { if ($filePath === 'src/Gateway/GatewayModule.php') { return preg_replace( "%\$class = 'Mollie\\\\WooCommerce\\\\PaymentMethod\\\\' . \$transformedId;%", - '$class = \'' . $prefix . '\\\\Humbug\\\\Format\\\\Type\\\\\' . $type;', + '$class = \'' . $prefix . '\\\\Mollie\\\\WooCommerce\\\\PaymentMethod\\\\\' . $transformedId;', $content ); } From d87b83eddd3fbb0f6b47164621ebc7971a2487d1 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 19 Sep 2024 12:28:34 +0200 Subject: [PATCH 7/9] Update .distignore to include mollie sdk resources --- .distignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.distignore b/.distignore index 32ec1a62..d0c5bdb8 100644 --- a/.distignore +++ b/.distignore @@ -3,6 +3,7 @@ .git* tests/ resources/ +!vendor/mollie/mollie-api-php/Resources vendor/**/test* vendor/mollie/mollie-api-php/examples/ languages/*.po From a56e39e60bc205bdb3e4744f46f4926f02b78141 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 19 Sep 2024 12:48:22 +0200 Subject: [PATCH 8/9] Fix namespace on build payment method --- src/Gateway/GatewayModule.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index 403ff616..b141ad9a 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -691,7 +691,7 @@ public function in3FieldsMandatoryPayForOrder($order) * @param PaymentFieldsService $paymentFieldsService * @param Surcharge $surchargeService * @param array $paymentMethods - * @return PaymentMethodI + * @return PaymentMethodI | array */ public function buildPaymentMethod( string $id, @@ -700,10 +700,14 @@ public function buildPaymentMethod( PaymentFieldsService $paymentFieldsService, Surcharge $surchargeService, array $apiMethod - ): PaymentMethodI { - $scopedPrefix = array_shift(explode('\\', __NAMESPACE__)); + ) { + $namespaceParts = explode('\\', __NAMESPACE__); + if (!(count($namespaceParts) >= 2)) { + return []; + } + $scopedPrefix = $namespaceParts[0] . '\\' . $namespaceParts[1]; $transformedId = ucfirst($id); - $paymentMethodClassName = $scopedPrefix . '\\Mollie\\WooCommerce\\PaymentMethods\\' . $transformedId; + $paymentMethodClassName = $scopedPrefix . '\Mollie\WooCommerce\PaymentMethods\\' . $transformedId; $paymentMethod = new $paymentMethodClassName( $iconFactory, $settingsHelper, From 932f9c02851b8f674c1fad360a61c3deaf51997b Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Fri, 20 Sep 2024 08:32:07 +0200 Subject: [PATCH 9/9] Change scoped prefix to Mollie --- scoper.inc.php | 20 +++----------------- src/Gateway/GatewayModule.php | 7 +------ 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/scoper.inc.php b/scoper.inc.php index 1f3a06f0..ccb1eb52 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -41,24 +41,9 @@ ]; return [ - 'prefix' => 'Syde\\Vendor', // string|null + 'prefix' => 'Mollie', // string|null 'finders' => $finders, // list - 'patchers' => [ - static function (string $filePath, string $prefix, string $content): string { - // - // PHP-Parser patch conditions for file targets - // - if ($filePath === 'src/Gateway/GatewayModule.php') { - return preg_replace( - "%\$class = 'Mollie\\\\WooCommerce\\\\PaymentMethod\\\\' . \$transformedId;%", - '$class = \'' . $prefix . '\\\\Mollie\\\\WooCommerce\\\\PaymentMethod\\\\\' . $transformedId;', - $content - ); - } - - return $content; - }, - ], // list + 'patchers' => [], // list 'exclude-files' => [ 'vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php', 'inc/functions.php', @@ -70,6 +55,7 @@ static function (string $filePath, string $prefix, string $content): string { 'Automattic', '^WooCommerce', 'Inpsyde\Assets', + 'Mollie' ], // list 'exclude-constants' => array_merge($wp_constants, [ 'WC_VERSION', diff --git a/src/Gateway/GatewayModule.php b/src/Gateway/GatewayModule.php index b141ad9a..3e65f34a 100644 --- a/src/Gateway/GatewayModule.php +++ b/src/Gateway/GatewayModule.php @@ -701,13 +701,8 @@ public function buildPaymentMethod( Surcharge $surchargeService, array $apiMethod ) { - $namespaceParts = explode('\\', __NAMESPACE__); - if (!(count($namespaceParts) >= 2)) { - return []; - } - $scopedPrefix = $namespaceParts[0] . '\\' . $namespaceParts[1]; $transformedId = ucfirst($id); - $paymentMethodClassName = $scopedPrefix . '\Mollie\WooCommerce\PaymentMethods\\' . $transformedId; + $paymentMethodClassName = 'Mollie\\WooCommerce\\PaymentMethods\\' . $transformedId; $paymentMethod = new $paymentMethodClassName( $iconFactory, $settingsHelper,