sybrew / the-seo-framework

The SEO Framework WordPress plugin.
https://theseoframework.com/
GNU General Public License v3.0
417 stars 46 forks source link

Upgrade to PHP 8.2 #644

Open sybrew opened 1 year ago

sybrew commented 1 year ago

See https://github.com/sybrew/the-seo-framework/issues/98 and #608.

We expect TSF v5.0 to be released late 2024-- that's when most sites have hopefully upgraded to a secure PHP version–that'd be 8.2. See https://www.php.net/supported-versions.php.

Since the jump from PHP 8.0 to 8.2 is perceived as minor, we expect that most PHP 8.X users will be on 8.2 by the time we upgrade from 7.4.

Features we'd want to utilize

PHP 8.0

PHP 8.1

PHP 8.2

Conclusion

The tiny list of features in 8.2 does not justify an upgrade unless we can reasonably assume most sites are upgraded.

Proposed version

Ref: https://wordpress.org/about/stats/

We'll upgrade to a version that at least 66% of sites support at our scheduled release. We previously aimed at 85%. However, since WordPress reports data from inactive sites and prevents users from updating plugins with unsupported required PHP versions, I see no issue in upgrading earlier.

TSF v5.0 will have an estimated 6-month development cycle. Hopefully, we can get started somewhere early or even before 2024. Extension Manager's upgrade will follow soon after that.

chesio commented 1 year ago

I also find enums (added in PHP 8.1) quite useful.

sybrew commented 1 year ago

I simulated the Fiber API here; it's where we could benefit by upgrading, where we need not test for also valid() and next() -- but only resume() (now current()) and isTerminated() (now false): https://github.com/sybrew/the-seo-framework/blob/e44d72af7fc6a71c79de59600ed259a015c5e022/inc/classes/meta/factory/image.class.php#L612-L639

We have various functions that could benefit from array_is_list(): https://github.com/sybrew/the-seo-framework/blob/e44d72af7fc6a71c79de59600ed259a015c5e022/inc/functions/utils.php#L70-L72

This could be condensed using array unpacking by string (...dimensions,[ etc, ]): https://github.com/sybrew/the-seo-framework/blob/e44d72af7fc6a71c79de59600ed259a015c5e022/inc/classes/meta/factory/image.class.php#L678-L685

We're already using str_contains() and str_starts_with() because WordPress provides polyfills.

Some properties could benefit from being readonly -- for now, I marked those as "private" or blocked access altogether by requiring a functional interface. Bypassing the function overhead could speed things up and make the code more readable, especially since the nullsafe operator is also available.

About enums... this requires a new way of thinking about objects -- I'm not sure if it's backportable. I'll look into this one a bit more once we can actually embrace it.

sybrew commented 3 months ago

WordPress 6.5+ has a polyfill for array_is_list().