/** * {@inheritdoc} * @param ReflectionFileNamespace|string $ns */ public function matches($ns) { $isNamespaceIsObject = $ns === (object) $ns; if ($isNamespaceIsObject && !$ns instanceof ReflectionFileNamespace) { return false; } $nsName = $isNamespaceIsObject ? $ns->getName() : $ns; return $nsName === $this->nsName || (bool) preg_match("/^(?:{$this->regexp})\$/", $nsName); }
public function testGetName() { $namespaceName = $this->parsedRefFileNamespace->getName(); $this->assertEquals(\Go\ParserReflection\Stub\NAMESPACE_NAME, $namespaceName); }
protected function resolveExprConstFetch(Expr\ConstFetch $node) { $constantValue = null; $isResolved = false; /** @var ReflectionFileNamespace|null $fileNamespace */ $fileNamespace = null; $isFQNConstant = $node->name instanceof Node\Name\FullyQualified; $constantName = $node->name->toString(); if (!$isFQNConstant) { if (method_exists($this->context, 'getFileName')) { $fileName = $this->context->getFileName(); $namespaceName = $this->context->getNamespaceName(); $fileNamespace = new ReflectionFileNamespace($fileName, $namespaceName); if ($fileNamespace->hasConstant($constantName)) { $constantValue = $fileNamespace->getConstant($constantName); $constantName = $fileNamespace->getName() . '\\' . $constantName; $isResolved = true; } } } if (!$isResolved && defined($constantName)) { $constantValue = constant($constantName); } if ($this->nodeLevel === 1 && !isset(self::$notConstants[$constantName])) { $this->isConstant = true; $this->constantName = $constantName; } return $constantValue; }
/** * Returns list of function advices for specific namespace * * @param ReflectionFileNamespace $namespace * @param Aop\PointcutAdvisor $advisor Advisor for class * @param string $advisorId Identifier of advisor * @param Aop\PointFilter $pointcut Filter for points * * @return array */ private function getFunctionAdvicesFromAdvisor(ReflectionFileNamespace $namespace, Aop\PointcutAdvisor $advisor, $advisorId, Aop\PointFilter $pointcut) { $functions = []; $advices = []; $listOfGlobalFunctions = get_defined_functions(); foreach ($listOfGlobalFunctions['internal'] as $functionName) { $functions[$functionName] = new NamespacedReflectionFunction($functionName, $namespace->getName()); } foreach ($functions as $functionName => $function) { if ($pointcut->matches($function)) { $advices[AspectContainer::FUNCTION_PREFIX][$functionName][$advisorId] = $advisor->getAdvice(); } } return $advices; }