示例#1
0
 /**
  * Handles classes
  */
 function it_handles_final_classes(PHPNamespace $namespace, CodeFactoryContract $codeFactory, PHPClass $class)
 {
     $classNode = new Class_('Foo', ['type' => Class_::MODIFIER_FINAL]);
     $codeFactory->buildClass('Foo', PHPClass::IS_FINAL)->willReturn($class)->shouldBeCalled();
     $namespace->addClass($class)->shouldBeCalled();
     $this->parse([$classNode], $namespace);
 }
示例#2
0
 /**
  * @param Class_       $node
  * @param PHPNamespace $target
  */
 public function handleClass(Class_ $node, PHPNamespace $target)
 {
     $name = $node->name;
     $modifiers = 0;
     $modifiers |= $node->isAbstract() ? PHPClass::IS_ABSTRACT : 0;
     $modifiers |= $node->isFinal() ? PHPClass::IS_FINAL : 0;
     $class = $this->codeFactory->buildClass($name, $modifiers);
     $target->addClass($class);
     $this->parse($node->stmts, $class);
 }
示例#3
0
 /**
  * Has namespaces
  */
 function it_has_namespaces(PHPNamespace $namespace, PHPNamespace $namespaceAdded)
 {
     $this->getNamespaces()->shouldBe([$namespace]);
     $namespace->getName()->willReturn(PHPNamespace::NO_NAMESPACE);
     $namespace->isEmpty()->willReturn(true);
     $this->addNamespace($namespace);
     $this->getNamespaces()->shouldBe([$namespace]);
     $namespace->isEmpty()->willReturn(false);
     $namespace->setName(PHPNamespace::GLOBAL_NAMESPACE)->shouldBeCalled();
     $this->addNamespace($namespaceAdded);
     $this->getNamespaces()->shouldBe([$namespace, $namespaceAdded]);
 }
示例#4
0
 /**
  * @param PHPNamespace $namespace
  *
  * @return \PhpParser\Node
  */
 public function generateNamespace(PHPNamespace $namespace)
 {
     $ns = $this->factory->namespace($namespace->getName());
     return $ns->getNode();
 }