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 Compatibility Progress #1

Closed
25 of 58 tasks
WalterWoshid opened this issue Nov 20, 2022 · 5 comments
Closed
25 of 58 tasks

PHP: 8.0 Compatibility Progress #1

WalterWoshid opened this issue Nov 20, 2022 · 5 comments

Comments

@WalterWoshid
Copy link
Owner

WalterWoshid commented Nov 20, 2022

I am currently working on upgrading this library to be compatible with PHP 8.0 and 8.1. Since they introduced Attributes in PHP and thus deprecated the Doctrine Annotations, it is required to migrate to PHP attributes.

I am probably done with the update in less than a month, maybe even less than 2 weeks hopefully.

See Fork-branch

Changes

Click to show

Kernel

The kernel now looks like this:

<?php

namespace App\Aspect;

use App\Aspect\Aspects\ResponseAppender;
use Go\Core\AspectKernel;

class Kernel extends AspectKernel
{
    /**
     * # The application's aspects.
     *
     * These aspects will be applied to the application.
     *
     * Aspects should be marked with the {@link \Go\Lang\Attribute\Aspect #[Aspect]} attribute.
     *
     * @var array<int, class-string|string>
     */
    protected array $aspects = [
        ResponseAppender::class,
    ];
}

Aspects

Aspects now look like this:

<?php

namespace App\Aspect\Aspects;

use Go\Aop\Intercept\MethodInvocation;
use Go\Lang\Attribute\Aspect;
use Go\Lang\Attribute\Before;
use Go\Lang\Attribute\Execution;
use Inertia\ResponseFactory;

#[Aspect]
class ResponseAppender
{
    #[Before]
    #[Execution(
        public: true,
        class: ResponseFactory::class,
        method: 'render',
    )]
    public function beforeMethodExecution(MethodInvocation $invocation): void
    {
        $invocation->setArguments(['Hello new world!']);
    }
}

Bootstrapping

The bootstrapping/initialization now looks like this:

<?php

use App\Aspect\Kernel;

// Add AOP library
Kernel::init(
    debug:    true,
    appDir:   __DIR__ . '/..',
    cacheDir: __DIR__ . '/../storage/aop',
    includePaths: [
        __DIR__ . '/../vendor/inertiajs/inertia-laravel/src',
        __DIR__ . '/../app',
    ]
);

Progress

  • Replace the deprecated Doctrine Annotations with PHP attributes - Implement Attribute Parsing #2
    • After
      • Initialization/Usage
      • Parsing
      • PhpDoc Documentation
    • AfterThrowing
      • Initialization/Usage
      • Parsing
      • PhpDoc Documentation
    • And
      • Initialization/Usage
      • Parsing
      • PhpDoc Documentation
    • Around
      • Initialization/Usage
      • Parsing
      • PhpDoc Documentation
    • Aspect
      • Initialization/Usage
      • Parsing
      • PhpDoc Documentation
    • Before
      • Initialization/Usage
      • Parsing
      • PhpDoc Documentation
    • DeclareError
      • Initialization/Usage
      • Parsing
      • PhpDoc Documentation
    • DeclareParents
      • Initialization/Usage
      • Parsing
      • PhpDoc Documentation
    • Execution
      • Initialization/Usage
      • Parsing
      • PhpDoc Documentation
    • Not
      • Initialization/Usage
      • Parsing
      • PhpDoc Documentation
    • Or
      • Initialization/Usage
      • Parsing
      • PhpDoc Documentation
    • Pointcut
      • Initialization/Usage
      • Parsing
      • PhpDoc Documentation
  • Refactor Container services with the Singleton Pattern
  • Add JetBrains/phpstorm-attributes for better completions
  • Remove goaop-parser-reflection and replace with BetterReflection
  • Update Copyright comments
  • Replace Doctrine Cache with Symfony Cache
  • Improve overall code documentation
  • Edit README files - Edit README files #3
  • Faster parsing and rebuilding of source code and ast-tree (It was fast before, I didn't notice that modifying the current method was a bad decision
  • Rewrite tests - Rewrite Tests #4
@WalterWoshid
Copy link
Owner Author

goaop#486

@lisachenko
Copy link

@WalterWoshid really happy that you decided to work on PHP8 support 🎁 and goaop#486, this makes me happy ))

Wish you good luck and best wishes on this way!

@lisachenko
Copy link

lisachenko commented Nov 30, 2022

BTW, have you succeeded with integration of BetterReflection with goaop? I have spent few hours trying to switch to BR instead of goaop/parser-reflection but without any success.

On a long run - this will be logical step to switch from own parsing library (which requires maintenance) to BR, which is now used in many places, including phpstan, for example.

@WalterWoshid
Copy link
Owner Author

@WalterWoshid really happy that you decided to work on PHP8 support 🎁 and goaop#486, this makes me happy ))

I really love aspect oriented programming! And this is a great library :)

@WalterWoshid
Copy link
Owner Author

BTW, have you succeeded with integration of BetterReflection with goaop?

I had some difficulties with locating source files, but I think I was very close on fork-2 or fork-3 with implementing it. Once done with attribute support for goaop/parser-reflection I will implement BetterReflection!

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

No branches or pull requests

2 participants