Skip to content

Commit 4aa1273

Browse files
committed
Merge branch 'support/5'
2 parents 2a87c65 + 3232277 commit 4aa1273

File tree

7 files changed

+36
-7
lines changed

7 files changed

+36
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
- 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)
2323
- Fix invalid classnames in Runtime code for foreach [#1000](https://github.com/smarty-php/smarty/issues/1000)
2424

25+
## [5.0.2] - 2024-03-28
26+
- Fix Smarty::assign() not returning $this when called with an array as first parameter [#972](https://github.com/smarty-php/smarty/pull/972)
2527

2628
## [5.0.1] - 2024-03-27
2729
- Fix error in Smarty\Smarty::compileAllTemplates() by including missing FilesystemIterator class [#966](https://github.com/smarty-php/smarty/issues/966)
2830

29-
3031
## [5.0.0] - 2024-03-25
3132
- Fixed that scoped variables would overwrite parent scope [#952](https://github.com/smarty-php/smarty/issues/952)
3233
- Removed publicly accessible `$tpl->_var_stack` variable
3334

34-
3535
### Fixed
3636
- 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)
3737

changelog/977.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix warning when calling hasVariable for an undefined variable [#977](https://github.com/smarty-php/smarty/issues/977)

src/Data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public function setVariable($varName, Variable $variableObject) {
290290
* @return bool
291291
*/
292292
public function hasVariable($varName): bool {
293-
return !($this->getVariable($varName) instanceof UndefinedVariable);
293+
return !($this->getVariable($varName, true, false) instanceof UndefinedVariable);
294294
}
295295

296296
/**

tests/UnitTests/SmartyMethodsTests/GetTemplateVars/cache/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/UnitTests/SmartyMethodsTests/GetTemplateVars/templates_c/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/**
4+
* Tests the ::hasVariable method
5+
*/
6+
class HasVariableTest extends PHPUnit_Smarty
7+
{
8+
public function setUp(): void
9+
{
10+
$this->setUpSmarty(__DIR__);
11+
}
12+
13+
14+
public function testInit()
15+
{
16+
$this->cleanDirs();
17+
}
18+
19+
public function testSimpleTrue()
20+
{
21+
$this->smarty->assign('foo', 'bar');
22+
$this->assertTrue($this->smarty->hasVariable('foo'));
23+
}
24+
25+
26+
public function testSimpleFalse()
27+
{
28+
$this->smarty->assign('foo', 'bar');
29+
$this->assertFalse($this->smarty->hasVariable('foox'));
30+
}
31+
32+
}

0 commit comments

Comments
 (0)