Use Composer modules and convert modules to PSR-4

PSR-4 is much more robust and predictable. But to do this,
a source root dir must be specified for every module.
This could be done in the root file, but this is not very modular.
Instead, now every module declares its own source root by using
the amazing Composer Merge Plugin. This approach allows each module
to also declare its own dependencies. Together, these changes allow
modules to be easily extractable to separate pacakges when the need
arises, and in general improves modularity significantly.
This commit is contained in:
Anton Ukhanev 2021-02-17 12:31:40 +01:00
parent 45db097bd8
commit d4c8282518
157 changed files with 168 additions and 8 deletions

View file

@ -5,6 +5,7 @@
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/tests/PHPUnit" isTestSource="true" packagePrefix="WooCommerce\PayPalCommerce\" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="WooCommerce\PayPalCommerce\" />
<excludeFolder url="file://$MODULE_DIR$/vendor/squizlabs/php_codesniffer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/webmozart/assert" />
<excludeFolder url="file://$MODULE_DIR$/vendor/antecedent/patchwork" />
@ -57,6 +58,7 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/recursion-context" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/diff" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
<excludeFolder url="file://$MODULE_DIR$/vendor/wikimedia/composer-merge-plugin" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />

View file

@ -12,7 +12,8 @@
"dhii/wp-containers": "^0.1.0-alpha1",
"psr/log": "^1.1",
"ext-json": "*",
"ralouphie/getallheaders": "^3.0"
"ralouphie/getallheaders": "^3.0",
"wikimedia/composer-merge-plugin": "^1.4"
},
"require-dev": {
"woocommerce/woocommerce-sniffs": "^0.1.0",
@ -20,10 +21,9 @@
"brain/monkey": "^2.4"
},
"autoload": {
"classmap": [
"modules/",
"src/"
]
"psr-4": {
"WooCommerce\\PayPalCommerce\\": "src"
}
},
"autoload-dev": {
"psr-4": {
@ -47,6 +47,11 @@
"type:inpsyde-module"
]
},
"merge-plugin": {
"include": [
"modules/*/composer.json"
]
},
"hooks": {
"pre-commit": [
"vendor/bin/phpcbf"

View file

@ -0,0 +1,17 @@
{
"name": "woocommerce/ppcp-admin-notices",
"type": "dhii-mod",
"description": "Admin notices module for PPCP",
"license": "GPL-2.0",
"require": {
"php": "^7.1 | ^8.0",
"dhii/module-interface": "^0.2.0-alpha1"
},
"autoload": {
"psr-4": {
"WooCommerce\\PayPalCommerce\\AdminNotices\\": "src"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}

View file

@ -0,0 +1,17 @@
{
"name": "woocommerce/ppcp-api-client",
"type": "dhii-mod",
"description": "API client module for PPCP",
"license": "GPL-2.0",
"require": {
"php": "^7.1 | ^8.0",
"dhii/module-interface": "^0.2.0-alpha1"
},
"autoload": {
"psr-4": {
"WooCommerce\\PayPalCommerce\\ApiClient\\": "src"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}

View file

@ -0,0 +1,17 @@
{
"name": "woocommerce/ppcp-button",
"type": "dhii-mod",
"description": "Button module for PPCP",
"license": "GPL-2.0",
"require": {
"php": "^7.1 | ^8.0",
"dhii/module-interface": "^0.2.0-alpha1"
},
"autoload": {
"psr-4": {
"WooCommerce\\PayPalCommerce\\Button\\": "src"
}
},
"minimum-stability": "dev",
"prefer-stable": true
}

Some files were not shown because too many files have changed in this diff Show more