public function testVisitFunction()
 {
     $writer = new Writer();
     $function = new PhpFunction('foo');
     $function->addParameter(PhpParameter::create('a'))->addParameter(PhpParameter::create('b'))->setBody($writer->writeln('if ($a === $b) {')->indent()->writeln('throw new \\InvalidArgumentException(\'$a is not allowed to be the same as $b.\');')->outdent()->write("}\n\n")->write('return $b;')->getContent());
     $visitor = new DefaultVisitor();
     $visitor->visitFunction($function);
     $this->assertEquals($this->getContent('a_b_function.php'), $visitor->getContent());
 }
 public function sample()
 {
     $class = new PhpClass('Sample');
     $class->setNamespace('name\\space');
     $class->setProperty(PhpProperty::create('string')->setType('string', 'String'));
     $writer = new Writer();
     $class->setMethod(PhpMethod::create('get')->setDescription(['Return string'])->setType('string')->setBody($writer->writeln('return $this->string;')->getContent()));
     $writer = new Writer();
     $class->setMethod(PhpMethod::create('set')->setDescription(['Set string'])->addSimpleDescParameter('string', 'string', 'String')->setType('$this')->setBody($writer->writeln('$this->string = $string;')->writeln('return $this;')->getContent()));
     $generator = new CodeFileGenerator();
     $code = $generator->generate($class);
     file_put_contents('tmp/origin/Gossi.php', (string) $code);
 }
 public function testGetUnindentedDocComment()
 {
     $writer = new Writer();
     $comment = $writer->writeln('/**')->indent()->writeln(' * Foo.')->write(' */')->getContent();
     $this->assertEquals("/**\n * Foo.\n */", ReflectionUtils::getUnindentedDocComment($comment));
 }