Fix comments and indentation (#637)

* Fix indentation

* Replace url of smarty.net from http to https

* Fix breaking links

Replace from http://smarty.php.net to https://www.smarty.net

* Replace link from http to https

* Fix CHANGELOG.md
This commit is contained in:
T. Nishino
2021-08-19 05:41:34 +09:00
committed by GitHub
parent 1a052b6a77
commit c5cc763802
99 changed files with 405 additions and 406 deletions

View File

@@ -32,7 +32,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [3.1.37] - 2021-01-07
### Changed
- Dropped support for PHP versions lower than PHP7.1 (and disabled unit tests for 7.1)
- Changed error handlers and handling of undefined constants for php8-compatibility (set $errcontext argument optional) https://github.com/smarty-php/smarty/issues/605
- Changed expected error levels in unit tests for php8-compatibility
- Travis unit tests now run for all php versions >= 5.3, including php8
@@ -337,7 +336,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
20.09.2016
- bugfix some $smarty special template variables are no longer accessed as real variable.
using them on calls like {if isset($smarty.foo)} or {if empty($smarty.foo)} will fail
http://www.smarty.net/forums/viewtopic.php?t=26222
https://www.smarty.net/forums/viewtopic.php?t=26222
- temporary fix for https://github.com/smarty-php/smarty/issues/293 main reason still under investigation
- improvement new tags {block_parent} {block_child} in template inheritance
@@ -349,7 +348,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- bugfix assigning a variable in if condition by function like {if $value = array_shift($array)} the function got called twice https://github.com/smarty-php/smarty/issues/291
- bugfix function plugins called with assign attribute like {foo assign='bar'} did not output returned content because
because assumption was made that it was assigned to a variable https://github.com/smarty-php/smarty/issues/292
- bugfix calling $smarty->isCached() on a not existing cache file with $smarty->cache_locking = true; could cause a 10 second delay http://www.smarty.net/forums/viewtopic.php?t=26282
- bugfix calling $smarty->isCached() on a not existing cache file with $smarty->cache_locking = true; could cause a 10 second delay https://www.smarty.net/forums/viewtopic.php?t=26282
- improvement make Smarty::clearCompiledTemplate() on custom resource independent from changes of templateId computation
11.09.2016

2
README
View File

@@ -51,7 +51,7 @@ $smarty->unregisterFilter(...)
Please refer to the online documentation for all specific changes:
http://www.smarty.net/documentation
https://www.smarty.net/documentation
----

View File

@@ -5,7 +5,7 @@
"keywords": [
"templating"
],
"homepage": "http://www.smarty.net",
"homepage": "https://www.smarty.net",
"license": "LGPL-3.0",
"authors": [
{
@@ -27,7 +27,7 @@
],
"support": {
"issues": "https://github.com/smarty-php/smarty/issues",
"forum": "http://www.smarty.net/forums/"
"forum": "https://www.smarty.net/forums/"
},
"require": {
"php": "^7.1 || ^8.0"

View File

@@ -20,7 +20,7 @@
* Smarty mailing list. Send a blank e-mail to
* smarty-discussion-subscribe@googlegroups.com
*
* @link http://www.smarty.net/
* @link https://www.smarty.net/
* @copyright 2018 New Digital Group, Inc.
* @copyright 2018 Uwe Tews
* @author Monte Ohrt <monte at ohrt dot com>

View File

@@ -20,7 +20,7 @@
* - indent_char - string (" ")
* - wrap_boundary - boolean (true)
*
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
* @link https://www.smarty.net/manual/en/language.function.textformat.php {textformat}
* (Smarty online manual)
*
* @param array $params parameters

View File

@@ -12,7 +12,7 @@
* Purpose: print out a counter value
*
* @author Monte Ohrt <monte at ohrt dot com>
* @link http://www.smarty.net/manual/en/language.function.counter.php {counter}
* @link https://www.smarty.net/manual/en/language.function.counter.php {counter}
* (Smarty online manual)
*
* @param array $params parameters

View File

@@ -28,7 +28,7 @@
* {cycle name=row values="one,two,three" reset=true}
* {cycle name=row}
*
* @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
* @link https://www.smarty.net/manual/en/language.function.cycle.php {cycle}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author credit to Mark Priatel <mpriatel@rogers.com>

View File

@@ -11,7 +11,7 @@
* Name: fetch
* Purpose: fetch file, web or ftp data and display results
*
* @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch}
* @link https://www.smarty.net/manual/en/language.function.fetch.php {fetch}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*

View File

@@ -29,7 +29,7 @@
* - assign (optional) - assign the output as an array to this variable
* - escape (optional) - escape the content (not value), defaults to true
*
* @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
* @link https://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
* (Smarty online manual)
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
* @author credits to Monte Ohrt <monte at ohrt dot com>

View File

@@ -21,7 +21,7 @@
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
* - path_prefix - prefix for path output (optional, default empty)
*
* @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
* @link https://www.smarty.net/manual/en/language.function.html.image.php {html_image}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author credits to Duda <duda@big.hu>

View File

@@ -21,7 +21,7 @@
* - id (optional) - string default not set
* - class (optional) - string default not set
*
* @link http://www.smarty.net/manual/en/language.function.html.options.php {html_image}
* @link https://www.smarty.net/manual/en/language.function.html.options.php {html_image}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>

View File

@@ -29,7 +29,7 @@
* {html_radios values=$ids name='box' separator='<br>' output=$names}
* {html_radios values=$ids checked=$checked separator='<br>' output=$names}
*
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
* @link https://www.smarty.net/manual/en/language.function.html.radios.php {html_radios}
* (Smarty online manual)
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
* @author credits to Monte Ohrt <monte at ohrt dot com>

View File

@@ -28,7 +28,7 @@
* - 2.0 complete rewrite for performance,
* added attributes month_names, *_id
*
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
* @link https://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
* (Smarty online manual)
* @version 2.0
* @author Andrei Zmievski

View File

@@ -11,7 +11,7 @@
* Name: html_select_time
* Purpose: Prints the dropdowns for time selection
*
* @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
* @link https://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
* (Smarty online manual)
* @author Roberto Berto <roberto@berto.net>
* @author Monte Ohrt <monte AT ohrt DOT com>

View File

@@ -38,7 +38,7 @@
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
* @author credit to boots <boots dot smarty at yahoo dot com>
* @version 1.1
* @link http://www.smarty.net/manual/en/language.function.html.table.php {html_table}
* @link https://www.smarty.net/manual/en/language.function.html.table.php {html_table}
* (Smarty online manual)
*
* @param array $params parameters

View File

@@ -36,7 +36,7 @@
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
* {mailto address="me@domain.com" extra='class="mailto"'}
*
* @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
* @link https://www.smarty.net/manual/en/language.function.mailto.php {mailto}
* (Smarty online manual)
* @version 1.2
* @author Monte Ohrt <monte at ohrt dot com>

View File

@@ -12,7 +12,7 @@
* Name: math
* Purpose: handle math computations in template
*
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
* @link https://www.smarty.net/manual/en/language.function.math.php {math}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*

View File

@@ -15,7 +15,7 @@
* - format: strftime format for output
* - default_date: default date if $string is empty
*
* @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input date string

View File

@@ -11,7 +11,7 @@
* Name: escape
* Purpose: escape string for output
*
* @link http://www.smarty.net/docs/en/language.modifier.escape
* @link https://www.smarty.net/docs/en/language.modifier.escape
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input string

View File

@@ -11,7 +11,7 @@
* Name: mb_wordwrap
* Purpose: Wrap a string to a given number of characters
*
* @link http://php.net/manual/en/function.wordwrap.php for similarity
* @link https://php.net/manual/en/function.wordwrap.php for similarity
*
* @param string $str the string to wrap
* @param int $width the width of the output

View File

@@ -11,7 +11,7 @@
* Name: regex_replace
* Purpose: regular expression search/replace
*
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
* @link https://www.smarty.net/manual/en/language.modifier.regex.replace.php
* regex_replace (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*

View File

@@ -11,7 +11,7 @@
* Name: replace
* Purpose: simple search/replace
*
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews
*

View File

@@ -11,7 +11,7 @@
* Name: spacify
* Purpose: add spaces between characters in a string
*
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input string

View File

@@ -13,7 +13,7 @@
* optionally splitting in the middle of a word, and
* appending the $etc string or inserting $etc into the middle.
*
* @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input string

View File

@@ -14,7 +14,7 @@
* Input: string to catenate
* Example: {$var|cat:"foo"}
*
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
* @link https://www.smarty.net/manual/en/language.modifier.cat.php cat
* (Smarty online manual)
* @author Uwe Tews
*

View File

@@ -11,7 +11,7 @@
* Name: count_characters
* Purpose: count the number of characters in a text
*
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
* @link https://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
* manual)
* @author Uwe Tews
*

View File

@@ -11,7 +11,7 @@
* Name: count_paragraphs
* Purpose: count the number of paragraphs in a text
*
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* count_paragraphs (Smarty online manual)
* @author Uwe Tews
*

View File

@@ -11,7 +11,7 @@
* Name: count_sentences
* Purpose: count the number of sentences in a text
*
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* count_sentences (Smarty online manual)
* @author Uwe Tews
*

View File

@@ -11,7 +11,7 @@
* Name: count_words
* Purpose: count the number of words in a text
*
* @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters

View File

@@ -11,7 +11,7 @@
* Name: default
* Purpose: designate default value for empty variables
*
* @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters

View File

@@ -11,7 +11,7 @@
* Name: escape
* Purpose: escape string for output
*
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
* @link https://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
* @author Rodney Rehm
*
* @param array $params parameters

View File

@@ -11,7 +11,7 @@
* Name: indent
* Purpose: indent lines of text
*
* @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters

View File

@@ -11,7 +11,7 @@
* Name: lower
* Purpose: convert string to lowercase
*
* @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews
*

View File

@@ -11,7 +11,7 @@
* Name: string_format
* Purpose: format strings via sprintf
*
* @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters

View File

@@ -14,7 +14,7 @@
* Example: {$var|strip} {$var|strip:"&nbsp;"}
* Date: September 25th, 2002
*
* @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters

View File

@@ -11,7 +11,7 @@
* Name: strip_tags
* Purpose: strip html tags from text
*
* @link http://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual)
* @link https://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters

View File

@@ -11,7 +11,7 @@
* Name: lower
* Purpose: convert string to uppercase
*
* @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters

View File

@@ -11,7 +11,7 @@
* Name: wordwrap
* Purpose: wrap a string of text at a given length
*
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters

View File

@@ -41,7 +41,7 @@ function smarty_outputfilter_trimwhitespace($source)
}
}
// Strip all HTML-Comments
// yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124
// yes, even the ones in <script> - see https://stackoverflow.com/a/808850/515124
$source = preg_replace('#<!--.*?-->#ms', '', $source);
// capture html elements not to be messed with
$_offset = 0;

View File

@@ -219,9 +219,9 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
if (isset($itemAttr[ 'index' ])) {
$output .= "{$itemVar}->index = -1;\n";
}
$output .= "{$itemVar}->do_else = true;\n";
$output .= "{$itemVar}->do_else = true;\n";
$output .= "if (\$_from !== null) foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
$output .= "{$itemVar}->do_else = false;\n";
$output .= "{$itemVar}->do_else = false;\n";
if (isset($attributes[ 'key' ]) && isset($itemAttr[ 'key' ])) {
$output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
}

View File

@@ -121,7 +121,7 @@ abstract class Smarty_Internal_Data
* appends values to template variables
*
* @api Smarty::append()
* @link http://www.smarty.net/docs/en/api.append.tpl
* @link https://www.smarty.net/docs/en/api.append.tpl
*
* @param array|string $tpl_var the template variable name(s)
* @param mixed $value the value to append
@@ -182,7 +182,7 @@ abstract class Smarty_Internal_Data
* Returns a single or all template variables
*
* @api Smarty::getTemplateVars()
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
* @link https://www.smarty.net/docs/en/api.get.template.vars.tpl
*
* @param string $varName variable name or null
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object

View File

@@ -31,7 +31,7 @@ class Smarty_Internal_ErrorHandler
public function activate() {
/*
Error muting is done because some people implemented custom error_handlers using
http://php.net/set_error_handler and for some reason did not understand the following paragraph:
https://php.net/set_error_handler and for some reason did not understand the following paragraph:
It is important to remember that the standard PHP error handler is completely bypassed for the
error types specified by error_types unless the callback function returns FALSE.
@@ -54,7 +54,7 @@ class Smarty_Internal_ErrorHandler
/**
* Error Handler to mute expected messages
*
* @link http://php.net/set_error_handler
* @link https://php.net/set_error_handler
*
* @param integer $errno Error level
* @param $errstr

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_Append
* appends values to template variables
*
* @api Smarty::append()
* @link http://www.smarty.net/docs/en/api.append.tpl
* @link https://www.smarty.net/docs/en/api.append.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param array|string $tpl_var the template variable name(s)

View File

@@ -15,7 +15,7 @@ class Smarty_Internal_Method_AppendByRef
* appends values to template variables by reference
*
* @api Smarty::appendByRef()
* @link http://www.smarty.net/docs/en/api.append.by.ref.tpl
* @link https://www.smarty.net/docs/en/api.append.by.ref.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param string $tpl_var the template variable name

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearAllAssign
* clear all the assigned template variables.
*
* @api Smarty::clearAllAssign()
* @link http://www.smarty.net/docs/en/api.clear.all.assign.tpl
* @link https://www.smarty.net/docs/en/api.clear.all.assign.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
*

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearAllCache
* Empty cache folder
*
* @api Smarty::clearAllCache()
* @link http://www.smarty.net/docs/en/api.clear.all.cache.tpl
* @link https://www.smarty.net/docs/en/api.clear.all.cache.tpl
*
* @param \Smarty $smarty
* @param integer $exp_time expiration time

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearAssign
* clear the given assigned template variable(s).
*
* @api Smarty::clearAssign()
* @link http://www.smarty.net/docs/en/api.clear.assign.tpl
* @link https://www.smarty.net/docs/en/api.clear.assign.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param string|array $tpl_var the template variable(s) to clear

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearCache
* Empty cache for a specific template
*
* @api Smarty::clearCache()
* @link http://www.smarty.net/docs/en/api.clear.cache.tpl
* @link https://www.smarty.net/docs/en/api.clear.cache.tpl
*
* @param \Smarty $smarty
* @param string $template_name template name

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearCompiledTemplate
* Delete compiled template file
*
* @api Smarty::clearCompiledTemplate()
* @link http://www.smarty.net/docs/en/api.clear.compiled.template.tpl
* @link https://www.smarty.net/docs/en/api.clear.compiled.template.tpl
*
* @param \Smarty $smarty
* @param string $resource_name template name

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearConfig
* clear a single or all config variables
*
* @api Smarty::clearConfig()
* @link http://www.smarty.net/docs/en/api.clear.config.tpl
* @link https://www.smarty.net/docs/en/api.clear.config.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param string|null $name variable name or null

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ConfigLoad
* load a config file, optionally load just selected sections
*
* @api Smarty::configLoad()
* @link http://www.smarty.net/docs/en/api.config.load.tpl
* @link https://www.smarty.net/docs/en/api.config.load.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param string $config_file filename
@@ -42,7 +42,7 @@ class Smarty_Internal_Method_ConfigLoad
* load a config file, optionally load just selected sections
*
* @api Smarty::configLoad()
* @link http://www.smarty.net/docs/en/api.config.load.tpl
* @link https://www.smarty.net/docs/en/api.config.load.tpl
*
* @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data
* @param string $config_file filename

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_CreateData
* creates a data object
*
* @api Smarty::createData()
* @link http://www.smarty.net/docs/en/api.create.data.tpl
* @link https://www.smarty.net/docs/en/api.create.data.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param \Smarty_Internal_Template|\Smarty_Internal_Data|\Smarty_Data|\Smarty $parent next higher level of Smarty

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetConfigVars
* Returns a single or all config variables
*
* @api Smarty::getConfigVars()
* @link http://www.smarty.net/docs/en/api.get.config.vars.tpl
* @link https://www.smarty.net/docs/en/api.get.config.vars.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param string $varname variable name or null

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetRegisteredObject
* return a reference to a registered object
*
* @api Smarty::getRegisteredObject()
* @link http://www.smarty.net/docs/en/api.get.registered.object.tpl
* @link https://www.smarty.net/docs/en/api.get.registered.object.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $object_name object name

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetTags
* Return array of tag/attributes of all tags used by an template
*
* @api Smarty::getTags()
* @link http://www.smarty.net/docs/en/api.get.tags.tpl
* @link https://www.smarty.net/docs/en/api.get.tags.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param null|string|Smarty_Internal_Template $template

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetTemplateVars
* Returns a single or all template variables
*
* @api Smarty::getTemplateVars()
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
* @link https://www.smarty.net/docs/en/api.get.template.vars.tpl
*
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
* @param string $varName variable name or null

View File

@@ -30,7 +30,7 @@ class Smarty_Internal_Method_LoadFilter
*
* @api Smarty::loadFilter()
*
* @link http://www.smarty.net/docs/en/api.load.filter.tpl
* @link https://www.smarty.net/docs/en/api.load.filter.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type filter type

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterCacheResource
* Registers a resource to fetch a template
*
* @api Smarty::registerCacheResource()
* @link http://www.smarty.net/docs/en/api.register.cacheresource.tpl
* @link https://www.smarty.net/docs/en/api.register.cacheresource.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $name name of resource type

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterClass
* Registers static classes to be used in templates
*
* @api Smarty::registerClass()
* @link http://www.smarty.net/docs/en/api.register.class.tpl
* @link https://www.smarty.net/docs/en/api.register.class.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $class_name

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterDefaultPluginHandler
* Registers a default plugin handler
*
* @api Smarty::registerDefaultPluginHandler()
* @link http://www.smarty.net/docs/en/api.register.default.plugin.handler.tpl
* @link https://www.smarty.net/docs/en/api.register.default.plugin.handler.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param callable $callback class/method name

View File

@@ -30,7 +30,7 @@ class Smarty_Internal_Method_RegisterFilter
*
* @api Smarty::registerFilter()
*
* @link http://www.smarty.net/docs/en/api.register.filter.tpl
* @link https://www.smarty.net/docs/en/api.register.filter.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type filter type

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterObject
* Registers object to be used in templates
*
* @api Smarty::registerObject()
* @link http://www.smarty.net/docs/en/api.register.object.tpl
* @link https://www.smarty.net/docs/en/api.register.object.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $object_name

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterPlugin
* Registers plugin to be used in templates
*
* @api Smarty::registerPlugin()
* @link http://www.smarty.net/docs/en/api.register.plugin.tpl
* @link https://www.smarty.net/docs/en/api.register.plugin.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type plugin type

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterResource
* Registers a resource to fetch a template
*
* @api Smarty::registerResource()
* @link http://www.smarty.net/docs/en/api.register.resource.tpl
* @link https://www.smarty.net/docs/en/api.register.resource.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $name name of resource type

View File

@@ -16,7 +16,7 @@ class Smarty_Internal_Method_UnloadFilter extends Smarty_Internal_Method_LoadFil
*
* @api Smarty::unloadFilter()
*
* @link http://www.smarty.net/docs/en/api.unload.filter.tpl
* @link https://www.smarty.net/docs/en/api.unload.filter.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type filter type

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterCacheResource
* Registers a resource to fetch a template
*
* @api Smarty::unregisterCacheResource()
* @link http://www.smarty.net/docs/en/api.unregister.cacheresource.tpl
* @link https://www.smarty.net/docs/en/api.unregister.cacheresource.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param $name

View File

@@ -16,7 +16,7 @@ class Smarty_Internal_Method_UnregisterFilter extends Smarty_Internal_Method_Reg
*
* @api Smarty::unregisterFilter()
*
* @link http://www.smarty.net/docs/en/api.unregister.filter.tpl
* @link https://www.smarty.net/docs/en/api.unregister.filter.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type filter type

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterObject
* Registers plugin to be used in templates
*
* @api Smarty::unregisterObject()
* @link http://www.smarty.net/docs/en/api.unregister.object.tpl
* @link https://www.smarty.net/docs/en/api.unregister.object.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $object_name name of object

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterPlugin
* Registers plugin to be used in templates
*
* @api Smarty::unregisterPlugin()
* @link http://www.smarty.net/docs/en/api.unregister.plugin.tpl
* @link https://www.smarty.net/docs/en/api.unregister.plugin.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type plugin type

View File

@@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterResource
* Registers a resource to fetch a template
*
* @api Smarty::unregisterResource()
* @link http://www.smarty.net/docs/en/api.unregister.resource.tpl
* @link https://www.smarty.net/docs/en/api.unregister.resource.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param string $type name of resource type

View File

@@ -87,83 +87,83 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
$code = '';
foreach ($this->getChunkedSubtrees() as $chunk) {
$text = '';
switch ($chunk['mode']) {
case 'textstripped':
foreach ($chunk['subtrees'] as $subtree) {
$text .= $subtree->to_smarty_php($parser);
}
$code .= preg_replace(
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
"<?php echo '\$1'; ?>\n",
$parser->compiler->processText($text)
);
break;
case 'text':
foreach ($chunk['subtrees'] as $subtree) {
$text .= $subtree->to_smarty_php($parser);
}
$code .= preg_replace(
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
"<?php echo '\$1'; ?>\n",
$text
);
break;
case 'tag':
foreach ($chunk['subtrees'] as $subtree) {
$text = $parser->compiler->appendCode($text, $subtree->to_smarty_php($parser));
}
$code .= $text;
break;
default:
foreach ($chunk['subtrees'] as $subtree) {
$text = $subtree->to_smarty_php($parser);
}
$code .= $text;
$text = '';
switch ($chunk['mode']) {
case 'textstripped':
foreach ($chunk['subtrees'] as $subtree) {
$text .= $subtree->to_smarty_php($parser);
}
$code .= preg_replace(
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
"<?php echo '\$1'; ?>\n",
$parser->compiler->processText($text)
);
break;
case 'text':
foreach ($chunk['subtrees'] as $subtree) {
$text .= $subtree->to_smarty_php($parser);
}
$code .= preg_replace(
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
"<?php echo '\$1'; ?>\n",
$text
);
break;
case 'tag':
foreach ($chunk['subtrees'] as $subtree) {
$text = $parser->compiler->appendCode($text, $subtree->to_smarty_php($parser));
}
$code .= $text;
break;
default:
foreach ($chunk['subtrees'] as $subtree) {
$text = $subtree->to_smarty_php($parser);
}
$code .= $text;
}
}
}
return $code;
}
private function getChunkedSubtrees() {
$chunks = array();
$currentMode = null;
$currentChunk = array();
for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) {
$chunks = array();
$currentMode = null;
$currentChunk = array();
for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) {
if ($this->subtrees[ $key ]->data === '' && in_array($currentMode, array('textstripped', 'text', 'tag'))) {
continue;
}
if ($this->subtrees[ $key ]->data === '' && in_array($currentMode, array('textstripped', 'text', 'tag'))) {
continue;
}
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text
&& $this->subtrees[ $key ]->isToBeStripped()) {
$newMode = 'textstripped';
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text) {
$newMode = 'text';
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) {
$newMode = 'tag';
} else {
$newMode = 'other';
}
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text
&& $this->subtrees[ $key ]->isToBeStripped()) {
$newMode = 'textstripped';
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text) {
$newMode = 'text';
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) {
$newMode = 'tag';
} else {
$newMode = 'other';
}
if ($newMode == $currentMode) {
$currentChunk[] = $this->subtrees[ $key ];
} else {
$chunks[] = array(
'mode' => $currentMode,
'subtrees' => $currentChunk
);
$currentMode = $newMode;
$currentChunk = array($this->subtrees[ $key ]);
}
}
if ($currentMode && $currentChunk) {
$chunks[] = array(
'mode' => $currentMode,
'subtrees' => $currentChunk
);
}
return $chunks;
if ($newMode == $currentMode) {
$currentChunk[] = $this->subtrees[ $key ];
} else {
$chunks[] = array(
'mode' => $currentMode,
'subtrees' => $currentChunk
);
$currentMode = $newMode;
$currentChunk = array($this->subtrees[ $key ]);
}
}
if ($currentMode && $currentChunk) {
$chunks[] = array(
'mode' => $currentMode,
'subtrees' => $currentChunk
);
}
return $chunks;
}
}

View File

@@ -17,30 +17,30 @@
class Smarty_Internal_ParseTree_Text extends Smarty_Internal_ParseTree
{
/**
* Wether this section should be stripped on output to smarty php
* @var bool
*/
private $toBeStripped = false;
/**
* Wether this section should be stripped on output to smarty php
* @var bool
*/
private $toBeStripped = false;
/**
* Create template text buffer
*
* @param string $data text
* @param bool $toBeStripped wether this section should be stripped on output to smarty php
*/
/**
* Create template text buffer
*
* @param string $data text
* @param bool $toBeStripped wether this section should be stripped on output to smarty php
*/
public function __construct($data, $toBeStripped = false)
{
$this->data = $data;
$this->toBeStripped = $toBeStripped;
}
/**
* Wether this section should be stripped on output to smarty php
* @return bool
*/
public function isToBeStripped() {
return $this->toBeStripped;
/**
* Wether this section should be stripped on output to smarty php
* @return bool
*/
public function isToBeStripped() {
return $this->toBeStripped;
}
/**

View File

@@ -13,7 +13,7 @@
* Smarty Internal Plugin Resource Stream
* Implements the streams as resource for Smarty template
*
* @link http://php.net/streams
* @link https://php.net/streams
* @package Smarty
* @subpackage TemplateResources
*/

View File

@@ -138,7 +138,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* test if cache is valid
*
* @api Smarty::isCached()
* @link http://www.smarty.net/docs/en/api.is.cached.tpl
* @link https://www.smarty.net/docs/en/api.is.cached.tpl
*
* @param null|string|\Smarty_Internal_Template $template the resource handle of the template file or template
* object
@@ -201,8 +201,8 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
isset($smarty->error_reporting) ? error_reporting($smarty->error_reporting) : null;
if ($smarty->getPHP7CompatMode()) {
$errorHandler = new Smarty_Internal_ErrorHandler();
$errorHandler->activate();
$errorHandler = new Smarty_Internal_ErrorHandler();
$errorHandler->activate();
}
if ($this->_objType === 2) {
@@ -250,7 +250,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
}
if (isset($errorHandler)) {
$errorHandler->deactivate();
$errorHandler->deactivate();
}
if (isset($_smarty_old_error_level)) {
@@ -261,13 +261,13 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
while (ob_get_level() > $level) {
ob_end_clean();
}
if (isset($errorHandler)) {
$errorHandler->deactivate();
}
if (isset($errorHandler)) {
$errorHandler->deactivate();
}
if (isset($_smarty_old_error_level)) {
error_reporting($_smarty_old_error_level);
}
if (isset($_smarty_old_error_level)) {
error_reporting($_smarty_old_error_level);
}
throw $e;
}
}
@@ -276,7 +276,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* Registers plugin to be used in templates
*
* @api Smarty::registerPlugin()
* @link http://www.smarty.net/docs/en/api.register.plugin.tpl
* @link https://www.smarty.net/docs/en/api.register.plugin.tpl
*
* @param string $type plugin type
* @param string $name name of template tag
@@ -296,7 +296,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* load a filter of specified type and name
*
* @api Smarty::loadFilter()
* @link http://www.smarty.net/docs/en/api.load.filter.tpl
* @link https://www.smarty.net/docs/en/api.load.filter.tpl
*
* @param string $type filter type
* @param string $name filter name
@@ -313,7 +313,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* Registers a filter function
*
* @api Smarty::registerFilter()
* @link http://www.smarty.net/docs/en/api.register.filter.tpl
* @link https://www.smarty.net/docs/en/api.register.filter.tpl
*
* @param string $type filter type
* @param callable $callback
@@ -331,7 +331,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* Registers object to be used in templates
*
* @api Smarty::registerObject()
* @link http://www.smarty.net/docs/en/api.register.object.tpl
* @link https://www.smarty.net/docs/en/api.register.object.tpl
*
* @param string $object_name
* @param object $object the referenced PHP object to register

View File

@@ -615,11 +615,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
$this->trigger_template_error('Illegal number of parameter in "isset()"');
}
$pa = array();
foreach ($parameter as $p) {
$pa[] = $this->syntaxMatchesVariable($p) ? 'isset(' . $p . ')' : '(' . $p . ' !== null )';
}
return '(' . implode(' && ', $pa) . ')';
$pa = array();
foreach ($parameter as $p) {
$pa[] = $this->syntaxMatchesVariable($p) ? 'isset(' . $p . ')' : '(' . $p . ' !== null )';
}
return '(' . implode(' && ', $pa) . ')';
} elseif (in_array(
$func_name,
@@ -651,16 +651,16 @@ abstract class Smarty_Internal_TemplateCompilerBase
}
}
/**
* Determines whether the passed string represents a valid (PHP) variable.
* This is important, because `isset()` only works on variables and `empty()` can only be passed
* a variable prior to php5.5
* @param $string
* @return bool
*/
private function syntaxMatchesVariable($string) {
static $regex_pattern = '/^\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*((->)[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*|\[.*]*\])*$/';
return 1 === preg_match($regex_pattern, trim($string));
/**
* Determines whether the passed string represents a valid (PHP) variable.
* This is important, because `isset()` only works on variables and `empty()` can only be passed
* a variable prior to php5.5
* @param $string
* @return bool
*/
private function syntaxMatchesVariable($string) {
static $regex_pattern = '/^\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*((->)[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*|\[.*]*\])*$/';
return 1 === preg_match($regex_pattern, trim($string));
}
/**
@@ -675,11 +675,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
{
if (strpos($text, '<') === false) {
return preg_replace($this->stripRegEx, '', $text);
return preg_replace($this->stripRegEx, '', $text);
}
$store = array();
$_store = 0;
$store = array();
$_store = 0;
// capture html elements not to be messed with
$_offset = 0;

View File

@@ -32,8 +32,8 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
*/
public function testUnknownConfigFile()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to load config \'file:foo.conf\'');
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to load config \'file:foo.conf\'');
$this->smarty->configLoad('foo.conf');
}
@@ -42,9 +42,9 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
*/
public function testRegisterUnknownDefaultConfigHandler()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('Default config handler');
$this->expectExceptionMessage('not callable');
$this->expectException('SmartyException');
$this->expectExceptionMessage('Default config handler');
$this->expectExceptionMessage('not callable');
$this->smarty->registerDefaultConfigHandler('foo');
}
@@ -76,8 +76,8 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
public function testDefaultConfigHandlerReplacementByConfigFileFail()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage("Unable to load config default file 'no.conf' for 'file:fo.conf'");
$this->expectException('SmartyException');
$this->expectExceptionMessage("Unable to load config default file 'no.conf' for 'file:fo.conf'");
$this->smarty->registerDefaultConfigHandler('configHandlerFile');
$this->smarty->configLoad('fo.conf');
$this->assertEquals("123.4", $this->smarty->fetch('number.tpl'));
@@ -88,8 +88,8 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
*/
public function testDefaultConfigHandlerReplacementReturningFalse()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to load config \'file:foo.conf\'');
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to load config \'file:foo.conf\'');
$this->smarty->configLoad('foo.conf');
}
@@ -98,8 +98,8 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
*/
public function testDefaultConfigHandlerReplacementReturningFalse1()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('No config default content for \'file:bla.conf\'');
$this->expectException('SmartyException');
$this->expectExceptionMessage('No config default content for \'file:bla.conf\'');
$this->smarty->registerDefaultConfigHandler('configHandlerData');
$this->smarty->configLoad('bla.conf');
}

View File

@@ -403,7 +403,7 @@ class ConfigVarTest extends PHPUnit_Smarty
$this->assertEquals("", $this->smarty->fetch('foo.tpl'));
}
catch (Exception $e) {
$this->assertStringStartsWith('Undefined variable', $e->getMessage());
$this->assertStringStartsWith('Undefined variable', $e->getMessage());
}
}
}

View File

@@ -143,8 +143,8 @@ if (MysqlResourceEnable == true) {
*
*/
public function testUnknownTemplate() {
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to load template \'mysqlstest:foo.tpl\'');
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to load template \'mysqlstest:foo.tpl\'');
$this->assertEquals('foo', $this->smarty->fetch('mysqlstest:foo.tpl'));
}
}

View File

@@ -69,10 +69,10 @@ class FileResourceTest extends PHPUnit_Smarty
*/
public function testTemplateFileNotExists3()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to');
$this->expectExceptionMessage('notthere.tpl');
$this->smarty->fetch('notthere.tpl');
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to');
$this->expectExceptionMessage('notthere.tpl');
$this->smarty->fetch('notthere.tpl');
}
public function testGetTemplateTimestamp()
@@ -108,9 +108,9 @@ class FileResourceTest extends PHPUnit_Smarty
);
}
/**
* @doesNotPerformAssertions
*/
/**
* @doesNotPerformAssertions
*/
public function testGetCompiledTimestampPrepare()
{
$tpl = $this->smarty->createTemplate('helloworld.tpl');
@@ -143,9 +143,9 @@ class FileResourceTest extends PHPUnit_Smarty
$this->assertTrue($tpl->mustCompile());
}
/**
* @doesNotPerformAssertions
*/
/**
* @doesNotPerformAssertions
*/
public function testMustCompileTouchedSourcePrepare()
{
// touch to prepare next test
@@ -222,8 +222,8 @@ class FileResourceTest extends PHPUnit_Smarty
*/
public function testRelativeIncludeFail()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to');
$this->expectException('SmartyException');
$this->expectExceptionMessage('Unable to');
$this->smarty->fetch('relative_sub.tpl');
}
/**
@@ -234,8 +234,8 @@ class FileResourceTest extends PHPUnit_Smarty
*/
public function testRelativeIncludeFailOtherDir()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('./hello.tpl');
$this->expectException('SmartyException');
$this->expectExceptionMessage('./hello.tpl');
$this->smarty->addTemplateDir('./templates_2');
$this->smarty->fetch('relative_notexist.tpl');
}

