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

Update docs to avoid recommending early return PHP "anti-pattern" #58454

Merged
merged 3 commits into from Feb 8, 2024

Conversation

getdave
Copy link
Contributor

@getdave getdave commented Jan 30, 2024

What?

Updates PHP in Gutenberg docs to avoid recommending a pattern that could cause problems for older versions of PHP.

See #58429 (comment).

Why?

#58429 (comment)

How?

Updates docs.

Testing Instructions

Testing Instructions for Keyboard

Screenshots or screencast

@getdave getdave added the [Type] Developer Documentation Documentation for developers label Jan 30, 2024
@getdave getdave self-assigned this Jan 30, 2024
Copy link

This pull request has changed or added PHP files. Please confirm whether these changes need to be synced to WordPress Core, and therefore featured in the next release of WordPress.

If so, it is recommended to create a new Trac ticket and submit a pull request to the WordPress Core Github repository soon after this pull request is merged.

If you're unsure, you can always ask for help in the #core-editor channel in WordPress Slack.

Thank you! ❤️

View changed files
❔ lib/README.md

Copy link

Flaky tests detected in 1127a5d.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7713081919
📝 Reported issues:

@getdave
Copy link
Contributor Author

getdave commented Jan 31, 2024

Noting that some of the Fonts Library classes use this pattern.

#57688

@getdave getdave marked this pull request as ready for review January 31, 2024 13:34
@getdave
Copy link
Contributor Author

getdave commented Jan 31, 2024

Possible overlap/duplication with #58500

Copy link
Contributor

@anton-vlasenko anton-vlasenko left a comment

Choose a reason for hiding this comment

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

This PR looks good to me, except for the small issue mentioned below. I don't think it duplicates anything.
Considering the ongoing work on implementing a slightly different approach as outlined in #58467, the documentation might need to be updated again soon.

However, updating the documentation is always a good idea, in my opinion.

lib/README.md Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Feb 6, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core SVN

Core Committers: Use this line as a base for the props when committing in SVN:

Props get_dave, antonvlasenko.

GitHub Merge commits

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: getdave <get_dave@git.wordpress.org>
Co-authored-by: anton-vlasenko <antonvlasenko@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

@anton-vlasenko anton-vlasenko left a comment

Choose a reason for hiding this comment

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

I'm sorry for being too picky, but I have another request.
Could the documentation specify more clearly that the issue stems from the usage of the return operator, rather than the return early pattern as a whole?

I'm afraid this might be misunderstood as discouraging the entire return early pattern, which isn't the case, as early returns can improve code clarity as outlined here.

lib/README.md Outdated Show resolved Hide resolved
getdave and others added 3 commits February 7, 2024 10:41
Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com>
Co-authored-by: Anton Vlasenko <43744263+anton-vlasenko@users.noreply.github.com>
@getdave getdave force-pushed the update/document-php-return-anti-pattern branch from 27b1a74 to 3d27476 Compare February 7, 2024 10:41
@getdave
Copy link
Contributor Author

getdave commented Feb 7, 2024

I'm sorry for being too picky, but I have another request.

Pickiness is never a bad thing when it comes to accurate documentation 😄 Thank you!

I've marked to auto-merge.

@getdave getdave enabled auto-merge (squash) February 7, 2024 10:42
Copy link
Contributor

@anton-vlasenko anton-vlasenko left a comment

Choose a reason for hiding this comment

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

LGTM!

@getdave getdave disabled auto-merge February 8, 2024 09:10
@getdave
Copy link
Contributor Author

getdave commented Feb 8, 2024

PHPUnit failures are not related to this PR and have been fixed on trunk. Force merging this one as it's only a docs update.

@getdave getdave merged commit 76987e3 into trunk Feb 8, 2024
39 of 58 checks passed
@getdave getdave deleted the update/document-php-return-anti-pattern branch February 8, 2024 09:11
@github-actions github-actions bot added this to the Gutenberg 17.7 milestone Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants