mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-11 07:51:32 +02:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3232277bc5 | ||
|
|
bbd09c7bfa | ||
|
|
52dc8adafb | ||
|
|
6f054ecc2f | ||
|
|
4fec27ccc2 | ||
|
|
fea0d02d99 | ||
|
|
4efa427a87 | ||
|
|
30b1c5bf6d | ||
|
|
3f871f9f7a |
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [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
|
## [5.0.0] - 2024-03-25
|
||||||
- Fixed that scoped variables would overwrite parent scope [#952](https://github.com/smarty-php/smarty/issues/952)
|
- Fixed that scoped variables would overwrite parent scope [#952](https://github.com/smarty-php/smarty/issues/952)
|
||||||
- Removed publicly accessible `$tpl->_var_stack` variable
|
- Removed publicly accessible `$tpl->_var_stack` variable
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
- Fix warning when calling hasVariable for an undefined variable [#977](https://github.com/smarty-php/smarty/issues/977)
|
||||||
+1
-1
@@ -15,7 +15,7 @@ php utilities/update-smarty-version-number.php $1
|
|||||||
git add changelog CHANGELOG.md src/Smarty.php
|
git add changelog CHANGELOG.md src/Smarty.php
|
||||||
git commit -m "version bump"
|
git commit -m "version bump"
|
||||||
|
|
||||||
git checkout master
|
git checkout support/5
|
||||||
git pull
|
git pull
|
||||||
git merge --no-ff "release/$1"
|
git merge --no-ff "release/$1"
|
||||||
git branch -d "release/$1"
|
git branch -d "release/$1"
|
||||||
|
|||||||
+2
-2
@@ -109,7 +109,7 @@ class Data
|
|||||||
foreach ($tpl_var as $_key => $_val) {
|
foreach ($tpl_var as $_key => $_val) {
|
||||||
$this->assign($_key, $_val, $nocache, $scope);
|
$this->assign($_key, $_val, $nocache, $scope);
|
||||||
}
|
}
|
||||||
return;
|
return $this;
|
||||||
}
|
}
|
||||||
switch ($scope ?? $this->getDefaultScope()) {
|
switch ($scope ?? $this->getDefaultScope()) {
|
||||||
case self::SCOPE_GLOBAL:
|
case self::SCOPE_GLOBAL:
|
||||||
@@ -290,7 +290,7 @@ class Data
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasVariable($varName): bool {
|
public function hasVariable($varName): bool {
|
||||||
return !($this->getVariable($varName) instanceof UndefinedVariable);
|
return !($this->getVariable($varName, true, false) instanceof UndefinedVariable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+15
-13
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Smarty;
|
namespace Smarty;
|
||||||
|
|
||||||
|
use FilesystemIterator;
|
||||||
use RecursiveDirectoryIterator;
|
use RecursiveDirectoryIterator;
|
||||||
use RecursiveIteratorIterator;
|
use RecursiveIteratorIterator;
|
||||||
use Smarty\Cacheresource\File;
|
use Smarty\Cacheresource\File;
|
||||||
@@ -12,11 +13,12 @@ use Smarty\Extension\CoreExtension;
|
|||||||
use Smarty\Extension\DefaultExtension;
|
use Smarty\Extension\DefaultExtension;
|
||||||
use Smarty\Extension\ExtensionInterface;
|
use Smarty\Extension\ExtensionInterface;
|
||||||
use Smarty\Filter\Output\TrimWhitespace;
|
use Smarty\Filter\Output\TrimWhitespace;
|
||||||
use Smarty\Resource\BasePlugin;
|
use Smarty\Runtime\CaptureRuntime;
|
||||||
use Smarty\Smarty\Runtime\CaptureRuntime;
|
use Smarty\Runtime\DefaultPluginHandlerRuntime;
|
||||||
use Smarty\Smarty\Runtime\ForeachRuntime;
|
use Smarty\Runtime\ForeachRuntime;
|
||||||
use Smarty\Smarty\Runtime\InheritanceRuntime;
|
use Smarty\Runtime\InheritanceRuntime;
|
||||||
use Smarty\Smarty\Runtime\TplFunctionRuntime;
|
use Smarty\Runtime\TplFunctionRuntime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Project: Smarty: the PHP compiling template engine
|
* Project: Smarty: the PHP compiling template engine
|
||||||
@@ -53,7 +55,7 @@ class Smarty extends \Smarty\TemplateBase {
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '5.0.0';
|
const SMARTY_VERSION = '5.0.2';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define caching modes
|
* define caching modes
|
||||||
@@ -1755,15 +1757,15 @@ class Smarty extends \Smarty\TemplateBase {
|
|||||||
// Lazy load runtimes when/if needed
|
// Lazy load runtimes when/if needed
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'Capture':
|
case 'Capture':
|
||||||
return $this->runtimes[$type] = new \Smarty\Runtime\CaptureRuntime();
|
return $this->runtimes[$type] = new CaptureRuntime();
|
||||||
case 'Foreach':
|
case 'Foreach':
|
||||||
return $this->runtimes[$type] = new \Smarty\Runtime\ForeachRuntime();
|
return $this->runtimes[$type] = new ForeachRuntime();
|
||||||
case 'Inheritance':
|
case 'Inheritance':
|
||||||
return $this->runtimes[$type] = new \Smarty\Runtime\InheritanceRuntime();
|
return $this->runtimes[$type] = new InheritanceRuntime();
|
||||||
case 'TplFunction':
|
case 'TplFunction':
|
||||||
return $this->runtimes[$type] = new \Smarty\Runtime\TplFunctionRuntime();
|
return $this->runtimes[$type] = new TplFunctionRuntime();
|
||||||
case 'DefaultPluginHandler':
|
case 'DefaultPluginHandler':
|
||||||
return $this->runtimes[$type] = new \Smarty\Runtime\DefaultPluginHandlerRuntime(
|
return $this->runtimes[$type] = new DefaultPluginHandlerRuntime(
|
||||||
$this->getDefaultPluginHandlerFunc()
|
$this->getDefaultPluginHandlerFunc()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2052,7 +2054,7 @@ class Smarty extends \Smarty\TemplateBase {
|
|||||||
* @param array|string $modifiers modifier or list of modifiers
|
* @param array|string $modifiers modifier or list of modifiers
|
||||||
* to add
|
* to add
|
||||||
*
|
*
|
||||||
* @return \Smarty|Template
|
* @return Smarty
|
||||||
* @api Smarty::addDefaultModifiers()
|
* @api Smarty::addDefaultModifiers()
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -2131,7 +2133,7 @@ class Smarty extends \Smarty\TemplateBase {
|
|||||||
* @throws \Smarty\Exception
|
* @throws \Smarty\Exception
|
||||||
*/
|
*/
|
||||||
public function display($template = null, $cache_id = null, $compile_id = null) {
|
public function display($template = null, $cache_id = null, $compile_id = null) {
|
||||||
return $this->returnOrCreateTemplate($template, $cache_id, $compile_id)->display();
|
$this->returnOrCreateTemplate($template, $cache_id, $compile_id)->display();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -377,9 +377,9 @@ abstract class TemplateBase extends Data {
|
|||||||
* Registers a resource to fetch a template
|
* Registers a resource to fetch a template
|
||||||
*
|
*
|
||||||
* @param string $name name of resource type
|
* @param string $name name of resource type
|
||||||
* @param Smarty\Resource\Base $resource_handler instance of Smarty\Resource\Base
|
* @param \Smarty\Resource\BasePlugin $resource_handler instance of Smarty\Resource\BasePlugin
|
||||||
*
|
*
|
||||||
* @return \Smarty|\Smarty\Template
|
* @return \Smarty\Smarty|\Smarty\Template
|
||||||
* @link https://www.smarty.net/docs/en/api.register.resource.tpl
|
* @link https://www.smarty.net/docs/en/api.register.resource.tpl
|
||||||
*
|
*
|
||||||
* @api Smarty::registerResource()
|
* @api Smarty::registerResource()
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ function smarty_make_timestamp($string)
|
|||||||
|| (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)
|
|| (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)
|
||||||
) {
|
) {
|
||||||
return (int)$string->format('U'); // PHP 5.2 BC
|
return (int)$string->format('U'); // PHP 5.2 BC
|
||||||
} elseif (strlen($string) === 14 && ctype_digit($string)) {
|
} elseif (strlen($string) === 14 && ctype_digit((string)$string)) {
|
||||||
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
||||||
return mktime(
|
return mktime(
|
||||||
substr($string, 8, 2),
|
substr($string, 8, 2),
|
||||||
|
|||||||
@@ -42,4 +42,15 @@ class AssignTest extends PHPUnit_Smarty
|
|||||||
$this->smarty->assign(array('foo' => 'bar', 'foo2' => 'bar2'));
|
$this->smarty->assign(array('foo' => 'bar', 'foo2' => 'bar2'));
|
||||||
$this->assertEquals('bar bar2', $this->smarty->fetch('eval:{$foo} {$foo2}'));
|
$this->assertEquals('bar bar2', $this->smarty->fetch('eval:{$foo} {$foo2}'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that assign returns this.
|
||||||
|
*/
|
||||||
|
public function testAssignReturnsThis()
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
'data',
|
||||||
|
$this->smarty->assign(['dummy' => 'data'])->fetch('eval:{$dummy}')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
# Ignore anything in here, but keep this directory
|
|
||||||
*
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# Ignore anything in here, but keep this directory
|
|
||||||
*
|
|
||||||
@@ -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'));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user