Skip to content

Commit

Permalink
bug FriendsOfPHP#149 fixed parsing error display when using --no-ansi…
Browse files Browse the repository at this point in the history
… (fabpot)

This PR was merged into the 3.0-dev branch.

Discussion
----------

fixed parsing error display when using --no-ansi

fixes #117

Commits
-------

a6a4aec updated the error message for phpdocs issues to include the file name
7bf80c5 fixed parsing error display when using --no-ansi
  • Loading branch information
fabpot committed Feb 18, 2015
2 parents d6b2780 + a6a4aec commit 3aaa667
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ CHANGELOG

* 3.0.1 (2015-XX-XX)

* fixed parsing error display when using --no-ansi
* fixed tag parsing when the value is already an array

* 3.0.0 (2015-02-17)
Expand Down
20 changes: 8 additions & 12 deletions Sami/Console/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,14 @@ public function update(Project $project)

public function parse(Project $project)
{
$callback = $this->output->isDecorated() ? array($this, 'messageCallback') : null;

$project->parse($callback, $this->input->getOption('force'));
$project->parse(array($this, 'messageCallback'), $this->input->getOption('force'));

$this->displayParseSummary();
}

public function render(Project $project)
{
$callback = $this->output->isDecorated() ? array($this, 'messageCallback') : null;

$project->render($callback, $this->input->getOption('force'));
$project->render(array($this, 'messageCallback'), $this->input->getOption('force'));

$this->displayRenderSummary();
}
Expand Down Expand Up @@ -143,11 +139,11 @@ public function renderProgressBar($percent, $length)
public function displayParseProgress($progress, $class)
{
if ($this->started) {
$this->output->write("\033[2A");
$this->output->isDecorated() and $this->output->write("\033[2A");
}
$this->started = true;

$this->output->write(sprintf(
$this->output->isDecorated() and $this->output->write(sprintf(
" Parsing <comment>%s</comment>%s\033[K\n %s\033[K\n",
$this->renderProgressBar($progress, 50), count($this->errors) ? ' <fg=red>'.count($this->errors).' error'.(1 == count($this->errors) ? '' : 's').'</>' : '', $class->getName())
);
Expand All @@ -156,11 +152,11 @@ public function displayParseProgress($progress, $class)
public function displayRenderProgress($section, $message, $progression)
{
if ($this->started) {
$this->output->write("\033[2A");
$this->output->isDecorated() and $this->output->write("\033[2A");
}
$this->started = true;

$this->output->write(sprintf(
$this->output->isDecorated() and $this->output->write(sprintf(
" Rendering <comment>%s</comment>\033[K\n <info>%s</info> %s\033[K\n",
$this->renderProgressBar($progression, 50), $section, $message
));
Expand All @@ -172,7 +168,7 @@ public function displayParseEnd(Transaction $transaction)
return;
}

$this->output->write(sprintf("\033[2A<info> Parsing done</info>\033[K\n\033[K\n\033[1A", count($this->errors) ? ' <fg=red>'.count($this->errors).' errors</>' : ''));
$this->output->isDecorated() and $this->output->write(sprintf("\033[2A<info> Parsing done</info>\033[K\n\033[K\n\033[1A", count($this->errors) ? ' <fg=red>'.count($this->errors).' errors</>' : ''));

if ($this->input->getOption('verbose') && count($this->errors)) {
foreach ($this->errors as $error) {
Expand All @@ -189,7 +185,7 @@ public function displayRenderEnd(Diff $diff)
return;
}

$this->output->write("\033[2A<info> Rendering done</info>\033[K\n\033[K\n\033[1A");
$this->output->isDecorated() and $this->output->write("\033[2A<info> Rendering done</info>\033[K\n\033[K\n\033[1A");
}

public function displayParseSummary()
Expand Down
2 changes: 1 addition & 1 deletion Sami/Parser/ParserContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function addErrors($name, $line, array $errors)

public function addError($name, $line, $error)
{
$this->errors[] = sprintf('An error occurred while parsing "%s" line "%d": %s', $name, $line, $error);
$this->errors[] = sprintf('%s on "%s" in %s:%d', $error, $name, $this->file, $line);
}

public function getErrors()
Expand Down

0 comments on commit 3aaa667

Please sign in to comment.