Skip to content

Commit

Permalink
Skip @deprecated rules
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jun 22, 2024
1 parent e448dfb commit b4de54d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/DirectoryToMarkdownPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public function print(string $workingDirectory, array $directories, ?int $catego
*/
private function filterOutSkippedTypes(array $ruleClassWithFilePaths, array $skipTypes): array
{
// remove deprecated classes, as no point in promoting them
$ruleClassWithFilePaths = array_filter($ruleClassWithFilePaths, static fn (RuleClassWithFilePath $ruleClassWithFilePath): bool => $ruleClassWithFilePath->isDeprecated() === false);

if ($skipTypes === []) {
return $ruleClassWithFilePaths;
}
Expand Down
4 changes: 3 additions & 1 deletion src/FileSystem/ClassByTypeFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ public function findByType(string $workingDirectory, array $directories, string
continue;
}

$isDeprecated = str_contains((string) $reflectionClass->getDocComment(), '@deprecated');

$relativeFilePath = PathsHelper::relativeFromDirectory($filePath, $workingDirectory);
$desiredClasses[] = new RuleClassWithFilePath($class, $relativeFilePath);
$desiredClasses[] = new RuleClassWithFilePath($class, $relativeFilePath, $isDeprecated);
}

usort(
Expand Down
8 changes: 7 additions & 1 deletion src/ValueObject/RuleClassWithFilePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ final class RuleClassWithFilePath
{
public function __construct(
private readonly string $class,
private readonly string $path
private readonly string $path,
private readonly bool $isDeprecated
) {
}

Expand All @@ -21,4 +22,9 @@ public function getPath(): string
{
return $this->path;
}

public function isDeprecated(): bool
{
return $this->isDeprecated;
}
}

0 comments on commit b4de54d

Please sign in to comment.