Skip to content

Commit 8bb88c9

Browse files
committed
Marked classes/methods as @final and #[\Override] where applicable
Because we don't want to bump the major version for now, a hard `final` hasn't been used here: `@final` will signal the problem to downstream projects using static analysis. We will move to a hard `final` later on.
1 parent 1cfbd3c commit 8bb88c9

23 files changed

Lines changed: 44 additions & 1 deletion

src/DocbookPage.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
use function str_starts_with;
1616
use function strip_tags;
1717

18-
/** @psalm-immutable */
18+
/**
19+
* @psalm-immutable
20+
* @final
21+
*/
1922
class DocbookPage
2023
{
2124
private const int DEFAULT_ORDER = 100;

src/Environment.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use function in_array;
1111
use function sprintf;
1212

13+
/** @final */
1314
class Environment
1415
{
1516
/** @return non-empty-string */

src/Formatter/AggregatePageFormatter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
namespace Roave\DocbookTool\Formatter;
66

7+
use Override;
78
use Roave\DocbookTool\DocbookPage;
89

10+
/** @final */
911
class AggregatePageFormatter implements PageFormatter
1012
{
1113
/**
@@ -16,6 +18,7 @@ public function __construct(private array $formatters)
1618
{
1719
}
1820

21+
#[Override]
1922
public function __invoke(DocbookPage $page): DocbookPage
2023
{
2124
foreach ($this->formatters as $formatter) {

src/Formatter/ExtractFrontMatter.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Roave\DocbookTool\Formatter;
66

77
use InvalidArgumentException;
8+
use Override;
89
use Psl\Regex;
910
use Psl\Regex\Exception\ExceptionInterface;
1011
use Psl\Type;
@@ -27,6 +28,7 @@ public function __construct(private readonly LoggerInterface $logger)
2728
* @throws ExceptionInterface
2829
* @throws InvalidArgumentException
2930
*/
31+
#[Override]
3032
public function __invoke(DocbookPage $page): DocbookPage
3133
{
3234
$this->logger->debug(sprintf('[%s] Checking page "%s" for YAML front matter', self::class, $page->slug()));

src/Formatter/InlineCodeFromFile.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Roave\DocbookTool\Formatter;
66

7+
use Override;
78
use Psl\Regex;
89
use Psr\Log\LoggerInterface;
910
use Roave\DocbookTool\DocbookPage;
@@ -23,6 +24,7 @@ public function __construct(private string $contentPath, private readonly Logger
2324
{
2425
}
2526

27+
#[Override]
2628
public function __invoke(DocbookPage $page): DocbookPage
2729
{
2830
$this->logger->debug(sprintf('[%s] Checking if source code files can be inlined in %s', self::class, $page->slug()));

src/Formatter/InlineExternalImages.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Roave\DocbookTool\Formatter;
66

7+
use Override;
78
use Psl\Regex;
89
use Psr\Log\LoggerInterface;
910
use Roave\DocbookTool\DocbookPage;
@@ -27,6 +28,7 @@ public function __construct(private readonly LoggerInterface $logger, private Re
2728
}
2829

2930
/** @throws RuntimeException */
31+
#[Override]
3032
public function __invoke(DocbookPage $page): DocbookPage
3133
{
3234
$this->logger->debug(sprintf('[%s] Checking if external images can be inlined in %s', self::class, $page->slug()));

src/Formatter/InlineFeatureFile.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Roave\DocbookTool\Formatter;
66

7+
use Override;
78
use Psl\Regex;
89
use Psr\Log\LoggerInterface;
910
use Roave\DocbookTool\DocbookPage;
@@ -20,6 +21,7 @@ public function __construct(private string $featuresPath, private readonly Logge
2021
{
2122
}
2223

24+
#[Override]
2325
public function __invoke(DocbookPage $page): DocbookPage
2426
{
2527
$this->logger->debug(sprintf('[%s] Checking if feature files can be inlined in %s', self::class, $page->slug()));

src/Formatter/MarkdownToHtml.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Roave\DocbookTool\Formatter;
66

77
use Michelf\MarkdownExtra;
8+
use Override;
89
use Psr\Log\LoggerInterface;
910
use Roave\DocbookTool\DocbookPage;
1011

@@ -26,6 +27,7 @@ public function __construct(private readonly LoggerInterface $logger)
2627
ini_set('pcre.backtrack_limit', 5_000_000);
2728
}
2829

30+
#[Override]
2931
public function __invoke(DocbookPage $page): DocbookPage
3032
{
3133
$this->logger->debug(sprintf('[%s] Converting MD to HTML in "%s"', self::class, $page->slug()));

src/Formatter/RenderPlantUmlDiagramInline.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Roave\DocbookTool\Formatter;
66

7+
use Override;
78
use Psl\Encoding;
89
use Psl\Regex;
910
use Psl\Shell\ErrorOutputBehavior;
@@ -32,6 +33,7 @@ public function __construct(private readonly LoggerInterface $logger)
3233
}
3334

3435
/** @throws RuntimeException */
36+
#[Override]
3537
public function __invoke(DocbookPage $page): DocbookPage
3638
{
3739
$this->logger->debug(sprintf('[%s] Checking if PlantUML diagrams can be rendered and inlined in %s', self::class, $page->slug()));

src/Formatter/ReplaceGithubMarkdownAlerts.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Roave\DocbookTool\Formatter;
66

7+
use Override;
78
use Psl\Regex;
89
use Psr\Log\LoggerInterface;
910
use Roave\DocbookTool\DocbookPage;
@@ -28,6 +29,7 @@ public function __construct(private readonly LoggerInterface $logger)
2829
{
2930
}
3031

32+
#[Override]
3133
public function __invoke(DocbookPage $page): DocbookPage
3234
{
3335
$this->logger->debug(sprintf('[%s] Making replacements for GFM alerts in %s', self::class, $page->slug()));

0 commit comments

Comments
 (0)