mirror of
https://github.com/doctrine/doctrine-website.git
synced 2026-03-23 22:32:11 +01:00
Use final and readonly where possible
This commit is contained in:
@@ -28,7 +28,7 @@ use function is_string;
|
||||
use function realpath;
|
||||
use function sprintf;
|
||||
|
||||
class Application
|
||||
final readonly class Application
|
||||
{
|
||||
public const ENV_PROD = 'prod';
|
||||
public const ENV_STAGING = 'staging';
|
||||
|
||||
@@ -10,13 +10,16 @@ use function file_get_contents;
|
||||
use function hash;
|
||||
use function realpath;
|
||||
|
||||
/** @final */
|
||||
class AssetIntegrityGenerator
|
||||
{
|
||||
/** @var string[] */
|
||||
private array $cache = [];
|
||||
|
||||
public function __construct(private string $sourceDir, private string $webpackBuildDir)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $sourceDir,
|
||||
private readonly string $webpackBuildDir,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getAssetIntegrity(string $path, string|null $rootPath = null): string
|
||||
|
||||
@@ -10,7 +10,7 @@ use function array_filter;
|
||||
use function glob;
|
||||
use function sprintf;
|
||||
|
||||
class CacheClearer
|
||||
final readonly class CacheClearer
|
||||
{
|
||||
public function __construct(
|
||||
private Filesystem $filesystem,
|
||||
|
||||
@@ -20,11 +20,11 @@ use function is_bool;
|
||||
use function is_string;
|
||||
use function sprintf;
|
||||
|
||||
class BuildAllCommand extends Command
|
||||
final class BuildAllCommand extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private string $rootDir,
|
||||
private string $env,
|
||||
private readonly string $rootDir,
|
||||
private readonly string $env,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@@ -14,10 +14,11 @@ use function assert;
|
||||
use function is_bool;
|
||||
use function is_string;
|
||||
|
||||
class BuildDocsCommand extends Command
|
||||
final class BuildDocsCommand extends Command
|
||||
{
|
||||
public function __construct(private BuildDocs $buildDocs)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly BuildDocs $buildDocs,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ use function realpath;
|
||||
use function sprintf;
|
||||
use function time;
|
||||
|
||||
class BuildWebsiteCommand extends Command
|
||||
final class BuildWebsiteCommand extends Command
|
||||
{
|
||||
private const WATCH_DIRS = [
|
||||
'config',
|
||||
@@ -37,9 +37,9 @@ class BuildWebsiteCommand extends Command
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private WebsiteBuilder $websiteBuilder,
|
||||
private string $rootDir,
|
||||
private string $env,
|
||||
private readonly WebsiteBuilder $websiteBuilder,
|
||||
private readonly string $rootDir,
|
||||
private readonly string $env,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@@ -15,14 +15,14 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
class BuildWebsiteDataCommand extends Command
|
||||
final class BuildWebsiteDataCommand extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private ProjectDataBuilder $projectDataBuilder,
|
||||
private ProjectContributorDataBuilder $projectContributorDataBuilder,
|
||||
private ContributorDataBuilder $contributorDataBuilder,
|
||||
private BlogPostDataBuilder $blogPostDataBuilder,
|
||||
private WebsiteDataWriter $dataWriter,
|
||||
private readonly ProjectDataBuilder $projectDataBuilder,
|
||||
private readonly ProjectContributorDataBuilder $projectContributorDataBuilder,
|
||||
private readonly ContributorDataBuilder $contributorDataBuilder,
|
||||
private readonly BlogPostDataBuilder $blogPostDataBuilder,
|
||||
private readonly WebsiteDataWriter $dataWriter,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@@ -14,10 +14,13 @@ use function assert;
|
||||
use function is_string;
|
||||
use function sprintf;
|
||||
|
||||
class ClearBuildCacheCommand extends Command
|
||||
final class ClearBuildCacheCommand extends Command
|
||||
{
|
||||
public function __construct(private CacheClearer $cacheClearer, private string $rootDir, private string $env)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CacheClearer $cacheClearer,
|
||||
private readonly string $rootDir,
|
||||
private readonly string $env,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
class SyncRepositoriesCommand extends Command
|
||||
final class SyncRepositoriesCommand extends Command
|
||||
{
|
||||
public function __construct(
|
||||
private ProjectDataRepository $projectDataRepository,
|
||||
private ProjectGitSyncer $projectGitSyncer,
|
||||
private readonly ProjectDataRepository $projectDataRepository,
|
||||
private readonly ProjectGitSyncer $projectGitSyncer,
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
@@ -8,11 +8,12 @@ use Doctrine\StaticWebsiteGenerator\Controller\Response;
|
||||
use Doctrine\Website\Model\BlogPost;
|
||||
use Doctrine\Website\Repositories\BlogPostRepository;
|
||||
|
||||
class AtomController
|
||||
final readonly class AtomController
|
||||
{
|
||||
/** @param BlogPostRepository<BlogPost> $blogPostRepository */
|
||||
public function __construct(private BlogPostRepository $blogPostRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private BlogPostRepository $blogPostRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function index(): Response
|
||||
|
||||
@@ -8,11 +8,12 @@ use Doctrine\StaticWebsiteGenerator\Controller\Response;
|
||||
use Doctrine\Website\Model\BlogPost;
|
||||
use Doctrine\Website\Repositories\BlogPostRepository;
|
||||
|
||||
class BlogController
|
||||
final readonly class BlogController
|
||||
{
|
||||
/** @param BlogPostRepository<BlogPost> $blogPostRepository */
|
||||
public function __construct(private BlogPostRepository $blogPostRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private BlogPostRepository $blogPostRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function index(): Response
|
||||
|
||||
@@ -9,11 +9,12 @@ use Doctrine\Website\Model\CommittersStats;
|
||||
use Doctrine\Website\Model\TeamMember;
|
||||
use Doctrine\Website\Repositories\TeamMemberRepository;
|
||||
|
||||
class ConsultingController
|
||||
final readonly class ConsultingController
|
||||
{
|
||||
/** @param TeamMemberRepository<TeamMember> $teamMemberRepository */
|
||||
public function __construct(private TeamMemberRepository $teamMemberRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private TeamMemberRepository $teamMemberRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function index(): Response
|
||||
|
||||
@@ -8,11 +8,12 @@ use Doctrine\StaticWebsiteGenerator\Controller\Response;
|
||||
use Doctrine\Website\Model\Project;
|
||||
use Doctrine\Website\Repositories\ProjectRepository;
|
||||
|
||||
class DocumentationController
|
||||
final readonly class DocumentationController
|
||||
{
|
||||
/** @param ProjectRepository<Project> $projectRepository */
|
||||
public function __construct(private ProjectRepository $projectRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private ProjectRepository $projectRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function view(string $docsSlug, string $docsVersion): Response
|
||||
|
||||
@@ -15,7 +15,7 @@ use Doctrine\Website\Repositories\DoctrineUserRepository;
|
||||
use Doctrine\Website\Repositories\PartnerRepository;
|
||||
use Doctrine\Website\Repositories\ProjectRepository;
|
||||
|
||||
class HomepageController
|
||||
final readonly class HomepageController
|
||||
{
|
||||
/**
|
||||
* @param BlogPostRepository<BlogPost> $blogPostRepository
|
||||
|
||||
@@ -8,11 +8,12 @@ use Doctrine\StaticWebsiteGenerator\Controller\Response;
|
||||
use Doctrine\Website\Model\Partner;
|
||||
use Doctrine\Website\Repositories\PartnerRepository;
|
||||
|
||||
final class PartnersController
|
||||
final readonly class PartnersController
|
||||
{
|
||||
/** @param PartnerRepository<Partner> $partnerRepository */
|
||||
public function __construct(private PartnerRepository $partnerRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private PartnerRepository $partnerRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function index(): Response
|
||||
|
||||
@@ -10,7 +10,7 @@ use Doctrine\Website\Model\ProjectContributor;
|
||||
use Doctrine\Website\Repositories\ProjectContributorRepository;
|
||||
use Doctrine\Website\Repositories\ProjectRepository;
|
||||
|
||||
class ProjectController
|
||||
final readonly class ProjectController
|
||||
{
|
||||
/**
|
||||
* @param ProjectRepository<Project> $projectRepository
|
||||
|
||||
@@ -8,11 +8,12 @@ use Doctrine\StaticWebsiteGenerator\Controller\Response;
|
||||
use Doctrine\Website\Model\SitemapPage;
|
||||
use Doctrine\Website\Repositories\SitemapPageRepository;
|
||||
|
||||
class SitemapController
|
||||
final readonly class SitemapController
|
||||
{
|
||||
/** @param SitemapPageRepository<SitemapPage> $sitemapPageRepository */
|
||||
public function __construct(private SitemapPageRepository $sitemapPageRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private SitemapPageRepository $sitemapPageRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function index(): Response
|
||||
|
||||
@@ -8,11 +8,12 @@ use Doctrine\StaticWebsiteGenerator\Controller\Response;
|
||||
use Doctrine\Website\Model\Sponsor;
|
||||
use Doctrine\Website\Repositories\SponsorRepository;
|
||||
|
||||
class SponsorshipController
|
||||
final readonly class SponsorshipController
|
||||
{
|
||||
/** @param SponsorRepository<Sponsor> $sponsorRepository */
|
||||
public function __construct(private SponsorRepository $sponsorRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private SponsorRepository $sponsorRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function index(): Response
|
||||
|
||||
@@ -8,11 +8,12 @@ use Doctrine\StaticWebsiteGenerator\Controller\Response;
|
||||
use Doctrine\Website\Model\Contributor;
|
||||
use Doctrine\Website\Repositories\ContributorRepository;
|
||||
|
||||
class TeamController
|
||||
final readonly class TeamController
|
||||
{
|
||||
/** @param ContributorRepository<Contributor> $contributorRepository */
|
||||
public function __construct(private ContributorRepository $contributorRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private ContributorRepository $contributorRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function maintainers(): Response
|
||||
|
||||
@@ -6,12 +6,13 @@ namespace Doctrine\Website\DataBuilder;
|
||||
|
||||
use Doctrine\StaticWebsiteGenerator\SourceFile\SourceFileFilesystemReader;
|
||||
|
||||
class BlogPostDataBuilder implements DataBuilder
|
||||
final readonly class BlogPostDataBuilder implements DataBuilder
|
||||
{
|
||||
public const DATA_FILE = 'blog_posts';
|
||||
|
||||
public function __construct(private SourceFileFilesystemReader $sourceFileFilesystemReader)
|
||||
{
|
||||
public function __construct(
|
||||
private SourceFileFilesystemReader $sourceFileFilesystemReader,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
|
||||
@@ -7,13 +7,14 @@ namespace Doctrine\Website\DataBuilder;
|
||||
use Doctrine\Website\Model\ProjectContributor;
|
||||
use Doctrine\Website\Repositories\ProjectContributorRepository;
|
||||
|
||||
class ContributorDataBuilder implements DataBuilder
|
||||
final readonly class ContributorDataBuilder implements DataBuilder
|
||||
{
|
||||
public const DATA_FILE = 'contributors';
|
||||
|
||||
/** @param ProjectContributorRepository<ProjectContributor> $projectContributorRepository */
|
||||
public function __construct(private ProjectContributorRepository $projectContributorRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private ProjectContributorRepository $projectContributorRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
|
||||
@@ -10,7 +10,7 @@ use Doctrine\Website\Model\TeamMember;
|
||||
use Doctrine\Website\Repositories\ProjectRepository;
|
||||
use Doctrine\Website\Repositories\TeamMemberRepository;
|
||||
|
||||
class ProjectContributorDataBuilder implements DataBuilder
|
||||
final readonly class ProjectContributorDataBuilder implements DataBuilder
|
||||
{
|
||||
public const DATA_FILE = 'project_contributors';
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ use function end;
|
||||
use function strnatcmp;
|
||||
use function usort;
|
||||
|
||||
class ProjectDataBuilder implements DataBuilder
|
||||
final readonly class ProjectDataBuilder implements DataBuilder
|
||||
{
|
||||
public const DATA_FILE = 'projects';
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Website\DataBuilder;
|
||||
|
||||
class WebsiteData
|
||||
final readonly class WebsiteData
|
||||
{
|
||||
/** @param mixed[] $data */
|
||||
public function __construct(private string $name, private array $data)
|
||||
{
|
||||
public function __construct(
|
||||
private string $name,
|
||||
private array $data,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
|
||||
@@ -11,10 +11,12 @@ use function file_get_contents;
|
||||
use function json_decode;
|
||||
use function sprintf;
|
||||
|
||||
/** @final */
|
||||
class WebsiteDataReader
|
||||
{
|
||||
public function __construct(private string $cacheDir)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $cacheDir,
|
||||
) {
|
||||
}
|
||||
|
||||
public function read(string $file): WebsiteData
|
||||
|
||||
@@ -13,10 +13,11 @@ use function mkdir;
|
||||
use const JSON_PRETTY_PRINT;
|
||||
use const JSON_UNESCAPED_SLASHES;
|
||||
|
||||
class WebsiteDataWriter
|
||||
final readonly class WebsiteDataWriter
|
||||
{
|
||||
public function __construct(private string $cacheDir)
|
||||
{
|
||||
public function __construct(
|
||||
private string $cacheDir,
|
||||
) {
|
||||
}
|
||||
|
||||
public function write(WebsiteData $websiteData): void
|
||||
|
||||
@@ -6,11 +6,12 @@ namespace Doctrine\Website\DataSources;
|
||||
|
||||
use Doctrine\SkeletonMapper\DataSource\DataSource;
|
||||
|
||||
final class ArrayDataSource implements DataSource
|
||||
final readonly class ArrayDataSource implements DataSource
|
||||
{
|
||||
/** @param mixed[] $sourceRows */
|
||||
public function __construct(private array $sourceRows)
|
||||
{
|
||||
public function __construct(
|
||||
private array $sourceRows,
|
||||
) {
|
||||
}
|
||||
|
||||
/** @return mixed[][] */
|
||||
|
||||
@@ -9,10 +9,11 @@ use Doctrine\SkeletonMapper\DataSource\DataSource;
|
||||
use Doctrine\Website\DataBuilder\BlogPostDataBuilder;
|
||||
use Doctrine\Website\DataBuilder\WebsiteDataReader;
|
||||
|
||||
class BlogPosts implements DataSource
|
||||
final readonly class BlogPosts implements DataSource
|
||||
{
|
||||
public function __construct(private WebsiteDataReader $dataReader)
|
||||
{
|
||||
public function __construct(
|
||||
private WebsiteDataReader $dataReader,
|
||||
) {
|
||||
}
|
||||
|
||||
/** @return mixed[][] */
|
||||
|
||||
@@ -12,7 +12,7 @@ use Doctrine\Website\Model\TeamMember;
|
||||
use Doctrine\Website\Repositories\ProjectRepository;
|
||||
use Doctrine\Website\Repositories\TeamMemberRepository;
|
||||
|
||||
class Contributors implements DataSource
|
||||
final readonly class Contributors implements DataSource
|
||||
{
|
||||
/**
|
||||
* @param TeamMemberRepository<TeamMember> $teamMemberRepository
|
||||
|
||||
@@ -12,7 +12,7 @@ use Doctrine\Website\Model\TeamMember;
|
||||
use Doctrine\Website\Repositories\ProjectRepository;
|
||||
use Doctrine\Website\Repositories\TeamMemberRepository;
|
||||
|
||||
class ProjectContributors implements DataSource
|
||||
final readonly class ProjectContributors implements DataSource
|
||||
{
|
||||
/**
|
||||
* @param TeamMemberRepository<TeamMember> $teamMemberRepository
|
||||
|
||||
@@ -8,10 +8,11 @@ use Doctrine\SkeletonMapper\DataSource\DataSource;
|
||||
use Doctrine\Website\DataBuilder\ProjectDataBuilder;
|
||||
use Doctrine\Website\DataBuilder\WebsiteDataReader;
|
||||
|
||||
class Projects implements DataSource
|
||||
final readonly class Projects implements DataSource
|
||||
{
|
||||
public function __construct(private WebsiteDataReader $dataReader)
|
||||
{
|
||||
public function __construct(
|
||||
private WebsiteDataReader $dataReader,
|
||||
) {
|
||||
}
|
||||
|
||||
/** @return mixed[][] */
|
||||
|
||||
@@ -8,10 +8,11 @@ use DateTimeImmutable;
|
||||
use Doctrine\SkeletonMapper\DataSource\DataSource;
|
||||
use Doctrine\StaticWebsiteGenerator\SourceFile\SourceFileRepository;
|
||||
|
||||
class SitemapPages implements DataSource
|
||||
final readonly class SitemapPages implements DataSource
|
||||
{
|
||||
public function __construct(private SourceFileRepository $sourceFileRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private SourceFileRepository $sourceFileRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
/** @return mixed[][] */
|
||||
|
||||
@@ -17,7 +17,7 @@ use function array_filter;
|
||||
use function count;
|
||||
use function sprintf;
|
||||
|
||||
class BuildDocs
|
||||
final readonly class BuildDocs
|
||||
{
|
||||
/** @param ProjectRepository<Project> $projectRepository */
|
||||
public function __construct(
|
||||
|
||||
@@ -10,6 +10,7 @@ use function ltrim;
|
||||
use function sprintf;
|
||||
use function substr;
|
||||
|
||||
/** @final */
|
||||
class CodeBlockConsoleRenderer
|
||||
{
|
||||
/** @param string[] $lines */
|
||||
|
||||
@@ -9,7 +9,7 @@ use Highlight\Highlighter;
|
||||
use function sprintf;
|
||||
use function trim;
|
||||
|
||||
class CodeBlockLanguageDetector
|
||||
final readonly class CodeBlockLanguageDetector
|
||||
{
|
||||
/**
|
||||
* We use some language aliases not supported by our highlighter library
|
||||
@@ -22,8 +22,9 @@ class CodeBlockLanguageDetector
|
||||
'php-attributes' => 'php',
|
||||
];
|
||||
|
||||
public function __construct(private string $rootDir)
|
||||
{
|
||||
public function __construct(
|
||||
private string $rootDir,
|
||||
) {
|
||||
}
|
||||
|
||||
/** @param string[] $lines */
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Doctrine\Website\Docs;
|
||||
|
||||
use function in_array;
|
||||
|
||||
class CodeBlockRenderer
|
||||
final readonly class CodeBlockRenderer
|
||||
{
|
||||
private const CONSOLE_LANGUAGES = ['terminal', 'bash', 'sh', 'console'];
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ use function sha1;
|
||||
use function sprintf;
|
||||
use function str_replace;
|
||||
|
||||
/** @final */
|
||||
class CodeBlockWithLineNumbersRenderer
|
||||
{
|
||||
/**
|
||||
@@ -31,23 +32,24 @@ class CodeBlockWithLineNumbersRenderer
|
||||
private const CODE_LINE_TABLE_COLUMN_TEMPLATE = '<td class="code-line" rowspan="%d">{{ RENDERED_CODE }}</td>';
|
||||
|
||||
private const CODE_BLOCK_TABLE_TEMPLATE = <<<'TEMPLATE'
|
||||
<pre class="code-block-table">
|
||||
<code class="%s">
|
||||
<button
|
||||
type="button"
|
||||
class="copy-to-clipboard"
|
||||
data-copy-element-id="%s"
|
||||
title="Copy to Clipboard"
|
||||
>
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
<div id="%s">%s</div>
|
||||
</code>
|
||||
</pre>
|
||||
TEMPLATE;
|
||||
<pre class="code-block-table">
|
||||
<code class="%s">
|
||||
<button
|
||||
type="button"
|
||||
class="copy-to-clipboard"
|
||||
data-copy-element-id="%s"
|
||||
title="Copy to Clipboard"
|
||||
>
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
<div id="%s">%s</div>
|
||||
</code>
|
||||
</pre>
|
||||
TEMPLATE;
|
||||
|
||||
public function __construct(private Highlighter $highlighter)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Highlighter $highlighter,
|
||||
) {
|
||||
}
|
||||
|
||||
/** @param string[] $lines */
|
||||
|
||||
@@ -10,16 +10,17 @@ use Doctrine\Website\Model\Project;
|
||||
use Doctrine\Website\Model\ProjectVersion;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
/** @final */
|
||||
class RSTBuilder
|
||||
{
|
||||
public function __construct(
|
||||
private RSTFileRepository $rstFileRepository,
|
||||
private RSTCopier $rstCopier,
|
||||
private readonly RSTFileRepository $rstFileRepository,
|
||||
private readonly RSTCopier $rstCopier,
|
||||
private Builder $builder,
|
||||
private RSTPostBuildProcessor $rstPostBuildProcessor,
|
||||
private Filesystem $filesystem,
|
||||
private string $sourceDir,
|
||||
private string $docsDir,
|
||||
private readonly RSTPostBuildProcessor $rstPostBuildProcessor,
|
||||
private readonly Filesystem $filesystem,
|
||||
private readonly string $sourceDir,
|
||||
private readonly string $docsDir,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -13,30 +13,31 @@ use function preg_replace;
|
||||
use function sprintf;
|
||||
use function str_replace;
|
||||
|
||||
/** @final */
|
||||
class RSTCopier
|
||||
{
|
||||
public const RST_TEMPLATE = <<<'TEMPLATE'
|
||||
SIDEBAR BEGIN
|
||||
final public const RST_TEMPLATE = <<<'TEMPLATE'
|
||||
SIDEBAR BEGIN
|
||||
|
||||
{{ sidebar }}
|
||||
|
||||
CONTENT BEGIN
|
||||
|
||||
{{ content }}
|
||||
TEMPLATE;
|
||||
|
||||
{{ sidebar }}
|
||||
|
||||
CONTENT BEGIN
|
||||
|
||||
{{ content }}
|
||||
TEMPLATE;
|
||||
|
||||
public const DEFAULT_SIDEBAR = <<<'SIDEBAR'
|
||||
.. toctree::
|
||||
:depth: 3
|
||||
:glob:
|
||||
|
||||
/*
|
||||
SIDEBAR;
|
||||
final public const DEFAULT_SIDEBAR = <<<'SIDEBAR'
|
||||
.. toctree::
|
||||
:depth: 3
|
||||
:glob:
|
||||
|
||||
/*
|
||||
SIDEBAR;
|
||||
|
||||
public function __construct(
|
||||
private RSTFileRepository $rstFileRepository,
|
||||
private Filesystem $filesystem,
|
||||
private string $docsDir,
|
||||
private readonly RSTFileRepository $rstFileRepository,
|
||||
private readonly Filesystem $filesystem,
|
||||
private readonly string $docsDir,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ use function iterator_to_array;
|
||||
use function sprintf;
|
||||
use function trim;
|
||||
|
||||
/** @final */
|
||||
class RSTFileRepository
|
||||
{
|
||||
/** @throws InvalidArgumentException */
|
||||
|
||||
@@ -4,10 +4,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Website\Docs\RST;
|
||||
|
||||
class RSTLanguage
|
||||
final readonly class RSTLanguage
|
||||
{
|
||||
public function __construct(private string $code, private string $path)
|
||||
{
|
||||
public function __construct(
|
||||
private string $code,
|
||||
private string $path,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getCode(): string
|
||||
|
||||
@@ -17,9 +17,10 @@ use function is_dir;
|
||||
use function iterator_to_array;
|
||||
use function strlen;
|
||||
|
||||
/** @final */
|
||||
class RSTLanguagesDetector
|
||||
{
|
||||
public const ENGLISH_LANGUAGE_CODE = 'en';
|
||||
final public const ENGLISH_LANGUAGE_CODE = 'en';
|
||||
|
||||
/** @return RSTLanguage[] */
|
||||
public function detectLanguages(string $docsDir): array
|
||||
|
||||
@@ -14,21 +14,22 @@ use function sprintf;
|
||||
use function str_replace;
|
||||
use function strpos;
|
||||
|
||||
/** @final */
|
||||
class RSTPostBuildProcessor
|
||||
{
|
||||
public const PARAMETERS_TEMPLATE = <<<'TEMPLATE'
|
||||
---
|
||||
title: "%s"
|
||||
docsIndex: %s
|
||||
docsSourcePath: "%s"
|
||||
---
|
||||
%s
|
||||
TEMPLATE;
|
||||
final public const PARAMETERS_TEMPLATE = <<<'TEMPLATE'
|
||||
---
|
||||
title: "%s"
|
||||
docsIndex: %s
|
||||
docsSourcePath: "%s"
|
||||
---
|
||||
%s
|
||||
TEMPLATE;
|
||||
|
||||
public function __construct(
|
||||
private RSTFileRepository $rstFileRepository,
|
||||
private Filesystem $filesystem,
|
||||
private string $sourceDir,
|
||||
private readonly RSTFileRepository $rstFileRepository,
|
||||
private readonly Filesystem $filesystem,
|
||||
private readonly string $sourceDir,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,16 @@ use function strpos;
|
||||
|
||||
/**
|
||||
* Influenced by Laravel.com website code search indexes that also use Algolia.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class SearchIndexer
|
||||
{
|
||||
public const INDEX_NAME = 'pages';
|
||||
final public const INDEX_NAME = 'pages';
|
||||
|
||||
public function __construct(private SearchClient $client)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SearchClient $client,
|
||||
) {
|
||||
}
|
||||
|
||||
public function initSearchIndex(): void
|
||||
|
||||
@@ -9,7 +9,7 @@ use Doctrine\RST\Nodes\Node;
|
||||
|
||||
use function str_replace;
|
||||
|
||||
final class NodeValue
|
||||
final readonly class NodeValue
|
||||
{
|
||||
public function preNodeRender(PreNodeRenderEvent $event): void
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ use Doctrine\RST\Event\PreParseDocumentEvent;
|
||||
use function str_contains;
|
||||
use function str_replace;
|
||||
|
||||
final class TableIncompatibility
|
||||
final readonly class TableIncompatibility
|
||||
{
|
||||
private const BEFORE = '| **SQL Server** | +----------------------------------------------------------+';
|
||||
private const AFTER = '| **SQL Server** | | |';
|
||||
|
||||
@@ -11,7 +11,7 @@ use function stripos;
|
||||
use function strpos;
|
||||
use function strtoupper;
|
||||
|
||||
class Tag
|
||||
final readonly class Tag
|
||||
{
|
||||
private const ALPHA = 'alpha';
|
||||
private const BETA = 'beta';
|
||||
@@ -27,8 +27,10 @@ class Tag
|
||||
|
||||
private const COMPOSER_EPOCH = '2011-09-25';
|
||||
|
||||
public function __construct(private string $name, private DateTimeImmutable $date)
|
||||
{
|
||||
public function __construct(
|
||||
private string $name,
|
||||
private DateTimeImmutable $date,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
|
||||
@@ -12,12 +12,14 @@ use function ltrim;
|
||||
use function preg_match_all;
|
||||
use function sprintf;
|
||||
|
||||
/** @final */
|
||||
class TagBranchGuesser
|
||||
{
|
||||
private const COMMAND = 'cd %s && git branch -a';
|
||||
|
||||
public function __construct(private ProcessFactory $processFactory)
|
||||
{
|
||||
public function __construct(
|
||||
private ProcessFactory $processFactory,
|
||||
) {
|
||||
}
|
||||
|
||||
public function guessTagBranchName(string $repositoryPath, Tag $tag): string|null
|
||||
|
||||
@@ -13,12 +13,14 @@ use function sprintf;
|
||||
use function str_replace;
|
||||
use function usort;
|
||||
|
||||
/** @final */
|
||||
class TagReader
|
||||
{
|
||||
private const COMMAND = "cd %s && git tag -l --format='refname: %%(refname) creatordate: %%(creatordate)'";
|
||||
|
||||
public function __construct(private ProcessFactory $processFactory)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ProcessFactory $processFactory,
|
||||
) {
|
||||
}
|
||||
|
||||
/** @return Tag[] */
|
||||
|
||||
@@ -8,12 +8,15 @@ use Github\AuthMethod;
|
||||
use Github\Client;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/** @final */
|
||||
class GithubClientProvider
|
||||
{
|
||||
private bool $authenticated = false;
|
||||
|
||||
public function __construct(private Client $githubClient, private string $githubHttpToken)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Client $githubClient,
|
||||
private readonly string $githubHttpToken,
|
||||
) {
|
||||
if ($githubHttpToken === '') {
|
||||
throw new InvalidArgumentException('You must configure a Github http token.');
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use function assert;
|
||||
use function sleep;
|
||||
use function sprintf;
|
||||
|
||||
class ProdGithubProjectContributors implements GithubProjectContributors
|
||||
final readonly class ProdGithubProjectContributors implements GithubProjectContributors
|
||||
{
|
||||
public function __construct(
|
||||
private CacheItemPoolInterface $cache,
|
||||
|
||||
@@ -15,13 +15,14 @@ abstract class ModelHydrator extends ObjectHydrator
|
||||
private object $object;
|
||||
|
||||
/** @var ClassMetadataInterface<T> */
|
||||
private ClassMetadataInterface $classMetadata;
|
||||
private readonly ClassMetadataInterface $classMetadata;
|
||||
|
||||
/** @var ReflectionProperty[] */
|
||||
private array $reflectionProperties;
|
||||
|
||||
public function __construct(protected ObjectManagerInterface $objectManager)
|
||||
{
|
||||
public function __construct(
|
||||
protected readonly ObjectManagerInterface $objectManager,
|
||||
) {
|
||||
$this->classMetadata = $this->objectManager->getClassMetadata($this->getClassName());
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ use Closure;
|
||||
use Symfony\Component\Process\Exception\ProcessFailedException;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
/** @final */
|
||||
class ProcessFactory
|
||||
{
|
||||
/** @return Process<string, string> */
|
||||
|
||||
@@ -8,10 +8,12 @@ use function file_get_contents;
|
||||
use function json_decode;
|
||||
use function sprintf;
|
||||
|
||||
/** @final */
|
||||
class GetProjectPackagistData
|
||||
{
|
||||
public function __construct(private string $packagistUrlFormat)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly string $packagistUrlFormat,
|
||||
) {
|
||||
}
|
||||
|
||||
/** @return mixed[] */
|
||||
|
||||
@@ -7,11 +7,12 @@ namespace Doctrine\Website\Projects;
|
||||
use Doctrine\Website\Model\Project;
|
||||
use Doctrine\Website\Repositories\ProjectRepository;
|
||||
|
||||
final class GetTotalDownloads
|
||||
final readonly class GetTotalDownloads
|
||||
{
|
||||
/** @param ProjectRepository<Project> $projectRepository */
|
||||
public function __construct(private ProjectRepository $projectRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private ProjectRepository $projectRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(): int
|
||||
|
||||
@@ -21,22 +21,23 @@ use function str_replace;
|
||||
|
||||
use const JSON_ERROR_NONE;
|
||||
|
||||
/** @final */
|
||||
class ProjectDataReader
|
||||
{
|
||||
private const DOCTRINE_PROJECT_JSON_FILE_NAME = '.doctrine-project.json';
|
||||
|
||||
private const COMPOSER_JSON_FILE_NAME = 'composer.json';
|
||||
|
||||
private Inflector $inflector;
|
||||
private readonly Inflector $inflector;
|
||||
|
||||
/**
|
||||
* @param mixed[] $projectsData
|
||||
* @param mixed[] $projectIntegrationTypes
|
||||
*/
|
||||
public function __construct(
|
||||
private string $projectsDir,
|
||||
private array $projectsData,
|
||||
private array $projectIntegrationTypes,
|
||||
private readonly string $projectsDir,
|
||||
private readonly array $projectsData,
|
||||
private readonly array $projectIntegrationTypes,
|
||||
) {
|
||||
$this->inflector = InflectorFactory::create()->build();
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Website\Projects;
|
||||
|
||||
/** @final */
|
||||
class ProjectDataRepository
|
||||
{
|
||||
/** @param mixed[][] $projectsData */
|
||||
public function __construct(private array $projectsData = [])
|
||||
{
|
||||
public function __construct(
|
||||
private readonly array $projectsData = [],
|
||||
) {
|
||||
}
|
||||
|
||||
/** @return string[] */
|
||||
|
||||
@@ -12,12 +12,16 @@ use function escapeshellarg;
|
||||
use function is_dir;
|
||||
use function sprintf;
|
||||
|
||||
/** @final */
|
||||
class ProjectGitSyncer
|
||||
{
|
||||
private Repo $githubRepo;
|
||||
private readonly Repo $githubRepo;
|
||||
|
||||
public function __construct(private ProcessFactory $processFactory, GithubClientProvider $githubClientProvider, private string $projectsDir)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ProcessFactory $processFactory,
|
||||
GithubClientProvider $githubClientProvider,
|
||||
private readonly string $projectsDir,
|
||||
) {
|
||||
// TODO Inject Repo instead of GithubClientProvider
|
||||
$this->githubRepo = $githubClientProvider->getGithubClient()->repo();
|
||||
}
|
||||
|
||||
@@ -11,10 +11,13 @@ use Doctrine\Website\Git\TagReader;
|
||||
use function array_filter;
|
||||
use function array_values;
|
||||
|
||||
/** @final */
|
||||
class ProjectVersionsReader
|
||||
{
|
||||
public function __construct(private TagReader $tagReader, private TagBranchGuesser $tagBranchGuesser)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly TagReader $tagReader,
|
||||
private readonly TagBranchGuesser $tagBranchGuesser,
|
||||
) {
|
||||
}
|
||||
|
||||
/** @return mixed[] */
|
||||
|
||||
@@ -9,11 +9,12 @@ use Doctrine\StaticWebsiteGenerator\Request\RequestCollection;
|
||||
use Doctrine\Website\Model\Contributor;
|
||||
use Doctrine\Website\Repositories\ContributorRepository;
|
||||
|
||||
class ContributorRequests
|
||||
final readonly class ContributorRequests
|
||||
{
|
||||
/** @param ContributorRepository<Contributor> $contributorRepository */
|
||||
public function __construct(private ContributorRepository $contributorRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private ContributorRepository $contributorRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getContributors(): RequestCollection
|
||||
|
||||
@@ -9,11 +9,12 @@ use Doctrine\StaticWebsiteGenerator\Request\RequestCollection;
|
||||
use Doctrine\Website\Model\Partner;
|
||||
use Doctrine\Website\Repositories\PartnerRepository;
|
||||
|
||||
class PartnerRequests
|
||||
final readonly class PartnerRequests
|
||||
{
|
||||
/** @param PartnerRepository<Partner> $partnerRepository */
|
||||
public function __construct(private PartnerRepository $partnerRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private PartnerRepository $partnerRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getPartners(): RequestCollection
|
||||
|
||||
@@ -9,11 +9,12 @@ use Doctrine\StaticWebsiteGenerator\Request\RequestCollection;
|
||||
use Doctrine\Website\Model\Project;
|
||||
use Doctrine\Website\Repositories\ProjectRepository;
|
||||
|
||||
class ProjectRequests
|
||||
final readonly class ProjectRequests
|
||||
{
|
||||
/** @param ProjectRepository<Project> $projectRepository */
|
||||
public function __construct(private ProjectRepository $projectRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private ProjectRepository $projectRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getProjects(): RequestCollection
|
||||
|
||||
@@ -9,11 +9,12 @@ use Doctrine\StaticWebsiteGenerator\Request\RequestCollection;
|
||||
use Doctrine\Website\Model\Project;
|
||||
use Doctrine\Website\Repositories\ProjectRepository;
|
||||
|
||||
class ProjectVersionRequests
|
||||
final readonly class ProjectVersionRequests
|
||||
{
|
||||
/** @param ProjectRepository<Project> $projectRepository */
|
||||
public function __construct(private ProjectRepository $projectRepository)
|
||||
{
|
||||
public function __construct(
|
||||
private ProjectRepository $projectRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getProjectVersions(): RequestCollection
|
||||
|
||||
@@ -17,7 +17,7 @@ final class Site extends BaseSite
|
||||
string $description,
|
||||
string $env,
|
||||
string $googleAnalyticsTrackingId,
|
||||
private string $assetsUrl,
|
||||
private readonly string $assetsUrl,
|
||||
) {
|
||||
parent::__construct(
|
||||
$title,
|
||||
|
||||
@@ -23,13 +23,13 @@ use function strlen;
|
||||
use function strrpos;
|
||||
use function substr;
|
||||
|
||||
class MainExtension extends AbstractExtension
|
||||
final class MainExtension extends AbstractExtension
|
||||
{
|
||||
public function __construct(
|
||||
private Parsedown $parsedown,
|
||||
private AssetIntegrityGenerator $assetIntegrityGenerator,
|
||||
private string $sourceDir,
|
||||
private string $webpackBuildDir,
|
||||
private readonly Parsedown $parsedown,
|
||||
private readonly AssetIntegrityGenerator $assetIntegrityGenerator,
|
||||
private readonly string $sourceDir,
|
||||
private readonly string $webpackBuildDir,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,13 @@ use function file_exists;
|
||||
use function str_replace;
|
||||
use function strpos;
|
||||
|
||||
class ProjectExtension extends AbstractExtension
|
||||
final class ProjectExtension extends AbstractExtension
|
||||
{
|
||||
/** @param ProjectRepository<Project> $projectRepository */
|
||||
public function __construct(private ProjectRepository $projectRepository, private string $sourceDir)
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ProjectRepository $projectRepository,
|
||||
private readonly string $sourceDir,
|
||||
) {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
|
||||
@@ -22,6 +22,7 @@ use function is_dir;
|
||||
use function is_link;
|
||||
use function sprintf;
|
||||
|
||||
/** @final */
|
||||
class WebsiteBuilder
|
||||
{
|
||||
public const PUBLISHABLE_ENVS = [Application::ENV_PROD, Application::ENV_STAGING];
|
||||
@@ -36,14 +37,14 @@ class WebsiteBuilder
|
||||
|
||||
/** @param ProjectRepository<Project> $projectRepository */
|
||||
public function __construct(
|
||||
private ProcessFactory $processFactory,
|
||||
private ProjectRepository $projectRepository,
|
||||
private Filesystem $filesystem,
|
||||
private SourceFileRepository $sourceFileRepository,
|
||||
private SourceFilesBuilder $sourceFilesBuilder,
|
||||
private string $rootDir,
|
||||
private string $cacheDir,
|
||||
private string $webpackBuildDir,
|
||||
private readonly ProcessFactory $processFactory,
|
||||
private readonly ProjectRepository $projectRepository,
|
||||
private readonly Filesystem $filesystem,
|
||||
private readonly SourceFileRepository $sourceFileRepository,
|
||||
private readonly SourceFilesBuilder $sourceFilesBuilder,
|
||||
private readonly string $rootDir,
|
||||
private readonly string $cacheDir,
|
||||
private readonly string $webpackBuildDir,
|
||||
) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user