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

Roadmap #9

Closed
5 of 23 tasks
WalterWoshid opened this issue Jun 7, 2023 · 4 comments
Closed
5 of 23 tasks

Roadmap #9

WalterWoshid opened this issue Jun 7, 2023 · 4 comments
Labels
enhancement 🎆 New feature or request help wanted 🆘 Extra attention is needed

Comments

@WalterWoshid
Copy link
Contributor

WalterWoshid commented Jun 7, 2023

Roadmap

  • Explicit aspects (adding aspects directly to classes or methods): Implement Explicit Aspects #8

  • Create a flowchart (WIP)

  • Document how to use xdebug with php-unit tests that use the #[RunTestsInSeparateProcesses] attribute (PhpStorm)

  • Add support for Production/Development environments:

    • Production: Cache will not be checked for updates (better performance)
    • Development: Cache will be checked for updates (better debugging experience)
  • Test with Dependency Injection for aspects

  • Replace full proxy include dir with AOP_CACHE_DIR constant inside the proxy class

  • More advice types:

    • AfterThrowing
    • InsteadOf
    • DeclareParents
    • DeclareError
  • Adding aspects directly to properties

  • Implement Pointcuts

  • IDE plugins:

    • PhpStorm
    • VSCode
      • Highlight the code that will be intercepted
      • Show the list of aspects and their configuration
  • Complex advices for intercepting code structures and statements

  • Cache lifetime

  • Add exception handler to AopKernel

  • Separate Aspects and their attribute declarations: Roadmap #9 (comment)

  • Access declaration as a parameter: Roadmap #9 (comment)

  • Ignore already initialized Kernel: How to use with Laravel? #25 (comment)

  • Convert this stupid roadmap to issues lol

@WalterWoshid WalterWoshid added enhancement 🎆 New feature or request help wanted 🆘 Extra attention is needed labels Jun 7, 2023
@jakublabno
Copy link

jakublabno commented Jul 28, 2023

  1. Are you planning to change the way apsect are being declared?
    Current solution is not convenient at all, I want to initialize apsects as objects along with their dependencies
 protected array $aspects = [
        DiscountAspect::class,
        PaymentProcessorAspect::class,
    ];   
  1. Have you thought about separating aspects and their attributes declarations?
#[Aspect]
class CacheAspect 
{
    #[\Okapi\Aop\Attributes\Around(Cache::class)]
    public function around(\Okapi\Aop\Attributes\Around $invocation)
    {
        //it would be good to have access to method/attribute directly from $invocation
        $invocation->getDeclaration()->ttl;
    }
}

#[Attribute]
readonly class Cache
{
    public function __construct(public int $ttl) {}
}

@WalterWoshid
Copy link
Contributor Author

Hi @jakublabno,

  1. what do you mean exactly by "initialize aspects as objects"? Could you create an example of how that would look like? Even pseudo-code would be enough.

  2. I think that could be doable, I will add it to the roadmap.

Instead of accessing methods/attributes directly from $invocation, how about being able to add it as a parameter like this:

#[\Okapi\Aop\Attributes\Around(Cache::class)]
public function around(\Okapi\Aop\Attributes\Around $invocation, Cache $cache)
{
    $invocation->getDeclaration()->ttl;
    // or
    $cache->ttl;
}

Adding it directly to $invocation could create type conflicts and conflicts between methods/attributes, plus the IDE wouldn't know about the methods/attributes.

@jakublabno
Copy link

final class AopKernel extends \Okapi\Aop\AopKernel
{
    public function addAspect(Aspect $aspect): self
    {
        //add aspect as object, not only class reference
        
        return $this;
    }
    
    //or second options, allow to inject own dependency container from which aspects will be resolved
    public function setContainer(Container $container): void {}
}
  1. Sometimes attributes works together, so I want be able to get reflection of method/class to get different attributes, not only this one, however, additional, second parameter is a good idea for primary attribute.

@WalterWoshid
Copy link
Contributor Author

Moved to separate issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🎆 New feature or request help wanted 🆘 Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants