Compare commits

..
5 changed files with 592 additions and 610 deletions
+1
View File
@@ -0,0 +1 @@
- Fixed that using `count()` would trigger a deprecation notice. [#813](https://github.com/smarty-php/smarty/issues/813)
+4 -6
View File
@@ -785,11 +785,9 @@ value(res) ::= ns1(c)DOUBLECOLON static_class_access(s). {
if (isset($this->smarty->registered_classes[c])) {
res = $this->smarty->registered_classes[c].'::'.s[0].s[1];
} else {
if (s[2] === 'method') {
trigger_error('Using unregistered static method "' . c.'::'.s[0] . '" in a template is deprecated and will be ' .
'removed in a future release. Use Smarty::registerClass to explicitly register ' .
'a class for access.', E_USER_DEPRECATED);
}
trigger_error('Using unregistered static method "' . c.'::'.s[0] . '" in a template is deprecated and will be ' .
'removed in a future release. Use Smarty::registerClass to explicitly register ' .
'a class for access.', E_USER_DEPRECATED);
res = c.'::'.s[0].s[1];
}
} else {
@@ -1125,7 +1123,7 @@ static_class_access(res) ::= method(m) objectchain(oc). {
// static class constant
static_class_access(res) ::= ID(v). {
res = array(v, '', 'constant');
res = array(v, '');
}
// static class variables
@@ -658,7 +658,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (
!$this->smarty->loadPlugin('smarty_modifiercompiler_' . $name)
&& !isset($this->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][$name])
&& !in_array($name, ['time', 'join', 'is_array', 'in_array'])
&& !in_array($name, ['time', 'join', 'is_array', 'in_array', 'count'])
) {
trigger_error('Using unregistered function "' . $name . '" in a template is deprecated and will be ' .
'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
File diff suppressed because it is too large Load Diff
@@ -247,6 +247,7 @@ class PhpFunctionTest extends PHPUnit_Smarty
$this->smarty->assign('f', 3.14);
$errorMessage = '';
$output = '';
try {
$output = $this->smarty->fetch('string:' . $strTemplateSource);
@@ -255,9 +256,8 @@ class PhpFunctionTest extends PHPUnit_Smarty
}
if ($shouldTriggerDeprecationNotice) {
$this->assertStringContainsString('Using unregistered ', $errorMessage);
$this->assertStringContainsString('Using unregistered function', $errorMessage);
} else {
$this->assertEquals('', $errorMessage);
$this->assertEquals($expected, $output);
$this->assertEquals('', $errorMessage);
}
@@ -283,6 +283,7 @@ class PhpFunctionTest extends PHPUnit_Smarty
['{$a|substr:-1}', 'a', false],
['{$f|substr:-1}', '4', false],
['{$ar|count}', '2', false],
['{count($ar)}', '2', false],
['{foreach "."|explode:$f as $n}{$n}{/foreach}', '314', false],
['{"-"|implode:$ar}', '1-2', false],
['{"-"|join:$ar}', '1-2', false],
@@ -296,9 +297,6 @@ class PhpFunctionTest extends PHPUnit_Smarty
['{$a|addslashes}', '', true],
['{$a|sha1}', '', true],
['{$a|get_parent_class}', '', true],
['{StaticMethodsTesterClass::giveMeEmptyString($a)}', '', true],
['{StaticMethodsTesterClass::EMPTY_STRING}', '', false],
];
}
@@ -330,12 +328,3 @@ class TestIsset {
return $v;
}
}
class StaticMethodsTesterClass {
const EMPTY_STRING = '';
public static function giveMeEmptyString($data) {
return '';
}
}