errorLine() public method

The string is formatted before it is written to the output.
public errorLine ( string $string, integer $flags = null )
$string string The string to write. A newline is appended.
$flags integer The flags. One of {@link VERBOSE}, {@link VERY_VERBOSE} and {@link DEBUG}.
 /**
  * @param IO $io
  */
 protected function parseConfig(IO $io)
 {
     $configFile = __DIR__ . '/../../../etc/config.yml';
     if (file_exists($configFile) && is_file($configFile)) {
         $config = Yaml::parse(file_get_contents($configFile));
         try {
             $this->profile = Profile::fromArray($config);
         } catch (\InvalidArgumentException $e) {
             $io->errorLine("Invalid config.yml file");
             exit;
         }
     } else {
         $io->errorLine("No config.yml file");
         exit;
     }
 }
 private function scopeFile($path, $prefix, IO $io)
 {
     $fileContent = file_get_contents($path);
     try {
         $scoppedContent = $this->scoper->addNamespacePrefix($fileContent, $prefix);
         $this->filesystem->dumpFile($path, $scoppedContent);
         $io->writeLine(sprintf('Scoping %s. . . Success', $path));
     } catch (ParsingException $exception) {
         $io->errorLine(sprintf('Scoping %s. . . Fail', $path));
     }
 }
示例#3
0
 /**
  * Handles the "ls" command.
  *
  * @param Args $args The console arguments.
  * @param IO   $io   The I/O.
  *
  * @return int The status code.
  */
 public function handle(Args $args, IO $io)
 {
     $path = Path::makeAbsolute($args->getArgument('path'), $this->currentPath);
     $resources = $this->repo->find($path);
     if (!count($resources)) {
         $io->errorLine("No resources found for path {$path}");
         return 1;
     }
     foreach ($resources as $resource) {
         if ($resource instanceof BodyResource) {
             $io->writeLine($resource->getBody());
         }
     }
     return 0;
 }
示例#4
0
 private function printTrace(IO $io, Exception $exception)
 {
     $traces = $exception->getTrace();
     $cwd = getcwd() . DIRECTORY_SEPARATOR;
     $cwdLength = strlen($cwd);
     $lastTrace = array('function' => '', 'args' => array());
     if (null !== $exception->getFile()) {
         $lastTrace['file'] = $exception->getFile();
     }
     if (null !== $exception->getLine()) {
         $lastTrace['line'] = $exception->getLine();
     }
     array_unshift($traces, $lastTrace);
     $io->errorLine('<b>Exception trace:</b>');
     foreach ($traces as $trace) {
         $namespace = '';
         $class = '';
         $location = 'n/a';
         if (isset($trace['class'])) {
             if (false !== ($pos = strrpos($trace['class'], '\\'))) {
                 $namespace = substr($trace['class'], 0, $pos + 1);
                 $class = substr($trace['class'], $pos + 1);
             } else {
                 $class = $trace['class'];
             }
         }
         if (isset($trace['file'])) {
             if (0 === strpos($trace['file'], $cwd)) {
                 $location = substr($trace['file'], $cwdLength);
             } else {
                 $location = $trace['file'];
             }
         }
         // class, operator, function
         $signature = $class . (isset($trace['type']) ? $trace['type'] : '') . $trace['function'];
         $location .= ':' . (isset($trace['line']) ? $trace['line'] : 'n/a');
         $io->errorLineRaw(sprintf('  %s%s()', $namespace, $io->format('<u>' . $signature . '</u>')));
         $io->errorLineRaw(sprintf('    %s', $io->format('<c1>' . $location . '</c1>')));
     }
     $io->errorLine('');
     $io->errorLine('');
 }
示例#5
0
 private function warnIfProcessTitleNotSupported($processTitle, IO $io)
 {
     if ($processTitle && !ProcessTitle::isSupported()) {
         $io->errorLine('<warn>Notice: Install the proctitle PECL to be able to change the process title.</warn>', IO::VERY_VERBOSE);
     }
 }