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

Don't error on goto #847

Open
sybrew opened this issue Jan 3, 2025 · 0 comments
Open

Don't error on goto #847

sybrew opened this issue Jan 3, 2025 · 0 comments
Labels
[Team] Plugin Review Issues owned by Plugin Review Team

Comments

@sybrew
Copy link

sybrew commented Jan 3, 2025

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 igorw/retry#3.

Please try to implement it in your code before condemning others. Thanks.

@swissspidy swissspidy added the [Team] Plugin Review Issues owned by Plugin Review Team label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Team] Plugin Review Issues owned by Plugin Review Team
Projects
None yet
Development

No branches or pull requests

2 participants