From c9f413d2978915a695616499f162318077579b84 Mon Sep 17 00:00:00 2001 From: Christopher Allford Date: Wed, 18 Nov 2020 13:54:20 -0800 Subject: [PATCH] Created dummy `woocommerce/woocommerce-lib` package to contain dependencies In order to avoid problems posed by potentially including the unconverted dependencies in the root autoloader, this package will hold all dependencies that require conflict avoidance. --- .gitignore | 3 +- bin/{move-vendor-packages.sh => build-lib.sh} | 14 +- bin/composer/mozart/composer.lock | 33 +++- bin/composer/phpcs/composer.lock | 32 +++- bin/composer/phpunit/composer.lock | 50 +++++- bin/composer/wp/composer.lock | 39 ++++- composer.json | 28 ++- composer.lock | 160 ++++++++++-------- lib/README.md | 31 ++++ lib/composer.json | 51 ++++++ lib/composer.lock | 154 +++++++++++++++++ .../Argument/ArgumentResolverInterface.php | 4 +- .../Argument/ArgumentResolverTrait.php | 8 +- .../League/Container/Argument/ClassName.php | 2 +- .../Container/Argument/ClassNameInterface.php | 2 +- .../Argument/ClassNameWithOptionalValue.php | 2 +- .../League/Container/Argument/RawArgument.php | 2 +- .../Argument/RawArgumentInterface.php | 2 +- .../packages}/League/Container/Container.php | 10 +- .../Container/ContainerAwareInterface.php | 2 +- .../League/Container/ContainerAwareTrait.php | 4 +- .../Container/Definition/Definition.php | 6 +- .../Definition/DefinitionAggregate.php | 6 +- .../DefinitionAggregateInterface.php | 4 +- .../Definition/DefinitionInterface.php | 4 +- .../Exception/ContainerException.php | 2 +- .../Container/Exception/NotFoundException.php | 2 +- .../League/Container/Inflector/Inflector.php | 8 +- .../Inflector/InflectorAggregate.php | 4 +- .../Inflector/InflectorAggregateInterface.php | 4 +- .../Inflector/InflectorInterface.php | 2 +- .../League/Container/ReflectionContainer.php | 6 +- .../AbstractServiceProvider.php | 4 +- .../BootableServiceProviderInterface.php | 2 +- .../ServiceProviderAggregate.php | 8 +- .../ServiceProviderAggregateInterface.php | 4 +- .../ServiceProviderInterface.php | 4 +- phpcs.xml | 1 + .../AbstractServiceProvider.php | 7 +- .../DependencyManagement/Definition.php | 2 +- .../ExtendedContainer.php | 4 +- src/Internal/Vendor/README.md | 45 ----- src/Vendor/.gitignore | 5 + src/Vendor/README.md | 7 + .../AbstractServiceProviderTest.php | 2 +- 45 files changed, 566 insertions(+), 210 deletions(-) rename bin/{move-vendor-packages.sh => build-lib.sh} (55%) create mode 100644 lib/README.md create mode 100644 lib/composer.json create mode 100644 lib/composer.lock rename {src/Internal/Vendor => lib/packages}/League/Container/Argument/ArgumentResolverInterface.php (80%) rename {src/Internal/Vendor => lib/packages}/League/Container/Argument/ArgumentResolverTrait.php (90%) rename {src/Internal/Vendor => lib/packages}/League/Container/Argument/ClassName.php (84%) rename {src/Internal/Vendor => lib/packages}/League/Container/Argument/ClassNameInterface.php (70%) rename {src/Internal/Vendor => lib/packages}/League/Container/Argument/ClassNameWithOptionalValue.php (89%) rename {src/Internal/Vendor => lib/packages}/League/Container/Argument/RawArgument.php (84%) rename {src/Internal/Vendor => lib/packages}/League/Container/Argument/RawArgumentInterface.php (71%) rename {src/Internal/Vendor => lib/packages}/League/Container/Container.php (92%) rename {src/Internal/Vendor => lib/packages}/League/Container/ContainerAwareInterface.php (93%) rename {src/Internal/Vendor => lib/packages}/League/Container/ContainerAwareTrait.php (90%) rename {src/Internal/Vendor => lib/packages}/League/Container/Definition/Definition.php (95%) rename {src/Internal/Vendor => lib/packages}/League/Container/Definition/DefinitionAggregate.php (91%) rename {src/Internal/Vendor => lib/packages}/League/Container/Definition/DefinitionAggregateInterface.php (89%) rename {src/Internal/Vendor => lib/packages}/League/Container/Definition/DefinitionInterface.php (93%) rename {src/Internal/Vendor => lib/packages}/League/Container/Exception/ContainerException.php (68%) rename {src/Internal/Vendor => lib/packages}/League/Container/Exception/NotFoundException.php (70%) rename {src/Internal/Vendor => lib/packages}/League/Container/Inflector/Inflector.php (87%) rename {src/Internal/Vendor => lib/packages}/League/Container/Inflector/InflectorAggregate.php (87%) rename {src/Internal/Vendor => lib/packages}/League/Container/Inflector/InflectorAggregateInterface.php (77%) rename {src/Internal/Vendor => lib/packages}/League/Container/Inflector/InflectorInterface.php (94%) rename {src/Internal/Vendor => lib/packages}/League/Container/ReflectionContainer.php (91%) rename {src/Internal/Vendor => lib/packages}/League/Container/ServiceProvider/AbstractServiceProvider.php (82%) rename {src/Internal/Vendor => lib/packages}/League/Container/ServiceProvider/BootableServiceProviderInterface.php (80%) rename {src/Internal/Vendor => lib/packages}/League/Container/ServiceProvider/ServiceProviderAggregate.php (86%) rename {src/Internal/Vendor => lib/packages}/League/Container/ServiceProvider/ServiceProviderAggregateInterface.php (82%) rename {src/Internal/Vendor => lib/packages}/League/Container/ServiceProvider/ServiceProviderInterface.php (87%) delete mode 100644 src/Internal/Vendor/README.md create mode 100644 src/Vendor/.gitignore create mode 100644 src/Vendor/README.md diff --git a/.gitignore b/.gitignore index b396e534b34..c1723b0345e 100644 --- a/.gitignore +++ b/.gitignore @@ -59,7 +59,8 @@ tests/cli/vendor # Composer /vendor/ -/bin/composer/**/vendor +/bin/composer/**/vendor/ +/lib/vendor/ contributors.md contributors.html diff --git a/bin/move-vendor-packages.sh b/bin/build-lib.sh similarity index 55% rename from bin/move-vendor-packages.sh rename to bin/build-lib.sh index 40f06127800..19e6acb9cbb 100755 --- a/bin/move-vendor-packages.sh +++ b/bin/build-lib.sh @@ -20,14 +20,16 @@ if [ -z "$(php -r "echo version_compare(PHP_VERSION,'7.2','>=');")" ]; then exit 1 fi -output 6 "Moving the appropriate vendor packages to Automattic\WooCommerce\Internal\Vendor" +output 6 "Building lib package" -# Delete the entire contents of src/Internal/Vendor, except README.md -find src/Internal/Vendor/* ! -name README.md -prune -exec rm -rf {} + +# Clean the output directories to remove any files not present anymore +rm -rf lib/packages lib/classes +mkdir lib/packages lib/classes -# Move the appropriate vendor packages to src/Internal/Vendor -# (see extra/mozart for configuration) -./vendor/bin/mozart compose || exit "$?" +# Running update on the lib package will automatically run Mozart +pushd ./lib +composer update +popd output 6 "Updating autoload files" diff --git a/bin/composer/mozart/composer.lock b/bin/composer/mozart/composer.lock index 10b7d6a0ec7..cf2baa492df 100644 --- a/bin/composer/mozart/composer.lock +++ b/bin/composer/mozart/composer.lock @@ -32,6 +32,7 @@ "phpunit/phpunit": "^8.5", "squizlabs/php_codesniffer": "^3.5" }, + "default-branch": true, "bin": [ "bin/mozart" ], @@ -52,6 +53,10 @@ } ], "description": "Composes all dependencies as a package inside a WordPress plugin", + "support": { + "issues": "https://github.com/coenjacobs/mozart/issues", + "source": "https://github.com/coenjacobs/mozart/tree/master" + }, "funding": [ { "url": "https://github.com/coenjacobs", @@ -142,6 +147,10 @@ "sftp", "storage" ], + "support": { + "issues": "https://github.com/thephpleague/flysystem/issues", + "source": "https://github.com/thephpleague/flysystem/tree/1.0.70" + }, "funding": [ { "url": "https://offset.earth/frankdejonge", @@ -197,6 +206,10 @@ "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" }, { @@ -269,6 +282,9 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/console/tree/v4.4.16" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -327,6 +343,9 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v4.4.16" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -404,6 +423,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.20.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -480,6 +502,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.20.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -560,6 +585,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.20.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -636,6 +664,9 @@ "interoperability", "standards" ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v1.1.9" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -665,5 +696,5 @@ "platform-overrides": { "php": "7.2" }, - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } diff --git a/bin/composer/phpcs/composer.lock b/bin/composer/phpcs/composer.lock index 9eee228d3be..363928fcb9a 100644 --- a/bin/composer/phpcs/composer.lock +++ b/bin/composer/phpcs/composer.lock @@ -71,6 +71,10 @@ "stylecheck", "tests" ], + "support": { + "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", + "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + }, "time": "2020-06-25T14:57:39+00:00" }, { @@ -129,6 +133,10 @@ "phpcs", "standards" ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibility" + }, "time": "2019-12-27T09:44:58+00:00" }, { @@ -181,6 +189,10 @@ "polyfill", "standards" ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" + }, "time": "2019-11-04T15:17:54+00:00" }, { @@ -231,6 +243,10 @@ "standards", "wordpress" ], + "support": { + "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", + "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + }, "time": "2019-08-28T14:22:28+00:00" }, { @@ -282,6 +298,11 @@ "phpcs", "standards" ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, "time": "2020-10-23T02:01:07+00:00" }, { @@ -322,6 +343,10 @@ "woocommerce", "wordpress" ], + "support": { + "issues": "https://github.com/woocommerce/woocommerce-sniffs/issues", + "source": "https://github.com/woocommerce/woocommerce-sniffs/tree/master" + }, "time": "2020-08-06T18:23:45+00:00" }, { @@ -368,6 +393,11 @@ "standards", "wordpress" ], + "support": { + "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", + "source": "https://github.com/WordPress/WordPress-Coding-Standards", + "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" + }, "time": "2020-05-13T23:57:56+00:00" } ], @@ -381,5 +411,5 @@ "platform-overrides": { "php": "7.0" }, - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } diff --git a/bin/composer/phpunit/composer.lock b/bin/composer/phpunit/composer.lock index c39e74f0ed9..3d4ddb93b9f 100644 --- a/bin/composer/phpunit/composer.lock +++ b/bin/composer/phpunit/composer.lock @@ -332,6 +332,10 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/release/4.x" + }, "time": "2019-12-28T18:55:12+00:00" }, { @@ -444,6 +448,10 @@ "spy", "stub" ], + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/v1.10.3" + }, "time": "2020-03-05T15:02:03+00:00" }, { @@ -604,6 +612,10 @@ "keywords": [ "template" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/1.2.1" + }, "time": "2015-06-21T13:50:34+00:00" }, { @@ -908,6 +920,10 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/master" + }, "time": "2017-03-04T06:30:41+00:00" }, { @@ -1153,6 +1169,10 @@ "export", "exporter" ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/master" + }, "time": "2019-09-14T09:02:43+00:00" }, { @@ -1204,6 +1224,10 @@ "keywords": [ "global state" ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/2.0.0" + }, "time": "2017-04-27T15:39:26+00:00" }, { @@ -1251,6 +1275,10 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/master" + }, "time": "2017-08-03T12:35:26+00:00" }, { @@ -1296,6 +1324,10 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/master" + }, "time": "2017-03-29T09:07:27+00:00" }, { @@ -1349,6 +1381,10 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/master" + }, "time": "2017-03-03T06:23:57+00:00" }, { @@ -1438,6 +1474,10 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/master" + }, "time": "2016-10-03T07:35:21+00:00" }, { @@ -1557,6 +1597,10 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/master" + }, "time": "2019-06-13T22:48:21+00:00" }, { @@ -1606,6 +1650,10 @@ "check", "validate" ], + "support": { + "issues": "https://github.com/webmozart/assert/issues", + "source": "https://github.com/webmozart/assert/tree/master" + }, "time": "2020-07-08T17:02:28+00:00" } ], @@ -1619,5 +1667,5 @@ "platform-overrides": { "php": "7.0" }, - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } diff --git a/bin/composer/wp/composer.lock b/bin/composer/wp/composer.lock index 13d55f66c0a..9d610856bc0 100644 --- a/bin/composer/wp/composer.lock +++ b/bin/composer/wp/composer.lock @@ -67,6 +67,11 @@ "po", "translation" ], + "support": { + "email": "oom@oscarotero.com", + "issues": "https://github.com/oscarotero/Gettext/issues", + "source": "https://github.com/php-gettext/Gettext/tree/v4.8.2" + }, "time": "2019-12-02T10:21:14+00:00" }, { @@ -128,6 +133,10 @@ "translations", "unicode" ], + "support": { + "issues": "https://github.com/php-gettext/Languages/issues", + "source": "https://github.com/php-gettext/Languages/tree/2.6.0" + }, "time": "2019-11-13T10:30:21+00:00" }, { @@ -173,6 +182,10 @@ } ], "description": "Peast is PHP library that generates AST for JavaScript code", + "support": { + "issues": "https://github.com/mck89/peast/issues", + "source": "https://github.com/mck89/peast/tree/v1.11.0" + }, "time": "2020-10-09T15:12:13+00:00" }, { @@ -219,6 +232,10 @@ "mustache", "templating" ], + "support": { + "issues": "https://github.com/bobthecow/mustache.php/issues", + "source": "https://github.com/bobthecow/mustache.php/tree/master" + }, "time": "2019-11-23T21:40:31+00:00" }, { @@ -268,6 +285,10 @@ "iri", "sockets" ], + "support": { + "issues": "https://github.com/rmccue/Requests/issues", + "source": "https://github.com/rmccue/Requests/tree/master" + }, "time": "2016-10-13T00:11:37+00:00" }, { @@ -377,6 +398,10 @@ ], "description": "Provides internationalization tools for WordPress projects.", "homepage": "https://github.com/wp-cli/i18n-command", + "support": { + "issues": "https://github.com/wp-cli/i18n-command/issues", + "source": "https://github.com/wp-cli/i18n-command/tree/master" + }, "time": "2020-07-08T15:20:38+00:00" }, { @@ -425,6 +450,9 @@ ], "description": "A simple YAML loader/dumper class for PHP (WP-CLI fork)", "homepage": "https://github.com/mustangostang/spyc/", + "support": { + "source": "https://github.com/wp-cli/spyc/tree/autoload" + }, "time": "2017-04-25T11:26:20+00:00" }, { @@ -475,6 +503,10 @@ "cli", "console" ], + "support": { + "issues": "https://github.com/wp-cli/php-cli-tools/issues", + "source": "https://github.com/wp-cli/php-cli-tools/tree/master" + }, "time": "2018-09-04T13:28:00+00:00" }, { @@ -537,6 +569,11 @@ "cli", "wordpress" ], + "support": { + "docs": "https://make.wordpress.org/cli/handbook/", + "issues": "https://github.com/wp-cli/wp-cli/issues", + "source": "https://github.com/wp-cli/wp-cli" + }, "time": "2020-02-18T08:15:37+00:00" } ], @@ -550,5 +587,5 @@ "platform-overrides": { "php": "7.0" }, - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } diff --git a/composer.json b/composer.json index f41446b1785..96f8467e83b 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,12 @@ "license": "GPL-3.0-or-later", "prefer-stable": true, "minimum-stability": "dev", + "repositories": [ + { + "type": "path", + "url": "lib" + } + ], "require": { "php": ">=7.0", "automattic/jetpack-autoloader": "2.2.0", @@ -17,11 +23,10 @@ "woocommerce/action-scheduler": "3.1.6", "woocommerce/woocommerce-admin": "1.7.0", "woocommerce/woocommerce-blocks": "3.8.0", - "league/container": "3.3.3" + "woocommerce/woocommerce-lib": "@dev" }, "require-dev": { - "bamarni/composer-bin-plugin": "^1.4", - "league/container": "3.3.3" + "bamarni/composer-bin-plugin": "^1.4" }, "config": { "platform": { @@ -85,8 +90,8 @@ "bin": [ "echo 'bin not installed'" ], - "move-vendor-packages": [ - "sh ./bin/move-vendor-packages.sh" + "build-lib": [ + "sh ./bin/build-lib.sh" ] }, "extra": { @@ -106,19 +111,6 @@ }, "bamarni-bin": { "target-directory": "bin/composer" - }, - "mozart": { - "dep_namespace": "Automattic\\WooCommerce\\Internal\\Vendor\\", - "dep_directory": "/src/Internal/Vendor/", - "packages": [ - "league/container" - ], - "excluded_packages": [ - "psr/container" - ], - "classmap_directory": "/classmaps", - "classmap_prefix": "WOO_", - "delete_vendor_directories": true } } } diff --git a/composer.lock b/composer.lock index b77c6986064..cdba0b3a917 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": "0373a0a4d2df08885d048edab884822b", + "content-hash": "cf86e77a0dae2549e3e8060ae85f8af7", "packages": [ { "name": "automattic/jetpack-autoloader", @@ -40,6 +40,9 @@ "GPL-2.0-or-later" ], "description": "Creates a custom autoloader for a plugin or theme.", + "support": { + "source": "https://github.com/Automattic/jetpack-autoloader/tree/master" + }, "time": "2020-08-14T20:34:36+00:00" }, { @@ -71,6 +74,9 @@ "GPL-2.0-or-later" ], "description": "A wrapper for defining constants in a more testable way.", + "support": { + "source": "https://github.com/Automattic/jetpack-constants/tree/master" + }, "time": "2020-08-13T14:33:09+00:00" }, { @@ -214,78 +220,6 @@ ], "time": "2020-04-07T06:57:05+00:00" }, - { - "name": "league/container", - "version": "3.3.3", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/container.git", - "reference": "7dc67bdf89efc338e674863c0ea70a63efe4de05" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/container/zipball/7dc67bdf89efc338e674863c0ea70a63efe4de05", - "reference": "7dc67bdf89efc338e674863c0ea70a63efe4de05", - "shasum": "" - }, - "require": { - "php": "^7.0 || ^8.0", - "psr/container": "^1.0" - }, - "provide": { - "psr/container-implementation": "^1.0" - }, - "replace": { - "orno/di": "~2.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.0", - "squizlabs/php_codesniffer": "^3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-3.x": "3.x-dev", - "dev-2.x": "2.x-dev", - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Container\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Phil Bennett", - "email": "philipobenito@gmail.com", - "homepage": "http://www.philipobenito.com", - "role": "Developer" - } - ], - "description": "A fast and intuitive dependency injection container.", - "homepage": "https://github.com/thephpleague/container", - "keywords": [ - "container", - "dependency", - "di", - "injection", - "league", - "provider", - "service" - ], - "funding": [ - { - "url": "https://github.com/philipobenito", - "type": "github" - } - ], - "time": "2020-09-28T13:38:44+00:00" - }, { "name": "maxmind-db/reader", "version": "v1.6.0", @@ -344,6 +278,10 @@ "geolocation", "maxmind" ], + "support": { + "issues": "https://github.com/maxmind/MaxMind-DB-Reader-php/issues", + "source": "https://github.com/maxmind/MaxMind-DB-Reader-php/tree/v1.6.0" + }, "time": "2019-12-19T22:59:03+00:00" }, { @@ -418,6 +356,10 @@ "email", "pre-processing" ], + "support": { + "issues": "https://github.com/MyIntervals/emogrifier/issues", + "source": "https://github.com/MyIntervals/emogrifier" + }, "time": "2019-12-26T19:37:31+00:00" }, { @@ -467,6 +409,10 @@ "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" }, { @@ -558,6 +504,10 @@ ], "description": "Action Scheduler for WordPress and WooCommerce", "homepage": "https://actionscheduler.org/", + "support": { + "issues": "https://github.com/woocommerce/action-scheduler/issues", + "source": "https://github.com/woocommerce/action-scheduler/tree/master" + }, "time": "2020-05-12T16:22:33+00:00" }, { @@ -659,6 +609,60 @@ "source": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/v3.8.0" }, "time": "2020-11-10T15:07:11+00:00" + }, + { + "name": "woocommerce/woocommerce-lib", + "version": "dev-use-mozart-to-renamespace-dependencies", + "dist": { + "type": "path", + "url": "lib", + "reference": "d9d4733f0ed94289ad50fdf98cb4bc028384f482" + }, + "require": { + "php": ">=7.0", + "psr/container": "^1.0" + }, + "require-dev": { + "league/container": "3.3.3" + }, + "type": "library", + "extra": { + "mozart": { + "dep_namespace": "Automattic\\WooCommerce\\Vendor\\", + "dep_directory": "/packages/", + "packages": [ + "league/container" + ], + "excluded_packages": [ + "psr/container" + ], + "classmap_directory": "/classes/", + "classmap_prefix": "WC_", + "delete_vendor_directories": false + } + }, + "autoload": { + "psr-4": { + "Automattic\\WooCommerce\\Vendor\\": "packages/" + }, + "psr-0": { + "Automattic\\WooCommerce\\Vendor\\": "packages/" + } + }, + "scripts": { + "post-install-cmd": [ + "\"../vendor/bin/mozart\" compose", + "composer dump-autoload" + ], + "post-update-cmd": [ + "\"../vendor/bin/mozart\" compose", + "composer dump-autoload" + ] + }, + "description": "A package for hiding re-namespaced dependencies and executing them", + "transport-options": { + "relative": true + } } ], "packages-dev": [ @@ -706,12 +710,18 @@ "isolation", "tool" ], + "support": { + "issues": "https://github.com/bamarni/composer-bin-plugin/issues", + "source": "https://github.com/bamarni/composer-bin-plugin/tree/master" + }, "time": "2020-05-03T08:27:20+00:00" } ], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": { + "woocommerce/woocommerce-lib": 20 + }, "prefer-stable": true, "prefer-lowest": false, "platform": { @@ -721,5 +731,5 @@ "platform-overrides": { "php": "7.0" }, - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } diff --git a/lib/README.md b/lib/README.md new file mode 100644 index 00000000000..543b5e4bd96 --- /dev/null +++ b/lib/README.md @@ -0,0 +1,31 @@ +## WooCommerce Lib Directory + +This directory contains a dummy package responsible for managing WooCommerce dependencies that require conflict avoidance. +The contents of the `packages` and `classes` directories get automatically generated by `composer install` and `composer update`. + +This allows us to prefix namespaces and classmap classes to avoid conflicts with plugins that include the same package. +All namespaces are prefixed with `Automattic\WooCommerce\Vendor` and classmap classes prefixed with `WC_Vendor_`. + +**_Do not_ make direct changes in the files contained in `packages` or `classes`! Any changes will be lost!** + +### Adding Packages + +In order to avoid including the original dependencies in the root autoloader we must utilize `require-dev` for them. +Composer treats `require` dependencies as transitive while `require-dev` dependencies get ignored by consumers. + +1. Add package to `require-dev` section of `composer.json` +2. Add package slug to `extra/mozart/packages` section of `composer.json` +3. Run `composer run-script build-lib` from the root directory (You should now see the package in `packages/VendorName/PackageName` or `classes`) + +### Updating Packages + +Updating a package is as easy as changing the version in `composer.json` and then running `composer run-script build-lib` from the root directory. + +### Ignoring Packages + +If you would like to add a package which does not undergo conflict avoidance you must take steps to ensure it appears in +the root autoloader. + +1. Add package to `require` instead of `require-dev` (This allows it to be pulled transitively) +2. Add package slug to `extra/mozart/excluded-packages` section of `composer.json` +3. Run `composer run-script build-lib` from the root directory (You **should not** see the package in `packages/VendorName/PackageName` or `classes`) diff --git a/lib/composer.json b/lib/composer.json new file mode 100644 index 00000000000..2970eb74f92 --- /dev/null +++ b/lib/composer.json @@ -0,0 +1,51 @@ +{ + "name": "woocommerce/woocommerce-lib", + "description": "A package for hiding re-namespaced dependencies and executing them", + "prefer-stable": true, + "minimum-stability": "dev", + "require": { + "php": ">=7.0", + "psr/container": "^1.0" + }, + "require-dev": { + "league/container": "3.3.3" + }, + "autoload": { + "psr-4": { + "Automattic\\WooCommerce\\Vendor\\": "packages/" + }, + "psr-0": { + "Automattic\\WooCommerce\\Vendor\\": "packages/" + } + }, + "config": { + "platform": { + "php": "7.0" + } + }, + "scripts": { + "post-install-cmd": [ + "\"../vendor/bin/mozart\" compose", + "composer dump-autoload" + ], + "post-update-cmd": [ + "\"../vendor/bin/mozart\" compose", + "composer dump-autoload" + ] + }, + "extra": { + "mozart": { + "dep_namespace": "Automattic\\WooCommerce\\Vendor\\", + "dep_directory": "/packages/", + "packages": [ + "league/container" + ], + "excluded_packages": [ + "psr/container" + ], + "classmap_directory": "/classes/", + "classmap_prefix": "WC_Vendor_", + "delete_vendor_directories": false + } + } +} diff --git a/lib/composer.lock b/lib/composer.lock new file mode 100644 index 00000000000..f24c69c33ed --- /dev/null +++ b/lib/composer.lock @@ -0,0 +1,154 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "998898140bfcf00b7d3a9b793ecfba72", + "packages": [ + { + "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" + } + ], + "packages-dev": [ + { + "name": "league/container", + "version": "3.3.3", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/container.git", + "reference": "7dc67bdf89efc338e674863c0ea70a63efe4de05" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/container/zipball/7dc67bdf89efc338e674863c0ea70a63efe4de05", + "reference": "7dc67bdf89efc338e674863c0ea70a63efe4de05", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/container": "^1.0" + }, + "provide": { + "psr/container-implementation": "^1.0" + }, + "replace": { + "orno/di": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0", + "squizlabs/php_codesniffer": "^3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-3.x": "3.x-dev", + "dev-2.x": "2.x-dev", + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Container\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Phil Bennett", + "email": "philipobenito@gmail.com", + "homepage": "http://www.philipobenito.com", + "role": "Developer" + } + ], + "description": "A fast and intuitive dependency injection container.", + "homepage": "https://github.com/thephpleague/container", + "keywords": [ + "container", + "dependency", + "di", + "injection", + "league", + "provider", + "service" + ], + "support": { + "issues": "https://github.com/thephpleague/container/issues", + "source": "https://github.com/thephpleague/container/tree/3.3.3" + }, + "funding": [ + { + "url": "https://github.com/philipobenito", + "type": "github" + } + ], + "time": "2020-09-28T13:38:44+00:00" + } + ], + "aliases": [], + "minimum-stability": "dev", + "stability-flags": [], + "prefer-stable": true, + "prefer-lowest": false, + "platform": { + "php": ">=7.0" + }, + "platform-dev": [], + "platform-overrides": { + "php": "7.0" + }, + "plugin-api-version": "2.0.0" +} diff --git a/src/Internal/Vendor/League/Container/Argument/ArgumentResolverInterface.php b/lib/packages/League/Container/Argument/ArgumentResolverInterface.php similarity index 80% rename from src/Internal/Vendor/League/Container/Argument/ArgumentResolverInterface.php rename to lib/packages/League/Container/Argument/ArgumentResolverInterface.php index 82744c31f91..9c7393f6578 100644 --- a/src/Internal/Vendor/League/Container/Argument/ArgumentResolverInterface.php +++ b/lib/packages/League/Container/Argument/ArgumentResolverInterface.php @@ -1,8 +1,8 @@ includes/wc-deprecated-functions.php */node_modules/* */vendor/* + lib/ diff --git a/src/Internal/DependencyManagement/AbstractServiceProvider.php b/src/Internal/DependencyManagement/AbstractServiceProvider.php index 128ceaa9e79..bc35e90b37c 100644 --- a/src/Internal/DependencyManagement/AbstractServiceProvider.php +++ b/src/Internal/DependencyManagement/AbstractServiceProvider.php @@ -5,8 +5,9 @@ namespace Automattic\WooCommerce\Internal\DependencyManagement; -use Automattic\WooCommerce\Internal\Vendor\League\Container\Argument\RawArgument; -use Automattic\WooCommerce\Internal\Vendor\League\Container\Definition\DefinitionInterface; +use Automattic\WooCommerce\Vendor\League\Container\Argument\RawArgument; +use Automattic\WooCommerce\Vendor\League\Container\Definition\DefinitionInterface; +use Automattic\WooCommerce\Vendor\League\Container\ServiceProvider\AbstractServiceProvider as BaseServiceProvider; /** * Base class for the service providers used to register classes in the container. @@ -18,7 +19,7 @@ use Automattic\WooCommerce\Internal\Vendor\League\Container\Definition\Definitio * - The `share_with_auto_arguments` method, sibling of the above. * - Convenience `add` and `share` methods that are just proxies for the same methods in `$this->getContainer()`. */ -abstract class AbstractServiceProvider extends \Automattic\WooCommerce\Internal\Vendor\League\Container\ServiceProvider\AbstractServiceProvider { +abstract class AbstractServiceProvider extends BaseServiceProvider { /** * Register a class in the container and use reflection to guess the injection method arguments. diff --git a/src/Internal/DependencyManagement/Definition.php b/src/Internal/DependencyManagement/Definition.php index b4248fd49c1..5ed07283749 100644 --- a/src/Internal/DependencyManagement/Definition.php +++ b/src/Internal/DependencyManagement/Definition.php @@ -5,7 +5,7 @@ namespace Automattic\WooCommerce\Internal\DependencyManagement; -use Automattic\WooCommerce\Internal\Vendor\League\Container\Definition\Definition as BaseDefinition; +use Automattic\WooCommerce\Vendor\League\Container\Definition\Definition as BaseDefinition; /** * An extension of the definition class that replaces constructor injection with method injection. diff --git a/src/Internal/DependencyManagement/ExtendedContainer.php b/src/Internal/DependencyManagement/ExtendedContainer.php index 59bd25dee87..a4e084cf76a 100644 --- a/src/Internal/DependencyManagement/ExtendedContainer.php +++ b/src/Internal/DependencyManagement/ExtendedContainer.php @@ -6,8 +6,8 @@ namespace Automattic\WooCommerce\Internal\DependencyManagement; use Automattic\WooCommerce\Utilities\StringUtil; -use Automattic\WooCommerce\Internal\Vendor\League\Container\Container as BaseContainer; -use Automattic\WooCommerce\Internal\Vendor\League\Container\Definition\DefinitionInterface; +use Automattic\WooCommerce\Vendor\League\Container\Container as BaseContainer; +use Automattic\WooCommerce\Vendor\League\Container\Definition\DefinitionInterface; /** * This class extends the original League's Container object by adding some functionality diff --git a/src/Internal/Vendor/README.md b/src/Internal/Vendor/README.md deleted file mode 100644 index 107994346a0..00000000000 --- a/src/Internal/Vendor/README.md +++ /dev/null @@ -1,45 +0,0 @@ -## Vendor files directory - -The contents of this directory are automatically generated by moving some of the packages in the `vendor` directory and prefixing the namespace of their classes with `Automattic\WooCommerce\Internal\Vendor`, right after `composer install/update` finishes. This is done to prevent conflicts with plugins using the same packages. - -**Do no** make manual changes in the files here. Such changes will be lost the next time the contents are regenerated. - -### Registering packages to be moved - -If you want to register a vendor package for being moved to the `Automattic\WooCommerce\Internal\Vendor` namespace in order to avoid possible namespace conflicts, follow these steps: - -1. Add the package to the `require-dev` section in `composer.json`. If the package was already listed in `require`, remove it. - -2. Add the package to the `extra/mozart/packages` section in `composer.json` too, note that this time you add only the package slug (not the version). - -3. Run `composer update`. - -4. Run `composer run move-vendor-packages`. - -5. Notice that a new folder `VendorName/PackageName` has been added to `src/Internal/Vendor`. Add it to source control. - -6. All the namespaces in the moved code will have been prefixed with `Automattic\WooCommerce\Internal\Vendor`, so if you already had code that made use of the package, you'll need to adjust it accordingly. - -The `composer run move-vendor-packages` command uses the [coenjacobs/mozart](https://github.com/coenjacobs/mozart) package, which requires PHP 7.2 or newer. - -### Updating packages - -If you want to update any of the moved packages to a new version, repeat steps 3 to 5 above. - -### Preventing a dependency from being moved - -If you want to prevent a package dependency from being moved and thus re-namespaced (for example, we use a moved `league/container` package but it has a dependency on `psr/container` which we don't want to be moved) you need to follow these additional steps after 2 above: - -2.1. Add the dependency to the `require` section in `composer.json`. Yes, this time it's `require`, not `require-dev`. - -2.2. Add the dependency to the `extra/mozart/excluded-packages` section in `composer.json` too (again, the slug only). - -### Why adding the packages to be moved to require-dev? - -Once a package has been moved it's no longer needed in the `vendor` directory, so we don't want it to be there when we build WooCommerce into a zip file (we want that zip file to be as small as possible). - -Fortunately, the `npm run build` command executes `composer install --no-dev` before generating the zip file. Therefore, by adding the package to `require-dev` we make sure that the package will not be present in the `vendor` directory in the generated zip. - -The package will still be in `vendor` when you run `composer update/install` in your development environment, but you are free to just ignore it. Note that `composer run move-vendor-packages` will effectively remove the package from `vendor`, but that's not a command you will normally need to run. - - diff --git a/src/Vendor/.gitignore b/src/Vendor/.gitignore new file mode 100644 index 00000000000..ef7b2901fa6 --- /dev/null +++ b/src/Vendor/.gitignore @@ -0,0 +1,5 @@ +# Prevent anyone from accidentally adding code to these directories. +# This will break any PRs that do, revealing ths mistake they made. +README.md +!.gitignore +!README.md diff --git a/src/Vendor/README.md b/src/Vendor/README.md new file mode 100644 index 00000000000..ae39d3e4e8b --- /dev/null +++ b/src/Vendor/README.md @@ -0,0 +1,7 @@ +# WARNING + +The namespace of this folder belongs to our dummy [lib package](./../lib/README.md) to manage conflict avoidance. +No files should be added here! + +These are **internal** dependencies and **should not** be considered backwards compatible! Developers should not +use these files outside of WooCommerce Core as they are subject to change. diff --git a/tests/php/src/Internal/DependencyManagement/AbstractServiceProviderTest.php b/tests/php/src/Internal/DependencyManagement/AbstractServiceProviderTest.php index acc6ba81b83..beaa70dcef8 100644 --- a/tests/php/src/Internal/DependencyManagement/AbstractServiceProviderTest.php +++ b/tests/php/src/Internal/DependencyManagement/AbstractServiceProviderTest.php @@ -15,7 +15,7 @@ use Automattic\WooCommerce\Tests\Internal\DependencyManagement\ExampleClasses\Cl use Automattic\WooCommerce\Tests\Internal\DependencyManagement\ExampleClasses\ClassWithPrivateInjectionMethod; use Automattic\WooCommerce\Tests\Internal\DependencyManagement\ExampleClasses\ClassWithScalarInjectionMethodArgument; use Automattic\WooCommerce\Tests\Internal\DependencyManagement\ExampleClasses\DependencyClass; -use Automattic\WooCommerce\Internal\Vendor\League\Container\Definition\DefinitionInterface; +use Automattic\WooCommerce\Vendor\League\Container\Definition\DefinitionInterface; /** * Tests for AbstractServiceProvider.