本文整理汇总了PHP中PhpSpec\Console\IO::writeln方法的典型用法代码示例。如果您正苦于以下问题:PHP IO::writeln方法的具体用法?PHP IO::writeln怎么用?PHP IO::writeln使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhpSpec\Console\IO
的用法示例。
在下文中一共展示了IO::writeln方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* @param ResourceInterface $resource
* @param array $data
*/
public function generate(ResourceInterface $resource, array $data = array())
{
$filepath = $resource->getSrcFilename();
$methodName = $data['name'];
$arguments = $data['arguments'];
$content = $this->getContent($resource, $methodName, $arguments);
$code = $this->appendMethodToCode($this->filesystem->getFileContents($filepath), $content);
$this->filesystem->putFileContents($filepath, $code);
$this->io->writeln(sprintf("<info>Method <value>%s::%s()</value> has been created.</info>\n", $resource->getSrcClassname(), $methodName), 2);
}
示例2: generate
/**
* @param ResourceInterface $resource
* @param array $data
*/
public function generate(ResourceInterface $resource, array $data)
{
$filepath = $resource->getSrcFilename();
if (!($content = $this->templates->render('private-constructor', array()))) {
$content = $this->templates->renderString($this->getTemplate(), array());
}
$code = $this->filesystem->getFileContents($filepath);
$code = $this->codeWriter->insertMethodFirstInClass($code, $content);
$this->filesystem->putFileContents($filepath, $code);
$this->io->writeln("<info>Private constructor has been created.</info>\n", 2);
}
示例3: generate
/**
* @param ResourceInterface $resource
* @param array $data
*/
public function generate(ResourceInterface $resource, array $data = array())
{
$filepath = $resource->getSrcFilename();
$methodName = $data['name'];
$arguments = $data['arguments'];
$content = $this->getContent($resource, $methodName, $arguments);
$code = $this->filesystem->getFileContents($filepath);
$code = preg_replace('/}[ \\n]*$/', rtrim($content) . "\n}\n", trim($code));
$this->filesystem->putFileContents($filepath, $code);
$this->io->writeln(sprintf("\n<info>Method <value>%s::%s()</value> has been created.</info>", $resource->getSrcClassname(), $methodName), 2);
}
示例4: generate
/**
* @param ResourceInterface $resource
* @param array $data
*/
public function generate(ResourceInterface $resource, array $data)
{
$filepath = $resource->getSrcFilename();
if (!($content = $this->templates->render('private-constructor', array()))) {
$content = $this->templates->renderString($this->getTemplate(), array());
}
$code = $this->filesystem->getFileContents($filepath);
$code = preg_replace('/}[ \\n]*$/', rtrim($content) . "\n}\n", trim($code));
$this->filesystem->putFileContents($filepath, $code);
$this->io->writeln("<info>Private constructor has been created.</info>\n", 2);
}
示例5: printSpecificException
/**
* @param ExampleEvent $event
* @param string $type
*/
protected function printSpecificException(ExampleEvent $event, $type)
{
$title = str_replace('\\', DIRECTORY_SEPARATOR, $event->getSpecification()->getTitle());
$message = $this->getPresenter()->presentException($event->getException(), $this->io->isVerbose());
foreach (explode("\n", wordwrap($title, $this->io->getBlockWidth(), "\n", true)) as $line) {
$this->io->writeln(sprintf('<%s-bg>%s</%s-bg>', $type, str_pad($line, $this->io->getBlockWidth()), $type));
}
$this->io->writeln(sprintf('<lineno>%4d</lineno> <%s>- %s</%s>', $event->getExample()->getFunctionReflection()->getStartLine(), $type, $event->getExample()->getTitle(), $type));
$this->io->writeln(sprintf('<%s>%s</%s>', $type, lcfirst($message), $type), 6);
$this->io->writeln();
}
示例6: generate
/**
* @param ResourceInterface $resource
* @param array $data
*/
public function generate(ResourceInterface $resource, array $data = array())
{
$filepath = $resource->getSrcFilename();
$name = $data['name'];
$arguments = $data['arguments'];
$argString = $this->buildArgumentString($arguments);
$values = array('%name%' => $name, '%arguments%' => $argString);
if (!($content = $this->templates->render('interface-method-signature', $values))) {
$content = $this->templates->renderString($this->getTemplate(), $values);
}
$this->insertMethodSignature($filepath, $content);
$this->io->writeln(sprintf("<info>Method signature <value>%s::%s()</value> has been created.</info>\n", $resource->getSrcClassname(), $name), 2);
}
示例7: generate
/**
* @param ResourceInterface $resource
* @param array $data
*/
public function generate(ResourceInterface $resource, array $data)
{
$destination = $this->getSavePath($resource);
if (file_exists($destination) && !$this->io->askConfirmation(sprintf('File "%s" already exists. Overwrite?', basename($destination)), false)) {
return;
}
$directory = dirname($destination);
if (!file_exists($directory)) {
$this->createDir($directory);
}
$code = $this->generateCodeForResource($resource, $data);
$this->filesystem->putFileContents($destination, $code);
$this->io->writeln($this->getPromptMessage($resource, $resource->getSrcFilename()));
}
示例8: generate
/**
* @param ResourceInterface $resource
* @param array $data
*/
public function generate(ResourceInterface $resource, array $data = array())
{
$filepath = $resource->getSrcFilename();
$name = $data['name'];
$arguments = $data['arguments'];
$argString = count($arguments) ? '$argument' . implode(', $argument', range(1, count($arguments))) : '';
$values = array('%name%' => $name, '%arguments%' => $argString);
if (!($content = $this->templates->render('method', $values))) {
$content = $this->templates->renderString($this->getTemplate(), $values);
}
$code = $this->filesystem->getFileContents($filepath);
$this->filesystem->putFileContents($filepath, $this->getUpdatedCode($name, $content, $code));
$this->io->writeln(sprintf("<info>Method <value>%s::%s()</value> has been created.</info>\n", $resource->getSrcClassname(), $name), 2);
}
示例9: generate
/**
* @param ResourceInterface $resource
* @param array $data
*
* @return mixed
*/
public function generate(ResourceInterface $resource, array $data = array())
{
$filepath = $resource->getSrcFilename();
$name = $data['name'];
$arguments = $data['arguments'];
$argString = $this->argumentBuilder->buildFrom($arguments);
$values = array('%name%' => $name, '%arguments%' => $argString);
if (!($content = $this->templates->render('method', $values))) {
$content = $this->templates->renderString($this->getTemplate(), $values);
}
$code = $this->filesystem->getFileContents($filepath);
$code = preg_replace('/}[ \\n]*$/', rtrim($content) . "\n}\n", trim($code));
$this->filesystem->putFileContents($filepath, $code);
$this->io->writeln(sprintf("\n<info>Method <value>%s::%s()</value> has been created.</info>", $resource->getSrcClassname(), $name), 2);
}
示例10: generate
/**
* @param ResourceInterface $resource
* @param array $data
*/
public function generate(ResourceInterface $resource, array $data)
{
$method = $data['method'];
$expected = $data['expected'];
$code = $this->filesystem->getFileContents($resource->getSrcFilename());
$values = array('%constant%' => var_export($expected, true));
if (!($content = $this->templates->render('method', $values))) {
$content = $this->templates->renderString($this->getTemplate(), $values);
}
$pattern = '/' . '(function\\s+' . preg_quote($method, '/') . '\\s*\\([^\\)]*\\))\\s+{[^}]*?}/';
$replacement = '$1' . $content;
$modifiedCode = preg_replace($pattern, $replacement, $code);
$this->filesystem->putFileContents($resource->getSrcFilename(), $modifiedCode);
$this->io->writeln(sprintf("\n<info>Method <value>%s::%s()</value> has been modified.</info>", $resource->getSrcClassname(), $method), 2);
}
示例11: let
function let(IO $io, ResourceManager $resourceManager, GeneratorManager $generatorManager, SuiteEvent $suiteEvent, ExampleEvent $exampleEvent, NameCheckerInterface $nameChecker)
{
$io->writeln(Argument::any())->willReturn();
$io->askConfirmation(Argument::any())->willReturn();
$this->beConstructedWith($io, $resourceManager, $generatorManager, $nameChecker);
$io->isCodeGenerationEnabled()->willReturn(true);
}
示例12: displayFatal
public function displayFatal(CurrentExampleTracker $currentExample, $error)
{
if (null !== $error && $currentExample->getCurrentExample() || is_null($currentExample->getCurrentExample()) && defined('HHVM_VERSION')) {
ini_set('display_errors', "stderr");
$failedOpen = $this->io->isDecorated() ? '<failed>' : '';
$failedClosed = $this->io->isDecorated() ? '</failed>' : '';
$failedCross = $this->io->isDecorated() ? '✘' : '';
$this->io->writeln("{$failedOpen}{$failedCross} Fatal error happened while executing the following {$failedClosed}");
$this->io->writeln("{$failedOpen} {$currentExample->getCurrentExample()} {$failedClosed}");
$this->io->writeln("{$failedOpen} {$error['message']} in {$error['file']} on line {$error['line']} {$failedClosed}");
}
}
示例13: outputSummary
public function outputSummary()
{
$this->io->writeln();
}
示例14: generateFileAndRenderTemplate
/**
* @param ResourceInterface $resource
* @param string $filepath
*/
private function generateFileAndRenderTemplate(ResourceInterface $resource, $filepath)
{
$content = $this->renderTemplate($resource, $filepath);
$this->filesystem->putFileContents($filepath, $content);
$this->io->writeln($this->getGeneratedMessage($resource, $filepath));
}
示例15:
function it_outputs_a_break_at_the_end(IO $io)
{
$this->outputSummary();
$io->writeln()->shouldHaveBeenCalled();
}