Open
Description
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
.- When a child class implements a function but ignores one of the parameters, use a PHPCS ignore until PHPCS/Psalm: Figure out how to reconcile
$_unused_
var name prefixes in child classes with Psalm static analysis #8956 is fixed.
- When a child class implements a function but ignores one of the parameters, use a PHPCS ignore until PHPCS/Psalm: Figure out how to reconcile
- 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
.
Activity