Skip to content

Commit 91f6f52

Browse files
committed
wip
1 parent fb22c6e commit 91f6f52

File tree

5 files changed

+27
-5
lines changed

5 files changed

+27
-5
lines changed

src/Command/AnalyzeCommand.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public function run(?string $projectDirectory = null, array $skip = []): int
106106
$this->outputPrinter->writeln($lineFilePath);
107107
}
108108

109+
// identifier
110+
$this->outputPrinter->writeln(sprintf('* id: <fg=cyan>[%s]</>', $allRuleError->getIdentifier()));
111+
$this->outputPrinter->newLine(2);
112+
109113
$this->outputPrinter->newLine(2);
110114

111115
++$i;

src/Rule/DuplicatedContextDefinitionContentsRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function process(
5454
$maskStrings
5555
);
5656

57-
$ruleErrors[] = new RuleError($errorMessage, $lineFilePaths);
57+
$ruleErrors[] = new RuleError($errorMessage, $lineFilePaths, $this->getIdentifier());
5858
}
5959

6060
return $ruleErrors;

src/Rule/DuplicatedMaskRule.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ public function process(
5555
$lineFilePaths[] = $relativeFilePath . ':' . $sameMakClassMethodContextDefinition->getMethodLine();
5656
}
5757

58-
$ruleErrors[] = new RuleError(sprintf('Duplicated mask "%s"', $mask), $lineFilePaths);
58+
$ruleErrors[] = new RuleError(sprintf(
59+
'Duplicated mask "%s"',
60+
$mask
61+
), $lineFilePaths, $this->getIdentifier());
5962
}
6063

6164
return $ruleErrors;

src/Rule/UnusedContextDefinitionsRule.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@ public function process(
3434
$ruleErrors = [];
3535

3636
foreach ($unusedMasks as $unusedMask) {
37-
$ruleErrors[] = new RuleError(sprintf(
37+
$errorMessage = sprintf(
3838
'The mask "%s" and its definition %s::%s() is never used',
3939
$unusedMask->mask,
4040
$unusedMask->className,
4141
$unusedMask->methodName
42-
), [$unusedMask->filePath . ':' . $unusedMask->line]);
42+
);
43+
44+
$ruleErrors[] = new RuleError(
45+
$errorMessage,
46+
[$unusedMask->filePath . ':' . $unusedMask->line],
47+
$this->getIdentifier()
48+
);
4349
}
4450

4551
return $ruleErrors;

src/ValueObject/RuleError.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44

55
namespace Rector\Behastan\ValueObject;
66

7+
use Rector\Behastan\Enum\RuleIdentifier;
8+
79
final readonly class RuleError
810
{
911
/**
1012
* @param string[] $lineFilePaths
13+
* @param RuleIdentifier::* $identifier
1114
*/
1215
public function __construct(
1316
private string $message,
14-
private array $lineFilePaths
17+
private array $lineFilePaths,
18+
private string $identifier,
1519
) {
1620
}
1721

@@ -27,4 +31,9 @@ public function getLineFilePaths(): array
2731
{
2832
return $this->lineFilePaths;
2933
}
34+
35+
public function getIdentifier(): string
36+
{
37+
return $this->identifier;
38+
}
3039
}

0 commit comments

Comments
 (0)