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

PHP 8.2 | Fix deprecated embedded variables in text strings #44538

Merged
merged 1 commit into from Oct 3, 2022

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Sep 28, 2022

What?

PHP 8.2 will deprecate two of the four currently supported syntaxes for embedding variables in double quoted text string/heredocs.

This library contains six uses of embedded variables using braces after the dollar sign ("${foo}"), which is one of the deprecated forms.

This commit fixes all six.

Refs:

Why?

Because code should be cross-version compatible with all supported PHP versions, including the upcoming PHP 8.2.

PHP 8.2 will deprecate two of the four currently supported syntaxes for embedding variables in double quoted text string/heredocs.

This library contains six uses of embedded variables using braces after the dollar sign (`"${foo}"`), which is one of the deprecated forms.

This commit fixes all six.

Refs:
* https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
@jrfnl jrfnl requested a review from anton-vlasenko Sep 28, 2022
@jrfnl jrfnl requested a review from spacedmonkey as a code owner Sep 28, 2022
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Sep 28, 2022
@jrfnl jrfnl removed the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Sep 28, 2022
@WordPress WordPress deleted a comment from github-actions bot Sep 28, 2022
@gziolo
Copy link
Member

gziolo commented Sep 28, 2022

This library contains six uses of embedded variables using braces after the dollar sign ("${foo}"), which is one of the deprecated forms.

It’s a JavaScript syntax for variables in strings. 😃 Thank you for spotting and correcting it 👍

@anton-vlasenko anton-vlasenko added the [Type] Code Quality Gotta shave those yaks. label Oct 3, 2022
@anton-vlasenko anton-vlasenko added this to the Gutenberg 14.3 milestone Oct 3, 2022
Copy link
Contributor

@anton-vlasenko anton-vlasenko left a comment

LGTM!
Nice job.

@anton-vlasenko anton-vlasenko merged commit 9c7c637 into trunk Oct 3, 2022
23 checks passed
@anton-vlasenko anton-vlasenko deleted the php-8.2/fix-deprecated-embedded-variables branch Oct 3, 2022
@jrfnl
Copy link
Member Author

jrfnl commented Oct 3, 2022

Does this need a port to WP Core ? Will this be handled automatically or should I open a PR to Core for this too ?

@anton-vlasenko
Copy link
Contributor

anton-vlasenko commented Oct 3, 2022

I wonder if this particular PR needs porting, as Core version of the WP_Theme_JSON class uses sprintf() for concatenation and probably(?) doesn't need this fix.
In general, a Backport to WP Beta/RC or a Backport to WP minor release label should be added to PRs that need backporting.

Will this be handled automatically or should I open a PR to Core for this too ?

As far as I know, this is handled by the release managers.
Here is the tracking issue for all Gutenberg PRs that need backporting:
#43440

@jrfnl jrfnl added Backport to WP Beta/RC PRs to be back-ported to the WordPress major release that's currently in beta. Backport to WP Minor Release PRs to be back-ported to a WordPress minor release. Needs PHP backport labels Oct 3, 2022
@jrfnl
Copy link
Member Author

jrfnl commented Oct 3, 2022

@anton-vlasenko I have added the labels, let's see what happens...

@michalczaplinski michalczaplinski removed Backport to WP Beta/RC PRs to be back-ported to the WordPress major release that's currently in beta. Backport to WP Minor Release PRs to be back-ported to a WordPress minor release. labels Oct 3, 2022
@michalczaplinski
Copy link
Contributor

michalczaplinski commented Oct 3, 2022

Hey 👋 I've removed the labels as this PR will not need to be ported to Core. The equivalent function in Core is already using the sprintf() syntax.

I wonder if in fact the GB should have the same syntax here as the Core one 🤔 .

@jrfnl
Copy link
Member Author

jrfnl commented Oct 3, 2022

Thanks @michalczaplinski for investigating.

I wonder if in fact the GB should have the same syntax here as the Core one

I imagine that would greatly improve the code readability as it reduces the length of that really long long line and makes it clear which are the variable parts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants