Fixes to deprecation warnings starting in PHP 8.2 by neapsix · Pull Request #248 · sbrl/Pepperminty-Wiki · GitHub
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

Fixes to deprecation warnings starting in PHP 8.2 #248

Merged
merged 2 commits into from
Sep 5, 2024

Conversation

neapsix
Copy link
Contributor

@neapsix neapsix commented Jun 6, 2023

Hello! Another patch for you to consider. This PR updates a few lines that still work but cause deprecation warnings starting in PHP 8.2.

The first commit replaces ${var} with {$var}. The second uses an iterator instead of calling reset() on an object. I've validated them on FreeBSD with Apache and PHP 8.0, 8.1, and 8.2.

I followed the guidance in the deprecation notices but don't have much experience with PHP—happy to change or rework based on your feedback. Thank you so much!

I agree to release this contribution under the Mozilla Public License 2.0.

Using `${var}` to embed variables in strings causes warnings starting
in PHP 8.2. This commit replaces two instances with `{$var}`, following
recommendations in the deprecation notice and related RFC.
Calling `reset()` on an object causes warnings starting in PHP 8.2.
This commit replaces one instance with ArrayIterator object and
getIterator() method following a recommendation in the deprecation
notice RFC.
@neapsix neapsix changed the title Patch php82 2 Fixes to deprecation warnings starting in PHP 8.2 Jun 6, 2023
@neapsix neapsix marked this pull request as ready for review June 6, 2023 03:55
Copy link
Owner

@sbrl sbrl left a comment

Choose a reason for hiding this comment

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

Looks good to me! I didn't know the ${var} syntax had been deprecated. It's been kinda my default go-to, since that's what you do in Bash.

Thanks for the update! Do you have a link to that deprecation notice at all? Probably worth me giving it a read.

I assume this doesn't kill support for e.g. 8.1?

@sbrl sbrl merged commit 63c59ea into sbrl:master Sep 5, 2024
@neapsix
Copy link
Contributor Author

neapsix commented Sep 5, 2024

Hey, thanks so much for the merges!

Here are the links to the RFC and migration notes for ${var} string interpolation (landed in PHP 8.2):

I agree that the {$var} syntax is a little unfamiliar for me, but I think I see why they recommend it.

And for calling reset() on objects (landed in PHP 8.1):

These changes shouldn't break support for PHP 8.0 and 8.1! I just re-tested 8.1 and verified that internal links and searching work as expected. I don't have a VM with 8.0 handy, but I recall that I checked it before and didn't see any issues.

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

Successfully merging this pull request may close these issues.

2 participants