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.0 Upgrade Features/Notes #1992

Open
7 tasks
chrisblakley opened this issue Mar 23, 2020 · 9 comments
Open
7 tasks

🔮 PHP 8.0 Upgrade Features/Notes #1992

chrisblakley opened this issue Mar 23, 2020 · 9 comments
Labels
Backend (Server) Related to the server-side (includes PHP, HTML, etc). 💭 Question / Research Additional research/discussion is needed to answer this question.
Milestone

Comments

@chrisblakley
Copy link
Owner

chrisblakley commented Mar 23, 2020

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

  • Release Date: November 2020
  • Active Support Until November 2022
  • Security Support Until November 2023

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.

  • str_contains()
  • str_starts_with() and str_ends_with()
  • The @ operator no longer silences fatal errors. Make sure there are none in Nebula
  • Union Types
  • Named Arguments
  • Null safe operator
  • Match expression

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 chrisblakley added 💭 Question / Research Additional research/discussion is needed to answer this question. Backend (Server) Related to the server-side (includes PHP, HTML, etc). labels Mar 23, 2020
@chrisblakley chrisblakley added this to the 8.0 Eight-Burst milestone Mar 23, 2020
@chrisblakley
Copy link
Owner Author

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

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

@chrisblakley
Copy link
Owner Author

chrisblakley commented Jun 19, 2020

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

  • Arrow functions (probably only use sparingly in Nebula) fn()
  • Null coalescing assignment operator ??=
  • Numerical literal separators (underscores) 123_456_789.01
    • Added //PHP 7.4 use numeric separators here comments for these

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: #2147

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

@chrisblakley
Copy link
Owner Author

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
Copy link
Owner Author

chrisblakley commented Sep 19, 2020

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 chrisblakley changed the title PHP 8 Upgrade Features/Notes 🔮 PHP 8 Upgrade Features/Notes Sep 19, 2020
@chrisblakley
Copy link
Owner Author

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

@chrisblakley
Copy link
Owner Author

chrisblakley commented Apr 17, 2021

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: #2147 (comment)

@chrisblakley
Copy link
Owner Author

Thinking sometime in 2023 for minimum version to 8.0... #2147 (comment)

@chrisblakley
Copy link
Owner Author

chrisblakley commented May 17, 2022

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 chrisblakley changed the title 🔮 PHP 8 Upgrade Features/Notes 🔮 PHP 8.0 Upgrade Features/Notes Dec 25, 2022
@chrisblakley chrisblakley modified the milestones: 11.0 Carina, 12.0 Flame May 1, 2023
@chrisblakley chrisblakley pinned this issue Apr 2, 2024
@chrisblakley
Copy link
Owner Author

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%.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend (Server) Related to the server-side (includes PHP, HTML, etc). 💭 Question / Research Additional research/discussion is needed to answer this question.
Projects
Development

No branches or pull requests

1 participant