chrisblakley / Nebula

Nebula is a WordPress theme framework that focuses on enhancing development. The core features of Nebula make it a powerful tool for designing, developing, and analyzing WordPress websites consistently, yet its deliberately uncomplicated code syntax also serves as a learning resource for programmers themselves.
https://nebula.gearside.com
GNU General Public License v2.0
137 stars 36 forks source link

🔮 PHP 8.0 Upgrade Features/Notes #1992

Open chrisblakley opened 4 years ago

chrisblakley commented 4 years ago

PHP Version Timeline: https://www.php.net/supported-versions.php PHP Release Notes: https://php.watch/versions

PHP 8.0 Info & References

https://php.watch/versions/8.0 https://stitcher.io/blog/new-in-php-8

Projected Nebula Minimum Version Timeline

PHP Version Proposed Date Nebula GitHub Issue
7.3 May 2022 ✅ #2089
7.4 May 2023 ✅ #2147
8.0 November 2024 #1992
8.1 2027 #2234
8.2 2029 #2235
8.3 2031 #2283
9.0 TBD #2236

Notable Features related to Nebula in PHP 8.0

Launch window is around December 2020, but will be much longer before we can make use of these in Nebula.

Old:

if ( strpos('Foo Bar Baz', 'Bar') !== false ){
    echo 'Found';
}

New:

if ( str_contains('Foo Bar Baz', 'Foo') ){ //This is case-sensitive
    echo 'Found';
}
chrisblakley commented 4 years ago

https://php.watch/versions/8.0/str_starts_with-str_ends_with

str_starts_with() and str_ends_with() coming to PHP 8.

chrisblakley commented 3 years ago

I know this is for PHP v8, but some other things to note regarding PHP 7.4:

7.4 is in mainstream support right now, but until it is the minimum supported version we can't implement these in Nebula. Could be a few years before that happens. Probably at least January 2022.

Moved this comment to: https://github.com/chrisblakley/Nebula/issues/2147

For PHP 8 we're probably looking at January 2023...

chrisblakley commented 3 years ago

Named Arguments is added to the list as well: https://stitcher.io/blog/php-8-named-arguments

setcookie(
    name: 'test',
    expires: time() + 60 * 60 * 2,
);
chrisblakley commented 3 years ago

The match expression seems really useful too:

$result = match($input){
    0 => "hello",
    '1', '2', '3' => "world",
};

So in this case if $input was 2, then $result would be set to world.

Another example of match(): Screen Shot 2020-12-23 at 11 46 16 PM

chrisblakley commented 3 years ago

In the meantime, testing can be performed on WP Taste: https://tastewp.com/

chrisblakley commented 3 years ago

Here's my more specific guesstimates at PHP minimum version update dates: #2089 (comment)

Once we bump to 7.2 and then 7.3, I'll update #2147 with the next guesstimate and then this issue with the one related to PHP 8 and so on.

New guesstimate: https://github.com/chrisblakley/Nebula/issues/2147#issuecomment-1115731046

chrisblakley commented 2 years ago

Thinking sometime in 2023 for minimum version to 8.0... https://github.com/chrisblakley/Nebula/issues/2147#issuecomment-1115731046

chrisblakley commented 2 years ago

Noting locations to update strpos() with str_contains() with the following comment:

 //@todo "Nebula" 0: Update strpos() to str_contains() in PHP8

Edit: Be careful of some locations that are using strpos() to actually get the index (and not just detect if a string contains another string)!

chrisblakley commented 2 months ago

Usage statistics as of January 2024.

Screenshot 2024-04-02 at 6 24 14 PM

I'm thinking the threshold for minimum v8 is when 7.4 goes under 5%.