From 5193653ecb34a541d98d0947604af06d64134dab Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 8 Oct 2023 09:05:22 +0200 Subject: [PATCH] Fix CS --- extra/markdown-extra/MarkdownExtension.php | 2 +- extra/markdown-extra/Tests/FunctionalTest.php | 2 +- .../TwigExtraExtension.php | 2 +- .../Tests/Fixture/Kernel.php | 2 +- src/Cache/FilesystemCache.php | 2 +- src/Extension/CoreExtension.php | 11 +++---- src/Extension/DebugExtension.php | 4 +-- src/Extension/EscaperExtension.php | 4 +-- src/Lexer.php | 2 +- src/Markup.php | 3 -- .../MacroAutoImportNodeVisitor.php | 8 ++--- src/NodeVisitor/OptimizerNodeVisitor.php | 16 +++++----- src/Parser.php | 3 +- src/Test/IntegrationTestCase.php | 3 +- src/Token.php | 6 ++-- src/TokenParser/FromTokenParser.php | 4 +-- src/TokenParser/UseTokenParser.php | 4 +-- src/Util/TemplateDirIterator.php | 6 ---- tests/Extension/CoreTest.php | 6 ---- tests/Extension/EscaperTest.php | 24 +++++++-------- tests/IntegrationTest.php | 12 -------- tests/Node/IncludeTest.php | 10 +++---- tests/Node/ModuleTest.php | 10 +++---- tests/ParserTest.php | 2 +- tests/Profiler/Dumper/AbstractTest.php | 1 - tests/Profiler/Dumper/BlackfireTest.php | 2 +- tests/Profiler/Dumper/HtmlTest.php | 2 +- tests/Profiler/Dumper/TextTest.php | 2 +- tests/TemplateTest.php | 29 +++++++------------ 29 files changed, 72 insertions(+), 112 deletions(-) diff --git a/extra/markdown-extra/MarkdownExtension.php b/extra/markdown-extra/MarkdownExtension.php index 8f249ce6d86..6c4296bbf1b 100644 --- a/extra/markdown-extra/MarkdownExtension.php +++ b/extra/markdown-extra/MarkdownExtension.php @@ -34,7 +34,7 @@ function twig_html_to_markdown(string $body, array $options = []): string throw new \LogicException('You cannot use the "html_to_markdown" filter as league/html-to-markdown is not installed; try running "composer require league/html-to-markdown".'); } - $options = $options + [ + $options += [ 'hard_break' => true, 'strip_tags' => true, 'remove_nodes' => 'head style', diff --git a/extra/markdown-extra/Tests/FunctionalTest.php b/extra/markdown-extra/Tests/FunctionalTest.php index 368a0467b3b..42f4ff65a97 100644 --- a/extra/markdown-extra/Tests/FunctionalTest.php +++ b/extra/markdown-extra/Tests/FunctionalTest.php @@ -29,7 +29,7 @@ class FunctionalTest extends TestCase */ public function testMarkdown(string $template, string $expected): void { - foreach ([LeagueMarkdown::class, ErusevMarkdown::class, /*MichelfMarkdown::class,*/ DefaultMarkdown::class] as $class) { + foreach ([LeagueMarkdown::class, ErusevMarkdown::class, /* MichelfMarkdown::class, */ DefaultMarkdown::class] as $class) { $twig = new Environment(new ArrayLoader([ 'index' => $template, 'html' => <<isConfigEnabled($container, $config[$extension])) { $loader->load($extension.'.php'); - if ('markdown' === $extension && \class_exists(CommonMarkConverter::class)) { + if ('markdown' === $extension && class_exists(CommonMarkConverter::class)) { $loader->load('markdown_league.php'); } } diff --git a/extra/twig-extra-bundle/Tests/Fixture/Kernel.php b/extra/twig-extra-bundle/Tests/Fixture/Kernel.php index cbc9c4bd850..3df6357fe1f 100644 --- a/extra/twig-extra-bundle/Tests/Fixture/Kernel.php +++ b/extra/twig-extra-bundle/Tests/Fixture/Kernel.php @@ -4,11 +4,11 @@ use League\CommonMark\Extension\Strikethrough\StrikethroughExtension; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; +use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Bundle\TwigBundle\TwigBundle; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Kernel as BaseKernel; -use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Twig\Extra\TwigExtraBundle\TwigExtraBundle; class Kernel extends BaseKernel diff --git a/src/Cache/FilesystemCache.php b/src/Cache/FilesystemCache.php index e075563aef6..4024adbd70d 100644 --- a/src/Cache/FilesystemCache.php +++ b/src/Cache/FilesystemCache.php @@ -63,7 +63,7 @@ public function write(string $key, string $content): void if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) { // Compile cached file into bytecode cache - if (\function_exists('opcache_invalidate') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN)) { + if (\function_exists('opcache_invalidate') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN)) { @opcache_invalidate($key, true); } elseif (\function_exists('apc_compile_file')) { apc_compile_file($key); diff --git a/src/Extension/CoreExtension.php b/src/Extension/CoreExtension.php index 0f1a10216f3..6c16ee2b7d9 100644 --- a/src/Extension/CoreExtension.php +++ b/src/Extension/CoreExtension.php @@ -343,9 +343,9 @@ function twig_cycle($values, $position) * @param \Traversable|array|int|float|string $values The values to pick a random item from * @param int|null $max Maximum value used when $values is an int * - * @throws RuntimeError when $values is an empty array (does not apply to an empty string which is returned as is) - * * @return mixed A random value from the given sequence + * + * @throws RuntimeError when $values is an empty array (does not apply to an empty string which is returned as is) */ function twig_random(Environment $env, $values = null, $max = null) { @@ -768,7 +768,7 @@ function twig_split_filter(Environment $env, $value, $delimiter, $limit = null) { $value = $value ?? ''; - if (\strlen($delimiter) > 0) { + if ('' !== $delimiter) { return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit); } @@ -1022,9 +1022,6 @@ function twig_compare($a, $b) } /** - * @param string $pattern - * @param string|null $subject - * * @return int * * @throws RuntimeError When an invalid pattern is used @@ -1123,7 +1120,7 @@ function twig_length_filter(Environment $env, $thing) return 0; } - if (is_scalar($thing)) { + if (\is_scalar($thing)) { return mb_strlen($thing, $env->getCharset()); } diff --git a/src/Extension/DebugExtension.php b/src/Extension/DebugExtension.php index bfb23d7bd4f..c0f10d5a303 100644 --- a/src/Extension/DebugExtension.php +++ b/src/Extension/DebugExtension.php @@ -19,10 +19,10 @@ public function getFunctions(): array // dump is safe if var_dump is overridden by xdebug $isDumpOutputHtmlSafe = \extension_loaded('xdebug') // false means that it was not set (and the default is on) or it explicitly enabled - && (false === ini_get('xdebug.overload_var_dump') || ini_get('xdebug.overload_var_dump')) + && (false === \ini_get('xdebug.overload_var_dump') || \ini_get('xdebug.overload_var_dump')) // false means that it was not set (and the default is on) or it explicitly enabled // xdebug.overload_var_dump produces HTML only when html_errors is also enabled - && (false === ini_get('html_errors') || ini_get('html_errors')) + && (false === \ini_get('html_errors') || \ini_get('html_errors')) || 'cli' === \PHP_SAPI ; diff --git a/src/Extension/EscaperExtension.php b/src/Extension/EscaperExtension.php index 9d2251dc6e1..ef8879dbdc6 100644 --- a/src/Extension/EscaperExtension.php +++ b/src/Extension/EscaperExtension.php @@ -341,7 +341,7 @@ function twig_escape_filter(Environment $env, $string, $strategy = 'html', $char * The following replaces characters undefined in HTML with the * hex entity for the Unicode replacement character. */ - if (($ord <= 0x1f && "\t" != $chr && "\n" != $chr && "\r" != $chr) || ($ord >= 0x7f && $ord <= 0x9f)) { + if (($ord <= 0x1F && "\t" != $chr && "\n" != $chr && "\r" != $chr) || ($ord >= 0x7F && $ord <= 0x9F)) { return '�'; } @@ -388,7 +388,7 @@ function twig_escape_filter(Environment $env, $string, $strategy = 'html', $char default: $escapers = $env->getExtension(EscaperExtension::class)->getEscapers(); - if (array_key_exists($strategy, $escapers)) { + if (\array_key_exists($strategy, $escapers)) { return $escapers[$strategy]($env, $string, $charset); } diff --git a/src/Lexer.php b/src/Lexer.php index 6c45efbc9f6..5a6258c2c96 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -422,7 +422,7 @@ private function lexString(): void $this->pushToken(/* Token::INTERPOLATION_START_TYPE */ 10); $this->moveCursor($match[0]); $this->pushState(self::STATE_INTERPOLATION); - } elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, 0, $this->cursor) && \strlen($match[0]) > 0) { + } elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, 0, $this->cursor) && '' !== $match[0]) { $this->pushToken(/* Token::STRING_TYPE */ 7, stripcslashes($match[0])); $this->moveCursor($match[0]); } elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, 0, $this->cursor)) { diff --git a/src/Markup.php b/src/Markup.php index 1788acc4f73..231a29b4121 100644 --- a/src/Markup.php +++ b/src/Markup.php @@ -41,9 +41,6 @@ public function count() return mb_strlen($this->content, $this->charset); } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function jsonSerialize() { diff --git a/src/NodeVisitor/MacroAutoImportNodeVisitor.php b/src/NodeVisitor/MacroAutoImportNodeVisitor.php index af477e65356..d6a7781ba27 100644 --- a/src/NodeVisitor/MacroAutoImportNodeVisitor.php +++ b/src/NodeVisitor/MacroAutoImportNodeVisitor.php @@ -50,10 +50,10 @@ public function leaveNode(Node $node, Environment $env): Node } } elseif ($this->inAModule) { if ( - $node instanceof GetAttrExpression && - $node->getNode('node') instanceof NameExpression && - '_self' === $node->getNode('node')->getAttribute('name') && - $node->getNode('attribute') instanceof ConstantExpression + $node instanceof GetAttrExpression + && $node->getNode('node') instanceof NameExpression + && '_self' === $node->getNode('node')->getAttribute('name') + && $node->getNode('attribute') instanceof ConstantExpression ) { $this->hasMacroCalls = true; diff --git a/src/NodeVisitor/OptimizerNodeVisitor.php b/src/NodeVisitor/OptimizerNodeVisitor.php index 7ac75e41ad3..d9c23ff0ec0 100644 --- a/src/NodeVisitor/OptimizerNodeVisitor.php +++ b/src/NodeVisitor/OptimizerNodeVisitor.php @@ -99,8 +99,8 @@ private function optimizePrintNode(Node $node, Environment $env): Node $exprNode = $node->getNode('expr'); if ( - $exprNode instanceof BlockReferenceExpression || - $exprNode instanceof ParentExpression + $exprNode instanceof BlockReferenceExpression + || $exprNode instanceof ParentExpression ) { $exprNode->setAttribute('output', true); @@ -166,7 +166,7 @@ private function enterOptimizeFor(Node $node, Environment $env): void && 'include' === $node->getAttribute('name') && (!$node->getNode('arguments')->hasNode('with_context') || false !== $node->getNode('arguments')->getNode('with_context')->getAttribute('value') - ) + ) ) { $this->addLoopToAll(); } @@ -175,12 +175,12 @@ private function enterOptimizeFor(Node $node, Environment $env): void elseif ($node instanceof GetAttrExpression && (!$node->getNode('attribute') instanceof ConstantExpression || 'parent' === $node->getNode('attribute')->getAttribute('value') - ) + ) && (true === $this->loops[0]->getAttribute('with_loop') - || ($node->getNode('node') instanceof NameExpression - && 'loop' === $node->getNode('node')->getAttribute('name') - ) - ) + || ($node->getNode('node') instanceof NameExpression + && 'loop' === $node->getNode('node')->getAttribute('name') + ) + ) ) { $this->addLoopToAll(); } diff --git a/src/Parser.php b/src/Parser.php index 4428208fed3..5590086f120 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -303,8 +303,7 @@ private function filterBodyNodes(Node $node, bool $nested = false): ?Node // check that the body does not contain non-empty output nodes if ( ($node instanceof TextNode && !ctype_space($node->getAttribute('data'))) - || - (!$node instanceof TextNode && !$node instanceof BlockReferenceNode && $node instanceof NodeOutputInterface) + || (!$node instanceof TextNode && !$node instanceof BlockReferenceNode && $node instanceof NodeOutputInterface) ) { if (false !== strpos((string) $node, \chr(0xEF).\chr(0xBB).\chr(0xBF))) { $t = substr($node->getAttribute('data'), 3); diff --git a/src/Test/IntegrationTestCase.php b/src/Test/IntegrationTestCase.php index 307302bb624..0aa5c3a5658 100644 --- a/src/Test/IntegrationTestCase.php +++ b/src/Test/IntegrationTestCase.php @@ -84,6 +84,7 @@ public function testIntegration($file, $message, $condition, $templates, $except /** * @dataProvider getLegacyTests + * * @group legacy */ public function testLegacyIntegration($file, $message, $condition, $templates, $exception, $outputs, $deprecation = '') @@ -257,7 +258,7 @@ protected static function parseTemplates($test) $templates = []; preg_match_all('/--TEMPLATE(?:\((.*?)\))?--(.*?)(?=\-\-TEMPLATE|$)/s', $test, $matches, \PREG_SET_ORDER); foreach ($matches as $match) { - $templates[($match[1] ?: 'index.twig')] = $match[2]; + $templates[$match[1] ?: 'index.twig'] = $match[2]; } return $templates; diff --git a/src/Token.php b/src/Token.php index fd1a89d2adc..59279b8fe7c 100644 --- a/src/Token.php +++ b/src/Token.php @@ -68,9 +68,9 @@ public function test($type, $values = null): bool } return ($this->type === $type) && ( - null === $values || - (\is_array($values) && \in_array($this->value, $values)) || - $this->value == $values + null === $values + || (\is_array($values) && \in_array($this->value, $values)) + || $this->value == $values ); } diff --git a/src/TokenParser/FromTokenParser.php b/src/TokenParser/FromTokenParser.php index 35098c267b1..31b6cde4148 100644 --- a/src/TokenParser/FromTokenParser.php +++ b/src/TokenParser/FromTokenParser.php @@ -32,7 +32,7 @@ public function parse(Token $token): Node $stream->expect(/* Token::NAME_TYPE */ 5, 'import'); $targets = []; - do { + while (true) { $name = $stream->expect(/* Token::NAME_TYPE */ 5)->getValue(); $alias = $name; @@ -45,7 +45,7 @@ public function parse(Token $token): Node if (!$stream->nextIf(/* Token::PUNCTUATION_TYPE */ 9, ',')) { break; } - } while (true); + } $stream->expect(/* Token::BLOCK_END_TYPE */ 3); diff --git a/src/TokenParser/UseTokenParser.php b/src/TokenParser/UseTokenParser.php index d0a2de41a2e..3cdbb98ad01 100644 --- a/src/TokenParser/UseTokenParser.php +++ b/src/TokenParser/UseTokenParser.php @@ -43,7 +43,7 @@ public function parse(Token $token): Node $targets = []; if ($stream->nextIf('with')) { - do { + while (true) { $name = $stream->expect(/* Token::NAME_TYPE */ 5)->getValue(); $alias = $name; @@ -56,7 +56,7 @@ public function parse(Token $token): Node if (!$stream->nextIf(/* Token::PUNCTUATION_TYPE */ 9, ',')) { break; } - } while (true); + } } $stream->expect(/* Token::BLOCK_END_TYPE */ 3); diff --git a/src/Util/TemplateDirIterator.php b/src/Util/TemplateDirIterator.php index 3bef14beec3..8125341bd81 100644 --- a/src/Util/TemplateDirIterator.php +++ b/src/Util/TemplateDirIterator.php @@ -16,18 +16,12 @@ */ class TemplateDirIterator extends \IteratorIterator { - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function current() { return file_get_contents(parent::current()); } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function key() { diff --git a/tests/Extension/CoreTest.php b/tests/Extension/CoreTest.php index 29a799b8103..431517f6b21 100644 --- a/tests/Extension/CoreTest.php +++ b/tests/Extension/CoreTest.php @@ -380,9 +380,6 @@ public function rewind(): void $this->position = 0; } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function current() { @@ -393,9 +390,6 @@ public function current() throw new \LogicException('Code should only use the keys, not the values provided by iterator.'); } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function key() { diff --git a/tests/Extension/EscaperTest.php b/tests/Extension/EscaperTest.php index 9804feaa5c7..7c558c3ac1d 100644 --- a/tests/Extension/EscaperTest.php +++ b/tests/Extension/EscaperTest.php @@ -189,10 +189,10 @@ public function testJavascriptEscapingConvertsSpecialCharsWithInternalEncoding() try { mb_internal_encoding('ISO-8859-1'); foreach ($this->jsSpecialChars as $key => $value) { - $this->assertEquals($value, twig_escape_filter($twig, $key, 'js'), 'Failed to escape: ' . $key); + $this->assertEquals($value, twig_escape_filter($twig, $key, 'js'), 'Failed to escape: '.$key); } } finally { - if ($previousInternalEncoding !== false) { + if (false !== $previousInternalEncoding) { mb_internal_encoding($previousInternalEncoding); } } @@ -249,7 +249,7 @@ public function testUrlEscapingConvertsSpecialChars() public function testUnicodeCodepointConversionToUtf8() { $expected = ' ~ޙ'; - $codepoints = [0x20, 0x7e, 0x799]; + $codepoints = [0x20, 0x7E, 0x799]; $result = ''; foreach ($codepoints as $value) { $result .= $this->codepointToUtf8($value); @@ -270,19 +270,19 @@ protected function codepointToUtf8($codepoint) return \chr($codepoint); } if ($codepoint < 0x800) { - return \chr($codepoint >> 6 & 0x3f | 0xc0) - .\chr($codepoint & 0x3f | 0x80); + return \chr($codepoint >> 6 & 0x3F | 0xC0) + .\chr($codepoint & 0x3F | 0x80); } if ($codepoint < 0x10000) { - return \chr($codepoint >> 12 & 0x0f | 0xe0) - .\chr($codepoint >> 6 & 0x3f | 0x80) - .\chr($codepoint & 0x3f | 0x80); + return \chr($codepoint >> 12 & 0x0F | 0xE0) + .\chr($codepoint >> 6 & 0x3F | 0x80) + .\chr($codepoint & 0x3F | 0x80); } if ($codepoint < 0x110000) { - return \chr($codepoint >> 18 & 0x07 | 0xf0) - .\chr($codepoint >> 12 & 0x3f | 0x80) - .\chr($codepoint >> 6 & 0x3f | 0x80) - .\chr($codepoint & 0x3f | 0x80); + return \chr($codepoint >> 18 & 0x07 | 0xF0) + .\chr($codepoint >> 12 & 0x3F | 0x80) + .\chr($codepoint >> 6 & 0x3F | 0x80) + .\chr($codepoint & 0x3F | 0x80); } throw new \Exception('Codepoint requested outside of Unicode range.'); } diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index 893bda345e8..aa24d5fbe8f 100644 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -105,18 +105,12 @@ public function rewind(): void $this->position = 0; } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function current() { return $this->array[$this->position]; } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function key() { @@ -371,9 +365,6 @@ class SimpleIteratorForTesting implements \Iterator private $data = [1, 2, 3, 4, 5, 6, 7]; private $key = 0; - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function current() { @@ -385,9 +376,6 @@ public function next(): void ++$this->key; } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function key() { diff --git a/tests/Node/IncludeTest.php b/tests/Node/IncludeTest.php index ab1fdf0bfe0..92681662da7 100644 --- a/tests/Node/IncludeTest.php +++ b/tests/Node/IncludeTest.php @@ -47,11 +47,11 @@ public function getTests() ]; $expr = new ConditionalExpression( - new ConstantExpression(true, 1), - new ConstantExpression('foo', 1), - new ConstantExpression('foo', 1), - 0 - ); + new ConstantExpression(true, 1), + new ConstantExpression('foo', 1), + new ConstantExpression('foo', 1), + 0 + ); $node = new IncludeNode($expr, null, false, false, 1); $tests[] = [$node, <<createMock(LoaderInterface::class), ['debug' => true]); $node = new ModuleNode($body, $extends, $blocks, $macros, $traits, new Node([]), $source); diff --git a/tests/ParserTest.php b/tests/ParserTest.php index 65956cf7e74..cdd8e875743 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -168,7 +168,7 @@ public function testGetVarName() {{ foo }} {% endmacro %} EOF - , 'index'))); + , 'index'))); // The getVarName() must not depend on the template loaders, // If this test does not throw any exception, that's good. diff --git a/tests/Profiler/Dumper/AbstractTest.php b/tests/Profiler/Dumper/AbstractTest.php index 29e40d26cbc..1891c27507a 100644 --- a/tests/Profiler/Dumper/AbstractTest.php +++ b/tests/Profiler/Dumper/AbstractTest.php @@ -73,7 +73,6 @@ private function getMacroProfile(array $subProfiles = []) /** * @param string $name * @param float $duration - * @param bool $isTemplate * @param string $type * @param string $templateName * diff --git a/tests/Profiler/Dumper/BlackfireTest.php b/tests/Profiler/Dumper/BlackfireTest.php index b1c2cd7d1f0..3a33d94031b 100644 --- a/tests/Profiler/Dumper/BlackfireTest.php +++ b/tests/Profiler/Dumper/BlackfireTest.php @@ -31,6 +31,6 @@ public function testDump() embedded.twig==>included.twig//2 %d %d %d index.twig==>index.twig::macro(foo)//1 %d %d %d EOF - , $dumper->dump($this->getProfile())); + , $dumper->dump($this->getProfile())); } } diff --git a/tests/Profiler/Dumper/HtmlTest.php b/tests/Profiler/Dumper/HtmlTest.php index 20a1ab439c5..2dcbb9aec57 100644 --- a/tests/Profiler/Dumper/HtmlTest.php +++ b/tests/Profiler/Dumper/HtmlTest.php @@ -29,6 +29,6 @@ public function testDump() └ included.twig EOF - , $dumper->dump($this->getProfile())); + , $dumper->dump($this->getProfile())); } } diff --git a/tests/Profiler/Dumper/TextTest.php b/tests/Profiler/Dumper/TextTest.php index 8240e356bd2..ba19c2c90dc 100644 --- a/tests/Profiler/Dumper/TextTest.php +++ b/tests/Profiler/Dumper/TextTest.php @@ -29,6 +29,6 @@ public function testDump() └ included.twig EOF - , $dumper->dump($this->getProfile())); + , $dumper->dump($this->getProfile())); } } diff --git a/tests/TemplateTest.php b/tests/TemplateTest.php index bd26e9d95b7..9c2364c1d21 100644 --- a/tests/TemplateTest.php +++ b/tests/TemplateTest.php @@ -89,7 +89,7 @@ public function getAttributeExceptions() public function testGetAttributeWithSandbox($object, $item, $allowed) { $twig = new Environment($this->createMock(LoaderInterface::class)); - $policy = new SecurityPolicy([], [], [/*method*/], [/*prop*/], []); + $policy = new SecurityPolicy([], [], [/* method */], [/* prop */], []); $twig->addExtension(new SandboxExtension($policy, !$allowed)); $template = new TemplateForTest($twig); @@ -477,25 +477,22 @@ class TemplateArrayAccessObject implements \ArrayAccess '+4' => '+4', ]; - public function offsetExists($name) : bool + public function offsetExists($name): bool { return \array_key_exists($name, $this->attributes); } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function offsetGet($name) { return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : null; } - public function offsetSet($name, $value) : void + public function offsetSet($name, $value): void { } - public function offsetUnset($name) : void + public function offsetUnset($name): void { } } @@ -570,25 +567,22 @@ class TemplatePropertyObjectAndArrayAccess extends TemplatePropertyObject implem 'baf' => 'baf', ]; - public function offsetExists($offset) : bool + public function offsetExists($offset): bool { return \array_key_exists($offset, $this->data); } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->offsetExists($offset) ? $this->data[$offset] : 'n/a'; } - public function offsetSet($offset, $value) : void + public function offsetSet($offset, $value): void { } - public function offsetUnset($offset) : void + public function offsetUnset($offset): void { } } @@ -722,26 +716,23 @@ class TemplateArrayAccess implements \ArrayAccess ]; private $children = []; - public function offsetExists($offset) : bool + public function offsetExists($offset): bool { return \array_key_exists($offset, $this->children); } - /** - * @return mixed - */ #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->children[$offset]; } - public function offsetSet($offset, $value) : void + public function offsetSet($offset, $value): void { $this->children[$offset] = $value; } - public function offsetUnset($offset) : void + public function offsetUnset($offset): void { unset($this->children[$offset]); }