goaop / framework

:gem: Go! AOP PHP - modern aspect-oriented framework for the new level of software development
go.aopphp.com
MIT License
1.66k stars 163 forks source link

PHP 8 Support #486

Closed WalterWoshid closed 10 months ago

WalterWoshid commented 1 year ago

I have added PHP 8 Support by replacing the @Annotation with the new #[Attribute] syntax

I have refactored goaop/parser-reflection to also support PHP 8. I might have refactored too much of it, but all the tests are running :)

The tests from the framework must be edited, but most of them work as well. I also ran some custom tests on the Laravel framework and it seemed to work

Tasks:

WalterWoshid commented 1 year ago

There are still some things to do after this:

lisachenko commented 1 year ago

Helo, @WalterWoshid! Really nice work towards PHP8 support, check my small comments inside PR.

WalterWoshid commented 1 year ago

I would also like to hear your thoughts about a new and easier syntax style proposal:

<?php

use Go\Aop\Intercept\MethodInvocation;
use Go\Lang\Attribute\Aspect;
use Go\Lang\Attribute\Before;

#[Aspect]
class AspectExample /* or keep the old */ implements Aspect /* instead of the #[Aspect] */
{
    #[Before(
        public: true,
        class: TargetClass::class, // or "Namespace/Target*"
        method: "render", // or "get*"
    )]
    public function beforeMethodExecution(...)
    {
        // ...
    }
}

It would use the new named arguments syntax for PHP 8 which adds better typings and you could skip the whole execution(...) parsing, which would be faster I guess. It requires a lot of refactoring though

lisachenko commented 1 year ago

I would also like to hear your thoughts about a new and easier syntax style proposal:

<?php

use Go\Aop\Intercept\MethodInvocation;
use Go\Lang\Attribute\Aspect;
use Go\Lang\Attribute\Before;

#[Aspect]
class AspectExample /* or keep the old */ implements Aspect /* instead of the #[Aspect] */
{
    #[Before(
        public: true,
        class: TargetClass::class, // or "Namespace/Target*"
        method: "render", // or "get*"
    )]
    public function beforeMethodExecution(...)
    {
        // ...
    }
}

It would use the new named arguments syntax for PHP 8 which adds better typings and you could skip the whole execution(...) parsing, which would be faster I guess. It requires a lot of refactoring though

It looks good for me, assuming native attributes support - this looks logical šŸ‘

WalterWoshid commented 1 year ago

@lisachenko I read that you don't have much time to manage this framework. If you'd like, you could give me concrete tasks to do and so I could do them for you )

lisachenko commented 1 year ago

Oh, that's sounds sweet for me ) So, basically, you have almost done full the job already, let's collect and put all tasks one by one. Writing tasks in your main PR body now...

scrutinizer-notifier commented 1 year ago

A new inspection was created.

AmraniCh commented 10 months ago

hey, any news for PHP 8 support ?

WalterWoshid commented 10 months ago

Hi @AmraniCh, check out Okapi/AOP which is my own implementation of AOP for PHP :)

https://github.com/okapi-web/php-aop

AmraniCh commented 10 months ago

@WalterWoshid I already did, I think I do not have other options because our web application is running on PHP 8, however I would like to thank you for your effort in this package šŸ‘ If I see something needs to improve or fix I will open a PR!

HighLiuk commented 3 months ago

Hi @AmraniCh, check out Okapi/AOP which is my own implementation of AOP for PHP :)

https://github.com/okapi-web/php-aop

@WalterWoshid You saved my life! I starred your repo like number 1 šŸ”