public function testExecutionConsidersExposedContext() { $lexer = new PointcutLexer(); $parser = new PointcutParser(); $context = new PointcutContext(); $context->addParam('resource', 'ResourceInterface'); $tok = $lexer->tokenize('execution(@Profiled (@Debug $resource)->*())'); $execution = $parser->parse($tok, $context); $this->assertTrue($execution instanceof ExecutionPointcut); $this->assertEquals('*', $execution->getNamePattern()); $filters = $execution->getAnnotationFilters(); $this->assertCount(1, $filters); $this->assertEquals(['Profiled'], $filters[0]->getAnnotations()); $type = $execution->getTypeMatcher(); $this->assertTrue($type instanceof TypePointcut); $this->assertEquals('ResourceInterface', $type->getNamePattern()); $filters = $type->getAnnotationFilters(); $this->assertCount(1, $filters); $this->assertEquals(['Debug'], $filters[0]->getAnnotations()); }
protected function createTypePattern($typePattern, PointcutContext $context, &$exposed = NULL) { if (substr($typePattern, 0, 1) === '$') { $exposed = substr($typePattern, 1); $typePattern = $context->getParamType(substr($typePattern, 1)); if ($typePattern === NULL) { $typePattern = '*'; } } if (0 !== strpos($typePattern, '\\') && !preg_match("'^\\*+\$'", $typePattern)) { if (false === strpos($typePattern, '*')) { return ltrim($context->getNamespaceContext()->lookup($typePattern), '\\'); } else { return ltrim($context->getNamespaceContext()->getNamespace() . '\\' . $typePattern, '\\'); } } return ltrim($typePattern, '\\'); }
protected function createPointcutContext(TypeInfoInterface $type, MethodInfoInterface $method) { $context = new PointcutContext($type->getNamespaceContext()); foreach ($method->getParameters() as $param) { $context->addParam($param->getName(), $param->getRequiredType()); } foreach ($method->getAnnotationCandidates() as $anno) { $context->addAnnotation($anno); } return $context; }