Re: Aspect Oriented Programming in PHP

From: Date: Fri, 24 Aug 2012 21:00:25 +0000
Subject: Re: Aspect Oriented Programming in PHP
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-62458@lists.php.net to get a copy of this message
On Fri, 24 Aug 2012 19:18:40 +0200, Anthony Ferrara <ircmaxell@gmail.com> wrote:
Just a pedantic note here. You don't need any special functionality to do AOP style programming in PHP. In fact, this use-case is the exact definition of a Decorator. Instead of hooking in with a function call and cut-points, you would just decorate the object you want to interact with, and you're set. Then just add your functionality where it's needed.
I think you're missing the fundamental difference between decorators and AOP or interceptors. Decorators augment the object with domain-specific additions, while interceptors are more appropriate for orthogonal concerns. CDI (JSR 299/346) has both. Their interceptors are slightly different from traditional AOP in that you don't have the usual pointcut syntax, and decoration is done is done automatically upon injection. You might want to take a look nevertheless; this is the weld (CDI reference implementation) documentation: * http://docs.jboss.org/weld/reference/latest/en-US/html/interceptors.html * http://docs.jboss.org/weld/reference/latest/en-US/html/decorators.html -- Gustavo Lopes

« previous php.internals (#62458) next »