当前位置: 首页>>代码示例>>PHP>>正文


PHP Helper\FormatterHelper类代码示例

本文整理汇总了PHP中Symfony\Component\Console\Helper\FormatterHelper的典型用法代码示例。如果您正苦于以下问题:PHP FormatterHelper类的具体用法?PHP FormatterHelper怎么用?PHP FormatterHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FormatterHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Run the dotenv diff
  */
 public static function run()
 {
     $output = new ConsoleOutput();
     $formatter = new FormatterHelper();
     $env = self::readFile('.env');
     $envExample = self::readFile('.env.example');
     // Check which variables are missing and which ones are extra
     $envKeys = array_keys($env);
     $envExampleKeys = array_keys($envExample);
     $missing = array_diff($envExampleKeys, $envKeys);
     $extra = array_diff($envKeys, $envExampleKeys);
     if (count($missing) > 0 || count($extra) > 0) {
         $output->writeln('');
         $warning = $formatter->formatBlock('Warning: Your .env and .env.example files are not in sync.', 'bg=blue;fg=white', true);
         $output->writeln($warning);
     }
     if (count($missing) > 0) {
         $output->writeln("\n<comment>The following variables are missing from your .env file:<comment>");
         foreach ($missing as $variable) {
             $output->writeln(sprintf('<info>%s=%s<info>', $variable, $envExample[$variable]));
         }
     }
     if (count($extra) > 0) {
         $output->writeln("\n<comment>The following variables are in your .env file but not in .env.example:<comment>");
         foreach ($extra as $variable) {
             $output->writeln(sprintf('<info>%s=%s<info>', $variable, $env[$variable]));
         }
     }
     $output->writeln('');
 }
开发者ID:kielabokkie,项目名称:dotenv-diff,代码行数:33,代码来源:DotenvDiff.php