View File

@@ -84,48 +84,48 @@ class RegisteredResourceTest extends PHPUnit_Smarty
class RegisteredResourceTest_Resource1 extends Smarty_Resource_Custom {
protected function fetch($name, &$source, &$mtime) {
$source = '{$x="hello world"}{$x}';
$mtime = 1000000000;
}
protected function fetch($name, &$source, &$mtime) {
$source = '{$x="hello world"}{$x}';
$mtime = 1000000000;
}
}
class RegisteredResourceTest_Resource2 extends Smarty_Resource_Custom {
protected function fetch($name, &$source, &$mtime) {
protected function fetch($name, &$source, &$mtime) {
// we update a counter, so that we return a new source for every call
static $counter = 0;
$counter ++;
// we update a counter, so that we return a new source for every call
static $counter = 0;
$counter ++;
// construct a new source
$source = "this is template $counter";
// construct a new source
$source = "this is template $counter";
$mtime = 1000000000;
}
$mtime = 1000000000;
}
protected function fetchTimestamp($name)
{
return 1000000000;
}
protected function fetchTimestamp($name)
{
return 1000000000;
}
}
class RegisteredResourceTest_Resource3 extends Smarty_Resource_Custom {
protected function fetch($name, &$source, &$mtime) {
$source = 'template = {$smarty.template}';
$mtime = 1000000000;
}
protected function fetch($name, &$source, &$mtime) {
$source = 'template = {$smarty.template}';
$mtime = 1000000000;
}
}
class RegisteredResourceTest_Resource4 extends Smarty_Resource_Custom {
protected function fetch($name, &$source, &$mtime) {
$source = 'current_dir = {$smarty.current_dir}';
$mtime = 1000000000;
}
protected function fetch($name, &$source, &$mtime) {
$source = 'current_dir = {$smarty.current_dir}';
$mtime = 1000000000;
}
}

View File

@@ -12,14 +12,14 @@
class Smarty_Resource_Db extends Smarty_Resource_Recompiled {
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) {
$source->filepath = 'db:';
$source->uid = sha1($source->resource);
$source->timestamp = 1000000000;
$source->exists = true;
}
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null) {
$source->filepath = 'db:';
$source->uid = sha1($source->resource);
$source->timestamp = 1000000000;
$source->exists = true;
}
public function getContent(Smarty_Template_Source $source) {
return '{$x="hello world"}{$x}';
}
public function getContent(Smarty_Template_Source $source) {
return '{$x="hello world"}{$x}';
}
}

View File

@@ -146,8 +146,8 @@ class StreamResourceTest extends PHPUnit_Smarty
public function testTemplateStramNotExists3()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('\'global:notthere\'');
$this->expectException('SmartyException');
$this->expectExceptionMessage('\'global:notthere\'');
$this->smarty->fetch('global:notthere');
}

View File

@@ -62,8 +62,8 @@ class SecurityTest extends PHPUnit_Smarty
*/
public function testNotTrustedPHPFunction()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('PHP function \'count\' not allowed by security setting');
$this->expectException('SmartyException');
$this->expectExceptionMessage('PHP function \'count\' not allowed by security setting');
$this->smarty->security_policy->php_functions = array('null');
$this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{count($foo)}');
}
@@ -93,8 +93,8 @@ class SecurityTest extends PHPUnit_Smarty
*/
public function testNotTrustedModifier()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('modifier \'count\' not allowed by security setting');
$this->expectException('SmartyException');
$this->expectExceptionMessage('modifier \'count\' not allowed by security setting');
$this->smarty->security_policy->php_modifiers = array('null');
$this->smarty->fetch('string:{assign var=foo value=[1,2,3,4,5]}{$foo|@count}');
}
@@ -125,8 +125,8 @@ class SecurityTest extends PHPUnit_Smarty
*/
public function testNotAllowedTags2()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('tag \'cycle\' not allowed by security setting');
$this->expectException('SmartyException');
$this->expectExceptionMessage('tag \'cycle\' not allowed by security setting');
$this->smarty->security_policy->allowed_tags = array('counter');
$this->smarty->fetch('string:{counter}{cycle values="1,2"}');
}
@@ -138,8 +138,8 @@ class SecurityTest extends PHPUnit_Smarty
*/
public function testDisabledTags()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('tag \'cycle\' disabled by security setting');
$this->expectException('SmartyException');
$this->expectExceptionMessage('tag \'cycle\' disabled by security setting');
$this->smarty->security_policy->disabled_tags = array('cycle');
$this->smarty->fetch('string:{counter}{cycle values="1,2"}');
}
@@ -168,8 +168,8 @@ class SecurityTest extends PHPUnit_Smarty
*/
public function testNotAllowedModifier()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('modifier \'lower\' not allowed by security setting');
$this->expectException('SmartyException');
$this->expectExceptionMessage('modifier \'lower\' not allowed by security setting');
$this->smarty->security_policy->allowed_modifiers = array('upper');
$this->smarty->fetch('string:{"hello"|upper}{"world"|lower}');
}
@@ -181,8 +181,8 @@ class SecurityTest extends PHPUnit_Smarty
*/
public function testDisabledModifier()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('modifier \'lower\' disabled by security setting');
$this->expectException('SmartyException');
$this->expectExceptionMessage('modifier \'lower\' disabled by security setting');
$this->smarty->security_policy->disabled_modifiers = array('lower');
$this->smarty->fetch('string:{"hello"|upper}{"world"|lower}');
}
@@ -196,15 +196,15 @@ class SecurityTest extends PHPUnit_Smarty
$this->assertEquals('<?php echo "hello world"; ?>', $this->smarty->fetch('string:<?php echo "hello world"; ?>'));
}
public function testSmartyPhpAllow2()
{
$this->assertEquals('<? echo "hello world"; ?>', $this->smarty->fetch('string:<? echo "hello world"; ?>'));
}
public function testSmartyPhpAllow2()
{
$this->assertEquals('<? echo "hello world"; ?>', $this->smarty->fetch('string:<? echo "hello world"; ?>'));
}
public function testSmartyPhpAllow3()
{
$this->assertEquals('<% echo "hello world"; %>', $this->smarty->fetch('string:<% echo "hello world"; %>'));
}
public function testSmartyPhpAllow3()
{
$this->assertEquals('<% echo "hello world"; %>', $this->smarty->fetch('string:<% echo "hello world"; %>'));
}
/**
* test standard directory
@@ -232,8 +232,8 @@ class SecurityTest extends PHPUnit_Smarty
*/
public function testNotTrustedDirectory()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('not trusted file path');
$this->expectException('SmartyException');
$this->expectExceptionMessage('not trusted file path');
$this->smarty->security_policy->secure_dir = array(str_replace('\\', '/', dirname(__FILE__) . '/templates_3/'));
$this->smarty->fetch('string:{include file="templates_2/hello.tpl"}');
}
@@ -264,8 +264,8 @@ class SecurityTest extends PHPUnit_Smarty
*/
public function testNotTrustedStaticClass()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('access to static class \'mysecuritystaticclass\' not allowed by security setting');
$this->expectException('SmartyException');
$this->expectExceptionMessage('access to static class \'mysecuritystaticclass\' not allowed by security setting');
$this->smarty->security_policy->static_classes = array('null');
$this->smarty->fetch('string:{mysecuritystaticclass::square(5)}');
}
@@ -307,8 +307,8 @@ class SecurityTest extends PHPUnit_Smarty
*/
public function testTemplateNotTrustedStream()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('stream \'global\' not allowed by security setting');
$this->expectException('SmartyException');
$this->expectExceptionMessage('stream \'global\' not allowed by security setting');
stream_wrapper_register("global", "ResourceStreamSecurity")
or die("Failed to register protocol");
$fp = fopen("global://mytest", "r+");
@@ -336,8 +336,8 @@ class SecurityTest extends PHPUnit_Smarty
*/
public function testNotTrustedUri()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('URI \'https://www.smarty.net/docs/en/preface.tpl\' not allowed by security setting');
$this->expectException('SmartyException');
$this->expectExceptionMessage('URI \'https://www.smarty.net/docs/en/preface.tpl\' not allowed by security setting');
$this->smarty->security_policy->trusted_uri = array();
$this->assertStringContainsString('<title>Preface | Smarty</title>', $this->smarty->fetch('string:{fetch file="https://www.smarty.net/docs/en/preface.tpl"}'));
}

