minor #1786 move property initialization to the declaration when possible (Tobion)

This PR was merged into the 1.x branch.

Discussion
----------

move property initialization to the declaration when possible

From #1781

Commits
-------

5951d1f move property initialization to the declaration when possible
This commit is contained in:
Fabien Potencier
2015-08-22 17:40:25 +02:00
6 changed files with 11 additions and 20 deletions
+1 -2
View File
@@ -21,7 +21,7 @@ class Twig_Compiler implements Twig_CompilerInterface
protected $source;
protected $indentation;
protected $env;
protected $debugInfo;
protected $debugInfo = array();
protected $sourceOffset;
protected $sourceLine;
protected $filename;
@@ -34,7 +34,6 @@ class Twig_Compiler implements Twig_CompilerInterface
public function __construct(Twig_Environment $env)
{
$this->env = $env;
$this->debugInfo = array();
}
public function getFilename()
+4 -8
View File
@@ -34,15 +34,15 @@ class Twig_Environment
protected $tests;
protected $functions;
protected $globals;
protected $runtimeInitialized;
protected $extensionInitialized;
protected $runtimeInitialized = false;
protected $extensionInitialized = false;
protected $loadedTemplates;
protected $strictVariables;
protected $unaryOperators;
protected $binaryOperators;
protected $templateClassPrefix = '__TwigTemplate_';
protected $functionCallbacks;
protected $filterCallbacks;
protected $functionCallbacks = array();
protected $filterCallbacks = array();
protected $staging;
/**
@@ -106,15 +106,11 @@ class Twig_Environment
$this->baseTemplateClass = $options['base_template_class'];
$this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload'];
$this->strictVariables = (bool) $options['strict_variables'];
$this->runtimeInitialized = false;
$this->setCache($options['cache']);
$this->functionCallbacks = array();
$this->filterCallbacks = array();
$this->addExtension(new Twig_Extension_Core());
$this->addExtension(new Twig_Extension_Escaper($options['autoescape']));
$this->addExtension(new Twig_Extension_Optimizer($options['optimizations']));
$this->extensionInitialized = false;
$this->staging = new Twig_Extension_Staging();
}
+2 -2
View File
@@ -11,11 +11,11 @@
class Twig_Extension_Profiler extends Twig_Extension
{
private $actives;
private $actives = array();
public function __construct(Twig_Profiler_Profile $profile)
{
$this->actives = array($profile);
$this->actives[] = $profile;
}
public function enter(Twig_Profiler_Profile $profile)
+1 -2
View File
@@ -19,7 +19,7 @@
class Twig_NodeTraverser
{
protected $env;
protected $visitors;
protected $visitors = array();
/**
* Constructor.
@@ -30,7 +30,6 @@ class Twig_NodeTraverser
public function __construct(Twig_Environment $env, array $visitors = array())
{
$this->env = $env;
$this->visitors = array();
foreach ($visitors as $visitor) {
$this->addVisitor($visitor);
}
+2 -4
View File
@@ -22,8 +22,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
protected $parent;
protected $parents = array();
protected $env;
protected $blocks;
protected $traits;
protected $blocks = array();
protected $traits = array();
/**
* Constructor.
@@ -33,8 +33,6 @@ abstract class Twig_Template implements Twig_TemplateInterface
public function __construct(Twig_Environment $env)
{
$this->env = $env;
$this->blocks = array();
$this->traits = array();
}
/**
+1 -2
View File
@@ -18,7 +18,7 @@
class Twig_TokenStream
{
protected $tokens;
protected $current;
protected $current = 0;
protected $filename;
/**
@@ -30,7 +30,6 @@ class Twig_TokenStream
public function __construct(array $tokens, $filename = null)
{
$this->tokens = $tokens;
$this->current = 0;
$this->filename = $filename;
}