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

Support PHP 8 and its new features #148

Closed
carlosas opened this issue Dec 28, 2020 · 6 comments
Closed

Support PHP 8 and its new features #148

carlosas opened this issue Dec 28, 2020 · 6 comments
Labels
enhancement New feature or request high priority

Comments

@carlosas
Copy link
Owner

carlosas commented Dec 28, 2020

This list is based on phpactor/phpactor#1135

Package Support

Ensuring that all packages support 8.0 and phpat can be composer-installed in a PHP 8.0 environment ✅

Language Support

Constructor promotion ✅

class CustomerDTO
{
    public function __construct(
        public Email $email, 
        public DateTimeImmutable $birth_date,
    ) {}
}

Named Parameters ✅

$data = new CustomerData(
    email: new Email('[email protected]')
);

Union Types ✅

Currently supported in docblocks

class Example {
    private int|float $foo;
    public function squareAndAdd(float|int $bar): int|float {
        return $bar ** 2 + $foo;
    }
}
$class is instanceof Foo|Bar

Attributes ✅ ⚠️

TODO:

  • Attribute arguments might use types
  • Currently only class and method attributes are catched

Match and Throw Expression ✅

match ($class) {
    $class instanceof Foo => 'one',
    $class instanceof Bar => 'bar',
    default => throw new Exception('error');
}
@carlosas carlosas added enhancement New feature or request high priority labels Dec 28, 2020
@j6s
Copy link
Contributor

j6s commented Jan 31, 2021

There are currently a couple of things standing in the way of phpat being installable on PHP8:

@Lukasz93P
Copy link

Hi @carlosas any updates on this topic? Is support for php8 coming soon?

@carlosas
Copy link
Owner Author

carlosas commented Aug 5, 2021

Hello @Lukasz93P
I'm doing some work in a dev branch to support PHP 8.0, but it will still not catch some new features (so it might not find relations on, for instance, union types) or the execution might even fail. I'm going to continue working on the support so hopefully I will release it soon-ish.

Right now you can test the progress using the version v0.8.x-dev

@carlosas
Copy link
Owner Author

carlosas commented Aug 5, 2021

I have created some tests and with the recent changes the current support in v0.8.x-dev is:

Version support ✅
Constructor property promotion ✅
Named arguments ✅
Union types ✅
Attributes ❌ (Aug 6th 13:30 -> ✅)
Match with Throw expression ✅

@Lukasz93P
Copy link

@carlosas "it will still not catch some new features", ok it sounds great despite that, I will be very happy being able to install this package with php version specified as 8 in my composer file, thats all, so thanks for answering my question.

@carlosas
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request high priority
Projects
None yet
Development

No branches or pull requests

3 participants