* 1.7.0-DEV
- * removed hardcoded optimization in Twig_Expression_Node_Name as it is already covered by the Optimizer
* removed the creation of Twig_Markup instances when not needed
* added a way to set the default global timezone for dates
* fixed the slice filter on strings when the length is not specified
} elseif ($this->isSpecial()) {
$compiler->raw($this->specialVars[$name]);
} else {
+ // remove the non-PHP 5.4 version when PHP 5.3 support is dropped
+ // as the non-optimized version is just a workaround for slow ternary operator
+ // when the context has a lot of variables
if (version_compare(phpversion(), '5.4.0RC1', '>=') && ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables())) {
// PHP 5.4 ternary operator performance was optimized
$compiler
/**
* Returns a variable from the context.
*
+ * This method is for internal use only and should never be called
+ * directly.
+ *
+ * This method should not be overriden in a sub-class as this is an
+ * implementation detail that has been introduced to optimize variable
+ * access for versions of PHP before 5.4. This is not a way to override
+ * the way to get a variable value.
+ *
* @param array $context The context
* @param string $item The variable to return from the context
* @param Boolean $ignoreStrictCheck Whether to ignore the strict variable check or not
*
* @throws Twig_Error_Runtime if the variable does not exist and Twig is running in strict mode
*/
- protected function getContext($context, $item, $ignoreStrictCheck = false)
+ final protected function getContext($context, $item, $ignoreStrictCheck = false)
{
if (!array_key_exists($item, $context)) {
if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {