mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 03:46:39 +00:00
Merge branch '1.x'
* 1.x: updated CHANGELOG [DOC] Fixed typos in advanced.rst Improve deprecations message Add the version in the message Make file cache tolerant for trailing (back)slashes on directory configuration.
This commit is contained in:
@@ -16,7 +16,9 @@
|
||||
|
||||
* 1.23.2 (2015-XX-XX)
|
||||
|
||||
* n/a
|
||||
* added versions in deprecated messages
|
||||
* made file cache tolerant for trailing (back)slashes on directory configuration
|
||||
* deprecated unused Twig_Node_Expression_ExtensionReference class
|
||||
|
||||
* 1.23.1 (2015-11-05)
|
||||
|
||||
|
||||
+1
-1
@@ -541,7 +541,7 @@ An extension is a class that implements the following interface::
|
||||
*
|
||||
* @param Twig_Environment $environment The current Twig_Environment instance
|
||||
*
|
||||
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterace instead
|
||||
* @deprecated since 1.23 (to be removed in 2.0), implement Twig_Extension_InitRuntimeInterface instead
|
||||
*/
|
||||
public function initRuntime(Twig_Environment $environment);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
||||
*/
|
||||
public function __construct($directory, $options = 0)
|
||||
{
|
||||
$this->directory = $directory;
|
||||
$this->directory = rtrim($directory, '\/').'/';
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class Twig_Cache_Filesystem implements Twig_CacheInterface
|
||||
{
|
||||
$hash = hash('sha256', $className);
|
||||
|
||||
return $this->directory.'/'.$hash[0].$hash[1].'/'.$hash.'.php';
|
||||
return $this->directory.$hash[0].$hash[1].'/'.$hash.'.php';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -574,6 +574,9 @@ class Twig_ExpressionParser
|
||||
|
||||
if ($function->isDeprecated()) {
|
||||
$message = sprintf('Twig Function "%s" is deprecated', $function->getName());
|
||||
if (!is_bool($functon->getDeprecatedVersion())) {
|
||||
$message .= sprintf(' since version %s', $function->getDeprecatedVersion());
|
||||
}
|
||||
if ($function->getAlternative()) {
|
||||
$message .= sprintf('. Use "%s" instead', $function->getAlternative());
|
||||
}
|
||||
@@ -598,6 +601,9 @@ class Twig_ExpressionParser
|
||||
|
||||
if ($filter->isDeprecated()) {
|
||||
$message = sprintf('Twig Filter "%s" is deprecated', $filter->getName());
|
||||
if (!is_bool($filter->getDeprecatedVersion())) {
|
||||
$message .= sprintf(' since version %s', $filter->getDeprecatedVersion());
|
||||
}
|
||||
if ($filter->getAlternative()) {
|
||||
$message .= sprintf('. Use "%s" instead', $filter->getAlternative());
|
||||
}
|
||||
|
||||
@@ -115,6 +115,11 @@ class Twig_Filter
|
||||
}
|
||||
|
||||
public function isDeprecated()
|
||||
{
|
||||
return (bool) $this->options['deprecated'];
|
||||
}
|
||||
|
||||
public function getDeprecatedVersion()
|
||||
{
|
||||
return $this->options['deprecated'];
|
||||
}
|
||||
|
||||
@@ -105,6 +105,11 @@ class Twig_Function
|
||||
}
|
||||
|
||||
public function isDeprecated()
|
||||
{
|
||||
return (bool) $this->options['deprecated'];
|
||||
}
|
||||
|
||||
public function getDeprecatedVersion()
|
||||
{
|
||||
return $this->options['deprecated'];
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
@trigger_error('The Twig_Node_Expression_ExtensionReference class is deprecated and will be removed in 2.0.', E_USER_DEPRECATED);
|
||||
@trigger_error('The Twig_Node_Expression_ExtensionReference class is deprecated since version 1.23 and will be removed in 2.0.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Represents an extension call node.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @deprecated (to be removed in 2.0)
|
||||
* @deprecated since 1.23 and will be removed in 2.0.
|
||||
*/
|
||||
class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression
|
||||
{
|
||||
|
||||
@@ -67,6 +67,11 @@ class Twig_Test
|
||||
}
|
||||
|
||||
public function isDeprecated()
|
||||
{
|
||||
return (bool) $this->options['deprecated'];
|
||||
}
|
||||
|
||||
public function getDeprecatedVersion()
|
||||
{
|
||||
return $this->options['deprecated'];
|
||||
}
|
||||
|
||||
@@ -159,6 +159,31 @@ class Twig_Tests_Cache_FilesystemTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertSame(0, $this->cache->getTimestamp($key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test file cache is tolerant towards trailing (back)slashes on the configured cache directory.
|
||||
*
|
||||
* @dataProvider provideDirectories
|
||||
*/
|
||||
public function testGenerateKey($expected, $input)
|
||||
{
|
||||
$cache = new Twig_Cache_Filesystem($input);
|
||||
$this->assertRegExp($expected, $cache->generateKey('_test_', get_class($this)));
|
||||
}
|
||||
|
||||
public function provideDirectories()
|
||||
{
|
||||
$pattern = '#a/b/[a-zA-Z0-9]+/[a-zA-Z0-9]+.php$#';
|
||||
|
||||
return array(
|
||||
array($pattern, 'a/b'),
|
||||
array($pattern, 'a/b/'),
|
||||
array($pattern, 'a/b\\'),
|
||||
array($pattern, 'a/b\\/'),
|
||||
array($pattern, 'a/b\\//'),
|
||||
array('#/'.substr($pattern, 1), '/a/b'),
|
||||
);
|
||||
}
|
||||
|
||||
private function generateSource()
|
||||
{
|
||||
return strtr('<?php class {{classname}} {}', array(
|
||||
|
||||
Reference in New Issue
Block a user