示例2: testTruncatingWithNegativeLength

 public function testTruncatingWithNegativeLength()
 {
     $formatter = new FormatterHelper();
     $message = 'testing truncate';
     $this->assertSame('testing tru...', $formatter->truncate($message, -5));
     $this->assertSame('...', $formatter->truncate($message, -100));
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:7,代码来源:FormatterHelperTest.php

示例3: notify

 public function notify(\Exception $exception)
 {
     if (!$exception instanceof ServiceNotFoundException) {
         return;
     }
     $serviceId = $exception->getId();
     $guessedFqcn = $this->guessFqcn($serviceId);
     $definition = new Definition();
     $definition->setClass($guessedFqcn);
     $containerBuilder = new ContainerBuilder();
     $containerBuilder->addDefinitions([$serviceId => $definition]);
     $dumper = new YamlDumper($containerBuilder);
     $result = $dumper->dump();
     $message = sprintf('Service `%s` missing. Define it in your services.yml:', $serviceId);
     $this->output->writeln('--- ' . $message . PHP_EOL);
     $this->output->write($result, true);
     $errorMessages = ['Service ' . $serviceId . ' was not found.'];
     $formatter = new FormatterHelper();
     $formattedBlock = $formatter->formatBlock($errorMessages, 'error', true);
     $this->output->writeln('');
     $this->output->writeln($formattedBlock);
     $this->output->writeln('');
     $question = sprintf('<question>Do you want to create a specification for %s? (Y/n)</question>', $guessedFqcn);
     $dialog = new DialogHelper();
     if ($dialog->askConfirmation($this->output, $question, true)) {
         $this->specRunner->runDescCommand($guessedFqcn);
     }
 }
开发者ID:kix,项目名称:behat-sf2-service-generator,代码行数:28,代码来源:NonExistentServiceObserver.php

示例4: testFormatBlock

 public function testFormatBlock()
 {
     $formatter = new FormatterHelper();
     $this->assertEquals('<error> Some text to display </error>', $formatter->formatBlock('Some text to display', 'error'), '::formatBlock() formats a message in a block');
     $this->assertEquals("<error> Some text to display </error>\n<error> foo bar              </error>", $formatter->formatBlock(array('Some text to display', 'foo bar'), 'error'), '::formatBlock() formats a message in a block');
     $this->assertEquals("<error>                        </error>\n<error>  Some text to display  </error>\n<error>                        </error>", $formatter->formatBlock('Some text to display', 'error', true), '::formatBlock() formats a message in a block');
 }
开发者ID:notbrain,项目名称:symfony,代码行数:7,代码来源:FormatterHelperTest.php

示例5: testFormatBlockWithDiacriticLetters

 public function testFormatBlockWithDiacriticLetters()
 {
     if (!extension_loaded('mbstring')) {
         $this->markTestSkipped('This test requires mbstring to work.');
     }
     $formatter = new FormatterHelper();
     $this->assertEquals('<error>                       </error>' . "\n" . '<error>  Du texte à afficher  </error>' . "\n" . '<error>                       </error>', $formatter->formatBlock('Du texte à afficher', 'error', true), '::formatBlock() formats a message in a block');
 }
开发者ID:laiello,项目名称:masfletes,代码行数:8,代码来源:FormatterHelperTest.php

示例6: executeWithBlueprint

 protected function executeWithBlueprint(Blueprint $blueprint, InputInterface $input, OutputInterface $output)
 {
     $blueprintAction = new BlueprintAction($blueprint, $this->profileManager, $output);
     $blueprintAction->validateTemplate();
     // will throw an exception if there's a problem
     $formatter = new FormatterHelper();
     $formattedBlock = $formatter->formatBlock(['No validation errors found.'], 'info', true);
     $output->writeln("\n\n{$formattedBlock}\n\n");
 }
开发者ID:aoepeople,项目名称:stackformation,代码行数:9,代码来源:ValidateCommand.php

示例7: executeWithStack

 protected function executeWithStack(Stack $stack, InputInterface $input, OutputInterface $output)
 {
     $blueprint = $this->blueprintFactory->getBlueprintByStack($stack);
     $diff = new Diff($output);
     $diff->setStack($stack)->setBlueprint($blueprint);
     $formatter = new FormatterHelper();
     $output->writeln("\n" . $formatter->formatBlock(['Parameters:'], 'error', true) . "\n");
     $diff->diffParameters();
     $output->writeln("\n" . $formatter->formatBlock(['Template:'], 'error', true) . "\n");
     $diff->diffTemplates();
 }
开发者ID:aoepeople,项目名称:stackformation,代码行数:11,代码来源:DiffCommand.php

示例8: format

 public static function format(ConstraintViolationList $problems, GeneratorInterface $generator, FormatterHelper $formatter)
 {
     $messages = [];
     // add header message
     $problemCount = count($problems);
     $name = $generator->getName();
     $messages[] = "While trying to call the generator '{$name}', {$problemCount} problems were found:";
     $messages[] = "";
     /** @var ConstraintViolation $problem */
     foreach ($problems as $problem) {
         $messages[] = "In \$arguments{$problem->getPropertyPath()}: {$problem->getMessage()}";
     }
     return $formatter->formatBlock($messages, 'error', true);
 }
开发者ID:tweedegolf,项目名称:generator,代码行数:14,代码来源:ValidationProblemFormatter.php

示例9: printErrorBlock

 /**
  * Print a debugging message out in a big red block
  *
  * @param $string
  */
 protected function printErrorBlock($string)
 {
     if ($this->formatterHelper === null) {
         $this->formatterHelper = new FormatterHelper();
     }
     $output = $this->formatterHelper->formatBlock($string, 'bg=red;fg=white', true);
     $this->printDebug($output);
 }
开发者ID:zcichanski,项目名称:symfony2-rest,代码行数:13,代码来源:ApiTestCase.php

示例10: setUp

 /**
  * Sets up suite for a test.
  *
  * @param Environment $env
  * @param SpecificationIterator $iterator
  * @param Boolean $skip
  *
  * @return Setup
  */
 public function setUp(Environment $env, SpecificationIterator $iterator, $skip)
 {
     spl_autoload_register(function ($class) {
         $errorMessages = [$class . ' was not found.'];
         $formatter = new FormatterHelper();
         $formattedBlock = $formatter->formatBlock($errorMessages, 'error', true);
         $this->output->writeln('');
         $this->output->writeln($formattedBlock);
         $this->output->writeln('');
         $question = sprintf('Do you want to create a specification for %s? (Y/n)', $class);
         $questionBlock = $formatter->formatBlock($question, 'question', true);
         $dialog = new DialogHelper();
         if ($dialog->askConfirmation($this->output, $questionBlock, true)) {
             $this->output->writeln('');
             $this->specRunner->runDescCommand($class);
         }
     }, true, false);
     return $this->baseTester->setUp($env, $iterator, $skip);
 }
开发者ID:vukanac,项目名称:PhpSpecExtension,代码行数:28,代码来源:PhpSpecTester.php

示例11: renderErrors

 public function renderErrors(Suite $suite)
 {
     $this->renderSuite($suite);
     if (true === $suite->isSuccessful()) {
         return;
     }
     $formatter = new FormatterHelper();
     foreach ($suite->getTests() as $test) {
         if (true === $test->isSuccessful()) {
             continue;
         }
         $this->output->writeln('');
         $lines = [$test];
         if (false === empty($test->getErrorOutput())) {
             $lines[] = '';
             $lines[] = $test->getErrorOutput();
         }
         $this->output->writeln($formatter->formatBlock($lines, 'error', true));
     }
 }
开发者ID:PedroTroller,项目名称:CircleCI-Parallel-Builder,代码行数:20,代码来源:SuiteHelper.php

示例12: changeUser

 /**
  * @return bool
  */
 private function changeUser()
 {
     $user = $this->container->getConfig()->get('command.user');
     // Bypass cache commands as we need the sudoer user to run the commands
     if (null !== $user && (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !== 'flushall') && (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !== 'redis:flushall') && (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !== 'apc:flushall')) {
         $name = $user;
         $user = posix_getpwnam($user);
         posix_setgid($user['gid']);
         posix_setuid($user['uid']);
         if (posix_geteuid() !== (int) $user['uid']) {
             $output = new ConsoleOutput();
             $formatter = new FormatterHelper();
             $output->writeln('', true);
             $errorMessages = array('', ' [Error] ', ' Could not change user to ' . $name . ' ', '');
             $formattedBlock = $formatter->formatBlock($errorMessages, 'error');
             $output->writeln($formattedBlock);
             $output->writeln('', true);
             return false;
         }
     }
     return true;
 }
开发者ID:sinergi,项目名称:core,代码行数:25,代码来源:CommandRuntime.php

示例13: testGet

 public function testGet()
 {
     $application = new Application();
     $command = new \TestCommand();
     $command->setApplication($application);
     $formatterHelper = new FormatterHelper();
     $this->assertEquals($formatterHelper->getName(), $command->getHelper('formatter')->getName(), '->__get() returns the correct helper');
 }
开发者ID:mawaha,项目名称:tracker,代码行数:8,代码来源:CommandTest.php

示例14: finishProcess

 /**
  * Finish current licenser process log and display results in the output.
  */
 public function finishProcess()
 {
     $total = $this->countTotal();
     $additions = $this->countAdditions();
     $updates = $this->countUpdates();
     $untouched = $this->countUntouched();
     $formatter = new FormatterHelper();
     //summary
     $this->output->writeln('', OutputInterface::VERBOSITY_VERBOSE);
     $this->output->writeln(sprintf('<fg=green>[+] Additions: %s</>', $additions), OutputInterface::VERBOSITY_VERBOSE);
     $this->output->writeln(sprintf('<fg=cyan>[u] Updates: %s</>', $updates), OutputInterface::VERBOSITY_VERBOSE);
     $this->output->writeln(sprintf('<fg=yellow>[=] Untouched: %s</>', $untouched), OutputInterface::VERBOSITY_VERBOSE);
     $this->output->writeln('');
     if ($this->watch->isStarted('licenser')) {
         $event = $this->watch->stop('licenser');
         $processMessage = sprintf('%s file(s) has been processed in %s ms, memory usage %.2F MiB', $total, $event->getDuration(), $event->getMemory() / 1024 / 1024);
         if ($this->mode & Licenser::MODE_NORMAL || $this->mode & Licenser::MODE_DRY_RUN) {
             $style = new OutputFormatterStyle('white', $this->mode === Licenser::MODE_DRY_RUN ? 'cyan' : 'green', ['bold']);
             $this->output->getFormatter()->setStyle('success', $style);
             $formattedBlock = $formatter->formatBlock($processMessage, 'success', true);
             $this->output->writeln($formattedBlock);
         } elseif ($this->mode & Licenser::MODE_CHECK_ONLY) {
             $needUpdate = $additions + $updates > 0;
             if ($needUpdate) {
                 $successMsg = sprintf('[WARN] %s file(s) should be updated.', $additions + $updates);
             } else {
                 $successMsg = '[OK] All files contains a valid license header.';
             }
             $style = new OutputFormatterStyle('white', $needUpdate ? 'red' : 'green', ['bold']);
             $this->output->getFormatter()->setStyle('success', $style);
             $formattedBlock = $formatter->formatBlock([$successMsg, $processMessage], 'success', true);
             $this->output->writeln($formattedBlock);
         }
         if ($this->mode === Licenser::MODE_DRY_RUN) {
             $this->output->writeln('');
             $this->output->writeln('<fg=yellow>NOTE: The command run in dry-run mode, it not made any changes.</>');
         }
     }
 }
开发者ID:rafrsr,项目名称:licenser,代码行数:42,代码来源:ProcessLogger.php

示例15: testFormatBlockLGEscaping

 public function testFormatBlockLGEscaping()
 {
     $formatter = new FormatterHelper();
     $this->assertEquals('<error>                            </error>' . "\n" . '<error>  \\<info>some info\\</info>  </error>' . "\n" . '<error>                            </error>', $formatter->formatBlock('<info>some info</info>', 'error', true), '::formatBlock() escapes \'<\' chars');
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:5,代码来源:FormatterHelperTest.php


注:本文中的Symfony\Component\Console\Helper\FormatterHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。