View File

@@ -50,8 +50,8 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
*/
public function testBlockPluginUnknown()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unknown tag \'bar\'');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unknown tag \'bar\'');
$this->assertEquals("hello world", $this->smarty->fetch('unknown.tpl'));
}
@@ -76,8 +76,8 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
*/
public function testBlockPluginRegisteredFunction2()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('block tag \'blockplugintest\' not callable');
$this->expectException('SmartyException');
$this->expectExceptionMessage('block tag \'blockplugintest\' not callable');
$this->assertEquals('block test', $this->smarty->fetch('registered.tpl'));
}
@@ -103,8 +103,8 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
*/
public function testBlockPluginRegisteredStatic2()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('block tag \'blockpluginstatic\' not callable');
$this->expectException('SmartyException');
$this->expectExceptionMessage('block tag \'blockpluginstatic\' not callable');
$this->assertEquals('static block test', $this->smarty->fetch('registered_static.tpl'));
}
@@ -130,8 +130,8 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
*/
public function testBlockPluginRegisteredMethod2()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('block tag \'blockpluginmethod\' not callable');
$this->expectException('SmartyException');
$this->expectExceptionMessage('block tag \'blockpluginmethod\' not callable');
$this->assertEquals('method block test', $this->smarty->fetch('registered_method.tpl'));
}
@@ -157,8 +157,8 @@ class CompileBlockPluginTest extends PHPUnit_Smarty
*/
public function testBlockPluginRegisteredObject2()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('block tag \'myobject\' not callable');
$this->expectException('SmartyException');
$this->expectExceptionMessage('block tag \'myobject\' not callable');
$this->assertEquals('object block test', $this->smarty->fetch('registered_object.tpl'));
}

View File

