Compare commits

..
5 changed files with 612 additions and 594 deletions
-1
View File
@@ -1 +0,0 @@
- Fixed that using `count()` would trigger a deprecation notice. [#813](https://github.com/smarty-php/smarty/issues/813)
+6 -4
View File
@@ -785,9 +785,11 @@ 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 {
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);
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);
}
res = c.'::'.s[0].s[1];
}
} else {
@@ -1123,7 +1125,7 @@ static_class_access(res) ::= method(m) objectchain(oc). {
// static class constant
static_class_access(res) ::= ID(v). {
res = array(v, '');
res = array(v, '', 'constant');
}
// 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', 'count'])
&& !in_array($name, ['time', 'join', 'is_array', 'in_array'])
) {
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,7 +247,6 @@ class PhpFunctionTest extends PHPUnit_Smarty
$this->smarty->assign('f', 3.14);
$errorMessage = '';
$output = '';
try {
$output = $this->smarty->fetch('string:' . $strTemplateSource);
@@ -256,8 +255,9 @@ class PhpFunctionTest extends PHPUnit_Smarty
}
if ($shouldTriggerDeprecationNotice) {
$this->assertStringContainsString('Using unregistered function', $errorMessage);
$this->assertStringContainsString('Using unregistered ', $errorMessage);
} else {
$this->assertEquals('', $errorMessage);
$this->assertEquals($expected, $output);
$this->assertEquals('', $errorMessage);
}
@@ -283,7 +283,6 @@ 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],
@@ -297,6 +296,9 @@ class PhpFunctionTest extends PHPUnit_Smarty
['{$a|addslashes}', '', true],
['{$a|sha1}', '', true],
['{$a|get_parent_class}', '', true],
['{StaticMethodsTesterClass::giveMeEmptyString($a)}', '', true],
['{StaticMethodsTesterClass::EMPTY_STRING}', '', false],
];
}
@@ -328,3 +330,12 @@ class TestIsset {
return $v;
}
}
class StaticMethodsTesterClass {
const EMPTY_STRING = '';
public static function giveMeEmptyString($data) {
return '';
}
}