From 0fc2b3726b4d17897324e6785db5bb4fb2d6ff3f Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Thu, 22 Dec 2022 21:23:22 +0100 Subject: [PATCH] src/Template/* to PSR-4 --- demo/plugins/resource.extendsall.php | 9 +- .../plugins/plugins-block-functions.md | 2 +- docs/programmers/plugins/plugins-resources.md | 6 +- plugins/block.textformat.php | 7 +- plugins/function.counter.php | 13 +- plugins/function.cycle.php | 5 +- plugins/function.fetch.php | 5 +- plugins/function.html_checkboxes.php | 7 +- plugins/function.html_image.php | 7 +- plugins/function.html_options.php | 7 +- plugins/function.html_radios.php | 7 +- plugins/function.html_select_date.php | 7 +- plugins/function.html_select_time.php | 17 +- plugins/function.math.php | 5 +- plugins/variablefilter.htmlspecialchars.php | 7 +- src/Block.php | 4 +- src/Cacheresource/Base.php | 52 +- src/Cacheresource/Custom.php | 28 +- src/Cacheresource/File.php | 44 +- src/Cacheresource/KeyValueStore.php | 44 +- src/Compile/ExtendsTag.php | 5 +- src/Compile/ForeachClose.php | 5 +- src/Compile/IncludeTag.php | 15 +- src/Compiler/CodeFrame.php | 38 +- src/Compiler/ConfigFile.php | 12 +- src/Compiler/Template.php | 10 +- src/Data.php | 10 +- src/Debug.php | 54 +- src/Resource/BasePlugin.php | 32 +- src/Resource/CustomPlugin.php | 20 +- src/Resource/ExtendsPlugin.php | 26 +- src/Resource/FilePlugin.php | 30 +- src/Resource/PhpPlugin.php | 24 +- src/Resource/RecompiledPlugin.php | 14 +- src/Resource/StreamPlugin.php | 14 +- src/Resource/StringEval.php | 18 +- src/Resource/StringPlugin.php | 20 +- src/Resource/UncompiledPlugin.php | 12 +- src/Runtime/CaptureRuntime.php | 30 +- src/Runtime/ForeachRuntime.php | 22 +- src/Runtime/InheritanceRuntime.php | 40 +- src/Runtime/MakeNocacheRuntime.php | 10 +- src/Runtime/TplFunctionRuntime.php | 28 +- src/Smarty.php | 50 +- src/Template.php | 910 +++++++++++++++++ src/Template/Cached.php | 379 +++++++ src/Template/Compiled.php | 253 +++++ src/Template/Config.php | 97 ++ src/Template/ResourceBase.php | 154 +++ src/Template/Source.php | 253 +++++ src/Template/smarty_template_cached.php | 387 -------- src/Template/smarty_template_compiled.php | 257 ----- src/Template/smarty_template_config.php | 100 -- .../smarty_template_resource_base.php | 152 --- src/Template/smarty_template_source.php | 251 ----- src/TemplateBase.php | 894 +++++++++++++++++ src/bootstrap.php | 16 - src/smarty_internal_template.php | 930 ------------------ src/smarty_internal_templatebase.php | 927 ----------------- src/sysplugins/smarty_data.php | 4 +- src/sysplugins/smarty_security.php | 6 +- tests/PHPUnit_Smarty.php | 23 +- .../_shared/CacheResourceTestCommon.php | 4 +- .../PHPunitplugins/cacheresource.apctest.php | 7 +- .../PHPunitplugins/cacheresource.filetest.php | 2 +- .../cacheresource.memcachetest.php | 7 +- .../cacheresource.mysqltest.php | 4 +- .../cacheresource.pdo_gziptest.php | 4 +- .../PHPunitplugins/cacheresource.pdotest.php | 4 +- .../PHPunitplugins/resource.filetest.php | 8 +- .../file/PHPunitplugins/resource.db4.php | 7 +- .../PHPunitplugins/resource.ambiguous.php | 8 +- .../Extends/ExtendsResourceTest.php | 4 +- .../PHPunitplugins/resource.db.php | 6 +- .../PHPunitplugins/resource.db2.php | 6 +- .../PHPunitplugins/resource.db3.php | 9 +- .../PHPunitplugins/resource.db4.php | 7 +- .../PHPunitplugins/block.testparameter.php | 7 +- .../BockExtend/CompileBlockExtendsTest.php | 6 +- .../function.checkconfigvar.php | 4 +- .../PHPunitplugins/function.checkvar.php | 4 +- .../PHPunitplugins/function.getparams.php | 4 +- .../PHPunitplugins/function.getvar.php | 4 +- 83 files changed, 3473 insertions(+), 3458 deletions(-) create mode 100644 src/Template.php create mode 100644 src/Template/Cached.php create mode 100644 src/Template/Compiled.php create mode 100644 src/Template/Config.php create mode 100644 src/Template/ResourceBase.php create mode 100644 src/Template/Source.php delete mode 100644 src/Template/smarty_template_cached.php delete mode 100644 src/Template/smarty_template_compiled.php delete mode 100644 src/Template/smarty_template_config.php delete mode 100644 src/Template/smarty_template_resource_base.php delete mode 100644 src/Template/smarty_template_source.php create mode 100644 src/TemplateBase.php delete mode 100644 src/bootstrap.php delete mode 100644 src/smarty_internal_template.php delete mode 100644 src/smarty_internal_templatebase.php diff --git a/demo/plugins/resource.extendsall.php b/demo/plugins/resource.extendsall.php index b6e46393..6441b47a 100644 --- a/demo/plugins/resource.extendsall.php +++ b/demo/plugins/resource.extendsall.php @@ -1,5 +1,8 @@ smarty->getTemplateVars()`. These Resources simply echo their rendered content to the output stream. The rendered output will be output-cached if the Smarty instance was configured accordingly. See -`libs/sysplugins/smarty_internal_resource_php.php` for an example. +`src/Resource/PhpPlugin.php` for an example. If the Resource\'s compiled templates should not be cached on disk, the Custom Resource may extend `Smarty_Resource_Recompiled`. These Resources are compiled every time they are accessed. This may be an expensive -overhead. See `libs/sysplugins/smarty_internal_resource_eval.php` for an +overhead. See `src/Resource/StringEval.php` for an example. diff --git a/plugins/block.textformat.php b/plugins/block.textformat.php index 290e5795..3935a4a1 100644 --- a/plugins/block.textformat.php +++ b/plugins/block.textformat.php @@ -5,6 +5,9 @@ * @package Smarty * @subpackage PluginsBlock */ + +use Smarty\Template; + /** * Smarty {textformat}{/textformat} block plugin * Type: block function @@ -25,14 +28,14 @@ * * @param array $params parameters * @param string $content contents of the block - * @param Smarty_Internal_Template $template template object + * @param Template $template template object * @param boolean &$repeat repeat flag * * @return string content re-formatted * @author Monte Ohrt * @throws \SmartyException */ -function smarty_block_textformat($params, $content, Smarty_Internal_Template $template, &$repeat) +function smarty_block_textformat($params, $content, Template $template, &$repeat) { if (is_null($content)) { return; diff --git a/plugins/function.counter.php b/plugins/function.counter.php index 54795459..7884d4c1 100644 --- a/plugins/function.counter.php +++ b/plugins/function.counter.php @@ -5,20 +5,23 @@ * @package Smarty * @subpackage PluginsFunction */ + +use Smarty\Template; + /** * Smarty {counter} function plugin * Type: function * Name: counter * Purpose: print out a counter value * - * @author Monte Ohrt - * @link https://www.smarty.net/manual/en/language.function.counter.php {counter} - * (Smarty online manual) - * * @param array $params parameters - * @param Smarty_Internal_Template $template template object + * @param Template $template template object * * @return string|null + *@link https://www.smarty.net/manual/en/language.function.counter.php {counter} + * (Smarty online manual) + * + * @author Monte Ohrt */ function smarty_function_counter($params, $template) { diff --git a/plugins/function.cycle.php b/plugins/function.cycle.php index 79356999..c45c18f3 100644 --- a/plugins/function.cycle.php +++ b/plugins/function.cycle.php @@ -5,6 +5,9 @@ * @package Smarty * @subpackage PluginsFunction */ + +use Smarty\Template; + /** * Smarty {cycle} function plugin * Type: function @@ -37,7 +40,7 @@ * @version 1.3 * * @param array $params parameters - * @param Smarty_Internal_Template $template template object + * @param Template $template template object * * @return string|null */ diff --git a/plugins/function.fetch.php b/plugins/function.fetch.php index d6b777e0..745846f9 100644 --- a/plugins/function.fetch.php +++ b/plugins/function.fetch.php @@ -5,6 +5,9 @@ * @package Smarty * @subpackage PluginsFunction */ + +use Smarty\Template; + /** * Smarty {fetch} plugin * Type: function @@ -16,7 +19,7 @@ * @author Monte Ohrt * * @param array $params parameters - * @param Smarty_Internal_Template $template template object + * @param Template $template template object * * @throws SmartyException * @return string|null if the assign parameter is passed, Smarty assigns the result to a template variable diff --git a/plugins/function.html_checkboxes.php b/plugins/function.html_checkboxes.php index e41de2de..81a44dd3 100644 --- a/plugins/function.html_checkboxes.php +++ b/plugins/function.html_checkboxes.php @@ -5,6 +5,9 @@ * @package Smarty * @subpackage PluginsFunction */ + +use Smarty\Template; + /** * Smarty {html_checkboxes} function plugin * File: function.html_checkboxes.php @@ -36,13 +39,13 @@ * @version 1.0 * * @param array $params parameters - * @param Smarty_Internal_Template $template template object + * @param Template $template template object * * @return string * @uses smarty_function_escape_special_chars() * @throws \SmartyException */ -function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template) +function smarty_function_html_checkboxes($params, Template $template) { $name = 'checkbox'; $values = null; diff --git a/plugins/function.html_image.php b/plugins/function.html_image.php index ad39a8b1..055d6e61 100644 --- a/plugins/function.html_image.php +++ b/plugins/function.html_image.php @@ -5,6 +5,9 @@ * @package Smarty * @subpackage PluginsFunction */ + +use Smarty\Template; + /** * Smarty {html_image} function plugin * Type: function @@ -28,13 +31,13 @@ * @version 1.0 * * @param array $params parameters - * @param Smarty_Internal_Template $template template object + * @param Template $template template object * * @throws SmartyException * @return string * @uses smarty_function_escape_special_chars() */ -function smarty_function_html_image($params, Smarty_Internal_Template $template) +function smarty_function_html_image($params, Template $template) { $alt = ''; $file = ''; diff --git a/plugins/function.html_options.php b/plugins/function.html_options.php index 905e35a2..73afdd80 100644 --- a/plugins/function.html_options.php +++ b/plugins/function.html_options.php @@ -5,6 +5,9 @@ * @package Smarty * @subpackage PluginsFunction */ + +use Smarty\Template; + /** * Smarty {html_options} function plugin * Type: function @@ -28,13 +31,13 @@ * * @param array $params parameters * - * @param \Smarty_Internal_Template $template + * @param \Smarty\Template $template * * @return string * @uses smarty_function_escape_special_chars() * @throws \SmartyException */ -function smarty_function_html_options($params, Smarty_Internal_Template $template) +function smarty_function_html_options($params, Template $template) { $name = null; $values = null; diff --git a/plugins/function.html_radios.php b/plugins/function.html_radios.php index 96aa8ef6..ec1453a9 100644 --- a/plugins/function.html_radios.php +++ b/plugins/function.html_radios.php @@ -5,6 +5,9 @@ * @package Smarty * @subpackage PluginsFunction */ + +use Smarty\Template; + /** * Smarty {html_radios} function plugin * File: function.html_radios.php @@ -36,13 +39,13 @@ * @version 1.0 * * @param array $params parameters - * @param Smarty_Internal_Template $template template object + * @param Template $template template object * * @return string * @uses smarty_function_escape_special_chars() * @throws \SmartyException */ -function smarty_function_html_radios($params, Smarty_Internal_Template $template) +function smarty_function_html_radios($params, Template $template) { $name = 'radio'; $values = null; diff --git a/plugins/function.html_select_date.php b/plugins/function.html_select_date.php index b84a547e..77483abe 100644 --- a/plugins/function.html_select_date.php +++ b/plugins/function.html_select_date.php @@ -5,6 +5,9 @@ * @package Smarty * @subpackage PluginsFunction */ + +use Smarty\Template; + /** * Smarty {html_select_date} plugin * Type: function @@ -37,12 +40,12 @@ * * @param array $params parameters * - * @param \Smarty_Internal_Template $template + * @param \Smarty\Template $template * * @return string * @throws \SmartyException */ -function smarty_function_html_select_date($params, Smarty_Internal_Template $template) +function smarty_function_html_select_date($params, Template $template) { // generate timestamps used for month names only static $_month_timestamps = null; diff --git a/plugins/function.html_select_time.php b/plugins/function.html_select_time.php index 9f15d7da..30c25b21 100644 --- a/plugins/function.html_select_time.php +++ b/plugins/function.html_select_time.php @@ -5,6 +5,9 @@ * @package Smarty * @subpackage PluginsFunction */ + +use Smarty\Template; + /** * Smarty {html_select_time} function plugin * Type: function @@ -18,13 +21,13 @@ * * @param array $params parameters * - * @param \Smarty_Internal_Template $template + * @param \Smarty\Template $template * * @return string * @uses smarty_make_timestamp() * @throws \SmartyException */ -function smarty_function_html_select_time($params, Smarty_Internal_Template $template) +function smarty_function_html_select_time($params, Template $template) { $prefix = 'Time_'; $field_array = null; @@ -139,7 +142,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem isset($params[ 'time' ][ $prefix . 'Meridian' ]) ? (' ' . $params[ 'time' ][ $prefix . 'Meridian' ]) : ''; $time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian); - list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); + [$_hour, $_minute, $_second] = $time = explode('-', date('H-i-s', $time)); } elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Hour' ])) { // $_REQUEST given foreach (array( @@ -154,19 +157,19 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem $_meridian = isset($params[ 'time' ][ $field_array ][ $prefix . 'Meridian' ]) ? (' ' . $params[ 'time' ][ $field_array ][ $prefix . 'Meridian' ]) : ''; $time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian); - list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); + [$_hour, $_minute, $_second] = $time = explode('-', date('H-i-s', $time)); } else { // no date found, use NOW - list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); + [$_year, $_month, $_day] = $time = explode('-', date('Y-m-d')); } } elseif ($time === null) { if (array_key_exists('time', $params)) { $_hour = $_minute = $_second = $time = null; } else { - list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s')); + [$_hour, $_minute, $_second] = $time = explode('-', date('H-i-s')); } } else { - list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); + [$_hour, $_minute, $_second] = $time = explode('-', date('H-i-s', $time)); } // generate hour