I18nTextDomainFixer: remove unnecessary variable initialization#2513
Merged
dingo-d merged 1 commit intoWordPress:developfrom Dec 2, 2024
Merged
Conversation
Initializing the variable here is unnecessary as its value is immediately overridden in the if/else below.
dingo-d
approved these changes
Dec 2, 2024
Member
Contributor
Author
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. |
Member
|
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 😄 |
Member
|
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. |
Contributor
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) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

While working on #2512, I noticed an unnecessary variable initialization, so I'm creating this PR to suggest that it be removed. Its value is immediately overridden in an if/else below.
https://github.com/rodrigoprimo/WordPress-Coding-Standards/blob/690f05a51d190586e0bb0426a0f04242224d0723/WordPress/Sniffs/Utils/I18nTextDomainFixerSniff.php#L727
https://github.com/rodrigoprimo/WordPress-Coding-Standards/blob/690f05a51d190586e0bb0426a0f04242224d0723/WordPress/Sniffs/Utils/I18nTextDomainFixerSniff.php#L749