withNamespace() публичный Метод

*
public withNamespace ( string $namespace ) : Context
$namespace string The namespace of the file
Результат Context A clone of this context with the given value is returned
Пример #1
0
 public function testSimple()
 {
     $context = new Context();
     $context_namespace = $context->withNamespace('\\A');
     $context_class = $context_namespace->withClassFQSEN(FullyQualifiedClassName::fromFullyQualifiedString('\\A\\B'));
     $context_method = $context_namespace->withMethodFQSEN(FullyQualifiedMethodName::fromFullyQualifiedString('\\A\\b::c'));
     $this->assertTrue(!empty($context));
     $this->assertTrue(!empty($context_namespace));
     $this->assertTrue(!empty($context_class));
     $this->assertTrue(!empty($context_method));
 }
Пример #2
0
 public function testSimple()
 {
     $context = new Context();
     $context_namespace = $context->withNamespace('\\A');
     $context_class = $context_namespace->withScope(new ClassScope($context_namespace->getScope(), FullyQualifiedClassName::fromFullyQualifiedString('\\A\\B')));
     $context_method = $context_namespace->withScope(new FunctionLikeScope($context_namespace->getScope(), FullyQualifiedMethodName::fromFullyQualifiedString('\\A\\b::c')));
     $this->assertTrue(!empty($context));
     $this->assertTrue(!empty($context_namespace));
     $this->assertTrue(!empty($context_class));
     $this->assertTrue(!empty($context_method));
 }
Пример #3
0
 /**
  * Visit a node with kind `\ast\AST_NAMESPACE`
  *
  * @param Node $node
  * A node to parse
  *
  * @return Context
  * A new or an unchanged context resulting from
  * parsing the node
  */
 public function visitNamespace(Node $node) : Context
 {
     return $this->context->withNamespace('\\' . (string) $node->children['name']);
 }