Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
- name: Run PHPUnit
run: ./vendor/bin/phpunit

- name: Run Psalm
run: ./vendor/bin/psalm --show-info=false --threads=2
- name: Run PHPStan
run: ./vendor/bin/phpstan analyze --error-format=github

- name: Run PhpCS
run: ./vendor/bin/phpcs -n --parallel=2 --runtime-set ignore_warnings_on_exit 1
3 changes: 2 additions & 1 deletion .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"tests": "@php ./vendor/phpunit/phpunit/phpunit --coverage-text",
"tests:no-cov": "@php ./vendor/phpunit/phpunit/phpunit --no-coverage",
"phpstan": "vendor/bin/phpstan analyse",
"phpstan:raw": "vendor/bin/phpstan analyse --no-progress --error-format=raw",
"check-psalm": "vendor/bin/psalm",
"check-psalm:no-cache": "vendor/bin/psalm --no-cache"
},
Expand Down
224 changes: 217 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions inc/woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ function is_order_received_page()

if (!function_exists('untrailingslashit')) {
/**
* @since WooCommerce 2.2.0
* @param string $string
* @param string|null $string
* @return string
* @since WooCommerce 2.2.0
*/
function untrailingslashit($string)
function untrailingslashit(?string $string): string
{
if ($string === null) {
return '';
Expand Down
4 changes: 3 additions & 1 deletion lib/payment-gateway/src/PaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public function __construct(
unset($this->form_fields);
unset($this->enabled);

// phpstan:ignore [wc-stub] process_admin_options is inherited from WC_Payment_Gateway but absent from stubs
// @phpstan-ignore-next-line
add_action(
'woocommerce_update_options_payment_gateways_' . $this->id,
[$this, 'process_admin_options']
Expand Down Expand Up @@ -420,7 +422,7 @@ public function get_field_value($key, $field, $postData = [])
sprintf('Field "%1$s" is invalid: %2$s', $key, $exception->getMessage())
);

return null;
return '';
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/payment-gateway/src/PaymentGatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function services(): array
* prevent potential namespace conflicts when multiple plugins use this payment gateway library.
*/
'payment_gateways.plugin_slug' => static function (ContainerInterface $container): string {
/** @var PluginProperties $properties */
/** @var PluginProperties $pluginProperties */
$pluginProperties = $container->get(Package::PROPERTIES);

return $pluginProperties->baseName();
Expand Down
17 changes: 17 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
parameters:
level: 5
dynamicConstantNames:
- M4W_PLUGIN_DIR
- M4W_FILE
- M4W_PLUGIN_URL
paths:
- mollie-payments-for-woocommerce.php
- lib/
- inc/
- src/
excludePaths:
- '*/node_modules/*'
bootstrapFiles:
- vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php
- vendor/php-stubs/woocommerce-stubs/woocommerce-packages-stubs.php
- vendor/php-stubs/woocommerce-subscriptions-stubs/woocommerce-subscriptions-stubs.php
ignoreErrors:
# apply_filters is variadic in WordPress but the stubs only declare 2 required params
- '#^Function apply_filters invoked with [0-9]+ parameters, [0-9]+ required\.$#'
# CustomOrdersTableController is an internal WooCommerce class not in stubs
- '#^(Class Automattic\\WooCommerce\\Internal\\DataStores\\Orders\\CustomOrdersTableController not found|Call to method custom_orders_table_usage_is_enabled\(\) on an unknown class)#'
# Vendored PSR container uses a namespaced path
- '#(unknown class|Call to method .+ on an unknown class|has unknown class) Mollie\\WooCommerce\\Vendor\\Psr\\Container\\ContainerInterface#'
# WC()->cart and WC()->customer are typed as non-nullable in stubs but can be null at runtime
- '#^(Property WooCommerce::\$cart \(WC_Cart\) in isset\(\) is not nullable|Left side of && is always true)\.$#'
# M4W_PLUGIN_DIR constant is defined at runtime in the main plugin file
- '#^Constant M4W_PLUGIN_DIR not found\.$#'

2 changes: 1 addition & 1 deletion src/Assets/AssetsModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ function () use ($container, $pluginUrl, $pluginPath) {
);
add_action(
'admin_init',
function () use ($container, $pluginVersion, $pluginUrl) {
function () use ($pluginVersion, $pluginUrl) {
if (is_admin()) {
global $current_section;
wp_register_script(
Expand Down
Loading
Loading