Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPCS: fixed last PHPCompatibility check errors #4164

Merged
merged 2 commits into from
Sep 2, 2024

Conversation

sreichel
Copy link
Contributor

@sreichel sreichel commented Aug 24, 2024

@github-actions github-actions bot added environment Component: Core Relates to Mage_Core Component: Catalog Relates to Mage_Catalog Component: Oauth Relates to Mage_Oauth phpcs labels Aug 24, 2024
@sreichel sreichel changed the title PHPCS: removed last errors form PHPCompatibility check PHPCS: fixed last errors form PHPCompatibility check Aug 24, 2024
@sreichel sreichel changed the title PHPCS: fixed last errors form PHPCompatibility check PHPCS: fixed last PHPCompatibility check errors Aug 24, 2024
@kiatng
Copy link
Contributor

kiatng commented Aug 26, 2024

PHPCompatibility complaint is

Since PHP 7.0, functions inspecting arguments, like func_get_args(), no longer report the original value as passed to a parameter, but will instead provide the current value. The parameter "$var" was used, and possibly changed (by reference), on line n.

But in the cases listed, it's all false, because the variables are not changed. So, isn't it a problem with PHPCompatibility and not the code?

Other fix is to add comment (see PHPCompatibility/PHPCompatibility#1240)

// phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection -- Reason: value is unchanged.

@sreichel
Copy link
Contributor Author

  • Always use a call to any of the following functions - func_get_arg(), func_get_args() - at the top of a function before the rest of the logic.
    This will make sure that the passed parameters have not been changed yet before they are captured and will prevent the error/warning altogether,
  • ...
  • If all else fails: PHPCS allows for the use of inline ignore annotations which when used correctly, can silence the error/warning from this sniff alone.

Followed this.

@kiatng kiatng merged commit 2b368b2 into OpenMage:main Sep 2, 2024
19 checks passed
@sreichel sreichel deleted the php-compa branch September 2, 2024 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog Relates to Mage_Catalog Component: Core Relates to Mage_Core Component: Oauth Relates to Mage_Oauth environment phpcs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants