public function it_stores_the_file_content_if_a_namespace_starts(Factory $factory, NodeFilter $filter, Node $node, Generator $generator, Node $node2) { $node->name = new Node\Name(['\\Foo', 'Bar']); $filter->isNamespace($node)->willReturn(true); $filter->isNamespace($node2)->willReturn(false); $factory->create([$node], '\\Foo\\Bar')->willReturn($generator); $reflection = new \ReflectionProperty(ToDocBlockVisitor::class, 'docBlock'); $reflection->setAccessible(true); $this->enterNode($node2); //TODO why doensnt $reflection->getValue($this)->shouldBe(null) work? if ($reflection->getValue($this->getWrappedObject()) instanceof Generator) { throw new FailedPredictionException('docBlock written but it shouldnt'); } $this->enterNode($node); //TODO why doensnt $reflection->getValue($this)->shouldHaveType(Generator::class)) work? if (!$reflection->getValue($this->getWrappedObject()) instanceof Generator) { throw new FailedPredictionException('docBlock doesnt implement ' . Generator::class); } }
/** * {@inheritdoc} */ public function enterNode(Node $node) { if ($this->filter->isNamespace($node)) { $this->docBlock = $this->commentFactory->create([$node], implode('\\', $node->name->parts)); } }