@@ -755,8 +755,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*/
public function testSmartyBlockChildOutsideBlock_025()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('\'{$smarty.block.child}\' used outside {block} tags');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('\'{$smarty.block.child}\' used outside {block} tags');
$this->smarty->fetch('025_parent.tpl');
}
@@ -765,8 +765,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*/
public function testSmartyBlockParentOutsideBlock_026()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('\'{$smarty.block.parent}\' used outside {block} tags');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('\'{$smarty.block.parent}\' used outside {block} tags');
$this->smarty->fetch('026_child.tpl');
}
@@ -775,8 +775,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*/
public function testSmartyBlockParentInParent_027()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('illegal \'{$smarty.block.parent}\'');
$this->expectException('SmartyException');
$this->expectExceptionMessage('illegal \'{$smarty.block.parent}\'');
$this->smarty->fetch('027_parent.tpl');
}
@@ -1145,8 +1145,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*/
public function testSmartyBlockWrongBlockName_036()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('$smarty.block is not defined');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('$smarty.block is not defined');
$this->smarty->fetch('036_parent.tpl');
}
/**
@@ -1154,8 +1154,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*/
public function testSmartyParentBlockCalledInParent_036_1()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('inheritance: illegal \'{$smarty.block.parent}\' used in child template');
$this->expectException('SmartyException');
$this->expectExceptionMessage('inheritance: illegal \'{$smarty.block.parent}\' used in child template');
$this->smarty->fetch('036_1_parent.tpl');
}
/**
@@ -1163,8 +1163,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*/
public function testSmartyParentBlockCalledInParent_036_2()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('inheritance: illegal \'{block_parent}\' used in child template');
$this->expectException('SmartyException');
$this->expectExceptionMessage('inheritance: illegal \'{block_parent}\' used in child template');
$this->smarty->fetch('036_2_parent.tpl');
}
/**
@@ -1172,8 +1172,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*/
public function testSmartyParentBlockCalledInParent_036_3()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('inheritance: illegal \'{parent}\' used in child template');
$this->expectException('SmartyException');
$this->expectExceptionMessage('inheritance: illegal \'{parent}\' used in child template');
$this->smarty->fetch('036_3_parent.tpl');
}
@@ -1182,8 +1182,8 @@ class CompileBlockExtendsTest extends PHPUnit_Smarty
*/
public function testSmartyBlockMissigBlockName_037()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('$smarty.block is not defined');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('$smarty.block is not defined');
$this->smarty->fetch('037_parent.tpl');
}

View File

@@ -165,8 +165,8 @@ class CompileConfigLoadTest extends PHPUnit_Smarty
*/
public function testConfigSyntaxError_009()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('Syntax error in config file');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('Syntax error in config file');
$this->smarty->fetch('009_error.tpl');
}
}

View File

@@ -43,8 +43,8 @@ class CompileDelimiterTest extends PHPUnit_Smarty
public function testLeftDelimiterError()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('nocache option not allowed');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('nocache option not allowed');
$tpl = $this->smarty->createTemplate('string:x{ldelim nocache}x');
$this->assertEquals('x{x', $this->smarty->fetch($tpl));
}

View File

@@ -94,9 +94,9 @@ class CompileForeachTest extends PHPUnit_Smarty
array('{foreach item=x from=$foo}{$x}{foreachelse}else{/foreach}{if $x@show}-show{else}-noshow{/if}', array(), 'else-noshow', '', $i ++),
array('{foreach $foo x y foo}{$y}.{$x},{foreachelse}else{/foreach}total{$smarty.foreach.foo.total}', array(9,10,11), '0.9,1.10,2.11,total3', '', $i ++),
array('{$x = "hallo"}{$bar=[1,2,3]}{foreach $foo as $x}outer={$x@index}.{$x}#{foreach $bar as $x}inner={$x@index}.{$x}{/foreach}##{/foreach}###{$x}', array(9,10,11), 'outer=0.9#inner=0.1inner=1.2inner=2.3##outer=1.10#inner=0.1inner=1.2inner=2.3##outer=2.11#inner=0.1inner=1.2inner=2.3#####hallo', '', $i ++),
array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', null, 'else', '', $i ++),
array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', array(), 'else', '', $i ++),
array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', new \ArrayIterator(), 'else', '', $i ++),
array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', null, 'else', '', $i ++),
array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', array(), 'else', '', $i ++),
array('{foreach $foo as $x}{$x}{foreachelse}else{/foreach}', new \ArrayIterator(), 'else', '', $i ++),
);
}

View File

@@ -2,5 +2,5 @@
function smarty_insert_test2($params, $smarty) {
return $smarty->tpl_vars[$params['var']]->value;
return $smarty->tpl_vars[$params['var']]->value;
}

View File

@@ -45,8 +45,8 @@ class PluginFunctionFetchTest extends PHPUnit_Smarty
*/
public function testFetchInvalidUri()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('{fetch} cannot read resource \'https://foo.smarty.net/foo.dat\'');
$this->expectException('SmartyException');
$this->expectExceptionMessage('{fetch} cannot read resource \'https://foo.smarty.net/foo.dat\'');
$this->smarty->fetch('string:{fetch file="https://foo.smarty.net/foo.dat"}');
}
@@ -58,8 +58,8 @@ class PluginFunctionFetchTest extends PHPUnit_Smarty
*/
public function testFetchSecurity()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('not trusted file path');
$this->expectException('SmartyException');
$this->expectExceptionMessage('not trusted file path');
$this->cleanDirs();
$dir=$this->smarty->getTemplateDir();
$this->smarty->enableSecurity();
@@ -73,8 +73,8 @@ class PluginFunctionFetchTest extends PHPUnit_Smarty
*/
public function testFetchSecurity2()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('not trusted file path');
$this->expectException('SmartyException');
$this->expectExceptionMessage('not trusted file path');
$this->cleanDirs();
$this->smarty->getTemplateDir();
$this->smarty->enableSecurity();

View File

@@ -285,7 +285,7 @@ class PluginFunctionHtmlCheckboxesTest extends PHPUnit_Smarty
$this->_errors = array();
set_error_handler(array($this, 'error_handler'));
$this->smarty->setPHP7CompatMode();
$this->smarty->setPHP7CompatMode();
$tpl = $this->smarty->createTemplate('eval:{html_checkboxes name="id" options=$cust_radios selected=$customer_id separator="<br />"}');
$tpl->assign('customer_id', new _object_noString(1001));
$tpl->assign('cust_radios', array(

View File

@@ -20,11 +20,11 @@ class PluginModifierDefaultTest extends PHPUnit_Smarty
$this->setUpSmarty(dirname(__FILE__));
}
public function testDefault()
{
$tpl = $this->smarty->createTemplate('string:{$array.a.b|default:$array.c:\'defaultval\'}');
public function testDefault()
{
$tpl = $this->smarty->createTemplate('string:{$array.a.b|default:$array.c:\'defaultval\'}');
$this->smarty->assign('array', []);
$this->assertEquals('defaultval', $this->smarty->fetch($tpl));
}
$this->smarty->assign('array', []);
$this->assertEquals('defaultval', $this->smarty->fetch($tpl));
}
}

View File

@@ -32,8 +32,8 @@ class AttributeTest extends PHPUnit_Smarty
*/
public function testRequiredAttributeVar()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('missing \'var\' attribute');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('missing \'var\' attribute');
$this->smarty->fetch('string:{assign value=1}');
}
@@ -42,8 +42,8 @@ class AttributeTest extends PHPUnit_Smarty
*/
public function testUnexpectedAttribute()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unexpected \'bar\' attribute');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unexpected \'bar\' attribute');
$this->smarty->fetch('string:{assign var=foo value=1 bar=2}');
}
@@ -52,9 +52,9 @@ class AttributeTest extends PHPUnit_Smarty
*/
public function testIllegalOptionValue()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('for option flag \'nocache\'');
$this->expectExceptionMessage('illegal value');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('for option flag \'nocache\'');
$this->expectExceptionMessage('illegal value');
$this->smarty->fetch('string:{assign var=foo value=1 nocache=buh}');
}
@@ -63,8 +63,8 @@ class AttributeTest extends PHPUnit_Smarty
*/
public function testTooManyShorthands()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('too many shorthand attributes');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('too many shorthand attributes');
$this->smarty->fetch('string:{assign foo 1 2}');
}

View File

