The Artima Developer Community
Sponsored Link

PHP Buzz Forum
AspectPHP

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Sebastian Bergmann

Posts: 313
Nickname: sbergmann
Registered: Sep, 2004

Sebastian Bergmann is the developer of PHPUnit.
AspectPHP Posted: Mar 19, 2006 2:02 AM
Reply to this message Reply

This post originated from an RSS feed registered with PHP Buzz by Sebastian Bergmann.
Original Post: AspectPHP
Feed Title: Sebastian Bergmann
Feed URL: http://sebastian-bergmann.de/
Feed Description: Geek by nature, PHP by choice.
Latest PHP Buzz Posts
Latest PHP Buzz Posts by Sebastian Bergmann
Latest Posts From Sebastian Bergmann

Advertisement
As I wrote earlier, I am not satisfied with the Current State of AOP for PHP and started to work on AspectPHP a while ago. Today I am going to share my ideas on the subject.

What sets AspectPHP apart from other implementations of Aspect-Oriented Programming is its simplicity: aspects are plain PHP classes that declare pointcuts using annotations.

Inside a method that is used as an advice a special variable, $joinPoint, is available that contains all information relevant to the join point that triggered the execution of the advice.

The example belows shows how to declare an aspect that logs all method calls:
<?php
/**
 * An aspect that logs all method calls.
 *
 * Declare a new pointcut named callPointCut using the @pointcut
 * annotation that captures join points on a method regardless of
 * modifier, class, method, or number of parameters.
 * @pointcut callPointCut : call(* *->*(..));
 *
 * Bind the after() method of this aspect as an after-advice to the
 * previously declared pointcut.
 * @after callPointCut : LoggingAspect->after();
 */
class LoggingAspect
{
    public function after()
    {
        printf(
          "%s->%s() called %s->%s()\n",
 
          $joinPoint->getSource()->getDeclaringClass()->getName(),
          $joinPoint->getSource()->getName(),
          $joinPoint->getTarget()->getDeclaringClass()->getName(),
          $joinPoint->getTarget()->getName()
        );
    }
}
?>
Unfortunately, I am too busy with other projects (preparing for my final two exams and working on PHPUnit 3) and therefore cannot offer any downloadable code at this point.

I hope to make an initial code release within the next two months.

Read: AspectPHP

Topic: embarq.com Previous Topic   Next Topic Topic: Gollem File Manager H3 (1.0.2) released

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use