woocommerce/src
Nestor Soriano 064ae558ab Changes in the overall organization of the dependency injection:
- 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.
2020-07-24 09:23:01 +02:00
..
Admin Added handling to prevent namespace conflicts with included packages 2020-04-28 14:04:00 -07:00
Blocks Added handling to prevent namespace conflicts with included packages 2020-04-28 14:04:00 -07:00
Checkout/Helpers Removed type hints. 2020-07-06 15:36:33 +02:00
Internal/WCCom Add unit tests. 2020-07-15 15:27:34 +05:30
Tools Changes in the overall organization of the dependency injection: 2020-07-24 09:23:01 +02:00
Autoloader.php Changes in the overall organization of the dependency injection: 2020-07-24 09:23:01 +02:00
Container.php Changes in the overall organization of the dependency injection: 2020-07-24 09:23:01 +02:00
Packages.php change the namespace of the WC Admin Package class 2020-02-24 22:56:32 -04:00
README.md Updated the minimum PHP version to 7.0 2020-04-06 17:07:33 -07:00

README.md

WooCommerce src files

This directory is home to new WooCommerce class files under the \Automattic\WooCommerce\ namespace using PSR-4 file naming. This is to take full advantage of autoloading.

Currently, these classes have a PHP 7.0 requirement. No required core classes will be added here until this PHP version is enforced. If running an older version of PHP, these class files will not be used.

Installing Composer

Composer is used to generate autoload class-maps for the files here. The stable release of WooCommerce comes with the autoloader, however, if you're running a development version you'll need to use Composer.

If you don't have Composer installed, go and check how to install Composer and then continue here.

Installing packages

To install the packages WooCommerce requires, from the main directory run:

composer install

To update packages run:

composer update

If you add a class to WooCommerce and want to ensure it's included in the autoloader class-maps, run:

composer dump-autoload

Using classes

To use something a namespaced class you have to declare it at the top of the file before any other instruction, and then use it in the code. For example:

use Automattic\WooCommerce\TestClass;

// other code...

$test_class = new TestClass();

If you need to rule out conflicts, you can alias it:

use Automattic\WooCommerce\TestClass as Test_Class_Alias;

// other code...

$test_class = new Test_Class_Alias();