├── .gitignore ├── tests ├── bootstrap.php ├── .atoum.php └── units │ └── Aop │ └── Aop.php ├── src └── Aop │ ├── Introduction.php │ ├── Exception │ ├── KindException.php │ ├── AdviceException.php │ ├── AspectException.php │ ├── SpecException.php │ ├── WeaverException.php │ ├── PointcutException.php │ ├── JoinPointException.php │ ├── InterceptorException.php │ ├── IntroductionException.php │ └── AopException.php │ ├── JoinPoint │ ├── AfterJoinPoint.php │ ├── BeforeJoinPoint.php │ ├── AroundJoinPoint.php │ ├── Support │ │ ├── PointcutSupportInterface.php │ │ ├── ExceptionGetterSupportInterface.php │ │ ├── PropertyValueGetterSupportInterface.php │ │ ├── ArgsGetterSupportInterface.php │ │ ├── PropertyValueSetterSupportInterface.php │ │ ├── ReturnValueSetterSupportInterface.php │ │ ├── ArgsSetterSupportInterface.php │ │ ├── KindSupportInterface.php │ │ ├── ProceedSupportInterface.php │ │ ├── ReturnValueGetterSupportInterface.php │ │ ├── JoinPointSupportInterceptorInterface.php │ │ ├── MethodSupportInterface.php │ │ ├── FunctionSupportInterface.php │ │ ├── PropertySupportInterface.php │ │ └── ClassSupportInterface.php │ ├── Traits │ │ ├── ProceedTrait.php │ │ ├── ArgsGetterTrait.php │ │ ├── ArgsSetterTrait.php │ │ ├── ExceptionGetterTrait.php │ │ ├── MethodTrait.php │ │ ├── FunctionTrait.php │ │ ├── PropertyTrait.php │ │ ├── ReturnValueGetterTrait.php │ │ ├── PropertyValueGetterTrait.php │ │ ├── ReturnValueSetterTrait.php │ │ ├── PropertyValueSetterTrait.php │ │ ├── PointcutTrait.php │ │ ├── ClassTrait.php │ │ ├── ReflectionFunctionTrait.php │ │ ├── ReflectionPropertyTrait.php │ │ ├── ReflectionClassTrait.php │ │ └── ReflectionMethodTrait.php │ ├── AfterPropertyReadJoinPoint.php │ ├── AroundPropertyReadJoinPoint.php │ ├── BeforePropertyReadJoinPoint.php │ ├── BeforeFunctionJoinPoint.php │ ├── BeforeMethodJoinPoint.php │ ├── AfterPropertyJoinPoint.php │ ├── AfterFunctionThrowJoinPoint.php │ ├── AfterPropertyWriteJoinPoint.php │ ├── AroundPropertyJoinPoint.php │ ├── BeforePropertyJoinPoint.php │ ├── AfterFunctionReturnJoinPoint.php │ ├── AroundPropertyWriteJoinPoint.php │ ├── BeforePropertyWriteJoinPoint.php │ ├── AfterMethodThrowJoinPoint.php │ ├── AroundFunctionJoinPoint.php │ ├── AfterMethodReturnJoinPoint.php │ ├── AfterFunctionJoinPoint.php │ ├── AroundMethodJoinPoint.php │ ├── AfterMethodJoinPoint.php │ └── JoinPoint.php │ ├── Pointcut │ ├── PointcutCollection.php │ ├── Pointcut.php │ └── PointcutInterface.php │ ├── Aspect │ ├── AspectCollection.php │ ├── LazyAspect.php │ └── AspectInterface.php │ ├── Advice │ ├── AdviceCollection.php │ ├── AdviceInterface.php │ └── LazyAdvice.php │ ├── CollectionInterface.php │ ├── Traits │ └── OptionTrait.php │ ├── Weaver │ ├── Interceptor.php │ ├── Weaver.php │ └── WeaverInterface.php │ ├── Collection.php │ ├── KindConstantInterface.php │ └── Aop.php ├── composer.json ├── .php_cs ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.phar 3 | composer.lock 4 | .DS_Store 5 | Thumbs.db 6 | /.Trash-1000 -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop; 13 | 14 | /** 15 | * TODO: Code introduction 16 | * 17 | * @author Nicolas Tallefourtane 18 | */ 19 | class Introduction 20 | { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/Aop/Exception/KindException.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Exception; 13 | 14 | /** 15 | * KindException thrown if an error on kind occurs. 16 | * 17 | * @author Nicolas Tallefourtane 18 | */ 19 | class KindException extends AopException {} 20 | -------------------------------------------------------------------------------- /src/Aop/Exception/AdviceException.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Exception; 13 | 14 | /** 15 | * AdviceException thrown if an error on advice occurs. 16 | * 17 | * @author Nicolas Tallefourtane 18 | */ 19 | class AdviceException extends AopException {} 20 | -------------------------------------------------------------------------------- /src/Aop/Exception/AspectException.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Exception; 13 | 14 | /** 15 | * AspectException thrown if an error on aspect occurs. 16 | * 17 | * @author Nicolas Tallefourtane 18 | */ 19 | class AspectException extends AopException {} 20 | -------------------------------------------------------------------------------- /src/Aop/Exception/SpecException.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Exception; 13 | 14 | /** 15 | * SpecException thrown if an error on specification occurs. 16 | * 17 | * @author Nicolas Tallefourtane 18 | */ 19 | class SpecException extends AopException {} 20 | -------------------------------------------------------------------------------- /src/Aop/Exception/WeaverException.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Exception; 13 | 14 | /** 15 | * WeaverException thrown if an error on the weaver occurs. 16 | * 17 | * @author Nicolas Tallefourtane 18 | */ 19 | class WeaverException extends AopException {} 20 | -------------------------------------------------------------------------------- /src/Aop/Exception/PointcutException.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Exception; 13 | 14 | /** 15 | * PointcutException thrown if an error on pointcut occurs. 16 | * 17 | * @author Nicolas Tallefourtane 18 | */ 19 | class PointcutException extends AopException {} 20 | -------------------------------------------------------------------------------- /src/Aop/Exception/JoinPointException.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Exception; 13 | 14 | /** 15 | * JoinPointException thrown if an error on joinpoint occurs. 16 | * 17 | * @author Nicolas Tallefourtane 18 | */ 19 | class JoinPointException extends AopException {} 20 | -------------------------------------------------------------------------------- /src/Aop/Exception/InterceptorException.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Exception; 13 | 14 | /** 15 | * InterceptorException thrown if an error on interceptor occurs. 16 | * 17 | * @author Nicolas Tallefourtane 18 | */ 19 | class InterceptorException extends WeaverException {} 20 | -------------------------------------------------------------------------------- /src/Aop/Exception/IntroductionException.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Exception; 13 | 14 | /** 15 | * IntroductionException thrown if an error on code introduction occurs. 16 | * 17 | * @author Nicolas Tallefourtane 18 | */ 19 | class IntroductionException extends AopException {} 20 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/AfterJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Base class for all `JoinPoint` abstraction layers of kind 17 | * `\Aop\KindConstantInterface::KIND_AFTER`. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_AFTER 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | abstract class AfterJoinPoint extends JoinPoint 24 | { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/BeforeJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Base class for all `JoinPoint` abstraction layers of kind 17 | * `\Aop\KindConstantInterface::KIND_BEFORE`. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_BEFORE 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | abstract class BeforeJoinPoint extends JoinPoint 24 | { 25 | 26 | } 27 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aop-io/php-aop", 3 | "description": "Implements a simplified subset of AOP pragmatism and provides the AOP (Aspect Oriented Programming) features for PHP.", 4 | "keywords": ["aop", "lib", "patch monkey", "ioc", "injection", "interceptor", "event"], 5 | "license": "MIT", 6 | "homepage": "http://aop.io", 7 | 8 | "authors": [ 9 | { 10 | "name": "Nicolas Tallefourtane", 11 | "email": "dev@nicolab.net", 12 | "homepage": "http://nicolab.net" 13 | } 14 | ], 15 | "require": { 16 | "php": ">=5.4" 17 | }, 18 | "suggest": { 19 | "aop-io/pecl-aop-interceptor": "Interceptor using the PECL AOP extension." 20 | }, 21 | "autoload": { 22 | "psr-0": {"Aop": "src/"} 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/AroundJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Base class for all `JoinPoint` abstraction layers of kind 17 | * `\Aop\KindConstantInterface::KIND_AROUND`. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_AROUND 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | abstract class AroundJoinPoint extends JoinPoint implements Support\ProceedSupportInterface 24 | { 25 | use Traits\ProceedTrait; 26 | } 27 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Support/PointcutSupportInterface.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Support; 13 | 14 | /** 15 | * PointcutSupportInterface provides the accessor method to get the current point cut. 16 | * 17 | * @author Nicolas Tallefourtane 18 | */ 19 | interface PointcutSupportInterface 20 | { 21 | /** 22 | * Get the point cut that triggered the join point. 23 | * 24 | * @return \Aop\Pointcut\PointcutInterface The Pointcut instance. 25 | */ 26 | public function getPointcut(); 27 | } 28 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/ProceedTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\ProceedSupportInterface` 16 | * 17 | * @see \Aop\JoinPoint\Support\ProceedSupportInterface 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | trait ProceedTrait 22 | { 23 | /** 24 | * @see \Aop\JoinPoint\Support\ProceedSupportInterface::proceed() 25 | */ 26 | public function proceed() 27 | { 28 | return $this->support->proceed(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/ArgsGetterTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\ArgsGetterSupportInterface` 16 | * 17 | * @see \Aop\JoinPoint\Support\ArgsGetterSupportInterface 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | trait ArgsGetterTrait 22 | { 23 | /** 24 | * @see \Aop\JoinPoint\Support\ArgsGetterSupportInterface::getArgs() 25 | */ 26 | public function getArgs() 27 | { 28 | return $this->support->getArgs(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Support/ExceptionGetterSupportInterface.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Support; 13 | 14 | /** 15 | * ExceptionGetterSupportInterface provides the accessor method to get a PHP Exception intercepted. 16 | * 17 | * @author Nicolas Tallefourtane 18 | */ 19 | interface ExceptionGetterSupportInterface 20 | { 21 | /** 22 | * Get the PHP Exception thrown and intercepted. 23 | * 24 | * @return \Exception The instance of the PHP Exception intercepted. 25 | */ 26 | public function getException(); 27 | } 28 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Support/PropertyValueGetterSupportInterface.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Support; 13 | 14 | /** 15 | * PropertyValueGetterSupportInterface provides the accessor method 16 | * to get the value of a property intercepted. 17 | * 18 | * @author Nicolas Tallefourtane 19 | */ 20 | interface PropertyValueGetterSupportInterface 21 | { 22 | /** 23 | * Get the value of the current property intercepted. 24 | * 25 | * @return mixed The property value. 26 | */ 27 | public function getPropertyValue(); 28 | } 29 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/ArgsSetterTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\ArgsSetterSupportInterface` 16 | * 17 | * @see \Aop\JoinPoint\Support\ArgsSetterSupportInterface 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | trait ArgsSetterTrait 22 | { 23 | /** 24 | * @see \Aop\JoinPoint\Support\ArgsSetterSupportInterface::setArgs() 25 | */ 26 | public function setArgs(array $args) 27 | { 28 | return $this->support->setArgs($args); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Support/ArgsGetterSupportInterface.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Support; 13 | 14 | /** 15 | * ArgsGetterSupportInterface provides the accessor method to get the arguments values 16 | * of a callable (function or method) intercepted. 17 | * 18 | * @author Nicolas Tallefourtane 19 | */ 20 | interface ArgsGetterSupportInterface 21 | { 22 | /** 23 | * Get the arguments of the current callable intercepted. 24 | * 25 | * @return array An array of arguments. 26 | */ 27 | public function getArgs(); 28 | } 29 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Support/PropertyValueSetterSupportInterface.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Support; 13 | 14 | /** 15 | * PropertyValueSetterSupportInterface provides the accessor method 16 | * to set the value of a property intercepted. 17 | * 18 | * @author Nicolas Tallefourtane 19 | */ 20 | interface PropertyValueSetterSupportInterface 21 | { 22 | /** 23 | * Set the value of the current property intercepted. 24 | * 25 | * @param mixed $value The new property value. 26 | */ 27 | public function setPropertyValue($value); 28 | } 29 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/ExceptionGetterTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\ExceptionGetterSupportInterface` 16 | * 17 | * @see \Aop\JoinPoint\Support\ExceptionGetterSupportInterface 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | trait ExceptionGetterTrait 22 | { 23 | /** 24 | * @see \Aop\JoinPoint\Support\ExceptionGetterSupportInterface::getException() 25 | */ 26 | public function getException() 27 | { 28 | return $this->support->getException(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/MethodTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\MethodSupportInterface` 16 | * 17 | * @see \Aop\JoinPoint\Support\MethodSupportInterface 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | trait MethodTrait 22 | { 23 | use ReflectionMethodTrait; 24 | 25 | /** 26 | * @see \Aop\JoinPoint\Support\MethodSupportInterface::getMethodName() 27 | */ 28 | public function getMethodName() 29 | { 30 | return $this->support->getMethodName(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Support/ReturnValueSetterSupportInterface.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Support; 13 | 14 | /** 15 | * ReturnValueSetterSupportInterface provides the accessor method 16 | * to set the return value of a callable (function or method) intercepted. 17 | * 18 | * @author Nicolas Tallefourtane 19 | */ 20 | interface ReturnValueSetterSupportInterface 21 | { 22 | /** 23 | * Set the value of the current callable intercepted. 24 | * 25 | * @param mixed $value The new value to return. 26 | */ 27 | public function setReturnValue($value); 28 | } 29 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/FunctionTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\FunctionSupportInterface` 16 | * 17 | * @see \Aop\JoinPoint\Support\FunctionSupportInterface 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | trait FunctionTrait 22 | { 23 | use ReflectionFunctionTrait; 24 | 25 | /** 26 | * @see \Aop\JoinPoint\Support\FunctionSupportInterface::getFunctionName() 27 | */ 28 | public function getFunctionName() 29 | { 30 | return $this->support->getFunctionName(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/PropertyTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\PropertySupportInterface` 16 | * 17 | * @see \Aop\JoinPoint\Support\PropertySupportInterface 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | trait PropertyTrait 22 | { 23 | use ReflectionPropertyTrait; 24 | 25 | /** 26 | * @see \Aop\JoinPoint\Support\PropertySupportInterface::getPropertyName() 27 | */ 28 | public function getPropertyName() 29 | { 30 | return $this->support->getPropertyName(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/ReturnValueGetterTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\ReturnValueGetterSupportInterface`. 16 | * 17 | * @see \Aop\JoinPoint\Support\ReturnValueGetterSupportInterface 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | trait ReturnValueGetterTrait 22 | { 23 | /** 24 | * @see \Aop\JoinPoint\Support\ReturnValueGetterSupportInterface::getReturnValue() 25 | */ 26 | public function &getReturnValue() 27 | { 28 | return $this->support->getReturnValue(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/PropertyValueGetterTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `Aop\JoinPoint\Support\PropertyValueGetterSupportInterface` 16 | * 17 | * @see \Aop\JoinPoint\Support\PropertyValueGetterSupportInterface 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | trait PropertyValueGetterTrait 22 | { 23 | /** 24 | * @see \Aop\JoinPoint\Support\PropertyValueGetterSupportInterface::getPropertyValue() 25 | */ 26 | public function getPropertyValue() 27 | { 28 | return $this->support->getPropertyValue(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/ReturnValueSetterTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support the `\Aop\JoinPoint\Support\ReturnValueSetterSupportInterface`. 16 | * 17 | * @see \Aop\JoinPoint\Support\ReturnValueSetterSupportInterface 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | trait ReturnValueSetterTrait 22 | { 23 | /** 24 | * @see \Aop\JoinPoint\Support\ReturnValueSetterSupportInterface::setReturnValue() 25 | */ 26 | public function setReturnValue($value) 27 | { 28 | return $this->support->setReturnValue($value); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/PropertyValueSetterTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\PropertyValueSetterSupportInterface` 16 | * 17 | * @see \Aop\JoinPoint\Support\PropertyValueSetterSupportInterface 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | trait PropertyValueSetterTrait 22 | { 23 | /** 24 | * @see \Aop\JoinPoint\Support\PropertyValueSetterSupportInterface::setPropertyValue() 25 | */ 26 | public function setPropertyValue($value) 27 | { 28 | return $this->support->setPropertyValue($value); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.php_cs: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane http://nicolab.net 11 | */ 12 | 13 | // Rules for php-cs-fixer 14 | 15 | $finder = Symfony\CS\Finder\DefaultFinder::create() 16 | ->in(__DIR__.'/src') 17 | ; 18 | 19 | return Symfony\CS\Config\Config::create() 20 | ->fixers(array( 21 | 'indentation', 22 | 'linefeed', 23 | 'trailing_spaces', 24 | 'unused_use', 25 | 'visibility', 26 | 'php_closing_tag', 27 | 'braces', 28 | 'extra_empty_lines', 29 | 'eof_ending', 30 | 'function_declaration', 31 | 'controls_spaces', 32 | 'psr0', 33 | 'elseif', 34 | 'phpdoc_params', 35 | )) 36 | ->finder($finder) 37 | ; -------------------------------------------------------------------------------- /src/Aop/Exception/AopException.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Exception; 13 | 14 | /** 15 | * AopException thrown if an error on AOP occurs. 16 | * 17 | * AopException is the base PHP Exception for all AOP exceptions. 18 | * 19 | * PHP AOP.io provides a set of standard exceptions. 20 | * All AOP exceptions are inherited from `AopException`. 21 | * So, in general way, you can test any AOP errors by AopException. 22 | * 23 | * `AopException` thrown directly only concerning the domains which are not handled 24 | * by the other AOP exception class. 25 | * 26 | * @see \Aop\Exception 27 | * 28 | * @author Nicolas Tallefourtane 29 | */ 30 | class AopException extends \Exception {} 31 | -------------------------------------------------------------------------------- /src/Aop/Pointcut/PointcutCollection.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Pointcut; 13 | 14 | use Aop\Collection; 15 | 16 | /** 17 | * A collection (`\Aop\Collection`) of `Pointcut` instance. 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | class PointcutCollection extends Collection 22 | { 23 | /** 24 | * Add a `Pointcut` in the `PointcutCollection`. 25 | * 26 | * @param \Aop\Pointcut\PointcutInterface $pointcut 27 | * @return PointcutCollection The current instance. 28 | */ 29 | public function add(PointcutInterface $pointcut) 30 | { 31 | $this->container[$pointcut->getName()] = $pointcut; 32 | 33 | return $this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Aop/Aspect/AspectCollection.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Aspect; 13 | 14 | use Aop\Collection; 15 | 16 | /** 17 | * A collection (`\Aop\Collection`) of aspects. 18 | * 19 | * @see \Aop\Collection 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | class AspectCollection extends Collection 24 | { 25 | /** 26 | * Add an aspect in the `AspectCollection`. 27 | * 28 | * @param \Aop\Aspect\AspectInterface $aspect 29 | * @return \Aop\Aspect\AspectCollection The current instance. 30 | */ 31 | public function add(AspectInterface $aspect) 32 | { 33 | $this->container[$aspect->getName()] = $aspect; 34 | 35 | return $this; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Aop/Advice/AdviceCollection.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Advice; 13 | 14 | use Aop\Collection; 15 | 16 | /** 17 | * A collection (`\Aop\Collection`) of advices. 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | class AdviceCollection extends Collection 22 | { 23 | /** 24 | * Add an advice in the `AdviceCollection` 25 | * 26 | * @param \Aop\Advice\AdviceInterface $advice An advice instance. 27 | * @return \Aop\Advice\AdviceCollection The current `AdviceCollection` instance. 28 | */ 29 | public function add(AdviceInterface $advice) 30 | { 31 | $this->container[$advice->getName()] = $advice; 32 | 33 | return $this; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Support/ArgsSetterSupportInterface.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Support; 13 | 14 | /** 15 | * ArgsSetterSupportInterface provides the accessor method to set the arguments values 16 | * of a callable (function or method) intercepted. 17 | * 18 | * @author Nicolas Tallefourtane 19 | */ 20 | interface ArgsSetterSupportInterface 21 | { 22 | /** 23 | * Set the arguments of the current callable intercepted. 24 | * Note: if you want to keep references, you will have to explicitly pass them back 25 | * to `setArgs()` method. 26 | * 27 | * @param array $args An array with the new values of arguments. 28 | */ 29 | public function setArgs(array $args); 30 | } 31 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/PointcutTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\PointcutSupportInterface` 16 | * 17 | * @see \Aop\JoinPoint\Support\PointcutSupportInterface 18 | * @see \Aop\Pointcut\PointcutInterface 19 | * 20 | * @author Nicolas Tallefourtane 21 | */ 22 | trait PointcutTrait 23 | { 24 | /** 25 | * The pointcut that triggered the current JoinPoint. 26 | * @var \Aop\Pointcut\PointcutInterface 27 | */ 28 | protected $pointcut; 29 | 30 | /** 31 | * @see \Aop\JoinPoint\Support\PointcutSupportInterface::getPointcut() 32 | */ 33 | public function getPointcut() 34 | { 35 | return $this->pointcut; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Support/KindSupportInterface.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Support; 13 | 14 | /** 15 | * KindSupportInterface provides the method to get the kind of the current interception. 16 | * The kind of JoinPoint depends on the context of the aspect. 17 | * 18 | * @author Nicolas Tallefourtane 19 | */ 20 | interface KindSupportInterface 21 | { 22 | /** 23 | * Get the kind of JoinPoint. 24 | * This indicates the invocation context of an advice. 25 | * 26 | * @see \Aop\Aop::getKindName() 27 | * @see \Aop\Aop::getKinds() 28 | * @see \Aop\Aop::isValidKind() 29 | * 30 | * @return int The constant value (`\Aop\KindConstantInterface::KIND_*`). 31 | */ 32 | public function getKind(); 33 | } 34 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Support/ProceedSupportInterface.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Support; 13 | 14 | /** 15 | * ProceedSupportInterface provides the method to proceed explicitly 16 | * to the execution of the callable (function or method) intercepted. 17 | * 18 | * @author Nicolas Tallefourtane 19 | */ 20 | interface ProceedSupportInterface 21 | { 22 | /** 23 | * The `proceed()` method allows you to explicitly launch the triggering of the item intercepted: 24 | * function, method or property operation (read / write). 25 | * The `proceed()` method will only be available for advice of kind `around`. 26 | * 27 | * @return mixed The value of the callable intercepted. 28 | */ 29 | public function proceed(); 30 | } 31 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/ClassTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\ClassSupportInterface` 16 | * 17 | * @see \Aop\JoinPoint\Support\ClassSupportInterface 18 | * 19 | * @author Nicolas Tallefourtane 20 | */ 21 | trait ClassTrait 22 | { 23 | use ReflectionClassTrait; 24 | 25 | /** 26 | * @see \Aop\JoinPoint\Support\ClassSupportInterface::getClassName() 27 | */ 28 | public function getClassName() 29 | { 30 | return $this->support->getClassName(); 31 | } 32 | 33 | /** 34 | * @see \Aop\JoinPoint\Support\ClassSupportInterface::getObject() 35 | */ 36 | public function getObject() 37 | { 38 | return $this->support->getObject(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Support/ReturnValueGetterSupportInterface.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Support; 13 | 14 | /** 15 | * ReturnValueGetterSupportInterface provides the accessor method 16 | * to get the returned value of a callable (function or method) intercepted. 17 | * 18 | * @author Nicolas Tallefourtane 19 | */ 20 | interface ReturnValueGetterSupportInterface 21 | { 22 | /** 23 | * Get the returned value by the current callable intercepted. 24 | * 25 | * If in an advice of kind `around` the method `getReturnValue()` is called before 26 | * the execution of the `proceed()` method, a `JoinPointException` is thrown. 27 | * 28 | * @return &mixed The value returned (by reference). 29 | */ 30 | public function &getReturnValue(); 31 | } 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | AOP.io 2 | The MIT License (MIT) 3 | 4 | Copyright (c) 2013 Nicolas Tallefourtane dev@nicolab.net 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files (the 8 | "Software"), to deal in the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 22 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/Aop/JoinPoint/AfterPropertyReadJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_AFTER_PROPERTY_READ` handled by the interceptor. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_AFTER_PROPERTY_READ 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | class AfterPropertyReadJoinPoint extends AfterJoinPoint implements 24 | Support\ClassSupportInterface, 25 | Support\PropertySupportInterface 26 | { 27 | use 28 | Traits\ClassTrait, 29 | Traits\PropertyTrait 30 | ; 31 | 32 | /** 33 | * @inheritdoc 34 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 35 | */ 36 | public function getKind() 37 | { 38 | return \Aop\KindConstantInterface::KIND_AFTER_PROPERTY_READ; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/AroundPropertyReadJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_AROUND_PROPERTY_READ` handled by the interceptor. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_AROUND_PROPERTY_READ 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | class AroundPropertyReadJoinPoint extends AroundJoinPoint implements 24 | Support\ClassSupportInterface, 25 | Support\PropertySupportInterface 26 | { 27 | use 28 | Traits\ClassTrait, 29 | Traits\PropertyTrait 30 | ; 31 | 32 | /** 33 | * @inheritdoc 34 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 35 | */ 36 | public function getKind() 37 | { 38 | return \Aop\KindConstantInterface::KIND_AROUND_PROPERTY_READ; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/BeforePropertyReadJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_BEFORE_PROPERTY_READ` handled by the interceptor. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_BEFORE_PROPERTY_READ 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | class BeforePropertyReadJoinPoint extends BeforeJoinPoint implements 24 | Support\ClassSupportInterface, 25 | Support\PropertySupportInterface 26 | { 27 | use 28 | Traits\ClassTrait, 29 | Traits\PropertyTrait 30 | ; 31 | 32 | /** 33 | * @inheritdoc 34 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 35 | */ 36 | public function getKind() 37 | { 38 | return \Aop\KindConstantInterface::KIND_BEFORE_PROPERTY_READ; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tests/.atoum.php: -------------------------------------------------------------------------------- 1 | addDefaultReport(); 16 | 17 | //* 18 | //LOGO 19 | 20 | // This will add the atoum logo before each run. 21 | //$report->addField(new atoum\report\fields\runner\atoum\logo()); 22 | 23 | // This will add a green or red logo after each run depending on its status. 24 | $report->addField(new atoum\report\fields\runner\result\logo()); 25 | //*/ 26 | 27 | /* 28 | //CODE COVERAGE SETUP 29 | 30 | // Destination directory path for html files. 31 | $coverageField = new atoum\report\fields\runner\coverage\html( 32 | 'aop-io/php-aop', __DIR__.'/../doc/html/code-coverage' 33 | ); 34 | 35 | // Root url of the code coverage web site. 36 | $coverageField->setRootUrl('http://aop.io'); 37 | 38 | 39 | $report->addField($coverageField); 40 | //*/ 41 | 42 | $script->bootstrapFile(__DIR__. '/bootstrap.php'); 43 | $runner->addTestsFromDirectory(__DIR__. '/units'); 44 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/BeforeFunctionJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_BEFORE_FUNCTION` handled by the interceptor. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_BEFORE_FUNCTION 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | class BeforeFunctionJoinPoint extends BeforeJoinPoint implements 24 | Support\FunctionSupportInterface, 25 | Support\ArgsGetterSupportInterface, 26 | Support\ArgsSetterSupportInterface 27 | { 28 | use 29 | Traits\FunctionTrait, 30 | Traits\ArgsGetterTrait, 31 | Traits\ArgsSetterTrait 32 | ; 33 | 34 | /** 35 | * @inheritdoc 36 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 37 | */ 38 | public function getKind() 39 | { 40 | return \Aop\KindConstantInterface::KIND_BEFORE_FUNCTION; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/BeforeMethodJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_BEFORE_METHOD` handled by the interceptor. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_BEFORE_METHOD 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | class BeforeMethodJoinPoint extends BeforeJoinPoint implements 24 | Support\ClassSupportInterface, 25 | Support\MethodSupportInterface, 26 | Support\ArgsGetterSupportInterface, 27 | Support\ArgsSetterSupportInterface 28 | { 29 | use 30 | Traits\ClassTrait, 31 | Traits\MethodTrait, 32 | Traits\ArgsGetterTrait, 33 | Traits\ArgsSetterTrait 34 | ; 35 | 36 | /** 37 | * @inheritdoc 38 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 39 | */ 40 | public function getKind() 41 | { 42 | return \Aop\KindConstantInterface::KIND_BEFORE_METHOD; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/AfterPropertyJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_AFTER_PROPERTY` (write and read) handled by the interceptor. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_AFTER_PROPERTY 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | class AfterPropertyJoinPoint extends AfterJoinPoint implements 24 | Support\ClassSupportInterface, 25 | Support\PropertySupportInterface, 26 | Support\PropertyValueGetterSupportInterface, 27 | Support\PropertyValueSetterSupportInterface 28 | { 29 | use 30 | Traits\ClassTrait, 31 | Traits\PropertyTrait, 32 | Traits\PropertyValueGetterTrait, 33 | Traits\PropertyValueSetterTrait 34 | ; 35 | 36 | /** 37 | * @inheritdoc 38 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 39 | */ 40 | public function getKind() 41 | { 42 | return \Aop\KindConstantInterface::KIND_AFTER_PROPERTY; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/AfterFunctionThrowJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_AFTER_FUNCTION_THROW` handled by the interceptor. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_AFTER_FUNCTION_THROW 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | class AfterFunctionThrowJoinPoint extends AfterJoinPoint implements 24 | Support\FunctionSupportInterface, 25 | Support\ArgsGetterSupportInterface, 26 | Support\ExceptionGetterSupportInterface, 27 | Support\ReturnValueSetterSupportInterface 28 | { 29 | use 30 | Traits\FunctionTrait, 31 | Traits\ArgsGetterTrait, 32 | Traits\ExceptionGetterTrait, 33 | Traits\ReturnValueSetterTrait 34 | ; 35 | 36 | /** 37 | * @inheritdoc 38 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 39 | */ 40 | public function getKind() 41 | { 42 | return \Aop\KindConstantInterface::KIND_AFTER_FUNCTION_THROW; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/AfterPropertyWriteJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_AFTER_PROPERTY_WRITE` handled by the interceptor. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_AFTER_PROPERTY_WRITE 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | class AfterPropertyWriteJoinPoint extends AfterJoinPoint implements 24 | Support\ClassSupportInterface, 25 | Support\PropertySupportInterface, 26 | Support\PropertyValueGetterSupportInterface, 27 | Support\PropertyValueSetterSupportInterface 28 | { 29 | use 30 | Traits\ClassTrait, 31 | Traits\PropertyTrait, 32 | Traits\PropertyValueGetterTrait, 33 | Traits\PropertyValueSetterTrait 34 | ; 35 | 36 | /** 37 | * @inheritdoc 38 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 39 | */ 40 | public function getKind() 41 | { 42 | return \Aop\KindConstantInterface::KIND_AFTER_PROPERTY_WRITE; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/AroundPropertyJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_AROUND_PROPERTY` (write and read) handled by 18 | * the interceptor. 19 | * 20 | * @see \Aop\KindConstantInterface::KIND_AROUND_PROPERTY 21 | * 22 | * @author Nicolas Tallefourtane 23 | */ 24 | class AroundPropertyJoinPoint extends AroundJoinPoint implements 25 | Support\ClassSupportInterface, 26 | Support\PropertySupportInterface, 27 | Support\PropertyValueGetterSupportInterface, 28 | Support\PropertyValueSetterSupportInterface 29 | { 30 | use 31 | Traits\ClassTrait, 32 | Traits\PropertyTrait, 33 | Traits\PropertyValueGetterTrait, 34 | Traits\PropertyValueSetterTrait 35 | ; 36 | 37 | /** 38 | * @inheritdoc 39 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 40 | */ 41 | public function getKind() 42 | { 43 | return \Aop\KindConstantInterface::KIND_AROUND_PROPERTY; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/BeforePropertyJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_BEFORE_PROPERTY` (write and read) 18 | * handled by the interceptor. 19 | * 20 | * @see \Aop\KindConstantInterface::KIND_BEFORE_PROPERTY 21 | * 22 | * @author Nicolas Tallefourtane 23 | */ 24 | class BeforePropertyJoinPoint extends BeforeJoinPoint implements 25 | Support\ClassSupportInterface, 26 | Support\PropertySupportInterface, 27 | Support\PropertyValueGetterSupportInterface, 28 | Support\PropertyValueSetterSupportInterface 29 | { 30 | use 31 | Traits\ClassTrait, 32 | Traits\PropertyTrait, 33 | Traits\PropertyValueGetterTrait, 34 | Traits\PropertyValueSetterTrait 35 | ; 36 | 37 | /** 38 | * @inheritdoc 39 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 40 | */ 41 | public function getKind() 42 | { 43 | return \Aop\KindConstantInterface::KIND_BEFORE_PROPERTY; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/ReflectionFunctionTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\FunctionSupportInterface`. 16 | * This trait provides a reflector for the `JoinPoint` classes of kind `function`. 17 | * 18 | * @see \Aop\JoinPoint\Support\FunctionSupportInterface 19 | * 20 | * @author Nicolas Tallefourtane 21 | */ 22 | trait ReflectionFunctionTrait 23 | { 24 | /** 25 | * @see \Aop\JoinPoint\Support\FunctionSupportInterface::createReflectionFunction() 26 | */ 27 | public function createReflectionFunction() 28 | { 29 | return new \ReflectionFunction($this->getFunctionName()); 30 | } 31 | 32 | /** 33 | * @see \Aop\JoinPoint\Support\FunctionSupportInterface::getReflectionFunction() 34 | */ 35 | public function getReflectionFunction($singleton = true) 36 | { 37 | static $ref; // singleton 38 | 39 | if($singleton && $ref) { 40 | return $ref; 41 | } 42 | 43 | return $ref = $this->createReflectionFunction(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/AfterFunctionReturnJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_AFTER_FUNCTION_RETURN` handled by the interceptor. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_AFTER_FUNCTION_RETURN 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | class AfterFunctionReturnJoinPoint extends AfterJoinPoint implements 24 | Support\FunctionSupportInterface, 25 | Support\ArgsGetterSupportInterface, 26 | Support\ReturnValueGetterSupportInterface, 27 | Support\ReturnValueSetterSupportInterface 28 | { 29 | use 30 | Traits\FunctionTrait, 31 | Traits\ArgsGetterTrait, 32 | Traits\ReturnValueGetterTrait, 33 | Traits\ReturnValueSetterTrait 34 | ; 35 | 36 | /** 37 | * @inheritdoc 38 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 39 | */ 40 | public function getKind() 41 | { 42 | return \Aop\KindConstantInterface::KIND_AFTER_FUNCTION_RETURN; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/AroundPropertyWriteJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_AROUND_PROPERTY_WRITE` handled by the interceptor. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_AROUND_PROPERTY_WRITE 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | class AroundPropertyWriteJoinPoint extends AroundJoinPoint implements 24 | Support\ClassSupportInterface, 25 | Support\PropertySupportInterface, 26 | Support\PropertyValueGetterSupportInterface, 27 | Support\PropertyValueSetterSupportInterface 28 | { 29 | use 30 | Traits\ClassTrait, 31 | Traits\PropertyTrait, 32 | Traits\PropertyValueGetterTrait, 33 | Traits\PropertyValueSetterTrait 34 | ; 35 | 36 | /** 37 | * @inheritdoc 38 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 39 | */ 40 | public function getKind() 41 | { 42 | return \Aop\KindConstantInterface::KIND_AROUND_PROPERTY_WRITE; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/BeforePropertyWriteJoinPoint.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | 13 | namespace Aop\JoinPoint; 14 | 15 | /** 16 | * Provides an abstraction layer of `JoinPoint` of kind 17 | * `\Aop\KindConstantInterface::KIND_BEFORE_PROPERTY_WRITE` handled by the interceptor. 18 | * 19 | * @see \Aop\KindConstantInterface::KIND_BEFORE_PROPERTY_WRITE 20 | * 21 | * @author Nicolas Tallefourtane 22 | */ 23 | class BeforePropertyWriteJoinPoint extends BeforeJoinPoint implements 24 | Support\ClassSupportInterface, 25 | Support\PropertySupportInterface, 26 | Support\PropertyValueGetterSupportInterface, 27 | Support\PropertyValueSetterSupportInterface 28 | { 29 | use 30 | Traits\ClassTrait, 31 | Traits\PropertyTrait, 32 | Traits\PropertyValueGetterTrait, 33 | Traits\PropertyValueSetterTrait 34 | ; 35 | 36 | /** 37 | * @inheritdoc 38 | * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() 39 | */ 40 | public function getKind() 41 | { 42 | return \Aop\KindConstantInterface::KIND_BEFORE_PROPERTY_WRITE; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Aop/JoinPoint/Traits/ReflectionPropertyTrait.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\JoinPoint\Traits; 13 | 14 | /** 15 | * Support `\Aop\JoinPoint\Support\PropertySupportInterface`. 16 | * This trait provides a reflector for the `JoinPoint` classes of kind `property`. 17 | * 18 | * @see \Aop\JoinPoint\Support\PropertySupportInterface 19 | * 20 | * @author Nicolas Tallefourtane 21 | */ 22 | trait ReflectionPropertyTrait 23 | { 24 | /** 25 | * @see \Aop\JoinPoint\Support\PropertySupportInterface::createReflectionProperty() 26 | */ 27 | public function createReflectionProperty() 28 | { 29 | return new \ReflectionProperty($this->getClassName(), $this->getPropertyName()); 30 | } 31 | 32 | /** 33 | * @see \Aop\JoinPoint\Support\PropertySupportInterface::getReflectionProperty() 34 | */ 35 | public function getReflectionProperty($singleton = true) 36 | { 37 | static $ref; // singleton 38 | 39 | if($singleton && $ref) { 40 | return $ref; 41 | } 42 | 43 | return $ref = $this->createReflectionProperty(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Aop/Aspect/LazyAspect.php: -------------------------------------------------------------------------------- 1 | 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code or visit http://aop.io 9 | * 10 | * @copyright Nicolas Tallefourtane 11 | */ 12 | namespace Aop\Aspect; 13 | 14 | use Aop\Traits\OptionTrait; 15 | 16 | /** 17 | * AspectInterface lazy proxy. 18 | * 19 | * @inheritdoc 20 | * @author Nicolas Tallefourtane 21 | */ 22 | class LazyAspect implements AspectInterface 23 | { 24 | use OptionTrait; 25 | 26 | /** 27 | * Name of the aspect. 28 | * @var string 29 | */ 30 | protected $name; 31 | 32 | /** 33 | * Constructor. 34 | * 35 | * @param string $name Aspect name. 36 | * @param array $options Aspect options [(string)