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:
tests/unit/core/server/request/test-trait-order-info.php
tests/unit/core/server/request/test-class-core-cancel-intention-request.php
tests/unit/core/server/request/test-class-core-capture-intention-request.php
tests/unit/helpers/class-wc-mock-wc-data-store.php
tests/unit/core/server/request/test-class-core-get-intention-request.php
tests/unit/core/server/request/test-class-core-get-setup-intention-request.php
tests/unit/woopay/services/test-checkout-service.php
tests/unit/core/server/request/test-class-core-update-intention-request.php
tests/unit/subscriptions/test-class-wc-payments-subscription-service.php
tests/unit/woopay/test-class-woopay-session.php
tests/unit/helpers/class-wc-helper-product-add-ons-helper.php
tests/unit/subscriptions/test-class-wc-payments-subscriptions-event-handler.php
tests/unit/subscriptions/test-class-wc-payments-subscriptions-migrator.php
tests/unit/helpers/class-wc-helper-product.php
tests/unit/helpers/class-wc-helper-subscription.php
tests/unit/helpers/class-wc-helper-subscriptions-product.php
tests/unit/helpers/class-wc-helper-subscriptions-synchroniser.php
tests/unit/test-class-database-cache.php
tests/unit/multi-currency/test-class-multi-currency.php
tests/unit/test-class-payment-information.php
tests/unit/multi-currency/compatibility/test-class-woocommerce-subscriptions.php
tests/unit/src/Internal/Service/MinimumAmountServiceTest.php
tests/unit/test-class-wc-payment-gateway-wcpay-payment-types.php
tests/unit/admin/test-class-wc-rest-payments-orders-controller.php
tests/unit/multi-currency/test-class-analytics.php
tests/unit/admin/test-class-wc-rest-payments-readers-controller.php
tests/unit/subscriptions/test-class-wc-payments-invoice-service.php
tests/unit/test-class-wc-payment-gateway-wcpay-process-payment.php
tests/unit/subscriptions/test-class-wc-payments-subscription-change-payment-method.php
tests/unit/test-class-wc-payments-payment-request-button-handler.php
tests/unit/test-class-wc-payment-gateway-wcpay-process-refund.php
tests/unit/payment-methods/test-class-upe-split-payment-gateway.php
tests/unit/reports/test-class-wc-rest-payments-reports-authorizations-controller.php
tests/unit/test-class-wc-payment-gateway-wcpay-subscriptions-payment-method-order-note.php
tests/unit/test-class-wc-payments-utils.php
tests/unit/test-class-wc-payment-gateway-wcpay-subscriptions-process-payment.php
tests/unit/test-class-wc-payment-gateway-wcpay-subscriptions.php
tests/unit/test-class-wc-payment-gateway-wcpay.php
tests/unit/test-class-wc-payments-account.php
tests/unit/test-class-compatibility-service.php
Suggested fixes:
Note
We should consider just adding an exclude for the tests directory, but it may be worth it to keep the rule.
- 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