@@ -30,8 +30,8 @@ class CompileErrorTest extends PHPUnit_Smarty
*/
public function testNoneExistingTemplateError()
{
$this->expectException('SmartyException');
$this->expectExceptionMessage('no.tpl');
$this->expectException('SmartyException');
$this->expectExceptionMessage('no.tpl');
$this->smarty->fetch('eval:{include file=\'no.tpl\'}');
}
@@ -40,8 +40,8 @@ class CompileErrorTest extends PHPUnit_Smarty
*/
public function testUnknownTagError()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unknown tag \'unknown\'');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unknown tag \'unknown\'');
$this->smarty->fetch('eval:{unknown}');
}
@@ -50,8 +50,8 @@ class CompileErrorTest extends PHPUnit_Smarty
*/
public function testUnclosedTagError()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unclosed {if} tag');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unclosed {if} tag');
$this->smarty->fetch('eval:{if true}');
}
@@ -60,8 +60,8 @@ class CompileErrorTest extends PHPUnit_Smarty
*/
public function testSyntaxError()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('Unexpected "}"');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('Unexpected "}"');
$this->smarty->fetch('eval:{assign var=}');
}
}

View File

@@ -84,8 +84,8 @@ class DoubleQuotedStringTest extends PHPUnit_Smarty
*/
public function testDoubleQuotedUnclosedBlock_001()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unclosed \'{if}\' in doubled quoted string');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unclosed \'{if}\' in doubled quoted string');
$this->smarty->fetch('001_unclosedBlock.tpl');
}

View File

@@ -100,8 +100,8 @@ class ModifierTest extends PHPUnit_Smarty
*/
public function testUnknownModifier()
{
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unknown modifier \'unknown\'');
$this->expectException('SmartyCompilerException');
$this->expectExceptionMessage('unknown modifier \'unknown\'');
$this->smarty->fetch('eval:{"hello world"|unknown}');
}

View File

@@ -146,56 +146,56 @@ class PhpFunctionTest extends PHPUnit_Smarty
'));
}
/**
* test PHP isset() on (non-)variables
* @dataProvider dataTestIsset3
* @param string $strTemplate template to test
* @param string $result expected result
*/
public function testIsset3($strTemplate, $result)
{
$this->smarty->disableSecurity();
/**
* test PHP isset() on (non-)variables
* @dataProvider dataTestIsset3
* @param string $strTemplate template to test
* @param string $result expected result
*/
public function testIsset3($strTemplate, $result)
{
$this->smarty->disableSecurity();
$this->smarty->assign('varobject', new TestIsset());
$this->smarty->assign('vararray', $vararray = array(
'keythatexists' => false,
'keywitharray' => array(1 => 1),
'keywithobject' => new TestIsset()
));
$this->smarty->assign('varobject', new TestIsset());
$this->smarty->assign('vararray', $vararray = array(
'keythatexists' => false,
'keywitharray' => array(1 => 1),
'keywithobject' => new TestIsset()
));
$this->smarty->assign('key', 'A');
$this->smarty->assign('_varsimpleA', 1);
$this->smarty->assign('varsimpleB', 0);
$this->smarty->assign('varsimpleC', null);
$this->smarty->assign('key', 'A');
$this->smarty->assign('_varsimpleA', 1);
$this->smarty->assign('varsimpleB', 0);
$this->smarty->assign('varsimpleC', null);
$this->assertEquals($result, $this->smarty->fetch('string:' . $strTemplate));
}
$this->assertEquals($result, $this->smarty->fetch('string:' . $strTemplate));
}
/**
* Data provider for testIsset3
*/
public function dataTestIsset3()
{
return array(
array('{if isset($varobject->arr)}true{else}false{/if}', 'true'),
array('{if isset($vararray["keywitharray"])}true{else}false{/if}', 'true'),
array('{if isset($vararray["keythatexists"])}true{else}false{/if}', 'true'),
array('{if isset($vararray["nonexistingkey"])}true{else}false{/if}', 'false'),
array('{if isset($_GET["sscr6hr6cz34j6"])}true{else}false{/if}', 'false'),
array('{if isset(count([\'hi\']))}true{else}false{/if}', 'true'),
array('{if isset($vararray[\'keywitharray\'][intval(\'1\')])}true{else}false{/if}', 'true'),
array('{if isset($vararray[\'keywithobject\']->arr[\'isSet\'])}true{else}false{/if}', 'true'),
array('{if isset($vararray[\'keywithobject\']->arr[\'isNull\'])}true{else}false{/if}', 'false'),
array('{if isset($varobject->arr[\'isSet\'])}true{else}false{/if}', 'true'),
array('{if isset($varobject->arr[\'isNull\'])}true{else}false{/if}', 'false'),
array('{if isset($_varsimpleA)}true{else}false{/if}', 'true'),
array('{if isset($varsimpleB)}true{else}false{/if}', 'true'),
array('{if isset($varsimpleC)}true{else}false{/if}', 'false'),
array('{if isset($_varsimpleA && varsimpleB)}true{else}false{/if}', 'true'),
array('{if isset($_varsimpleA && varsimpleC)}true{else}false{/if}', 'true'),
array('{if isset($_varsimple{$key})}true{else}false{/if}', 'true'),
);
}
/**
* Data provider for testIsset3
*/
public function dataTestIsset3()
{
return array(
array('{if isset($varobject->arr)}true{else}false{/if}', 'true'),
array('{if isset($vararray["keywitharray"])}true{else}false{/if}', 'true'),
array('{if isset($vararray["keythatexists"])}true{else}false{/if}', 'true'),
array('{if isset($vararray["nonexistingkey"])}true{else}false{/if}', 'false'),
array('{if isset($_GET["sscr6hr6cz34j6"])}true{else}false{/if}', 'false'),
array('{if isset(count([\'hi\']))}true{else}false{/if}', 'true'),
array('{if isset($vararray[\'keywitharray\'][intval(\'1\')])}true{else}false{/if}', 'true'),
array('{if isset($vararray[\'keywithobject\']->arr[\'isSet\'])}true{else}false{/if}', 'true'),
array('{if isset($vararray[\'keywithobject\']->arr[\'isNull\'])}true{else}false{/if}', 'false'),
array('{if isset($varobject->arr[\'isSet\'])}true{else}false{/if}', 'true'),
array('{if isset($varobject->arr[\'isNull\'])}true{else}false{/if}', 'false'),
array('{if isset($_varsimpleA)}true{else}false{/if}', 'true'),
array('{if isset($varsimpleB)}true{else}false{/if}', 'true'),
array('{if isset($varsimpleC)}true{else}false{/if}', 'false'),
array('{if isset($_varsimpleA && varsimpleB)}true{else}false{/if}', 'true'),
array('{if isset($_varsimpleA && varsimpleC)}true{else}false{/if}', 'true'),
array('{if isset($_varsimple{$key})}true{else}false{/if}', 'true'),
);
}
}
/**

View File

@@ -28,8 +28,8 @@ class SmartyErrorTest extends PHPUnit_Smarty
* test undefined Smarty special variable
*/
public function testSmartyError() {
$this->expectException('SmartyException');
$this->expectExceptionMessage('$smarty.foo is not defined');
$this->expectException('SmartyException');
$this->expectExceptionMessage('$smarty.foo is not defined');
$this->assertEquals(Smarty::SMARTY_VERSION, $this->smarty->fetch('error.tpl'));
}
}

View File

@@ -291,9 +291,9 @@ class ScopeTest extends PHPUnit_Smarty
'no smarty', $i ++,),);
}
/**
* @doesNotPerformAssertions
*/
/**
* @doesNotPerformAssertions
*/
public function testFunctionScope()
{
$this->smarty->assign('scope', 'none');