Skip to content

Commit

Permalink
move property initialization to the declaration when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobion committed Aug 22, 2015
1 parent d65a137 commit 5951d1f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 20 deletions.
3 changes: 1 addition & 2 deletions lib/Twig/Compiler.php
Expand Up @@ -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;
Expand All @@ -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()
Expand Down
12 changes: 4 additions & 8 deletions lib/Twig/Environment.php
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -106,15 +106,11 @@ public function __construct(Twig_LoaderInterface $loader = null, $options = arra
$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();
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Twig/Extension/Profiler.php
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions lib/Twig/NodeTraverser.php
Expand Up @@ -19,7 +19,7 @@
class Twig_NodeTraverser
{
protected $env;
protected $visitors;
protected $visitors = array();

/**
* Constructor.
Expand All @@ -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);
}
Expand Down
6 changes: 2 additions & 4 deletions lib/Twig/Template.php
Expand Up @@ -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.
Expand All @@ -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();
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/Twig/TokenStream.php
Expand Up @@ -18,7 +18,7 @@
class Twig_TokenStream
{
protected $tokens;
protected $current;
protected $current = 0;
protected $filename;

/**
Expand All @@ -30,7 +30,6 @@ class Twig_TokenStream
public function __construct(array $tokens, $filename = null)
{
$this->tokens = $tokens;
$this->current = 0;
$this->filename = $filename;
}

Expand Down

0 comments on commit 5951d1f

Please sign in to comment.