Skip to content

[RFC] PHP Language Level for Symfony 6 #40389

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

Closed
derrabus opened this issue Mar 6, 2021 · 34 comments
Closed

[RFC] PHP Language Level for Symfony 6 #40389

derrabus opened this issue Mar 6, 2021 · 34 comments
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed)

Comments

@derrabus
Copy link
Member

derrabus commented Mar 6, 2021

Symfony 6 will be released this year in November and traditionally, we bump the minimum required PHP version with such a major release. This helps us to continuously modernize the codebase and to remove compatibility code for PHP releases that are not maintained (and thus shouldn't be used) anymore.

I'd like to discuss the options that we have, so we can come to a good and well-informed decision.

Overview

The following PHP requirements have been set in the past for Symfony major releases:

Symfony major maintenance period min. PHP version maintenance period
2.0 – 2.8 07/2011 – 09/2019 5.3 06/2009 – 08/2014
3.0 – 3.4 11/2015 – 11/2021 5.5 06/2013 – 07/2016
4.0 – 4.4 11/2017 – 11/2023 7.1 12/2016 – 12/2019
5.0 – 5.4 11/2019 – 11/2025 7.2 11/2017 – 11/2020
6.0 – 6.4 11/2021 – 11/2027 TBD TBD

The options

Given that we want to continue the tradition and bump PHP at least by one minor version, we have the following options.

PHP 7.3

  • Initially released December 2018
  • Receives security fixes only and will EOL shortly after the Symfony 6 release.

PHP 7.3 was mainly a maintenance release. By bumping we would gain:

  • JSON_THROW_ON_ERROR
  • Indented heredoc and nowdoc statements
  • Trailing commas in function calls

PHP 7.4

  • Initially released November 2019
  • Actively maintained at the moment and will enter the security support phase at the same time as Symfony 6 is released
  • The final PHP 7 minor release

PHP 7.4 was a big step forwards. It introduced features that I actively use in my projects and I would be delighted to see them in Symfony's codebase as well.

We would gain:

  • Arrow functions
  • Typed properties
  • Covariant return types and contravariant parameter types
  • We can assume preloading to be available (though not necessarily enabled)
  • We can simplify serializable classes (__serialize, __unserialize all the way)
  • Oh, and most importantly, we could use the ??= operator as several Psalm users have already told us. 😉

If we plan to update the codebase with return types, the introduced covariance is certainly a feature that we want to have. PHP 7.4 is currently bundled by the stable and LTS releases of Debian and Ubuntu. In Packagist's November 2020 report, it had an adoption of 42.6% and I would assume that this number has grown since then. Given that the upgrade to PHP 8.0 has been bumpy for the projects I've seen, I would also assume that PHP 7.4 will live a little bit longer that usual.

PHP 8.0

  • Initially released November 2020
  • Actively maintained until November 2022, EOL in November 2023.

We would gain:

  • Union types, mixed type, static return type
  • Attributes could be a first-class citizen in Symfony
  • Constructor property promotion
  • The nullsafe operator, match and throw expressions
  • Internal functions throw TypeErrors and ValueErrors which allows us to remove some hacks with custom error handlers.
  • We could implement psr/cache v3

Again, if we plan to introduce return type declarations, we would probably need to leave some holes when doing so on PHP 7.4 that we would be able to fill in PHP 8. The whole type system feels a lot more complete here.

PHP 8.1

  • Will be release at the same time as Symfony 6
  • The feature set is still WIP

We would gain:

  • Enums?
  • Constructor calls in initializers? Nested atttibutes?

This would be a bold move. Too bold, probably.

Conclusion

I think the only two options that would really make sense are 7.4 and 8.0. With 7.3, we wouldn't gain much. Applications are already migrating away from it and I expect that release to become pretty much irrelevant soon. By requiring 8.1, we would slow down Symfony 6's adoption too much, cutting off too many developers from the active feature development.

PHP 7.4 would certainly be the save bet. It's a feature-rich release, included in popular Linux distributions already. However, PHP 8.0 would overall be the larger step forward for Symfony.

What do you think?

@carsonbot carsonbot added the RFC RFC = Request For Comments (proposals about features that you want to be discussed) label Mar 6, 2021
@fabpot
Copy link
Member

fabpot commented Mar 6, 2021

Thank you @derrabus for giving us all the information to make the decision much easier to make.

I think we need to set the minimum version to 8.0.
Supporting 7.4 does not make sense IMHO as 5.4 (which has the same features as 6.0 is a LTS) and will reach OEM right after our release.

So, 8.0 for me.

@OskarStark
Copy link
Contributor

I agree with bumping to 8.0 👍🏻

@lsmith77
Copy link
Contributor

lsmith77 commented Mar 6, 2021

+1 for php 8

@ro0NL
Copy link
Contributor

ro0NL commented Mar 6, 2021

can we reasonably predict min php version for future versions? to be displayed at eg. https://symfony.com/releases/9.4

@javiereguiluz
Copy link
Member

@derrabus thanks for this detailed summary. I'm extremely happy to read that Fabien and others vote for PHP 8. It's the best PHP version in years. Using it would have a very significant impact in Symfony project.

So, another vote for PHP 8 🎉

@christian-kolb
Copy link

I would also like to vote for PHP 8! 🙂

@alcaeus
Copy link
Contributor

alcaeus commented Mar 6, 2021

I agree with both @derrabus and @fabpot: people who can't upgrade to 8.0 can use Symfony 5.4 on PHP 7, but the improvements in PHP 8 allow us to be braver when introducing new features in subsequent versions.

@chalasr
Copy link
Member

chalasr commented Mar 6, 2021

👍 for PHP 8.

@xabbuh
Copy link
Member

xabbuh commented Mar 6, 2021

👍 from me for PHP 8 as well

@michaljusiega
Copy link
Contributor

My vote may not mean too much, but 👍 from for PHP8.

@YetiCGN
Copy link

YetiCGN commented Mar 6, 2021

+1 for PHP 8.0.

Will make things so much better and it's not hard to go from 7.3 or 7.4 to 8.0!

@kevin-emo
Copy link

👍 PHP 8.0 👍

@carusogabriel
Copy link
Contributor

PHP 8.0 as the minimum version supported 🙏🏻

@Chemaclass
Copy link

Chemaclass commented Mar 6, 2021

PHP 8.0 👍🎉

@JesusValeraDev
Copy link

PHP 8.0 👌🏼👍🏼👍🏼👍🏼🙂

@TheCadien
Copy link

TheCadien commented Mar 6, 2021

thumbs up for PHP 8.0 !!

@faizanakram99
Copy link
Contributor

PHP 8.1, that seems a bit bold but I do think the main obstacle against PHP version upgrades are BC breaks.
There aren't as many BC breaks between PHP 8.0 and PHP 8.1 as there are between PHP 7.4 and PHP 8.0.

If one can be on PHP 8, they very well can be on PHP 8.1

PHP 8.1 gives a lot of features over PHP 8, most notably Enums 🎉, restricted $GLOBALS usage (which I believe needs some hacks in symfony code base at the moment), array unpacking with string keys and I believe there is more to come.

https://php-rfc-watch.beberlei.de/

@0x346e3730
Copy link
Contributor

👍 for PHP8

@medjalil
Copy link

medjalil commented Mar 6, 2021

🔔 PHP 8 👌

@crevillo
Copy link

crevillo commented Mar 6, 2021

Another one for PHP 8

@MinDBreaK
Copy link

I'd vote for PHP8 🎉

@makraz
Copy link
Contributor

makraz commented Mar 6, 2021

+1 for PHP 8.0

@derrabus
Copy link
Member Author

derrabus commented Mar 6, 2021

All right. Wow. I did not expect the outcome of this RFC to be that crystal clear. 🤩

@jderusse
Copy link
Member

jderusse commented Mar 6, 2021

Having a minimal requirement to php 8.0 does not mean that you can't use PHP 8.1, and it neither means we won't provide features dedicated to php 8.1+. We already provide Attributes in Symfony 5.x while the minimal requirement is 7.2.

Having a minimal requirement to php 8.0 does not mean we will switch everything to the new hype features, For the same reason we didn't switched to short array syntax with php 5.4: merging bugfix from 5.x to 6.x could be very complex when everything had changed upstream.

End-users would only be affected by cleaner interfaces (union type, enum), everything else only affect people that contribute to symfony's code.

As a user, I don't really care about the minimal version.

As a maintainer, I'd vote for php 8.0 and adds an other reason to the list, it would ease integration with our vendors that are less flexible than us, and thus will reduce the complexity in our bridges.

Don't forget we are choosing a version that will be supported until 2026 (which mean +6 PHP version from)

@pizzaminded
Copy link
Contributor

maybe i will not add anything new to topic, but +1 for php8.

@weaverryan
Copy link
Member

PHP 8 would help with documentation, as we could exclusively show attributes instead of annotations :).

@ademir-trusted-shops
Copy link

PHP 8.0

@ondrejfuhrer
Copy link
Contributor

I would suggest going for 8.0 . By the time Symfony get released it will be already several bug fixes in, therefore not "dangerous" bleeding edge.

@derrabus
Copy link
Member Author

derrabus commented Mar 6, 2021

PHP 8 would help with documentation, as we could exclusively show attributes instead of annotations :).

Yes, or at least default to attributes. Unfortunately, there's still a gap to fill: #38503

@fabpot
Copy link
Member

fabpot commented Mar 6, 2021

Let’s close now, 8.0 is the winner here.

@fabpot fabpot closed this as completed Mar 6, 2021
@aminvoly
Copy link

aminvoly commented Mar 6, 2021

Not php 8, just to jave different options.

@DennisdeBest
Copy link

PHP 8

@dguhl
Copy link

dguhl commented Mar 6, 2021

There is no way it could not be PHP 8 - PHP 7.4 will end its active support the very same month Symfony 6 would be released. Symfony 6 has to be on PHP 8.

@symfony symfony locked as resolved and limited conversation to collaborators Mar 6, 2021
@nicolas-grekas
Copy link
Member

Follow up in #40420 FYI.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed)
Projects
None yet
Development

No branches or pull requests