From 9bac13daf0a4d98c08ea42e87537d624460c77f4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Fri, 2 Mar 2018 13:12:59 -0800 Subject: [PATCH] fixed CS --- lib/Twig/Extension/Core.php | 4 ++-- lib/Twig/Node.php | 2 +- lib/Twig/Node/Expression/Call.php | 2 +- test/Twig/Tests/ErrorTest.php | 8 ++++---- test/Twig/Tests/Loader/ChainTest.php | 2 +- test/Twig/Tests/Loader/FilesystemTest.php | 4 ++-- test/Twig/Tests/Node/Expression/GetAttrTest.php | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index cdfa669c9..6eaad75a4 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -1052,7 +1052,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', * The following replaces characters undefined in HTML with the * hex entity for the Unicode replacement character. */ - if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") || ($ord >= 0x7f && $ord <= 0x9f)) { + if (($ord <= 0x1f && "\t" != $chr && "\n" != $chr && "\r" != $chr) || ($ord >= 0x7f && $ord <= 0x9f)) { return '�'; } @@ -1060,7 +1060,7 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', * Check if the current character to escape has a name entity we should * replace it with while grabbing the hex value of the character. */ - if (strlen($chr) == 1) { + if (1 == strlen($chr)) { $hex = strtoupper(substr('00'.bin2hex($chr), -2)); } else { $chr = twig_convert_encoding($chr, 'UTF-16BE', 'UTF-8'); diff --git a/lib/Twig/Node.php b/lib/Twig/Node.php index a8749cbda..8b62c2956 100644 --- a/lib/Twig/Node.php +++ b/lib/Twig/Node.php @@ -147,7 +147,7 @@ class Twig_Node implements Countable, IteratorAggregate return $this->nodes[$name]; } - public function setNode($name, Twig_Node $node) + public function setNode($name, self $node) { $this->nodes[$name] = $node; } diff --git a/lib/Twig/Node/Expression/Call.php b/lib/Twig/Node/Expression/Call.php index 3ba45e377..6bd53cc47 100644 --- a/lib/Twig/Node/Expression/Call.php +++ b/lib/Twig/Node/Expression/Call.php @@ -33,7 +33,7 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression if (!$compiler->getEnvironment()->hasExtension($class)) { throw new Twig_Error_Runtime(sprintf('The "%s" extension is not enabled.', $class)); } - + $compiler->raw(sprintf('$this->extensions[\'%s\']->%s', ltrim($class, '\\'), $callable[1])); } else { $closingParenthesis = true; diff --git a/test/Twig/Tests/ErrorTest.php b/test/Twig/Tests/ErrorTest.php index 7ba7a34be..c2beb0e50 100644 --- a/test/Twig/Tests/ErrorTest.php +++ b/test/Twig/Tests/ErrorTest.php @@ -86,7 +86,7 @@ EOHTML public function testTwigExceptionGuessWithMissingVarAndFilesystemLoader() { - $loader = new Twig_Loader_Filesystem(dirname(__FILE__).'/Fixtures/errors'); + $loader = new Twig_Loader_Filesystem(__DIR__.'/Fixtures/errors'); $twig = new Twig_Environment($loader, array('strict_variables' => true, 'debug' => true, 'cache' => false)); $template = $twig->loadTemplate('index.html'); @@ -99,13 +99,13 @@ EOHTML $this->assertEquals(3, $e->getTemplateLine()); $this->assertEquals('index.html', $e->getSourceContext()->getName()); $this->assertEquals(3, $e->getLine()); - $this->assertEquals(strtr(dirname(__FILE__).'/Fixtures/errors/index.html', '/', DIRECTORY_SEPARATOR), $e->getFile()); + $this->assertEquals(strtr(__DIR__.'/Fixtures/errors/index.html', '/', DIRECTORY_SEPARATOR), $e->getFile()); } } public function testTwigExceptionGuessWithExceptionAndFilesystemLoader() { - $loader = new Twig_Loader_Filesystem(dirname(__FILE__).'/Fixtures/errors'); + $loader = new Twig_Loader_Filesystem(__DIR__.'/Fixtures/errors'); $twig = new Twig_Environment($loader, array('strict_variables' => true, 'debug' => true, 'cache' => false)); $template = $twig->loadTemplate('index.html'); @@ -118,7 +118,7 @@ EOHTML $this->assertEquals(3, $e->getTemplateLine()); $this->assertEquals('index.html', $e->getSourceContext()->getName()); $this->assertEquals(3, $e->getLine()); - $this->assertEquals(strtr(dirname(__FILE__).'/Fixtures/errors/index.html', '/', DIRECTORY_SEPARATOR), $e->getFile()); + $this->assertEquals(strtr(__DIR__.'/Fixtures/errors/index.html', '/', DIRECTORY_SEPARATOR), $e->getFile()); } } diff --git a/test/Twig/Tests/Loader/ChainTest.php b/test/Twig/Tests/Loader/ChainTest.php index 44f01ae6d..d02f292b9 100644 --- a/test/Twig/Tests/Loader/ChainTest.php +++ b/test/Twig/Tests/Loader/ChainTest.php @@ -13,7 +13,7 @@ class Twig_Tests_Loader_ChainTest extends \PHPUnit\Framework\TestCase { public function testGetSourceContext() { - $path = dirname(__FILE__).'/../Fixtures'; + $path = __DIR__.'/../Fixtures'; $loader = new Twig_Loader_Chain(array( new Twig_Loader_Array(array('foo' => 'bar')), new Twig_Loader_Array(array('errors/index.html' => 'baz')), diff --git a/test/Twig/Tests/Loader/FilesystemTest.php b/test/Twig/Tests/Loader/FilesystemTest.php index 02c47a854..a55f6869d 100644 --- a/test/Twig/Tests/Loader/FilesystemTest.php +++ b/test/Twig/Tests/Loader/FilesystemTest.php @@ -13,7 +13,7 @@ class Twig_Tests_Loader_FilesystemTest extends \PHPUnit\Framework\TestCase { public function testGetSourceContext() { - $path = dirname(__FILE__).'/../Fixtures'; + $path = __DIR__.'/../Fixtures'; $loader = new Twig_Loader_Filesystem(array($path)); $this->assertEquals('errors/index.html', $loader->getSourceContext('errors/index.html')->getName()); $this->assertEquals(realpath($path.'/errors/index.html'), realpath($loader->getSourceContext('errors/index.html')->getPath())); @@ -217,7 +217,7 @@ class Twig_Tests_Loader_FilesystemTest extends \PHPUnit\Framework\TestCase // phar-sample.phar was created with the following script: // $f = new Phar('phar-test.phar'); // $f->addFromString('hello.twig', 'hello from phar'); - $loader->addPath('phar://'.dirname(__FILE__).'/Fixtures/phar/phar-sample.phar'); + $loader->addPath('phar://'.__DIR__.'/Fixtures/phar/phar-sample.phar'); $this->assertSame('hello from phar', $loader->getSourceContext('hello.twig')->getCode()); } } diff --git a/test/Twig/Tests/Node/Expression/GetAttrTest.php b/test/Twig/Tests/Node/Expression/GetAttrTest.php index 17e9b397f..a720d76fe 100644 --- a/test/Twig/Tests/Node/Expression/GetAttrTest.php +++ b/test/Twig/Tests/Node/Expression/GetAttrTest.php @@ -38,7 +38,7 @@ class Twig_Tests_Node_Expression_GetAttrTest extends Twig_Test_NodeTestCase $node = new Twig_Node_Expression_GetAttr($expr, $attr, $args, Twig_Template::ARRAY_CALL, 1); $tests[] = array($node, '(($__internal_%s = // line 1'."\n". - '($context["foo"] ?? null)) && is_array($__internal_%s) || $__internal_%s instanceof ArrayAccess ? ($__internal_%s["bar"] ?? null) : null)', null, true); + '($context["foo"] ?? null)) && is_array($__internal_%s) || $__internal_%s instanceof ArrayAccess ? ($__internal_%s["bar"] ?? null) : null)', null, true, ); $args = new Twig_Node_Expression_Array(array(), 1); $args->addElement(new Twig_Node_Expression_Name('foo', 1));