WordPress / WordPress/plugin-check
Don't error on goto
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 362
- Forks
- 126
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 22
Description
PHP's goto is not the same as C's.
From PHP's manual:
This is not a full unrestricted goto. The target label must be within the same file and context, meaning that you cannot jump out of a function or method, nor can you jump into one. You also cannot jump into any sort of loop or switch structure.
To broaden your perspective, see the comments here: https://stackoverflow.com/questions/3517726/what-is-wrong-with-using-goto/.
And here https://www.reddit.com/r/PHP/comments/75sa2y/what_valid_use_cases_if_any_exist_for_goto_in_php/.
Also see https://en.wikipedia.org/wiki/Goto#Common_usage_patterns.
For a real-world instance of proper goto usage in the WordPress world, see https://github.com/sybrew/the-seo-framework/blob/5.1.2/inc/classes/meta/robots/args.class.php#L96.
Rewriting that code to adhere to WordPress's ostracizing PHP 4 standard would introduce at least 9 opcodes (2 vars forwarded (+2) and read (+2), in static scope (+1), function call (+1), unnecessary return yield from in generator (+2), and another yield (+1)) in that function, which can be called up to 600 times per admin page load.
To learn more, see https://github.com/igorw/retry/issues/3.
Please try to implement it in your code before condemning others. Thanks.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no file, test, or entry point. Start by locating the Plugin Check diagnostic that reports PHP goto usage and review its existing tests. Done means valid PHP goto usage is not reported while the checks for prohibited jumps remain covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100