8000 Removes deprecation notice · symfony/symfony@27dadb3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 27dadb3

Browse files
committed
Removes deprecation notice
1 parent ac7ff46 commit 27dadb3

File tree

2 files changed

+7
-27
lines changed

2 files changed

+7
-27
lines changed

src/Symfony/Bundle/TwigBundle/TemplateIterator.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ class TemplateIterator implements \IteratorAggregate
2929
private \Traversable $templates;
3030
private array $paths;
3131
private ?string $defaultPath;
32-
private ?array $fileNames;
32+
private array $fileNames;
3333

3434
/**
3535
* @param array $paths Additional Twig paths to warm
3636
* @param string|null $defaultPath The directory where global templates can be stored
3737
* @param string[]|null $fileNames Pattern of file names
3838
*/
39-
public function __construct(KernelInterface $kernel, array $paths = [], string $defaultPath = null, array $fileNames = null)
39+
public function __construct(KernelInterface $kernel, array $paths = [], string $defaultPath = null, array $fileNames = [])
4040
{
4141
$this->kernel = $kernel;
4242
$this->paths = $paths;
@@ -85,19 +85,8 @@ private function findTemplatesInDirectory(string $dir, string $namespace = null,
8585
}
8686

8787
$templates = [];
88-
$finder = Finder::create()->files()->followLinks()->in($dir)->exclude($excludeDirs);
89-
if (null !== $this->fileNames) {
90-
$finder->name($this->fileNames);
91-
} else {
92-
$deprecationNotice = true;
93-
}
94-
foreach ($finder as $file) {
88+
foreach (Finder::create()->files()->followLinks()->in($dir)->exclude($excludeDirs)->name($this->fileNames) as $file) {
9589
$templates[] = (null !== $namespace ? '@'.$namespace.'/' : '').str_replace('\\', '/', $file->getRelativePathname());
96-
97-
if (null === $this->fileNames && $deprecationNotice && 'twig' !== $file->getExtension()) {
98-
trigger_deprecation('symfony/twig-bundle', '6.1', 'Directory "%s" contains non "*.twig" files. They will not be compiled by cache warmer in Symfony 7.0. Set "twig.file_name_pattern: \'*.twig\'" in your configuration.', $dir);
99-
$deprecationNotice = false;
100-
}
10190
}
10291

10392
return $templates;

src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@
1111

1212
namespace Symfony\Bundle\TwigBundle\Tests;
1313

14-
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
1514
use Symfony\Bundle\TwigBundle\TemplateIterator;
1615
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
1716
use Symfony\Component\HttpKernel\Kernel;
1817

1918
class TemplateIteratorTest extends TestCase
2019
{
21-
use ExpectDeprecationTrait;
22-
2320
public function testGetIterator()
2421
{
25-
$iterator = new TemplateIterator($this->createKernelMock(), [__DIR__.'/Fixtures/templates/Foo' => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates', ['*.twig']);
22+
$iterator = new TemplateIterator($this->createKernelMock(), [__DIR__.'/Fixtures/templates/Foo' => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates');
2623

2724
$sorted = iterator_to_array($iterator);
2825
sort($sorted);
@@ -31,21 +28,16 @@ public function testGetIterator()
3128
'@Bar/index.html.twig',
3229
'@Bar/layout.html.twig',
3330
'@Foo/index.html.twig',
31+
'@Foo/not-twig.js',
3432
'layout.html.twig',
3533
],
3634
$sorted
3735
);
3836
}
3937

40-
/**
41-
* @group legacy
42-
*/
43-
public function testGetIteratorDeprecateNonTwig()
38+
public function testGetIteratorWithFileNameFilter()
4439
{
45-
$dir = __DIR__.'/Fixtures/templates/Foo';
46-
$this->expectDeprecation(sprintf('Since symfony/twig-bundle 6.1: Directory "%s" contains non "*.twig" files. They will not be compiled by cache warmer in Symfony 7.0. Set "twig.file_name_pattern: \'*.twig\'" in your configuration.', $dir));
47-
48-
$iterator = new TemplateIterator($this->createKernelMock(), [$dir => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates', null);
40+
$iterator = new TemplateIterator($this->createKernelMock(), [__DIR__.'/Fixtures/templates/Foo' => 'Foo'], __DIR__.'/DependencyInjection/Fixtures/templates', ['*.twig']);
4941

5042
$sorted = iterator_to_array($iterator);
5143
sort($sorted);
@@ -54,7 +46,6 @@ public function testGetIteratorDeprecateNonTwig()
5446
'@Bar/index.html.twig',
5547
'@Bar/layout.html.twig',
5648
'@Foo/index.html.twig',
57-
'@Foo/not-twig.js',
5849
'layout.html.twig',
5950
],
6051
$sorted

0 commit comments

Comments
 (0)
0