renamed ignore_invalid_vars to strict_variables

This commit is contained in:
Fabien Potencier
2010-05-28 07:59:29 +02:00
parent 0ff74caca2
commit 28bbe6f2de
4 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ Backward incompatibilities:
* fixed iterator_to_array() usage
* changed the date filter to support any date format supported by DateTime
* added ignore_invalid_variables setting to throw an exception when an invalid variable is used in a template (disabled automatically when debug is true)
* added strict_variable setting to throw an exception when an invalid variable is used in a template (disabled by default when debug is false)
* added the lexer, parser, and compiler as arguments to the Twig_Environment constructor
* changed the cache option to only accepts an explicit path to a cache directory or false
* added a way to add token parsers, filters, and visitors without creating an extension
+4 -4
View File
@@ -93,12 +93,12 @@ The following options are available:
the `auto_reload` option, it will be determined automatically based on the
`debug` value.
* `ignore_invalid_variables` (new in Twig 0.9.7): If set to `true`, Twig will
* `strict_variables` (new in Twig 0.9.7): If set to `false`, Twig will
silently ignore invalid variables (variables and or attributes/methods that
do not exist) and replace them with a `null` value. When set to `false`,
do not exist) and replace them with a `null` value. When set to `true`,
Twig throws an exception instead. If you don't provide a value for the
`ignore_invalid_variables` option, it will be determined automatically
based on the `debug` value (`false` when in debug mode, `true` otherwise).
`strict_variables` option, it will be determined automatically based on the
`debug` value.
>**CAUTION**
>Before Twig 0.9.3, the `cache` and `auto_reload` options did not exist. They
+9 -9
View File
@@ -29,7 +29,7 @@ class Twig_Environment
protected $filters;
protected $runtimeInitialized;
protected $loadedTemplates;
protected $ignoreInvalidVars;
protected $strictVariables;
/**
* Constructor.
@@ -56,7 +56,7 @@ class Twig_Environment
* If you don't provide the auto_reload option, it will be
* determined automatically base on the debug value.
*
* * ignore_invalid_variables: Whether to ignore invalid variables in templates (default to the opposite value of debug).
* * strict_variables: Whether to ignore invalid variables in templates (default to the opposite value of debug).
*
* @param Twig_LoaderInterface $loader A Twig_LoaderInterface instance
* @param array $options An array of options
@@ -77,7 +77,7 @@ class Twig_Environment
$this->baseTemplateClass = isset($options['base_template_class']) ? $options['base_template_class'] : 'Twig_Template';
$this->autoReload = isset($options['auto_reload']) ? (bool) $options['auto_reload'] : $this->debug;
$this->extensions = array('core' => new Twig_Extension_Core());
$this->ignoreInvalidVars = isset($options['ignore_invalid_variables']) ? (bool) $options['ignore_invalid_variables'] : !$this->debug;
$this->strictVariables = isset($options['strict_variables']) ? (bool) $options['strict_variables'] : $this->debug;
$this->runtimeInitialized = false;
if (isset($options['cache']) && $options['cache']) {
$this->setCache($options['cache']);
@@ -119,19 +119,19 @@ class Twig_Environment
$this->autoReload = (Boolean) $autoReload;
}
public function enableignoreInvalidVars()
public function enableStrictVariables()
{
$this->ignoreInvalidVars = true;
$this->strictVariables = true;
}
public function disableignoreInvalidVars()
public function disableStrictVariables()
{
$this->ignoreInvalidVars = false;
$this->strictVariables = false;
}
public function ignoresInvalidVars()
public function isStrictVariables()
{
return $this->ignoreInvalidVars;
return $this->strictVariables;
}
public function getCache()
+3 -3
View File
@@ -35,7 +35,7 @@ abstract class Twig_Resource
return $context[$item];
}
if ($this->env->ignoresInvalidVars()) {
if (!$this->env->isStrictVariables()) {
return null;
}
@@ -51,7 +51,7 @@ abstract class Twig_Resource
}
if ($arrayOnly || !is_object($object)) {
if ($this->env->ignoresInvalidVars()) {
if (!$this->env->isStrictVariables()) {
return null;
}
@@ -84,7 +84,7 @@ abstract class Twig_Resource
} elseif (isset($this->cache[$class]['__call'])) {
$method = $item;
} else {
if ($this->env->ignoresInvalidVars()) {
if (!$this->env->isStrictVariables()) {
return null;
}