From 9283910e115b2df21f11b1d9d69d7601b03cae89 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 20 Jun 2019 13:37:59 +0100 Subject: [PATCH] Test version without custom autoloader and allow core to generate this after install --- .gitattributes | 1 - classmap.php | 104 --------------------------------------------- composer.json | 20 ++------- init.php | 9 ++-- src/Autoloader.php | 82 ----------------------------------- 5 files changed, 7 insertions(+), 209 deletions(-) delete mode 100644 classmap.php delete mode 100644 src/Autoloader.php diff --git a/.gitattributes b/.gitattributes index 51aa9279117..61739dd0a85 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,4 @@ /.* export-ignore -classmap.php.bak export-ignore phpcs.xml export-ignore phpunit.* export-ignore unit-tests export-ignore diff --git a/classmap.php b/classmap.php deleted file mode 100644 index 1120d34c766..00000000000 --- a/classmap.php +++ /dev/null @@ -1,104 +0,0 @@ - $baseDir . '/src/Controllers/Version3/class-wc-rest-crud-controller.php', - 'WC_REST_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-controller.php', - 'WC_REST_Coupons_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-coupons-controller.php', - 'WC_REST_Coupons_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-coupons-v1-controller.php', - 'WC_REST_Coupons_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-coupons-v2-controller.php', - 'WC_REST_Customer_Downloads_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-customer-downloads-controller.php', - 'WC_REST_Customer_Downloads_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-customer-downloads-v1-controller.php', - 'WC_REST_Customer_Downloads_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-customer-downloads-v2-controller.php', - 'WC_REST_Customers_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-customers-controller.php', - 'WC_REST_Customers_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-customers-v1-controller.php', - 'WC_REST_Customers_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-customers-v2-controller.php', - 'WC_REST_Data_Continents_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-data-continents-controller.php', - 'WC_REST_Data_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-data-controller.php', - 'WC_REST_Data_Countries_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-data-countries-controller.php', - 'WC_REST_Data_Currencies_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-data-currencies-controller.php', - 'WC_REST_Network_Orders_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-network-orders-controller.php', - 'WC_REST_Network_Orders_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-network-orders-v2-controller.php', - 'WC_REST_Order_Notes_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-order-notes-controller.php', - 'WC_REST_Order_Notes_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-order-notes-v1-controller.php', - 'WC_REST_Order_Notes_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-order-notes-v2-controller.php', - 'WC_REST_Order_Refunds_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-order-refunds-controller.php', - 'WC_REST_Order_Refunds_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php', - 'WC_REST_Order_Refunds_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php', - 'WC_REST_Orders_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-orders-controller.php', - 'WC_REST_Orders_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-orders-v1-controller.php', - 'WC_REST_Orders_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-orders-v2-controller.php', - 'WC_REST_Payment_Gateways_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-payment-gateways-controller.php', - 'WC_REST_Payment_Gateways_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-payment-gateways-v2-controller.php', - 'WC_REST_Posts_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-posts-controller.php', - 'WC_REST_Product_Attribute_Terms_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-product-attribute-terms-controller.php', - 'WC_REST_Product_Attribute_Terms_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-product-attribute-terms-v1-controller.php', - 'WC_REST_Product_Attribute_Terms_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-product-attribute-terms-v2-controller.php', - 'WC_REST_Product_Attributes_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-product-attributes-controller.php', - 'WC_REST_Product_Attributes_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-product-attributes-v1-controller.php', - 'WC_REST_Product_Attributes_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-product-attributes-v2-controller.php', - 'WC_REST_Product_Categories_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-product-categories-controller.php', - 'WC_REST_Product_Categories_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-product-categories-v1-controller.php', - 'WC_REST_Product_Categories_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-product-categories-v2-controller.php', - 'WC_REST_Product_Reviews_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-product-reviews-controller.php', - 'WC_REST_Product_Reviews_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-product-reviews-v1-controller.php', - 'WC_REST_Product_Reviews_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-product-reviews-v2-controller.php', - 'WC_REST_Product_Shipping_Classes_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-product-shipping-classes-controller.php', - 'WC_REST_Product_Shipping_Classes_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-product-shipping-classes-v1-controller.php', - 'WC_REST_Product_Shipping_Classes_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-product-shipping-classes-v2-controller.php', - 'WC_REST_Product_Tags_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-product-tags-controller.php', - 'WC_REST_Product_Tags_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-product-tags-v1-controller.php', - 'WC_REST_Product_Tags_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-product-tags-v2-controller.php', - 'WC_REST_Product_Variations_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-product-variations-controller.php', - 'WC_REST_Product_Variations_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-product-variations-v2-controller.php', - 'WC_REST_Products_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-products-controller.php', - 'WC_REST_Products_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-products-v1-controller.php', - 'WC_REST_Products_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-products-v2-controller.php', - 'WC_REST_Report_Coupons_Totals_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-report-coupons-totals-controller.php', - 'WC_REST_Report_Customers_Totals_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-report-customers-totals-controller.php', - 'WC_REST_Report_Orders_Totals_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-report-orders-totals-controller.php', - 'WC_REST_Report_Products_Totals_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-report-products-totals-controller.php', - 'WC_REST_Report_Reviews_Totals_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-report-reviews-totals-controller.php', - 'WC_REST_Report_Sales_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-report-sales-controller.php', - 'WC_REST_Report_Sales_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-report-sales-v1-controller.php', - 'WC_REST_Report_Sales_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-report-sales-v2-controller.php', - 'WC_REST_Report_Top_Sellers_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-report-top-sellers-controller.php', - 'WC_REST_Report_Top_Sellers_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-report-top-sellers-v1-controller.php', - 'WC_REST_Report_Top_Sellers_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-report-top-sellers-v2-controller.php', - 'WC_REST_Reports_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-reports-controller.php', - 'WC_REST_Reports_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-reports-v1-controller.php', - 'WC_REST_Reports_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-reports-v2-controller.php', - 'WC_REST_Setting_Options_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-setting-options-controller.php', - 'WC_REST_Setting_Options_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-setting-options-v2-controller.php', - 'WC_REST_Settings_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-settings-controller.php', - 'WC_REST_Settings_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-settings-v2-controller.php', - 'WC_REST_Shipping_Methods_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-shipping-methods-controller.php', - 'WC_REST_Shipping_Methods_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-shipping-methods-v2-controller.php', - 'WC_REST_Shipping_Zone_Locations_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-shipping-zone-locations-controller.php', - 'WC_REST_Shipping_Zone_Locations_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-shipping-zone-locations-v2-controller.php', - 'WC_REST_Shipping_Zone_Methods_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-shipping-zone-methods-controller.php', - 'WC_REST_Shipping_Zone_Methods_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-shipping-zone-methods-v2-controller.php', - 'WC_REST_Shipping_Zones_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-shipping-zones-controller.php', - 'WC_REST_Shipping_Zones_Controller_Base' => $baseDir . '/src/Controllers/Version3/class-wc-rest-shipping-zones-controller-base.php', - 'WC_REST_Shipping_Zones_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-shipping-zones-v2-controller.php', - 'WC_REST_System_Status_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-system-status-controller.php', - 'WC_REST_System_Status_Tools_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-system-status-tools-controller.php', - 'WC_REST_System_Status_Tools_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-system-status-tools-v2-controller.php', - 'WC_REST_System_Status_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-system-status-v2-controller.php', - 'WC_REST_Tax_Classes_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-tax-classes-controller.php', - 'WC_REST_Tax_Classes_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-tax-classes-v1-controller.php', - 'WC_REST_Tax_Classes_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-tax-classes-v2-controller.php', - 'WC_REST_Taxes_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-taxes-controller.php', - 'WC_REST_Taxes_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-taxes-v1-controller.php', - 'WC_REST_Taxes_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-taxes-v2-controller.php', - 'WC_REST_Terms_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-terms-controller.php', - 'WC_REST_Webhook_Deliveries_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-webhook-deliveries-v1-controller.php', - 'WC_REST_Webhook_Deliveries_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-webhook-deliveries-v2-controller.php', - 'WC_REST_Webhooks_Controller' => $baseDir . '/src/Controllers/Version3/class-wc-rest-webhooks-controller.php', - 'WC_REST_Webhooks_V1_Controller' => $baseDir . '/src/Controllers/Version1/class-wc-rest-webhooks-v1-controller.php', - 'WC_REST_Webhooks_V2_Controller' => $baseDir . '/src/Controllers/Version2/class-wc-rest-webhooks-v2-controller.php', -); diff --git a/composer.json b/composer.json index 83275842339..1d95ffbf90f 100644 --- a/composer.json +++ b/composer.json @@ -8,8 +8,7 @@ "minimum-stability": "dev", "require-dev": { "phpunit/phpunit": "6.5.14", - "woocommerce/woocommerce-sniffs": "0.0.6", - "slowprog/composer-copy-file": "~0.3" + "woocommerce/woocommerce-sniffs": "0.0.6" }, "scripts": { "post-install-cmd": [ @@ -17,12 +16,6 @@ ], "post-update-cmd": [ "composer dump-autoload" - ], - "pre-autoload-dump": [ - "composer dump-autoload --no-dev --no-scripts", - "SlowProg\\CopyFile\\ScriptHandler::copy", - "sed -i.bak -e 's/\\$baseDir = dirname(\\$vendorDir)/\\$baseDir = __DIR__/g' classmap.php", - "rm classmap.php.bak" ] }, "autoload": { @@ -30,14 +23,9 @@ "src/Controllers/Version1", "src/Controllers/Version2", "src/Controllers/Version3" - ] - }, - "extra": { - "copy-file": { - "vendor/composer/autoload_classmap.php": "classmap.php" - }, - "copy-file-dev": { - "vendor/composer/autoload_classmap.php": "classmap.php" + ], + "psr-4": { + "WooCommerce\\RestApi\\": "src/" } } } diff --git a/init.php b/init.php index 76f449f9bea..63e89eeb4ca 100644 --- a/init.php +++ b/init.php @@ -6,12 +6,9 @@ */ return function() { - if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { - require __DIR__ . '/vendor/autoload.php'; - } else { - require __DIR__ . '/src/Autoloader.php'; - $classmap = require 'classmap.php'; - \WooCommerce\RestApi\Autoloader::register( $classmap ); + if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) ) { + return; } + require __DIR__ . '/vendor/autoload.php'; \WooCommerce\RestApi\Server::instance()->init(); }; diff --git a/src/Autoloader.php b/src/Autoloader.php deleted file mode 100644 index 805b072ebbb..00000000000 --- a/src/Autoloader.php +++ /dev/null @@ -1,82 +0,0 @@ -