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.
1. Since our code style dictates that these be `final` methods, we shouldn't be concerned about overlap.
2. There is precedent for `init` methods as requirements before using class instances.
- The `Container` class now implements `Psr\Container\ContainerInterface`
(and registers itself as such), holding a private instance of the
real container. This way it's a read-only container from the point
of view of plugins (which should use their own containers, but
can still use this to get WooCommerce classes).
- All registrations are now done in the `Container` constructor via
service providers.
- The container instance is now held in a global variable, set in
`woocommerce.php`
- Added the `wc_get_container` function for old code.
- Added the `AbstractServiceProvider` class, which inherits with the
corresponding League's class and adds some utility methods,
most notably `add/shareWithAutoArguments`.
- Added the `ActionsProxy` and `LegacyProxy` classes, they are
registered via a dedicated service provider.
- `WC_Queue_Interface` is no longer resolvable via the container
(which is for classes inside `src` only).
- All the method names in the new classes have the format `fooBarFizz`
to be PSR4 compliant, so the MethodNameInvalid error has been
disabled in phpcs.xml for the `src` directory.
- Introduced the `@public` annotation for public API classes
(classes that plugins can use and whose backwards compatibility
we guarantee), applied to `ActionsProxy` and to `LegacyProxy` for now.
- Removed the hack for the autoloader as now it doesn't work anyway.
For the changes in this branch to work, now WP_DEBUG must be false.
The testing tools (only the code hacker at this time) have been moved
from 'src' to 'tests/Tools', since many opcode cache plugins
load the whole src folder in production.
Also, an extra autoloader is set in the tests bootstrap so that
the 'tests/Tools' directory corresponds, using PSR4, to the
'Automattic\WooCommerce\Testing\Tools' namespace.
This commit implements the following changes to PHPCS execution via its configuration file:
- Show progress while it is running
- Improves performance by checking up to 8 files simultaneously
- Display only the relevant bit of filepaths when showing error and warnings
Commit d6bd82865c removed apigen from
WooCommerce core repository as we are moving it to its own repository (https://github.com/woocommerce/woocommerce-api-docs). This
commit removes the apigen from configuration files. In most cases, it is
just removing the apigen directory from the exclude list of things like
PHPCS and Code Climate.
- Now wp-coding-standards/wpcs and wimg/php-compatibility are dependencies of WooCommerce Sniffs.
- Updated wp-coding-standards/wpcs to 1.1.
- Updated wimg/php-compatibility to 9.0.
Contrary to the rest of the WC codebase, WC CLI commands require PHP >= 5.5 and use anonymous functions. This commit excludes the PHPCombatibility rule for anonymous functions (PHPCompatibility.PHP.NewClosure.Found) when PHPCS is checking the `includes/cli` directory.
WooCommerce CLI commands use array_column() which was added in PHP 5.5. Since this was not noticed until now it is probably not worth changing and making the code compatible with PHP < 5.5.