Skip to content

Plugin: Fix unused parameter phpcs sniffs #8654

Open
@reykjalin

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.
  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    focus: architectureProduct architecture and engineering best practicespriority: lowThe issue/PR is low priority—not many people are affected or there’s a workaround, etc.type: technical debtThis issue/PR represents/solves the technical debt of the project.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions