diff --git a/Extension/TranslationExtension.php b/Extension/TranslationExtension.php index 7891dab1..67835e2b 100644 --- a/Extension/TranslationExtension.php +++ b/Extension/TranslationExtension.php @@ -103,6 +103,10 @@ public function trans(string|\Stringable|TranslatableInterface|null $message, ar throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be a locale passed as a string when the message is a "%s", "%s" given.', __METHOD__, TranslatableInterface::class, get_debug_type($arguments))); } + if ($message instanceof TranslatableMessage && '' === $message->getMessage()) { + return ''; + } + return $message->trans($this->getTranslator(), $locale ?? (\is_string($arguments) ? $arguments : null)); } diff --git a/LICENSE b/LICENSE index 00837045..0138f8f0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Mime/WrappedTemplatedEmail.php b/Mime/WrappedTemplatedEmail.php index 488898ca..c4e0003f 100644 --- a/Mime/WrappedTemplatedEmail.php +++ b/Mime/WrappedTemplatedEmail.php @@ -38,7 +38,7 @@ public function toName(): string } /** - * @param string $image A Twig path to the image file. It's recommended to define + * @param string $image A Twig path to the image file. It's recommended to define * some Twig namespace for email images (e.g. '@email/images/logo.png'). * @param string|null $contentType The media type (i.e. MIME type) of the image file (e.g. 'image/png'). * Some email clients require this to display embedded images. @@ -53,9 +53,9 @@ public function image(string $image, string $contentType = null): string } /** - * @param string $file A Twig path to the file. It's recommended to define + * @param string $file A Twig path to the file. It's recommended to define * some Twig namespace for email files (e.g. '@email/files/contract.pdf'). - * @param string|null $name A custom file name that overrides the original name of the attached file. + * @param string|null $name A custom file name that overrides the original name of the attached file * @param string|null $contentType The media type (i.e. MIME type) of the file (e.g. 'application/pdf'). * Some email clients require this to display attached files. */ diff --git a/Resources/views/Email/zurb_2/main.css b/Resources/views/Email/zurb_2/main.css index b826813e..dab0df58 100644 --- a/Resources/views/Email/zurb_2/main.css +++ b/Resources/views/Email/zurb_2/main.css @@ -1,7 +1,7 @@ /* * Copyright (c) 2017 ZURB, inc. -- MIT License * - * https://raw.githubusercontent.com/foundation/foundation-emails/v2.2.1/dist/foundation-emails.css + * https://github.com/foundation/foundation-emails/blob/v2.2.1/dist/foundation-emails.css */ .wrapper { diff --git a/Resources/views/Email/zurb_2/notification/body.html.twig b/Resources/views/Email/zurb_2/notification/body.html.twig index 0a52d36b..28a62de3 100644 --- a/Resources/views/Email/zurb_2/notification/body.html.twig +++ b/Resources/views/Email/zurb_2/notification/body.html.twig @@ -26,7 +26,7 @@ {% if markdown %} {{ include('@email/zurb_2/notification/content_markdown.html.twig') }} {% else %} - {{ (raw ? content|raw : content)|nl2br }} + {{ raw ? content|raw : content|nl2br }} {% endif %} {% endblock %} diff --git a/Resources/views/Form/bootstrap_3_layout.html.twig b/Resources/views/Form/bootstrap_3_layout.html.twig index 865f9078..f4e313b4 100644 --- a/Resources/views/Form/bootstrap_3_layout.html.twig +++ b/Resources/views/Form/bootstrap_3_layout.html.twig @@ -90,6 +90,10 @@ {%- if required -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%} {%- endif -%} + {%- if parent_label_class is defined -%} + {% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %} + {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%} + {% endif %} {%- if label is not same as(false) and label is empty -%} {%- if label_format is not empty -%} {%- set label = label_format|replace({ diff --git a/Resources/views/Form/bootstrap_4_layout.html.twig b/Resources/views/Form/bootstrap_4_layout.html.twig index 3e9904ad..458cc684 100644 --- a/Resources/views/Form/bootstrap_4_layout.html.twig +++ b/Resources/views/Form/bootstrap_4_layout.html.twig @@ -261,6 +261,10 @@ {%- if required -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%} {%- endif -%} + {%- if parent_label_class is defined -%} + {% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %} + {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%} + {% endif %} {{ widget|raw }} diff --git a/Resources/views/Form/foundation_5_layout.html.twig b/Resources/views/Form/foundation_5_layout.html.twig index f8c51b83..345695f6 100644 --- a/Resources/views/Form/foundation_5_layout.html.twig +++ b/Resources/views/Form/foundation_5_layout.html.twig @@ -253,6 +253,10 @@ {% if errors|length > 0 -%} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' error')|trim}) %} {% endif %} + {%- if parent_label_class is defined -%} + {% set embed_label_classes = parent_label_class|split(' ')|filter(class => class in ['checkbox-inline', 'radio-inline']) %} + {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ embed_label_classes|join(' '))|trim}) -%} + {% endif %} {% if label is empty %} {%- if label_format is not empty -%} {% set label = label_format|replace({ diff --git a/Tests/AppVariableTest.php b/Tests/AppVariableTest.php index ab3702fa..219d47d1 100644 --- a/Tests/AppVariableTest.php +++ b/Tests/AppVariableTest.php @@ -43,7 +43,7 @@ public function testDebug($debugFlag) $this->assertEquals($debugFlag, $this->appVariable->getDebug()); } - public function debugDataProvider() + public static function debugDataProvider() { return [ 'debug on' => [true], diff --git a/Tests/Command/DebugCommandTest.php b/Tests/Command/DebugCommandTest.php index f0d7d661..3d61d6ee 100644 --- a/Tests/Command/DebugCommandTest.php +++ b/Tests/Command/DebugCommandTest.php @@ -84,7 +84,7 @@ public function testDebugTemplateName(array $input, string $output, array $paths $this->assertStringMatchesFormat($output, $tester->getDisplay(true)); } - public function getDebugTemplateNameTestData() + public static function getDebugTemplateNameTestData() { $defaultPaths = [ 'templates/' => null, @@ -311,7 +311,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $suggestions); } - public function provideCompletionSuggestions(): iterable + public static function provideCompletionSuggestions(): iterable { yield 'name' => [['email'], []]; yield 'option --format' => [['--format', ''], ['text', 'json']]; diff --git a/Tests/Command/LintCommandTest.php b/Tests/Command/LintCommandTest.php index 6428f486..bae8e727 100644 --- a/Tests/Command/LintCommandTest.php +++ b/Tests/Command/LintCommandTest.php @@ -146,7 +146,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $tester->complete($input)); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'option' => [['--format', ''], ['txt', 'json', 'github']]; } diff --git a/Tests/EventListener/TemplateAttributeListenerTest.php b/Tests/EventListener/TemplateAttributeListenerTest.php index 8f6d6a2c..e1fb7f95 100644 --- a/Tests/EventListener/TemplateAttributeListenerTest.php +++ b/Tests/EventListener/TemplateAttributeListenerTest.php @@ -29,12 +29,18 @@ public function testAttribute() $twig = $this->createMock(Environment::class); $twig->expects($this->exactly(3)) ->method('render') - ->withConsecutive( - ['templates/foo.html.twig', ['foo' => 'bar']], - ['templates/foo.html.twig', ['bar' => 'Bar', 'buz' => 'def']], - ['templates/foo.html.twig', []], - ) - ->willReturn('Bar'); + ->willReturnCallback(function (...$args) { + static $series = [ + ['templates/foo.html.twig', ['foo' => 'bar']], + ['templates/foo.html.twig', ['bar' => 'Bar', 'buz' => 'def']], + ['templates/foo.html.twig', []], + ]; + + $this->assertSame(array_shift($series), $args); + + return 'Bar'; + }) + ; $request = new Request(); $kernel = $this->createMock(HttpKernelInterface::class); diff --git a/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php b/Tests/Extension/AbstractBootstrap3HorizontalLayoutTestCase.php similarity index 98% rename from Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php rename to Tests/Extension/AbstractBootstrap3HorizontalLayoutTestCase.php index c4874c34..e79b0c31 100644 --- a/Tests/Extension/AbstractBootstrap3HorizontalLayoutTest.php +++ b/Tests/Extension/AbstractBootstrap3HorizontalLayoutTestCase.php @@ -11,7 +11,7 @@ namespace Symfony\Bridge\Twig\Tests\Extension; -abstract class AbstractBootstrap3HorizontalLayoutTest extends AbstractBootstrap3LayoutTest +abstract class AbstractBootstrap3HorizontalLayoutTestCase extends AbstractBootstrap3LayoutTestCase { public function testLabelOnForm() { diff --git a/Tests/Extension/AbstractBootstrap3LayoutTest.php b/Tests/Extension/AbstractBootstrap3LayoutTestCase.php similarity index 99% rename from Tests/Extension/AbstractBootstrap3LayoutTest.php rename to Tests/Extension/AbstractBootstrap3LayoutTestCase.php index 80835230..16cb900b 100644 --- a/Tests/Extension/AbstractBootstrap3LayoutTest.php +++ b/Tests/Extension/AbstractBootstrap3LayoutTestCase.php @@ -13,9 +13,9 @@ use Symfony\Component\Form\Extension\Core\Type\PercentType; use Symfony\Component\Form\FormError; -use Symfony\Component\Form\Tests\AbstractLayoutTest; +use Symfony\Component\Form\Tests\AbstractLayoutTestCase; -abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest +abstract class AbstractBootstrap3LayoutTestCase extends AbstractLayoutTestCase { public function testLabelOnForm() { @@ -2154,6 +2154,25 @@ public function testRenderNumberWithHtml5NumberType() $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/input [@type="number"] + [@step="any"] + [@name="name"] + [@class="my&class form-control"] + [@value="1234.56"] +' + ); + } + + public function testRenderNumberWithHtml5NumberTypeAndStepAttribute() + { + $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56, [ + 'html5' => true, + 'attr' => ['step' => '0.1'], + ]); + + $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], + '/input + [@type="number"] + [@step="0.1"] [@name="name"] [@class="my&class form-control"] [@value="1234.56"] diff --git a/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php b/Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php similarity index 98% rename from Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php rename to Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php index 1ef14ecf..ce8a7336 100644 --- a/Tests/Extension/AbstractBootstrap4HorizontalLayoutTest.php +++ b/Tests/Extension/AbstractBootstrap4HorizontalLayoutTestCase.php @@ -18,7 +18,7 @@ * * @author Hidde Wieringa */ -abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4LayoutTest +abstract class AbstractBootstrap4HorizontalLayoutTestCase extends AbstractBootstrap4LayoutTestCase { public function testRow() { diff --git a/Tests/Extension/AbstractBootstrap4LayoutTest.php b/Tests/Extension/AbstractBootstrap4LayoutTestCase.php similarity index 99% rename from Tests/Extension/AbstractBootstrap4LayoutTest.php rename to Tests/Extension/AbstractBootstrap4LayoutTestCase.php index 8689df83..e329b5d4 100644 --- a/Tests/Extension/AbstractBootstrap4LayoutTest.php +++ b/Tests/Extension/AbstractBootstrap4LayoutTestCase.php @@ -28,7 +28,7 @@ * * @author Hidde Wieringa */ -abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest +abstract class AbstractBootstrap4LayoutTestCase extends AbstractBootstrap3LayoutTestCase { public function testRow() { diff --git a/Tests/Extension/AbstractBootstrap5HorizontalLayoutTest.php b/Tests/Extension/AbstractBootstrap5HorizontalLayoutTestCase.php similarity index 99% rename from Tests/Extension/AbstractBootstrap5HorizontalLayoutTest.php rename to Tests/Extension/AbstractBootstrap5HorizontalLayoutTestCase.php index e6a8846c..770c18a1 100644 --- a/Tests/Extension/AbstractBootstrap5HorizontalLayoutTest.php +++ b/Tests/Extension/AbstractBootstrap5HorizontalLayoutTestCase.php @@ -24,7 +24,7 @@ * * @author Romain Monteil */ -abstract class AbstractBootstrap5HorizontalLayoutTest extends AbstractBootstrap5LayoutTest +abstract class AbstractBootstrap5HorizontalLayoutTestCase extends AbstractBootstrap5LayoutTestCase { public function testRow() { diff --git a/Tests/Extension/AbstractBootstrap5LayoutTest.php b/Tests/Extension/AbstractBootstrap5LayoutTestCase.php similarity index 99% rename from Tests/Extension/AbstractBootstrap5LayoutTest.php rename to Tests/Extension/AbstractBootstrap5LayoutTestCase.php index e85ad797..a59e6597 100644 --- a/Tests/Extension/AbstractBootstrap5LayoutTest.php +++ b/Tests/Extension/AbstractBootstrap5LayoutTestCase.php @@ -36,7 +36,7 @@ * * @author Romain Monteil */ -abstract class AbstractBootstrap5LayoutTest extends AbstractBootstrap4LayoutTest +abstract class AbstractBootstrap5LayoutTestCase extends AbstractBootstrap4LayoutTestCase { public function testRow() { diff --git a/Tests/Extension/CodeExtensionTest.php b/Tests/Extension/CodeExtensionTest.php index 33bb266c..38983cbd 100644 --- a/Tests/Extension/CodeExtensionTest.php +++ b/Tests/Extension/CodeExtensionTest.php @@ -44,7 +44,7 @@ public function testGettingMethodAbbreviation($method, $abbr) $this->assertEquals($this->getExtension()->abbrMethod($method), $abbr); } - public function getClassNameProvider(): array + public static function getClassNameProvider(): array { return [ ['F\Q\N\Foo', 'Foo'], @@ -52,7 +52,7 @@ public function getClassNameProvider(): array ]; } - public function getMethodNameProvider(): array + public static function getMethodNameProvider(): array { return [ ['F\Q\N\Foo::Method', 'Foo::Method()'], diff --git a/Tests/Extension/DumpExtensionTest.php b/Tests/Extension/DumpExtensionTest.php index d0825221..8fe455e5 100644 --- a/Tests/Extension/DumpExtensionTest.php +++ b/Tests/Extension/DumpExtensionTest.php @@ -53,7 +53,7 @@ public function testDumpTag($template, $debug, $expectedOutput, $expectedDumped) $this->assertSame($expectedDumped, $dumped); } - public function getDumpTags() + public static function getDumpTags() { return [ ['A{% dump %}B', true, 'AB', []], @@ -88,7 +88,7 @@ public function testDump($context, $args, $expectedOutput, $debug = true) $this->assertEquals($expectedOutput, $dump); } - public function getDumpArgs() + public static function getDumpArgs() { return [ [[], [], '', false], diff --git a/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php b/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php index a0953a2d..e746a267 100644 --- a/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php +++ b/Tests/Extension/FormExtensionBootstrap3HorizontalLayoutTest.php @@ -21,7 +21,7 @@ use Twig\Environment; use Twig\Loader\FilesystemLoader; -class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTest +class FormExtensionBootstrap3HorizontalLayoutTest extends AbstractBootstrap3HorizontalLayoutTestCase { use RuntimeLoaderProvider; diff --git a/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index a3a6c751..2b7e186c 100644 --- a/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -21,7 +21,7 @@ use Twig\Environment; use Twig\Loader\FilesystemLoader; -class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest +class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTestCase { use RuntimeLoaderProvider; diff --git a/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php b/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php index 33e1862a..f95e6784 100644 --- a/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php +++ b/Tests/Extension/FormExtensionBootstrap4HorizontalLayoutTest.php @@ -26,7 +26,7 @@ * * @author Hidde Wieringa */ -class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4HorizontalLayoutTest +class FormExtensionBootstrap4HorizontalLayoutTest extends AbstractBootstrap4HorizontalLayoutTestCase { use RuntimeLoaderProvider; diff --git a/Tests/Extension/FormExtensionBootstrap4LayoutTest.php b/Tests/Extension/FormExtensionBootstrap4LayoutTest.php index 00fee10e..2d0ca9fa 100644 --- a/Tests/Extension/FormExtensionBootstrap4LayoutTest.php +++ b/Tests/Extension/FormExtensionBootstrap4LayoutTest.php @@ -26,7 +26,7 @@ * * @author Hidde Wieringa */ -class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTest +class FormExtensionBootstrap4LayoutTest extends AbstractBootstrap4LayoutTestCase { use RuntimeLoaderProvider; /** diff --git a/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php b/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php index ef924884..d6d2c3c2 100644 --- a/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php +++ b/Tests/Extension/FormExtensionBootstrap5HorizontalLayoutTest.php @@ -26,7 +26,7 @@ * * @author Romain Monteil */ -class FormExtensionBootstrap5HorizontalLayoutTest extends AbstractBootstrap5HorizontalLayoutTest +class FormExtensionBootstrap5HorizontalLayoutTest extends AbstractBootstrap5HorizontalLayoutTestCase { use RuntimeLoaderProvider; diff --git a/Tests/Extension/FormExtensionBootstrap5LayoutTest.php b/Tests/Extension/FormExtensionBootstrap5LayoutTest.php index ed69ca81..94174615 100644 --- a/Tests/Extension/FormExtensionBootstrap5LayoutTest.php +++ b/Tests/Extension/FormExtensionBootstrap5LayoutTest.php @@ -28,7 +28,7 @@ * * @author Romain Monteil */ -class FormExtensionBootstrap5LayoutTest extends AbstractBootstrap5LayoutTest +class FormExtensionBootstrap5LayoutTest extends AbstractBootstrap5LayoutTestCase { use RuntimeLoaderProvider; diff --git a/Tests/Extension/FormExtensionDivLayoutTest.php b/Tests/Extension/FormExtensionDivLayoutTest.php index cae1a1c6..9fa6a013 100644 --- a/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/Tests/Extension/FormExtensionDivLayoutTest.php @@ -18,12 +18,12 @@ use Symfony\Component\Form\ChoiceList\View\ChoiceView; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Tests\AbstractDivLayoutTest; +use Symfony\Component\Form\Tests\AbstractDivLayoutTestCase; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Twig\Environment; use Twig\Loader\FilesystemLoader; -class FormExtensionDivLayoutTest extends AbstractDivLayoutTest +class FormExtensionDivLayoutTest extends AbstractDivLayoutTestCase { use RuntimeLoaderProvider; @@ -100,7 +100,7 @@ public function testThemeBlockInheritanceUsingDynamicExtend() ); } - public function isSelectedChoiceProvider() + public static function isSelectedChoiceProvider() { return [ [true, '0', '0'], @@ -150,7 +150,7 @@ public function testStartTagHasActionAttributeWhenActionIsZero() $this->assertSame('
', $html); } - public function isRootFormProvider() + public static function isRootFormProvider() { return [ [true, new FormView()], diff --git a/Tests/Extension/FormExtensionTableLayoutTest.php b/Tests/Extension/FormExtensionTableLayoutTest.php index 7b75be23..c0a7a9e8 100644 --- a/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/Tests/Extension/FormExtensionTableLayoutTest.php @@ -17,12 +17,12 @@ use Symfony\Bridge\Twig\Tests\Extension\Fixtures\StubTranslator; use Symfony\Component\Form\FormRenderer; use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Tests\AbstractTableLayoutTest; +use Symfony\Component\Form\Tests\AbstractTableLayoutTestCase; use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; use Twig\Environment; use Twig\Loader\FilesystemLoader; -class FormExtensionTableLayoutTest extends AbstractTableLayoutTest +class FormExtensionTableLayoutTest extends AbstractTableLayoutTestCase { use RuntimeLoaderProvider; diff --git a/Tests/Extension/HttpFoundationExtensionTest.php b/Tests/Extension/HttpFoundationExtensionTest.php index 131cb3d0..b92c3f83 100644 --- a/Tests/Extension/HttpFoundationExtensionTest.php +++ b/Tests/Extension/HttpFoundationExtensionTest.php @@ -32,7 +32,7 @@ public function testGenerateAbsoluteUrl($expected, $path, $pathinfo) $this->assertEquals($expected, $extension->generateAbsoluteUrl($path)); } - public function getGenerateAbsoluteUrlData() + public static function getGenerateAbsoluteUrlData() { return [ ['http://localhost/foo.png', '/foo.png', '/foo/bar.html'], @@ -76,7 +76,7 @@ public function testGenerateAbsoluteUrlWithoutRequestAndRequestContext($path) $this->assertEquals($path, $extension->generateAbsoluteUrl($path)); } - public function getGenerateAbsoluteUrlRequestContextData() + public static function getGenerateAbsoluteUrlRequestContextData() { return [ ['/foo.png', '/foo', 'localhost', 'http', 80, 443, 'http://localhost/foo.png'], @@ -117,7 +117,7 @@ public function testGenerateRelativePath($expected, $path, $pathinfo) $this->assertEquals($expected, $extension->generateRelativePath($path)); } - public function getGenerateRelativePathData() + public static function getGenerateRelativePathData() { return [ ['../foo.png', '/foo.png', '/foo/bar.html'], diff --git a/Tests/Extension/RoutingExtensionTest.php b/Tests/Extension/RoutingExtensionTest.php index 5a995c8e..742a74f3 100644 --- a/Tests/Extension/RoutingExtensionTest.php +++ b/Tests/Extension/RoutingExtensionTest.php @@ -34,7 +34,7 @@ public function testEscaping($template, $mustBeEscaped) $this->assertSame($mustBeEscaped, $nodes->getNode('body')->getNode(0)->getNode('expr') instanceof FilterExpression); } - public function getEscapingTemplates() + public static function getEscapingTemplates() { return [ ['{{ path("foo") }}', false], diff --git a/Tests/Extension/SerializerExtensionTest.php b/Tests/Extension/SerializerExtensionTest.php index ef54ee27..0c36c8c6 100644 --- a/Tests/Extension/SerializerExtensionTest.php +++ b/Tests/Extension/SerializerExtensionTest.php @@ -41,7 +41,7 @@ public function testSerializeFilter(string $template, string $expectedResult) self::assertSame($expectedResult, $twig->render('template', ['object' => new SerializerModelFixture()])); } - public function serializerDataProvider(): \Generator + public static function serializerDataProvider(): \Generator { yield ['{{ object|serialize }}', '{"name":"howdy","title":"fixture"}']; yield ['{{ object|serialize(\'yaml\') }}', '{ name: howdy, title: fixture }']; diff --git a/Tests/Extension/StopwatchExtensionTest.php b/Tests/Extension/StopwatchExtensionTest.php index 65f1bd69..d7ff03d7 100644 --- a/Tests/Extension/StopwatchExtensionTest.php +++ b/Tests/Extension/StopwatchExtensionTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Bridge\Twig\Extension\StopwatchExtension; use Symfony\Component\Stopwatch\Stopwatch; +use Symfony\Component\Stopwatch\StopwatchEvent; use Twig\Environment; use Twig\Error\RuntimeError; use Twig\Loader\ArrayLoader; @@ -41,7 +42,7 @@ public function testTiming($template, $events) } } - public function getTimingTemplates() + public static function getTimingTemplates() { return [ ['{% stopwatch "foo" %}something{% endstopwatch %}', 'foo'], @@ -67,12 +68,29 @@ protected function getStopwatch($events = []) $expectedStopCalls[] = [$this->equalTo($eventName)]; } - $startInvocationMocker = $stopwatch->expects($this->exactly($expectedCalls)) - ->method('start'); - \call_user_func_array([$startInvocationMocker, 'withConsecutive'], $expectedStartCalls); - $stopInvocationMocker = $stopwatch->expects($this->exactly($expectedCalls)) - ->method('stop'); - \call_user_func_array([$stopInvocationMocker, 'withConsecutive'], $expectedStopCalls); + $stopwatch + ->expects($this->exactly($expectedCalls)) + ->method('start') + ->willReturnCallback(function (string $name, string $category) use (&$expectedStartCalls) { + [$expectedName, $expectedCategory] = array_shift($expectedStartCalls); + + $expectedName->evaluate($name); + $this->assertSame($expectedCategory, $category); + + return $this->createMock(StopwatchEvent::class); + }) + ; + + $stopwatch + ->expects($this->exactly($expectedCalls)) + ->method('stop') + ->willReturnCallback(function (string $name) use (&$expectedStopCalls) { + [$expectedName] = array_shift($expectedStopCalls); + $expectedName->evaluate($name); + + return $this->createMock(StopwatchEvent::class); + }) + ; return $stopwatch; } diff --git a/Tests/Extension/TranslationExtensionTest.php b/Tests/Extension/TranslationExtensionTest.php index a0c2cad1..12d6bc5e 100644 --- a/Tests/Extension/TranslationExtensionTest.php +++ b/Tests/Extension/TranslationExtensionTest.php @@ -61,7 +61,7 @@ public function testTransComplexBody() $this->getTemplate("{% trans %}\n{{ 1 + 2 }}{% endtrans %}")->render(); } - public function getTransTests() + public static function getTransTests() { return [ // trans tag @@ -124,6 +124,7 @@ public function getTransTests() ['{{ foo|trans }}', '', ['foo' => null]], // trans object + ['{{ t("")|trans }}', ''], ['{{ t("Hello")|trans }}', 'Hello'], ['{{ t(name)|trans }}', 'Symfony', ['name' => 'Symfony']], ['{{ t(hello, { \'%name%\': \'Symfony\' })|trans }}', 'Hello Symfony', ['hello' => 'Hello %name%']], diff --git a/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php b/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php index cc2b6ef2..25b8166e 100644 --- a/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php +++ b/Tests/NodeVisitor/TranslationDefaultDomainNodeVisitorTest.php @@ -76,7 +76,7 @@ public function testNewModuleWithoutDefaultDomainTag(Node $node) $this->assertEquals([[self::$message, null]], $visitor->getMessages()); } - public function getDefaultDomainAssignmentTestData() + public static function getDefaultDomainAssignmentTestData() { return [ [TwigNodeProvider::getTransFilter(self::$message)], diff --git a/Tests/NodeVisitor/TranslationNodeVisitorTest.php b/Tests/NodeVisitor/TranslationNodeVisitorTest.php index 069914a4..bf073602 100644 --- a/Tests/NodeVisitor/TranslationNodeVisitorTest.php +++ b/Tests/NodeVisitor/TranslationNodeVisitorTest.php @@ -51,7 +51,7 @@ public function testMessageExtractionWithInvalidDomainNode() $this->testMessagesExtraction($node, [[$message, TranslationNodeVisitor::UNDEFINED_DOMAIN]]); } - public function getMessagesExtractionTestData() + public static function getMessagesExtractionTestData() { $message = 'new key'; $domain = 'domain'; diff --git a/Tests/TokenParser/FormThemeTokenParserTest.php b/Tests/TokenParser/FormThemeTokenParserTest.php index d4040600..41504050 100644 --- a/Tests/TokenParser/FormThemeTokenParserTest.php +++ b/Tests/TokenParser/FormThemeTokenParserTest.php @@ -40,7 +40,7 @@ public function testCompile($source, $expected) $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0)); } - public function getTestsForFormTheme() + public static function getTestsForFormTheme() { return [ [ diff --git a/Tests/Translation/TwigExtractorTest.php b/Tests/Translation/TwigExtractorTest.php index c93bd718..7d7d65ad 100644 --- a/Tests/Translation/TwigExtractorTest.php +++ b/Tests/Translation/TwigExtractorTest.php @@ -53,7 +53,7 @@ public function testExtract($template, $messages) } } - public function getExtractData() + public static function getExtractData() { return [ ['{{ "new key" | trans() }}', ['new key' => 'messages']], @@ -101,7 +101,7 @@ public function testExtractSyntaxError($resources, array $messages) $this->assertSame($messages, $catalogue->all()); } - public function resourcesWithSyntaxErrorsProvider(): array + public static function resourcesWithSyntaxErrorsProvider(): array { return [ [__DIR__.'/../Fixtures', ['messages' => ['Hi!' => 'Hi!']]], @@ -132,7 +132,7 @@ public function testExtractWithFiles($resource) $this->assertEquals('Hi!', $catalogue->get('Hi!', 'messages')); } - public function resourceProvider(): array + public static function resourceProvider(): array { $directory = __DIR__.'/../Fixtures/extractor/'; diff --git a/composer.json b/composer.json index c1a45f91..a091f858 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "symfony/asset": "^5.4|^6.0", "symfony/dependency-injection": "^5.4|^6.0", "symfony/finder": "^5.4|^6.0", - "symfony/form": "^6.1", + "symfony/form": "^6.2.7", "symfony/html-sanitizer": "^6.1", "symfony/http-foundation": "^5.4|^6.0", "symfony/http-kernel": "^6.2", @@ -57,7 +57,7 @@ "phpdocumentor/reflection-docblock": "<3.2.2", "phpdocumentor/type-resolver": "<1.4.0", "symfony/console": "<5.4", - "symfony/form": "<6.1", + "symfony/form": "<6.2.7", "symfony/http-foundation": "<5.4", "symfony/http-kernel": "<6.2", "symfony/mime": "<6.2",