diff options
| author | Simon Wisselink <s.wisselink@iwink.nl> | 2024-05-30 13:11:33 +0200 |
|---|---|---|
| committer | Simon Wisselink <s.wisselink@iwink.nl> | 2024-05-30 13:11:33 +0200 |
| commit | 4aa1273a8003941b85e454b9267e13b812932182 (patch) | |
| tree | 45ce66f44c9495e272643f234126c5176fe9f6e5 | |
| parent | 2a87c65994811a1eb26a59f58ecbf663445e8739 (diff) | |
| parent | 3232277bc526602801225ac4fbc7aae3867f582e (diff) | |
| download | smarty-4aa1273a8003941b85e454b9267e13b812932182.tar.gz smarty-4aa1273a8003941b85e454b9267e13b812932182.tar.bz2 smarty-4aa1273a8003941b85e454b9267e13b812932182.zip | |
Merge branch 'support/5'
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | changelog/977.md | 1 | ||||
| -rw-r--r-- | src/Data.php | 2 | ||||
| -rw-r--r-- | tests/UnitTests/SmartyMethodsTests/GetTemplateVars/cache/.gitignore | 2 | ||||
| -rw-r--r-- | tests/UnitTests/SmartyMethodsTests/GetTemplateVars/templates_c/.gitignore | 2 | ||||
| -rw-r--r-- | tests/UnitTests/SmartyMethodsTests/TemplateVars/GetTemplateVarsTest.php (renamed from tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsTest.php) | 0 | ||||
| -rw-r--r-- | tests/UnitTests/SmartyMethodsTests/TemplateVars/HasVariableTest.php | 32 |
7 files changed, 36 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f359cec2..85fe2970 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,16 +22,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Internal compiler classes always return a string (the internal has_code flag has been removed for simplicity) [#918](https://github.com/smarty-php/smarty/pull/918) - Fix invalid classnames in Runtime code for foreach [#1000](https://github.com/smarty-php/smarty/issues/1000) +## [5.0.2] - 2024-03-28 +- Fix Smarty::assign() not returning $this when called with an array as first parameter [#972](https://github.com/smarty-php/smarty/pull/972) ## [5.0.1] - 2024-03-27 - Fix error in Smarty\Smarty::compileAllTemplates() by including missing FilesystemIterator class [#966](https://github.com/smarty-php/smarty/issues/966) - ## [5.0.0] - 2024-03-25 - Fixed that scoped variables would overwrite parent scope [#952](https://github.com/smarty-php/smarty/issues/952) - Removed publicly accessible `$tpl->_var_stack` variable - ### Fixed - Too many shorthand attributes error when using a modifier as a function with more than 3 parameters in an expression [#949](https://github.com/smarty-php/smarty/issues/949) diff --git a/changelog/977.md b/changelog/977.md new file mode 100644 index 00000000..d41453c1 --- /dev/null +++ b/changelog/977.md @@ -0,0 +1 @@ +- Fix warning when calling hasVariable for an undefined variable [#977](https://github.com/smarty-php/smarty/issues/977)
\ No newline at end of file diff --git a/src/Data.php b/src/Data.php index f8abe0f6..6ae823d8 100644 --- a/src/Data.php +++ b/src/Data.php @@ -290,7 +290,7 @@ class Data * @return bool */ public function hasVariable($varName): bool { - return !($this->getVariable($varName) instanceof UndefinedVariable); + return !($this->getVariable($varName, true, false) instanceof UndefinedVariable); } /** diff --git a/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/cache/.gitignore b/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/cache/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/cache/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/templates_c/.gitignore b/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/templates_c/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/templates_c/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsTest.php b/tests/UnitTests/SmartyMethodsTests/TemplateVars/GetTemplateVarsTest.php index db60b822..db60b822 100644 --- a/tests/UnitTests/SmartyMethodsTests/GetTemplateVars/GetTemplateVarsTest.php +++ b/tests/UnitTests/SmartyMethodsTests/TemplateVars/GetTemplateVarsTest.php diff --git a/tests/UnitTests/SmartyMethodsTests/TemplateVars/HasVariableTest.php b/tests/UnitTests/SmartyMethodsTests/TemplateVars/HasVariableTest.php new file mode 100644 index 00000000..047af7b9 --- /dev/null +++ b/tests/UnitTests/SmartyMethodsTests/TemplateVars/HasVariableTest.php @@ -0,0 +1,32 @@ +<?php + +/** + * Tests the ::hasVariable method + */ +class HasVariableTest extends PHPUnit_Smarty +{ + public function setUp(): void + { + $this->setUpSmarty(__DIR__); + } + + + public function testInit() + { + $this->cleanDirs(); + } + + public function testSimpleTrue() + { + $this->smarty->assign('foo', 'bar'); + $this->assertTrue($this->smarty->hasVariable('foo')); + } + + + public function testSimpleFalse() + { + $this->smarty->assign('foo', 'bar'); + $this->assertFalse($this->smarty->hasVariable('foox')); + } + +} |
