Part of #8436.
Description
Remove the VariableAnalysis.CodeAnalysis.VariableAnalysis exclude from phpcs.xml.dist and fix the issues reported when running npm run lint:php in the following files:
includes/admin/class-wc-rest-payments-terminal-locations-controller.php
includes/admin/class-wc-rest-payments-tos-controller.php
includes/admin/class-wc-payments-admin-sections-overwrite.php
includes/admin/class-wc-rest-payments-onboarding-controller.php
includes/admin/class-wc-rest-payments-reader-controller.php
src/Internal/Payment/State/AbstractPaymentState.php
includes/core/server/request/class-generic.php
includes/core/server/class-response.php
includes/class-logger.php
includes/constants/class-base-constant.php
includes/wc-payment-api/class-wc-payments-api-client.php
includes/class-wc-payments-incentives-service.php
includes/class-wc-payment-gateway-wcpay.php
includes/class-wc-payment-token-wcpay-link.php
includes/class-wc-payment-token-wcpay-sepa.php
includes/class-wc-payments-utils.php
includes/class-wc-payments-webhook-processing-service.php
includes/class-wc-payments-apple-pay-registration.php
includes/class-wc-payments.php
Suggested fixes:
- When a variable is truly unused, such as in filter functions where a parameter isn’t needed, prepend
$_unused_ to the variable name. For example $order → $_unused_order.
- If a variable is not necessary, remove it.
- When a parent class/interface doesn’t use a parameter but child classes do, use an inline
// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable.
Part of #8436.
Description
Remove the
VariableAnalysis.CodeAnalysis.VariableAnalysisexclude fromphpcs.xml.distand fix the issues reported when runningnpm run lint:phpin the following files:includes/admin/class-wc-rest-payments-terminal-locations-controller.phpincludes/admin/class-wc-rest-payments-tos-controller.phpincludes/admin/class-wc-payments-admin-sections-overwrite.phpincludes/admin/class-wc-rest-payments-onboarding-controller.phpincludes/admin/class-wc-rest-payments-reader-controller.phpsrc/Internal/Payment/State/AbstractPaymentState.phpincludes/core/server/request/class-generic.phpincludes/core/server/class-response.phpincludes/class-logger.phpincludes/constants/class-base-constant.phpincludes/wc-payment-api/class-wc-payments-api-client.phpincludes/class-wc-payments-incentives-service.phpincludes/class-wc-payment-gateway-wcpay.phpincludes/class-wc-payment-token-wcpay-link.phpincludes/class-wc-payment-token-wcpay-sepa.phpincludes/class-wc-payments-utils.phpincludes/class-wc-payments-webhook-processing-service.phpincludes/class-wc-payments-apple-pay-registration.phpincludes/class-wc-payments.phpSuggested fixes:
$_unused_to the variable name. For example$order→$_unused_order.$_unused_var name prefixes in child classes with Psalm static analysis #8956 is fixed.// phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable.