mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 12:26:30 +00:00
fixed CS
This commit is contained in:
@@ -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');
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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')),
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user