/** * Create a new instance of JoinPoint. * Note: The kind of `JoinPoint` class depends on the context execution. * * @param int $kind * The kind of `JoinPoint`. * @param \Aop\Pointcut\PointcutInterface $pointcut * The pointcut that triggers the `JoinPoint`. * @param \Aop\JoinPoint\Support\JoinPointSupportInterceptorInterface $support * The interceptor that support the JoinPoint * * @return \Aop\JoinPoint\JoinPoint * Returns a `JoinPoint` instance, the class of `JoinPoint` depends on the `$kind`. */ protected function createJoinPoint($kind, PointcutInterface $pointcut, JoinPointSupportInterceptorInterface $support) { // class name $jp = '\\Aop\\JoinPoint\\' . Aop::getKindName($kind, true) . 'JoinPoint'; // create an instance of JointPoint (kind class resolved) return new $jp($pointcut, $support); }
/** * Create and throws a `\Aop\Exception\KindException`. * * @param string $method * @param int $kind */ protected function createKindException($kind, $method) { throw new KindException('`' . $method . '` error: the interceptor does not support the `' . Aop::getKindName($kind) . '` kind.'); }
/** * @inheritdoc * @see \Aop\JoinPoint\Support\KindSupportInterface::getKind() */ public function getKind() { return Aop::getWeaver()->getInterceptor()->resolveKind($this->patch->getKindOfAdvice()); }
/** * @inheritdoc * @see \Aop\Weaver\WeaverInterface::addAround() */ public function addAround(Pointcutinterface $pointcut, AdviceInterface $advice, array $options = []) { throw new KindException('`' . __METHOD__ . '` error: the interceptor does not support the `' . Aop::getKindName(Aop::KIND_AROUND) . '` kind.'); }
/** * Resolve a kind provided by `AopJoinPoint` to a kind for AOP.io API. * * @see \Aop\KindConstantInterface * @see PeclAopInterceptor::resolveJoinPoint() * * @param int $kind AOP_KIND_* * @return int The kind * @throws \Aop\Exception\KindException If the kind is invalid. */ protected function resolveKind($kind) { $kinds = [AOP_KIND_BEFORE => Aop::KIND_BEFORE, AOP_KIND_AFTER => Aop::KIND_AFTER, AOP_KIND_AROUND => Aop::KIND_AROUND, AOP_KIND_PROPERTY => Aop::KIND_PROPERTY, AOP_KIND_FUNCTION => Aop::KIND_FUNCTION, AOP_KIND_METHOD => Aop::KIND_METHOD, AOP_KIND_READ => Aop::KIND_READ, AOP_KIND_WRITE => Aop::KIND_WRITE, AOP_KIND_AROUND_WRITE_PROPERTY => Aop::KIND_AROUND_PROPERTY_WRITE, AOP_KIND_AROUND_READ_PROPERTY => Aop::KIND_AROUND_PROPERTY_READ, AOP_KIND_BEFORE_WRITE_PROPERTY => Aop::KIND_BEFORE_PROPERTY_WRITE, AOP_KIND_BEFORE_READ_PROPERTY => Aop::KIND_BEFORE_PROPERTY_READ, AOP_KIND_AFTER_WRITE_PROPERTY => Aop::KIND_AFTER_PROPERTY_WRITE, AOP_KIND_AFTER_READ_PROPERTY => Aop::KIND_AFTER_PROPERTY_READ, AOP_KIND_BEFORE_METHOD => Aop::KIND_BEFORE_METHOD, AOP_KIND_AFTER_METHOD => Aop::KIND_AFTER_METHOD, AOP_KIND_AROUND_METHOD => Aop::KIND_AROUND_METHOD, AOP_KIND_BEFORE_FUNCTION => Aop::KIND_BEFORE_FUNCTION, AOP_KIND_AFTER_FUNCTION => Aop::KIND_AFTER_FUNCTION, AOP_KIND_AROUND_FUNCTION => Aop::KIND_AROUND_FUNCTION, 836 => Aop::KIND_AFTER_METHOD, 580 => Aop::KIND_AFTER_METHOD_RETURN, 324 => Aop::KIND_AFTER_METHOD_THROW, 900 => Aop::KIND_AFTER_FUNCTION, 644 => Aop::KIND_AFTER_FUNCTION_RETURN, 388 => Aop::KIND_AFTER_FUNCTION_THROW, 820 => Aop::KIND_AFTER_PROPERTY_WRITE, 812 => Aop::KIND_AFTER_PROPERTY_READ]; if (!array_key_exists($kind, $kinds) or !Aop::isValidKind($kinds[$kind])) { throw new KindException('The kind (' . $kind . ') is invalid.'); } return $kinds[$kind]; }
public function testWeaver() { new _Aop(); $weaver = _Aop::this()->getWeaver(); $this->object($weaver)->isInstanceOf('\\Aop\\Weaver\\WeaverInterface')->boolean($weaver->isEnabled())->object($weaver->getInterceptor())->isInstanceOf('\\Aop\\Weaver\\Interceptor'); }