Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit d1c31d0

Browse files
committed
Print parser errors again
1 parent af0ca73 commit d1c31d0

File tree

3 files changed

+38
-53
lines changed

3 files changed

+38
-53
lines changed

src/Violation/Renderer/Console/BaseRenderer.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,40 @@ public function __construct(OutputInterface $output, MessageHelper $messageHelpe
2929
$this->output = $output;
3030
$this->messageHelper = $messageHelper;
3131
}
32+
33+
/**
34+
* @param Violation[] $violations
35+
* @param Error[] $errors
36+
*/
37+
public function renderViolations(array $violations, array $errors)
38+
{
39+
$this->printViolations($violations);
40+
$this->printErrors($errors);
41+
}
42+
43+
/**
44+
* @param Violation[] $violations
45+
*/
46+
protected abstract function printViolations(array $violations);
47+
48+
/**
49+
* @param Error[] $errors
50+
*/
51+
protected function printErrors(array $errors)
52+
{
53+
if (0 === count($errors)) {
54+
return;
55+
}
56+
57+
$this->output->writeln("");
58+
$this->output->writeln('<error>Your project contains invalid code:</error>');
59+
foreach ($errors as $error) {
60+
$this->output->writeln(
61+
sprintf(
62+
'<error>%s</error>',
63+
$error->getRawMessage()
64+
)
65+
);
66+
}
67+
}
3268
}

src/Violation/Renderer/Console/DefaultRenderer.php

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,8 @@ public function __construct(OutputInterface $output, MessageHelper $messageHelpe
2424

2525
/**
2626
* @param Violation[] $violations
27-
* @param Error[] $errors
2827
*/
29-
public function renderViolations(array $violations, array $errors)
30-
{
31-
$this->printViolations($violations);
32-
$this->printErrors($errors);
33-
}
34-
35-
/**
36-
* @param Violation[] $violations
37-
*/
38-
private function printViolations(array $violations)
28+
protected function printViolations(array $violations)
3929
{
4030
if (0 === count($violations)) {
4131
return;
@@ -66,26 +56,6 @@ private function printViolations(array $violations)
6656
$table->render();
6757
}
6858

69-
/**
70-
* @param Error[] $errors
71-
*/
72-
private function printErrors(array $errors)
73-
{
74-
if (0 === count($errors)) {
75-
return;
76-
}
77-
78-
$this->output->writeln('<error>Your project contains invalid code:</error>');
79-
foreach ($errors as $error) {
80-
$this->output->writeln(
81-
sprintf(
82-
'<error>%s</error>',
83-
$error->getRawMessage()
84-
)
85-
);
86-
}
87-
}
88-
8959
/**
9060
* @param PhpFileInfo $file
9161
*

src/Violation/Renderer/Console/SimpleRenderer.php

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,8 @@ public function __construct(OutputInterface $output, MessageHelper $messageHelpe
2020

2121
/**
2222
* @param Violation[] $violations
23-
* @param Error[] $errors
2423
*/
25-
public function renderViolations(array $violations, array $errors)
26-
{
27-
$this->printViolations($violations);
28-
$this->printErrors($errors);
29-
}
30-
31-
/**
32-
* @param Violation[] $violations
33-
*/
34-
private function printViolations(array $violations)
24+
protected function printViolations(array $violations)
3525
{
3626
if (0 === count($violations)) {
3727
return;
@@ -55,15 +45,4 @@ private function printViolations(array $violations)
5545
));
5646
}
5747
}
58-
59-
/**
60-
* @param Error[] $errors
61-
*/
62-
private function printErrors(array $errors)
63-
{
64-
if (0 === count($errors)) {
65-
return;
66-
}
67-
68-
}
6948
}

0 commit comments

Comments
 (0)