/** * {@inheritdoc} */ public function generate($raw = false) { $writer = new Writer(4, true); $writer->setOutputIndentation(1); $this->getMethodDeclaration($writer, false); $writer->appendln(';'); return $raw ? $writer : $writer->dump(); }
/** * Constructor. * * @param bool $raw */ public function generate($raw = false) { $writer = new Writer(); $writer->writeln('<?php')->newline(); array_map([$writer, 'writeln'], $this->contents); $writer->appendln(PHP_EOL); return $raw ? $writer : $writer->dump(); }
/** * generate * * @param boolean $raw * * @return void */ public function generate($raw = self::RV_STRING) { $writer = new Writer(); $writer->setOutputIndentation(1); $this->getDoc($writer); $writer->setOutputIndentation(1); $writer->writeln(sprintf('const %s = %s;', strtoupper($this->name), $this->getValue())); return $raw ? $writer : $writer->dump(); }
/** * {@inheritdoc} */ public function generate($raw = false) { $this->getDoc($writer = new Writer())->writeln(sprintf('%s%s $%s', $this->visibility, $this->prefix, $this->name)); if (null !== $this->value) { $writer->appendln(' = ' . $this->value); } $writer->appendln(';')->setOutputIndentation(1); return $raw ? $writer : $writer->dump(); }
/** * {@inheritdoc} */ public function generate($raw = self::RV_STRING) { $writer = new Writer(); $this->prepareDoc($ddoc = clone $this->getDoc()); $this->prepareObjDoc($odoc = clone $this->getObjDoc()); $writer->writeln($this->getDocType()); if (!$ddoc->isEmpty()) { $writer->newline()->writeln($ddoc->generate()); } $writer->newline()->writeln(sprintf('namespace %s;', $ns = $this->getNamespace())); $this->writeUseStatements($writer, $this->getImportResolver(), null !== $ns); $writer->newline()->writeln($odoc->generate()); $this->writeObject($writer); return $raw ? $writer : $writer->dump(); }
/** * blockLine * * @param Writer $writer * @param array $lines * * @return void */ protected function blockLines(Writer $writer, array $lines) { foreach ($lines as $line) { $writer->writeln(' * ' . $line); } }
/** * getDocBlock * * @return Writer|string */ protected final function getDoc(Writer $writer, $asString = false) { $this->prepareAnnotations($block = clone $this->docBlock); $writer->writeln($block); return $asString ? $writer->dump() : $writer; }
/** * {@inheritdoc} */ public function generate($raw = false) { $writer = new Writer(); $prefix = $this->isReference ? '&' : ''; $prefix .= $this->isVariadic ? '...' : ''; $type = null === $this->type || in_array($this->type, array_merge(self::$silent, self::$primitives)) ? '' : $this->type . ' '; if (null !== $this->default) { $line = sprintf('%s%s$%s = %s', $type, $prefix, $this->name, $this->default); } else { $line = sprintf('%s%s$%s', $type, $prefix, $this->name); } $writer->writeln($line); return $raw ? $writer : $writer->dump(); }
/** @test */ public function itShouldThrowExceptionOnNoneStrangableValues() { $wr = new Writer(); try { $wr->writeln([]); } catch (\InvalidArgumentException $e) { $this->assertSame('Input value must be stringable.', $e->getMessage()); return; } $this->fail(); }
/** * getBody * * @return string */ protected function getBody() { if (null === $this->body) { return; } if ($this->body instanceof Writer) { $body = $this->body; } else { $body = new Writer(); $body->writeln($this->body); } $body->setOutputIndentation(0); return $body->dump(); }