diff --git a/extra/cache-extra/Tests/IntegrationTest.php b/extra/cache-extra/Tests/IntegrationTest.php index 4f597b0aa..c439976f9 100644 --- a/extra/cache-extra/Tests/IntegrationTest.php +++ b/extra/cache-extra/Tests/IntegrationTest.php @@ -38,7 +38,7 @@ class IntegrationTest extends IntegrationTestCase ]; } - public function getFixturesDir() + protected static function getFixturesDirectory(): string { return __DIR__.'/Fixtures/'; } diff --git a/extra/cache-extra/composer.json b/extra/cache-extra/composer.json index 454b94921..5551ca388 100644 --- a/extra/cache-extra/composer.json +++ b/extra/cache-extra/composer.json @@ -17,7 +17,7 @@ "require": { "php": ">=8.2", "symfony/cache": "^5.4|^6.4|^7.0", - "twig/twig": "^3.12|^4.0" + "twig/twig": "^3.13|^4.0" }, "require-dev": { "symfony/phpunit-bridge": "^6.4|^7.0" diff --git a/extra/cssinliner-extra/Tests/IntegrationTest.php b/extra/cssinliner-extra/Tests/IntegrationTest.php index 5ab6ec9b4..7004b5e99 100644 --- a/extra/cssinliner-extra/Tests/IntegrationTest.php +++ b/extra/cssinliner-extra/Tests/IntegrationTest.php @@ -23,7 +23,7 @@ class IntegrationTest extends IntegrationTestCase ]; } - public function getFixturesDir() + protected static function getFixturesDirectory(): string { return __DIR__.'/Fixtures/'; } diff --git a/extra/cssinliner-extra/composer.json b/extra/cssinliner-extra/composer.json index 00e9ff7a8..677a24ca4 100644 --- a/extra/cssinliner-extra/composer.json +++ b/extra/cssinliner-extra/composer.json @@ -18,7 +18,7 @@ "php": ">=8.2", "symfony/deprecation-contracts": "^2.5|^3", "tijsverkoyen/css-to-inline-styles": "^2.0", - "twig/twig": "^3.0|^4.0" + "twig/twig": "^3.13|^4.0" }, "require-dev": { "symfony/phpunit-bridge": "^6.4|^7.0" diff --git a/extra/html-extra/Tests/IntegrationTest.php b/extra/html-extra/Tests/IntegrationTest.php index 8f464c152..8e2f94e38 100644 --- a/extra/html-extra/Tests/IntegrationTest.php +++ b/extra/html-extra/Tests/IntegrationTest.php @@ -23,7 +23,7 @@ class IntegrationTest extends IntegrationTestCase ]; } - public function getFixturesDir() + protected static function getFixturesDirectory(): string { return __DIR__.'/Fixtures/'; } diff --git a/extra/html-extra/composer.json b/extra/html-extra/composer.json index 649294689..47d106ce2 100644 --- a/extra/html-extra/composer.json +++ b/extra/html-extra/composer.json @@ -18,7 +18,7 @@ "php": ">=8.2", "symfony/deprecation-contracts": "^2.5|^3", "symfony/mime": "^5.4|^6.4|^7.0", - "twig/twig": "^3.0|^4.0" + "twig/twig": "^3.13|^4.0" }, "require-dev": { "symfony/phpunit-bridge": "^6.4|^7.0" diff --git a/extra/inky-extra/Tests/IntegrationTest.php b/extra/inky-extra/Tests/IntegrationTest.php index 317d36476..d9420dd09 100644 --- a/extra/inky-extra/Tests/IntegrationTest.php +++ b/extra/inky-extra/Tests/IntegrationTest.php @@ -23,7 +23,7 @@ class IntegrationTest extends IntegrationTestCase ]; } - public function getFixturesDir() + protected static function getFixturesDirectory(): string { return __DIR__.'/Fixtures/'; } diff --git a/extra/inky-extra/composer.json b/extra/inky-extra/composer.json index 798a4d926..2071c86e9 100644 --- a/extra/inky-extra/composer.json +++ b/extra/inky-extra/composer.json @@ -18,7 +18,7 @@ "php": ">=8.2", "symfony/deprecation-contracts": "^2.5|^3", "lorenzo/pinky": "^1.0.5", - "twig/twig": "^3.0|^4.0" + "twig/twig": "^3.13|^4.0" }, "require-dev": { "symfony/phpunit-bridge": "^6.4|^7.0" diff --git a/extra/intl-extra/Tests/IntegrationTest.php b/extra/intl-extra/Tests/IntegrationTest.php index 7b191bacd..fa22b5708 100644 --- a/extra/intl-extra/Tests/IntegrationTest.php +++ b/extra/intl-extra/Tests/IntegrationTest.php @@ -23,7 +23,7 @@ class IntegrationTest extends IntegrationTestCase ]; } - public function getFixturesDir() + protected static function getFixturesDirectory(): string { return __DIR__.'/Fixtures/'; } diff --git a/extra/intl-extra/composer.json b/extra/intl-extra/composer.json index 45308c4d4..a4a6569ce 100644 --- a/extra/intl-extra/composer.json +++ b/extra/intl-extra/composer.json @@ -16,7 +16,7 @@ ], "require": { "php": ">=8.2", - "twig/twig": "^3.10|^4.0", + "twig/twig": "^3.13|^4.0", "symfony/intl": "^5.4|^6.4|^7.0" }, "require-dev": { diff --git a/extra/markdown-extra/Tests/FunctionalTest.php b/extra/markdown-extra/Tests/FunctionalTest.php index 62c7928fe..154d75a9c 100644 --- a/extra/markdown-extra/Tests/FunctionalTest.php +++ b/extra/markdown-extra/Tests/FunctionalTest.php @@ -57,7 +57,7 @@ EOF } } - public function getMarkdownTests() + public static function getMarkdownTests() { return [ [<<=8.2", "symfony/deprecation-contracts": "^2.5|^3", - "twig/twig": "^3.0|^4.0" + "twig/twig": "^3.13|^4.0" }, "require-dev": { "symfony/phpunit-bridge": "^6.4|^7.0", diff --git a/extra/string-extra/Tests/IntegrationTest.php b/extra/string-extra/Tests/IntegrationTest.php index 032c9a9d9..ddf6abfe5 100644 --- a/extra/string-extra/Tests/IntegrationTest.php +++ b/extra/string-extra/Tests/IntegrationTest.php @@ -23,7 +23,7 @@ class IntegrationTest extends IntegrationTestCase ]; } - public function getFixturesDir() + protected static function getFixturesDirectory(): string { return __DIR__.'/Fixtures/'; } diff --git a/extra/string-extra/composer.json b/extra/string-extra/composer.json index 672a0d7cc..dcfe9ebe4 100644 --- a/extra/string-extra/composer.json +++ b/extra/string-extra/composer.json @@ -18,7 +18,7 @@ "php": ">=8.2", "symfony/string": "^5.4|^6.4|^7.0", "symfony/translation-contracts": "^1.1|^2|^3", - "twig/twig": "^3.0|^4.0" + "twig/twig": "^3.13|^4.0" }, "require-dev": { "symfony/phpunit-bridge": "^6.4|^7.0" diff --git a/src/Extension/CoreExtension.php b/src/Extension/CoreExtension.php index 3e660ea83..f73851cdd 100644 --- a/src/Extension/CoreExtension.php +++ b/src/Extension/CoreExtension.php @@ -1788,6 +1788,10 @@ final class CoreExtension extends AbstractExtension */ public static function map(Environment $env, $array, $arrow) { + if (!is_iterable($array)) { + throw new RuntimeError(\sprintf('The "map" filter expects a sequence/mapping or "Traversable", got "%s".', get_debug_type($array))); + } + self::checkArrowInSandbox($env, $arrow, 'map', 'filter'); $r = []; diff --git a/src/Test/IntegrationTestCase.php b/src/Test/IntegrationTestCase.php index 24725f5a8..ba23e7305 100644 --- a/src/Test/IntegrationTestCase.php +++ b/src/Test/IntegrationTestCase.php @@ -31,9 +31,18 @@ use Twig\TwigTest; abstract class IntegrationTestCase extends TestCase { /** + * @deprecated since Twig 3.13, use getFixturesDirectory() instead. * @return string */ - abstract protected function getFixturesDir(); + protected function getFixturesDir() + { + throw new \BadMethodCallException('Not implemented.'); + } + + protected static function getFixturesDirectory(): string + { + throw new \BadMethodCallException('Not implemented.'); + } /** * @return RuntimeLoaderInterface[] @@ -93,9 +102,19 @@ abstract class IntegrationTestCase extends TestCase $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs, $deprecation); } + /** + * @final since Twig 3.13 + */ public function getTests($name, $legacyTests = false) { - $fixturesDir = realpath($this->getFixturesDir()); + try { + $fixturesDir = static::getFixturesDirectory(); + } catch (\BadMethodCallException) { + trigger_deprecation('twig/twig', '3.13', 'Not overriding "%s::getFixturesDirectory()" in "%s" is deprecated. This method will be abstract in 4.0.', self::class, static::class); + $fixturesDir = $this->getFixturesDir(); + } + + $fixturesDir = realpath($fixturesDir); $tests = []; foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($fixturesDir), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) { @@ -138,6 +157,9 @@ abstract class IntegrationTestCase extends TestCase return $tests; } + /** + * @final since Twig 3.13 + */ public function getLegacyTests() { return $this->getTests('testLegacyIntegration', true); diff --git a/tests/Cache/FilesystemTest.php b/tests/Cache/FilesystemTest.php index 808dcc8b3..4ea3d1d81 100644 --- a/tests/Cache/FilesystemTest.php +++ b/tests/Cache/FilesystemTest.php @@ -170,7 +170,7 @@ class FilesystemTest extends TestCase $this->assertMatchesRegularExpression($expected, $cache->generateKey('_test_', static::class)); } - public function provideDirectories() + public static function provideDirectories() { $pattern = '#a/b/[a-zA-Z0-9]+/[a-zA-Z0-9]+.php$#'; diff --git a/tests/CustomExtensionTest.php b/tests/CustomExtensionTest.php index a2ac0dbed..fab7813b1 100644 --- a/tests/CustomExtensionTest.php +++ b/tests/CustomExtensionTest.php @@ -31,7 +31,7 @@ class CustomExtensionTest extends TestCase $env->getUnaryOperators(); } - public function provideInvalidExtensions() + public static function provideInvalidExtensions() { return [ [new InvalidOperatorExtension([1, 2, 3]), '"Twig\Tests\InvalidOperatorExtension::getOperators()" must return an array of 2 elements, got 3.'], diff --git a/tests/ErrorTest.php b/tests/ErrorTest.php index 423a1a58d..d29112cd7 100644 --- a/tests/ErrorTest.php +++ b/tests/ErrorTest.php @@ -234,7 +234,7 @@ EOHTML } } - public function getErroredTemplates() + public static function getErroredTemplates() { return [ // error occurs in a template diff --git a/tests/ExpressionParserTest.php b/tests/ExpressionParserTest.php index 4dcd1b9c2..5b738da72 100644 --- a/tests/ExpressionParserTest.php +++ b/tests/ExpressionParserTest.php @@ -40,7 +40,7 @@ class ExpressionParserTest extends TestCase $parser->parse($env->tokenize(new Source($template, 'index'))); } - public function getFailingTestsForAssignment() + public static function getFailingTestsForAssignment() { return [ ['{% set false = "foo" %}'], @@ -83,7 +83,7 @@ class ExpressionParserTest extends TestCase $parser->parse($env->tokenize(new Source($template, 'index'))); } - public function getFailingTestsForSequence() + public static function getFailingTestsForSequence() { return [ ['{{ [1, "a": "b"] }}'], @@ -92,7 +92,7 @@ class ExpressionParserTest extends TestCase ]; } - public function getTestsForSequence() + public static function getTestsForSequence() { return [ // simple sequence @@ -182,7 +182,7 @@ class ExpressionParserTest extends TestCase new ConstantExpression(2, 1), new ConstantExpression(2, 1), - $this->createNameExpression('foo', ['spread' => true]), + self::createNameExpression('foo', ['spread' => true]), ], 1)], // mapping with spread operator @@ -195,7 +195,7 @@ class ExpressionParserTest extends TestCase new ConstantExpression('c', 1), new ConstantExpression(0, 1), - $this->createNameExpression('otherLetters', ['spread' => true]), + self::createNameExpression('otherLetters', ['spread' => true]), ], 1)], ]; } @@ -224,7 +224,7 @@ class ExpressionParserTest extends TestCase $this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0)->getNode('expr')); } - public function getTestsForString() + public static function getTestsForString() { return [ [ @@ -313,7 +313,7 @@ class ExpressionParserTest extends TestCase $parser->parse($env->tokenize(new Source($template, 'index'))); } - public function getMacroDefinitionDoesNotSupportNonConstantDefaultValues() + public static function getMacroDefinitionDoesNotSupportNonConstantDefaultValues() { return [ ['{% macro foo(name = "a #{foo} a") %}{% endmacro %}'], @@ -336,7 +336,7 @@ class ExpressionParserTest extends TestCase $this->addToAssertionCount(1); } - public function getMacroDefinitionSupportsConstantDefaultValues() + public static function getMacroDefinitionSupportsConstantDefaultValues() { return [ ['{% macro foo(name = "aa") %}{% endmacro %}'], @@ -460,7 +460,18 @@ class ExpressionParserTest extends TestCase $this->assertStringContainsString('$this->env->getFilter(\'*_foo_*_bar\')->getCallable()("foo", "bar", "a")', $env->compile($env->parse($env->tokenize(new Source($env->getLoader()->getSourceContext('index')->getCode(), 'index'))))); } - private function createNameExpression(string $name, array $attributes) + public function testTwoWordTestPrecedence() + { + // a "empty element" test must have precedence over "empty" + $env = new Environment(new ArrayLoader(), ['cache' => false, 'autoescape' => false]); + $env->addTest(new TwigTest('empty element', 'foo')); + $parser = new Parser($env); + + $parser->parse($env->tokenize(new Source('{{ 1 is empty element }}', 'index'))); + $this->doesNotPerformAssertions(); + } + + private static function createNameExpression(string $name, array $attributes): NameExpression { $expression = new NameExpression($name, 1); foreach ($attributes as $key => $value) { diff --git a/tests/Extension/CoreTest.php b/tests/Extension/CoreTest.php index d5bb2e0f7..b83e04dda 100644 --- a/tests/Extension/CoreTest.php +++ b/tests/Extension/CoreTest.php @@ -67,7 +67,7 @@ class CoreTest extends TestCase } } - public function getRandomFunctionTestData() + public static function getRandomFunctionTestData() { return [ 'array' => [ @@ -165,7 +165,7 @@ class CoreTest extends TestCase $this->assertSame($expected, CoreExtension::first('UTF-8', $input)); } - public function provideTwigFirstCases() + public static function provideTwigFirstCases() { $i = [1 => 'a', 2 => 'b', 3 => 'c']; @@ -186,7 +186,7 @@ class CoreTest extends TestCase $this->assertSame($expected, CoreExtension::last('UTF-8', $input)); } - public function provideTwigLastCases() + public static function provideTwigLastCases() { $i = [1 => 'a', 2 => 'b', 3 => 'c']; @@ -207,7 +207,7 @@ class CoreTest extends TestCase $this->assertSame($expected, CoreExtension::keys($input)); } - public function provideArrayKeyCases() + public static function provideArrayKeyCases() { $array = ['a' => 'a1', 'b' => 'b1', 'c' => 'c1']; $keys = array_keys($array); @@ -230,7 +230,7 @@ class CoreTest extends TestCase $this->assertSame($expected, CoreExtension::inFilter($value, $compare)); } - public function provideInFilterCases() + public static function provideInFilterCases() { $array = [1, 2, 'a' => 3, 5, 6, 7]; $keys = array_keys($array); @@ -258,7 +258,7 @@ class CoreTest extends TestCase $this->assertSame($expected, CoreExtension::slice('UTF-8', $input, $start, $length, $preserveKeys)); } - public function provideSliceFilterCases() + public static function provideSliceFilterCases() { $i = ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4]; $keys = array_keys($i); @@ -296,7 +296,7 @@ class CoreTest extends TestCase $this->assertSame(1, CoreExtension::compare('foo', \NAN)); } - public function provideCompareCases() + public static function provideCompareCases() { return [ [0, 'a', 'a'], diff --git a/tests/Extension/SandboxTest.php b/tests/Extension/SandboxTest.php index 43474af8f..e26ff90c1 100644 --- a/tests/Extension/SandboxTest.php +++ b/tests/Extension/SandboxTest.php @@ -77,7 +77,7 @@ class SandboxTest extends TestCase $twig->createTemplate($template, 'index')->render([]); } - public function getSandboxedForCoreTagsTests() + public static function getSandboxedForCoreTagsTests() { yield ['apply', '{% apply upper %}foo{% endapply %}']; yield ['autoescape', '{% autoescape %}foo{% endautoescape %}']; @@ -230,7 +230,7 @@ class SandboxTest extends TestCase } } - public function getSandboxUnallowedToStringTests() + public static function getSandboxUnallowedToStringTests() { return [ 'simple' => ['{{ obj }}'], @@ -258,7 +258,7 @@ class SandboxTest extends TestCase $this->assertEquals($output, $twig->load('index')->render(self::$params)); } - public function getSandboxAllowedToStringTests() + public static function getSandboxAllowedToStringTests() { return [ 'constant_test' => ['{{ obj is constant("PHP_INT_MAX") }}', ''], diff --git a/tests/FileExtensionEscapingStrategyTest.php b/tests/FileExtensionEscapingStrategyTest.php index 883aa882c..ed5ce060b 100644 --- a/tests/FileExtensionEscapingStrategyTest.php +++ b/tests/FileExtensionEscapingStrategyTest.php @@ -24,7 +24,7 @@ class FileExtensionEscapingStrategyTest extends TestCase $this->assertSame($strategy, FileExtensionEscapingStrategy::guess($filename)); } - public function getGuessData() + public static function getGuessData() { return [ // default diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index c18ffe142..868825103 100644 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -48,7 +48,7 @@ class IntegrationTest extends IntegrationTestCase ]; } - public function getFixturesDir() + protected static function getFixturesDirectory(): string { return __DIR__.'/Fixtures/'; } diff --git a/tests/LexerTest.php b/tests/LexerTest.php index a2a2794a0..41ae7b9dc 100644 --- a/tests/LexerTest.php +++ b/tests/LexerTest.php @@ -190,7 +190,7 @@ class LexerTest extends TestCase $this->assertSame($expected, $token->getValue()); } - public function getStringWithEscapedDelimiter() + public static function getStringWithEscapedDelimiter() { yield '{{ \'App\Test\' }} => App\Test' => [ '{{ \'App\\Test\' }}', @@ -437,7 +437,7 @@ bar } } - public function getTemplateForErrorsAtTheEndOfTheStream() + public static function getTemplateForErrorsAtTheEndOfTheStream() { yield ['{{ =']; yield ['{{ ..']; @@ -465,7 +465,7 @@ bar $this->addToAssertionCount(1); } - public function getTemplateForStrings() + public static function getTemplateForStrings() { yield ['日本では、春になると桜の花が咲きます。多くの人々は、公園や川の近くに集まり、お花見を楽しみます。桜の花びらが風に舞い、まるで雪のように見える瞬間は、とても美しいです。']; yield ['في العالم العربي، يُعتبر الخط العربي أحد أجمل أشكال الفن. يُستخدم الخط في تزيين المساجد والكتب والمخطوطات القديمة. يتميز الخط العربي بجماله وتناسقه، ويُعتبر رمزًا للثقافة الإسلامية.']; diff --git a/tests/Loader/FilesystemTest.php b/tests/Loader/FilesystemTest.php index 44b3c170d..c7315ea80 100644 --- a/tests/Loader/FilesystemTest.php +++ b/tests/Loader/FilesystemTest.php @@ -42,7 +42,7 @@ class FilesystemTest extends TestCase } } - public function getSecurityTests() + public static function getSecurityTests() { return [ ["AutoloaderTest\0.php"], @@ -105,7 +105,7 @@ class FilesystemTest extends TestCase $this->assertEquals("named path (final)\n", $loader->getSourceContext('@named/index.html')->getCode()); } - public function getBasePaths() + public static function getBasePaths() { return [ [ @@ -197,7 +197,7 @@ class FilesystemTest extends TestCase $this->assertSame('block from theme 2', $template->renderBlock('b2', [])); } - public function getArrayInheritanceTests() + public static function getArrayInheritanceTests() { return [ 'valid array inheritance' => ['array_inheritance_valid_parent.html.twig'], diff --git a/tests/NodeVisitor/OptimizerTest.php b/tests/NodeVisitor/OptimizerTest.php index 95c8f2d09..524287be1 100644 --- a/tests/NodeVisitor/OptimizerTest.php +++ b/tests/NodeVisitor/OptimizerTest.php @@ -92,7 +92,7 @@ class OptimizerTest extends TestCase } } - public function getTestsForForLoopOptimizer() + public static function getTestsForForLoopOptimizer() { return [ ['{% for i in foo %}{% endfor %}', ['i' => false]], diff --git a/tests/ParserTest.php b/tests/ParserTest.php index b0827b910..9b940602b 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -67,7 +67,7 @@ class ParserTest extends TestCase $this->assertEquals($expected, $m->invoke($parser, $input)); } - public function getFilterBodyNodesData() + public static function getFilterBodyNodesData() { return [ [ @@ -98,7 +98,7 @@ class ParserTest extends TestCase $m->invoke($parser, $input); } - public function getFilterBodyNodesDataThrowsException() + public static function getFilterBodyNodesDataThrowsException() { return [ [new TextNode('foo', 1)], @@ -117,7 +117,7 @@ class ParserTest extends TestCase $this->assertNull($m->invoke($parser, new TextNode(\chr(0xEF).\chr(0xBB).\chr(0xBF).$emptyNode, 1))); } - public function getFilterBodyNodesWithBOMData() + public static function getFilterBodyNodesWithBOMData() { return [ [' '], diff --git a/tests/Profiler/Dumper/BlackfireTest.php b/tests/Profiler/Dumper/BlackfireTest.php index 3a33d9403..ecf709a3d 100644 --- a/tests/Profiler/Dumper/BlackfireTest.php +++ b/tests/Profiler/Dumper/BlackfireTest.php @@ -13,7 +13,7 @@ namespace Twig\Tests\Profiler\Dumper; use Twig\Profiler\Dumper\BlackfireDumper; -class BlackfireTest extends AbstractTest +class BlackfireTest extends ProfilerTestCase { public function testDump() { diff --git a/tests/Profiler/Dumper/HtmlTest.php b/tests/Profiler/Dumper/HtmlTest.php index 2dcbb9aec..64e459bab 100644 --- a/tests/Profiler/Dumper/HtmlTest.php +++ b/tests/Profiler/Dumper/HtmlTest.php @@ -13,7 +13,7 @@ namespace Twig\Tests\Profiler\Dumper; use Twig\Profiler\Dumper\HtmlDumper; -class HtmlTest extends AbstractTest +class HtmlTest extends ProfilerTestCase { public function testDump() { diff --git a/tests/Profiler/Dumper/AbstractTest.php b/tests/Profiler/Dumper/ProfilerTestCase.php similarity index 98% rename from tests/Profiler/Dumper/AbstractTest.php rename to tests/Profiler/Dumper/ProfilerTestCase.php index 6b7acb1a9..92b5dacd5 100644 --- a/tests/Profiler/Dumper/AbstractTest.php +++ b/tests/Profiler/Dumper/ProfilerTestCase.php @@ -14,7 +14,7 @@ namespace Twig\Tests\Profiler\Dumper; use PHPUnit\Framework\TestCase; use Twig\Profiler\Profile; -abstract class AbstractTest extends TestCase +abstract class ProfilerTestCase extends TestCase { protected function getProfile() { diff --git a/tests/Profiler/Dumper/TextTest.php b/tests/Profiler/Dumper/TextTest.php index ba19c2c90..e488edc06 100644 --- a/tests/Profiler/Dumper/TextTest.php +++ b/tests/Profiler/Dumper/TextTest.php @@ -13,7 +13,7 @@ namespace Twig\Tests\Profiler\Dumper; use Twig\Profiler\Dumper\TextDumper; -class TextTest extends AbstractTest +class TextTest extends ProfilerTestCase { public function testDump() { diff --git a/tests/Runtime/EscaperRuntimeTest.php b/tests/Runtime/EscaperRuntimeTest.php index fc62246a3..347c9ca07 100644 --- a/tests/Runtime/EscaperRuntimeTest.php +++ b/tests/Runtime/EscaperRuntimeTest.php @@ -357,7 +357,7 @@ class EscaperRuntimeTest extends TestCase $this->assertSame($expected, $escaper->escape($string, $strategy, $charset)); } - public function provideCustomEscaperCases() + public static function provideCustomEscaperCases() { return [ ['foo**ISO-8859-1', 'foo', 'foo', 'ISO-8859-1'], @@ -378,7 +378,7 @@ class EscaperRuntimeTest extends TestCase $this->assertSame($escapedJs, $escaper->escape($obj, 'js', null, true)); } - public function provideObjectsForEscaping() + public static function provideObjectsForEscaping() { return [ ['<br />', '
', [ExtensionTestClass::class => ['js']]], diff --git a/tests/TemplateTest.php b/tests/TemplateTest.php index 33196f18b..4be4d03ca 100644 --- a/tests/TemplateTest.php +++ b/tests/TemplateTest.php @@ -61,7 +61,7 @@ class TemplateTest extends TestCase } } - public function getAttributeExceptions() + public static function getAttributeExceptions() { return [ ['{{ string["a"] }}', 'Impossible to access a key ("a") on a string variable ("foo") in "%s" at line 1.'], @@ -113,7 +113,7 @@ class TemplateTest extends TestCase } } - public function getGetAttributeWithSandbox() + public static function getGetAttributeWithSandbox() { return [ [new TemplatePropertyObject(), 'defined', false], @@ -132,7 +132,7 @@ class TemplateTest extends TestCase $this->assertSame('', $twig->render('index')); } - public function getRenderTemplateWithoutOutputData() + public static function getRenderTemplateWithoutOutputData() { return [ [''], @@ -247,7 +247,7 @@ class TemplateTest extends TestCase $this->assertNull(CoreExtension::getAttribute($twig, $template->getSourceContext(), $object, 'foo')); } - public function getGetAttributeTests() + public static function getGetAttributeTests() { $array = [ 'defined' => 'defined', diff --git a/tests/TokenParser/TypesTokenParserTest.php b/tests/TokenParser/TypesTokenParserTest.php index 67794c097..57ccb77cb 100644 --- a/tests/TokenParser/TypesTokenParserTest.php +++ b/tests/TokenParser/TypesTokenParserTest.php @@ -22,7 +22,7 @@ class TypesTokenParserTest extends TestCase self::assertEquals($expected, $typesNode->getAttribute('mapping')); } - public function getMappingTests(): array + public static function getMappingTests(): array { return [ // empty mapping