Skip to content

Conversation

rodrigoprimo
Copy link
Collaborator

Initializing the variable here is unnecessary as its value is immediately overridden in the if/else below.
Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@jrfnl jrfnl added this to the 3.2.0 milestone Nov 30, 2024
@dingo-d
Copy link
Member

dingo-d commented Dec 2, 2024

We could probably run 'inspect code' function from PhpStorm and quickly see similar unused variables in the codebase (and potential other fixes from the suggestion)

image

@dingo-d dingo-d merged commit 9f9726a into WordPress:develop Dec 2, 2024
39 checks passed
@rodrigoprimo rodrigoprimo deleted the remove-unnecessary-variable-initialization branch December 2, 2024 14:54
@rodrigoprimo
Copy link
Collaborator Author

We could probably run 'inspect code' function from PhpStorm and quickly see similar unused variables in the codebase (and potential other fixes from the suggestion)

That is a good idea, @dingo-d. If you are not planning to do it yourself, I can try that. Just let me know what you prefer.

@dingo-d
Copy link
Member

dingo-d commented Dec 2, 2024

I mean if you're already working on it you can take over, but it's not a problem for me to do as well 😄

@jrfnl
Copy link
Member

jrfnl commented Dec 2, 2024

Sounds like a plan gentlemen ;-) Please do check history though when doing this as some of these things may have been put in place to satisfy a higher PHPStan level than we're currently running at and a commit message may hint at that, if that's the case.

@rodrigoprimo
Copy link
Collaborator Author

Just documenting here that I created the PR to remove unused variables detected by PHPStorm: #2514

lesterchan added a commit to lesterchan/WordPress-Coding-Standards that referenced this pull request Jun 8, 2025
* upstream/develop: (428 commits)
  Rulesets: update schema URL
  GH Actions: use the xmllint-validate action runner and enhance checks (WordPress#2522)
  AbstractFunctionParameterSniff: fix first class callables and function imports (WordPress#2518)
  DontExtractStandard.xml file creation (WordPress#2456)
  Add documentation for WordPress.NamingConventions.ValidVariableName (WordPress#2457)
  Remove unused variables from a few sniffs (WordPress#2514)
  I18nTextDomainFixer: remove unnecessary variable initialization (WordPress#2513)
  GH Actions: Bump codecov/codecov-action from 4 to 5 (WordPress#2510)
  GH Actions: PHP 8.4 has been released
  CS/QA: remove redundant condition
  GH Actions: use explicit PHPStan major
  Various sniffs: simplify skipping the rest of the file
  GH Actions: always quote variables
  Release checklist: add new action item
  AbstractClassRestrictionsSniff: fix insufficient defensive coding (WordPress#2500)
  ✨ New WordPress.WP.GetMetaSingle sniff (WordPress#2465)
  Fix typo in AbstractFunctionRestrictionsSniff::is_targetted_token() DocBlock (WordPress#2477)
  Fix typos (WordPress#2472)
  Documentation: capitalization consistency fixes (WordPress#2469)
  [Documentation]: WordPress.DB.PreparedSQL (WordPress#2454)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants