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

Drop PHP 7 support #343

Open
thekid opened this issue Dec 20, 2022 · 10 comments
Open

Drop PHP 7 support #343

thekid opened this issue Dec 20, 2022 · 10 comments

Comments

@thekid
Copy link
Member

thekid commented Dec 20, 2022

Scope of Change

This RFC suggests dropping PHP 7 support

Rationale

PHP 7.4 is EOL since November 28, 2022: https://twitter.com/official_php/status/1597203297537957888

Functionality

  • Need to simulate PHP 8 Annotations goes away
  • We can use named arguments where it makes code more readable
  • We can use constructor property promotion to simplify code
  • Union types can now be expressed in syntax
  • We can refactor several switch statements to match
  • We can use the ?-> nullsafe operator

Security considerations

n/a

Speed impact

Better

Dependencies

Major version

Related documents

https://www.php.net/releases/8.0/en.php

@thekid
Copy link
Member Author

thekid commented Dec 20, 2022

As long as it's not a major hassle to support PHP 7.x we can also continue to keep compatibility with it, though.

@thekid
Copy link
Member Author

thekid commented Dec 30, 2022

It could be worthwhile dropping PHP < 7.4 for:

@thekid
Copy link
Member Author

thekid commented Feb 7, 2023

All PHP 8.0 features @ https://wiki.php.net/rfc#php_80

@thekid
Copy link
Member Author

thekid commented Jan 23, 2024

https://externals.io/message/122214

This would introduce the situation of not being able to write nullable parameters in a way that works for all PHP versions. PHP 7.0 needs T $arg= null, which would be deprecated and create warnings.

One argument more to only keep support for PHP 7.4

@thekid
Copy link
Member Author

thekid commented Mar 16, 2024

This would introduce the situation of not being able to write nullable parameters in a way that works for all PHP versions

Made XP 11 compatible by suppressing this specific error, see https://github.com/xp-framework/core/releases/tag/v11.9.0

@thekid
Copy link
Member Author

thekid commented Mar 23, 2024

The case for dropping 7.0 (but retaining 7.x)

This would introduce the situation of not being able to write nullable parameters in a way that works for all PHP versions

We should safely be able to drop at least PHP 7.0 as even really old Ubuntu versions come with 7.2:

This would allow us to restore full compatibility with the implicit nullable types deprecation as we can use https://wiki.php.net/rfc/nullable_types syntax while still supporting the broadest possible range of PHP versions!


Dropping 7.0 would also make these conditionals unnecessary:

$ grep -Hrn PHP_VERSION src/main/php/  | grep 70100
src/main/php/lang/ClassLoader.class.php:231:        $constraint= (PHP_VERSION_ID >= 70100 ? $t->getName() : $t->__toString());
src/main/php/lang/ClassLoader.class.php:233:        $constraint= '\\'.(PHP_VERSION_ID >= 70100 ? $t->getName() : $t->__toString());
src/main/php/lang/ClassLoader.class.php:253:      $decl.= ':'.(PHP_VERSION_ID >= 70100 ? $t->getName() : $t->__toString());
src/main/php/lang/ClassLoader.class.php:255:      $decl.= ': \\'.(PHP_VERSION_ID >= 70100 ? $t->getName() : $t->__toString());
src/main/php/lang/ClassLoader.class.php:303:            if (null !== $t && 'void' === (PHP_VERSION_ID >= 70100 ? $t->getName() : $t->__toString())) {
src/main/php/lang/Environment.class.php:17:    foreach (PHP_VERSION_ID >= 70100 ? getenv() : $_SERVER as $name => $value) {
src/main/php/lang/Environment.class.php:32:    $variables= PHP_VERSION_ID >= 70100 ? getenv() : $_SERVER;
src/main/php/lang/reflect/Field.class.php:99:      $name= PHP_VERSION_ID >= 70100 ? $t->getName() : $t->__toString();
src/main/php/lang/reflect/Parameter.class.php:107:      $name= PHP_VERSION_ID >= 70100 ? $t->getName() : $t->__toString();
src/main/php/lang/reflect/Routine.class.php:168:      $name= PHP_VERSION_ID >= 70100 ? $t->getName() : $t->__toString();
src/main/php/lang/Type.class.php:256:      $name= PHP_VERSION_ID >= 70100 ? $type->getName() : $type->__toString();

PHP 7.1 comes with a variety of syntactical features:

See https://wiki.php.net/rfc#php_71

PHP 7.2, 7.3 and 7.4 offer the following on top:

See https://wiki.php.net/rfc#php_72, https://wiki.php.net/rfc#php_73 and https://wiki.php.net/rfc#php_74


Our path forward could be as follows:

  1. XP 12 drops PHP 7.0 support
  2. XP 13 drops PHP 7.1 - 7.3 support
    • Released November 2024, two years after PHP 7.4 EOL
    • Minimum requirement: PHP 7.4
    • Removes XP relection API
  3. XP 14 drops PHP 7 support alltogether
    • Released 2025
    • Minimum requirement: PHP 8.0

Alternatively, a more "agressive" (see above for how long PHP 7.4 has been EOL) path could be:

  1. XP 12 drops PHP 7.0 - 7.3 support
  2. XP 13 drops PHP 7 support alltogether
    • Released November 2024, two years after PHP 7.4 EOL
    • Minimum requirement: PHP 8.0
    • Removes XP relection API

@thekid
Copy link
Member Author

thekid commented Mar 23, 2024

For contrast: Symfony, Laravel and PHPUnit all require PHP 8.2 at the time of writing

thekid added a commit to xp-framework/web that referenced this issue Mar 23, 2024
thekid added a commit to thekid/core that referenced this issue Mar 23, 2024
thekid added a commit to xp-framework/test that referenced this issue Mar 23, 2024
@thekid
Copy link
Member Author

thekid commented Mar 23, 2024

@thekid
Copy link
Member Author

thekid commented Mar 29, 2024

Alternatively, a more "agressive" (see above for how long PHP 7.4 has been EOL) path could be:
[...]
XP 12 drops PHP 7.0 - 7.3 support

Following this path, quite a bit of libraries have been pushed to 7.4+ in the meantime

@thekid
Copy link
Member Author

thekid commented Aug 17, 2024

See xp-forge/aws@613264f

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

No branches or pull requests

1 participant