Skip to content

Commit a73a760

Browse files
committed
feat: start using cli-tools
1 parent 621f363 commit a73a760

File tree

4 files changed

+10
-20
lines changed

4 files changed

+10
-20
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"symfony/yaml": "~3.4|~4.3|~5.1|~5.2",
3232
"symfony/process": "~3.4|~4.3|~5.1|~5.2",
3333
"phpdocumentor/reflection-docblock": "~4.3|~5.2.1",
34-
"wdes/php-i18n-l10n": "^2.0"
34+
"wdes/php-i18n-l10n": "^2.0",
35+
"code-lts/cli-tools": "dev-main"
3536
},
3637
"scripts": {
3738
"phpunit": "./vendor/bin/phpunit",

src/Console/Command/Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ abstract class Command extends BaseCommand
5353
protected $transactions = [];
5454

5555
/**
56-
* @var string[]
56+
* @var \Doctum\Parser\ParseError[]
5757
*/
5858
protected $errors = [];
5959

@@ -254,7 +254,7 @@ public function displayParseEnd(Transaction $transaction): void
254254
if ($this->output->isVerbose() && count($this->errors) > 0) {
255255
foreach ($this->errors as $error) {
256256
$this->output->write('<fg=red>ERROR</>: ');
257-
$this->output->writeln($error, OutputInterface::OUTPUT_RAW);
257+
$this->output->writeln($error->__toString(), OutputInterface::OUTPUT_RAW);
258258
}
259259
$this->output->writeln('');
260260
}

src/Parser/NodeVisitor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,14 +347,14 @@ protected function addTagFromCommentToMethod(
347347
if (is_array($tag[0])) {
348348
$methodOrFunctionOrProperty->setHint(is_array($tag[0][0]) ? $this->resolveHint($tag[0][0]) : $tag[0][0]);
349349
} else {
350-
$errors[] = '[Hint] Hint is wrong (' . json_encode($tag[0]) . ') for ' . $methodOrFunctionOrProperty->getName() . ' at line ' . $methodOrFunctionOrProperty->getLine();
350+
$errors[] = '[Hint] Hint is wrong (' . json_encode($tag[0]) . ')';
351351
}
352352
}
353353
if (isset($tag[1])) {
354354
if (is_array($tag[1])) {
355355
$methodOrFunctionOrProperty->setHintDesc($tag[0][1]);
356356
} else {
357-
$errors[] = '[Hint] Hint description is wrong (' . json_encode($tag[1]) . ') for ' . $methodOrFunctionOrProperty->getName() . ' at line ' . $methodOrFunctionOrProperty->getLine();
357+
$errors[] = '[Hint] Hint description is wrong (' . json_encode($tag[1]) . ')';
358358
}
359359
}
360360
}

src/Parser/ParseError.php

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,13 @@
99

1010
namespace Doctum\Parser;
1111

12-
final class ParseError
13-
{
14-
/** @var string */
15-
private $message;
16-
/** @var string|null */
17-
private $file;
18-
/** @var int */
19-
private $line;
12+
use CodeLts\CliTools\Error;
2013

21-
public function __construct(string $message, ?string $file, int $line)
22-
{
23-
$this->message = $message;
24-
$this->file = $file;
25-
$this->line = $line;
26-
}
14+
final class ParseError extends Error
15+
{
2716

2817
public function __toString()
2918
{
30-
return sprintf('%s in %s:%d', $this->message, $this->file ?? '', $this->line);
19+
return sprintf('%s in %s:%d', $this->getMessage(), $this->getFile() ?? '', $this->getLine());
3120
}
3221
}

0 commit comments

Comments
 (0)