merged branch m0ppers/master (PR #611)
merged branch m0ppers/master (PR #611)

Commits
-------

71449e8 Remove optimization (covered by Optimization VAR_ACCESS anyway)

Discussion
----------

Remove optimization (covered by Optimization VAR_ACCESS anyway)

I have an own template class implementing getContext() and this one drove me completely mad after a twig upgrade.

After compilation the resulting templates have:

isset($context['bla'])

vs.

$this->getContext('bla')

Changing the Name Node however didn't have any effect and i saw that due to the optimizations by the SetTemp class twig doesn't even reach the Name Node. In fact SetTemp has the isset optimization hardcoded (which is ok).

I could simply fix my issue by setting optimizations to -9 (all optimizations except VAR_ACCESS). However the issue will reappear immediately when using PHP 5.4. Please remove the isset stuff from the non optimized node and let the optimization handler handle it (which i would disable in my case)

---------------------------------------------------------------------------

by m0ppers at 2012-01-24T17:42:07Z

some hackish script to test what i mean

<?php
require 'lib/Twig/Autoloader.php';
Twig_Autoloader::register();

abstract class Harxtemplate extends Twig_Template
{
    public function getContext($context, $item, $ignoreStrictCheck = false)
    {
        if ($item == "hans") {
            return "hund";
        } else {
            return parent::getContext($context, $item, $ignorStrictCheck);
        }
    }
}

$template = <<<EOT
Der {{ hans }} hat hund
{% if hans %}
hund
{% endif %}
EOT;

$loader = new Twig_Loader_String();
$options = array('base_template_class' => 'Harxtemplate',
//                 'strict_variables' => true, // doesn't work
                 'debug' => true,
                 'optimizations' => -1, // 0 => works
                );
$twig = new Twig_Environment($loader, $options);

echo $twig->render($template);

hhamon/Twig,gencer/Twig,dkarvounaris/Twig,jamessingizi/Twig,nicolas-grekas/Twig,nicolas-grekas/Twig,apishka/templater,maartendekeizer/Twig,Rvanlaak/Twig,robregonm/Twig,hason/Twig,bocharsky-bw/Twig,znerol/Twig,Tobion/Twig,twigphp/Twig,jamessingizi/Twig,peterkokot/Twig,craue/Twig,framewr/Twig,robregonm/Twig,dkarvounaris/Twig,Rvanlaak/Twig,andrerom/Twig,moufmouf/Twig,markstory/Twig,znerol/Twig,loi-chuanoi/Twig,maartendekeizer/Twig,znerol/Twig,bocharsky-bw/Twig,hason/Twig,twigphp/Twig,fsw/Twig,huang53798584/Twig,jamessingizi/Twig,phansys/Twig,phansys/Twig,Tobion/Twig,peterkokot/Twig,huang53798584/Twig,moltin/Twig,derickr/Twig,moltin/Twig,gamernetwork/Twig,derickr/Twig,andrerom/Twig,nicolas-grekas/Twig,gamernetwork/Twig,iKwinto/Twig,dkarvounaris/Twig,bocharsky-bw/Twig,robregonm/Twig,hhamon/Twig,hhamon/Twig,moufmouf/Twig,gencer/Twig,hason/Twig,twigphp/Twig,moufmouf/Twig,sstok/Twig,gamernetwork/Twig,fsw/Twig,moltin/Twig,framewr/Twig,framewr/Twig,nicolas-grekas/Twig,derickr/Twig,apishka/templater,iKwinto/Twig,Tobion/Twig,sstok/Twig,markstory/Twig,fsw/Twig,craue/Twig,Rvanlaak/Twig,huang53798584/Twig,nicolas-grekas/Twig,iKwinto/Twig