本文整理匯總了PHP中Symfony\Component\Console\Output\OutputInterface::isDecorated方法的典型用法代碼示例。如果您正苦於以下問題:PHP OutputInterface::isDecorated方法的具體用法?PHP OutputInterface::isDecorated怎麽用?PHP OutputInterface::isDecorated使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Console\Output\OutputInterface
的用法示例。
在下文中一共展示了OutputInterface::isDecorated方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* Executes the application.
*
* Available options:
*
* * interactive: Sets the input interactive flag
* * decorated: Sets the output decorated flag
* * verbosity: Sets the output verbosity flag
* * capture_stderr_separately: Make output of stdOut and stdErr separately available
*
* @param array $input An array of arguments and options
* @param array $options An array of options
*
* @return int The command exit code
*/
public function run(array $input, $options = array())
{
$this->input = new ArrayInput($input);
if (isset($options['interactive'])) {
$this->input->setInteractive($options['interactive']);
}
$this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
if (!$this->captureStreamsIndependently) {
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
if (isset($options['decorated'])) {
$this->output->setDecorated($options['decorated']);
}
if (isset($options['verbosity'])) {
$this->output->setVerbosity($options['verbosity']);
}
} else {
$this->output = new ConsoleOutput(isset($options['verbosity']) ? $options['verbosity'] : ConsoleOutput::VERBOSITY_NORMAL, isset($options['decorated']) ? $options['decorated'] : null);
$errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
$errorOutput->setFormatter($this->output->getFormatter());
$errorOutput->setVerbosity($this->output->getVerbosity());
$errorOutput->setDecorated($this->output->isDecorated());
$reflectedOutput = new \ReflectionObject($this->output);
$strErrProperty = $reflectedOutput->getProperty('stderr');
$strErrProperty->setAccessible(true);
$strErrProperty->setValue($this->output, $errorOutput);
$reflectedParent = $reflectedOutput->getParentClass();
$streamProperty = $reflectedParent->getProperty('stream');
$streamProperty->setAccessible(true);
$streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
}
return $this->statusCode = $this->application->run($this->input, $this->output);
}
示例2: onMutationsGenerated
/**
* @return void
*/
public function onMutationsGenerated()
{
if ($this->input->getOption('no-progress-bar') || !$this->output->isDecorated()) {
return;
}
$this->moveToLineStart();
}
示例3: progressAdvance
/**
* @phpcsSuppress SlevomatCodingStandard.Typehints.TypeHintDeclaration.missingParameterTypeHint
* @param int $step
*/
public function progressAdvance($step = 1)
{
if ($this->output->isDecorated() && $step > 0) {
$stepTime = (time() - $this->progressBar->getStartTime()) / $step;
if ($stepTime > 0 && $stepTime < 1) {
$this->progressBar->setRedrawFrequency(1 / $stepTime);
} else {
$this->progressBar->setRedrawFrequency(1);
}
}
$this->progressBar->setProgress($this->progressBar->getProgress() + $step);
}
示例4: printLegend
public function printLegend()
{
$symbols = array();
foreach (self::$eventStatusMap as $status) {
$symbol = $status['symbol'];
if ('' === $symbol || isset($symbols[$symbol])) {
continue;
}
$symbols[$symbol] = sprintf('%s-%s', $this->output->isDecorated() ? sprintf($status['format'], $symbol) : $symbol, $status['description']);
}
$this->output->write(sprintf("\nLegend: %s\n", implode(', ', $symbols)));
}
示例5: __construct
/**
* Constructor.
*
* @param OutputInterface $output An OutputInterface instance
* @param int $max Maximum steps (0 if unknown)
*/
public function __construct(OutputInterface $output, $max = 0)
{
if ($output instanceof ConsoleOutputInterface) {
$output = $output->getErrorOutput();
}
$this->output = $output;
$this->setMaxSteps($max);
if (!$this->output->isDecorated()) {
// disable overwrite when output does not support ANSI codes.
$this->overwrite = false;
// set a reasonable redraw frequency so output isn't flooded
$this->setRedrawFrequency($max / 10);
}
$this->startTime = time();
}
示例6: __construct
/**
* Constructor.
*
* @param OutputInterface $output An OutputInterface instance
* @param int $max Maximum steps (0 if unknown)
*/
public function __construct(OutputInterface $output, $max = 0)
{
$this->output = $output;
$this->setMaxSteps($max);
if (!$this->output->isDecorated()) {
// disable overwrite when output does not support ANSI codes.
$this->overwrite = false;
if ($this->max > 10) {
// set a reasonable redraw frequency so output isn't flooded
$this->setRedrawFrequency($max / 10);
}
}
$this->setFormat($this->determineBestFormat());
$this->startTime = time();
}
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$watch = $input->getOption('watch');
$buffered = new BufferedOutput($output->getVerbosity(), $output->isDecorated());
$service = new StatsService($this->getBeanstalk());
do {
$tubes = $service->getAllTubeStats();
if (empty($tubes)) {
$output->writeln('No tubes found.');
return;
}
$table = new Table($buffered);
$table->setHeaders($service->getTubeHeaderMapping());
foreach ($tubes as $stats) {
if ($stats['current-jobs-buried'] > 0) {
$stats['name'] = "<error>{$stats['name']}</error>";
$stats['current-jobs-buried'] = "<error>{$stats['current-jobs-buried']}</error>";
}
$table->addRow($stats);
}
$table->render();
$clearScreen = $watch ? "[H[2J" : '';
$output->write($clearScreen . $buffered->fetch());
$watch && sleep(1);
} while ($watch);
}
示例8: run
/**
* Override run method to internationalize error message.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int Return code
*/
public function run(InputInterface $input, OutputInterface $output)
{
// Set extra colors
// The most problem is $output->getFormatter() don't work.
// So create new formatter to add extra color.
$formatter = new OutputFormatter($output->isDecorated());
$formatter->setStyle('red', new OutputFormatterStyle('red', 'black'));
$formatter->setStyle('green', new OutputFormatterStyle('green', 'black'));
$formatter->setStyle('yellow', new OutputFormatterStyle('yellow', 'black'));
$formatter->setStyle('blue', new OutputFormatterStyle('blue', 'black'));
$formatter->setStyle('magenta', new OutputFormatterStyle('magenta', 'black'));
$formatter->setStyle('yellow-blue', new OutputFormatterStyle('yellow', 'blue'));
$output->setFormatter($formatter);
\App::setLocale(\Config::get('syncle::MessageLang'));
try {
$result = parent::run($input, $output);
} catch (\RuntimeException $e) {
// All error messages were hard coded in
// Symfony/Component/Console/Input/Input.php
if ($e->getMessage() == 'Not enough arguments.') {
$this->error(\Lang::get('syncle::BaseCommand.ArgumentNotEnough'));
} elseif ($e->getMessage() == 'Too many arguments.') {
$this->error(\Lang::get('syncle::BaseCommand.TooManyArgument'));
} elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
$this->error(\Lang::get('syncle::BaseCommand.OptionNotExist', array('option' => $matches[1])));
} else {
$this->error($e->getMessage());
}
$result = 1;
}
return $result;
}
示例9: start
public function start(OutputInterface $output, $max = null)
{
$this->startTime = time();
$this->current = 0;
$this->max = (int) $max;
$this->output = $output->isDecorated() ? $output : new NullOutput();
$this->lastMessagesLength = 0;
$this->barCharOriginal = '';
if (null === $this->format) {
switch ($output->getVerbosity()) {
case OutputInterface::VERBOSITY_QUIET:
$this->format = self::FORMAT_QUIET_NOMAX;
if ($this->max > 0) {
$this->format = self::FORMAT_QUIET;
}
break;
case OutputInterface::VERBOSITY_VERBOSE:
case OutputInterface::VERBOSITY_VERY_VERBOSE:
case OutputInterface::VERBOSITY_DEBUG:
$this->format = self::FORMAT_VERBOSE_NOMAX;
if ($this->max > 0) {
$this->format = self::FORMAT_VERBOSE;
}
break;
default:
$this->format = self::FORMAT_NORMAL_NOMAX;
if ($this->max > 0) {
$this->format = self::FORMAT_NORMAL;
}
break;
}
}
$this->initialize();
}
示例10: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->setFormatter(new Console\Formatter($output->isDecorated()));
$this->io = new Console\IO($input, $output, $this->getHelperSet());
$spec = $input->getArgument('spec');
if (!is_dir($specsPath = $input->getOption('spec-path'))) {
mkdir($specsPath, 0777, true);
}
if ($srcPath = $input->getOption('src-path')) {
$spec = preg_replace('#^' . preg_quote($srcPath, '#') . '/#', '', $spec);
}
$spec = preg_replace('#\\.php$#', '', $spec);
$spec = str_replace('/', '\\', $spec);
$specsPath = realpath($specsPath) . DIRECTORY_SEPARATOR;
$subject = str_replace('/', '\\', $spec);
$classname = $input->getOption('namespace') . $subject;
$filepath = $specsPath . str_replace('\\', DIRECTORY_SEPARATOR, $spec) . '.php';
$namespace = str_replace('/', '\\', dirname(str_replace('\\', DIRECTORY_SEPARATOR, $classname)));
$class = basename(str_replace('\\', DIRECTORY_SEPARATOR, $classname));
if (file_exists($filepath)) {
$overwrite = $this->io->askConfirmation(sprintf('File "%s" already exists. Overwrite?', basename($filepath)), false);
if (!$overwrite) {
return 1;
}
$this->io->writeln();
}
$dirpath = dirname($filepath);
if (!is_dir($dirpath)) {
mkdir($dirpath, 0777, true);
}
file_put_contents($filepath, $this->getSpecContentFor(array('%classname%' => $classname, '%namespace%' => $namespace, '%filepath%' => $filepath, '%class%' => $class, '%subject%' => $subject)));
$output->writeln(sprintf("<info>Specification for <value>%s</value> created in <value>%s</value>.</info>\n", $subject, $this->relativizePath($filepath)));
}
示例11: __construct
/**
* Constructor.
*
* @param OutputInterface $output An OutputInterface instance
* @param int $max Maximum steps (0 if unknown)
*/
public function __construct(OutputInterface $output, $max = 0)
{
// Disabling output when it does not support ANSI codes as it would result in a broken display anyway.
$this->output = $output->isDecorated() ? $output : new NullOutput();
$this->setMaxSteps($max);
$this->setFormat($this->determineBestFormat());
$this->startTime = time();
}
示例12: createFromFiles
/**
* Create ProcessSet from given files, optionally filtering by given $groups and $excludeGroups
*
* @param Finder $files
* @param array $groups Groups to be run
* @param array $excludeGroups Groups to be excluded
* @param string $filter filter test cases by name
* @return ProcessSet
*/
public function createFromFiles(Finder $files, array $groups = null, array $excludeGroups = null, $filter = null)
{
$files->sortByName();
$processSet = $this->getProcessSet();
if ($groups || $excludeGroups || $filter) {
$this->output->writeln('Filtering testcases:');
}
if ($groups) {
$this->output->writeln(sprintf(' - by group(s): %s', implode(', ', $groups)));
}
if ($excludeGroups) {
$this->output->writeln(sprintf(' - excluding group(s): %s', implode(', ', $excludeGroups)));
}
if ($filter) {
$this->output->writeln(sprintf(' - by testcase/test name: %s', $filter));
}
$testCasesNum = 0;
foreach ($files as $file) {
$fileName = $file->getRealpath();
// Parse classes from the testcase file
$classes = AnnotationsParser::parsePhp(\file_get_contents($fileName));
// Get annotations for the first class in testcase (one file = one class)
$annotations = AnnotationsParser::getAll(new \ReflectionClass(key($classes)));
// Filter out test-cases having any of excluded groups
if ($excludeGroups && array_key_exists('group', $annotations) && count($excludingGroups = array_intersect($excludeGroups, $annotations['group']))) {
if ($this->output->isDebug()) {
$this->output->writeln(sprintf('Excluding testcase file %s with group %s', $fileName, implode(', ', $excludingGroups)));
}
continue;
}
// Filter out test-cases without any matching group
if ($groups) {
if (!array_key_exists('group', $annotations) || !count($matchingGroups = array_intersect($groups, $annotations['group']))) {
continue;
}
if ($this->output->isDebug()) {
$this->output->writeln(sprintf('Found testcase file #%d in group %s: %s', ++$testCasesNum, implode(', ', $matchingGroups), $fileName));
}
} else {
if ($this->output->isDebug()) {
$this->output->writeln(sprintf('Found testcase file #%d: %s', ++$testCasesNum, $fileName));
}
}
$phpunitArgs = ['--log-junit=logs/' . Strings::webalize(key($classes), null, $lower = false) . '.xml', '--configuration=' . realpath(__DIR__ . '/../phpunit.xml')];
if ($filter) {
$phpunitArgs[] = '--filter=' . $filter;
}
// If ANSI output is enabled, turn on colors in PHPUnit
if ($this->output->isDecorated()) {
$phpunitArgs[] = '--colors=always';
}
$processSet->add($this->buildProcess($fileName, $phpunitArgs), key($classes), $delayAfter = !empty($annotations['delayAfter']) ? current($annotations['delayAfter']) : '', $delayMinutes = !empty($annotations['delayMinutes']) ? current($annotations['delayMinutes']) : null);
}
return $processSet;
}
示例13: autoShowProgressIndicator
public function autoShowProgressIndicator()
{
if ($this->autoDisplayInterval < 0 || !isset($this->progressBar) || !$this->output->isDecorated()) {
return;
}
if ($this->autoDisplayInterval <= $this->getExecutionTime()) {
$this->autoDisplayInterval = -1;
$this->progressBar->start($this->totalSteps);
$this->showProgressIndicator();
}
}
示例14: getTaskActionStatusSectionFromContext
/**
* Returns the task status section based on the context.
*
* @param array $context
*
* @return string
*/
private function getTaskActionStatusSectionFromContext(array $context)
{
$actionStatusSection = '';
if ($this->output->isDecorated()) {
$actionStatusSection = sprintf(self::ANSI_CURSOR_BACKWARD_FORMAT, 1);
}
if (isset($context['event.task.action']) && isset($this->taskActionStatusToOutputMap[$context['event.task.action']])) {
$actionStatusSection = sprintf('[<event-task-action-%1$s>%2$s</event-task-action-%1$s>]', $context['event.task.action'], $this->taskActionStatusToOutputMap[$context['event.task.action']]);
}
return $actionStatusSection;
}
示例15: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$project = $input->getOption('project');
$multiple = 1 < count($project);
$color = $output->isDecorated();
$optList = $input->getOption('list');
$optNull = $input->getOption('null');
$optNoLine = $input->getOption('no-lines');
$dom = new \DOMDocument();
$dom->loadHTML(file_get_contents(rtrim($input->getOption('server'), '/') . '/search?' . '&n=' . $input->getOption('max-count') . '&q=' . rawurlencode($input->getArgument('query')) . '&project=' . implode('&project=', $project) . '&path=' . rawurlencode($input->getOption('path')) . '&sort=fullpath'));
$xpath = new \DOMXPath($dom);
$results = $xpath->query('//div[@id = "results"]/table/tr/td/tt[@class = "con"]/a[@class = "s"]');
$last = null;
for ($i = 0; $i < $results->length; $i++) {
$result = $results->item($i);
preg_match('@^.*/xref/([^/]+)(/.*)#(\\d+)$@', $result->getAttribute('href'), $file);
$out = '';
if ($color) {
$out = ($multiple ? "[33m{$file[1]}[36m:" : '') . "[35m{$file[2]}[0m";
} else {
$out = ($multiple ? "{$file[1]}:" : '') . $file[2];
}
if ($optList) {
if ($last == $file[1] . ':' . $file[2]) {
continue;
}
$last = $file[1] . ':' . $file[2];
$out .= $optNull ? chr(0) : "\n";
} else {
if ($optNoLine) {
$out .= $color ? "[36m:[0m" : ":";
} else {
$out .= $color ? "[36m:[32m{$file[3]}[36m:[0m" : ":{$file[3]}:";
}
$match = $dom->saveXML($result);
if ($color) {
$match = preg_replace_callback('@<b>([^<]+)</b>@', function ($match) {
return "[31m{$match[1]}[0m";
}, $match);
}
$match = preg_replace('@^<span class="l">\\d+</span>(.*)$@', '$1', html_entity_decode(strip_tags($match, '<span>')));
$out .= $match . "\n";
}
$output->write($out, false, OutputInterface::OUTPUT_RAW);
}
if (0 == $results->length) {
return 1;
} elseif (0 < $xpath->query('//div[@id = "results"]/p[@class = "slider"]/a[@class = "more"]')->length) {
fwrite(STDERR, 'Results truncated.' . "\n");
}
}