From 965275d04f7fcd7866c2705aa17d13ac10f80198 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Thu, 22 Sep 2022 23:55:25 +0200 Subject: [PATCH] whitespace --- libs/plugins/modifier.count.php | 22 +++---- libs/plugins/modifiercompiler.nl2br.php | 2 +- libs/plugins/modifiercompiler.round.php | 2 +- libs/plugins/modifiercompiler.str_repeat.php | 2 +- libs/plugins/modifiercompiler.strlen.php | 2 +- ...arty_internal_compile_private_modifier.php | 6 +- .../TagTests/Append/CompileAppendTest.php | 2 +- .../TagTests/Assign/CompileAssignTest.php | 2 +- .../TagTests/If/CompileIfTest.php | 2 +- .../PluginModifierCountTest.php | 56 +++++++++--------- .../PluginModifierExplodeTest.php | 2 +- .../PluginModifierNl2brTest.php | 32 +++++----- .../PluginModifierStrRepeatTest.php | 32 +++++----- .../ValueTests/Math/MathTest.php | 58 +++++++++---------- .../_Issues/327/ModifierIssue327Test.php | 2 +- 15 files changed, 112 insertions(+), 112 deletions(-) diff --git a/libs/plugins/modifier.count.php b/libs/plugins/modifier.count.php index 9333e8c9..ca35fc11 100644 --- a/libs/plugins/modifier.count.php +++ b/libs/plugins/modifier.count.php @@ -21,16 +21,16 @@ */ function smarty_modifier_count($arrayOrObject, $mode = 0) { - /* - * @see https://www.php.net/count - * > Prior to PHP 8.0.0, if the parameter was neither an array nor an object that implements the Countable interface, - * > 1 would be returned, unless value was null, in which case 0 would be returned. - */ + /* + * @see https://www.php.net/count + * > Prior to PHP 8.0.0, if the parameter was neither an array nor an object that implements the Countable interface, + * > 1 would be returned, unless value was null, in which case 0 would be returned. + */ - if ($arrayOrObject instanceof Countable || is_array($arrayOrObject)) { - return count($arrayOrObject, (int) $mode); - } elseif ($arrayOrObject === null) { - return 0; - } - return 1; + if ($arrayOrObject instanceof Countable || is_array($arrayOrObject)) { + return count($arrayOrObject, (int) $mode); + } elseif ($arrayOrObject === null) { + return 0; + } + return 1; } diff --git a/libs/plugins/modifiercompiler.nl2br.php b/libs/plugins/modifiercompiler.nl2br.php index cf56b102..308c00e4 100644 --- a/libs/plugins/modifiercompiler.nl2br.php +++ b/libs/plugins/modifiercompiler.nl2br.php @@ -19,5 +19,5 @@ * @return string with compiled code */ function smarty_modifiercompiler_nl2br($params) { - return 'nl2br((string) ' . $params[0] . ', (bool) ' . ($params[1] ?? true) . ')'; + return 'nl2br((string) ' . $params[0] . ', (bool) ' . ($params[1] ?? true) . ')'; } diff --git a/libs/plugins/modifiercompiler.round.php b/libs/plugins/modifiercompiler.round.php index 9aaadaa6..97f072f0 100644 --- a/libs/plugins/modifiercompiler.round.php +++ b/libs/plugins/modifiercompiler.round.php @@ -19,5 +19,5 @@ * @return string with compiled code */ function smarty_modifiercompiler_round($params) { - return 'round((float) ' . $params[0] . ', (int) ' . ($params[1] ?? 0) . ', (int) ' . ($params[2] ?? PHP_ROUND_HALF_UP) . ')'; + return 'round((float) ' . $params[0] . ', (int) ' . ($params[1] ?? 0) . ', (int) ' . ($params[2] ?? PHP_ROUND_HALF_UP) . ')'; } diff --git a/libs/plugins/modifiercompiler.str_repeat.php b/libs/plugins/modifiercompiler.str_repeat.php index c6889fc7..18eb7a76 100644 --- a/libs/plugins/modifiercompiler.str_repeat.php +++ b/libs/plugins/modifiercompiler.str_repeat.php @@ -19,5 +19,5 @@ * @return string with compiled code */ function smarty_modifiercompiler_str_repeat($params) { - return 'str_repeat((string) ' . $params[0] . ', (int) ' . $params[1] . ')'; + return 'str_repeat((string) ' . $params[0] . ', (int) ' . $params[1] . ')'; } diff --git a/libs/plugins/modifiercompiler.strlen.php b/libs/plugins/modifiercompiler.strlen.php index 79ea6d6a..d43e8ef1 100644 --- a/libs/plugins/modifiercompiler.strlen.php +++ b/libs/plugins/modifiercompiler.strlen.php @@ -19,5 +19,5 @@ * @return string with compiled code */ function smarty_modifiercompiler_strlen($params) { - return 'strlen((string) ' . $params[0] . ')'; + return 'strlen((string) ' . $params[0] . ')'; } diff --git a/libs/sysplugins/smarty_internal_compile_private_modifier.php b/libs/sysplugins/smarty_internal_compile_private_modifier.php index fb85ca09..aea082f0 100644 --- a/libs/sysplugins/smarty_internal_compile_private_modifier.php +++ b/libs/sysplugins/smarty_internal_compile_private_modifier.php @@ -109,9 +109,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler) ) { - trigger_error('Using php-function "' . $modifier . '" as a modifier is deprecated and will be ' . - 'removed in a future release. Use Smarty::registerPlugin to explicitly register ' . - 'a custom modifier.', E_USER_DEPRECATED); + trigger_error('Using php-function "' . $modifier . '" as a modifier is deprecated and will be ' . + 'removed in a future release. Use Smarty::registerPlugin to explicitly register ' . + 'a custom modifier.', E_USER_DEPRECATED); $output = "{$modifier}({$params})"; } $compiler->known_modifier_type[ $modifier ] = $type; diff --git a/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php index 268d0f2f..9fab4fae 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Append/CompileAppendTest.php @@ -21,7 +21,7 @@ class CompileAppendTest extends PHPUnit_Smarty $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); - $this->smarty->registerPlugin('modifier', 'var_export', 'var_export'); + $this->smarty->registerPlugin('modifier', 'var_export', 'var_export'); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php index ee212688..fb02564f 100644 --- a/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/Assign/CompileAssignTest.php @@ -21,7 +21,7 @@ class CompileAssignTest extends PHPUnit_Smarty $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); - $this->smarty->registerPlugin('modifier', 'var_export', 'var_export'); + $this->smarty->registerPlugin('modifier', 'var_export', 'var_export'); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php b/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php index b210610b..addd9999 100644 --- a/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/If/CompileIfTest.php @@ -21,7 +21,7 @@ class CompileIfTest extends PHPUnit_Smarty $this->smarty->addPluginsDir("../../../__shared/PHPunitplugins/"); $this->smarty->addTemplateDir("../../../__shared/templates/"); $this->smarty->addTemplateDir("./templates_tmp"); - $this->smarty->registerPlugin('modifier', 'var_export', 'var_export'); + $this->smarty->registerPlugin('modifier', 'var_export', 'var_export'); } public function testInit() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountTest.php index 0cb31cd7..c736356e 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountTest.php @@ -12,37 +12,37 @@ */ class PluginModifierCountTest extends PHPUnit_Smarty { - public function setUp(): void - { - $this->setUpSmarty(dirname(__FILE__)); - } + public function setUp(): void + { + $this->setUpSmarty(dirname(__FILE__)); + } - public function testArray() - { - $tpl = $this->smarty->createTemplate('string:count:{$v|count}'); - $tpl->assign("v", array(1, 2, 3)); - $this->assertEquals("count:3", $this->smarty->fetch($tpl)); - } + public function testArray() + { + $tpl = $this->smarty->createTemplate('string:count:{$v|count}'); + $tpl->assign("v", array(1, 2, 3)); + $this->assertEquals("count:3", $this->smarty->fetch($tpl)); + } - public function testEmptyArray() - { - $tpl = $this->smarty->createTemplate('string:count:{$v|count}'); - $tpl->assign("v", array()); - $this->assertEquals("count:0", $this->smarty->fetch($tpl)); - } + public function testEmptyArray() + { + $tpl = $this->smarty->createTemplate('string:count:{$v|count}'); + $tpl->assign("v", array()); + $this->assertEquals("count:0", $this->smarty->fetch($tpl)); + } - public function testNull() - { - $tpl = $this->smarty->createTemplate('string:count:{$v|count}'); - $tpl->assign("v", null); - $this->assertEquals("count:0", $this->smarty->fetch($tpl)); - } + public function testNull() + { + $tpl = $this->smarty->createTemplate('string:count:{$v|count}'); + $tpl->assign("v", null); + $this->assertEquals("count:0", $this->smarty->fetch($tpl)); + } - public function testString() - { - $tpl = $this->smarty->createTemplate('string:count:{$v|count}'); - $tpl->assign("v", "string"); - $this->assertEquals("count:1", $this->smarty->fetch($tpl)); - } + public function testString() + { + $tpl = $this->smarty->createTemplate('string:count:{$v|count}'); + $tpl->assign("v", "string"); + $this->assertEquals("count:1", $this->smarty->fetch($tpl)); + } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierExplodeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierExplodeTest.php index d6c754c1..5cd13dd3 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierExplodeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierExplodeTest.php @@ -14,7 +14,7 @@ class PluginModifierExplodeTest extends \PHPUnit_Smarty public function setUp(): void { $this->setUpSmarty(__DIR__); - $this->smarty->registerPlugin('modifier', 'json_encode', 'json_encode'); + $this->smarty->registerPlugin('modifier', 'json_encode', 'json_encode'); } /** diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNl2brTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNl2brTest.php index 70e106bd..ed263019 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNl2brTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierNl2brTest.php @@ -12,22 +12,22 @@ */ class PluginModifierNl2brTest extends PHPUnit_Smarty { - public function setUp(): void - { - $this->setUpSmarty(dirname(__FILE__)); - } + public function setUp(): void + { + $this->setUpSmarty(dirname(__FILE__)); + } - public function testDefault() - { - $tpl = $this->smarty->createTemplate('string:{$v|nl2br}'); - $tpl->assign("v", "Line1\nLine2"); - $this->assertEquals("Line1
\nLine2", $this->smarty->fetch($tpl)); - } + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{$v|nl2br}'); + $tpl->assign("v", "Line1\nLine2"); + $this->assertEquals("Line1
\nLine2", $this->smarty->fetch($tpl)); + } - public function testNoXHTML() - { - $tpl = $this->smarty->createTemplate('string:{$v|nl2br:false}'); - $tpl->assign("v", "Line1\nLine2"); - $this->assertEquals("Line1
\nLine2", $this->smarty->fetch($tpl)); - } + public function testNoXHTML() + { + $tpl = $this->smarty->createTemplate('string:{$v|nl2br:false}'); + $tpl->assign("v", "Line1\nLine2"); + $this->assertEquals("Line1
\nLine2", $this->smarty->fetch($tpl)); + } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStrRepeatTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStrRepeatTest.php index 9f2805a2..ef5bcfde 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStrRepeatTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierStrRepeatTest.php @@ -12,22 +12,22 @@ */ class PluginModifierStrRepeatTest extends PHPUnit_Smarty { - public function setUp(): void - { - $this->setUpSmarty(dirname(__FILE__)); - } + public function setUp(): void + { + $this->setUpSmarty(dirname(__FILE__)); + } - public function testDefault() - { - $tpl = $this->smarty->createTemplate('string:{$v|str_repeat:2}'); - $tpl->assign("v", "foo"); - $this->assertEquals("foofoo", $this->smarty->fetch($tpl)); - } + public function testDefault() + { + $tpl = $this->smarty->createTemplate('string:{$v|str_repeat:2}'); + $tpl->assign("v", "foo"); + $this->assertEquals("foofoo", $this->smarty->fetch($tpl)); + } - public function testZeroTimes() - { - $tpl = $this->smarty->createTemplate('string:{$v|str_repeat:0}'); - $tpl->assign("v", "foo"); - $this->assertEquals("", $this->smarty->fetch($tpl)); - } + public function testZeroTimes() + { + $tpl = $this->smarty->createTemplate('string:{$v|str_repeat:0}'); + $tpl->assign("v", "foo"); + $this->assertEquals("", $this->smarty->fetch($tpl)); + } } diff --git a/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php b/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php index ccc403f3..b29d5beb 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/Math/MathTest.php @@ -18,7 +18,7 @@ class MathTest extends PHPUnit_Smarty public function setUp(): void { $this->setUpSmarty(dirname(__FILE__)); - $this->smarty->registerPlugin('modifier', 'sin', 'sin'); + $this->smarty->registerPlugin('modifier', 'sin', 'sin'); } public function testInit() @@ -133,36 +133,36 @@ class MathTest extends PHPUnit_Smarty $this->assertEquals($expected, $this->smarty->fetch($tpl)); } - public function testBackticksIllegal() - { - $this->expectException(PHPUnit\Framework\Error\Warning::class); - $expected = "22.00"; - $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="`ls` x * y" x=$x y=$y}'); - $this->assertEquals($expected, $this->smarty->fetch($tpl)); - } + public function testBackticksIllegal() + { + $this->expectException(PHPUnit\Framework\Error\Warning::class); + $expected = "22.00"; + $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="`ls` x * y" x=$x y=$y}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } - public function testDollarSignsIllegal() - { - $this->expectException(PHPUnit\Framework\Error\Warning::class); - $expected = "22.00"; - $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="$" x=$x y=$y}'); - $this->assertEquals($expected, $this->smarty->fetch($tpl)); - } + public function testDollarSignsIllegal() + { + $this->expectException(PHPUnit\Framework\Error\Warning::class); + $expected = "22.00"; + $tpl = $this->smarty->createTemplate('eval:{$x = "4"}{$y = "5.5"}{math equation="$" x=$x y=$y}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } - public function testBracketsIllegal() - { - $this->expectException(PHPUnit\Framework\Error\Warning::class); - $expected = "I"; - $tpl = $this->smarty->createTemplate('eval:{$x = "0"}{$y = "1"}{math equation="((y/x).(x))[x]" x=$x y=$y}'); - $this->assertEquals($expected, $this->smarty->fetch($tpl)); - } + public function testBracketsIllegal() + { + $this->expectException(PHPUnit\Framework\Error\Warning::class); + $expected = "I"; + $tpl = $this->smarty->createTemplate('eval:{$x = "0"}{$y = "1"}{math equation="((y/x).(x))[x]" x=$x y=$y}'); + $this->assertEquals($expected, $this->smarty->fetch($tpl)); + } - public function testRand() - { - $tpl = $this->smarty->createTemplate('eval:{$x = "0"}{math equation="x * rand()" x=$x}'); - // this assertion may seem silly, but it serves to prove that using rand() without a parameter - // will not trigger a security error (see https://github.com/smarty-php/smarty/issues/794) - $this->assertEquals("0", $this->smarty->fetch($tpl)); - } + public function testRand() + { + $tpl = $this->smarty->createTemplate('eval:{$x = "0"}{math equation="x * rand()" x=$x}'); + // this assertion may seem silly, but it serves to prove that using rand() without a parameter + // will not trigger a security error (see https://github.com/smarty-php/smarty/issues/794) + $this->assertEquals("0", $this->smarty->fetch($tpl)); + } } diff --git a/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php b/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php index 86c0a473..0634907b 100644 --- a/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php +++ b/tests/UnitTests/TemplateSource/_Issues/327/ModifierIssue327Test.php @@ -18,7 +18,7 @@ class ModifierIssue327Test extends PHPUnit_Smarty public function setUp(): void { $this->setUpSmarty(dirname(__FILE__)); - $this->smarty->registerPlugin('modifier', 'substr', 'substr'); + $this->smarty->registerPlugin('modifier', 'substr', 'substr'); } public function testInit()