Skip to content

Commit 38fa985

Browse files
committed
Update warmup signature on all WarmableInterface implementations
Signed-off-by: Quentin Devos <4972091+Okhoshi@users.noreply.github.com>
1 parent df50972 commit 38fa985

File tree

17 files changed

+46
-34
lines changed

17 files changed

+46
-34
lines changed

src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public function isOptional(): bool
3838
}
3939

4040
/**
41-
* @return string[] A list of files to preload on PHP 7.4+
41+
* @param string|null $buildDir
4242
*/
43-
public function warmUp(string $cacheDir): array
43+
public function warmUp(string $cacheDir /* , string $buildDir = null */): array
4444
{
4545
$files = [];
4646
foreach ($this->registry->getManagers() as $em) {

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AbstractPhpFileCacheWarmer.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,16 @@ public function isOptional(): bool
3535
}
3636

3737
/**
38-
* @return string[] A list of classes to preload on PHP 7.4+
38+
* @param string|null $buildDir
3939
*/
40-
public function warmUp(string $cacheDir): array
40+
public function warmUp(string $cacheDir /* , string $buildDir = null */): array
4141
{
42+
$buildDir = 1 < \func_num_args() ? func_get_arg(1) : null;
4243
$arrayAdapter = new ArrayAdapter();
4344

4445
spl_autoload_register([ClassExistenceResource::class, 'throwOnRequiredClass']);
4546
try {
46-
if (!$this->doWarmUp($cacheDir, $arrayAdapter)) {
47+
if (!$this->doWarmUp($cacheDir, $arrayAdapter, $buildDir)) {
4748
return [];
4849
}
4950
} finally {
@@ -78,7 +79,9 @@ final protected function ignoreAutoloadException(string $class, \Exception $exce
7879
}
7980

8081
/**
82+
* @param string|null $buildDir
83+
*
8184
* @return bool false if there is nothing to warm-up
8285
*/
83-
abstract protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool;
86+
abstract protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter /* , string $buildDir = null */): bool;
8487
}

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/AnnotationsCacheWarmer.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ public function __construct(
4444
parent::__construct($phpArrayFile);
4545
}
4646

47-
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool
47+
/**
48+
* @param string|null $buildDir
49+
*/
50+
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter /* , string $buildDir = null */): bool
4851
{
4952
$annotatedClassPatterns = $cacheDir.'/annotations.map';
5053

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/CachePoolClearerCacheWarmer.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ public function __construct(Psr6CacheClearer $poolClearer, array $pools = [])
3737
$this->pools = $pools;
3838
}
3939

40-
/**
41-
* @return string[]
42-
*/
43-
public function warmUp(string $cacheDirectory): array
40+
public function warmUp(string $cacheDir, string $buildDir = null): array
4441
{
4542
foreach ($this->pools as $pool) {
4643
if ($this->poolClearer->hasPool($pool)) {

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/RouterCacheWarmer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ public function __construct(ContainerInterface $container)
3434
$this->container = $container;
3535
}
3636

37-
public function warmUp(string $cacheDir): array
37+
public function warmUp(string $cacheDir, string $buildDir = null): array
3838
{
3939
$router = $this->container->get('router');
4040

4141
if ($router instanceof WarmableInterface) {
42-
return (array) $router->warmUp($cacheDir);
42+
return (array) $router->warmUp($cacheDir, $buildDir);
4343
}
4444

4545
throw new \LogicException(sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', get_debug_type($router), WarmableInterface::class));

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/SerializerCacheWarmer.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ public function __construct(array $loaders, string $phpArrayFile)
3939
$this->loaders = $loaders;
4040
}
4141

42-
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool
42+
/**
43+
* @param string|null $buildDir
44+
*/
45+
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter /* , string $buildDir = null */): bool
4346
{
4447
if (!$this->loaders) {
4548
return true;

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TranslationsCacheWarmer.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ public function __construct(ContainerInterface $container)
3434
}
3535

3636
/**
37-
* @return string[]
37+
* @param string|null $buildDir
3838
*/
39-
public function warmUp(string $cacheDir): array
39+
public function warmUp(string $cacheDir /* , string $buildDir = null */): array
4040
{
4141
$this->translator ??= $this->container->get('translator');
4242

4343
if ($this->translator instanceof WarmableInterface) {
44-
return (array) $this->translator->warmUp($cacheDir);
44+
$buildDir = 1 < \func_num_args() ? func_get_arg(1) : null;
45+
46+
return (array) $this->translator->warmUp($cacheDir, $buildDir);
4547
}
4648

4749
return [];

src/Symfony/Bundle/FrameworkBundle/CacheWarmer/ValidatorCacheWarmer.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ public function __construct(ValidatorBuilder $validatorBuilder, string $phpArray
3939
$this->validatorBuilder = $validatorBuilder;
4040
}
4141

42-
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter): bool
42+
/**
43+
* @param string|null $buildDir
44+
*/
45+
protected function doWarmUp(string $cacheDir, ArrayAdapter $arrayAdapter /* , string $buildDir = null */): bool
4346
{
4447
$loaders = $this->validatorBuilder->getLoaders();
4548
$metadataFactory = new LazyLoadingMetadataFactory(new LoaderChain($loaders), $arrayAdapter);

src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7474

7575
$preload = $this->cacheWarmer->warmUp($cacheDir);
7676

77-
$buildDir = $kernel->getContainer()->getParameter('kernel.build_dir');
78-
if ($preload && $cacheDir === $buildDir && file_exists($preloadFile = $buildDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
77+
if ($preload && file_exists($preloadFile = $kernel->getContainer()->getParameter('kernel.build_dir').'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
7978
Preloader::append($preloadFile, $preload);
8079
}
8180

src/Symfony/Bundle/FrameworkBundle/Routing/Router.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ public function getRouteCollection(): RouteCollection
8181
}
8282

8383
/**
84-
* @return string[] A list of classes to preload on PHP 7.4+
84+
* @param string|null $buildDir
8585
*/
86-
public function warmUp(string $cacheDir): array
86+
public function warmUp(string $cacheDir /* , string $buildDir = null */): array
8787
{
8888
$currentDir = $this->getOption('cache_dir');
8989

src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/Fixture/TestAppKernel.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function isOptional(): bool
5252
return false;
5353
}
5454

55-
public function warmUp(string $cacheDir): array
55+
public function warmUp(string $cacheDir, string $buildDir = null): array
5656
{
5757
file_put_contents($cacheDir.'/dummy.txt', 'Hello');
5858

src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ public function __construct(ContainerInterface $container, MessageFormatterInter
9595
}
9696

9797
/**
98-
* @return string[]
98+
* @param string|null $buildDir
9999
*/
100-
public function warmUp(string $cacheDir): array
100+
public function warmUp(string $cacheDir /* , string $buildDir = null */): array
101101
{
102102
// skip warmUp when translator doesn't use cache
103103
if (null === $this->options['cache_dir']) {

src/Symfony/Bundle/SecurityBundle/CacheWarmer/ExpressionCacheWarmer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ public function isOptional(): bool
3535
}
3636

3737
/**
38-
* @return string[]
38+
* @param string|null $buildDir
3939
*/
40-
public function warmUp(string $cacheDir): array
40+
public function warmUp(string $cacheDir /* , string $buildDir = null */): array
4141
{
4242
foreach ($this->expressions as $expression) {
4343
$this->expressionLanguage->parse($expression, ['token', 'user', 'object', 'subject', 'role_names', 'request', 'trust_resolver']);

src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheWarmer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public function __construct(ContainerInterface $container, iterable $iterator)
3636
}
3737

3838
/**
39-
* @return string[] A list of template files to preload on PHP 7.4+
39+
* @param string|null $buildDir
4040
*/
41-
public function warmUp(string $cacheDir): array
41+
public function warmUp(string $cacheDir /* , string $buildDir = null */): array
4242
{
4343
$this->twig ??= $this->container->get('twig');
4444

src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct(string $file)
5454
$this->file = $file;
5555
}
5656

57-
public function warmUp(string $cacheDir): array
57+
public function warmUp(string $cacheDir, string $buildDir = null): array
5858
{
5959
$this->writeCacheFile($this->file, 'content');
6060

src/Symfony/Component/Serializer/CacheWarmer/CompiledClassMetadataCacheWarmer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(
2929
) {
3030
}
3131

32-
public function warmUp(string $cacheDir): array
32+
public function warmUp(string $cacheDir, string $buildDir = null): array
3333
{
3434
$metadatas = [];
3535

src/Symfony/Component/Translation/DataCollectorTranslator.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ public function getCatalogues(): array
7272
}
7373

7474
/**
75-
* @return string[]
75+
* @param string|null $buildDir
7676
*/
77-
public function warmUp(string $cacheDir): array
77+
public function warmUp(string $cacheDir /* , string $buildDir = null */): array
7878
{
79+
$buildDir = 1 < \func_num_args() ? func_get_arg(1) : null;
80+
7981
if ($this->translator instanceof WarmableInterface) {
80-
return (array) $this->translator->warmUp($cacheDir);
82+
return (array) $this->translator->warmUp($cacheDir, $buildDir);
8183
}
8284

8385
return [];

0 commit comments

Comments
 (0)